Skip to content

Commit

Permalink
try (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuheng55555 committed Nov 28, 2023
1 parent f28ea50 commit 8dd7a11
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit 8dd7a11

Please sign in to comment.