This is an automated email from the ASF dual-hosted git repository. leirui pushed a commit to branch research/M4-visualization in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit df9c9417648ce69762fe61f2310e6c16fe6a0bec Author: Lei Rui <[email protected]> AuthorDate: Wed Jul 5 18:40:56 2023 +0800 rename --- .../java/org/apache/iotdb/jdbc/IoTDBStatement.java | 7 + .../resources/conf/iotdb-engine.properties | 4 +- .../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 14 +- .../groupby/GroupByWithoutValueFilterDataSet.java | 13 +- .../dataset/groupby/LocalGroupByExecutor4CPV.java | 7 +- .../apache/iotdb/db/integration/m4/MyTest1.java | 8 +- .../apache/iotdb/db/integration/m4/MyTest2.java | 6 +- .../apache/iotdb/db/integration/m4/MyTest3.java | 6 +- .../apache/iotdb/db/integration/m4/MyTest4.java | 6 +- .../apache/iotdb/db/integration/m4/MyTest5.java | 6 +- .../apache/iotdb/db/integration/m4/MyTmpTest.java | 6 +- .../iotdb/tsfile/common/conf/TSFileConfig.java | 20 +- .../iotdb/tsfile/common/conf/TSFileDescriptor.java | 7 +- .../iotdb/tsfile/read/common/ChunkSuit4CPV.java | 6 +- .../iotdb/tsfile/read/common/IOMonitor2.java | 5 +- .../iotdb/tsfile/read/reader/page/PageReader.java | 484 +++++++++++++++------ 16 files changed, 422 insertions(+), 183 deletions(-) diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java index f8e9c6b8065..19c8d0f72f3 100644 --- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java +++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java @@ -25,6 +25,7 @@ import org.apache.iotdb.rpc.TSStatusCode; import org.apache.iotdb.service.rpc.thrift.TSCancelOperationReq; import org.apache.iotdb.service.rpc.thrift.TSCloseOperationReq; import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementReq; +import org.apache.iotdb.service.rpc.thrift.TSExecuteFinishResp; import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementReq; import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp; import org.apache.iotdb.service.rpc.thrift.TSIService; @@ -383,6 +384,12 @@ public class IoTDBStatement implements Statement { } } + public String executeFinish() throws TException, StatementExecutionException { + TSExecuteFinishResp ret = client.executeFinish(); + RpcUtils.verifySuccess(ret.getStatus()); + return ret.executionInfo; + } + private ResultSet executeQuerySQL(String sql, long timeoutInMS) throws TException, SQLException { isCancelled = false; TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionId, sql, stmtId); diff --git a/server/src/assembly/resources/conf/iotdb-engine.properties b/server/src/assembly/resources/conf/iotdb-engine.properties index 28ca06a1e62..48e720a2995 100644 --- a/server/src/assembly/resources/conf/iotdb-engine.properties +++ b/server/src/assembly/resources/conf/iotdb-engine.properties @@ -608,10 +608,12 @@ enable_unseq_compaction=false use_Statistics=true -use_ChunkIndex=true +use_TimeIndex=true use_Mad=false +use_ValueIndex=true + # group_size_in_byte=134217728 # The memory size for each series writer to pack page, default value is 64KB diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java index 04da72c848a..f40296e82b1 100644 --- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java +++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java @@ -906,12 +906,12 @@ public class IoTDBDescriptor { TSFileDescriptor.getInstance().getConfig().isUseStatistics())))); TSFileDescriptor.getInstance() .getConfig() - .setUseChunkIndex( + .setUseTimeIndex( Boolean.parseBoolean( properties.getProperty( - "use_ChunkIndex", + "use_TimeIndex", Boolean.toString( - TSFileDescriptor.getInstance().getConfig().isUseChunkIndex())))); + TSFileDescriptor.getInstance().getConfig().isUseTimeIndex())))); TSFileDescriptor.getInstance() .getConfig() .setUseMad( @@ -919,6 +919,14 @@ public class IoTDBDescriptor { properties.getProperty( "use_Mad", Boolean.toString(TSFileDescriptor.getInstance().getConfig().isUseMad())))); + TSFileDescriptor.getInstance() + .getConfig() + .setUseValueIndex( + Boolean.parseBoolean( + properties.getProperty( + "use_ValueIndex", + Boolean.toString( + TSFileDescriptor.getInstance().getConfig().isUseValueIndex())))); TSFileDescriptor.getInstance() .getConfig() .setGroupSizeInByte( diff --git a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByWithoutValueFilterDataSet.java b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByWithoutValueFilterDataSet.java index 0b8d58f145e..bd02b795e77 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByWithoutValueFilterDataSet.java +++ b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByWithoutValueFilterDataSet.java @@ -201,12 +201,21 @@ public class GroupByWithoutValueFilterDataSet extends GroupByEngineDataSet { boolean ascending) throws StorageEngineException, QueryProcessException { if (CONFIG.isEnableCPV()) { - if (TSFileDescriptor.getInstance().getConfig().isUseChunkIndex()) { + if (TSFileDescriptor.getInstance().getConfig().isUseTimeIndex() + && TSFileDescriptor.getInstance().getConfig().isUseValueIndex()) { IOMonitor2.dataSetType = DataSetType.GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_UseIndex; + } else if (!TSFileDescriptor.getInstance().getConfig().isUseTimeIndex() + && TSFileDescriptor.getInstance().getConfig().isUseValueIndex()) { + IOMonitor2.dataSetType = + DataSetType.GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_NoTimeIndex; + } else if (TSFileDescriptor.getInstance().getConfig().isUseTimeIndex() + && !TSFileDescriptor.getInstance().getConfig().isUseValueIndex()) { + IOMonitor2.dataSetType = + DataSetType.GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_NoValueIndex; } else { IOMonitor2.dataSetType = - DataSetType.GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_NotUseIndex; + DataSetType.GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_NoTimeValueIndex; } return new LocalGroupByExecutor4CPV( path, allSensors, dataType, context, timeFilter, fileFilter, ascending); diff --git a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor4CPV.java b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor4CPV.java index 5223ec6bde2..294129523e3 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor4CPV.java +++ b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor4CPV.java @@ -411,8 +411,9 @@ public class LocalGroupByExecutor4CPV implements GroupByExecutor { .getPageReader() .setDeleteIntervalList(chunkSuit4CPV.getChunkMetadata().getDeleteIntervalList()); } - // chunk data read operation (c): get all data points - chunkSuit4CPV.getPageReader().updateBPTP(chunkSuit4CPV); + // chunk data read operation (c) + // chunkSuit4CPV.getPageReader().updateBPTP(chunkSuit4CPV); + chunkSuit4CPV.getPageReader().updateBP_withValueIndex(chunkSuit4CPV); // check if empty if (chunkSuit4CPV.statistics.getCount() == 0) { currentChunkList.remove(chunkSuit4CPV); @@ -608,7 +609,7 @@ public class LocalGroupByExecutor4CPV implements GroupByExecutor { .getPageReader() .setDeleteIntervalList(chunkSuit4CPV.getChunkMetadata().getDeleteIntervalList()); } - // chunk data read operation (c): get all data points + // chunk data read operation (c) // chunkSuit4CPV.getPageReader().updateBPTP(chunkSuit4CPV); chunkSuit4CPV.getPageReader().updateTP_withValueIndex(chunkSuit4CPV); // TODO // check if empty diff --git a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest1.java b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest1.java index c2ab7f38682..db948cd3da0 100644 --- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest1.java +++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest1.java @@ -24,6 +24,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.engine.compaction.CompactionStrategy; import org.apache.iotdb.db.utils.EnvironmentUtils; import org.apache.iotdb.jdbc.Config; +import org.apache.iotdb.jdbc.IoTDBStatement; import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor; import org.junit.After; @@ -71,8 +72,8 @@ public class MyTest1 { originalEnableCPV = config.isEnableCPV(); config.setEnableCPV(true); // CPV - originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseChunkIndex(); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(false); + originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseTimeIndex(); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(false); originalUseMad = TSFileDescriptor.getInstance().getConfig().isUseMad(); TSFileDescriptor.getInstance().getConfig().setUseMad(true); @@ -87,7 +88,7 @@ public class MyTest1 { EnvironmentUtils.cleanEnv(); config.setCompactionStrategy(originalCompactionStrategy); config.setEnableCPV(originalEnableCPV); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(originalUseChunkIndex); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(originalUseChunkIndex); TSFileDescriptor.getInstance().getConfig().setUseMad(originalUseMad); } @@ -132,6 +133,7 @@ public class MyTest1 { Assert.assertEquals(res[i++], ans); } } + System.out.println(((IoTDBStatement) statement).executeFinish()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); diff --git a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest2.java b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest2.java index c6fc8dd3e1a..134fddbb2f6 100644 --- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest2.java +++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest2.java @@ -73,8 +73,8 @@ public class MyTest2 { originalSeqTsFileSize = config.getSeqTsFileSize(); originalUnSeqTsFileSize = config.getUnSeqTsFileSize(); - originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseChunkIndex(); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(false); + originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseTimeIndex(); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(false); config.setCompactionStrategy(CompactionStrategy.NO_COMPACTION); @@ -96,7 +96,7 @@ public class MyTest2 { config.setEnableCPV(originalEnableCPV); config.setSeqTsFileSize(originalSeqTsFileSize); config.setUnSeqTsFileSize(originalUnSeqTsFileSize); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(originalUseChunkIndex); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(originalUseChunkIndex); } @Test diff --git a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest3.java b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest3.java index 74923aed64a..fb5c514094e 100644 --- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest3.java +++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest3.java @@ -69,8 +69,8 @@ public class MyTest3 { // config.setEnableCPV(false); // MOC config.setEnableCPV(true); // CPV - originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseChunkIndex(); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(false); + originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseTimeIndex(); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(false); EnvironmentUtils.envSetUp(); Class.forName(Config.JDBC_DRIVER_NAME); @@ -82,7 +82,7 @@ public class MyTest3 { EnvironmentUtils.cleanEnv(); config.setCompactionStrategy(originalCompactionStrategy); config.setEnableCPV(originalEnableCPV); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(originalUseChunkIndex); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(originalUseChunkIndex); } @Test diff --git a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest4.java b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest4.java index 7b4bd91c414..db38c7e4f35 100644 --- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest4.java +++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest4.java @@ -69,8 +69,8 @@ public class MyTest4 { originalEnableCPV = config.isEnableCPV(); config.setEnableCPV(true); // CPV - originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseChunkIndex(); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(false); + originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseTimeIndex(); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(false); EnvironmentUtils.envSetUp(); Class.forName(Config.JDBC_DRIVER_NAME); @@ -82,7 +82,7 @@ public class MyTest4 { EnvironmentUtils.cleanEnv(); config.setCompactionStrategy(originalCompactionStrategy); config.setEnableCPV(originalEnableCPV); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(originalUseChunkIndex); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(originalUseChunkIndex); } @Test diff --git a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest5.java b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest5.java index 253dc40dd16..2f406f1153c 100644 --- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest5.java +++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTest5.java @@ -75,8 +75,8 @@ public class MyTest5 { // config.setEnableCPV(false); // MOC config.setEnableCPV(true); // CPV - originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseChunkIndex(); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(false); + originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseTimeIndex(); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(false); EnvironmentUtils.envSetUp(); Class.forName(Config.JDBC_DRIVER_NAME); @@ -88,7 +88,7 @@ public class MyTest5 { EnvironmentUtils.cleanEnv(); config.setCompactionStrategy(originalCompactionStrategy); config.setEnableCPV(originalEnableCPV); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(originalUseChunkIndex); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(originalUseChunkIndex); } @Test diff --git a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTmpTest.java b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTmpTest.java index 1c8a47cd729..98419762bdd 100644 --- a/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTmpTest.java +++ b/server/src/test/java/org/apache/iotdb/db/integration/m4/MyTmpTest.java @@ -71,8 +71,8 @@ public class MyTmpTest { originalEnableCPV = config.isEnableCPV(); config.setEnableCPV(true); // CPV - originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseChunkIndex(); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(true); + originalUseChunkIndex = TSFileDescriptor.getInstance().getConfig().isUseTimeIndex(); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(true); originalUseMad = TSFileDescriptor.getInstance().getConfig().isUseMad(); TSFileDescriptor.getInstance().getConfig().setUseMad(true); @@ -87,7 +87,7 @@ public class MyTmpTest { EnvironmentUtils.cleanEnv(); config.setCompactionStrategy(originalCompactionStrategy); config.setEnableCPV(originalEnableCPV); - TSFileDescriptor.getInstance().getConfig().setUseChunkIndex(originalUseChunkIndex); + TSFileDescriptor.getInstance().getConfig().setUseTimeIndex(originalUseChunkIndex); TSFileDescriptor.getInstance().getConfig().setUseMad(originalUseMad); } diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileConfig.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileConfig.java index 65cc33c8c6e..26e518b865d 100644 --- a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileConfig.java +++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileConfig.java @@ -29,7 +29,9 @@ public class TSFileConfig implements Serializable { private boolean useStatistics = true; - private boolean useChunkIndex = true; + private boolean useTimeIndex = true; + + private boolean useValueIndex = true; private boolean useMad = false; @@ -161,12 +163,12 @@ public class TSFileConfig implements Serializable { this.useStatistics = useStatistics; } - public boolean isUseChunkIndex() { - return useChunkIndex; + public boolean isUseTimeIndex() { + return useTimeIndex; } - public void setUseChunkIndex(boolean useChunkIndex) { - this.useChunkIndex = useChunkIndex; + public void setUseTimeIndex(boolean useTimeIndex) { + this.useTimeIndex = useTimeIndex; } public boolean isUseMad() { @@ -177,6 +179,14 @@ public class TSFileConfig implements Serializable { this.useMad = useMad; } + public boolean isUseValueIndex() { + return useValueIndex; + } + + public void setUseValueIndex(boolean useValueIndex) { + this.useValueIndex = useValueIndex; + } + public int getGroupSizeInByte() { return groupSizeInByte; } diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java index c287ad85d57..4394fd4ce67 100644 --- a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java +++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java @@ -108,12 +108,15 @@ public class TSFileDescriptor { conf.setUseStatistics( Boolean.parseBoolean( properties.getProperty("use_Statistics", Boolean.toString(conf.isUseStatistics())))); - conf.setUseChunkIndex( + conf.setUseTimeIndex( Boolean.parseBoolean( - properties.getProperty("use_ChunkIndex", Boolean.toString(conf.isUseChunkIndex())))); + properties.getProperty("use_TimeIndex", Boolean.toString(conf.isUseTimeIndex())))); conf.setUseMad( Boolean.parseBoolean( properties.getProperty("use_Mad", Boolean.toString(conf.isUseMad())))); + conf.setUseValueIndex( + Boolean.parseBoolean( + properties.getProperty("use_ValueIndex", Boolean.toString(conf.isUseValueIndex())))); conf.setGroupSizeInByte( Integer.parseInt( properties.getProperty( diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/ChunkSuit4CPV.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/ChunkSuit4CPV.java index 4c1e205781e..18d61065299 100644 --- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/ChunkSuit4CPV.java +++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/ChunkSuit4CPV.java @@ -251,7 +251,7 @@ public class ChunkSuit4CPV { public int updateFPwithTheClosetPointEqualOrAfter(long targetTimestamp) throws IOException { long start = System.nanoTime(); int estimatedPos; - if (TSFileDescriptor.getInstance().getConfig().isUseChunkIndex()) { + if (TSFileDescriptor.getInstance().getConfig().isUseTimeIndex()) { StepRegress stepRegress = chunkMetadata.getStatistics().getStepRegress(); // infer position starts from 1, so minus 1 here estimatedPos = (int) Math.round(stepRegress.infer(targetTimestamp)) - 1; @@ -368,7 +368,7 @@ public class ChunkSuit4CPV { public int updateLPwithTheClosetPointEqualOrBefore(long targetTimestamp) throws IOException { long start = System.nanoTime(); int estimatedPos; - if (TSFileDescriptor.getInstance().getConfig().isUseChunkIndex()) { + if (TSFileDescriptor.getInstance().getConfig().isUseTimeIndex()) { StepRegress stepRegress = chunkMetadata.getStatistics().getStepRegress(); // infer position starts from 1, so minus 1 here estimatedPos = (int) Math.round(stepRegress.infer(targetTimestamp)) - 1; @@ -490,7 +490,7 @@ public class ChunkSuit4CPV { public boolean checkIfExist(long targetTimestamp) throws IOException { long start = System.nanoTime(); boolean exist; - if (TSFileDescriptor.getInstance().getConfig().isUseChunkIndex()) { + if (TSFileDescriptor.getInstance().getConfig().isUseTimeIndex()) { StepRegress stepRegress = chunkMetadata.getStatistics().getStepRegress(); // infer position starts from 1, so minus 1 here // TODO debug buffer.get(index) diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/IOMonitor2.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/IOMonitor2.java index 62e79e40fac..44f5084c5da 100644 --- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/IOMonitor2.java +++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/IOMonitor2.java @@ -27,8 +27,9 @@ public class IOMonitor2 { UDTFAlignByTimeDataSet_M4_POINT, // mac UDTFAlignByTimeDataSet_M4_TIMEWINDOW, // mac_tw GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_UseIndex, // cpv - GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_NotUseIndex, // cpv_noIndex - + GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_NoTimeIndex, // cpv_noTimeIndex + GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_NoValueIndex, // cpv_noValueIndex + GroupByWithoutValueFilterDataSet_LocalGroupByExecutor4CPV_NoTimeValueIndex, // cpv_noTimeValueIndex GroupByWithoutValueFilterDataSet_LocalGroupByExecutor_UseStatistics, // moc GroupByWithoutValueFilterDataSet_LocalGroupByExecutor_NotUseStatistics // mac_groupBy } diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/PageReader.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/PageReader.java index db378202f56..27dac52c0b4 100644 --- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/PageReader.java +++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/PageReader.java @@ -18,6 +18,7 @@ */ package org.apache.iotdb.tsfile.read.reader.page; +import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor; import org.apache.iotdb.tsfile.encoding.decoder.Decoder; import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException; import org.apache.iotdb.tsfile.file.header.PageHeader; @@ -167,167 +168,362 @@ public class PageReader implements IPageReader { } public void updateTP_withValueIndex(ChunkSuit4CPV chunkSuit4CPV) { - // NOTE: get valueIndex from chunkSuit4CPV.getChunkMetadata().getStatistics(), not - // chunkSuit4CPV.getStatistics()! - ValueIndex valueIndex = chunkSuit4CPV.getChunkMetadata().getStatistics().valueIndex; - - // step 1: find threshold - boolean isFound = false; - double foundValue = 0; - // iterate SDT points from value big to small to find the first point not deleted - for (int n = valueIndex.sortedModelPoints.size() - 1; n >= 0; n--) { // NOTE from big to small - ValuePoint valuePoint = valueIndex.sortedModelPoints.get(n); - int idx = valuePoint.index; // index starting from 1 - int pos = idx - 1; // pos starting from 0 - long time = timeBuffer.getLong(pos * 8); - // check if deleted - if ((pos >= chunkSuit4CPV.startPos) - && (pos <= chunkSuit4CPV.endPos) - && !isDeleted_NoHistoryDeleteCursor(time)) { - // startPos&endPos conveys the virtual deletes of the current M4 time span - isFound = true; - foundValue = valuePoint.value; - break; + long start = System.nanoTime(); + if (TSFileDescriptor.getInstance().getConfig().isUseValueIndex()) { + // NOTE: get valueIndex from chunkSuit4CPV.getChunkMetadata().getStatistics(), not + // chunkSuit4CPV.getStatistics()! + ValueIndex valueIndex = chunkSuit4CPV.getChunkMetadata().getStatistics().valueIndex; + + // step 1: find threshold + boolean isFound = false; + double foundValue = 0; + // iterate SDT points from value big to small to find the first point not deleted + for (int n = valueIndex.sortedModelPoints.size() - 1; n >= 0; n--) { // NOTE from big to small + IOMonitor2.DCP_D_traversedPointNum++; // TODO + ValuePoint valuePoint = valueIndex.sortedModelPoints.get(n); + int idx = valuePoint.index; // index starting from 1 + int pos = idx - 1; // pos starting from 0 + long time = timeBuffer.getLong(pos * 8); + // check if deleted + if ((pos >= chunkSuit4CPV.startPos) + && (pos <= chunkSuit4CPV.endPos) + && !isDeleted_NoHistoryDeleteCursor(time)) { + // startPos&endPos conveys the virtual deletes of the current M4 time span + isFound = true; + foundValue = valuePoint.value; + break; + } } + if (!isFound) { // unfortunately all sdt points are deleted + // this includes the case that all points including model points are deleted, + // which is handled by updateBPTP + updateBPTP(chunkSuit4CPV); // then fall back to baseline method + return; + } + double threshold_LB = foundValue - valueIndex.errorBound; // near max LB + + // step 2: calculate pruned intervals for TP: UB<threshold=near max LB + // increment global chunkSuit4CPV.modelPointsCursor + int idx2; + // note that the first and last points of a chunk are stored in model points + // there must exist idx2-1 >= startPos, otherwise this chunk won't be processed for the + // current + // time span + while ((idx2 = valueIndex.modelPointIdx_list.get(chunkSuit4CPV.modelPointsCursor)) - 1 + < chunkSuit4CPV.startPos) { + // -1 because idx starting from 1 while pos starting from 0 + chunkSuit4CPV.modelPointsCursor++; + // pointing to the right end of the first model segment that passes the left endpoint of the + // current time span + } + // increment local cursor starting from chunkSuit4CPV.modelPointsCursor for iterating model + // segments for the current time span + // do not increment modelPointsCursor because the model segments for this time span may be + // iterated multiple times + int localCursor = + chunkSuit4CPV.modelPointsCursor; // pointing to the right end of the model segment + List<Integer> prune_intervals_start = new ArrayList<>(); + List<Integer> prune_intervals_end = new ArrayList<>(); + int interval_start = -1; + int interval_end = -1; + int idx1; + // there must exist idx1-1 <= endPos, otherwise this chunk won't be processed for the current + // time span + while (localCursor < valueIndex.modelPointIdx_list.size() + && (idx1 = valueIndex.modelPointIdx_list.get(localCursor - 1)) - 1 + <= chunkSuit4CPV.endPos) { + IOMonitor2.DCP_D_traversedPointNum++; // TODO + idx2 = valueIndex.modelPointIdx_list.get(localCursor); + double v1_UB = valueIndex.modelPointVal_list.get(localCursor - 1) + valueIndex.errorBound; + double v2_UB = valueIndex.modelPointVal_list.get(localCursor) + valueIndex.errorBound; + if (v1_UB < threshold_LB && v2_UB < threshold_LB) { + if (interval_start < 0) { + interval_start = idx1; + } + interval_end = idx2; // continuous + } else if (v1_UB < threshold_LB && v2_UB >= threshold_LB) { + if (interval_start < 0) { + interval_start = idx1; + } + prune_intervals_start.add(interval_start); + prune_intervals_end.add( + (int) Math.floor((threshold_LB - v1_UB) * (idx2 - idx1) / (v2_UB - v1_UB) + idx1)); + interval_start = -1; // discontinuous + } else if (v1_UB >= threshold_LB && v2_UB < threshold_LB) { + interval_start = + (int) Math.ceil((threshold_LB - v1_UB) * (idx2 - idx1) / (v2_UB - v1_UB) + idx1); + interval_end = idx2; // continuous + } + localCursor++; + } + if (interval_start > 0) { + prune_intervals_start.add(interval_start); + prune_intervals_end.add(interval_end); + } + + // step 3: calculate unpruned intervals + // deal with time span deletes -> update search_startPos and search_endPos + // note idx starting from 1, pos starting from 0 + int search_startPos = chunkSuit4CPV.startPos; + int search_endPos = chunkSuit4CPV.endPos; + if (prune_intervals_start.size() > 0) { + // deal with time span left virtual delete -> update search_startPos + int prune_idx1 = prune_intervals_start.get(0); + if (prune_idx1 - 1 <= chunkSuit4CPV.startPos) { + // +1 for included, -1 for starting from 0 + search_startPos = Math.max(search_startPos, prune_intervals_end.get(0) + 1 - 1); + prune_intervals_start.remove(0); + prune_intervals_end.remove(0); + } + } + if (prune_intervals_start.size() > 0) { + // deal with time span right virtual delete -> update search_endPos + int prune_idx2 = prune_intervals_end.get(prune_intervals_end.size() - 1); + if (prune_idx2 - 1 >= search_endPos) { + // -1 for included, -1 for starting from 0 + search_endPos = + Math.min( + search_endPos, + prune_intervals_start.get(prune_intervals_start.size() - 1) - 1 - 1); + prune_intervals_start.remove(prune_intervals_start.size() - 1); + prune_intervals_end.remove(prune_intervals_end.size() - 1); + } + } + // add search_endPos+1 to the end of prune_intervals_start + // turning into search_intervals_end (excluded endpoints) + // note that idx&prune_interval&search_interval starting from 1, pos starting from 0 + prune_intervals_start.add(search_endPos + 1 + 1); // +1 for starting from 1, +1 for excluded + // add search_startPos-1 to the start of prune_intervals_end + // turning into search_intervals_start (excluded endpoints) + prune_intervals_end.add( + 0, search_startPos + 1 - 1); // +1 for starting from 1, +1 for excluded + + // step 4: search unpruned intervals + // also deal with normal delete intervals + if (dataType == TSDataType.DOUBLE) { + double candidateTPvalue = -1; + long candidateTPtime = -1; + // note that idx&prune_interval&search_interval starting from 1, pos starting from 0 + for (int i = 0; i < prune_intervals_start.size(); i++) { + int search_interval_start = prune_intervals_end.get(i) + 1; // included + int search_interval_end = prune_intervals_start.get(i) - 1; // included + for (int j = search_interval_start; + j <= search_interval_end; + j++) { // idx starting from 1 + IOMonitor2.DCP_D_traversedPointNum++; // TODO + double v = valueBuffer.getDouble(timeBufferLength + (j - 1) * 8); // pos starting from 0 + long t = timeBuffer.getLong((j - 1) * 8); // pos starting from 0 + if (v > candidateTPvalue && !isDeleted_NoHistoryDeleteCursor(t)) { + candidateTPvalue = v; + candidateTPtime = t; + } + } + } + chunkSuit4CPV.statistics.setMaxInfo(new MinMaxInfo(candidateTPvalue, candidateTPtime)); + } else if (dataType == TSDataType.INT64) { + long candidateTPvalue = -1; // NOTE for TP + long candidateTPtime = -1; + for (int i = 0; i < prune_intervals_start.size(); i++) { + int search_interval_start = prune_intervals_end.get(i) + 1; // included + int search_interval_end = prune_intervals_start.get(i) - 1; // included + for (int j = search_interval_start; j <= search_interval_end; j++) { // starting from 1 + IOMonitor2.DCP_D_traversedPointNum++; // TODO + long v = valueBuffer.getLong(timeBufferLength + (j - 1) * 8); + long t = timeBuffer.getLong((j - 1) * 8); + if (v > candidateTPvalue && !isDeleted_NoHistoryDeleteCursor(t)) { + candidateTPvalue = v; + candidateTPtime = t; + } + } + } + chunkSuit4CPV.statistics.setMaxInfo(new MinMaxInfo(candidateTPvalue, candidateTPtime)); + } else { + throw new UnSupportedDataTypeException(String.valueOf(dataType)); + } + } else { + updateBPTP(chunkSuit4CPV); } - if (!isFound) { // unfortunately all sdt points are deleted - updateBPTP(chunkSuit4CPV); // then fall back to baseline method - return; - } - double threshold_LB = foundValue - valueIndex.errorBound; // near max LB - - // step 2: calculate pruned intervals for TP: UB<threshold=near max LB - // increment global chunkSuit4CPV.modelPointsCursor - int idx2; - // note that the first and last points of a chunk are stored in model points - // there must exist idx2-1 >= startPos, otherwise this chunk won't be processed for the current - // time span - while ((idx2 = valueIndex.modelPointIdx_list.get(chunkSuit4CPV.modelPointsCursor)) - 1 - < chunkSuit4CPV.startPos) { // TODO check - // -1 because idx starting from 1 while pos starting from 0 - chunkSuit4CPV.modelPointsCursor++; - // pointing to the right end of the first model segment that passes the left endpoint of the - // current time span - } - // increment local cursor starting from chunkSuit4CPV.modelPointsCursor for iterating model - // segments for the current time span - // do not increment modelPointsCursor because the model segments for this time span may be - // iterated multiple times - int localCursor = - chunkSuit4CPV.modelPointsCursor; // pointing to the right end of the model segment - List<Integer> prune_intervals_start = new ArrayList<>(); - List<Integer> prune_intervals_end = new ArrayList<>(); - int interval_start = -1; - int interval_end = -1; - int idx1; - // there must exist idx1-1 <= endPos, otherwise this chunk won't be processed for the current - // time span - while (localCursor < valueIndex.modelPointIdx_list.size() - && (idx1 = valueIndex.modelPointIdx_list.get(localCursor - 1)) - 1 - <= chunkSuit4CPV.endPos) { - idx2 = valueIndex.modelPointIdx_list.get(localCursor); - double v1_UB = valueIndex.modelPointVal_list.get(localCursor - 1) + valueIndex.errorBound; - double v2_UB = valueIndex.modelPointVal_list.get(localCursor) + valueIndex.errorBound; - if (v1_UB < threshold_LB && v2_UB < threshold_LB) { - if (interval_start < 0) { - interval_start = idx1; + IOMonitor2.addMeasure(Operation.SEARCH_ARRAY_c_genBPTP, System.nanoTime() - start); + } + + public void updateBP_withValueIndex(ChunkSuit4CPV chunkSuit4CPV) { + long start = System.nanoTime(); + if (TSFileDescriptor.getInstance().getConfig().isUseValueIndex()) { + // NOTE: get valueIndex from chunkSuit4CPV.getChunkMetadata().getStatistics(), not + // chunkSuit4CPV.getStatistics()! + ValueIndex valueIndex = chunkSuit4CPV.getChunkMetadata().getStatistics().valueIndex; + + // step 1: find threshold + boolean isFound = false; + double foundValue = 0; + // iterate SDT points from value small to big to find the first point not deleted + for (int n = 0; n < valueIndex.sortedModelPoints.size(); n++) { // NOTE from small to big + IOMonitor2.DCP_D_traversedPointNum++; // TODO + ValuePoint valuePoint = valueIndex.sortedModelPoints.get(n); + int idx = valuePoint.index; // index starting from 1 + int pos = idx - 1; // pos starting from 0 + long time = timeBuffer.getLong(pos * 8); + // check if deleted + if ((pos >= chunkSuit4CPV.startPos) + && (pos <= chunkSuit4CPV.endPos) + && !isDeleted_NoHistoryDeleteCursor(time)) { + // startPos&endPos conveys the virtual deletes of the current M4 time span + isFound = true; + foundValue = valuePoint.value; + break; } - interval_end = idx2; // continuous - } else if (v1_UB < threshold_LB && v2_UB >= threshold_LB) { - if (interval_start < 0) { - interval_start = idx1; + } + if (!isFound) { // unfortunately all sdt points are deleted + // this includes the case that all points including model points are deleted, + // which is handled by updateBPTP + updateBPTP(chunkSuit4CPV); // then fall back to baseline method + return; + } + double threshold_UB = foundValue + valueIndex.errorBound; // near min UB + + // step 2: calculate pruned intervals for BP: LB>threshold=near min UB + // increment global chunkSuit4CPV.modelPointsCursor + int idx2; + // note that the first and last points of a chunk are stored in model points + // there must exist idx2-1 >= startPos, otherwise this chunk won't be processed for the + // current + // time span + while ((idx2 = valueIndex.modelPointIdx_list.get(chunkSuit4CPV.modelPointsCursor)) - 1 + < chunkSuit4CPV.startPos) { + IOMonitor2.DCP_D_traversedPointNum++; // TODO + // -1 because idx starting from 1 while pos starting from 0 + chunkSuit4CPV.modelPointsCursor++; + // pointing to the right end of the first model segment that passes the left endpoint of the + // current time span + } + // increment local cursor starting from chunkSuit4CPV.modelPointsCursor for iterating model + // segments for the current time span + // do not increment modelPointsCursor because the model segments for this time span may be + // iterated multiple times + int localCursor = + chunkSuit4CPV.modelPointsCursor; // pointing to the right end of the model segment + List<Integer> prune_intervals_start = new ArrayList<>(); + List<Integer> prune_intervals_end = new ArrayList<>(); + int interval_start = -1; + int interval_end = -1; + int idx1; + // there must exist idx1-1 <= endPos, otherwise this chunk won't be processed for the current + // time span + while (localCursor < valueIndex.modelPointIdx_list.size() + && (idx1 = valueIndex.modelPointIdx_list.get(localCursor - 1)) - 1 + <= chunkSuit4CPV.endPos) { + IOMonitor2.DCP_D_traversedPointNum++; // TODO + idx2 = valueIndex.modelPointIdx_list.get(localCursor); + double v1_LB = valueIndex.modelPointVal_list.get(localCursor - 1) - valueIndex.errorBound; + double v2_LB = valueIndex.modelPointVal_list.get(localCursor) - valueIndex.errorBound; + if (v1_LB > threshold_UB && v2_LB > threshold_UB) { + if (interval_start < 0) { + interval_start = idx1; + } + interval_end = idx2; // continuous + } else if (v1_LB > threshold_UB && v2_LB <= threshold_UB) { + if (interval_start < 0) { + interval_start = idx1; + } + prune_intervals_start.add(interval_start); + prune_intervals_end.add( + (int) Math.floor((threshold_UB - v1_LB) * (idx2 - idx1) / (v2_LB - v1_LB) + idx1)); + interval_start = -1; // discontinuous + } else if (v1_LB <= threshold_UB && v2_LB > threshold_UB) { + interval_start = + (int) Math.ceil((threshold_UB - v1_LB) * (idx2 - idx1) / (v2_LB - v1_LB) + idx1); + interval_end = idx2; // continuous } + localCursor++; + } + if (interval_start > 0) { prune_intervals_start.add(interval_start); - prune_intervals_end.add( - (int) Math.floor((threshold_LB - v1_UB) * (idx2 - idx1) / (v2_UB - v1_UB) + idx1)); - interval_start = -1; // discontinuous - } else if (v1_UB >= threshold_LB && v2_UB < threshold_LB) { - interval_start = - (int) Math.ceil((threshold_LB - v1_UB) * (idx2 - idx1) / (v2_UB - v1_UB) + idx1); - interval_end = idx2; // continuous + prune_intervals_end.add(interval_end); } - localCursor++; - } - if (interval_start > 0) { - prune_intervals_start.add(interval_start); - prune_intervals_end.add(interval_end); - } - // step 3: calculate unpruned intervals - // TODO deal with time span deletes -> update search_startPos and search_endPos - // note idx starting from 1, pos starting from 0 - int search_startPos = chunkSuit4CPV.startPos; - int search_endPos = chunkSuit4CPV.endPos; - if (prune_intervals_start.size() > 0) { - // deal with time span left virtual delete -> update search_startPos - int prune_idx1 = prune_intervals_start.get(0); - if (prune_idx1 - 1 <= chunkSuit4CPV.startPos) { - // +1 for included, -1 for starting from 0 - search_startPos = Math.max(search_startPos, prune_intervals_end.get(0) + 1 - 1); - prune_intervals_start.remove(0); - prune_intervals_end.remove(0); + // step 3: calculate unpruned intervals + // deal with time span deletes -> update search_startPos and search_endPos + // note idx starting from 1, pos starting from 0 + int search_startPos = chunkSuit4CPV.startPos; + int search_endPos = chunkSuit4CPV.endPos; + if (prune_intervals_start.size() > 0) { + // deal with time span left virtual delete -> update search_startPos + int prune_idx1 = prune_intervals_start.get(0); + if (prune_idx1 - 1 <= chunkSuit4CPV.startPos) { + // +1 for included, -1 for starting from 0 + search_startPos = Math.max(search_startPos, prune_intervals_end.get(0) + 1 - 1); + prune_intervals_start.remove(0); + prune_intervals_end.remove(0); + } } - } - if (prune_intervals_start.size() > 0) { - // deal with time span right virtual delete -> update search_endPos - int prune_idx2 = prune_intervals_end.get(prune_intervals_end.size() - 1); - if (prune_idx2 - 1 >= search_endPos) { - // -1 for included, -1 for starting from 0 - search_endPos = - Math.min( - search_endPos, prune_intervals_start.get(prune_intervals_start.size() - 1) - 1 - 1); - prune_intervals_start.remove(prune_intervals_start.size() - 1); - prune_intervals_end.remove(prune_intervals_end.size() - 1); + if (prune_intervals_start.size() > 0) { + // deal with time span right virtual delete -> update search_endPos + int prune_idx2 = prune_intervals_end.get(prune_intervals_end.size() - 1); + if (prune_idx2 - 1 >= search_endPos) { + // -1 for included, -1 for starting from 0 + search_endPos = + Math.min( + search_endPos, + prune_intervals_start.get(prune_intervals_start.size() - 1) - 1 - 1); + prune_intervals_start.remove(prune_intervals_start.size() - 1); + prune_intervals_end.remove(prune_intervals_end.size() - 1); + } } - } - // add search_endPos+1 to the end of prune_intervals_start - // turning into search_intervals_end (excluded endpoints) - // note that idx&prune_interval&search_interval starting from 1, pos starting from 0 - prune_intervals_start.add(search_endPos + 1 + 1); // +1 for starting from 1, +1 for excluded - // add search_startPos-1 to the start of prune_intervals_end - // turning into search_intervals_start (excluded endpoints) - prune_intervals_end.add(0, search_startPos + 1 - 1); // +1 for starting from 1, +1 for excluded - - // step 4: search unpruned intervals - // TODO deal with normal delete intervals - if (dataType == TSDataType.DOUBLE) { - double candidateTPvalue = -1; - long candidateTPtime = -1; + // add search_endPos+1 to the end of prune_intervals_start + // turning into search_intervals_end (excluded endpoints) // note that idx&prune_interval&search_interval starting from 1, pos starting from 0 - for (int i = 0; i < prune_intervals_start.size(); i++) { - int search_interval_start = prune_intervals_end.get(i) + 1; // included - int search_interval_end = prune_intervals_start.get(i) - 1; // included - for (int j = search_interval_start; j <= search_interval_end; j++) { // idx starting from 1 - double v = valueBuffer.getDouble(timeBufferLength + (j - 1) * 8); // pos starting from 0 - long t = timeBuffer.getLong((j - 1) * 8); // pos starting from 0 - if (v > candidateTPvalue && !isDeleted_NoHistoryDeleteCursor(t)) { - candidateTPvalue = v; - candidateTPtime = t; + prune_intervals_start.add(search_endPos + 1 + 1); // +1 for starting from 1, +1 for excluded + // add search_startPos-1 to the start of prune_intervals_end + // turning into search_intervals_start (excluded endpoints) + prune_intervals_end.add( + 0, search_startPos + 1 - 1); // +1 for starting from 1, +1 for excluded + + // step 4: search unpruned intervals + // also deal with normal delete intervals + if (dataType == TSDataType.DOUBLE) { + double candidateBPvalue = Double.MAX_VALUE; // NOTE for BP + long candidateBPtime = -1; + // note that idx&prune_interval&search_interval starting from 1, pos starting from 0 + for (int i = 0; i < prune_intervals_start.size(); i++) { + int search_interval_start = prune_intervals_end.get(i) + 1; // included + int search_interval_end = prune_intervals_start.get(i) - 1; // included + for (int j = search_interval_start; + j <= search_interval_end; + j++) { // idx starting from 1 + IOMonitor2.DCP_D_traversedPointNum++; // TODO + double v = valueBuffer.getDouble(timeBufferLength + (j - 1) * 8); // pos starting from 0 + long t = timeBuffer.getLong((j - 1) * 8); // pos starting from 0 + if (v < candidateBPvalue && !isDeleted_NoHistoryDeleteCursor(t)) { + candidateBPvalue = v; + candidateBPtime = t; + } } } - } - chunkSuit4CPV.statistics.setMaxInfo(new MinMaxInfo(candidateTPvalue, candidateTPtime)); - } else if (dataType == TSDataType.INT64) { - long candidateTPvalue = -1; // NOTE for TP - long candidateTPtime = -1; - for (int i = 0; i < prune_intervals_start.size(); i++) { - int search_interval_start = prune_intervals_end.get(i) + 1; // included - int search_interval_end = prune_intervals_start.get(i) - 1; // included - for (int j = search_interval_start; j <= search_interval_end; j++) { // starting from 1 - long v = valueBuffer.getLong(timeBufferLength + (j - 1) * 8); - long t = timeBuffer.getLong((j - 1) * 8); - if (v > candidateTPvalue && !isDeleted_NoHistoryDeleteCursor(t)) { - candidateTPvalue = v; - candidateTPtime = t; + chunkSuit4CPV.statistics.setMinInfo(new MinMaxInfo(candidateBPvalue, candidateBPtime)); + } else if (dataType == TSDataType.INT64) { + long candidateBPvalue = Long.MAX_VALUE; // NOTE for BP + long candidateBPtime = -1; + for (int i = 0; i < prune_intervals_start.size(); i++) { + int search_interval_start = prune_intervals_end.get(i) + 1; // included + int search_interval_end = prune_intervals_start.get(i) - 1; // included + for (int j = search_interval_start; j <= search_interval_end; j++) { // starting from 1 + IOMonitor2.DCP_D_traversedPointNum++; // TODO + long v = valueBuffer.getLong(timeBufferLength + (j - 1) * 8); + long t = timeBuffer.getLong((j - 1) * 8); + if (v < candidateBPvalue && !isDeleted_NoHistoryDeleteCursor(t)) { + candidateBPvalue = v; + candidateBPtime = t; + } } } + chunkSuit4CPV.statistics.setMinInfo(new MinMaxInfo(candidateBPvalue, candidateBPtime)); + } else { + throw new UnSupportedDataTypeException(String.valueOf(dataType)); } - chunkSuit4CPV.statistics.setMaxInfo(new MinMaxInfo(candidateTPvalue, candidateTPtime)); } else { - throw new UnSupportedDataTypeException(String.valueOf(dataType)); + updateBPTP(chunkSuit4CPV); } - - // TODO 注意count=0全部点删掉的情况考虑 难道是在isFound=false的时候回到原来方法执行里处理了 + IOMonitor2.addMeasure(Operation.SEARCH_ARRAY_c_genBPTP, System.nanoTime() - start); } public void updateBPTP(ChunkSuit4CPV chunkSuit4CPV) {
