Skip to content

Commit

Permalink
remove table name in deviceId during schema validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jt2594838 committed Aug 1, 2024
1 parent 7d42b3d commit 4435d21
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowStatement;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -62,7 +63,8 @@ public String getTableName() {
@Override
public List<Object[]> getDeviceIdList() {
final InsertRowStatement insertRowStatement = getInnerTreeStatement();
return Collections.singletonList(insertRowStatement.getTableDeviceID().getSegments());
Object[] segments = insertRowStatement.getTableDeviceID().getSegments();
return Collections.singletonList(Arrays.copyOfRange(segments, 1, segments.length));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowsStatement;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -67,7 +68,7 @@ public String getTableName() {
@Override
public List<Object[]> getDeviceIdList() {
final InsertRowsStatement insertRowStatement = getInnerTreeStatement();
return insertRowStatement.getDeviceIdList();
return insertRowStatement.getDeviceIdListNoTableName();
}

@Override
Expand Down Expand Up @@ -124,7 +125,8 @@ public String getTableName() {

@Override
public List<Object[]> getDeviceIdList() {
return Collections.singletonList(insertRowStatement.getTableDeviceID().getSegments());
Object[] idSegments = insertRowStatement.getTableDeviceID().getSegments();
return Collections.singletonList(Arrays.copyOfRange(idSegments, 1, idSegments.length));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.tsfile.file.metadata.IDeviceID;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class InsertTablet extends WrappedInsertStatement {
Expand Down Expand Up @@ -66,11 +67,8 @@ public List<Object[]> getDeviceIdList() {
final InsertTabletStatement insertTabletStatement = getInnerTreeStatement();
for (int i = 0; i < insertTabletStatement.getRowCount(); i++) {
IDeviceID deviceID = insertTabletStatement.getTableDeviceID(i);
Object[] deviceIdSegments = new Object[deviceID.segmentNum()];
for (int j = 0; j < deviceIdSegments.length; j++) {
deviceIdSegments[j] = deviceID.segment(j);
}
deviceIdList.add(deviceIdSegments);
Object[] segments = deviceID.getSegments();
deviceIdList.add(Arrays.copyOfRange(segments, 1, segments.length));
}
return deviceIdList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.tsfile.exception.NotImplementedException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -163,9 +164,13 @@ public InsertBaseStatement removeLogicalView() {
return splitResult;
}

public List<Object[]> getDeviceIdList() {
public List<Object[]> getDeviceIdListNoTableName() {
return insertRowStatementList.stream()
.map(s -> s.getTableDeviceID().getSegments())
.map(
s -> {
Object[] segments = s.getTableDeviceID().getSegments();
return Arrays.copyOfRange(segments, 1, segments.length);
})
.collect(Collectors.toList());
}
}

0 comments on commit 4435d21

Please sign in to comment.