Skip to content

Commit f3ae405

Browse files
committed
Bug fix
1 parent a43ae0e commit f3ae405

3 files changed

Lines changed: 34 additions & 30 deletions

File tree

iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,10 @@ protected SessionDataSet executeLastDataQueryForOnePrefixPath(final List<String>
530530
tsExecuteStatementResp.queryResult,
531531
tsExecuteStatementResp.isIgnoreTimeStamp(),
532532
tsExecuteStatementResp.moreData,
533-
zoneId);
533+
zoneId,
534+
timeFactor,
535+
false,
536+
tsExecuteStatementResp.getColumnIndex2TsBlockColumnIndexList());
534537
}
535538

536539
protected Pair<SessionDataSet, TEndPoint> executeLastDataQueryForOneDevice(

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,12 @@ public TSExecuteStatementResp executeFastLastDataQueryForOnePrefixPath(
948948
final Map<TableId, Map<IDeviceID, Map<String, TimeValuePair>>> resultMap = new HashMap<>();
949949
int sensorNum = 0;
950950

951+
final String prefixString = prefixPath.toString();
951952
for (final ISchemaRegion region : SchemaEngine.getInstance().getAllSchemaRegions()) {
952-
// Do not filter by database, since we assume all the regions match the prefix path
953+
if (!prefixString.startsWith(region.getDatabaseFullPath())
954+
&& !region.getDatabaseFullPath().startsWith(prefixString)) {
955+
continue;
956+
}
953957
sensorNum += region.fillLastQueryMap(prefixPath, resultMap);
954958
}
955959

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
196196
private boolean isRecovering = true;
197197
private volatile boolean initialized = false;
198198

199-
private final String storageGroupDirPath;
199+
private final String databaseDirPath;
200200
private final String schemaRegionDirPath;
201201

202202
// For table model db: without "root."
203203
// For tree model db: with "root."
204-
private final String storageGroupFullPath;
204+
private final String databaseFullPath;
205205
private final SchemaRegionId schemaRegionId;
206206

207207
// the log file writer
@@ -222,11 +222,11 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
222222
public SchemaRegionMemoryImpl(final ISchemaRegionParams schemaRegionParams)
223223
throws MetadataException {
224224

225-
storageGroupFullPath = schemaRegionParams.getDatabase();
225+
databaseFullPath = schemaRegionParams.getDatabase();
226226
this.schemaRegionId = schemaRegionParams.getSchemaRegionId();
227227

228-
storageGroupDirPath = config.getSchemaDir() + File.separator + storageGroupFullPath;
229-
schemaRegionDirPath = storageGroupDirPath + File.separator + schemaRegionId.getId();
228+
databaseDirPath = config.getSchemaDir() + File.separator + databaseFullPath;
229+
schemaRegionDirPath = databaseDirPath + File.separator + schemaRegionId.getId();
230230

231231
// In ratis mode, no matter create schemaRegion or recover schemaRegion, the working dir should
232232
// be clear first
@@ -239,7 +239,7 @@ public SchemaRegionMemoryImpl(final ISchemaRegionParams schemaRegionParams)
239239
this.regionStatistics =
240240
new MemSchemaRegionStatistics(
241241
schemaRegionId.getId(), schemaRegionParams.getSchemaEngineStatistics());
242-
this.metric = new SchemaRegionMemMetric(regionStatistics, storageGroupFullPath);
242+
this.metric = new SchemaRegionMemMetric(regionStatistics, databaseFullPath);
243243
init();
244244
}
245245

@@ -270,11 +270,11 @@ public synchronized void init() throws MetadataException {
270270
deviceAttributeStore = new DeviceAttributeStore(regionStatistics);
271271
deviceAttributeCacheUpdater =
272272
new DeviceAttributeCacheUpdater(
273-
regionStatistics, PathUtils.unQualifyDatabaseName(storageGroupFullPath));
273+
regionStatistics, PathUtils.unQualifyDatabaseName(databaseFullPath));
274274
tagManager = new TagManager(schemaRegionDirPath, regionStatistics);
275275
mTree =
276276
new MTreeBelowSGMemoryImpl(
277-
PartialPath.getQualifiedDatabasePartialPath(storageGroupFullPath),
277+
PartialPath.getQualifiedDatabasePartialPath(databaseFullPath),
278278
tagManager::readTags,
279279
tagManager::readAttributes,
280280
regionStatistics,
@@ -300,14 +300,14 @@ public synchronized void init() throws MetadataException {
300300
}
301301

302302
private void initDir() throws SchemaDirCreationFailureException {
303-
final File sgSchemaFolder = SystemFileFactory.INSTANCE.getFile(storageGroupDirPath);
303+
final File sgSchemaFolder = SystemFileFactory.INSTANCE.getFile(databaseDirPath);
304304
if (!sgSchemaFolder.exists()) {
305305
if (sgSchemaFolder.mkdirs()) {
306-
logger.info("create database schema folder {}", storageGroupDirPath);
306+
logger.info("create database schema folder {}", databaseDirPath);
307307
} else {
308308
if (!sgSchemaFolder.exists()) {
309-
logger.error("create database schema folder {} failed.", storageGroupDirPath);
310-
throw new SchemaDirCreationFailureException(storageGroupDirPath);
309+
logger.error("create database schema folder {} failed.", databaseDirPath);
310+
throw new SchemaDirCreationFailureException(databaseDirPath);
311311
}
312312
}
313313
}
@@ -397,11 +397,11 @@ private int initFromLog() throws IOException {
397397
logger.debug(
398398
"spend {} ms to deserialize {} mtree from mlog.bin",
399399
System.currentTimeMillis() - time,
400-
storageGroupFullPath);
400+
databaseFullPath);
401401
return idx;
402402
} catch (final Exception e) {
403403
e.printStackTrace();
404-
throw new IOException("Failed to parse " + storageGroupFullPath + " mlog.bin for err:" + e);
404+
throw new IOException("Failed to parse " + databaseFullPath + " mlog.bin for err:" + e);
405405
}
406406
} else {
407407
return 0;
@@ -468,7 +468,7 @@ public synchronized void clear() {
468468

469469
@Override
470470
public String getDatabaseFullPath() {
471-
return storageGroupFullPath;
471+
return databaseFullPath;
472472
}
473473

474474
@Override
@@ -573,7 +573,7 @@ public void loadSnapshot(final File latestSnapshotRootDir) {
573573

574574
snapshotStartTime = System.currentTimeMillis();
575575
deviceAttributeCacheUpdater =
576-
new DeviceAttributeCacheUpdater(regionStatistics, storageGroupFullPath);
576+
new DeviceAttributeCacheUpdater(regionStatistics, databaseFullPath);
577577
deviceAttributeCacheUpdater.loadFromSnapshot(latestSnapshotRootDir);
578578
logger.info(
579579
"Device attribute remote updater snapshot loading of schemaRegion {} costs {}ms.",
@@ -592,7 +592,7 @@ public void loadSnapshot(final File latestSnapshotRootDir) {
592592
mTree =
593593
MTreeBelowSGMemoryImpl.loadFromSnapshot(
594594
latestSnapshotRootDir,
595-
storageGroupFullPath,
595+
databaseFullPath,
596596
regionStatistics,
597597
metric,
598598
measurementMNode -> {
@@ -609,7 +609,7 @@ public void loadSnapshot(final File latestSnapshotRootDir) {
609609
} catch (final IOException e) {
610610
logger.error(
611611
"Failed to recover tagIndex for {} in schemaRegion {}.",
612-
storageGroupFullPath + PATH_SEPARATOR + measurementMNode.getFullPath(),
612+
databaseFullPath + PATH_SEPARATOR + measurementMNode.getFullPath(),
613613
schemaRegionId);
614614
}
615615
},
@@ -891,10 +891,7 @@ public void checkSchemaQuota(final String tableName, final List<Object[]> device
891891
throws SchemaQuotaExceededException {
892892
final int notExistNum = mTree.getTableDeviceNotExistNum(tableName, deviceIdList);
893893
schemaQuotaManager.check(
894-
(long)
895-
DataNodeTableCache.getInstance()
896-
.getTable(storageGroupFullPath, tableName)
897-
.getFieldNum()
894+
(long) DataNodeTableCache.getInstance().getTable(databaseFullPath, tableName).getFieldNum()
898895
* notExistNum,
899896
notExistNum);
900897
}
@@ -1423,7 +1420,7 @@ public int fillLastQueryMap(
14231420
public void createOrUpdateTableDevice(final CreateOrUpdateTableDeviceNode node)
14241421
throws MetadataException {
14251422
for (int i = 0; i < node.getDeviceIdList().size(); i++) {
1426-
final String databaseName = storageGroupFullPath;
1423+
final String databaseName = databaseFullPath;
14271424
final String tableName = node.getTableName();
14281425
final String[] deviceId =
14291426
Arrays.stream(node.getDeviceIdList().get(i))
@@ -1614,14 +1611,14 @@ public long constructTableDevicesBlackList(
16141611
throws MetadataException {
16151612
final List<PartialPath> paths =
16161613
DeleteDevice.constructPaths(
1617-
storageGroupFullPath,
1614+
databaseFullPath,
16181615
constructTableDevicesBlackListNode.getTableName(),
16191616
constructTableDevicesBlackListNode.getPatternInfo());
16201617
final DeviceBlackListConstructor constructor =
16211618
DeleteDevice.constructDevicePredicateUpdater(
1622-
storageGroupFullPath,
1619+
databaseFullPath,
16231620
DataNodeTableCache.getInstance()
1624-
.getTable(storageGroupFullPath, constructTableDevicesBlackListNode.getTableName()),
1621+
.getTable(databaseFullPath, constructTableDevicesBlackListNode.getTableName()),
16251622
constructTableDevicesBlackListNode.getFilterInfo(),
16261623
(pointer, name) -> deviceAttributeStore.getAttributes(pointer, name),
16271624
regionStatistics);
@@ -1642,7 +1639,7 @@ public void rollbackTableDevicesBlackList(
16421639
throws MetadataException {
16431640
final List<PartialPath> paths =
16441641
DeleteDevice.constructPaths(
1645-
PathUtils.unQualifyDatabaseName(storageGroupFullPath),
1642+
PathUtils.unQualifyDatabaseName(databaseFullPath),
16461643
rollbackTableDevicesBlackListNode.getTableName(),
16471644
rollbackTableDevicesBlackListNode.getPatternInfo());
16481645
for (final PartialPath pattern : paths) {
@@ -1657,7 +1654,7 @@ public void deleteTableDevicesInBlackList(
16571654
throws MetadataException {
16581655
final List<PartialPath> paths =
16591656
DeleteDevice.constructPaths(
1660-
PathUtils.unQualifyDatabaseName(storageGroupFullPath),
1657+
PathUtils.unQualifyDatabaseName(databaseFullPath),
16611658
rollbackTableDevicesBlackListNode.getTableName(),
16621659
rollbackTableDevicesBlackListNode.getPatternInfo());
16631660
for (final PartialPath pattern : paths) {

0 commit comments

Comments
 (0)