Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize TEXT insertion #382

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand All @@ -66,6 +67,9 @@ public class IoTDBSessionBase extends IoTDB {
static final Config config = ConfigDescriptor.getInstance().getConfig();
IBenchmarkSession sessionWrapper;

private static final Map<String, Binary> binaryCache =
new ConcurrentHashMap<>(config.getWORKLOAD_BUFFER_SIZE());

public IoTDBSessionBase(DBConfig dbConfig) {
super(dbConfig);
}
Expand Down Expand Up @@ -376,6 +380,7 @@ public DeviceSummary deviceSummary(DeviceQuery deviceQuery) throws TsdbException
}

protected Tablet genTablet(IBatch batch) {
config.getWORKLOAD_BUFFER_SIZE();
List<MeasurementSchema> schemaList = new ArrayList<>();
int sensorIndex = 0;
for (Sensor sensor : batch.getDeviceSchema().getSensors()) {
Expand Down Expand Up @@ -428,10 +433,11 @@ protected Tablet genTablet(IBatch batch) {
case TEXT:
Binary[] sensorsText = (Binary[]) values[recordValueIndex];
sensorsText[recordIndex] =
Binary.valueOf((String) record.getRecordDataValue().get(recordValueIndex));
binaryCache.computeIfAbsent(
(String) record.getRecordDataValue().get(recordValueIndex), Binary::valueOf);
break;
default:
LOGGER.error("Unsupported Type:" + sensors.get(sensorIndex).getSensorType());
LOGGER.error("Unsupported Type: {}", sensors.get(sensorIndex).getSensorType());
}
sensorIndex++;
}
Expand Down