Skip to content

Commit

Permalink
fix compile (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuwenwei authored Dec 3, 2024
1 parent 456fa81 commit 5a31261
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private Status insertOneBatchByTablet(IBatch batch) {

private Tablet genTablet(IBatch batch) {
List<IMeasurementSchema> schemaList = new ArrayList<>();
List<Tablet.ColumnType> columnTypes = new ArrayList<>();
List<Tablet.ColumnCategory> columnTypes = new ArrayList<>();
List<Sensor> sensors = batch.getDeviceSchema().getSensors();
if (config.isIS_DOUBLE_WRITE()) {
iotdb.deleteIDColumnIfNecessary(columnTypes, sensors, batch);
Expand All @@ -147,7 +147,6 @@ private Tablet genTablet(IBatch batch) {
schemaList,
columnTypes,
batch.getRecords().size() * config.getDEVICE_NUM_PER_WRITE());
long[] timestamps = tablet.timestamps;
Object[] values = tablet.values;
int stepOff = 0;
batch.reset();
Expand All @@ -156,11 +155,10 @@ private Tablet genTablet(IBatch batch) {
for (int recordIndex = stepOff;
recordIndex < (batch.getRecords().size() + stepOff);
recordIndex++) {
tablet.rowSize++;
Record record = batch.getRecords().get(recordIndex % batch.getRecords().size());
sensorIndex = 0;
long currentTime = record.getTimestamp();
timestamps[recordIndex] = currentTime;
tablet.addTimestamp(recordIndex, currentTime);
for (int recordValueIndex = 0;
recordValueIndex < record.getRecordDataValue().size();
recordValueIndex++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ public String getInsertTargetName(DeviceSchema schema) {
public Tablet createTablet(
String insertTargetName,
List<IMeasurementSchema> schemas,
List<Tablet.ColumnType> columnTypes,
List<Tablet.ColumnCategory> columnTypes,
int maxRowNumber) {
return modelStrategy.createTablet(insertTargetName, schemas, columnTypes, maxRowNumber);
}
Expand All @@ -674,12 +674,12 @@ public void sessionInsertImpl(Session session, Tablet tablet, DeviceSchema devic
}

public void addIDColumnIfNecessary(
List<Tablet.ColumnType> columnTypes, List<Sensor> sensors, IBatch batch) {
List<Tablet.ColumnCategory> columnTypes, List<Sensor> sensors, IBatch batch) {
modelStrategy.addIDColumnIfNecessary(columnTypes, sensors, batch);
}

public void deleteIDColumnIfNecessary(
List<Tablet.ColumnType> columnTypes, List<Sensor> sensors, IBatch batch) {
List<Tablet.ColumnCategory> columnTypes, List<Sensor> sensors, IBatch batch) {
modelStrategy.deleteIDColumnIfNecessary(columnTypes, sensors, batch);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public abstract void addVerificationQueryWhereClause(
DeviceSchema deviceSchema);

public abstract void deleteIDColumnIfNecessary(
List<Tablet.ColumnType> columnTypes, List<Sensor> sensors, IBatch batch);
List<Tablet.ColumnCategory> columnTypes, List<Sensor> sensors, IBatch batch);

public abstract String getValueFilterClause(List<DeviceSchema> deviceSchemas, int valueThreshold);

Expand Down Expand Up @@ -146,13 +146,13 @@ public abstract void registerDatabases(Session metaSession, List<TimeseriesSchem
public abstract Tablet createTablet(
String insertTargetName,
List<IMeasurementSchema> schemas,
List<Tablet.ColumnType> columnTypes,
List<Tablet.ColumnCategory> columnTypes,
int maxRowNumber);

public abstract String getInsertTargetName(DeviceSchema schema);

public abstract void addIDColumnIfNecessary(
List<Tablet.ColumnType> columnTypes, List<Sensor> sensors, IBatch batch);
List<Tablet.ColumnCategory> columnTypes, List<Sensor> sensors, IBatch batch);

public abstract void sessionInsertImpl(Session session, Tablet tablet, DeviceSchema deviceSchema)
throws IoTDBConnectionException, StatementExecutionException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ private void registerTable(Session metaSession, List<TimeseriesSchema> timeserie
.append(" ")
.append(SensorType.STRING)
.append(" ")
.append(Tablet.ColumnType.ID);
.append(Tablet.ColumnCategory.ID);
for (String key : deviceSchema.getTags().keySet()) {
builder
.append(", ")
.append(key)
.append(" ")
.append(SensorType.STRING)
.append(" ")
.append(Tablet.ColumnType.ID);
.append(Tablet.ColumnCategory.ID);
}
builder.append(")");
tables
Expand Down Expand Up @@ -451,9 +451,14 @@ public String getMinTimeStampSql(DeviceSchema deviceSchema) {
public Tablet createTablet(
String insertTargetName,
List<IMeasurementSchema> schemas,
List<Tablet.ColumnType> columnTypes,
List<Tablet.ColumnCategory> columnTypes,
int maxRowNumber) {
return new Tablet(insertTargetName, schemas, columnTypes, maxRowNumber);
return new Tablet(
insertTargetName,
IMeasurementSchema.getMeasurementNameList(schemas),
IMeasurementSchema.getDataTypeList(schemas),
columnTypes,
maxRowNumber);
}

@Override
Expand All @@ -463,19 +468,19 @@ public String getInsertTargetName(DeviceSchema schema) {

@Override
public void addIDColumnIfNecessary(
List<Tablet.ColumnType> columnTypes, List<Sensor> sensors, IBatch batch) {
List<Tablet.ColumnCategory> columnTypes, List<Sensor> sensors, IBatch batch) {
// All sensors are of type measurement
for (int i = 0; i < sensors.size(); i++) {
columnTypes.add(Tablet.ColumnType.MEASUREMENT);
columnTypes.add(Tablet.ColumnCategory.MEASUREMENT);
}
// tag and device as ID column
// Add Identity Column Information to Schema
sensors.add(new Sensor("device_id", SensorType.STRING));
columnTypes.add(Tablet.ColumnType.ID);
columnTypes.add(Tablet.ColumnCategory.ID);
for (String key : batch.getDeviceSchema().getTags().keySet()) {
// Currently, the identity column can only be String
sensors.add(new Sensor(key, SensorType.STRING));
columnTypes.add(Tablet.ColumnType.ID);
columnTypes.add(Tablet.ColumnCategory.ID);
}
// Add the value of the identity column to the value of each record
for (int loop = 0; loop < config.getDEVICE_NUM_PER_WRITE(); loop++) {
Expand All @@ -494,7 +499,7 @@ public void addIDColumnIfNecessary(

@Override
public void deleteIDColumnIfNecessary(
List<Tablet.ColumnType> columnTypes, List<Sensor> sensors, IBatch batch) {
List<Tablet.ColumnCategory> columnTypes, List<Sensor> sensors, IBatch batch) {
// do nothing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public String getMinTimeStampSql(DeviceSchema deviceSchema) {
public Tablet createTablet(
String insertTargetName,
List<IMeasurementSchema> schemas,
List<Tablet.ColumnType> columnTypes,
List<Tablet.ColumnCategory> columnTypes,
int maxRowNumber) {
return new Tablet(insertTargetName, schemas, maxRowNumber);
}
Expand All @@ -456,13 +456,13 @@ public String getInsertTargetName(DeviceSchema schema) {

@Override
public void addIDColumnIfNecessary(
List<Tablet.ColumnType> columnTypes, List<Sensor> sensors, IBatch batch) {
List<Tablet.ColumnCategory> columnTypes, List<Sensor> sensors, IBatch batch) {
// do nothing
}

@Override
public void deleteIDColumnIfNecessary(
List<Tablet.ColumnType> columnTypes, List<Sensor> sensors, IBatch batch) {
List<Tablet.ColumnCategory> columnTypes, List<Sensor> sensors, IBatch batch) {
// delete the value of the identity column to the value of each record
for (int i = 0; i < batch.getRecords().size(); i++) {
List<Object> dataValue = batch.getRecords().get(i).getRecordDataValue();
Expand Down

0 comments on commit 5a31261

Please sign in to comment.