This is an automated email from the ASF dual-hosted git repository.
kangrong pushed a commit to branch f_index_dev
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/f_index_dev by this push:
new 2a3d917 fix index bug and prepare index demo
2a3d917 is described below
commit 2a3d917cccaec67495fd9c5e95e1299f811cd8c2
Author: kr11 <3095717866.com>
AuthorDate: Fri May 14 12:22:56 2021 +0800
fix index bug and prepare index demo
---
.../org/apache/iotdb/db/index/IndexProcessor.java | 3 +-
.../iotdb/db/index/algorithm/RTreeIndex.java | 47 ++++++++---
.../iotdb/db/index/algorithm/elb/ELBIndex.java | 8 +-
.../iotdb/db/index/algorithm/mmhh/MMHHIndex.java | 27 ++-----
.../iotdb/db/index/algorithm/rtree/RTree.java | 37 ++++-----
.../apache/iotdb/db/index/common/IndexUtils.java | 32 +++++++-
.../iotdb/db/index/algorithm/rtree/RTreeTest.java | 30 ++++++-
.../apache/iotdb/db/index/it/DemoMMHHWindIT.java | 94 +++++++++++-----------
.../apache/iotdb/db/index/it/DemoRTreeWindIT.java | 91 +++++++++++----------
.../apache/iotdb/db/index/it/MMHHIndexReadIT.java | 2 +-
10 files changed, 214 insertions(+), 157 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/index/IndexProcessor.java
b/server/src/main/java/org/apache/iotdb/db/index/IndexProcessor.java
index e541479..9795442 100644
--- a/server/src/main/java/org/apache/iotdb/db/index/IndexProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/index/IndexProcessor.java
@@ -62,7 +62,6 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import static org.apache.iotdb.db.index.common.IndexType.ANY_FOR_QUERY;
-import static org.apache.iotdb.db.index.common.IndexType.ELB_INDEX;
/**
* Each {@code IndexProcessor} manages all index instances under an
<b>IndexSeries</b>.
@@ -431,7 +430,7 @@ public class IndexProcessor implements
Comparable<IndexProcessor> {
void endFlushMemTable() {
// wait until all flushing tasks end.
try {
- waitingFlushEndAndDo(()-> allPathsIndexMap.forEach((k,index)->
index.serializeIndex()));
+ waitingFlushEndAndDo(() -> allPathsIndexMap.forEach((k, index) ->
index.serializeIndex()));
} catch (IOException ignored) {
// the exception is ignored
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/index/algorithm/RTreeIndex.java
b/server/src/main/java/org/apache/iotdb/db/index/algorithm/RTreeIndex.java
index a385cc7..0f9d933 100644
--- a/server/src/main/java/org/apache/iotdb/db/index/algorithm/RTreeIndex.java
+++ b/server/src/main/java/org/apache/iotdb/db/index/algorithm/RTreeIndex.java
@@ -49,6 +49,7 @@ import org.apache.iotdb.tsfile.read.common.BatchData;
import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
import org.apache.iotdb.tsfile.read.reader.IBatchReader;
import org.apache.iotdb.tsfile.utils.Pair;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,7 +81,6 @@ import static
org.apache.iotdb.db.index.common.IndexConstant.SEED_PICKER;
import static org.apache.iotdb.db.index.common.IndexConstant.SERIES_LENGTH;
import static org.apache.iotdb.db.index.common.IndexConstant.THRESHOLD;
import static org.apache.iotdb.db.index.common.IndexConstant.TOP_K;
-import static org.apache.iotdb.db.index.common.IndexType.MMHH;
import static org.apache.iotdb.db.index.common.IndexType.RTREE_PAA;
/**
@@ -105,9 +105,7 @@ public abstract class RTreeIndex extends IoTDBIndex {
* <p>The range of dimension {@code i} is {@code [corner[i],
corner[i]+range[i]]}
*/
private final boolean usePointType;
- /**
- * For generality, RTree only store ids of identifiers or others.
- */
+ /** For generality, RTree only store ids of identifiers or others. */
private RTree<PartialPath> rTree;
protected float[] currentLowerBounds;
@@ -116,6 +114,7 @@ public abstract class RTreeIndex extends IoTDBIndex {
// protected double threshold;
// private int amortizedPerInputCost;
private File featureFile;
+ // private PartialPath currentInsertPath;
private PartialPath currentInsertPath;
public RTreeIndex(
@@ -145,7 +144,24 @@ public abstract class RTreeIndex extends IoTDBIndex {
}
try (InputStream inputStream = new FileInputStream(featureFile)) {
logger.info("reload index {} from {}", RTREE_PAA, featureFile);
- this.rTree = RTree.deserialize(inputStream, involvedPathSet);
+ // in is inputStream exactly. It seems duplicate, but it would be really
weird if the second
+ // parameter "deserializeItemFunc" doesn't have an inputStream.
+ this.rTree =
+ RTree.deserialize(
+ inputStream,
+ in -> {
+ try {
+ // PartialPath path = new
+ // PartialPath(ReadWriteIOUtils.readString(inputStream));
+ long seriesId = ReadWriteIOUtils.readLong(in);
+ PartialPath path = IndexUtils.seriesIdToPath(indexSeries,
seriesId);
+ involvedPathSet.add(path);
+ return path;
+ } catch (IOException e) {
+ logger.error("read path error", e);
+ return null;
+ }
+ });
logger.info("Deserialize RTreeIndex rTree: {}",
rTree.toString().substring(0, 10));
logger.info("Deserialize InvolvedSet: {}, {}", involvedPathSet.size(),
involvedPathSet);
} catch (IOException e) {
@@ -159,7 +175,18 @@ public abstract class RTreeIndex extends IoTDBIndex {
logger.info("RTreeIndex RTree to serialized: {}",
rTree.toString().substring(0, 10));
logger.info("Serialize InvolvedSet: {}, {}", involvedPathSet.size(),
involvedPathSet);
try (OutputStream outputStream = new FileOutputStream(featureFile)) {
- rTree.serialize(outputStream);
+ // out is outputStream exactly. It seems redundant, but it would be
really weird if the second
+ // parameter "serializeItem" doesn't input an outputStream.
+ rTree.serialize(
+ outputStream,
+ (v, out) -> {
+ long seriesId = IndexUtils.pathToSeriesId(indexSeries, v);
+ try {
+ ReadWriteIOUtils.write(seriesId, out);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
} catch (IOException e) {
logger.error("Error when serialize router. Given up.", e);
}
@@ -275,16 +302,12 @@ public abstract class RTreeIndex extends IoTDBIndex {
// protected abstract BiConsumer<String, InputStream> getDeserializeFunc();
// protected abstract List<Identifier> getQueryCandidates(List<Integer>
candidateIds);
- /**
- *
- */
+ /** */
protected abstract float[] calcQueryFeature(double[] patterns);
public static class RTreeQueryStruct {
- /**
- * features is represented by float array
- */
+ /** features is represented by float array */
float[] patternFeatures;
// TriFunction<float[], float[], float[], Double> calcLowerDistFunc;
//
diff --git
a/server/src/main/java/org/apache/iotdb/db/index/algorithm/elb/ELBIndex.java
b/server/src/main/java/org/apache/iotdb/db/index/algorithm/elb/ELBIndex.java
index 84f149d..8335e66 100644
--- a/server/src/main/java/org/apache/iotdb/db/index/algorithm/elb/ELBIndex.java
+++ b/server/src/main/java/org/apache/iotdb/db/index/algorithm/elb/ELBIndex.java
@@ -175,10 +175,10 @@ public class ELBIndex extends IoTDBIndex {
}
}
-// @Override
-// public void endFlushTask() {
-// super.endFlushTask();
-// }
+ // @Override
+ // public void endFlushTask() {
+ // super.endFlushTask();
+ // }
@Override
public void serializeIndex() {
diff --git
a/server/src/main/java/org/apache/iotdb/db/index/algorithm/mmhh/MMHHIndex.java
b/server/src/main/java/org/apache/iotdb/db/index/algorithm/mmhh/MMHHIndex.java
index 48fd146..2d20a73 100644
---
a/server/src/main/java/org/apache/iotdb/db/index/algorithm/mmhh/MMHHIndex.java
+++
b/server/src/main/java/org/apache/iotdb/db/index/algorithm/mmhh/MMHHIndex.java
@@ -80,9 +80,7 @@ import static
org.apache.iotdb.db.index.common.IndexConstant.SERIES_LENGTH;
import static org.apache.iotdb.db.index.common.IndexConstant.TOP_K;
import static org.apache.iotdb.db.index.common.IndexType.MMHH;
-/**
- * Refer to: Kang, Rong, et al. Maximum-margin hamming hashing. ICCV.
IEEE/CVF. 2019: 8252-8261.
- */
+/** Refer to: Kang, Rong, et al. Maximum-margin hamming hashing. ICCV.
IEEE/CVF. 2019: 8252-8261. */
public class MMHHIndex extends IoTDBIndex {
private static final Logger logger =
LoggerFactory.getLogger(MMHHIndex.class);
@@ -149,9 +147,7 @@ public class MMHHIndex extends IoTDBIndex {
return res;
}
- /**
- * should be concise into WholeIndex or IoTDBIndex, it's duplicate
- */
+ /** should be concise into WholeIndex or IoTDBIndex, it's duplicate */
@Override
public void endFlushTask() {
super.endFlushTask();
@@ -200,7 +196,7 @@ public class MMHHIndex extends IoTDBIndex {
for (int j = 0; j < bucketSize; j++) {
Long v = ReadWriteIOUtils.readLong(inputStream);
bucket.add(v);
- involvedPathSet.add(seriesIdToPath(v));
+ involvedPathSet.add(IndexUtils.seriesIdToPath(indexSeries, v));
itemSize++;
}
hashLookupTable.put(key, bucket);
@@ -232,9 +228,7 @@ public class MMHHIndex extends IoTDBIndex {
private static class MMHHQueryStruct {
- /**
- * features is represented by float array
- */
+ /** features is represented by float array */
// float[] patternFeatures;
// TriFunction<float[], float[], float[], Double> calcLowerDistFunc;
//
@@ -440,9 +434,7 @@ public class MMHHIndex extends IoTDBIndex {
return res;
}
- /**
- * if res has reached topK
- */
+ /** if res has reached topK */
private boolean scanBucket(
long queryCode,
int doneIdx,
@@ -508,16 +500,9 @@ public class MMHHIndex extends IoTDBIndex {
}
}
- private PartialPath seriesIdToPath(Long seriesId) {
- int len = indexSeries.getNodeLength();
- String[] nodes = Arrays.copyOf(indexSeries.getNodes(), len);
- nodes[len - 2] = seriesId.toString();
- return new PartialPath(nodes);
- }
-
private DistSeries readRawData(
int hammingDist, Long seriesId, Function<PartialPath, TVList>
loadSeriesFunc) {
- PartialPath path = seriesIdToPath(seriesId);
+ PartialPath path = IndexUtils.seriesIdToPath(indexSeries, seriesId);
TVList rawData = loadSeriesFunc.apply(path);
return new DistSeries(hammingDist, rawData, path);
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/index/algorithm/rtree/RTree.java
b/server/src/main/java/org/apache/iotdb/db/index/algorithm/rtree/RTree.java
index 7639447..04eeed2 100644
--- a/server/src/main/java/org/apache/iotdb/db/index/algorithm/rtree/RTree.java
+++ b/server/src/main/java/org/apache/iotdb/db/index/algorithm/rtree/RTree.java
@@ -19,7 +19,6 @@ package org.apache.iotdb.db.index.algorithm.rtree;
import org.apache.iotdb.db.exception.index.IllegalIndexParamException;
import org.apache.iotdb.db.exception.index.IndexRuntimeException;
-import org.apache.iotdb.db.exception.metadata.IllegalPathException;
import org.apache.iotdb.db.index.common.DistSeries;
import org.apache.iotdb.db.index.common.TriFunction;
import org.apache.iotdb.db.index.stats.IndexStatManager;
@@ -43,6 +42,7 @@ import java.util.List;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.Set;
+import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
@@ -390,12 +390,13 @@ public class RTree<T> {
*
* @param outputStream serialize to
*/
- public void serialize(OutputStream outputStream) throws IOException {
+ public void serialize(OutputStream outputStream, BiConsumer<T, OutputStream>
serializeItem)
+ throws IOException {
ReadWriteIOUtils.write(dim, outputStream);
ReadWriteIOUtils.write(nMaxPerNode, outputStream);
ReadWriteIOUtils.write(nMinPerNode, outputStream);
ReadWriteIOUtils.write(seedsPicker.serialize(), outputStream);
- serialize(root, outputStream);
+ serialize(root, outputStream, serializeItem);
}
/**
@@ -404,7 +405,9 @@ public class RTree<T> {
* @param outputStream serialize to
*/
@SuppressWarnings("unchecked")
- private void serialize(RNode node, OutputStream outputStream) throws
IOException {
+ private void serialize(
+ RNode node, OutputStream outputStream, BiConsumer<T, OutputStream>
serializeItem)
+ throws IOException {
if (node instanceof Item) {
ReadWriteIOUtils.write(ITEM, outputStream);
} else if (node.isLeaf) {
@@ -420,39 +423,27 @@ public class RTree<T> {
}
if (node instanceof Item) {
T value = ((Item<T>) node).v;
- ReadWriteIOUtils.write(value.toString(), outputStream);
- // biConsumer.accept(value, outputStream);
+ // ReadWriteIOUtils.write(value.toString(), outputStream);
+ // only the series id
+ serializeItem.accept(value, outputStream);
} else {
// write child
ReadWriteIOUtils.write(node.getChildren().size(), outputStream);
for (RNode child : node.getChildren()) {
- serialize(child, outputStream);
+ serialize(child, outputStream, serializeItem);
}
}
}
- public static RTree<PartialPath> deserialize(InputStream inputStream,
- Set<PartialPath> involvedPathSet)
+ public static RTree<PartialPath> deserialize(
+ InputStream inputStream, Function<InputStream, PartialPath>
deserializeItemFunc)
throws IOException {
int dim = ReadWriteIOUtils.readInt(inputStream);
int nMaxPerNode = ReadWriteIOUtils.readInt(inputStream);
int nMinPerNode = ReadWriteIOUtils.readInt(inputStream);
SeedsPicker seedsPicker =
SeedsPicker.deserialize(ReadWriteIOUtils.readShort(inputStream));
RTree<PartialPath> rTree = new RTree<>(nMaxPerNode, nMinPerNode, dim,
seedsPicker);
- rTree.deserialize(
- rTree,
- null,
- inputStream,
- in -> {
- try {
- PartialPath path = new
PartialPath(ReadWriteIOUtils.readString(inputStream));
- involvedPathSet.add(path);
- return path;
- } catch (IOException | IllegalPathException e) {
- logger.error("read path error", e);
- return null;
- }
- });
+ rTree.deserialize(rTree, null, inputStream, deserializeItemFunc);
return rTree;
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/index/common/IndexUtils.java
b/server/src/main/java/org/apache/iotdb/db/index/common/IndexUtils.java
index f24b78f..06aa36d 100644
--- a/server/src/main/java/org/apache/iotdb/db/index/common/IndexUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/index/common/IndexUtils.java
@@ -32,6 +32,7 @@ import org.apache.iotdb.tsfile.read.TimeValuePair;
import org.apache.iotdb.tsfile.utils.Pair;
import java.io.File;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -226,7 +227,8 @@ public class IndexUtils {
return SystemFileFactory.INSTANCE.getFile(filePath);
}
- private IndexUtils() {}
+ private IndexUtils() {
+ }
public static Map<String, Object> toUpperCaseProps(Map<String, Object>
props) {
Map<String, Object> uppercase = new HashMap<>(props.size());
@@ -272,4 +274,32 @@ public class IndexUtils {
public static String addStarToIndexSeries(String previousDir) {
return previousDir.replace('#', '*');
}
+
+ public static PartialPath seriesIdToPath(PartialPath wildcardIndexSeries,
Long seriesId) {
+ int len = wildcardIndexSeries.getNodeLength();
+ String[] nodes = Arrays.copyOf(wildcardIndexSeries.getNodes(), len);
+
+ for (int i = 1; i < nodes.length; i++) {
+ if ("#".equals(nodes[i]) || "*".equals(nodes[i])) {
+ nodes[i] = seriesId.toString();
+ return new PartialPath(nodes);
+ }
+ }
+ throw new IndexRuntimeException("given index series has no * or #:" +
wildcardIndexSeries);
+ }
+
+ public static Long pathToSeriesId(PartialPath wildcardIndexSeries,
PartialPath path) {
+ String[] wildcardNodes = wildcardIndexSeries.getNodes();
+ String[] pathNodes = path.getNodes();
+ if (wildcardNodes.length != pathNodes.length) {
+ throw new IndexRuntimeException(
+ String.format("given path %s doesn't match index series %s", path,
wildcardIndexSeries));
+ }
+ for (int i = 1; i < wildcardNodes.length; i++) {
+ if ("#".equals(wildcardNodes[i]) || "*".equals(wildcardNodes[i])) {
+ return Long.parseLong(pathNodes[i]);
+ }
+ }
+ throw new IndexRuntimeException("given index series has no * or #:" +
wildcardIndexSeries);
+ }
}
diff --git
a/server/src/test/java/org/apache/iotdb/db/index/algorithm/rtree/RTreeTest.java
b/server/src/test/java/org/apache/iotdb/db/index/algorithm/rtree/RTreeTest.java
index d0fd10d..d3d41ef 100644
---
a/server/src/test/java/org/apache/iotdb/db/index/algorithm/rtree/RTreeTest.java
+++
b/server/src/test/java/org/apache/iotdb/db/index/algorithm/rtree/RTreeTest.java
@@ -17,11 +17,11 @@
*/
package org.apache.iotdb.db.index.algorithm.rtree;
-import java.util.HashSet;
import org.apache.iotdb.db.exception.metadata.IllegalPathException;
import org.apache.iotdb.db.index.algorithm.rtree.RTree.RNode;
import org.apache.iotdb.db.index.algorithm.rtree.RTree.SeedsPicker;
import org.apache.iotdb.db.metadata.PartialPath;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -38,6 +38,7 @@ import static org.junit.Assert.fail;
public class RTreeTest {
@Test
public void testRTreeSerialization() throws IllegalPathException,
IOException {
+ // PartialPath indexSeries = new PartialPath("root.*");
int dim = 2;
Random random = new Random(0);
RTree<PartialPath> rTree = new RTree<>(4, 2, 2, SeedsPicker.LINEAR);
@@ -54,10 +55,31 @@ public class RTreeTest {
}
System.out.println(rTree);
ByteArrayOutputStream out = new ByteArrayOutputStream();
- rTree.serialize(out);
- InputStream in = new ByteArrayInputStream(out.toByteArray());
+ rTree.serialize(
+ out,
+ (v, o) -> {
+ try {
+ ReadWriteIOUtils.write(v.toString(), o);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ InputStream inputStream = new ByteArrayInputStream(out.toByteArray());
- RTree<PartialPath> rTree2 = RTree.deserialize(in, new HashSet<>());
+ RTree<PartialPath> rTree2 =
+ RTree.deserialize(
+ inputStream,
+ in -> {
+ try {
+ // PartialPath path = new
+ // PartialPath(ReadWriteIOUtils.readString(inputStream));
+ PartialPath path = new
PartialPath(ReadWriteIOUtils.readString(inputStream));
+ return path;
+ } catch (IOException | IllegalPathException e) {
+ e.printStackTrace();
+ return null;
+ }
+ });
Assert.assertEquals(rTree.toString(), rTree2.toString());
}
diff --git
a/server/src/test/java/org/apache/iotdb/db/index/it/DemoMMHHWindIT.java
b/server/src/test/java/org/apache/iotdb/db/index/it/DemoMMHHWindIT.java
index 06ef98f..aa2815e 100644
--- a/server/src/test/java/org/apache/iotdb/db/index/it/DemoMMHHWindIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/index/it/DemoMMHHWindIT.java
@@ -18,7 +18,6 @@
*/
package org.apache.iotdb.db.index.it;
-import java.sql.SQLException;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.StartupException;
import org.apache.iotdb.db.index.IndexManager;
@@ -41,12 +40,10 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
import java.sql.Statement;
import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.List;
-import static org.apache.iotdb.db.index.IndexTestUtils.getStringFromList;
import static org.apache.iotdb.db.index.common.IndexConstant.MODEL_PATH;
import static org.apache.iotdb.db.index.common.IndexType.MMHH;
import static org.junit.Assert.fail;
@@ -90,9 +87,9 @@ public class DemoMMHHWindIT {
private void executeNonQuery(String sql) {
try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement();) {
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement(); ) {
statement.execute(sql);
} catch (SQLException e) {
e.printStackTrace();
@@ -102,9 +99,9 @@ public class DemoMMHHWindIT {
private static void insertSQL(boolean createTS) throws
ClassNotFoundException {
Class.forName(Config.JDBC_DRIVER_NAME);
try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement();) {
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement(); ) {
statement.execute(String.format("SET STORAGE GROUP TO %s",
storageGroupSub));
statement.execute(String.format("SET STORAGE GROUP TO %s",
storageGroupWhole));
System.out.println(String.format("SET STORAGE GROUP TO %s",
storageGroupSub));
@@ -208,7 +205,8 @@ public class DemoMMHHWindIT {
public void checkReadWithoutCreateTS() throws ClassNotFoundException,
StartupException {
insertSQL(false);
System.out.println("<<<<<<< Query after insert");
- // MMHH is approximate index. Before flushing, the index hasn't been built
thus the query is turned to scan and sort by euclidean distance.
+ // MMHH is approximate index. Before flushing, the index hasn't been built
thus the query is
+ // turned to scan and sort by euclidean distance.
// Therefore, the first query result might be slightly different from the
later three queries.
checkReads(false);
executeNonQuery("flush");
@@ -225,37 +223,43 @@ public class DemoMMHHWindIT {
private void checkReads(boolean assertResult) throws ClassNotFoundException {
String template = "SELECT TOP 3 speed FROM root.wind2.* WHERE speed LIKE
(%s)";
- String q1Line =
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
- +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
- + "20.0,20.0,20.0,20.0,20.0,"
- +
"20.5,21.0,21.5,22.0,22.5,23.0,23.5,24.0,24.5,25.0,25.5,26.0,26.5,27.0,"
- +
"27.5,28.0,28.5,29.0,29.5,30.0,29.5,29.0,28.5,28.0,27.5,27.0,26.5,26.0,"
- + "25.5,25.0,24.5,24.0,23.5,23.0,22.5,22.0,21.5,21.0,20.5,"
- +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
- +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0";
- String q2Best =
"17.548,16.949,16.906,16.993,17.630,16.945,17.284,16.831,16.706,17.216,"
- +
"16.937,16.196,15.916,15.947,15.200,16.076,16.000,16.152,15.537,15.362,"
- +
"15.737,15.656,15.995,15.698,15.857,15.706,16.643,16.779,16.383,17.665,"
- +
"18.364,19.835,18.765,18.451,19.949,19.530,20.692,20.544,20.879,20.904,"
- +
"21.953,21.726,22.571,23.718,24.009,23.462,23.782,23.871,24.508,24.553,"
- +
"24.843,24.750,25.500,25.127,25.079,24.951,24.683,24.003,22.977,21.877,"
- +
"21.850,21.100,20.499,19.988,19.376,18.960,19.471,17.961,17.570,18.652,"
- +
"18.555,18.401,18.645,17.587,18.056,18.448,17.901,18.105,17.168,18.083,"
- +
"18.283,16.916,17.099,17.115,18.685,17.483,16.859,16.968,16.339,17.476,"
- +
"16.835,16.379,17.312,17.789,17.147,17.456,18.596,18.269,17.956,17.851";
- String q3_76 =
"18.735,18.299,19.216,18.049,18.762,18.739,18.745,18.074,18.398,17.306,"
- +
"17.455,17.401,16.886,16.683,16.413,16.469,17.458,17.429,17.450,16.701,"
- +
"16.932,16.032,16.755,16.264,17.173,16.238,16.335,15.200,16.120,16.209,"
- +
"18.333,18.754,18.621,18.898,19.394,21.456,20.956,22.844,23.484,23.219,"
- +
"23.903,25.306,24.586,25.023,24.670,25.361,25.771,26.625,27.457,27.110,"
- +
"26.849,26.500,26.552,26.922,26.056,25.468,25.656,25.830,25.439,25.058,"
- +
"23.967,24.251,22.794,22.174,21.551,20.847,20.373,20.662,19.614,19.460,"
- +
"18.355,17.562,18.276,18.907,18.524,18.557,18.104,18.487,18.885,19.310,"
- +
"19.461,19.036,19.356,19.737,19.328,19.652,19.566,19.629,18.953,18.839,"
- +
"18.754,19.221,19.215,19.359,19.324,19.729,19.575,19.720,19.591,19.761";
- String gt_q1_line =
"Time,root.wind2.1417439639000.speed.(D_Ham=0),root.wind2.1417437998000.speed.(D_Ham=0),root.wind2.1417403228000.speed.(D_Ham=0),\n";
- String gt_q2_best =
"Time,root.wind2.1417403228000.speed.(D_Ham=0),root.wind2.1417439639000.speed.(D_Ham=0),root.wind2.1417434715000.speed.(D_Ham=0),\n";
- String gt_q3_series76 =
"Time,root.wind2.1417439639000.speed.(D_Ham=0),root.wind2.1417403228000.speed.(D_Ham=0),root.wind2.1417437998000.speed.(D_Ham=0),\n";
+ String q1Line =
+ "20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
+ +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
+ + "20.0,20.0,20.0,20.0,20.0,"
+ +
"20.5,21.0,21.5,22.0,22.5,23.0,23.5,24.0,24.5,25.0,25.5,26.0,26.5,27.0,"
+ +
"27.5,28.0,28.5,29.0,29.5,30.0,29.5,29.0,28.5,28.0,27.5,27.0,26.5,26.0,"
+ + "25.5,25.0,24.5,24.0,23.5,23.0,22.5,22.0,21.5,21.0,20.5,"
+ +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
+ +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0";
+ String q2Best =
+
"17.548,16.949,16.906,16.993,17.630,16.945,17.284,16.831,16.706,17.216,"
+ +
"16.937,16.196,15.916,15.947,15.200,16.076,16.000,16.152,15.537,15.362,"
+ +
"15.737,15.656,15.995,15.698,15.857,15.706,16.643,16.779,16.383,17.665,"
+ +
"18.364,19.835,18.765,18.451,19.949,19.530,20.692,20.544,20.879,20.904,"
+ +
"21.953,21.726,22.571,23.718,24.009,23.462,23.782,23.871,24.508,24.553,"
+ +
"24.843,24.750,25.500,25.127,25.079,24.951,24.683,24.003,22.977,21.877,"
+ +
"21.850,21.100,20.499,19.988,19.376,18.960,19.471,17.961,17.570,18.652,"
+ +
"18.555,18.401,18.645,17.587,18.056,18.448,17.901,18.105,17.168,18.083,"
+ +
"18.283,16.916,17.099,17.115,18.685,17.483,16.859,16.968,16.339,17.476,"
+ +
"16.835,16.379,17.312,17.789,17.147,17.456,18.596,18.269,17.956,17.851";
+ String q3_76 =
+
"18.735,18.299,19.216,18.049,18.762,18.739,18.745,18.074,18.398,17.306,"
+ +
"17.455,17.401,16.886,16.683,16.413,16.469,17.458,17.429,17.450,16.701,"
+ +
"16.932,16.032,16.755,16.264,17.173,16.238,16.335,15.200,16.120,16.209,"
+ +
"18.333,18.754,18.621,18.898,19.394,21.456,20.956,22.844,23.484,23.219,"
+ +
"23.903,25.306,24.586,25.023,24.670,25.361,25.771,26.625,27.457,27.110,"
+ +
"26.849,26.500,26.552,26.922,26.056,25.468,25.656,25.830,25.439,25.058,"
+ +
"23.967,24.251,22.794,22.174,21.551,20.847,20.373,20.662,19.614,19.460,"
+ +
"18.355,17.562,18.276,18.907,18.524,18.557,18.104,18.487,18.885,19.310,"
+ +
"19.461,19.036,19.356,19.737,19.328,19.652,19.566,19.629,18.953,18.839,"
+ +
"18.754,19.221,19.215,19.359,19.324,19.729,19.575,19.720,19.591,19.761";
+ String gt_q1_line =
+
"Time,root.wind2.1417439639000.speed.(D_Ham=0),root.wind2.1417437998000.speed.(D_Ham=0),root.wind2.1417403228000.speed.(D_Ham=0),\n";
+ String gt_q2_best =
+
"Time,root.wind2.1417403228000.speed.(D_Ham=0),root.wind2.1417439639000.speed.(D_Ham=0),root.wind2.1417434715000.speed.(D_Ham=0),\n";
+ String gt_q3_series76 =
+
"Time,root.wind2.1417439639000.speed.(D_Ham=0),root.wind2.1417403228000.speed.(D_Ham=0),root.wind2.1417437998000.speed.(D_Ham=0),\n";
checkRead(String.format(template, q1Line), assertResult ? gt_q1_line :
null, true);
checkRead(String.format(template, q2Best), assertResult ? gt_q2_best :
null, true);
checkRead(String.format(template, q3_76), assertResult ? gt_q3_series76 :
null, true);
@@ -265,10 +269,10 @@ public class DemoMMHHWindIT {
throws ClassNotFoundException {
Class.forName(Config.JDBC_DRIVER_NAME);
try (Connection connection =
- DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root",
"root");
+ DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/",
"root", "root");
Statement statement = connection.createStatement()) {
-// System.out.println(querySQL);
-// statement.setQueryTimeout(200);
+ // System.out.println(querySQL);
+ // statement.setQueryTimeout(200);
boolean hasIndex = statement.execute(querySQL);
// String gt = "Time,root.wind1.azq01.speed.17,\n";
Assert.assertTrue(hasIndex);
diff --git
a/server/src/test/java/org/apache/iotdb/db/index/it/DemoRTreeWindIT.java
b/server/src/test/java/org/apache/iotdb/db/index/it/DemoRTreeWindIT.java
index a85cfb4..d5bd877 100644
--- a/server/src/test/java/org/apache/iotdb/db/index/it/DemoRTreeWindIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/index/it/DemoRTreeWindIT.java
@@ -18,7 +18,6 @@
*/
package org.apache.iotdb.db.index.it;
-import java.sql.SQLException;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.StartupException;
import org.apache.iotdb.db.index.IndexManager;
@@ -40,12 +39,10 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
import java.sql.Statement;
import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.List;
-import static org.apache.iotdb.db.index.IndexTestUtils.getStringFromList;
import static org.apache.iotdb.db.index.common.IndexType.RTREE_PAA;
import static org.junit.Assert.fail;
@@ -87,9 +84,9 @@ public class DemoRTreeWindIT {
private void executeNonQuery(String sql) {
try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement();) {
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement(); ) {
statement.execute(sql);
} catch (SQLException e) {
e.printStackTrace();
@@ -99,9 +96,9 @@ public class DemoRTreeWindIT {
private static void insertSQL(boolean createTS) throws
ClassNotFoundException {
Class.forName(Config.JDBC_DRIVER_NAME);
try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement();) {
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement(); ) {
statement.execute(String.format("SET STORAGE GROUP TO %s",
storageGroupSub));
statement.execute(String.format("SET STORAGE GROUP TO %s",
storageGroupWhole));
System.out.println(String.format("SET STORAGE GROUP TO %s",
storageGroupSub));
@@ -199,37 +196,43 @@ public class DemoRTreeWindIT {
private void checkReads(boolean assertResult) throws ClassNotFoundException {
String template = "SELECT TOP 3 speed FROM root.wind2.* WHERE speed LIKE
(%s)";
- String q1Line =
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
- +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
- + "20.0,20.0,20.0,20.0,20.0,"
- +
"20.5,21.0,21.5,22.0,22.5,23.0,23.5,24.0,24.5,25.0,25.5,26.0,26.5,27.0,"
- +
"27.5,28.0,28.5,29.0,29.5,30.0,29.5,29.0,28.5,28.0,27.5,27.0,26.5,26.0,"
- + "25.5,25.0,24.5,24.0,23.5,23.0,22.5,22.0,21.5,21.0,20.5,"
- +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
- +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0";
- String q2Best =
"17.548,16.949,16.906,16.993,17.630,16.945,17.284,16.831,16.706,17.216,"
- +
"16.937,16.196,15.916,15.947,15.200,16.076,16.000,16.152,15.537,15.362,"
- +
"15.737,15.656,15.995,15.698,15.857,15.706,16.643,16.779,16.383,17.665,"
- +
"18.364,19.835,18.765,18.451,19.949,19.530,20.692,20.544,20.879,20.904,"
- +
"21.953,21.726,22.571,23.718,24.009,23.462,23.782,23.871,24.508,24.553,"
- +
"24.843,24.750,25.500,25.127,25.079,24.951,24.683,24.003,22.977,21.877,"
- +
"21.850,21.100,20.499,19.988,19.376,18.960,19.471,17.961,17.570,18.652,"
- +
"18.555,18.401,18.645,17.587,18.056,18.448,17.901,18.105,17.168,18.083,"
- +
"18.283,16.916,17.099,17.115,18.685,17.483,16.859,16.968,16.339,17.476,"
- +
"16.835,16.379,17.312,17.789,17.147,17.456,18.596,18.269,17.956,17.851";
- String q3_76 =
"18.735,18.299,19.216,18.049,18.762,18.739,18.745,18.074,18.398,17.306,"
- +
"17.455,17.401,16.886,16.683,16.413,16.469,17.458,17.429,17.450,16.701,"
- +
"16.932,16.032,16.755,16.264,17.173,16.238,16.335,15.200,16.120,16.209,"
- +
"18.333,18.754,18.621,18.898,19.394,21.456,20.956,22.844,23.484,23.219,"
- +
"23.903,25.306,24.586,25.023,24.670,25.361,25.771,26.625,27.457,27.110,"
- +
"26.849,26.500,26.552,26.922,26.056,25.468,25.656,25.830,25.439,25.058,"
- +
"23.967,24.251,22.794,22.174,21.551,20.847,20.373,20.662,19.614,19.460,"
- +
"18.355,17.562,18.276,18.907,18.524,18.557,18.104,18.487,18.885,19.310,"
- +
"19.461,19.036,19.356,19.737,19.328,19.652,19.566,19.629,18.953,18.839,"
- +
"18.754,19.221,19.215,19.359,19.324,19.729,19.575,19.720,19.591,19.761";
- String gt_q1_line =
"Time,root.wind2.1417439639000.speed.(D=20.17),root.wind2.1417437998000.speed.(D=32.81),root.wind2.1417437450000.speed.(D=34.97),\n";
- String gt_q2_best =
"Time,root.wind2.1417403228000.speed.(D=16.92),root.wind2.1417439639000.speed.(D=17.02),root.wind2.1417434715000.speed.(D=21.14),\n";
- String gt_q3_series76 =
"Time,root.wind2.1417439639000.speed.(D=0.00),root.wind2.1417403228000.speed.(D=21.57),root.wind2.1417437998000.speed.(D=29.78),\n";
+ String q1Line =
+ "20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
+ +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
+ + "20.0,20.0,20.0,20.0,20.0,"
+ +
"20.5,21.0,21.5,22.0,22.5,23.0,23.5,24.0,24.5,25.0,25.5,26.0,26.5,27.0,"
+ +
"27.5,28.0,28.5,29.0,29.5,30.0,29.5,29.0,28.5,28.0,27.5,27.0,26.5,26.0,"
+ + "25.5,25.0,24.5,24.0,23.5,23.0,22.5,22.0,21.5,21.0,20.5,"
+ +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,"
+ +
"20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0,20.0";
+ String q2Best =
+
"17.548,16.949,16.906,16.993,17.630,16.945,17.284,16.831,16.706,17.216,"
+ +
"16.937,16.196,15.916,15.947,15.200,16.076,16.000,16.152,15.537,15.362,"
+ +
"15.737,15.656,15.995,15.698,15.857,15.706,16.643,16.779,16.383,17.665,"
+ +
"18.364,19.835,18.765,18.451,19.949,19.530,20.692,20.544,20.879,20.904,"
+ +
"21.953,21.726,22.571,23.718,24.009,23.462,23.782,23.871,24.508,24.553,"
+ +
"24.843,24.750,25.500,25.127,25.079,24.951,24.683,24.003,22.977,21.877,"
+ +
"21.850,21.100,20.499,19.988,19.376,18.960,19.471,17.961,17.570,18.652,"
+ +
"18.555,18.401,18.645,17.587,18.056,18.448,17.901,18.105,17.168,18.083,"
+ +
"18.283,16.916,17.099,17.115,18.685,17.483,16.859,16.968,16.339,17.476,"
+ +
"16.835,16.379,17.312,17.789,17.147,17.456,18.596,18.269,17.956,17.851";
+ String q3_76 =
+
"18.735,18.299,19.216,18.049,18.762,18.739,18.745,18.074,18.398,17.306,"
+ +
"17.455,17.401,16.886,16.683,16.413,16.469,17.458,17.429,17.450,16.701,"
+ +
"16.932,16.032,16.755,16.264,17.173,16.238,16.335,15.200,16.120,16.209,"
+ +
"18.333,18.754,18.621,18.898,19.394,21.456,20.956,22.844,23.484,23.219,"
+ +
"23.903,25.306,24.586,25.023,24.670,25.361,25.771,26.625,27.457,27.110,"
+ +
"26.849,26.500,26.552,26.922,26.056,25.468,25.656,25.830,25.439,25.058,"
+ +
"23.967,24.251,22.794,22.174,21.551,20.847,20.373,20.662,19.614,19.460,"
+ +
"18.355,17.562,18.276,18.907,18.524,18.557,18.104,18.487,18.885,19.310,"
+ +
"19.461,19.036,19.356,19.737,19.328,19.652,19.566,19.629,18.953,18.839,"
+ +
"18.754,19.221,19.215,19.359,19.324,19.729,19.575,19.720,19.591,19.761";
+ String gt_q1_line =
+
"Time,root.wind2.1417439639000.speed.(D=20.17),root.wind2.1417437998000.speed.(D=32.81),root.wind2.1417437450000.speed.(D=34.97),\n";
+ String gt_q2_best =
+
"Time,root.wind2.1417403228000.speed.(D=16.92),root.wind2.1417439639000.speed.(D=17.02),root.wind2.1417434715000.speed.(D=21.14),\n";
+ String gt_q3_series76 =
+
"Time,root.wind2.1417439639000.speed.(D=0.00),root.wind2.1417403228000.speed.(D=21.57),root.wind2.1417437998000.speed.(D=29.78),\n";
checkRead(String.format(template, q1Line), assertResult ? gt_q1_line :
null, true);
checkRead(String.format(template, q2Best), assertResult ? gt_q2_best :
null, true);
checkRead(String.format(template, q3_76), assertResult ? gt_q3_series76 :
null, true);
@@ -239,10 +242,10 @@ public class DemoRTreeWindIT {
throws ClassNotFoundException {
Class.forName(Config.JDBC_DRIVER_NAME);
try (Connection connection =
- DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root",
"root");
+ DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/",
"root", "root");
Statement statement = connection.createStatement()) {
-// System.out.println(querySQL);
-// statement.setQueryTimeout(200);
+ // System.out.println(querySQL);
+ // statement.setQueryTimeout(200);
boolean hasIndex = statement.execute(querySQL);
// String gt = "Time,root.wind1.azq01.speed.17,\n";
Assert.assertTrue(hasIndex);
diff --git
a/server/src/test/java/org/apache/iotdb/db/index/it/MMHHIndexReadIT.java
b/server/src/test/java/org/apache/iotdb/db/index/it/MMHHIndexReadIT.java
index 950db1f..b5bb460 100644
--- a/server/src/test/java/org/apache/iotdb/db/index/it/MMHHIndexReadIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/index/it/MMHHIndexReadIT.java
@@ -160,7 +160,7 @@ public class MMHHIndexReadIT {
statement.setQueryTimeout(600);
boolean hasIndex = statement.execute(querySQL);
StringBuilder gt = new StringBuilder();
-
gt.append("Time,root.wind2.1.direction.(D=0.00),root.wind2.2.direction.(D=1.00),\n");
+
gt.append("Time,root.wind2.1.direction.(D_Ham=0),root.wind2.2.direction.(D_Ham=1),\n");
for (int i = 0; i < 100; i++) {
gt.append(String.format("%d,%.1f,%.1f,\n", i, 100f + i, 200f + i));
}