You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ea...@apache.org on 2019/06/15 05:40:13 UTC
[incubator-iotdb] branch feature_async_close_tsfile updated: add
test for bufferwrite query
This is an automated email from the ASF dual-hosted git repository.
east pushed a commit to branch feature_async_close_tsfile
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/feature_async_close_tsfile by this push:
new 407bbad add test for bufferwrite query
407bbad is described below
commit 407bbad92a109a772bca4b6f60f94f5576be5cc8
Author: mdf369 <95...@qq.com>
AuthorDate: Sat Jun 15 13:39:55 2019 +0800
add test for bufferwrite query
---
.../db/engine/filenode/FileNodeProcessorTest.java | 68 +++++++++++++++++++---
1 file changed, 61 insertions(+), 7 deletions(-)
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/filenode/FileNodeProcessorTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/filenode/FileNodeProcessorTest.java
index 5f862e1..6c0ca64 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/filenode/FileNodeProcessorTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/filenode/FileNodeProcessorTest.java
@@ -19,21 +19,32 @@
package org.apache.iotdb.db.engine.filenode;
-import java.io.File;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.engine.MetadataManagerHelper;
import org.apache.iotdb.db.engine.bufferwrite.BufferWriteProcessor;
+import org.apache.iotdb.db.exception.ArgsErrorException;
import org.apache.iotdb.db.exception.BufferWriteProcessorException;
import org.apache.iotdb.db.exception.FileNodeManagerException;
import org.apache.iotdb.db.exception.FileNodeProcessorException;
+import org.apache.iotdb.db.exception.ProcessorException;
+import org.apache.iotdb.db.exception.StartupException;
+import org.apache.iotdb.db.exception.qp.QueryProcessorException;
+import org.apache.iotdb.db.qp.QueryProcessor;
+import org.apache.iotdb.db.qp.executor.OverflowQPExecutor;
+import org.apache.iotdb.db.qp.executor.QueryProcessExecutor;
+import org.apache.iotdb.db.qp.physical.crud.QueryPlan;
import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.common.Path;
+import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
import org.apache.iotdb.tsfile.write.record.TSRecord;
+import org.apache.iotdb.tsfile.write.record.datapoint.DataPoint;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -41,17 +52,24 @@ import org.junit.Test;
public class FileNodeProcessorTest {
+ FileNodeManager fileNodeManager;
FileNodeProcessor processor;
+ private QueryProcessExecutor queryExecutor;
+ private QueryProcessor queryProcessor;
private String deviceId = "root.vehicle.d0";
private String measurementId = "s0";
private TSDataType dataType = TSDataType.INT32;
private String processName = "root.vehicle";
+
@Before
- public void setUp() throws FileNodeProcessorException {
+ public void setUp() throws FileNodeProcessorException, StartupException {
// init metadata
+// EnvironmentUtils.envSetUp();
MetadataManagerHelper.initMetadata();
+ fileNodeManager = FileNodeManager.getInstance();
processor = new FileNodeProcessor(IoTDBDescriptor.getInstance().getConfig().getFileNodeDir(), processName);
-
+ queryExecutor = new OverflowQPExecutor();
+ queryProcessor = new QueryProcessor(queryExecutor);
}
@After
@@ -68,7 +86,7 @@ public class FileNodeProcessorTest {
for (int j = 1; j < 5; j++) {
bwProcessor = processor.getBufferWriteProcessor(processName, System.currentTimeMillis());
for (; i <= 100 * j; i++) {
- bwProcessor.write(deviceId, measurementId, i, TSDataType.INT32, String.valueOf(i));
+ bwProcessor.write(deviceId, measurementId, i, dataType, String.valueOf(i));
}
processor.closeBufferWrite();
}
@@ -77,4 +95,40 @@ public class FileNodeProcessorTest {
Assert.assertEquals(0, processor.getClosingBufferWriteProcessor().size());
}
+
+ @Test
+ public void testBufferWriteQuery()
+ throws ProcessorException, ArgsErrorException, QueryProcessorException, FileNodeManagerException, QueryFilterOptimizationException, IOException {
+
+ int i =1;
+ for (int j = 1; j <= 5; j++) {
+ for (; i <= 100 * j; i++) {
+ TSRecord tsRecord = new TSRecord(i, deviceId).addTuple(DataPoint.getDataPoint(dataType, measurementId, String.valueOf(i)));
+ fileNodeManager.insert(tsRecord, false);
+ }
+ fileNodeManager.closeAll();
+ }
+ QueryPlan queryPlan = (QueryPlan) queryProcessor
+ .parseSQLToPhysicalPlan("select " + new Path(deviceId.replace("root.", ""), measurementId).getFullPath() + " from root");
+
+ int count = 0;
+ QueryDataSet dataSet = queryExecutor.processQuery(queryPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
+ assertTrue(dataSet.hasNext());
+ while (dataSet.hasNext()) {
+ count++;
+ assertEquals(count, dataSet.next().getFields().get(0).getIntV());
+ }
+ assertEquals(500, count);
+
+ processor.waitforAllClosed();
+
+ count = 0;
+ dataSet = queryExecutor.processQuery(queryPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
+ assertTrue(dataSet.hasNext());
+ while (dataSet.hasNext()) {
+ count++;
+ assertEquals(count, dataSet.next().getFields().get(0).getIntV());
+ }
+ assertEquals(500, count);
+ }
}