You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/03/02 08:04:14 UTC
[incubator-iotdb] 01/01: debug
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch debug_series_reader
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit f5886331a3c899078eacfee978f18f78543ee640
Author: qiaojialin <64...@qq.com>
AuthorDate: Mon Mar 2 16:03:56 2020 +0800
debug
---
.../test/java/org/apache/iotdb/jdbc/BatchTest.java | 154 --
.../org/apache/iotdb/jdbc/IoTDBConnectionTest.java | 95 --
.../iotdb/jdbc/IoTDBPreparedStatementTest.java | 309 ----
.../apache/iotdb/jdbc/IoTDBQueryResultSetTest.java | 343 -----
.../apache/iotdb/jdbc/IoTDBResultMetadataTest.java | 167 ---
.../org/apache/iotdb/jdbc/IoTDBStatementTest.java | 101 --
.../test/java/org/apache/iotdb/jdbc/UtilsTest.java | 114 --
.../iotdb/db/auth/LocalFIleRoleAccessorTest.java | 91 --
.../iotdb/db/auth/LocalFileAuthorizerTest.java | 337 -----
.../iotdb/db/auth/LocalFileRoleManagerTest.java | 143 --
.../iotdb/db/auth/LocalFileUserAccessorTest.java | 108 --
.../iotdb/db/auth/LocalFileUserManagerTest.java | 197 ---
.../IoTDBDefaultThreadExceptionHandlerTest.java | 78 -
.../db/concurrent/IoTDBThreadPoolFactoryTest.java | 219 ---
.../conf/adapter/ActiveTimeSeriesCounterTest.java | 122 --
.../db/conf/adapter/CompressionRatioTest.java | 109 --
.../iotdb/db/conf/adapter/HyperLogLogTest.java | 65 -
.../adapter/IoTDBConfigDynamicAdapterTest.java | 137 --
.../strategy/DirectoryStrategyTest.java | 200 ---
.../org/apache/iotdb/db/constant/TestConstant.java | 28 -
.../db/cost/statistic/PerformanceStatTest.java | 107 --
.../iotdb/db/engine/MetadataManagerHelper.java | 91 --
.../db/engine/cache/DeviceMetaDataCacheTest.java | 169 ---
.../db/engine/memtable/MemTableFlushTaskTest.java | 85 --
.../iotdb/db/engine/memtable/MemTablePoolTest.java | 94 --
.../db/engine/memtable/MemTableTestUtils.java | 54 -
.../db/engine/memtable/MemtableBenchmark.java | 58 -
.../db/engine/memtable/PrimitiveMemTableTest.java | 198 ---
.../engine/merge/MaxFileMergeFileSelectorTest.java | 85 --
.../merge/MaxSeriesMergeFileSelectorTest.java | 102 --
.../apache/iotdb/db/engine/merge/MergeLogTest.java | 83 --
.../iotdb/db/engine/merge/MergeOverLapTest.java | 177 ---
.../iotdb/db/engine/merge/MergePerfTest.java | 106 --
.../iotdb/db/engine/merge/MergeTaskTest.java | 260 ----
.../apache/iotdb/db/engine/merge/MergeTest.java | 191 ---
.../iotdb/db/engine/merge/MergeUpgradeTest.java | 161 ---
.../engine/modification/DeletionFileNodeTest.java | 290 ----
.../db/engine/modification/DeletionQueryTest.java | 336 -----
.../engine/modification/ModificationFileTest.java | 101 --
.../io/LocalTextModificationAccessorTest.java | 81 --
.../storagegroup/FileNodeManagerBenchmark.java | 129 --
.../storagegroup/StorageGroupProcessorTest.java | 293 ----
.../iotdb/db/engine/storagegroup/TTLTest.java | 348 -----
.../engine/storagegroup/TsFileProcessorTest.java | 297 ----
.../version/SimpleFileVersionControllerTest.java | 55 -
.../version/SysTimeVersionControllerTest.java | 43 -
.../iotdb/db/integration/IOTDBGroupByIT.java | 524 -------
.../integration/IOTDBGroupByInnerIntervalIT.java | 290 ----
.../iotdb/db/integration/IoTDBAggregationIT.java | 649 ---------
.../integration/IoTDBAggregationLargeDataIT.java | 785 -----------
.../integration/IoTDBAggregationSmallDataIT.java | 686 ---------
.../iotdb/db/integration/IoTDBAlignByDeviceIT.java | 1487 --------------------
.../iotdb/db/integration/IoTDBAuthorizationIT.java | 945 -------------
.../db/integration/IoTDBAutoCreateSchemaIT.java | 150 --
.../apache/iotdb/db/integration/IoTDBCloseIT.java | 198 ---
.../iotdb/db/integration/IoTDBCompleteIT.java | 421 ------
.../apache/iotdb/db/integration/IoTDBDaemonIT.java | 414 ------
.../db/integration/IoTDBDeleteStorageGroupIT.java | 141 --
.../iotdb/db/integration/IoTDBDeletionIT.java | 245 ----
.../iotdb/db/integration/IoTDBDisableAlignIT.java | 401 ------
.../db/integration/IoTDBEngineTimeGeneratorIT.java | 256 ----
.../apache/iotdb/db/integration/IoTDBFillIT.java | 313 ----
.../db/integration/IoTDBFloatPrecisionIT.java | 164 ---
.../db/integration/IoTDBFlushQueryMergeTest.java | 160 ---
.../iotdb/db/integration/IoTDBLargeDataIT.java | 338 -----
.../iotdb/db/integration/IoTDBLimitSlimitIT.java | 206 ---
.../integration/IoTDBLoadExternalTsfileTest.java | 499 -------
.../iotdb/db/integration/IoTDBMergeTest.java | 233 ---
.../iotdb/db/integration/IoTDBMetadataFetchIT.java | 413 ------
.../iotdb/db/integration/IoTDBMultiSeriesIT.java | 434 ------
.../db/integration/IoTDBMultiStatementsIT.java | 189 ---
.../iotdb/db/integration/IoTDBNumberPathIT.java | 428 ------
.../iotdb/db/integration/IoTDBQueryDemoIT.java | 418 ------
.../iotdb/db/integration/IoTDBQuotedPathIT.java | 109 --
.../iotdb/db/integration/IoTDBRecoverIT.java | 321 -----
.../db/integration/IoTDBSequenceDataQueryIT.java | 282 ----
.../iotdb/db/integration/IoTDBSeriesReaderIT.java | 4 -
.../iotdb/db/integration/IoTDBSimpleQueryTest.java | 187 ---
.../iotdb/db/integration/IoTDBTimeZoneIT.java | 137 --
.../apache/iotdb/db/integration/IoTDBTtlIT.java | 198 ---
.../iotdb/db/integration/IoTDBVersionIT.java | 67 -
.../apache/iotdb/db/integration/TestConstant.java | 1 +
.../iotdb/db/metadata/MManagerAdvancedTest.java | 120 --
.../iotdb/db/metadata/MManagerBasicTest.java | 377 -----
.../iotdb/db/metadata/MManagerImproveTest.java | 189 ---
.../org/apache/iotdb/db/metadata/MTreeTest.java | 341 -----
.../iotdb/db/monitor/collector/FileSizeTest.java | 95 --
.../java/org/apache/iotdb/db/qp/PlannerTest.java | 154 --
.../iotdb/db/qp/bench/QueryParseBenchmark.java | 44 -
.../iotdb/db/qp/other/TSPlanContextAuthorTest.java | 78 -
.../iotdb/db/qp/plan/ConcatOptimizerTest.java | 101 --
.../iotdb/db/qp/plan/LogicalPlanSmallTest.java | 218 ---
.../apache/iotdb/db/qp/plan/PhysicalPlanTest.java | 610 --------
.../iotdb/db/qp/strategy/LogicalGeneratorTest.java | 78 -
.../db/query/aggregation/AggregateResultTest.java | 265 ----
.../db/query/control/FileReaderManagerTest.java | 145 --
.../db/query/control/QueryResourceManagerTest.java | 29 -
.../dataset/EngineDataSetWithValueFilterTest.java | 132 --
.../query/executor/GroupByEngineDataSetTest.java | 177 ---
.../query/externalsort/ExternalSortEngineTest.java | 191 ---
.../db/query/externalsort/FakeChunkReaderWrap.java | 45 -
...ExternalSortFileSerializerDeserializerTest.java | 130 --
.../iotdb/db/query/reader/ReaderTestHelper.java | 77 -
.../reader/series/SeriesAggregateReaderTest.java | 116 --
.../reader/series/SeriesReaderByTimestampTest.java | 82 --
.../db/query/reader/series/SeriesReaderTest.java | 127 --
.../query/reader/series/SeriesReaderTestUtil.java | 177 ---
.../query/reader/universal/FakedSeriesReader.java | 88 --
.../reader/universal/PriorityMergeReaderTest.java | 66 -
.../reader/universal/PriorityMergeReaderTest2.java | 58 -
.../org/apache/iotdb/db/script/EnvScriptIT.java | 121 --
.../db/sql/DatetimeQueryDataSetUtilsTest.java | 119 --
.../db/sync/receiver/load/FileLoaderTest.java | 337 -----
.../recover/SyncReceiverLogAnalyzerTest.java | 207 ---
.../receiver/recover/SyncReceiverLoggerTest.java | 112 --
.../db/sync/sender/manage/SyncFileManagerTest.java | 285 ----
.../sender/recover/SyncSenderLogAnalyzerTest.java | 177 ---
.../sync/sender/recover/SyncSenderLoggerTest.java | 111 --
.../db/sync/sender/transfer/SyncClientTest.java | 140 --
.../apache/iotdb/db/tools/IoTDBWatermarkTest.java | 220 ---
.../org/apache/iotdb/db/tools/WalCheckerTest.java | 155 --
.../apache/iotdb/db/utils/EnvironmentUtils.java | 2 +-
.../iotdb/db/utils/MathQueryDataSetUtilsTest.java | 64 -
.../apache/iotdb/db/utils/OpenFileNumUtilTest.java | 288 ----
.../java/org/apache/iotdb/db/utils/RandomNum.java | 70 -
.../iotdb/db/utils/TypeInferenceUtilsTest.java | 53 -
.../db/utils/datastructure/LongTVListTest.java | 93 --
.../iotdb/db/writelog/IoTDBLogFileSizeTest.java | 177 ---
.../apache/iotdb/db/writelog/PerformanceTest.java | 168 ---
.../iotdb/db/writelog/WriteLogNodeManagerTest.java | 107 --
.../apache/iotdb/db/writelog/WriteLogNodeTest.java | 196 ---
.../iotdb/db/writelog/io/LogWriterReaderTest.java | 80 --
.../db/writelog/io/MultiFileLogReaderTest.java | 82 --
.../iotdb/db/writelog/recover/LogReplayerTest.java | 131 --
.../db/writelog/recover/SeqTsFileRecoverTest.java | 242 ----
.../writelog/recover/UnseqTsFileRecoverTest.java | 187 ---
.../apache/iotdb/tsfile/common/LRUCacheTest.java | 53 -
.../apache/iotdb/tsfile/compress/CompressTest.java | 80 --
.../apache/iotdb/tsfile/compress/SnappyTest.java | 82 --
.../apache/iotdb/tsfile/constant/TestConstant.java | 31 -
.../tsfile/encoding/bitpacking/IntPackerTest.java | 79 --
.../tsfile/encoding/bitpacking/LongPackerTest.java | 129 --
.../tsfile/encoding/decoder/BitmapDecoderTest.java | 96 --
.../tsfile/encoding/decoder/FloatDecoderTest.java | 220 ---
.../encoding/decoder/GorillaDecoderTest.java | 257 ----
.../tsfile/encoding/decoder/IntRleDecoderTest.java | 261 ----
.../encoding/decoder/LongRleDecoderTest.java | 225 ---
.../delta/DeltaBinaryEncoderIntegerTest.java | 109 --
.../decoder/delta/DeltaBinaryEncoderLongTest.java | 197 ---
.../regular/RegularDataEncoderIntegerTest.java | 145 --
.../regular/RegularDataEncoderLongTest.java | 223 ---
.../iotdb/tsfile/file/header/PageHeaderTest.java | 111 --
.../file/metadata/ChunkGroupMetaDataTest.java | 108 --
.../file/metadata/TimeSeriesMetadataTest.java | 102 --
.../file/metadata/TsDeviceMetadataIndexTest.java | 77 -
.../tsfile/file/metadata/TsFileMetaDataTest.java | 102 --
.../metadata/statistics/BooleanStatisticsTest.java | 62 -
.../metadata/statistics/DoubleStatisticsTest.java | 71 -
.../metadata/statistics/FloatStatisticsTest.java | 72 -
.../metadata/statistics/IntegerStatisticsTest.java | 68 -
.../metadata/statistics/LongStatisticsTest.java | 96 --
.../metadata/statistics/StringStatisticsTest.java | 60 -
.../tsfile/file/metadata/utils/TestHelper.java | 74 -
.../iotdb/tsfile/file/metadata/utils/Utils.java | 236 ----
.../apache/iotdb/tsfile/read/ExpressionTest.java | 60 -
.../iotdb/tsfile/read/ReadInPartitionTest.java | 240 ----
.../iotdb/tsfile/read/ReadOnlyTsFileTest.java | 160 ---
.../org/apache/iotdb/tsfile/read/ReadTest.java | 374 -----
.../iotdb/tsfile/read/TimePlainEncodeReadTest.java | 367 -----
.../tsfile/read/TsFileRestorableReaderTest.java | 63 -
.../tsfile/read/TsFileSequenceReaderTest.java | 120 --
.../iotdb/tsfile/read/common/BatchDataTest.java | 82 --
.../apache/iotdb/tsfile/read/common/PathTest.java | 89 --
.../iotdb/tsfile/read/common/TimeRangeTest.java | 370 -----
.../tsfile/read/controller/ChunkLoaderTest.java | 64 -
.../controller/IMetadataQuerierByFileImplTest.java | 165 ---
.../tsfile/read/filter/FilterSerializeTest.java | 95 --
.../tsfile/read/filter/GroupByFilterTest.java | 126 --
.../read/filter/IExpressionOptimizerTest.java | 249 ----
.../read/filter/MinTimeMaxTimeFilterTest.java | 215 ---
.../iotdb/tsfile/read/filter/OperatorTest.java | 171 ---
.../tsfile/read/filter/StatisticsFilterTest.java | 108 --
.../read/query/executor/QueryExecutorTest.java | 148 --
.../tsfile/read/query/timegenerator/NodeTest.java | 113 --
.../query/timegenerator/ReaderByTimestampTest.java | 107 --
.../query/timegenerator/TimeGeneratorTest.java | 86 --
.../TsFileGeneratorForSeriesReaderByTimestamp.java | 226 ---
.../iotdb/tsfile/read/reader/FakedBatchReader.java | 55 -
.../iotdb/tsfile/read/reader/PageReaderTest.java | 227 ---
.../iotdb/tsfile/read/reader/ReaderTest.java | 128 --
.../apache/iotdb/tsfile/utils/BloomFilterTest.java | 66 -
.../apache/iotdb/tsfile/utils/BytesUtilsTest.java | 392 ------
.../apache/iotdb/tsfile/utils/FileGenerator.java | 215 ---
.../org/apache/iotdb/tsfile/utils/FileUtils.java | 82 --
.../apache/iotdb/tsfile/utils/FileUtilsTest.java | 54 -
.../org/apache/iotdb/tsfile/utils/PairTest.java | 72 -
.../tsfile/utils/ReadWriteStreamUtilsTest.java | 165 ---
.../tsfile/utils/ReadWriteToBytesUtilsTest.java | 66 -
.../org/apache/iotdb/tsfile/utils/RecordUtils.java | 111 --
.../apache/iotdb/tsfile/utils/RecordUtilsTest.java | 183 ---
.../iotdb/tsfile/utils/StringContainerTest.java | 176 ---
.../iotdb/tsfile/utils/TsFileGeneratorForTest.java | 213 ---
.../iotdb/tsfile/utils/TsPrimitiveTypeTest.java | 60 -
.../org/apache/iotdb/tsfile/write/PerfTest.java | 207 ---
.../iotdb/tsfile/write/ReadPageInMemTest.java | 171 ---
.../iotdb/tsfile/write/TsFileIOWriterTest.java | 109 --
.../iotdb/tsfile/write/TsFileReadWriteTest.java | 232 ---
.../iotdb/tsfile/write/TsFileWriterTest.java | 286 ----
.../org/apache/iotdb/tsfile/write/WriteTest.java | 261 ----
.../write/schema/converter/SchemaBuilderTest.java | 56 -
.../iotdb/tsfile/write/writer/PageWriterTest.java | 221 ---
.../write/writer/RestorableTsFileIOWriterTest.java | 354 -----
tsfile/src/test/resources/logback.xml | 116 --
213 files changed, 2 insertions(+), 39538 deletions(-)
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/BatchTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/BatchTest.java
deleted file mode 100644
index f19edd9..0000000
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/BatchTest.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.jdbc;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
-import java.sql.BatchUpdateException;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSIService;
-import org.apache.iotdb.service.rpc.thrift.TSStatus;
-import org.apache.iotdb.service.rpc.thrift.TSStatusType;
-import org.apache.thrift.TException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-public class BatchTest {
-
- @Mock
- private IoTDBConnection connection;
- @Mock
- private TSIService.Iface client;
- private long sessionId;
- @Mock
- private IoTDBStatement statement;
- private TSStatusType successStatus = new TSStatusType(TSStatusCode.SUCCESS_STATUS.getStatusCode(), "");
- private TSStatusType errorStatus = new TSStatusType(TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), "");
- private TSStatus Status_SUCCESS = new TSStatus(successStatus);
- private TSStatus Status_ERROR = new TSStatus(errorStatus);
- private TSExecuteBatchStatementResp resp;
- private ZoneId zoneID = ZoneId.systemDefault();
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- when(connection.createStatement())
- .thenReturn(new IoTDBStatement(connection, client, sessionId, zoneID, 1L));
-
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @SuppressWarnings("serial")
- @Test
- public void testExecuteBatchSQL1() throws SQLException, TException {
- Statement statement = connection.createStatement();
- resp = new TSExecuteBatchStatementResp(Status_SUCCESS);
- when(client.executeBatchStatement(any(TSExecuteBatchStatementReq.class))).thenReturn(resp);
- int[] result = statement.executeBatch();
- assertEquals(result.length, 0);
-
- List<Integer> resExpected = new ArrayList<Integer>() {
- {
- add(Statement.SUCCESS_NO_INFO);
- add(Statement.SUCCESS_NO_INFO);
- add(Statement.SUCCESS_NO_INFO);
- add(Statement.SUCCESS_NO_INFO);
- add(Statement.SUCCESS_NO_INFO);
- add(Statement.EXECUTE_FAILED);
- add(Statement.SUCCESS_NO_INFO);
- add(Statement.SUCCESS_NO_INFO);
- add(Statement.EXECUTE_FAILED);
- }
- };
- resp.setResult(resExpected);
-
- statement.addBatch("SET STORAGE GROUP TO root.ln.wf01.wt01");
- statement.addBatch(
- "CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN");
- statement.addBatch(
- "CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE");
- statement
- .addBatch("insert into root.ln.wf01.wt01(timestamp,status) values(1509465600000,true)");
- statement
- .addBatch("insert into root.ln.wf01.wt01(timestamp,status) values(1509465660000,true)");
- statement
- .addBatch("insert into root.ln.wf01.wt01(timestamp,status) vvvvvv(1509465720000,false)");
- statement.addBatch(
- "insert into root.ln.wf01.wt01(timestamp,temperature) values(1509465600000,25.957603)");
- statement.addBatch(
- "insert into root.ln.wf01.wt01(timestamp,temperature) values(1509465660000,24.359503)");
- statement.addBatch(
- "insert into root.ln.wf01.wt01(timestamp,temperature) vvvvvv(1509465720000,20.092794)");
- result = statement.executeBatch();
- assertEquals(result.length, resExpected.size());
- for (int i = 0; i < resExpected.size(); i++) {
- assertEquals(result[i], (int) resExpected.get(i));
- }
- statement.clearBatch();
- }
-
- @Test(expected = BatchUpdateException.class)
- public void testExecuteBatchSQL2() throws SQLException, TException {
- Statement statement = connection.createStatement();
- resp = new TSExecuteBatchStatementResp(Status_ERROR);
- when(client.executeBatchStatement(any(TSExecuteBatchStatementReq.class))).thenReturn(resp);
- statement.executeBatch();
- }
-
- @SuppressWarnings("serial")
- @Test
- public void testExecuteBatchSQL3() throws SQLException, TException {
- Statement statement = connection.createStatement();
- resp = new TSExecuteBatchStatementResp(Status_ERROR);
- List<Integer> resExpected = new ArrayList<Integer>() {
- {
- add(Statement.SUCCESS_NO_INFO);
- add(Statement.EXECUTE_FAILED);
- }
- };
- resp.setResult(resExpected);
- when(client.executeBatchStatement(any(TSExecuteBatchStatementReq.class))).thenReturn(resp);
- try {
- statement.executeBatch();
- } catch (BatchUpdateException e) {
- int[] result = e.getUpdateCounts();
- for (int i = 0; i < resExpected.size(); i++) {
- assertEquals(result[i], (int) resExpected.get(i));
- }
- return;
- }
- fail();
- }
-}
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBConnectionTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBConnectionTest.java
deleted file mode 100644
index 787c48b..0000000
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBConnectionTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.jdbc;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.iotdb.service.rpc.thrift.*;
-import org.apache.thrift.TException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-public class IoTDBConnectionTest {
-
- @Mock
- private TSIService.Iface client;
-
- private IoTDBConnection connection = new IoTDBConnection();
- private TSStatusType successStatus = new TSStatusType(TSStatusCode.SUCCESS_STATUS.getStatusCode(), "");
- private TSStatus Status_SUCCESS = new TSStatus(successStatus);
- private long sessionId;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testSetTimeZone() throws TException, IoTDBSQLException {
- String timeZone = "Asia/Shanghai";
- when(client.setTimeZone(any(TSSetTimeZoneReq.class)))
- .thenReturn(new TSStatus(Status_SUCCESS));
- connection.setClient(client);
- connection.setTimeZone(timeZone);
- assertEquals(connection.getTimeZone(), timeZone);
- }
-
- @Test
- public void testGetTimeZone() throws IoTDBSQLException, TException {
- String timeZone = "GMT+:08:00";
- sessionId = connection.getSessionId();
- when(client.getTimeZone(sessionId)).thenReturn(new TSGetTimeZoneResp(Status_SUCCESS, timeZone));
- connection.setClient(client);
- assertEquals(connection.getTimeZone(), timeZone);
- }
-
- @Test
- public void testGetServerProperties() throws IoTDBSQLException, TException {
- final String version = "v0.1";
- @SuppressWarnings("serial") final List<String> supportedAggregationTime = new ArrayList<String>() {
- {
- add("max_time");
- add("min_time");
- }
- };
- final String timestampPrecision = "ms";
- when(client.getProperties())
- .thenReturn(new ServerProperties(version, supportedAggregationTime, timestampPrecision));
- connection.setClient(client);
- assertEquals(connection.getServerProperties().getVersion(), version);
- for (int i = 0; i < supportedAggregationTime.size(); i++) {
- assertEquals(connection.getServerProperties().getSupportedTimeAggregationOperations().get(i),
- supportedAggregationTime.get(i));
- }
- assertEquals(connection.getServerProperties().getTimestampPrecision(), timestampPrecision);
- }
-}
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBPreparedStatementTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBPreparedStatementTest.java
deleted file mode 100644
index b052252..0000000
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBPreparedStatementTest.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.jdbc;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.time.ZoneId;
-
-import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.iotdb.service.rpc.thrift.*;
-import org.apache.iotdb.service.rpc.thrift.TSIService.Iface;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-public class IoTDBPreparedStatementTest {
-
- @Mock
- TSExecuteStatementResp execStatementResp;
- @Mock
- TSStatus getOperationStatusResp;
- private ZoneId zoneId = ZoneId.systemDefault();
- @Mock
- private IoTDBConnection connection;
- @Mock
- private Iface client;
- @Mock
- private TSStatusType successStatus = new TSStatusType(TSStatusCode.SUCCESS_STATUS.getStatusCode(), "");
- private TSStatus Status_SUCCESS = new TSStatus(successStatus);
- private long queryId;
- private long sessionId;
-
- @Before
- public void before() throws Exception {
- MockitoAnnotations.initMocks(this);
- when(execStatementResp.getStatus()).thenReturn(Status_SUCCESS);
- when(execStatementResp.getQueryId()).thenReturn(queryId);
-
- when(client.executeStatement(any(TSExecuteStatementReq.class))).thenReturn(execStatementResp);
- }
-
- @SuppressWarnings("resource")
- @Test
- public void testNonParameterized() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 24 and time > 2017-11-1 0:13:00";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.execute();
-
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 24 and time > 2017-11-1 0:13:00",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void unusedArgument() throws SQLException {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 24 and time > 2017-11-1 0:13:00";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setString(1, "123");
- ps.execute();
- }
-
- @SuppressWarnings("resource")
- @Test(expected = SQLException.class)
- public void unsetArgument() throws SQLException {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 24 and time > ?";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.execute();
- }
-
- @SuppressWarnings("resource")
- @Test
- public void oneIntArgument() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < ? and time > 2017-11-1 0:13:00";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setInt(1, 123);
- ps.execute();
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 123 and time > 2017-11-1 0:13:00",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void oneLongArgument() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < ? and time > 2017-11-1 0:13:00";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setLong(1, 123);
- ps.execute();
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 123 and time > 2017-11-1 0:13:00",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void oneFloatArgument() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < ? and time > 2017-11-1 0:13:00";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setFloat(1, 123.133f);
- ps.execute();
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 123.133 and time > 2017-11-1 0:13:00",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void oneDoubleArgument() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < ? and time > 2017-11-1 0:13:00";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setDouble(1, 123.456);
- ps.execute();
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 123.456 and time > 2017-11-1 0:13:00",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void oneBooleanArgument() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < ? and time > 2017-11-1 0:13:00";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setBoolean(1, false);
- ps.execute();
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < false and time > 2017-11-1 0:13:00",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void oneStringArgument() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < ? and time > 2017-11-1 0:13:00";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setString(1, "abcde");
- ps.execute();
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 'abcde' and time > 2017-11-1 0:13:00",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void oneTimeLongArgument() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE time > ?";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setLong(1, 1233);
- ps.execute();
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals("SELECT status, temperature FROM root.ln.wf01.wt01 WHERE time > 1233",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void oneTimeTimestampArgument() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE time > ?";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setTimestamp(1, Timestamp.valueOf("2017-11-01 00:13:00"));
- ps.execute();
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE time > 2017-11-01T00:13:00",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void escapingOfStringArgument() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE status = '134' and temperature = ?";
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setLong(1, 1333);
- ps.execute();
-
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE status = '134' and temperature = 1333",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void pastingIntoEscapedQuery() throws Exception {
- String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE status = '\\044e' || temperature = ?";
-
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setDouble(1, -1323.0);
- ps.execute();
-
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE status = '\\044e' || temperature = -1323.0",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void testInsertStatement1() throws Exception {
- String sql = "INSERT INTO root.ln.wf01.wt01(timestamp,a,b,c,d,e,f) VALUES(?,?,?,?,?,?,?)";
-
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setLong(1, 12324);
- ps.setBoolean(2, false);
- ps.setInt(3, 123);
- ps.setLong(4, 123234345);
- ps.setFloat(5, 123.423f);
- ps.setDouble(6, -1323.0);
- ps.setString(7, "abc");
- ps.execute();
-
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "INSERT INTO root.ln.wf01.wt01(timestamp,a,b,c,d,e,f) VALUES(12324,false,123,123234345,123.423,-1323.0,'abc')",
- argument.getValue().getStatement());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void testInsertStatement2() throws Exception {
- String sql = "INSERT INTO root.ln.wf01.wt01(timestamp,a,b,c,d,e,f) VALUES(?,?,?,?,?,?,?)";
-
- IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql,
- zoneId);
- ps.setTimestamp(1, Timestamp.valueOf("2017-11-01 00:13:00"));
- ps.setBoolean(2, false);
- ps.setInt(3, 123);
- ps.setLong(4, 123234345);
- ps.setFloat(5, 123.423f);
- ps.setDouble(6, -1323.0);
- ps.setString(7, "abc");
- ps.execute();
-
- ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor
- .forClass(TSExecuteStatementReq.class);
- verify(client).executeStatement(argument.capture());
- assertEquals(
- "INSERT INTO root.ln.wf01.wt01(timestamp,a,b,c,d,e,f) VALUES(2017-11-01T00:13:00,false,123,123234345,123.423,-1323.0,'abc')",
- argument.getValue().getStatement());
- }
-}
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBQueryResultSetTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBQueryResultSetTest.java
deleted file mode 100644
index 80ce9e4..0000000
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBQueryResultSetTest.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.jdbc;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.Statement;
-import java.sql.Types;
-import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.iotdb.service.rpc.thrift.TSCloseOperationReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementReq;
-import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataReq;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataResp;
-import org.apache.iotdb.service.rpc.thrift.TSFetchResultsReq;
-import org.apache.iotdb.service.rpc.thrift.TSFetchResultsResp;
-import org.apache.iotdb.service.rpc.thrift.TSIService;
-import org.apache.iotdb.service.rpc.thrift.TSQueryDataSet;
-import org.apache.iotdb.service.rpc.thrift.TSStatus;
-import org.apache.iotdb.service.rpc.thrift.TSStatusType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-/*
- This class is designed to test the function of TsfileQueryResultSet.
- This class also sheds light on the complete execution process of a query sql from the jdbc perspective.
-
- The test utilizes the mockito framework to mock responses from an IoTDB server.
- The status of the IoTDB server mocked here is determined by the following sql commands:
-
- "SET STORAGE GROUP TO root.vehicle",
- "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s1 WITH DATATYPE=INT64, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s2 WITH DATATYPE=FLOAT, ENCODING=RLE",
- "insert into root.vehicle.d0(timestamp,s0) values(1,101)",
- "insert into root.vehicle.d0(timestamp,s0) values(2,198)",
- "insert into root.vehicle.d0(timestamp,s0) values(100,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(101,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(102,80)",
- "insert into root.vehicle.d0(timestamp,s0) values(103,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(104,90)",
- "insert into root.vehicle.d0(timestamp,s0) values(105,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(106,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(2,10000)",
- "insert into root.vehicle.d0(timestamp,s0) values(50,10000)",
- "insert into root.vehicle.d0(timestamp,s0) values(1000,22222)",
- "DELETE FROM root.vehicle.d0.s0 WHERE time < 104",
- "UPDATE root.vehicle.d0 SET s0 = 33333 WHERE time < 106 and time > 103",
- "insert into root.vehicle.d0(timestamp,s1) values(1,1101)",
- "insert into root.vehicle.d0(timestamp,s1) values(2,198)",
- "insert into root.vehicle.d0(timestamp,s1) values(100,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(101,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(102,180)",
- "insert into root.vehicle.d0(timestamp,s1) values(103,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(104,190)",
- "insert into root.vehicle.d0(timestamp,s1) values(105,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(2,40000)",
- "insert into root.vehicle.d0(timestamp,s1) values(50,50000)",
- "insert into root.vehicle.d0(timestamp,s1) values(1000,55555)",
- "insert into root.vehicle.d0(timestamp,s2) values(1000,55555)",
- "insert into root.vehicle.d0(timestamp,s2) values(2,2.22)",
- "insert into root.vehicle.d0(timestamp,s2) values(3,3.33)",
- "insert into root.vehicle.d0(timestamp,s2) values(4,4.44)",
- "insert into root.vehicle.d0(timestamp,s2) values(102,10.00)",
- "insert into root.vehicle.d0(timestamp,s2) values(105,11.11)",
- "insert into root.vehicle.d0(timestamp,s2) values(1000,1000.11)",
- "insert into root.vehicle.d0(timestamp,s1) values(2000-01-01T08:00:00+08:00, 100)",
- */
-
-public class IoTDBQueryResultSetTest {
-
- @Mock
- TSExecuteStatementResp execResp;
- private long queryId;
- private long sessionId;
- @Mock
- private IoTDBConnection connection;
- @Mock
- private TSIService.Iface client;
- @Mock
- private Statement statement;
- @Mock
- private TSFetchMetadataResp fetchMetadataResp;
- @Mock
- private TSFetchResultsResp fetchResultsResp;
-
- private TSStatusType successStatus = new TSStatusType(TSStatusCode.SUCCESS_STATUS.getStatusCode(),
- "");
- private TSStatus Status_SUCCESS = new TSStatus(successStatus);
- private ZoneId zoneID = ZoneId.systemDefault();
-
- @Before
- public void before() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- statement = new IoTDBStatement(connection, client, sessionId, zoneID);
-
- execResp.queryDataSet = FakedFirstFetchResult();
-
- when(connection.isClosed()).thenReturn(false);
- when(client.executeStatement(any(TSExecuteStatementReq.class))).thenReturn(execResp);
- when(execResp.getQueryId()).thenReturn(queryId);
- when(execResp.getStatus()).thenReturn(Status_SUCCESS);
-
- when(client.fetchMetadata(any(TSFetchMetadataReq.class))).thenReturn(fetchMetadataResp);
- when(fetchMetadataResp.getStatus()).thenReturn(Status_SUCCESS);
-
- when(client.fetchResults(any(TSFetchResultsReq.class))).thenReturn(fetchResultsResp);
- when(fetchResultsResp.getStatus()).thenReturn(Status_SUCCESS);
-
- TSStatus closeResp = Status_SUCCESS;
- when(client.closeOperation(any(TSCloseOperationReq.class))).thenReturn(closeResp);
- }
-
- @SuppressWarnings("resource")
- @Test
- public void testQuery() throws Exception {
-
- String testSql = "select *,s1,s0,s2 from root.vehicle.d0 where s1 > 190 or s2 < 10.0 "
- + "limit 20 slimit 4 soffset 2";
-
- /*
- * step 1: execute statement
- */
- List<String> columns = new ArrayList<>();
- columns.add("root.vehicle.d0.s2");
- columns.add("root.vehicle.d0.s1");
- columns.add("root.vehicle.d0.s0");
- columns.add("root.vehicle.d0.s2");
-
- List<String> dataTypeList = new ArrayList<>();
- dataTypeList.add("FLOAT");
- dataTypeList.add("INT64");
- dataTypeList.add("INT32");
- dataTypeList.add("FLOAT");
-
- when(execResp.isSetColumns()).thenReturn(true);
- when(execResp.getColumns()).thenReturn(columns);
- when(execResp.isSetDataTypeList()).thenReturn(true);
- when(execResp.getDataTypeList()).thenReturn(dataTypeList);
- when(execResp.isSetOperationType()).thenReturn(true);
- when(execResp.getOperationType()).thenReturn("QUERY");
- when(execResp.isSetQueryId()).thenReturn(true);
- when(execResp.getQueryId()).thenReturn(queryId);
- doReturn("FLOAT").doReturn("INT64").doReturn("INT32").doReturn("FLOAT").when(fetchMetadataResp)
- .getDataType();
-
- boolean hasResultSet = statement.execute(testSql);
- Assert.assertTrue(hasResultSet);
-
- verify(fetchMetadataResp, times(0)).getDataType();
-
- /*
- * step 2: fetch result
- */
- fetchResultsResp.hasResultSet = true; // at the first time to fetch
-
- try (ResultSet resultSet = statement.getResultSet()) {
- // check columnInfoMap
- Assert.assertEquals(resultSet.findColumn("Time"), 1);
- Assert.assertEquals(resultSet.findColumn("root.vehicle.d0.s2"), 2);
- Assert.assertEquals(resultSet.findColumn("root.vehicle.d0.s1"), 3);
- Assert.assertEquals(resultSet.findColumn("root.vehicle.d0.s0"), 4);
-
- ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
- // check columnInfoList
- Assert.assertEquals(resultSetMetaData.getColumnName(1), "Time");
- Assert.assertEquals(resultSetMetaData.getColumnName(2), "root.vehicle.d0.s2");
- Assert.assertEquals(resultSetMetaData.getColumnName(3), "root.vehicle.d0.s1");
- Assert.assertEquals(resultSetMetaData.getColumnName(4), "root.vehicle.d0.s0");
- Assert.assertEquals(resultSetMetaData.getColumnName(5), "root.vehicle.d0.s2");
- // check columnTypeList
- Assert.assertEquals(resultSetMetaData.getColumnType(1), Types.TIMESTAMP);
- Assert.assertEquals(resultSetMetaData.getColumnType(2), Types.FLOAT);
- Assert.assertEquals(resultSetMetaData.getColumnType(3), Types.BIGINT);
- Assert.assertEquals(resultSetMetaData.getColumnType(4), Types.INTEGER);
- Assert.assertEquals(resultSetMetaData.getColumnType(5), Types.FLOAT);
- // check fetched result
- int colCount = resultSetMetaData.getColumnCount();
- StringBuilder resultStr = new StringBuilder();
- for (int i = 1; i < colCount + 1; i++) { // meta title
- resultStr.append(resultSetMetaData.getColumnName(i)).append(",");
- }
- resultStr.append("\n");
- while (resultSet.next()) { // data
- for (int i = 1; i <= colCount; i++) {
- resultStr.append(resultSet.getString(i)).append(",");
- }
- resultStr.append("\n");
- fetchResultsResp.hasResultSet = false; // at the second time to fetch
- }
- String standard =
- "Time,root.vehicle.d0.s2,root.vehicle.d0.s1,root.vehicle.d0.s0,root.vehicle.d0.s2,\n"
- + "2,2.22,40000,null,2.22,\n"
- + "3,3.33,null,null,3.33,\n"
- + "4,4.44,null,null,4.44,\n"
- + "50,null,50000,null,null,\n"
- + "100,null,199,null,null,\n"
- + "101,null,199,null,null,\n"
- + "103,null,199,null,null,\n"
- + "105,11.11,199,33333,11.11,\n"
- + "1000,1000.11,55555,22222,1000.11,\n"; // Note the LIMIT&OFFSET clause takes effect
- Assert.assertEquals(standard, resultStr.toString());
- }
-
- // The client get TSQueryDataSet at the first request
- verify(fetchResultsResp, times(1)).getStatus();
- }
-
- // fake the first-time fetched result of 'testSql' from an IoTDB server
- private TSQueryDataSet FakedFirstFetchResult() throws IOException {
- List<TSDataType> tsDataTypeList = new ArrayList<>();
- tsDataTypeList.add(TSDataType.FLOAT); // root.vehicle.d0.s2
- tsDataTypeList.add(TSDataType.INT64); // root.vehicle.d0.s1
- tsDataTypeList.add(TSDataType.INT32); // root.vehicle.d0.s0
-
- Object[][] input = {
- {2L, 2.22F, 40000L, null,},
- {3L, 3.33F, null, null,},
- {4L, 4.44F, null, null,},
- {50L, null, 50000L, null,},
- {100L, null, 199L, null,},
- {101L, null, 199L, null,},
- {103L, null, 199L, null,},
- {105L, 11.11F, 199L, 33333,},
- {1000L, 1000.11F, 55555L, 22222,}};
-
- int columnNum = tsDataTypeList.size();
- TSQueryDataSet tsQueryDataSet = new TSQueryDataSet();
- // one time column and each value column has a actual value buffer and a bitmap value to indicate whether it is a null
- int columnNumWithTime = columnNum * 2 + 1;
- DataOutputStream[] dataOutputStreams = new DataOutputStream[columnNumWithTime];
- ByteArrayOutputStream[] byteArrayOutputStreams = new ByteArrayOutputStream[columnNumWithTime];
- for (int i = 0; i < columnNumWithTime; i++) {
- byteArrayOutputStreams[i] = new ByteArrayOutputStream();
- dataOutputStreams[i] = new DataOutputStream(byteArrayOutputStreams[i]);
- }
-
- int rowCount = input.length;
- int[] valueOccupation = new int[columnNum];
- // used to record a bitmap for every 8 row record
- int[] bitmap = new int[columnNum];
- for (int i = 0; i < rowCount; i++) {
- Object[] row = input[i];
- // use columnOutput to write byte array
- dataOutputStreams[0].writeLong((long) row[0]);
- for (int k = 0; k < columnNum; k++) {
- Object value = row[1 + k];
- DataOutputStream dataOutputStream = dataOutputStreams[2 * k + 1]; // DO NOT FORGET +1
- if (value == null) {
- bitmap[k] = (bitmap[k] << 1);
- } else {
- bitmap[k] = (bitmap[k] << 1) | 0x01;
- if (k == 0) { // TSDataType.FLOAT
- dataOutputStream.writeFloat((float) value);
- valueOccupation[k] += 4;
- } else if (k == 1) { // TSDataType.INT64
- dataOutputStream.writeLong((long) value);
- valueOccupation[k] += 8;
- } else { // TSDataType.INT32
- dataOutputStream.writeInt((int) value);
- valueOccupation[k] += 4;
- }
- }
- }
- if (i % 8 == 7) {
- for (int j = 0; j < bitmap.length; j++) {
- DataOutputStream dataBitmapOutputStream = dataOutputStreams[2 * (j + 1)];
- dataBitmapOutputStream.writeByte(bitmap[j]);
- // we should clear the bitmap every 8 row record
- bitmap[j] = 0;
- }
- }
- }
-
- // feed the remaining bitmap
- for (int j = 0; j < bitmap.length; j++) {
- DataOutputStream dataBitmapOutputStream = dataOutputStreams[2 * (j + 1)];
- dataBitmapOutputStream.writeByte(bitmap[j] << (8 - rowCount % 8));
- }
-
- // calculate the time buffer size
- int timeOccupation = rowCount * 8;
- ByteBuffer timeBuffer = ByteBuffer.allocate(timeOccupation);
- timeBuffer.put(byteArrayOutputStreams[0].toByteArray());
- timeBuffer.flip();
- tsQueryDataSet.setTime(timeBuffer);
-
- // calculate the bitmap buffer size
- int bitmapOccupation = rowCount / 8 + 1;
-
- List<ByteBuffer> bitmapList = new LinkedList<>();
- List<ByteBuffer> valueList = new LinkedList<>();
- for (int i = 1; i < byteArrayOutputStreams.length; i += 2) {
- ByteBuffer valueBuffer = ByteBuffer.allocate(valueOccupation[(i - 1) / 2]);
- valueBuffer.put(byteArrayOutputStreams[i].toByteArray());
- valueBuffer.flip();
- valueList.add(valueBuffer);
-
- ByteBuffer bitmapBuffer = ByteBuffer.allocate(bitmapOccupation);
- bitmapBuffer.put(byteArrayOutputStreams[i + 1].toByteArray());
- bitmapBuffer.flip();
- bitmapList.add(bitmapBuffer);
- }
- tsQueryDataSet.setBitmapList(bitmapList);
- tsQueryDataSet.setValueList(valueList);
- return tsQueryDataSet;
- }
-}
\ No newline at end of file
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java
deleted file mode 100644
index 0664f8e..0000000
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.jdbc;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IoTDBResultMetadataTest {
-
- private IoTDBResultMetadata metadata;
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGetColumnCount() {
- metadata = new IoTDBResultMetadata(null, null, false);
- boolean flag = false;
- try {
- metadata.getColumnCount();
- } catch (Exception e) {
- flag = true;
- }
- assertFalse(flag);
-
- flag = false;
- try {
- metadata = new IoTDBResultMetadata(Collections.emptyList(), null, false);
- metadata.getColumnCount();
- } catch (Exception e) {
- flag = true;
- }
- assertFalse(flag);
-
- List<String> columnInfoList = new ArrayList<>();
- columnInfoList.add("root.a.b.c");
- metadata = new IoTDBResultMetadata(columnInfoList, null, false);
- assertEquals(metadata.getColumnCount(), 1);
- }
-
- @Test
- public void testGetColumnName() throws SQLException {
- metadata = new IoTDBResultMetadata(null, null, false);
- boolean flag = false;
- try {
- metadata.getColumnName(1);
- } catch (Exception e) {
- flag = true;
- }
- assertTrue(flag);
-
- List<String> columnInfoList = new ArrayList<>();
- metadata = new IoTDBResultMetadata(columnInfoList, null, false);
- flag = false;
- try {
- metadata.getColumnName(1);
- } catch (Exception e) {
- flag = true;
- }
- assertTrue(flag);
-
- String[] colums = {"root.a.b.c1", "root.a.b.c2", "root.a.b.c3"};
- metadata = new IoTDBResultMetadata(Arrays.asList(colums), null, false);
- flag = false;
- try {
- metadata.getColumnName(colums.length + 1);
- } catch (Exception e) {
- flag = true;
- }
- assertTrue(flag);
-
- flag = false;
- try {
- metadata.getColumnName(0);
- } catch (Exception e) {
- flag = true;
- }
- assertTrue(flag);
-
- for (int i = 1; i <= colums.length; i++) {
- assertEquals(metadata.getColumnLabel(i), colums[i - 1]);
- }
-
- }
-
- @Test
- public void testGetColumnType() throws SQLException {
- metadata = new IoTDBResultMetadata(null, null, false);
- boolean flag = false;
- try {
- metadata.getColumnType(1);
- } catch (Exception e) {
- flag = true;
- }
- assertTrue(flag);
-
- List<String> columnInfoList = new ArrayList<>();
- metadata = new IoTDBResultMetadata(columnInfoList, null, false);
- flag = false;
- try {
- metadata.getColumnType(1);
- } catch (Exception e) {
- flag = true;
- }
- assertTrue(flag);
-
- String[] columns = {"timestamp", "root.a.b.boolean", "root.a.b.int32", "root.a.b.int64",
- "root.a.b.float",
- "root.a.b.double", "root.a.b.text"};
- String[] typesString = {"BOOLEAN", "INT32", "INT64", "FLOAT", "DOUBLE", "TEXT"};
- int[] types = {Types.BOOLEAN, Types.INTEGER, Types.BIGINT, Types.FLOAT, Types.DOUBLE,
- Types.VARCHAR};
- metadata = new IoTDBResultMetadata(Arrays.asList(columns), Arrays.asList(typesString), false);
- flag = false;
- try {
- metadata.getColumnType(columns.length + 1);
- } catch (Exception e) {
- flag = true;
- }
- assertTrue(flag);
-
- flag = false;
- try {
- metadata.getColumnType(0);
- } catch (Exception e) {
- flag = true;
- }
- assertTrue(flag);
-
- assertEquals(metadata.getColumnType(1), Types.TIMESTAMP);
- for (int i = 1; i <= types.length; i++) {
- assertEquals(metadata.getColumnType(i + 1), types[i - 1]);
- }
- }
-}
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java
deleted file mode 100644
index ebb1741..0000000
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBStatementTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.jdbc;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
-import java.sql.SQLException;
-import java.time.ZoneId;
-import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataReq;
-import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataResp;
-import org.apache.iotdb.service.rpc.thrift.TSIService.Iface;
-import org.apache.iotdb.service.rpc.thrift.TSStatus;
-import org.apache.iotdb.service.rpc.thrift.TSStatusType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-public class IoTDBStatementTest {
-
- @Mock
- private IoTDBConnection connection;
-
- @Mock
- private Iface client;
-
- private long sessionId;
-
- @Mock
- private TSFetchMetadataResp fetchMetadataResp;
-
- private TSStatusType successStatus = new TSStatusType(TSStatusCode.SUCCESS_STATUS.getStatusCode(), "");
- private TSStatus Status_SUCCESS = new TSStatus(successStatus);
- private ZoneId zoneID = ZoneId.systemDefault();
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- when(connection.getMetaData()).thenReturn(new IoTDBDatabaseMetadata(connection, client, sessionId));
- when(connection.isClosed()).thenReturn(false);
- when(client.fetchMetadata(any(TSFetchMetadataReq.class))).thenReturn(fetchMetadataResp);
- when(fetchMetadataResp.getStatus()).thenReturn(Status_SUCCESS);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
-
- @SuppressWarnings("resource")
- @Test
- public void testSetFetchSize1() throws SQLException {
- IoTDBStatement stmt = new IoTDBStatement(connection, client, sessionId, zoneID);
- stmt.setFetchSize(123);
- assertEquals(123, stmt.getFetchSize());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void testSetFetchSize2() throws SQLException {
- IoTDBStatement stmt = new IoTDBStatement(connection, client, sessionId, zoneID);
- int initial = stmt.getFetchSize();
- stmt.setFetchSize(0);
- assertEquals(initial, stmt.getFetchSize());
- }
-
- @SuppressWarnings("resource")
- @Test
- public void testSetFetchSize3() throws SQLException {
- final int fetchSize = 10000;
- IoTDBStatement stmt = new IoTDBStatement(connection, client, sessionId, fetchSize, zoneID);
- assertEquals(fetchSize, stmt.getFetchSize());
- }
-
- @SuppressWarnings("resource")
- @Test(expected = SQLException.class)
- public void testSetFetchSize4() throws SQLException {
- IoTDBStatement stmt = new IoTDBStatement(connection, client, sessionId, zoneID);
- stmt.setFetchSize(-1);
- }
-}
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java
deleted file mode 100644
index 34a0c3e..0000000
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.jdbc;
-
-import org.apache.iotdb.rpc.RpcUtils;
-import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.iotdb.service.rpc.thrift.TSStatus;
-import org.apache.iotdb.service.rpc.thrift.TSStatusType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Properties;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-public class UtilsTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testParseURL() throws IoTDBURLException {
- String userName = "test";
- String userPwd = "test";
- String host1 = "localhost";
- int port = 6667;
- Properties properties = new Properties();
- properties.setProperty(Config.AUTH_USER, userName);
- properties.setProperty(Config.AUTH_PASSWORD, userPwd);
- IoTDBConnectionParams params = Utils
- .parseUrl(String.format(Config.IOTDB_URL_PREFIX + "%s:%s/", host1, port),
- properties);
- assertEquals(params.getHost(), host1);
- assertEquals(params.getPort(), port);
- assertEquals(params.getUsername(), userName);
- assertEquals(params.getPassword(), userPwd);
-
- params = Utils.parseUrl(String.format(Config.IOTDB_URL_PREFIX + "%s:%s", host1, port), properties);
- assertEquals(params.getHost(), host1);
- assertEquals(params.getPort(), port);
- assertEquals(params.getUsername(), userName);
- assertEquals(params.getPassword(), userPwd);
- }
-
- @Test(expected = IoTDBURLException.class)
- public void testParseWrongUrl1() throws IoTDBURLException {
- Properties properties = new Properties();
- Utils.parseUrl("jdbc:iotdb//test6667", properties);
- }
-
- @Test(expected = IoTDBURLException.class)
- public void testParseWrongUrl2() throws IoTDBURLException {
- Properties properties = new Properties();
- Utils.parseUrl("jdbc:iotdb//test:test:test:6667:6667", properties);
- }
-
- @Test(expected = IoTDBURLException.class)
- public void testParseWrongPort() throws IoTDBURLException {
- String userName = "test";
- String userPwd = "test";
- String host = "localhost";
- int port = 66699999;
- Properties properties = new Properties();
- properties.setProperty(Config.AUTH_USER, userName);
- properties.setProperty(Config.AUTH_PASSWORD, userPwd);
- IoTDBConnectionParams params = Utils
- .parseUrl(String.format(Config.IOTDB_URL_PREFIX + "%s:%s/", host, port),
- properties);
- }
-
- @Test
- public void testVerifySuccess() {
- try {
- TSStatusType successStatus = new TSStatusType(TSStatusCode.SUCCESS_STATUS.getStatusCode(),
- "");
- RpcUtils.verifySuccess(new TSStatus(successStatus));
- } catch (Exception e) {
- fail();
- }
-
- try {
- TSStatusType errorStatus = new TSStatusType(
- TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), "");
- RpcUtils.verifySuccess(new TSStatus(errorStatus));
- } catch (Exception e) {
- return;
- }
- fail();
- }
-
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/auth/LocalFIleRoleAccessorTest.java b/server/src/test/java/org/apache/iotdb/db/auth/LocalFIleRoleAccessorTest.java
deleted file mode 100644
index 4203d4b..0000000
--- a/server/src/test/java/org/apache/iotdb/db/auth/LocalFIleRoleAccessorTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.auth;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.auth.entity.PathPrivilege;
-import org.apache.iotdb.db.auth.entity.Role;
-import org.apache.iotdb.db.auth.role.LocalFileRoleAccessor;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class LocalFIleRoleAccessorTest {
-
- private File testFolder;
- private LocalFileRoleAccessor accessor;
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- testFolder = new File(TestConstant.BASE_OUTPUT_PATH.concat("test"));
- testFolder.mkdirs();
- accessor = new LocalFileRoleAccessor(testFolder.getPath());
- }
-
- @After
- public void tearDown() throws Exception {
- FileUtils.deleteDirectory(testFolder);
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void test() throws IOException {
- Role[] roles = new Role[5];
- for (int i = 0; i < roles.length; i++) {
- roles[i] = new Role("role" + i);
- for (int j = 0; j <= i; j++) {
- PathPrivilege pathPrivilege = new PathPrivilege("root.a.b.c" + j);
- pathPrivilege.getPrivileges().add(j);
- roles[i].getPrivilegeList().add(pathPrivilege);
- }
- }
-
- // save
- for (Role role : roles) {
- accessor.saveRole(role);
- }
-
- // load
- for (Role role : roles) {
- Role loadedRole = accessor.loadRole(role.getName());
- assertEquals(role, loadedRole);
- }
- assertEquals(null, accessor.loadRole("not a role"));
-
- // delete
- assertEquals(true, accessor.deleteRole(roles[roles.length - 1].getName()));
- assertEquals(false, accessor.deleteRole(roles[roles.length - 1].getName()));
- assertEquals(null, accessor.loadRole(roles[roles.length - 1].getName()));
-
- // list
- List<String> roleNames = accessor.listAllRoles();
- roleNames.sort(null);
- for (int i = 0; i < roleNames.size(); i++) {
- assertEquals(roles[i].getName(), roleNames.get(i));
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/auth/LocalFileAuthorizerTest.java b/server/src/test/java/org/apache/iotdb/db/auth/LocalFileAuthorizerTest.java
deleted file mode 100644
index f4a01d7..0000000
--- a/server/src/test/java/org/apache/iotdb/db/auth/LocalFileAuthorizerTest.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.auth;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-import java.util.Set;
-import org.apache.iotdb.db.auth.authorizer.IAuthorizer;
-import org.apache.iotdb.db.auth.authorizer.LocalFileAuthorizer;
-import org.apache.iotdb.db.auth.entity.User;
-import org.apache.iotdb.db.conf.IoTDBConstant;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class LocalFileAuthorizerTest {
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void testAuthorizer() throws AuthException {
-
- IAuthorizer authorizer = LocalFileAuthorizer.getInstance();
- /*
- * login
- */
- try {
- authorizer.login("root", "root");
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- try {
- authorizer.login("root", "error");
- } catch (AuthException e) {
- assertEquals("The username or the password is not correct", e.getMessage());
- }
- /*
- * create user,delete user
- */
- User user = new User("user", "password");
- try {
- authorizer.createUser(user.getName(), user.getPassword());
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.createUser(user.getName(), user.getPassword());
- } catch (AuthException e) {
- assertEquals("User user already exists", e.getMessage());
- }
- try {
- authorizer.login(user.getName(), user.getPassword());
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.deleteUser(user.getName());
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.deleteUser(user.getName());
- } catch (AuthException e) {
- assertEquals("User user does not exist", e.getMessage());
- }
-
- /*
- * permission for user
- */
- String nodeName = "root.laptop.d1";
- try {
- authorizer.createUser(user.getName(), user.getPassword());
- authorizer.grantPrivilegeToUser(user.getName(), nodeName, 1);
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.grantPrivilegeToUser(user.getName(), nodeName, 1);
- } catch (AuthException e) {
- assertEquals("User user already has INSERT_TIMESERIES on root.laptop.d1", e.getMessage());
- }
- try {
- authorizer.grantPrivilegeToUser("error", nodeName, 1);
- } catch (AuthException e) {
- assertEquals("No such user error", e.getMessage());
- }
- try {
- authorizer.revokePrivilegeFromUser(user.getName(), nodeName, 1);
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.revokePrivilegeFromUser(user.getName(), nodeName, 1);
- } catch (AuthException e) {
- assertEquals("User user does not have INSERT_TIMESERIES on root.laptop.d1", e.getMessage());
- }
- try {
- authorizer.deleteUser(user.getName());
- authorizer.revokePrivilegeFromUser(user.getName(), nodeName, 1);
- } catch (AuthException e) {
- assertEquals("No such user user", e.getMessage());
- }
- /*
- * role
- */
- String roleName = "role";
- try {
- authorizer.createRole(roleName);
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.createRole(roleName);
- } catch (AuthException e) {
- assertEquals("Role role already exists", e.getMessage());
- }
-
- try {
- authorizer.deleteRole(roleName);
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.deleteRole(roleName);
- } catch (AuthException e) {
- assertEquals("Role role does not exist", e.getMessage());
- }
- /*
- * role permission
- */
- try {
- authorizer.createRole(roleName);
- authorizer.grantPrivilegeToRole(roleName, nodeName, 1);
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- try {
- authorizer.grantPrivilegeToRole(roleName, nodeName, 1);
- } catch (AuthException e) {
- assertEquals("Role role already has INSERT_TIMESERIES on root.laptop.d1", e.getMessage());
- }
-
- try {
- authorizer.revokePrivilegeFromRole(roleName, nodeName, 1);
- } catch (AuthException e1) {
- fail(e1.getMessage());
- }
- try {
- authorizer.revokePrivilegeFromRole(roleName, nodeName, 1);
- } catch (AuthException e) {
- assertEquals("Role role does not have INSERT_TIMESERIES on root.laptop.d1", e.getMessage());
- }
-
- try {
- authorizer.deleteRole(roleName);
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- try {
- authorizer.revokePrivilegeFromRole(roleName, nodeName, 1);
- } catch (AuthException e) {
- assertEquals("No such role role", e.getMessage());
- }
- try {
- authorizer.grantPrivilegeToRole(roleName, nodeName, 1);
- } catch (AuthException e) {
- assertEquals("No such role role", e.getMessage());
- }
-
- /*
- * user role
- */
- try {
- authorizer.createUser(user.getName(), user.getPassword());
- authorizer.createRole(roleName);
- authorizer.grantRoleToUser(roleName, user.getName());
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.grantPrivilegeToUser(user.getName(), nodeName, 1);
- authorizer.grantPrivilegeToRole(roleName, nodeName, 2);
- authorizer.grantPrivilegeToRole(roleName, nodeName, 3);
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- Set<Integer> permisssions = authorizer.getPrivileges(user.getName(), nodeName);
- assertEquals(3, permisssions.size());
- assertTrue(permisssions.contains(1));
- assertTrue(permisssions.contains(2));
- assertTrue(permisssions.contains(3));
- assertFalse(permisssions.contains(4));
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.revokeRoleFromUser(roleName, user.getName());
- Set<Integer> permisssions = authorizer.getPrivileges(user.getName(), nodeName);
- assertEquals(1, permisssions.size());
- assertTrue(permisssions.contains(1));
- assertFalse(permisssions.contains(2));
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.checkUserPrivileges(user.getName(), nodeName, 1);
- } catch (AuthException e) {
- fail(e.getMessage());
- }
- try {
- authorizer.checkUserPrivileges(user.getName(), nodeName, 2);
- } catch (AuthException e) {
- fail(e.getMessage());
- }
- try {
- authorizer.updateUserPassword(user.getName(), "newPassword");
- authorizer.login(user.getName(), "newPassword");
- } catch (AuthException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- try {
- authorizer.deleteUser(user.getName());
- authorizer.deleteRole(roleName);
- } catch (AuthException e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testListUser() throws AuthException {
- IAuthorizer authorizer = LocalFileAuthorizer.getInstance();
- List<String> userList = authorizer.listAllUsers();
- assertEquals(1, userList.size());
- assertEquals(IoTDBConstant.ADMIN_NAME, userList.get(0));
-
- int userCnt = 10;
- for (int i = 0; i < userCnt; i++) {
- authorizer.createUser("newUser" + i, "password" + i);
- }
- userList = authorizer.listAllUsers();
- assertEquals(11, userList.size());
- for (int i = 0; i < userCnt; i++) {
- assertEquals("newUser" + i, userList.get(i));
- }
-
- for (int i = 0; i < userCnt; i++) {
- if (i % 2 == 0) {
- authorizer.deleteUser("newUser" + i);
- }
- }
- userList = authorizer.listAllUsers();
- assertEquals(6, userList.size());
- for (int i = 0; i < userCnt; i++) {
- if (i % 2 == 1) {
- assertEquals("newUser" + i, userList.get(i / 2));
- }
- }
- }
-
- @Test
- public void testListRole() throws AuthException {
- IAuthorizer authorizer = LocalFileAuthorizer.getInstance();
- List<String> roleList = authorizer.listAllRoles();
- assertEquals(0, roleList.size());
-
- int roleCnt = 10;
- for (int i = 0; i < roleCnt; i++) {
- authorizer.createRole("newRole" + i);
- }
- roleList = authorizer.listAllRoles();
- assertEquals(10, roleList.size());
- for (int i = 0; i < roleCnt; i++) {
- assertEquals("newRole" + i, roleList.get(i));
- }
-
- for (int i = 0; i < roleCnt; i++) {
- if (i % 2 == 0) {
- authorizer.deleteRole("newRole" + i);
- }
- }
- roleList = authorizer.listAllRoles();
- assertEquals(5, roleList.size());
- for (int i = 0; i < roleCnt; i++) {
- if (i % 2 == 1) {
- assertEquals("newRole" + i, roleList.get(i / 2));
- }
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/auth/LocalFileRoleManagerTest.java b/server/src/test/java/org/apache/iotdb/db/auth/LocalFileRoleManagerTest.java
deleted file mode 100644
index 9bb836f..0000000
--- a/server/src/test/java/org/apache/iotdb/db/auth/LocalFileRoleManagerTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.auth;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.auth.entity.PathPrivilege;
-import org.apache.iotdb.db.auth.entity.Role;
-import org.apache.iotdb.db.auth.role.LocalFileRoleManager;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class LocalFileRoleManagerTest {
-
- private File testFolder;
- private LocalFileRoleManager manager;
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- testFolder = new File(TestConstant.BASE_OUTPUT_PATH.concat("test"));
- testFolder.mkdirs();
- manager = new LocalFileRoleManager(testFolder.getPath());
- }
-
- @After
- public void tearDown() throws Exception {
- FileUtils.deleteDirectory(testFolder);
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void test() throws AuthException {
- Role[] roles = new Role[5];
- for (int i = 0; i < roles.length; i++) {
- roles[i] = new Role("role" + i);
- for (int j = 0; j <= i; j++) {
- PathPrivilege pathPrivilege = new PathPrivilege("root.a.b.c" + j);
- pathPrivilege.getPrivileges().add(j);
- roles[i].getPrivilegeList().add(pathPrivilege);
- }
- }
-
- // create
- Role role = manager.getRole(roles[0].getName());
- assertEquals(null, role);
- for (Role role1 : roles) {
- assertEquals(true, manager.createRole(role1.getName()));
- }
- for (Role role1 : roles) {
- role = manager.getRole(role1.getName());
- assertEquals(role1.getName(), role.getName());
- }
-
- assertEquals(false, manager.createRole(roles[0].getName()));
- boolean caught = false;
- try {
- manager.createRole("too");
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
-
- // delete
- assertEquals(false, manager.deleteRole("not a role"));
- assertEquals(true, manager.deleteRole(roles[roles.length - 1].getName()));
- assertEquals(null, manager.getRole(roles[roles.length - 1].getName()));
- assertEquals(false, manager.deleteRole(roles[roles.length - 1].getName()));
-
- // grant privilege
- role = manager.getRole(roles[0].getName());
- String path = "root.a.b.c";
- int privilegeId = 0;
- assertEquals(false, role.hasPrivilege(path, privilegeId));
- assertEquals(true, manager.grantPrivilegeToRole(role.getName(), path, privilegeId));
- assertEquals(true, manager.grantPrivilegeToRole(role.getName(), path, privilegeId + 1));
- assertEquals(false, manager.grantPrivilegeToRole(role.getName(), path, privilegeId));
- role = manager.getRole(roles[0].getName());
- assertEquals(true, role.hasPrivilege(path, privilegeId));
- caught = false;
- try {
- manager.grantPrivilegeToRole("not a role", path, privilegeId);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
- caught = false;
- try {
- manager.grantPrivilegeToRole(role.getName(), path, -1);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
-
- // revoke privilege
- role = manager.getRole(roles[0].getName());
- assertEquals(true, manager.revokePrivilegeFromRole(role.getName(), path, privilegeId));
- assertEquals(false, manager.revokePrivilegeFromRole(role.getName(), path, privilegeId));
- caught = false;
- try {
- manager.revokePrivilegeFromRole("not a role", path, privilegeId);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
- caught = false;
- try {
- manager.revokePrivilegeFromRole(role.getName(), path, -1);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
-
- // list roles
- List<String> rolenames = manager.listAllRoles();
- rolenames.sort(null);
- for (int i = 0; i < roles.length - 1; i++) {
- assertEquals(roles[i].getName(), rolenames.get(i));
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/auth/LocalFileUserAccessorTest.java b/server/src/test/java/org/apache/iotdb/db/auth/LocalFileUserAccessorTest.java
deleted file mode 100644
index 18c636e..0000000
--- a/server/src/test/java/org/apache/iotdb/db/auth/LocalFileUserAccessorTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.auth;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.auth.entity.PathPrivilege;
-import org.apache.iotdb.db.auth.entity.User;
-import org.apache.iotdb.db.auth.user.LocalFileUserAccessor;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class LocalFileUserAccessorTest {
-
- private File testFolder;
- private LocalFileUserAccessor accessor;
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- testFolder = new File(TestConstant.BASE_OUTPUT_PATH.concat("test"));
- testFolder.mkdirs();
- accessor = new LocalFileUserAccessor(testFolder.getPath());
- }
-
- @After
- public void tearDown() throws Exception {
- FileUtils.deleteDirectory(testFolder);
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void test() throws IOException {
- User[] users = new User[5];
- for (int i = 0; i < users.length; i++) {
- users[i] = new User("user" + i, "password" + i);
- for (int j = 0; j <= i; j++) {
- PathPrivilege pathPrivilege = new PathPrivilege("root.a.b.c" + j);
- pathPrivilege.getPrivileges().add(j);
- users[i].getPrivilegeList().add(pathPrivilege);
- users[i].getRoleList().add("role" + j);
- }
- }
-
- // save
- for (User user : users) {
- try {
- accessor.saveUser(user);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- // load
- for (User user : users) {
- try {
- User loadedUser = accessor.loadUser(user.getName());
- assertEquals(user, loadedUser);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
- assertEquals(null, accessor.loadUser("not a user"));
-
- // list
- List<String> usernames = accessor.listAllUsers();
- usernames.sort(null);
- for (int i = 0; i < users.length; i++) {
- assertEquals(users[i].getName(), usernames.get(i));
- }
-
- // delete
- assertEquals(false, accessor.deleteUser("not a user"));
- assertEquals(true, accessor.deleteUser(users[users.length - 1].getName()));
- usernames = accessor.listAllUsers();
- assertEquals(users.length - 1, usernames.size());
- usernames.sort(null);
- for (int i = 0; i < users.length - 1; i++) {
- assertEquals(users[i].getName(), usernames.get(i));
- }
- User nullUser = accessor.loadUser(users[users.length - 1].getName());
- assertEquals(null, nullUser);
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/auth/LocalFileUserManagerTest.java b/server/src/test/java/org/apache/iotdb/db/auth/LocalFileUserManagerTest.java
deleted file mode 100644
index 919c17c..0000000
--- a/server/src/test/java/org/apache/iotdb/db/auth/LocalFileUserManagerTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.auth;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.auth.entity.PathPrivilege;
-import org.apache.iotdb.db.auth.entity.User;
-import org.apache.iotdb.db.auth.user.LocalFileUserManager;
-import org.apache.iotdb.db.conf.IoTDBConstant;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.utils.AuthUtils;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class LocalFileUserManagerTest {
-
- private File testFolder;
- private LocalFileUserManager manager;
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- testFolder = new File(TestConstant.BASE_OUTPUT_PATH.concat("test"));
- testFolder.mkdirs();
- manager = new LocalFileUserManager(testFolder.getPath());
- }
-
- @After
- public void tearDown() throws Exception {
- FileUtils.deleteDirectory(testFolder);
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void test() throws AuthException {
- User[] users = new User[5];
- for (int i = 0; i < users.length; i++) {
- users[i] = new User("user" + i, "password" + i);
- for (int j = 0; j <= i; j++) {
- PathPrivilege pathPrivilege = new PathPrivilege("root.a.b.c" + j);
- pathPrivilege.getPrivileges().add(j);
- users[i].getPrivilegeList().add(pathPrivilege);
- users[i].getRoleList().add("role" + j);
- }
- }
-
- // create
- User user = manager.getUser(users[0].getName());
- assertEquals(null, user);
- for (User user1 : users) {
- assertEquals(true, manager.createUser(user1.getName(), user1.getPassword()));
- }
- for (User user1 : users) {
- user = manager.getUser(user1.getName());
- assertEquals(user1.getName(), user.getName());
- assertEquals(AuthUtils.encryptPassword(user1.getPassword()), user.getPassword());
- }
-
- assertEquals(false, manager.createUser(users[0].getName(), users[0].getPassword()));
- boolean caught = false;
- try {
- manager.createUser("too", "short");
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
- caught = false;
- try {
- manager.createUser("short", "too");
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
-
- // delete
- assertEquals(false, manager.deleteUser("not a user"));
- assertEquals(true, manager.deleteUser(users[users.length - 1].getName()));
- assertEquals(null, manager.getUser(users[users.length - 1].getName()));
- assertEquals(false, manager.deleteUser(users[users.length - 1].getName()));
-
- // grant privilege
- user = manager.getUser(users[0].getName());
- String path = "root.a.b.c";
- int privilegeId = 0;
- assertEquals(false, user.hasPrivilege(path, privilegeId));
- assertEquals(true, manager.grantPrivilegeToUser(user.getName(), path, privilegeId));
- assertEquals(true, manager.grantPrivilegeToUser(user.getName(), path, privilegeId + 1));
- assertEquals(false, manager.grantPrivilegeToUser(user.getName(), path, privilegeId));
- user = manager.getUser(users[0].getName());
- assertEquals(true, user.hasPrivilege(path, privilegeId));
- caught = false;
- try {
- manager.grantPrivilegeToUser("not a user", path, privilegeId);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
- caught = false;
- try {
- manager.grantPrivilegeToUser(user.getName(), path, -1);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
-
- // revoke privilege
- user = manager.getUser(users[0].getName());
- assertEquals(true, manager.revokePrivilegeFromUser(user.getName(), path, privilegeId));
- assertEquals(false, manager.revokePrivilegeFromUser(user.getName(), path, privilegeId));
- caught = false;
- try {
- manager.revokePrivilegeFromUser("not a user", path, privilegeId);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
- caught = false;
- try {
- manager.revokePrivilegeFromUser(user.getName(), path, -1);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
-
- // update password
- String newPassword = "newPassword";
- String illegalPW = "new";
- assertEquals(true, manager.updateUserPassword(user.getName(), newPassword));
- assertEquals(false, manager.updateUserPassword(user.getName(), illegalPW));
- user = manager.getUser(user.getName());
- assertEquals(AuthUtils.encryptPassword(newPassword), user.getPassword());
- caught = false;
- try {
- manager.updateUserPassword("not a user", newPassword);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
-
- // grant role
- String roleName = "newrole";
- assertEquals(true, manager.grantRoleToUser(roleName, user.getName()));
- assertEquals(false, manager.grantRoleToUser(roleName, user.getName()));
- user = manager.getUser(user.getName());
- assertEquals(true, user.hasRole(roleName));
- caught = false;
- try {
- manager.grantRoleToUser("not a user", roleName);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
-
- // revoke role
- assertEquals(true, manager.revokeRoleFromUser(roleName, user.getName()));
- assertEquals(false, manager.revokeRoleFromUser(roleName, user.getName()));
- user = manager.getUser(user.getName());
- assertEquals(false, user.hasRole(roleName));
- caught = false;
- try {
- manager.revokeRoleFromUser("not a user", roleName);
- } catch (AuthException e) {
- caught = true;
- }
- assertEquals(true, caught);
-
- // list users
- List<String> usernames = manager.listAllUsers();
- usernames.sort(null);
- assertEquals(IoTDBConstant.ADMIN_NAME, usernames.get(0));
- for (int i = 0; i < users.length - 1; i++) {
- assertEquals(users[i].getName(), usernames.get(i + 1));
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBDefaultThreadExceptionHandlerTest.java b/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBDefaultThreadExceptionHandlerTest.java
deleted file mode 100644
index 0e1997a..0000000
--- a/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBDefaultThreadExceptionHandlerTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.concurrent;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IoTDBDefaultThreadExceptionHandlerTest {
-
- private final String message = "Expected!";
- private Thread.UncaughtExceptionHandler handler;
- private AtomicInteger count;
-
- @Before
- public void setUp() throws Exception {
- handler = Thread.getDefaultUncaughtExceptionHandler();
- Thread.setDefaultUncaughtExceptionHandler(new TestExceptionHandler(message));
- count = new AtomicInteger(0);
- }
-
- @After
- public void tearDown() throws Exception {
- Thread.setDefaultUncaughtExceptionHandler(handler);
- }
-
- @Test
- public void test() throws InterruptedException {
- int num = 10;
- for (int i = 0; i < num; i++) {
- TestThread thread = new TestThread();
- thread.start();
- }
- Thread.sleep(500);
- assertEquals(num, count.get());
- }
-
- class TestThread extends Thread {
-
- public void run() {
- throw new RuntimeException(message);
- }
- }
-
- class TestExceptionHandler implements Thread.UncaughtExceptionHandler {
-
- private String name;
-
- public TestExceptionHandler(String name) {
- this.name = name;
- }
-
- @Override
- public void uncaughtException(Thread t, Throwable e) {
- assertEquals(name, e.getMessage());
- count.addAndGet(1);
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java b/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java
deleted file mode 100644
index 0825288..0000000
--- a/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.concurrent;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.thrift.server.TThreadPoolServer;
-import org.apache.thrift.server.TThreadPoolServer.Args;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IoTDBThreadPoolFactoryTest {
-
- private final String POOL_NAME = "test";
- private AtomicInteger count;
- private CountDownLatch latch;
-
- @Before
- public void setUp() throws Exception {
- count = new AtomicInteger(0);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testNewFixedThreadPool() throws InterruptedException, ExecutionException {
- String reason = "NewFixedThreadPool";
- Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 5;
- latch = new CountDownLatch(threadCount);
- ExecutorService exec = IoTDBThreadPoolFactory
- .newFixedThreadPool(threadCount, POOL_NAME, handler);
- for (int i = 0; i < threadCount; i++) {
- Runnable task = new TestThread(reason);
- exec.execute(task);
- }
- try {
- latch.await();
- assertEquals(count.get(), threadCount);
- } catch (InterruptedException E) {
- fail();
- }
- }
-
- @Test
- public void testNewSingleThreadExecutor() throws InterruptedException {
- String reason = "NewSingleThreadExecutor";
- Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 1;
- latch = new CountDownLatch(threadCount);
- ExecutorService exec = IoTDBThreadPoolFactory.newSingleThreadExecutor(POOL_NAME, handler);
- for (int i = 0; i < threadCount; i++) {
- Runnable task = new TestThread(reason);
- exec.execute(task);
- }
- try {
- latch.await();
- assertEquals(count.get(), threadCount);
- } catch (InterruptedException E) {
- fail();
- }
- }
-
- @Test
- public void testNewCachedThreadPool() throws InterruptedException {
- String reason = "NewCachedThreadPool";
- Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 10;
- latch = new CountDownLatch(threadCount);
- ExecutorService exec = IoTDBThreadPoolFactory.newCachedThreadPool(POOL_NAME, handler);
- for (int i = 0; i < threadCount; i++) {
- Runnable task = new TestThread(reason);
- exec.execute(task);
- }
- try {
- latch.await();
- assertEquals(count.get(), threadCount);
- } catch (InterruptedException E) {
- fail();
- }
- }
-
- @Test
- public void testNewSingleThreadScheduledExecutor() throws InterruptedException {
- String reason = "NewSingleThreadScheduledExecutor";
- Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 1;
- latch = new CountDownLatch(threadCount);
- ScheduledExecutorService exec = IoTDBThreadPoolFactory
- .newSingleThreadScheduledExecutor(POOL_NAME, handler);
- for (int i = 0; i < threadCount; i++) {
- Runnable task = new TestThread(reason);
- ScheduledFuture<?> future = exec.scheduleAtFixedRate(task, 0, 1, TimeUnit.SECONDS);
- try {
- future.get();
- } catch (ExecutionException e) {
- assertEquals(reason, e.getCause().getMessage());
- count.addAndGet(1);
- latch.countDown();
- }
- }
- try {
- latch.await();
- assertEquals(count.get(), threadCount);
- } catch (InterruptedException E) {
- fail();
- }
- }
-
- @Test
- public void testNewScheduledThreadPool() throws InterruptedException {
- String reason = "NewScheduledThreadPool";
- Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 10;
- latch = new CountDownLatch(threadCount);
- ScheduledExecutorService exec = IoTDBThreadPoolFactory
- .newScheduledThreadPool(threadCount, POOL_NAME, handler);
- for (int i = 0; i < threadCount; i++) {
- Runnable task = new TestThread(reason);
- ScheduledFuture<?> future = exec.scheduleAtFixedRate(task, 0, 1, TimeUnit.SECONDS);
- try {
- future.get();
- } catch (ExecutionException e) {
- assertEquals(reason, e.getCause().getMessage());
- count.addAndGet(1);
- latch.countDown();
- }
- }
- try {
- latch.await();
- assertEquals(count.get(), threadCount);
- } catch (InterruptedException E) {
- fail();
- }
- }
-
- @Test
- public void testCreateJDBCClientThreadPool() throws InterruptedException {
- String reason = "CreateJDBCClientThreadPool";
- TThreadPoolServer.Args args = new Args(null);
- args.maxWorkerThreads = 100;
- args.minWorkerThreads = 10;
- args.stopTimeoutVal = 10;
- args.stopTimeoutUnit = TimeUnit.SECONDS;
- Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 50;
- latch = new CountDownLatch(threadCount);
- ExecutorService exec = IoTDBThreadPoolFactory
- .createThriftRpcClientThreadPool(args, POOL_NAME, handler);
- for (int i = 0; i < threadCount; i++) {
- Runnable task = new TestThread(reason);
- exec.execute(task);
- }
- try {
- latch.await();
- assertEquals(count.get(), threadCount);
- } catch (InterruptedException E) {
- fail();
- }
- }
-
- class TestExceptionHandler implements Thread.UncaughtExceptionHandler {
-
- private String name;
-
- public TestExceptionHandler(String name) {
- this.name = name;
- }
-
- @Override
- public void uncaughtException(Thread t, Throwable e) {
- assertEquals(name, e.getMessage());
- count.addAndGet(1);
- latch.countDown();
- }
- }
-
- class TestThread implements Runnable {
-
- private String name;
-
- public TestThread(String name) {
- this.name = name;
- }
-
- @Override
- public void run() {
- throw new RuntimeException(name);
- }
-
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/conf/adapter/ActiveTimeSeriesCounterTest.java b/server/src/test/java/org/apache/iotdb/db/conf/adapter/ActiveTimeSeriesCounterTest.java
deleted file mode 100644
index 5bd0e11..0000000
--- a/server/src/test/java/org/apache/iotdb/db/conf/adapter/ActiveTimeSeriesCounterTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.conf.adapter;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * ActiveTimeSeriesCounter Tester.
- */
-public class ActiveTimeSeriesCounterTest {
-
- private static final String TEST_SG_PREFIX = "root.sg_";
- private static int testStorageGroupNum = 10;
- private static String[] storageGroups = new String[testStorageGroupNum];
- private static int[] sensorNum = new int[testStorageGroupNum];
- private static double totalSeriesNum = 0;
-
- static {
- for (int i = 0; i < testStorageGroupNum; i++) {
- storageGroups[i] = TEST_SG_PREFIX + i;
- sensorNum[i] = i + 1;
- totalSeriesNum += sensorNum[i];
- }
- }
-
- @Before
- public void before() throws Exception {
- ActiveTimeSeriesCounter.clear();
- for (String storageGroup : storageGroups) {
- ActiveTimeSeriesCounter.getInstance().init(storageGroup);
- }
- }
-
- @After
- public void after() throws Exception {
- for (String storageGroup : storageGroups) {
- ActiveTimeSeriesCounter.getInstance().delete(storageGroup);
- }
- }
-
- /**
- * Method: init(String storageGroup)
- */
- @Test
- public void testInit() throws Exception {
- for (int i = 0; i < testStorageGroupNum; i++) {
- assertEquals(0D, ActiveTimeSeriesCounter.getInstance().getActiveRatio(storageGroups[i]), 0.0);
- }
- }
-
- /**
- * Method: updateActiveRatio(String storageGroup)
- */
- @Test
- public void testUpdateActiveRatio() throws Exception {
- ExecutorService service = Executors.newFixedThreadPool(storageGroups.length);
- CountDownLatch finished = new CountDownLatch(storageGroups.length);
- for (int i = 0; i < storageGroups.length; i++) {
- service.submit(new OfferThreads(storageGroups[i], sensorNum[i], finished));
- }
- finished.await();
- for (String storageGroup : storageGroups) {
- ActiveTimeSeriesCounter.getInstance().updateActiveRatio(storageGroup);
- double sum = 0;
- for (String s : storageGroups) {
- sum += ActiveTimeSeriesCounter.getInstance().getActiveRatio(s);
- }
- assertEquals(1.0, sum, 0.001);
- }
- for (int i = 0; i < storageGroups.length; i++) {
- double r = ActiveTimeSeriesCounter.getInstance().getActiveRatio(storageGroups[i]);
- assertEquals(sensorNum[i] / totalSeriesNum, r, 0.001);
- }
- }
-
- private static class OfferThreads implements Runnable {
- private int sensorNum;
- private String storageGroup;
- private CountDownLatch finished;
-
- private OfferThreads(String storageGroup, int sensorNum, CountDownLatch finished) {
- this.sensorNum = sensorNum;
- this.storageGroup = storageGroup;
- this.finished = finished;
- }
-
- @Override
- public void run() {
- try {
- for (int j = 0; j < sensorNum; j++) {
- ActiveTimeSeriesCounter.getInstance().offer(storageGroup, "device_0", "sensor_" + j);
- }
- } finally {
- finished.countDown();
- }
- }
- }
-
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/conf/adapter/CompressionRatioTest.java b/server/src/test/java/org/apache/iotdb/db/conf/adapter/CompressionRatioTest.java
deleted file mode 100644
index 4269f8f..0000000
--- a/server/src/test/java/org/apache/iotdb/db/conf/adapter/CompressionRatioTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.conf.adapter;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Locale;
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.db.utils.FilePathUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class CompressionRatioTest {
-
- private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
-
- private CompressionRatio compressionRatio = CompressionRatio.getInstance();
-
- private static final String directory = FilePathUtils.regularizePath(CONFIG.getSystemDir())
- + CompressionRatio.COMPRESSION_RATIO_DIR;
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.closeStatMonitor();
- EnvironmentUtils.envSetUp();
- FileUtils.forceMkdir(new File(directory));
- compressionRatio.reset();
- compressionRatio.restore();
- IoTDBDescriptor.getInstance().getConfig().setEnableParameterAdapter(true);
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void testCompressionRatio() throws IOException {
- double compressionRatioSum = 0;
- int calcuTimes = 0;
- if (new File(directory, String.format(Locale.ENGLISH, CompressionRatio.RATIO_FILE_PATH_FORMAT, compressionRatioSum , calcuTimes)).exists()) {
- fail();
- }
- double compressionRatio = 10;
- for(int i = 0; i < 500 ; i+= compressionRatio){
- this.compressionRatio.updateRatio(compressionRatio);
- if (new File(directory, String.format(Locale.ENGLISH, CompressionRatio.RATIO_FILE_PATH_FORMAT, compressionRatioSum , calcuTimes)).exists()) {
- fail();
- }
- calcuTimes++;
- compressionRatioSum += compressionRatio;
- if (!new File(directory, String.format(Locale.ENGLISH, CompressionRatio.RATIO_FILE_PATH_FORMAT, compressionRatioSum , calcuTimes)).exists()) {
- fail();
- }
- assertEquals(0, Double
- .compare(compressionRatioSum / calcuTimes, this.compressionRatio.getRatio()));
- }
- }
-
- @Test
- public void testRestore() throws IOException {
- double compressionRatioSum = 0;
- int calcuTimes = 0;
- if (new File(directory, String.format(Locale.ENGLISH, CompressionRatio.RATIO_FILE_PATH_FORMAT, compressionRatioSum , calcuTimes)).exists()) {
- fail();
- }
- int compressionRatio = 10;
- for(int i = 0; i < 100 ; i+= compressionRatio){
- this.compressionRatio.updateRatio(compressionRatio);
- if (new File(directory, String.format(Locale.ENGLISH, CompressionRatio.RATIO_FILE_PATH_FORMAT, compressionRatioSum , calcuTimes)).exists()) {
- fail();
- }
- calcuTimes++;
- compressionRatioSum += compressionRatio;
- if (!new File(directory, String.format(Locale.ENGLISH, CompressionRatio.RATIO_FILE_PATH_FORMAT, compressionRatioSum , calcuTimes)).exists()) {
- fail();
- }
- assertEquals(0, Double
- .compare(compressionRatioSum / calcuTimes, this.compressionRatio.getRatio()));
- }
- this.compressionRatio.restore();
- assertEquals(10, this.compressionRatio.getCalcTimes());
- assertEquals(0, Double
- .compare(compressionRatioSum / calcuTimes, this.compressionRatio.getRatio()));
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/conf/adapter/HyperLogLogTest.java b/server/src/test/java/org/apache/iotdb/db/conf/adapter/HyperLogLogTest.java
deleted file mode 100644
index 09da1b1..0000000
--- a/server/src/test/java/org/apache/iotdb/db/conf/adapter/HyperLogLogTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.conf.adapter;
-
-import static org.junit.Assert.assertEquals;
-
-import com.clearspring.analytics.stream.cardinality.HyperLogLog;
-import com.clearspring.analytics.stream.cardinality.ICardinality;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Random;
-import java.util.Set;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class HyperLogLogTest {
-
- @Test
- public void testStreamLibHll() {
- final int seed = 12345;
- // data on which to calculate distinct count
- Random random = new Random(seed);
- int sampleSize = 10000;
- double[] floor = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0};
- String[] avgErrors = new String[floor.length];
- int testNum = 1000;
-
- for (double v : floor) {
- double errorSum = 0;
- for (int testIndex = 0; testIndex < testNum; testIndex++) {
- final ArrayList<Integer> list = new ArrayList<>();
- for (int i = 0; i < sampleSize; i++) {
- list.add(random.nextInt((int) (sampleSize * v)));
- }
- Set<Integer> set = new HashSet<>();
- ICardinality card = new HyperLogLog(ActiveTimeSeriesCounter.LOG2M);
- for (int a : list) {
- set.add(a);
- card.offer(a);
- }
- double p = (card.cardinality() - set.size()) / (double) set.size();
- errorSum += Math.abs(p);
- }
- // allow average error rate less than 1%
- assertEquals(0, errorSum / testNum, 0.01);
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/conf/adapter/IoTDBConfigDynamicAdapterTest.java b/server/src/test/java/org/apache/iotdb/db/conf/adapter/IoTDBConfigDynamicAdapterTest.java
deleted file mode 100644
index 5c2cefa..0000000
--- a/server/src/test/java/org/apache/iotdb/db/conf/adapter/IoTDBConfigDynamicAdapterTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.conf.adapter;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.ConfigAdjusterException;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IoTDBConfigDynamicAdapterTest {
-
- private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
-
- private long oldTsFileThreshold = CONFIG.getTsFileSizeThreshold();
-
- private int oldMaxMemTableNumber = CONFIG.getMaxMemtableNumber();
-
- private long oldGroupSizeInByte = CONFIG.getMemtableSizeThreshold();
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.closeStatMonitor();
- EnvironmentUtils.envSetUp();
- IoTDBDescriptor.getInstance().getConfig().setEnableParameterAdapter(true);
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- CONFIG.setMaxMemtableNumber(oldMaxMemTableNumber);
- CONFIG.setTsFileSizeThreshold(oldTsFileThreshold);
- CONFIG.setMemtableSizeThreshold(oldGroupSizeInByte);
- MManager.getInstance().setMaxSeriesNumberAmongStorageGroup(0);
- IoTDBConfigDynamicAdapter.getInstance().reset();
- }
-
- @Test
- public void addOrDeleteStorageGroup() throws ConfigAdjusterException {
- int memTableNum = IoTDBConfigDynamicAdapter.MEM_TABLE_AVERAGE_QUEUE_LEN;
- for (int i = 1; i < 100; i++) {
- IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(1);
- }
- MManager.getInstance().setMaxSeriesNumberAmongStorageGroup(100);
- for (int i = 1; i < 1000000; i++) {
- try {
- IoTDBConfigDynamicAdapter.getInstance().addOrDeleteStorageGroup(1);
- memTableNum += IoTDBDescriptor.getInstance().getConfig().getMemtableNumInEachStorageGroup();
- assertEquals(IoTDBConfigDynamicAdapter.getInstance().getCurrentMemTableSize(),
- CONFIG.getMemtableSizeThreshold());
- assertEquals(CONFIG.getMaxMemtableNumber(), memTableNum);
- } catch (ConfigAdjusterException e) {
- assertEquals(String.format(ConfigAdjusterException.ERROR_MSG_FORMAT,
- IoTDBConfigDynamicAdapter.CREATE_STORAGE_GROUP), e.getMessage());
- assertEquals(CONFIG.getMaxMemtableNumber(), memTableNum);
- break;
- }
- }
- }
-
- @Test
- public void addOrDeleteTimeSeries() throws ConfigAdjusterException {
- int totalTimeseries = 0;
- for (int i = 1; i < 100; i++) {
- IoTDBConfigDynamicAdapter.getInstance().addOrDeleteStorageGroup(1);
- }
- MManager.getInstance().setMaxSeriesNumberAmongStorageGroup(100);
- for (int i = 1; i < 1000000; i++) {
- try {
- IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(1);
-
- if (i % 10 == 0) {
- MManager.getInstance().setMaxSeriesNumberAmongStorageGroup(i);
- }
- totalTimeseries += 1;
- assertEquals(IoTDBConfigDynamicAdapter.getInstance().getCurrentMemTableSize(),
- CONFIG.getMemtableSizeThreshold());
- assertEquals(IoTDBConfigDynamicAdapter.getInstance().getTotalTimeseries(),
- totalTimeseries);
- } catch (ConfigAdjusterException e) {
- assertEquals(String.format(ConfigAdjusterException.ERROR_MSG_FORMAT,
- IoTDBConfigDynamicAdapter.ADD_TIMESERIES), e.getMessage());
- assertEquals(IoTDBConfigDynamicAdapter.getInstance().getTotalTimeseries(),
- totalTimeseries);
- break;
- }
- }
- }
-
- @Test
- public void addOrDeleteTimeSeriesSyso() throws ConfigAdjusterException {
- int sgNum = 1;
- for (int i = 0; i < 30; i++) {
- IoTDBConfigDynamicAdapter.getInstance().addOrDeleteStorageGroup(sgNum);
- }
- int i = 1;
- try {
- for (; i <= 280 * 3200; i++) {
- IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(1);
- MManager.getInstance().setMaxSeriesNumberAmongStorageGroup(i / 30 + 1);
- }
- } catch (ConfigAdjusterException e) {
- assertEquals(String.format(ConfigAdjusterException.ERROR_MSG_FORMAT,
- IoTDBConfigDynamicAdapter.ADD_TIMESERIES), e.getMessage());
- }
- try {
- while (true) {
- IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(1);
- MManager.getInstance().setMaxSeriesNumberAmongStorageGroup(MManager.getInstance().getMaximalSeriesNumberAmongStorageGroups() + 1);
- }
- } catch (ConfigAdjusterException e ) {
- assertEquals(String.format(ConfigAdjusterException.ERROR_MSG_FORMAT,
- IoTDBConfigDynamicAdapter.ADD_TIMESERIES), e.getMessage());
- }
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/conf/directories/strategy/DirectoryStrategyTest.java b/server/src/test/java/org/apache/iotdb/db/conf/directories/strategy/DirectoryStrategyTest.java
deleted file mode 100644
index 8aaf7bc..0000000
--- a/server/src/test/java/org/apache/iotdb/db/conf/directories/strategy/DirectoryStrategyTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.conf.directories.strategy;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.exception.DiskSpaceInsufficientException;
-import org.apache.iotdb.db.utils.CommonUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@RunWith(PowerMockRunner.class)
-@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "org.w3c.*"})
-@PrepareForTest(CommonUtils.class)
-public class DirectoryStrategyTest {
-
- List<String> dataDirList;
- Set<Integer> fullDirIndexSet;
-
- @Before
- public void setUp() throws IOException {
- dataDirList = new ArrayList<>();
- for (int i = 0; i < 5; i++) {
- dataDirList.add(TestConstant.OUTPUT_DATA_DIR + i);
- }
-
- fullDirIndexSet = new HashSet<>();
- fullDirIndexSet.add(1);
- fullDirIndexSet.add(3);
-
- PowerMockito.mockStatic(CommonUtils.class);
- for (int i = 0; i < dataDirList.size(); i++) {
- boolean res = !fullDirIndexSet.contains(i);
- PowerMockito.when(CommonUtils.hasSpace(dataDirList.get(i))).thenReturn(res);
- PowerMockito.when(CommonUtils.getUsableSpace(dataDirList.get(i))).thenReturn(res ? (long) (i + 1) : 0L);
- PowerMockito.when(CommonUtils.getOccupiedSpace(dataDirList.get(i))).thenReturn(res ? (long) (i + 1) : Long.MAX_VALUE);
- }
- }
-
- @After
- public void tearDown() {
-
- }
-
- @Test
- public void testSequenceStrategy() throws DiskSpaceInsufficientException {
- SequenceStrategy sequenceStrategy = new SequenceStrategy();
- sequenceStrategy.setFolders(dataDirList);
-
- // loop two times of data dir size to fully loop
- int index = 0;
- for (int i = 0; i < dataDirList.size() * 2; i++, index++) {
- index = index % dataDirList.size();
- while (fullDirIndexSet.contains(index)) {
- index = (index + 1) % dataDirList.size();
- }
- assertEquals(index, sequenceStrategy.nextFolderIndex());
- }
- }
-
- @Test
- public void testMaxDiskUsableSpaceFirstStrategy() throws DiskSpaceInsufficientException {
- MaxDiskUsableSpaceFirstStrategy maxDiskUsableSpaceFirstStrategy = new MaxDiskUsableSpaceFirstStrategy();
- maxDiskUsableSpaceFirstStrategy.setFolders(dataDirList);
-
- int maxIndex = getIndexOfMaxSpace();
- for (int i = 0; i < dataDirList.size(); i++) {
- assertEquals(maxIndex, maxDiskUsableSpaceFirstStrategy.nextFolderIndex());
- }
-
- PowerMockito.when(CommonUtils.getUsableSpace(dataDirList.get(maxIndex))).thenReturn(0L);
- maxIndex = getIndexOfMaxSpace();
- for (int i = 0; i < dataDirList.size(); i++) {
- assertEquals(maxIndex, maxDiskUsableSpaceFirstStrategy.nextFolderIndex());
- }
- }
-
- private int getIndexOfMaxSpace() {
- int index = -1;
- long maxSpace = -1;
- for (int i = 0; i < dataDirList.size(); i++) {
- long space = CommonUtils.getUsableSpace(dataDirList.get(i));
- if (maxSpace < space) {
- index = i;
- maxSpace = space;
- }
- }
- return index;
- }
-
- @Test
- public void testMinFolderOccupiedSpaceFirstStrategy()
- throws DiskSpaceInsufficientException, IOException {
- MinFolderOccupiedSpaceFirstStrategy minFolderOccupiedSpaceFirstStrategy = new MinFolderOccupiedSpaceFirstStrategy();
- minFolderOccupiedSpaceFirstStrategy.setFolders(dataDirList);
-
- int minIndex = getIndexOfMinOccupiedSpace();
- for (int i = 0; i < dataDirList.size(); i++) {
- assertEquals(minIndex, minFolderOccupiedSpaceFirstStrategy.nextFolderIndex());
- }
-
- PowerMockito.when(CommonUtils.getOccupiedSpace(dataDirList.get(minIndex))).thenReturn(Long.MAX_VALUE);
- minIndex = getIndexOfMinOccupiedSpace();
- for (int i = 0; i < dataDirList.size(); i++) {
- assertEquals(minIndex, minFolderOccupiedSpaceFirstStrategy.nextFolderIndex());
- }
- }
-
- private int getIndexOfMinOccupiedSpace() throws IOException {
- int index = -1;
- long minOccupied = Long.MAX_VALUE;
- for (int i = 0; i < dataDirList.size(); i++) {
- long space = CommonUtils.getOccupiedSpace(dataDirList.get(i));
- if (minOccupied > space) {
- index = i;
- minOccupied = space;
- }
- }
- return index;
- }
-
- @Test
- public void testRandomOnDiskUsableSpaceStrategy()
- throws DiskSpaceInsufficientException {
- RandomOnDiskUsableSpaceStrategy randomOnDiskUsableSpaceStrategy = new RandomOnDiskUsableSpaceStrategy();
- randomOnDiskUsableSpaceStrategy.setFolders(dataDirList);
-
- for (int i = 0; i < dataDirList.size(); i++) {
- assertFalse(fullDirIndexSet.contains(randomOnDiskUsableSpaceStrategy.nextFolderIndex()));
- }
-
- int newFullIndex = randomOnDiskUsableSpaceStrategy.nextFolderIndex();
- PowerMockito.when(CommonUtils.getUsableSpace(dataDirList.get(newFullIndex))).thenReturn(0L);
- for (int i = 0; i < dataDirList.size(); i++) {
- int index = randomOnDiskUsableSpaceStrategy.nextFolderIndex();
- assertFalse(fullDirIndexSet.contains(index));
- assertTrue(newFullIndex != index);
- }
- }
-
- @Test
- public void testAllDiskFull() {
- for (int i = 0; i < dataDirList.size(); i++) {
- PowerMockito.when(CommonUtils.hasSpace(dataDirList.get(i))).thenReturn(false);
- }
-
- SequenceStrategy sequenceStrategy = new SequenceStrategy();
- try {
- sequenceStrategy.setFolders(dataDirList);
- fail();
- } catch (DiskSpaceInsufficientException e) {
- }
-
- MaxDiskUsableSpaceFirstStrategy maxDiskUsableSpaceFirstStrategy = new MaxDiskUsableSpaceFirstStrategy();
- try {
- maxDiskUsableSpaceFirstStrategy.setFolders(dataDirList);
- fail();
- } catch (DiskSpaceInsufficientException e) {
- }
-
- MinFolderOccupiedSpaceFirstStrategy minFolderOccupiedSpaceFirstStrategy = new MinFolderOccupiedSpaceFirstStrategy();
- try {
- minFolderOccupiedSpaceFirstStrategy.setFolders(dataDirList);
- fail();
- } catch (DiskSpaceInsufficientException e) {
- }
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/constant/TestConstant.java b/server/src/test/java/org/apache/iotdb/db/constant/TestConstant.java
deleted file mode 100644
index 090c922..0000000
--- a/server/src/test/java/org/apache/iotdb/db/constant/TestConstant.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.constant;
-
-import java.io.File;
-import java.util.Random;
-
-public class TestConstant {
- public static final String BASE_OUTPUT_PATH = "target".concat(File.separator);
- public static final String OUTPUT_DATA_DIR = BASE_OUTPUT_PATH.concat("data").concat(File.separator);
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/cost/statistic/PerformanceStatTest.java b/server/src/test/java/org/apache/iotdb/db/cost/statistic/PerformanceStatTest.java
deleted file mode 100644
index 8381eb4..0000000
--- a/server/src/test/java/org/apache/iotdb/db/cost/statistic/PerformanceStatTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.cost.statistic;
-
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.StartupException;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PerformanceStatTest {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(PerformanceStatTest.class);
-
- @Before
- public void setUp() {
- IoTDBDescriptor.getInstance().getConfig().setEnablePerformanceStat(true);
- }
-
- @After
- public void tearDown() {
- IoTDBDescriptor.getInstance().getConfig().setEnablePerformanceStat(false);
- }
-
- @Test
- public void test() {
- Measurement measurement = Measurement.INSTANCE;
- Operation operation = Operation.EXECUTE_JDBC_BATCH;
- measurement.addOperationLatency(operation, System.currentTimeMillis());
- measurement.addOperationLatency(operation,
- System.currentTimeMillis() - 8000000);
-
- long batchOpCnt = measurement.getOperationCnt()[operation.ordinal()];
- Assert.assertEquals(0L, batchOpCnt);
- try {
- measurement.start();
- measurement.startContinuousPrintStatistics();
- measurement.addOperationLatency(operation, System.currentTimeMillis());
- measurement
- .addOperationLatency(operation, System.currentTimeMillis() - 8000000);
- Thread.currentThread().sleep(1000);
- batchOpCnt = measurement.getOperationCnt()[operation.ordinal()];
- Assert.assertEquals(2L, batchOpCnt);
- measurement.stopPrintStatistic();
- measurement.stopPrintStatistic();
- measurement.stopPrintStatistic();
- LOGGER.info("After stopPrintStatistic!");
- Thread.currentThread().sleep(1000);
- measurement.clearStatisticalState();
- batchOpCnt = measurement.getOperationCnt()[operation.ordinal()];
- Assert.assertEquals(0L, batchOpCnt);
- measurement.startContinuousPrintStatistics();
- LOGGER.info("ReStart!");
- Thread.currentThread().sleep(1000);
- measurement.startContinuousPrintStatistics();
- LOGGER.info("ReStart2!");
- Thread.currentThread().sleep(1000);
- measurement.stopPrintStatistic();
- LOGGER.info("After stopStatistic2!");
- } catch (Exception e) {
- LOGGER.error("find error in stat performance, the message is {}", e.getMessage());
- } finally {
- measurement.stop();
- }
- }
-
- @Test
- public void testSwitch() {
- Measurement measurement = Measurement.INSTANCE;
- try {
- measurement.start();
- measurement.startStatistics();
- measurement.startStatistics();
- measurement.startContinuousPrintStatistics();
- measurement.stopPrintStatistic();
- measurement.stopStatistic();
- measurement.clearStatisticalState();
- measurement.startPrintStatisticsOnce();
- measurement.startContinuousPrintStatistics();
- measurement.startStatistics();
- } catch (StartupException e) {
- e.printStackTrace();
- } finally {
- measurement.stop();
- }
-
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/MetadataManagerHelper.java b/server/src/test/java/org/apache/iotdb/db/engine/MetadataManagerHelper.java
deleted file mode 100644
index 76c0bb9..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/MetadataManagerHelper.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine;
-
-import java.util.Collections;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-public class MetadataManagerHelper {
-
- public static void initMetadata() {
- MManager mmanager = MManager.getInstance();
- mmanager.init();
- mmanager.clear();
- try {
- mmanager.setStorageGroup("root.vehicle.d0");
- mmanager.setStorageGroup("root.vehicle.d1");
- mmanager.setStorageGroup("root.vehicle.d2");
-
- CompressionType compressionType = TSFileDescriptor.getInstance().getConfig().getCompressor();
-
- mmanager.createTimeseries("root.vehicle.d0.s0", TSDataType.valueOf("INT32"),
- TSEncoding.valueOf("RLE"), compressionType,
- Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d0.s1", TSDataType.valueOf("INT64"),
- TSEncoding.valueOf("RLE"), compressionType,
- Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d0.s2", TSDataType.valueOf("FLOAT"),
- TSEncoding.valueOf("RLE"), compressionType,
- Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d0.s3", TSDataType.valueOf("DOUBLE"),
- TSEncoding.valueOf("RLE"), compressionType,
- Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d0.s4", TSDataType.valueOf("BOOLEAN"),
- TSEncoding.valueOf("PLAIN"), compressionType,
- Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d0.s5", TSDataType.valueOf("TEXT"),
- TSEncoding.valueOf("PLAIN"), compressionType,
- Collections.emptyMap());
-
- mmanager.createTimeseries("root.vehicle.d1.s0", TSDataType.valueOf("INT32"),
- TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d1.s1", TSDataType.valueOf("INT64"),
- TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d1.s2", TSDataType.valueOf("FLOAT"),
- TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d1.s3", TSDataType.valueOf("DOUBLE"),
- TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d1.s4", TSDataType.valueOf("BOOLEAN"),
- TSEncoding.valueOf("PLAIN"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d1.s5", TSDataType.valueOf("TEXT"),
- TSEncoding.valueOf("PLAIN"), compressionType, Collections.emptyMap());
-
- mmanager.createTimeseries("root.vehicle.d2.s0", TSDataType.valueOf("INT32"),
- TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d2.s1", TSDataType.valueOf("INT64"),
- TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d2.s2", TSDataType.valueOf("FLOAT"),
- TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d2.s3", TSDataType.valueOf("DOUBLE"),
- TSEncoding.valueOf("RLE"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d2.s4", TSDataType.valueOf("BOOLEAN"),
- TSEncoding.valueOf("PLAIN"), compressionType, Collections.emptyMap());
- mmanager.createTimeseries("root.vehicle.d2.s5", TSDataType.valueOf("TEXT"),
- TSEncoding.valueOf("PLAIN"), compressionType, Collections.emptyMap());
-
- } catch (Exception e) {
- throw new RuntimeException("Initialize the metadata manager failed", e);
- }
- }
-
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/cache/DeviceMetaDataCacheTest.java b/server/src/test/java/org/apache/iotdb/db/engine/cache/DeviceMetaDataCacheTest.java
deleted file mode 100644
index ff05387..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/cache/DeviceMetaDataCacheTest.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine.cache;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.conf.adapter.ActiveTimeSeriesCounter;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.MetadataManagerHelper;
-import org.apache.iotdb.db.engine.flush.TsFileFlushPolicy.DirectFlushPolicy;
-import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
-import org.apache.iotdb.db.engine.storagegroup.StorageGroupProcessor;
-import org.apache.iotdb.db.engine.storagegroup.TsFileProcessor;
-import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
-import org.apache.iotdb.db.query.context.QueryContext;
-import org.apache.iotdb.db.query.control.FileReaderManager;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.read.common.Path;
-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;
-import org.junit.Test;
-
-public class DeviceMetaDataCacheTest {
-
- private QueryContext context = EnvironmentUtils.TEST_QUERY_CONTEXT;
-
- private String storageGroup = "root.vehicle.d0";
- private String measurementId0 = "s0";
- private String measurementId1 = "s1";
- private String measurementId2 = "s2";
- private String measurementId3 = "s3";
- private String measurementId4 = "s4";
- private String measurementId5 = "s5";
- private StorageGroupProcessor storageGroupProcessor;
- private String systemDir = TestConstant.BASE_OUTPUT_PATH.concat("data")
- .concat(File.separator).concat("info");
-
- static {
- MManager.getInstance().init();
- }
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- MetadataManagerHelper.initMetadata();
- ActiveTimeSeriesCounter.getInstance().init(storageGroup);
- storageGroupProcessor = new StorageGroupProcessor(systemDir, storageGroup, new DirectFlushPolicy());
- insertData();
- }
-
- @After
- public void tearDown() throws Exception {
- FileReaderManager.getInstance().closeAndRemoveAllOpenedReaders();
- storageGroupProcessor.syncDeleteDataFiles();
- EnvironmentUtils.cleanEnv();
- EnvironmentUtils.cleanDir(systemDir);
- }
-
- private void insertOneRecord(long time, int num) throws QueryProcessException {
- TSRecord record = new TSRecord(time, storageGroup);
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId0, String.valueOf(num)));
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT64, measurementId1, String.valueOf(num)));
- record.addTuple(DataPoint.getDataPoint(TSDataType.FLOAT, measurementId2, String.valueOf(num)));
- record.addTuple(DataPoint.getDataPoint(TSDataType.DOUBLE, measurementId3, String.valueOf(num)));
- record.addTuple(DataPoint.getDataPoint(TSDataType.BOOLEAN, measurementId4, "True"));
- storageGroupProcessor.insert(new InsertPlan(record));
- }
-
- protected void insertData() throws IOException, QueryProcessException {
- for (int j = 1; j <= 100; j++) {
- insertOneRecord(j, j);
- }
- for(TsFileProcessor tsFileProcessor : storageGroupProcessor.getWorkSequenceTsFileProcessors()){
- tsFileProcessor.syncFlush();
- }
-
- for (int j = 10; j >= 1; j--) {
- insertOneRecord(j, j);
- }
- for (int j = 11; j <= 20; j++) {
- insertOneRecord(j, j);
- }
- storageGroupProcessor.putAllWorkingTsFileProcessorIntoClosingList();
-
- for (int j = 21; j <= 30; j += 2) {
- insertOneRecord(j, 0); // will be covered when read
- }
- storageGroupProcessor.waitForAllCurrentTsFileProcessorsClosed();
-
- for (int j = 21; j <= 30; j += 2) {
- insertOneRecord(j, j);
- }
- storageGroupProcessor.waitForAllCurrentTsFileProcessorsClosed();
-
- insertOneRecord(2, 100);
- }
-
- @Test
- public void test1() throws IOException {
- IoTDBDescriptor.getInstance().getConfig().setMetaDataCacheEnable(false);
- QueryDataSource queryDataSource = storageGroupProcessor
- .query(storageGroup, measurementId5, context, null, null);
-
- List<TsFileResource> seqResources = queryDataSource.getSeqResources();
- List<TsFileResource> unseqResources = queryDataSource.getUnseqResources();
-
- Assert.assertEquals(1, seqResources.size());
- Assert.assertEquals(4, unseqResources.size());
- Assert.assertTrue(seqResources.get(0).isClosed());
- Assert.assertTrue(unseqResources.get(0).isClosed());
- Assert.assertTrue(unseqResources.get(1).isClosed());
- Assert.assertTrue(unseqResources.get(2).isClosed());
- Assert.assertFalse(unseqResources.get(3).isClosed());
-
- List<ChunkMetaData> metaDataList = DeviceMetaDataCache.getInstance()
- .get(seqResources.get(0), new Path(storageGroup, measurementId5));
- Assert.assertEquals(0, metaDataList.size());
- }
-
- @Test
- public void test2() throws IOException {
- IoTDBDescriptor.getInstance().getConfig().setMetaDataCacheEnable(true);
- QueryDataSource queryDataSource = storageGroupProcessor
- .query(storageGroup, measurementId5, context, null, null);
-
- List<TsFileResource> seqResources = queryDataSource.getSeqResources();
- List<TsFileResource> unseqResources = queryDataSource.getUnseqResources();
-
- Assert.assertEquals(1, seqResources.size());
- Assert.assertEquals(4, unseqResources.size());
- Assert.assertTrue(seqResources.get(0).isClosed());
- Assert.assertTrue(unseqResources.get(0).isClosed());
- Assert.assertTrue(unseqResources.get(1).isClosed());
- Assert.assertTrue(unseqResources.get(2).isClosed());
- Assert.assertFalse(unseqResources.get(3).isClosed());
-
- List<ChunkMetaData> metaDataList = DeviceMetaDataCache.getInstance()
- .get(seqResources.get(0), new Path(storageGroup, measurementId5));
- Assert.assertEquals(0, metaDataList.size());
- }
-
-
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemTableFlushTaskTest.java b/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemTableFlushTaskTest.java
deleted file mode 100644
index 8aa75dd..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemTableFlushTaskTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine.memtable;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutionException;
-import org.apache.iotdb.db.conf.adapter.ActiveTimeSeriesCounter;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.MetadataManagerHelper;
-import org.apache.iotdb.db.engine.flush.MemTableFlushTask;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
-import org.apache.iotdb.tsfile.fileSystem.FSFactoryProducer;
-import org.apache.iotdb.tsfile.write.writer.RestorableTsFileIOWriter;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MemTableFlushTaskTest {
-
- private RestorableTsFileIOWriter writer;
- private String storageGroup = "storage_group1";
- private String filePath = TestConstant.OUTPUT_DATA_DIR.concat("testUnsealedTsFileProcessor.tsfile");
- private IMemTable memTable;
- private long startTime = 1;
- private long endTime = 100;
-
- @Before
- public void setUp() throws Exception {
- MetadataManagerHelper.initMetadata();
- ActiveTimeSeriesCounter.getInstance().init(storageGroup);
- EnvironmentUtils.envSetUp();
- writer = new RestorableTsFileIOWriter(FSFactoryProducer.getFSFactory().getFile(filePath));
- memTable = new PrimitiveMemTable();
- }
-
- @After
- public void tearDown() throws Exception {
- writer.close();
- EnvironmentUtils.cleanEnv();
- EnvironmentUtils.cleanDir(TestConstant.OUTPUT_DATA_DIR);
- }
-
- @Test
- public void testFlushMemTable() throws ExecutionException, InterruptedException {
- MemTableTestUtils.produceData(memTable, startTime, endTime, MemTableTestUtils.deviceId0,
- MemTableTestUtils.measurementId0,
- MemTableTestUtils.dataType0);
- MemTableFlushTask memTableFlushTask = new MemTableFlushTask(memTable, MemTableTestUtils.getSchema(), writer, storageGroup);
- assertTrue(writer
- .getVisibleMetadataList(MemTableTestUtils.deviceId0, MemTableTestUtils.measurementId0,
- MemTableTestUtils.dataType0).isEmpty());
- memTableFlushTask.syncFlushMemTable();
- writer.makeMetadataVisible();
- assertEquals(1, writer
- .getVisibleMetadataList(MemTableTestUtils.deviceId0, MemTableTestUtils.measurementId0,
- MemTableTestUtils.dataType0).size());
- ChunkMetaData chunkMetaData = writer
- .getVisibleMetadataList(MemTableTestUtils.deviceId0, MemTableTestUtils.measurementId0,
- MemTableTestUtils.dataType0).get(0);
- assertEquals(MemTableTestUtils.measurementId0, chunkMetaData.getMeasurementUid());
- assertEquals(startTime, chunkMetaData.getStartTime());
- assertEquals(endTime, chunkMetaData.getEndTime());
- assertEquals(MemTableTestUtils.dataType0, chunkMetaData.getDataType());
- assertEquals(endTime - startTime + 1, chunkMetaData.getNumOfPoints());
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemTablePoolTest.java b/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemTablePoolTest.java
deleted file mode 100644
index 0c617bc..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemTablePoolTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine.memtable;
-
-import java.util.TreeMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import org.apache.iotdb.db.rescon.MemTablePool;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MemTablePoolTest {
-
- private ConcurrentLinkedQueue<IMemTable> memTables;
- private Thread thread = new ReturnThread();
- private volatile boolean isFinished = false;
-
- @Before
- public void setUp() throws Exception {
- memTables = new ConcurrentLinkedQueue();
- thread.start();
- }
-
- @After
- public void tearDown() throws Exception {
- isFinished = true;
- thread.join();
- }
-
- @Test
- public void testGetAndRelease() {
- long time = System.currentTimeMillis();
- for (int i = 0; i < 10; i++) {
- IMemTable memTable = MemTablePool.getInstance().getAvailableMemTable("test case");
- memTables.add(memTable);
- }
- time -= System.currentTimeMillis();
- System.out.println("memtable pool use deque and synchronized consume:" + time);
- }
-
- //@Test
- public void testSort() {
- long start = System.currentTimeMillis();
- TreeMap<Long, Long> treeMap = new TreeMap<>();
- for (int i = 0; i < 1000000; i++) {
- treeMap.put((long) i, (long) i);
- }
- start = System.currentTimeMillis() - start;
- System.out.println("time cost of sort: " + start);
- }
-
-
- class ReturnThread extends Thread {
-
- @Override
- public void run() {
- while (true) {
- if (isInterrupted()) {
- break;
- }
- IMemTable memTable = memTables.poll();
- if (memTable == null) {
- if (isFinished) {
- break;
- }
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- }
- continue;
- }
- memTables.remove(memTable);
- MemTablePool.getInstance().putBack(memTable, "test case");
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemTableTestUtils.java b/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemTableTestUtils.java
deleted file mode 100644
index 6cda342..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemTableTestUtils.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine.memtable;
-
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.write.schema.Schema;
-import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
-
-public class MemTableTestUtils {
-
- public static String deviceId0 = "d0";
-
- public static String measurementId0 = "s0";
-
- public static TSDataType dataType0 = TSDataType.INT32;
- private static Schema schema = new Schema();
-
- static {
- schema
- .registerMeasurement(new MeasurementSchema(measurementId0, dataType0, TSEncoding.PLAIN));
- }
-
- public static void produceData(IMemTable iMemTable, long startTime, long endTime, String deviceId,
- String measurementId, TSDataType dataType) {
- if (startTime > endTime) {
- throw new RuntimeException(String.format("start time %d > end time %d", startTime, endTime));
- }
- for (long l = startTime; l <= endTime; l++) {
- iMemTable.write(deviceId, measurementId, dataType, l, (int)l);
- }
- }
-
- public static Schema getSchema() {
- return schema;
- }
-
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemtableBenchmark.java b/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemtableBenchmark.java
deleted file mode 100644
index 6c03f2b..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/memtable/MemtableBenchmark.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine.memtable;
-
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-
-/**
- * Memtable insert benchmark. Bench the Memtable and get its performance.
- */
-public class MemtableBenchmark {
-
- private static String deviceId = "d0";
- private static int numOfMeasurement = 10000;
- private static int numOfPoint = 1000;
-
- private static String[] measurementId = new String[numOfMeasurement];
- private static TSDataType tsDataType = TSDataType.INT64;
-
- static {
- for (int i = 0; i < numOfMeasurement; i++) {
- measurementId[i] = "m" + i;
- }
- }
-
- public static void main(String[] args) {
- IMemTable memTable = new PrimitiveMemTable();
- final long startTime = System.currentTimeMillis();
- // cpu not locality
- for (int i = 0; i < numOfPoint; i++) {
- for (int j = 0; j < numOfMeasurement; j++) {
- memTable.write(deviceId, measurementId[j], tsDataType, System.nanoTime(),
- String.valueOf(System.currentTimeMillis()));
- }
- }
-
- final long endTime = System.currentTimeMillis();
- System.out.println(String.format(
- "Num of time series: %d, " + "Num of points for each time series: %d, "
- + "The total time: %d ms. ",
- numOfMeasurement, numOfPoint, endTime - startTime));
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/memtable/PrimitiveMemTableTest.java b/server/src/test/java/org/apache/iotdb/db/engine/memtable/PrimitiveMemTableTest.java
deleted file mode 100644
index f146321..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/memtable/PrimitiveMemTableTest.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine.memtable;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Random;
-import org.apache.iotdb.db.engine.querycontext.ReadOnlyMemChunk;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.utils.MathUtils;
-import org.apache.iotdb.db.utils.datastructure.TVList;
-import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.read.reader.IPointReader;
-import org.apache.iotdb.tsfile.read.TimeValuePair;
-import org.apache.iotdb.tsfile.utils.Binary;
-import org.apache.iotdb.tsfile.utils.TsPrimitiveType;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class PrimitiveMemTableTest {
-
- double delta;
-
- @Before
- public void setUp() {
- delta = Math.pow(0.1, TSFileDescriptor.getInstance().getConfig().getFloatPrecision());
- }
-
- @Test
- public void memSeriesSortIteratorTest() throws IOException {
- TSDataType dataType = TSDataType.INT32;
- WritableMemChunk series = new WritableMemChunk(dataType, TVList.newList(dataType));
- int count = 1000;
- for (int i = 0; i < count; i++) {
- series.write(i, i);
- }
- IPointReader it = series.getSortedTVList().getIterator();
- int i = 0;
- while (it.hasNextTimeValuePair()) {
- Assert.assertEquals(i, it.nextTimeValuePair().getTimestamp());
- i++;
- }
- Assert.assertEquals(count, i);
- }
-
- @Test
- public void simpleTest() throws IOException, QueryProcessException {
- IMemTable memTable = new PrimitiveMemTable();
- int count = 10;
- String deviceId = "d1";
- String measurementId[] = new String[count];
- for (int i = 0; i < measurementId.length; i++) {
- measurementId[i] = "s" + i;
- }
-
- int dataSize = 10000;
- for (int i = 0; i < dataSize; i++) {
- memTable.write(deviceId, measurementId[0], TSDataType.INT32, dataSize - i - 1,
- i + 10);
- }
- for (int i = 0; i < dataSize; i++) {
- memTable.write(deviceId, measurementId[0], TSDataType.INT32, i, i);
- }
- ReadOnlyMemChunk memChunk = memTable
- .query(deviceId, measurementId[0], TSDataType.INT32, TSEncoding.RLE, Collections.emptyMap(),
- Long.MIN_VALUE);
- IPointReader iterator = memChunk.getPointReader();
- for (int i = 0; i < dataSize; i++) {
- iterator.hasNextTimeValuePair();
- TimeValuePair timeValuePair = iterator.nextTimeValuePair();
- Assert.assertEquals(i, timeValuePair.getTimestamp());
- Assert.assertEquals(i, timeValuePair.getValue().getValue());
- }
- }
-
- private void write(IMemTable memTable, String deviceId, String sensorId, TSDataType dataType,
- TSEncoding encoding, int size) throws IOException, QueryProcessException {
- TimeValuePair[] ret = genTimeValuePair(size, dataType);
-
- for (TimeValuePair aRet : ret) {
- memTable.write(deviceId, sensorId, dataType, aRet.getTimestamp(),
- aRet.getValue().getValue());
- }
- IPointReader tvPair = memTable
- .query(deviceId, sensorId, dataType, encoding, Collections.emptyMap(), Long.MIN_VALUE)
- .getPointReader();
- Arrays.sort(ret);
- TimeValuePair last = null;
- for (int i = 0; i < ret.length; i++) {
- while (last != null && (i < ret.length && last.getTimestamp() == ret[i].getTimestamp())) {
- i++;
- }
- if (i >= ret.length) {
- break;
- }
- TimeValuePair pair = ret[i];
- last = pair;
- tvPair.hasNextTimeValuePair();
- TimeValuePair next = tvPair.nextTimeValuePair();
- Assert.assertEquals(pair.getTimestamp(), next.getTimestamp());
- if (dataType == TSDataType.DOUBLE) {
- Assert.assertEquals(pair.getValue().getDouble(),
- MathUtils.roundWithGivenPrecision(next.getValue().getDouble()), delta);
- } else if (dataType == TSDataType.FLOAT) {
- float expected = pair.getValue().getFloat();
- float actual = MathUtils.roundWithGivenPrecision(next.getValue().getFloat());
- Assert.assertEquals(expected, actual, delta + Float.MIN_NORMAL);
- } else {
- Assert.assertEquals(pair.getValue(), next.getValue());
- }
- }
- }
-
- @Test
- public void testFloatType() throws IOException, QueryProcessException {
- IMemTable memTable = new PrimitiveMemTable();
- String deviceId = "d1";
- int size = 100;
- write(memTable, deviceId, "s1", TSDataType.FLOAT, TSEncoding.RLE, size);
- }
-
- @Test
- public void testAllType() throws IOException, QueryProcessException {
- IMemTable memTable = new PrimitiveMemTable();
- int count = 10;
- String deviceId = "d1";
- String measurementId[] = new String[count];
- for (int i = 0; i < measurementId.length; i++) {
- measurementId[i] = "s" + i;
- }
- int index = 0;
-
- int size = 10000;
- write(memTable, deviceId, measurementId[index++], TSDataType.BOOLEAN, TSEncoding.RLE, size);
- write(memTable, deviceId, measurementId[index++], TSDataType.INT32, TSEncoding.RLE, size);
- write(memTable, deviceId, measurementId[index++], TSDataType.INT64, TSEncoding.RLE, size);
- write(memTable, deviceId, measurementId[index++], TSDataType.FLOAT, TSEncoding.RLE, size);
- write(memTable, deviceId, measurementId[index++], TSDataType.DOUBLE, TSEncoding.RLE, size);
- write(memTable, deviceId, measurementId[index++], TSDataType.TEXT, TSEncoding.PLAIN, size);
- }
-
- private TimeValuePair[] genTimeValuePair(int size, TSDataType dataType) {
- TimeValuePair[] ret = new TimeValuePair[size];
- Random rand = new Random();
- for (int i = 0; i < size; i++) {
- switch (dataType) {
- case BOOLEAN:
- ret[i] = new TimeValuePair(rand.nextLong(),
- TsPrimitiveType.getByType(dataType, true));
- break;
- case INT32:
- ret[i] = new TimeValuePair(rand.nextLong(),
- TsPrimitiveType.getByType(dataType, rand.nextInt()));
- break;
- case INT64:
- ret[i] = new TimeValuePair(rand.nextLong(),
- TsPrimitiveType.getByType(dataType, rand.nextLong()));
- break;
- case FLOAT:
- ret[i] = new TimeValuePair(rand.nextLong(),
- TsPrimitiveType.getByType(dataType, rand.nextFloat()));
- break;
- case DOUBLE:
- ret[i] = new TimeValuePair(rand.nextLong(),
- TsPrimitiveType.getByType(dataType, rand.nextDouble()));
- break;
- case TEXT:
- ret[i] = new TimeValuePair(rand.nextLong(),
- TsPrimitiveType.getByType(dataType, new Binary("a" + rand.nextDouble())));
- break;
- default:
- throw new UnSupportedDataTypeException("Unsupported data type:" + dataType);
- }
- }
- return ret;
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/merge/MaxFileMergeFileSelectorTest.java b/server/src/test/java/org/apache/iotdb/db/engine/merge/MaxFileMergeFileSelectorTest.java
deleted file mode 100644
index 0f795b5..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/merge/MaxFileMergeFileSelectorTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.merge;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.List;
-import org.apache.iotdb.db.engine.merge.manage.MergeResource;
-import org.apache.iotdb.db.engine.merge.selector.MaxFileMergeFileSelector;
-import org.apache.iotdb.db.engine.merge.selector.IMergeFileSelector;
-import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.exception.MergeException;
-import org.junit.Test;
-
-public class MaxFileMergeFileSelectorTest extends MergeTest{
-
- @Test
- public void testFullSelection() throws MergeException, IOException {
- MergeResource resource = new MergeResource(seqResources, unseqResources);
- IMergeFileSelector mergeFileSelector = new MaxFileMergeFileSelector(resource, Long.MAX_VALUE);
- List[] result = mergeFileSelector.select();
- List<TsFileResource> seqSelected = result[0];
- List<TsFileResource> unseqSelected = result[1];
- assertEquals(seqResources, seqSelected);
- assertEquals(unseqResources, unseqSelected);
- resource.clear();
-
- resource = new MergeResource(seqResources.subList(0, 1), unseqResources);
- mergeFileSelector = new MaxFileMergeFileSelector(resource, Long.MAX_VALUE);
- result = mergeFileSelector.select();
- seqSelected = result[0];
- unseqSelected = result[1];
- assertEquals(seqResources.subList(0, 1), seqSelected);
- assertEquals(unseqResources, unseqSelected);
- resource.clear();
-
- resource = new MergeResource(seqResources, unseqResources.subList(0, 1));
- mergeFileSelector = new MaxFileMergeFileSelector(resource, Long.MAX_VALUE);
- result = mergeFileSelector.select();
- seqSelected = result[0];
- unseqSelected = result[1];
- assertEquals(seqResources.subList(0, 1), seqSelected);
- assertEquals(unseqResources.subList(0, 1), unseqSelected);
- resource.clear();
- }
-
- @Test
- public void testNonSelection() throws MergeException, IOException {
- MergeResource resource = new MergeResource(seqResources, unseqResources);
- IMergeFileSelector mergeFileSelector = new MaxFileMergeFileSelector(resource, 1);
- List[] result = mergeFileSelector.select();
- assertEquals(0, result.length);
- resource.clear();
- }
-
- @Test
- public void testRestrictedSelection() throws MergeException, IOException {
- MergeResource resource = new MergeResource(seqResources, unseqResources);
- IMergeFileSelector mergeFileSelector = new MaxFileMergeFileSelector(resource, 400000);
- List[] result = mergeFileSelector.select();
- List<TsFileResource> seqSelected = result[0];
- List<TsFileResource> unseqSelected = result[1];
- assertEquals(seqResources.subList(0, 2), seqSelected);
- assertEquals(unseqResources.subList(0, 2), unseqSelected);
- resource.clear();
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/merge/MaxSeriesMergeFileSelectorTest.java b/server/src/test/java/org/apache/iotdb/db/engine/merge/MaxSeriesMergeFileSelectorTest.java
deleted file mode 100644
index ac99cf0..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/merge/MaxSeriesMergeFileSelectorTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.merge;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.List;
-import org.apache.iotdb.db.engine.merge.manage.MergeResource;
-import org.apache.iotdb.db.engine.merge.selector.MaxSeriesMergeFileSelector;
-import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.exception.MergeException;
-import org.junit.Test;
-
-public class MaxSeriesMergeFileSelectorTest extends MergeTest{
-
- @Test
- public void testFullSelection() throws MergeException, IOException {
- MergeResource resource = new MergeResource(seqResources, unseqResources);
- MaxSeriesMergeFileSelector mergeFileSelector = new MaxSeriesMergeFileSelector(resource, Long.MAX_VALUE);
- List[] result = mergeFileSelector.select();
- List<TsFileResource> seqSelected = result[0];
- List<TsFileResource> unseqSelected = result[1];
- assertEquals(seqResources, seqSelected);
- assertEquals(unseqResources, unseqSelected);
- assertEquals(MaxSeriesMergeFileSelector.MAX_SERIES_NUM, mergeFileSelector.getConcurrentMergeNum());
- resource.clear();
-
- resource = new MergeResource(seqResources.subList(0, 1), unseqResources);
- mergeFileSelector = new MaxSeriesMergeFileSelector(resource, Long.MAX_VALUE);
- result = mergeFileSelector.select();
- seqSelected = result[0];
- unseqSelected = result[1];
- assertEquals(seqResources.subList(0, 1), seqSelected);
- assertEquals(unseqResources, unseqSelected);
- assertEquals(MaxSeriesMergeFileSelector.MAX_SERIES_NUM, mergeFileSelector.getConcurrentMergeNum());
- resource.clear();
-
- resource = new MergeResource(seqResources, unseqResources.subList(0, 1));
- mergeFileSelector = new MaxSeriesMergeFileSelector(resource, Long.MAX_VALUE);
- result = mergeFileSelector.select();
- seqSelected = result[0];
- unseqSelected = result[1];
- assertEquals(seqResources.subList(0, 1), seqSelected);
- assertEquals(unseqResources.subList(0, 1), unseqSelected);
- assertEquals(MaxSeriesMergeFileSelector.MAX_SERIES_NUM, mergeFileSelector.getConcurrentMergeNum());
- resource.clear();
- }
-
- @Test
- public void testNonSelection() throws MergeException, IOException {
- MergeResource resource = new MergeResource(seqResources, unseqResources);
- MaxSeriesMergeFileSelector mergeFileSelector = new MaxSeriesMergeFileSelector(resource, 1);
- List[] result = mergeFileSelector.select();
- assertEquals(0, result.length);
- assertEquals(0, mergeFileSelector.getConcurrentMergeNum());
- resource.clear();
- }
-
- @Test
- public void testRestrictedSelection() throws MergeException, IOException {
- MergeResource resource = new MergeResource(seqResources, unseqResources);
- MaxSeriesMergeFileSelector mergeFileSelector = new MaxSeriesMergeFileSelector(resource, 400000);
- List[] result = mergeFileSelector.select();
- List<TsFileResource> seqSelected = result[0];
- List<TsFileResource> unseqSelected = result[1];
- assertEquals(seqResources.subList(0, 2), seqSelected);
- assertEquals(unseqResources.subList(0, 2), unseqSelected);
- assertEquals(MaxSeriesMergeFileSelector.MAX_SERIES_NUM, mergeFileSelector.getConcurrentMergeNum());
- resource.clear();
- }
-
- @Test
- public void testRestrictedSelection2() throws MergeException, IOException {
- MergeResource resource = new MergeResource(seqResources, unseqResources);
- MaxSeriesMergeFileSelector mergeFileSelector = new MaxSeriesMergeFileSelector(resource,
- 100000);
- List[] result = mergeFileSelector.select();
- List<TsFileResource> seqSelected = result[0];
- List<TsFileResource> unseqSelected = result[1];
- assertEquals(seqResources.subList(0, 1), seqSelected);
- assertEquals(unseqResources.subList(0, 1), unseqSelected);
- resource.clear();
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeLogTest.java b/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeLogTest.java
deleted file mode 100644
index cf4bd93..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeLogTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.merge;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.merge.manage.MergeResource;
-import org.apache.iotdb.db.engine.merge.task.MergeTask;
-import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.query.PathException;
-import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.tsfile.exception.write.WriteProcessException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MergeLogTest extends MergeTest {
-
- File tempSGDir;
-
- @Before
- public void setUp() throws IOException, WriteProcessException, MetadataException, PathException {
- super.setUp();
- tempSGDir = new File(TestConstant.BASE_OUTPUT_PATH.concat("tempSG"));
- tempSGDir.mkdirs();
- }
-
- @After
- public void tearDown() throws IOException, StorageEngineException {
- super.tearDown();
- FileUtils.deleteDirectory(tempSGDir);FileUtils.deleteDirectory(tempSGDir);
- }
-
- @Test
- public void testMergeLog() throws Exception {
- MergeTask mergeTask =
- new MergeTask(new MergeResource(seqResources.subList(0, 1), unseqResources.subList(0, 1)),
- tempSGDir.getPath(), this::testCallBack, "test", false, 1, MERGE_TEST_SG);
- mergeTask.call();
- }
-
- private void testCallBack(List<TsFileResource> seqFiles, List<TsFileResource> unseqFiles,
- File mergeLog) {
- int lineCnt = 0;
- try (BufferedReader bufferedReader = new BufferedReader(new FileReader(mergeLog))) {
- String line;
- while ((line = bufferedReader.readLine()) != null) {
- lineCnt ++;
- }
- } catch (IOException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- assertEquals(309, lineCnt);
- }
-
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeOverLapTest.java b/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeOverLapTest.java
deleted file mode 100644
index a4b5e7c..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeOverLapTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.iotdb.db.engine.merge;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.conf.IoTDBConstant;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.merge.manage.MergeResource;
-import org.apache.iotdb.db.engine.merge.task.MergeTask;
-import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.query.PathException;
-import org.apache.iotdb.db.query.context.QueryContext;
-import org.apache.iotdb.db.query.reader.series.SeriesRawDataBatchReader;
-import org.apache.iotdb.tsfile.exception.write.WriteProcessException;
-import org.apache.iotdb.tsfile.read.common.BatchData;
-import org.apache.iotdb.tsfile.read.common.Path;
-import org.apache.iotdb.tsfile.read.reader.IBatchReader;
-import org.apache.iotdb.tsfile.write.TsFileWriter;
-import org.apache.iotdb.tsfile.write.record.TSRecord;
-import org.apache.iotdb.tsfile.write.record.datapoint.DataPoint;
-import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-public class MergeOverLapTest extends MergeTest {
-
- private File tempSGDir;
-
- @Before
- public void setUp()
- throws IOException, WriteProcessException, MetadataException, PathException {
- ptNum = 1000;
- super.setUp();
- tempSGDir = new File(TestConstant.BASE_OUTPUT_PATH.concat("tempSG"));
- tempSGDir.mkdirs();
- }
-
- @After
- public void tearDown() throws IOException, StorageEngineException {
- super.tearDown();
- FileUtils.deleteDirectory(tempSGDir);
- }
-
- @Override
- void prepareFiles(int seqFileNum, int unseqFileNum) throws IOException, WriteProcessException {
- for (int i = 0; i < seqFileNum; i++) {
- File file = new File(TestConstant.BASE_OUTPUT_PATH.concat(
- i + "seq" + IoTDBConstant.TSFILE_NAME_SEPARATOR + i + IoTDBConstant.TSFILE_NAME_SEPARATOR
- + i + IoTDBConstant.TSFILE_NAME_SEPARATOR + 0
- + ".tsfile"));
- TsFileResource tsFileResource = new TsFileResource(file);
- tsFileResource.setClosed(true);
- tsFileResource.setHistoricalVersions(Collections.singleton((long) i));
- seqResources.add(tsFileResource);
- prepareFile(tsFileResource, i * ptNum, ptNum, 0);
- }
- for (int i = 0; i < unseqFileNum; i++) {
- File file = new File(TestConstant.BASE_OUTPUT_PATH.concat(
- i + "unseq" + IoTDBConstant.TSFILE_NAME_SEPARATOR + i
- + IoTDBConstant.TSFILE_NAME_SEPARATOR
- + i + IoTDBConstant.TSFILE_NAME_SEPARATOR + 0
- + ".tsfile"));
- TsFileResource tsFileResource = new TsFileResource(file);
- tsFileResource.setClosed(true);
- tsFileResource.setHistoricalVersions(Collections.singleton((long) (i + seqFileNum)));
- unseqResources.add(tsFileResource);
- prepareUnseqFile(tsFileResource, i * ptNum, ptNum * (i + 1) / unseqFileNum, 10000);
- }
- File file = new File(TestConstant.BASE_OUTPUT_PATH.concat(
- unseqFileNum + "unseq" + IoTDBConstant.TSFILE_NAME_SEPARATOR + unseqFileNum
- + IoTDBConstant.TSFILE_NAME_SEPARATOR + unseqFileNum
- + IoTDBConstant.TSFILE_NAME_SEPARATOR + 0
- + ".tsfile"));
- TsFileResource tsFileResource = new TsFileResource(file);
- tsFileResource.setClosed(true);
- tsFileResource.setHistoricalVersions(Collections.singleton((long) (seqFileNum + unseqFileNum)));
- unseqResources.add(tsFileResource);
- prepareUnseqFile(tsFileResource, 0, ptNum * unseqFileNum, 20000);
- }
-
- private void prepareUnseqFile(TsFileResource tsFileResource, long timeOffset, long ptNum,
- long valueOffset)
- throws IOException, WriteProcessException {
- TsFileWriter fileWriter = new TsFileWriter(tsFileResource.getFile());
- for (MeasurementSchema measurementSchema : measurementSchemas) {
- fileWriter.addMeasurement(measurementSchema);
- }
- for (long i = timeOffset; i < timeOffset + ptNum; i++) {
- for (int j = 0; j < deviceNum; j++) {
- TSRecord record = new TSRecord(i, deviceIds[j]);
- for (int k = 0; k < measurementNum; k++) {
- record.addTuple(DataPoint.getDataPoint(measurementSchemas[k].getType(),
- measurementSchemas[k].getMeasurementId(), String.valueOf(i + valueOffset)));
- }
- fileWriter.write(record);
- tsFileResource.updateStartTime(deviceIds[j], i);
- tsFileResource.updateEndTime(deviceIds[j], i);
- }
- // insert overlapping tuples
- if ((i + 1) % 100 == 0) {
- for (int j = 0; j < deviceNum; j++) {
- TSRecord record = new TSRecord(i, deviceIds[j]);
- for (int k = 0; k < measurementNum; k++) {
- record.addTuple(DataPoint.getDataPoint(measurementSchemas[k].getType(),
- measurementSchemas[k].getMeasurementId(), String.valueOf(i + valueOffset)));
- }
- fileWriter.write(record);
- tsFileResource.updateStartTime(deviceIds[j], i);
- tsFileResource.updateEndTime(deviceIds[j], i);
- }
- }
- if ((i + 1) % flushInterval == 0) {
- fileWriter.flushForTest();
- }
- }
- fileWriter.close();
- }
-
- @Test
- public void testFullMerge() throws Exception {
- MergeTask mergeTask =
- new MergeTask(new MergeResource(seqResources, unseqResources), tempSGDir.getPath(),
- (k, v, l) -> {
- }, "test",
- true, 1, MERGE_TEST_SG);
- mergeTask.call();
-
- QueryContext context = new QueryContext();
- Path path = new Path(deviceIds[0], measurementSchemas[0].getMeasurementId());
- List<TsFileResource> resources = new ArrayList<>();
- resources.add(seqResources.get(0));
- IBatchReader tsFilesReader = new SeriesRawDataBatchReader(path, measurementSchemas[0].getType(), context,
- resources, new ArrayList<>(), null, null);
- int cnt = 0;
- try {
- while (tsFilesReader.hasNextBatch()) {
- BatchData batchData = tsFilesReader.nextBatch();
- for (int i = 0; i < batchData.length(); i++) {
- cnt++;
- assertEquals(batchData.getTimeByIndex(i) + 20000.0, batchData.getDoubleByIndex(i), 0.001);
- }
- }
- assertEquals(1000, cnt);
- } finally {
- tsFilesReader.close();
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergePerfTest.java b/server/src/test/java/org/apache/iotdb/db/engine/merge/MergePerfTest.java
deleted file mode 100644
index 4dcdcc3..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergePerfTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.merge;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.merge.manage.MergeResource;
-import org.apache.iotdb.db.engine.merge.task.MergeTask;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-public class MergePerfTest extends MergeTest{
-
- private long timeConsumption;
- private boolean fullMerge;
- private File tempSGDir;
-
- public void test() throws Exception {
- MManager.getInstance().init();
- tempSGDir = new File(TestConstant.BASE_OUTPUT_PATH.concat("tempSG"));
- tempSGDir.mkdirs();
- setUp();
- timeConsumption = System.currentTimeMillis();
- MergeResource resource = new MergeResource(seqResources, unseqResources);
- resource.setCacheDeviceMeta(true);
- MergeTask mergeTask =
- new MergeTask(resource, tempSGDir.getPath(), (k, v
- , l) -> {}, "test", fullMerge, 100, MERGE_TEST_SG);
- mergeTask.call();
- timeConsumption = System.currentTimeMillis() - timeConsumption;
- tearDown();
- FileUtils.deleteDirectory(tempSGDir);
- }
-
- public static void main(String[] args) throws Exception {
- IoTDBDescriptor.getInstance().getConfig().setChunkMergePointThreshold(-1);
-
- List<Long> timeConsumptions = new ArrayList<>();
- MergePerfTest perfTest = new MergePerfTest();
-
- perfTest.seqFileNum = 5;
- perfTest.unseqFileNum = 5;
- perfTest.measurementNum = 100;
- perfTest.deviceNum = 10;
- perfTest.ptNum = 5000;
- perfTest.flushInterval = 1000;
- perfTest.fullMerge = true;
- perfTest.encoding = TSEncoding.PLAIN;
-
- for (int i = 0; i < 1; i++) {
- // cache warm-up
- perfTest.test();
- }
-
-// int[] intParameters = new int[10];
-// for (int i = 1; i <= 10; i++) {
-// intParameters[i-1] = i;
-// }
-// for (int param : intParameters) {
-// perfTest.unseqFileNum = param;
-// perfTest.test();
-// timeConsumptions.add(perfTest.timeConsumption);
-// }
-// long[] longParameters = new long[10];
-// for (int i = 1; i <= 10; i++) {
-// longParameters[i-1] = i * 200;
-// }
-// for (long param : longParameters) {
-// perfTest.flushInterval = param;
-// perfTest.test();
-// timeConsumptions.add(perfTest.timeConsumption);
-// }
-// double[] doubleParameters = new double[10];
-// for (int i = 1; i <= 10; i++) {
-// doubleParameters[i-1] = 0.1 * i;
-// }
-// for (double param : doubleParameters) {
-// perfTest.unseqRatio = param;
-// perfTest.test();
-// timeConsumptions.add(perfTest.timeConsumption);
-// }
-
- System.out.println(timeConsumptions);
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeTaskTest.java b/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeTaskTest.java
deleted file mode 100644
index e333c66..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeTaskTest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.merge;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.merge.manage.MergeResource;
-import org.apache.iotdb.db.engine.merge.task.MergeTask;
-import org.apache.iotdb.db.engine.modification.Deletion;
-import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.query.PathException;
-import org.apache.iotdb.db.query.context.QueryContext;
-import org.apache.iotdb.db.query.reader.series.SeriesRawDataBatchReader;
-import org.apache.iotdb.tsfile.exception.write.WriteProcessException;
-import org.apache.iotdb.tsfile.read.common.BatchData;
-import org.apache.iotdb.tsfile.read.common.Path;
-import org.apache.iotdb.tsfile.read.reader.IBatchReader;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-public class MergeTaskTest extends MergeTest {
-
- private File tempSGDir;
-
- @Before
- public void setUp() throws IOException, WriteProcessException, MetadataException, PathException {
- super.setUp();
- tempSGDir = new File(TestConstant.BASE_OUTPUT_PATH.concat("tempSG"));
- tempSGDir.mkdirs();
- }
-
- @After
- public void tearDown() throws IOException, StorageEngineException {
- super.tearDown();
- FileUtils.deleteDirectory(tempSGDir);
- }
-
- @Test
- public void testMerge() throws Exception {
- MergeTask mergeTask =
- new MergeTask(new MergeResource(seqResources, unseqResources), tempSGDir.getPath(), (k, v
- , l) -> {
- }, "test", false, 1, MERGE_TEST_SG);
- mergeTask.call();
-
- QueryContext context = new QueryContext();
- Path path = new Path(deviceIds[0], measurementSchemas[0].getMeasurementId());
- List<TsFileResource> list = new ArrayList<>();
- list.add(seqResources.get(0));
- IBatchReader tsFilesReader = new SeriesRawDataBatchReader(path, measurementSchemas[0].getType(), context,
- list, new ArrayList<>(), null, null);
- while (tsFilesReader.hasNextBatch()) {
- BatchData batchData = tsFilesReader.nextBatch();
- for (int i = 0; i < batchData.length(); i++) {
- assertEquals(batchData.getTimeByIndex(i) + 20000.0, batchData.getDoubleByIndex(i), 0.001);
- }
- }
- tsFilesReader.close();
- }
-
- @Test
- public void testFullMerge() throws Exception {
- MergeTask mergeTask =
- new MergeTask(new MergeResource(seqResources, unseqResources), tempSGDir.getPath(),
- (k, v, l) -> {
- }, "test",
- true, 1, MERGE_TEST_SG);
- mergeTask.call();
-
- QueryContext context = new QueryContext();
- Path path = new Path(deviceIds[0], measurementSchemas[0].getMeasurementId());
- List<TsFileResource> list = new ArrayList<>();
- list.add(seqResources.get(0));
- IBatchReader tsFilesReader = new SeriesRawDataBatchReader(path, measurementSchemas[0].getType(), context,
- list, new ArrayList<>(), null, null);
- while (tsFilesReader.hasNextBatch()) {
- BatchData batchData = tsFilesReader.nextBatch();
- for (int i = 0; i < batchData.length(); i++) {
- assertEquals(batchData.getTimeByIndex(i) + 20000.0, batchData.getDoubleByIndex(i), 0.001);
- }
- }
- tsFilesReader.close();
- }
-
- @Test
- public void testChunkNumThreshold() throws Exception {
- IoTDBDescriptor.getInstance().getConfig().setChunkMergePointThreshold(Integer.MAX_VALUE);
- MergeTask mergeTask =
- new MergeTask(new MergeResource(seqResources, unseqResources), tempSGDir.getPath(),
- (k, v, l) -> {
- }, "test",
- false, 1, MERGE_TEST_SG);
- mergeTask.call();
-
- QueryContext context = new QueryContext();
- Path path = new Path(deviceIds[0], measurementSchemas[0].getMeasurementId());
- List<TsFileResource> resources = new ArrayList<>();
- resources.add(seqResources.get(0));
- IBatchReader tsFilesReader = new SeriesRawDataBatchReader(path, measurementSchemas[0].getType(), context,
- resources, new ArrayList<>(), null, null);
- while (tsFilesReader.hasNextBatch()) {
- BatchData batchData = tsFilesReader.nextBatch();
- for (int i = 0; i < batchData.length(); i++) {
- assertEquals(batchData.getTimeByIndex(i) + 20000.0, batchData.getDoubleByIndex(i), 0.001);
- }
- }
- tsFilesReader.close();
- }
-
- @Test
- public void testPartialMerge1() throws Exception {
- MergeTask mergeTask =
- new MergeTask(new MergeResource(seqResources, unseqResources.subList(0, 1)),
- tempSGDir.getPath(),
- (k, v, l) -> {
- }, "test", false, 1, MERGE_TEST_SG);
- mergeTask.call();
-
- QueryContext context = new QueryContext();
- Path path = new Path(deviceIds[0], measurementSchemas[0].getMeasurementId());
- List<TsFileResource> list = new ArrayList<>();
- list.add(seqResources.get(0));
- IBatchReader tsFilesReader = new SeriesRawDataBatchReader(path, measurementSchemas[0].getType(), context,
- list, new ArrayList<>(), null, null);
- while (tsFilesReader.hasNextBatch()) {
- BatchData batchData = tsFilesReader.nextBatch();
- for (int i = 0; i < batchData.length(); i++) {
- if (batchData.getTimeByIndex(i) < 20) {
- assertEquals(batchData.getTimeByIndex(i) + 10000.0, batchData.getDoubleByIndex(i), 0.001);
- } else {
- assertEquals(batchData.getTimeByIndex(i) + 0.0, batchData.getDoubleByIndex(i), 0.001);
- }
- }
- }
- tsFilesReader.close();
- }
-
- @Test
- public void testPartialMerge2() throws Exception {
- MergeTask mergeTask =
- new MergeTask(new MergeResource(seqResources, unseqResources.subList(5, 6)),
- tempSGDir.getPath(),
- (k, v, l) -> {
- }, "test", false, 1, MERGE_TEST_SG);
- mergeTask.call();
-
- QueryContext context = new QueryContext();
- Path path = new Path(deviceIds[0], measurementSchemas[0].getMeasurementId());
- List<TsFileResource> list = new ArrayList<>();
- list.add(seqResources.get(0));
- IBatchReader tsFilesReader = new SeriesRawDataBatchReader(path, measurementSchemas[0].getType(), context,
- list, new ArrayList<>(), null, null);
- while (tsFilesReader.hasNextBatch()) {
- BatchData batchData = tsFilesReader.nextBatch();
- for (int i = 0; i < batchData.length(); i++) {
- assertEquals(batchData.getTimeByIndex(i) + 20000.0, batchData.getDoubleByIndex(i), 0.001);
- }
- }
- tsFilesReader.close();
- }
-
- @Test
- public void testPartialMerge3() throws Exception {
- MergeTask mergeTask =
- new MergeTask(new MergeResource(seqResources, unseqResources.subList(0, 5)),
- tempSGDir.getPath(),
- (k, v, l) -> {
- }, "test", false, 1, MERGE_TEST_SG);
- mergeTask.call();
-
- QueryContext context = new QueryContext();
- Path path = new Path(deviceIds[0], measurementSchemas[0].getMeasurementId());
- List<TsFileResource> list = new ArrayList<>();
- list.add(seqResources.get(2));
- IBatchReader tsFilesReader = new SeriesRawDataBatchReader(path, measurementSchemas[0].getType(), context,
- list, new ArrayList<>(), null, null);
- while (tsFilesReader.hasNextBatch()) {
- BatchData batchData = tsFilesReader.nextBatch();
- for (int i = 0; i < batchData.length(); i++) {
- if (batchData.getTimeByIndex(i) < 260) {
- assertEquals(batchData.getTimeByIndex(i) + 10000.0, batchData.getDoubleByIndex(i), 0.001);
- } else {
- assertEquals(batchData.getTimeByIndex(i) + 0.0, batchData.getDoubleByIndex(i), 0.001);
- }
- }
- }
- tsFilesReader.close();
- }
-
- @Test
- public void mergeWithDeletionTest() throws Exception {
- try {
- seqResources.get(0).getModFile().write(new Deletion(new Path(deviceIds[0],
- measurementSchemas[0].getMeasurementId()), 10000, 49));
- } finally {
- seqResources.get(0).getModFile().close();
- }
-
- MergeTask mergeTask =
- new MergeTask(new MergeResource(seqResources, unseqResources.subList(0, 1)),
- tempSGDir.getPath(),
- (k, v, l) -> {
- try {
- seqResources.get(0).removeModFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }, "test", false, 1, MERGE_TEST_SG);
- mergeTask.call();
-
- QueryContext context = new QueryContext();
- Path path = new Path(deviceIds[0], measurementSchemas[0].getMeasurementId());
- List<TsFileResource> resources = new ArrayList<>();
- resources.add(seqResources.get(0));
- IBatchReader tsFilesReader = new SeriesRawDataBatchReader(path, measurementSchemas[0].getType(), context,
- resources, new ArrayList<>(), null, null);
- int count = 0;
- while (tsFilesReader.hasNextBatch()) {
- BatchData batchData = tsFilesReader.nextBatch();
- for (int i = 0; i < batchData.length(); i++) {
- if (batchData.getTimeByIndex(i) <= 20) {
- assertEquals(batchData.getTimeByIndex(i) + 10000.0, batchData.getDoubleByIndex(i), 0.001);
- } else {
- assertEquals(batchData.getTimeByIndex(i), batchData.getDoubleByIndex(i), 0.001);
- }
- count++;
- }
- }
- assertEquals(70, count);
- tsFilesReader.close();
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeTest.java b/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeTest.java
deleted file mode 100644
index 21a4683..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.merge;
-
-import static org.apache.iotdb.db.conf.IoTDBConstant.PATH_SEPARATOR;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.iotdb.db.conf.IoTDBConstant;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.cache.DeviceMetaDataCache;
-import org.apache.iotdb.db.engine.cache.TsFileMetaDataCache;
-import org.apache.iotdb.db.engine.merge.manage.MergeManager;
-import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.query.PathException;
-import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.db.query.control.FileReaderManager;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.tsfile.exception.write.WriteProcessException;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.write.TsFileWriter;
-import org.apache.iotdb.tsfile.write.record.TSRecord;
-import org.apache.iotdb.tsfile.write.record.datapoint.DataPoint;
-import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
-import org.junit.After;
-import org.junit.Before;
-
-abstract class MergeTest {
-
- static final String MERGE_TEST_SG = "root.mergeTest";
-
- int seqFileNum = 5;
- int unseqFileNum = 5;
- int measurementNum = 10;
- int deviceNum = 10;
- long ptNum = 100;
- long flushInterval = 20;
- TSEncoding encoding = TSEncoding.PLAIN;
-
- String[] deviceIds;
- MeasurementSchema[] measurementSchemas;
-
- List<TsFileResource> seqResources = new ArrayList<>();
- List<TsFileResource> unseqResources = new ArrayList<>();
-
- private int prevMergeChunkThreshold;
-
- @Before
- public void setUp() throws IOException, WriteProcessException, MetadataException, PathException {
- MManager.getInstance().init();
- prevMergeChunkThreshold =
- IoTDBDescriptor.getInstance().getConfig().getChunkMergePointThreshold();
- IoTDBDescriptor.getInstance().getConfig().setChunkMergePointThreshold(-1);
- prepareSeries();
- prepareFiles(seqFileNum, unseqFileNum);
- MergeManager.getINSTANCE().start();
- }
-
- @After
- public void tearDown() throws IOException, StorageEngineException {
- removeFiles();
- seqResources.clear();
- unseqResources.clear();
- IoTDBDescriptor.getInstance().getConfig().setChunkMergePointThreshold(prevMergeChunkThreshold);
- TsFileMetaDataCache.getInstance().clear();
- DeviceMetaDataCache.getInstance().clear();
- MManager.getInstance().clear();
- EnvironmentUtils.cleanAllDir();
- MergeManager.getINSTANCE().stop();
- }
-
- private void prepareSeries() throws MetadataException, PathException {
- measurementSchemas = new MeasurementSchema[measurementNum];
- for (int i = 0; i < measurementNum; i++) {
- measurementSchemas[i] = new MeasurementSchema("sensor" + i, TSDataType.DOUBLE,
- encoding, CompressionType.UNCOMPRESSED);
- }
- deviceIds = new String[deviceNum];
- for (int i = 0; i < deviceNum; i++) {
- deviceIds[i] = MERGE_TEST_SG + PATH_SEPARATOR + "device" + i;
- }
- MManager.getInstance().setStorageGroup(MERGE_TEST_SG);
- for (String device : deviceIds) {
- for (MeasurementSchema measurementSchema : measurementSchemas) {
- MManager.getInstance().createTimeseries(
- device + PATH_SEPARATOR + measurementSchema.getMeasurementId(), measurementSchema
- .getType(), measurementSchema.getEncodingType(), measurementSchema.getCompressor(),
- Collections.emptyMap());
- }
- }
- }
-
- void prepareFiles(int seqFileNum, int unseqFileNum)
- throws IOException, WriteProcessException {
- for (int i = 0; i < seqFileNum; i++) {
- File file = new File(TestConstant.BASE_OUTPUT_PATH.concat(
- i + "seq" + IoTDBConstant.TSFILE_NAME_SEPARATOR + i + IoTDBConstant.TSFILE_NAME_SEPARATOR
- + i + IoTDBConstant.TSFILE_NAME_SEPARATOR + 0
- + ".tsfile"));
- TsFileResource tsFileResource = new TsFileResource(file);
- tsFileResource.setClosed(true);
- tsFileResource.setHistoricalVersions(Collections.singleton((long) i));
- seqResources.add(tsFileResource);
- prepareFile(tsFileResource, i * ptNum, ptNum, 0);
- }
- for (int i = 0; i < unseqFileNum; i++) {
- File file = new File(TestConstant.BASE_OUTPUT_PATH.concat(
- i + "unseq" + IoTDBConstant.TSFILE_NAME_SEPARATOR
- + i + IoTDBConstant.TSFILE_NAME_SEPARATOR
- + i + IoTDBConstant.TSFILE_NAME_SEPARATOR + 0
- + ".tsfile"));
- TsFileResource tsFileResource = new TsFileResource(file);
- tsFileResource.setClosed(true);
- tsFileResource.setHistoricalVersions(Collections.singleton((long) (i + seqFileNum)));
- unseqResources.add(tsFileResource);
- prepareFile(tsFileResource, i * ptNum, ptNum * (i + 1) / unseqFileNum, 10000);
- }
-
- File file = new File(TestConstant.BASE_OUTPUT_PATH
- .concat(unseqFileNum + "unseq" + IoTDBConstant.TSFILE_NAME_SEPARATOR + unseqFileNum
- + IoTDBConstant.TSFILE_NAME_SEPARATOR + unseqFileNum
- + IoTDBConstant.TSFILE_NAME_SEPARATOR + 0 + ".tsfile"));
- TsFileResource tsFileResource = new TsFileResource(file);
- tsFileResource.setClosed(true);
- tsFileResource.setHistoricalVersions(Collections.singleton((long) (seqFileNum + unseqFileNum)));
- unseqResources.add(tsFileResource);
- prepareFile(tsFileResource, 0, ptNum * unseqFileNum, 20000);
- }
-
- private void removeFiles() throws IOException {
- for (TsFileResource tsFileResource : seqResources) {
- tsFileResource.remove();
- }
- for (TsFileResource tsFileResource : unseqResources) {
- tsFileResource.remove();
- }
-
- FileReaderManager.getInstance().closeAndRemoveAllOpenedReaders();
- FileReaderManager.getInstance().stop();
- }
-
- void prepareFile(TsFileResource tsFileResource, long timeOffset, long ptNum,
- long valueOffset)
- throws IOException, WriteProcessException {
- TsFileWriter fileWriter = new TsFileWriter(tsFileResource.getFile());
- for (MeasurementSchema measurementSchema : measurementSchemas) {
- fileWriter.addMeasurement(measurementSchema);
- }
- for (long i = timeOffset; i < timeOffset + ptNum; i++) {
- for (int j = 0; j < deviceNum; j++) {
- TSRecord record = new TSRecord(i, deviceIds[j]);
- for (int k = 0; k < measurementNum; k++) {
- record.addTuple(DataPoint.getDataPoint(measurementSchemas[k].getType(),
- measurementSchemas[k].getMeasurementId(), String.valueOf(i + valueOffset)));
- }
- fileWriter.write(record);
- tsFileResource.updateStartTime(deviceIds[j], i);
- tsFileResource.updateEndTime(deviceIds[j], i);
- }
- if ((i + 1) % flushInterval == 0) {
- fileWriter.flushForTest();
- }
- }
- fileWriter.close();
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeUpgradeTest.java b/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeUpgradeTest.java
deleted file mode 100644
index bfeeeb0..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/merge/MergeUpgradeTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.merge;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.iotdb.db.conf.IoTDBConstant;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.merge.manage.MergeResource;
-import org.apache.iotdb.db.engine.merge.selector.MaxFileMergeFileSelector;
-import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.exception.MergeException;
-import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
-import org.apache.iotdb.tsfile.exception.write.WriteProcessException;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.fileSystem.FSFactoryProducer;
-import org.apache.iotdb.tsfile.write.TsFileWriter;
-import org.apache.iotdb.tsfile.write.record.TSRecord;
-import org.apache.iotdb.tsfile.write.record.datapoint.DataPoint;
-import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MergeUpgradeTest {
-
- private List<TsFileResource> seqResources = new ArrayList<>();
- private List<TsFileResource> unseqResources = new ArrayList<>();
-
- private int seqFileNum = 2;
- private TSEncoding encoding = TSEncoding.RLE;
- private MeasurementSchema[] measurementSchemas;
- private int measurementNum = 5;
- private long ptNum = 10;
- private boolean changeVersion = true;
- private String deviceName = "root.MergeUpgrade.device0";
-
-
- @Before
- public void setUp() throws IOException, WriteProcessException {
- prepareSeries();
- prepareFiles();
- }
-
- @After
- public void tearDown() {
- removeFiles();
- seqResources.clear();
- unseqResources.clear();
- }
-
- @Test
- public void testMergeUpgradeSelect() throws MergeException {
- MergeResource resource = new MergeResource(seqResources, unseqResources);
- MaxFileMergeFileSelector mergeFileSelector = new MaxFileMergeFileSelector(resource,
- Long.MAX_VALUE);
- List[] result = mergeFileSelector.select();
- assertEquals(0, result.length);
- }
-
- private void prepareFiles() throws IOException, WriteProcessException {
- // prepare seqFiles
- for (int i = 0; i < seqFileNum; i++) {
- File seqfile = FSFactoryProducer.getFSFactory().getFile(TestConstant.BASE_OUTPUT_PATH.concat(
- "seq" + IoTDBConstant.TSFILE_NAME_SEPARATOR + i + IoTDBConstant.TSFILE_NAME_SEPARATOR
- + i + IoTDBConstant.TSFILE_NAME_SEPARATOR + 0
- + ".tsfile"));
- TsFileResource seqTsFileResource = new TsFileResource(seqfile);
- seqResources.add(seqTsFileResource);
- prepareOldFile(seqTsFileResource, i * ptNum, ptNum, 0);
- }
- // prepare unseqFile
- File unseqfile = FSFactoryProducer.getFSFactory().getFile(TestConstant.BASE_OUTPUT_PATH.concat(
- "unseq" + IoTDBConstant.TSFILE_NAME_SEPARATOR + 0 + IoTDBConstant.TSFILE_NAME_SEPARATOR
- + 0 + IoTDBConstant.TSFILE_NAME_SEPARATOR + 0
- + ".tsfile"));
- TsFileResource unseqTsFileResource = new TsFileResource(unseqfile);
- unseqResources.add(unseqTsFileResource);
- prepareFile(unseqTsFileResource, 0, 2 * ptNum, 10);
- }
-
- private void prepareSeries() {
- measurementSchemas = new MeasurementSchema[measurementNum];
- for (int i = 0; i < measurementNum; i++) {
- measurementSchemas[i] = new MeasurementSchema("sensor" + i, TSDataType.DOUBLE,
- encoding, CompressionType.UNCOMPRESSED);
- }
- }
-
- private void prepareOldFile(TsFileResource tsFileResource, long timeOffset, long ptNum,
- long valueOffset)
- throws IOException, WriteProcessException {
- TsFileWriter fileWriter = new TsFileWriter(tsFileResource.getFile());
- prepareData(tsFileResource, fileWriter, timeOffset, ptNum, valueOffset);
- fileWriter.close();
- if (changeVersion) {
- try (RandomAccessFile oldTsfile = new RandomAccessFile(tsFileResource.getFile(), "rw")) {
- oldTsfile.seek(TSFileConfig.MAGIC_STRING.length());
- oldTsfile.write(TSFileConfig.OLD_VERSION.getBytes());
- }
- changeVersion = false;
- }
- }
-
- private void prepareFile(TsFileResource tsFileResource, long timeOffset, long ptNum,
- long valueOffset) throws IOException, WriteProcessException {
- TsFileWriter fileWriter = new TsFileWriter(tsFileResource.getFile());
- prepareData(tsFileResource, fileWriter, timeOffset, ptNum, valueOffset);
- fileWriter.close();
- }
-
- private void removeFiles() {
- for (TsFileResource tsFileResource : seqResources) {
- tsFileResource.remove();
- }
- for (TsFileResource tsFileResource : unseqResources) {
- tsFileResource.remove();
- }
- }
-
- private void prepareData(TsFileResource tsFileResource, TsFileWriter fileWriter, long timeOffset,
- long ptNum, long valueOffset) throws WriteProcessException, IOException {
- for (MeasurementSchema measurementSchema : measurementSchemas) {
- fileWriter.addMeasurement(measurementSchema);
- }
- for (long i = timeOffset; i < timeOffset + ptNum; i++) {
- TSRecord record = new TSRecord(i, deviceName);
- for (int k = 0; k < measurementNum; k++) {
- record.addTuple(DataPoint.getDataPoint(measurementSchemas[k].getType(),
- measurementSchemas[k].getMeasurementId(), String.valueOf(i + valueOffset)));
- }
- fileWriter.write(record);
- tsFileResource.updateStartTime(deviceName, i);
- tsFileResource.updateEndTime(deviceName, i);
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/modification/DeletionFileNodeTest.java b/server/src/test/java/org/apache/iotdb/db/engine/modification/DeletionFileNodeTest.java
deleted file mode 100644
index 5be94ea..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/modification/DeletionFileNodeTest.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.modification;
-
-import static org.apache.iotdb.db.utils.EnvironmentUtils.TEST_QUERY_CONTEXT;
-import static org.apache.iotdb.db.utils.EnvironmentUtils.TEST_QUERY_JOB_ID;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import junit.framework.TestCase;
-import org.apache.iotdb.db.conf.directories.DirectoryManager;
-import org.apache.iotdb.db.engine.StorageEngine;
-import org.apache.iotdb.db.engine.modification.io.LocalTextModificationAccessor;
-import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
-import org.apache.iotdb.db.engine.querycontext.ReadOnlyMemChunk;
-import org.apache.iotdb.db.exception.StartupException;
-import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.query.PathException;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.exception.storageGroup.StorageGroupException;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
-import org.apache.iotdb.db.query.control.QueryResourceManager;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.read.reader.IPointReader;
-import org.apache.iotdb.tsfile.read.common.Path;
-import org.apache.iotdb.tsfile.read.expression.impl.SingleSeriesExpression;
-import org.apache.iotdb.tsfile.write.record.TSRecord;
-import org.apache.iotdb.tsfile.write.record.datapoint.DoubleDataPoint;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class DeletionFileNodeTest {
-
- private String processorName = "root.test";
-
- private static String[] measurements = new String[10];
- private String dataType = TSDataType.DOUBLE.toString();
- private String encoding = TSEncoding.PLAIN.toString();
-
- static {
- for (int i = 0; i < 10; i++) {
- measurements[i] = "m" + i;
- }
- }
-
- @Before
- public void setup() throws MetadataException, StorageEngineException, StartupException {
- EnvironmentUtils.envSetUp();
-
- MManager.getInstance().setStorageGroup(processorName);
- for (int i = 0; i < 10; i++) {
- MManager.getInstance().createTimeseries(processorName + "." + measurements[i], dataType,
- encoding);
- StorageEngine.getInstance()
- .addTimeSeries(new Path(processorName, measurements[i]), TSDataType.valueOf(dataType),
- TSEncoding.valueOf(encoding),
- TSFileDescriptor.getInstance().getConfig().getCompressor(),
- Collections.emptyMap());
- }
- }
-
- @After
- public void teardown() throws IOException, StorageEngineException {
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void testDeleteInBufferWriteCache() throws
- StorageEngineException, QueryProcessException, IOException {
-
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
-
- StorageEngine.getInstance().delete(processorName, measurements[3], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 50);
- StorageEngine.getInstance().delete(processorName, measurements[5], 30);
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
-
- SingleSeriesExpression expression = new SingleSeriesExpression(new Path(processorName,
- measurements[5]), null);
- QueryDataSource dataSource = QueryResourceManager.getInstance()
- .getQueryDataSource(expression.getSeriesPath(), TEST_QUERY_CONTEXT, null);
-
- List<ReadOnlyMemChunk> timeValuePairs =
- dataSource.getSeqResources().get(0).getReadOnlyMemChunk();
- int count = 0;
- for (ReadOnlyMemChunk chunk : timeValuePairs) {
- IPointReader iterator = chunk.getPointReader();
- while (iterator.hasNextTimeValuePair()) {
- iterator.nextTimeValuePair();
- count++;
- }
- }
- assertEquals(50, count);
- QueryResourceManager.getInstance().endQuery(TEST_QUERY_JOB_ID);
- }
-
- @Test
- public void testDeleteInBufferWriteFile()
- throws StorageEngineException, IOException, QueryProcessException {
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 40);
- StorageEngine.getInstance().delete(processorName, measurements[3], 30);
-
- Modification[] realModifications = new Modification[]{
- new Deletion(new Path(processorName, measurements[5]), 201, 50),
- new Deletion(new Path(processorName, measurements[4]), 202, 40),
- new Deletion(new Path(processorName, measurements[3]), 203, 30),
- };
-
- File fileNodeDir = new File(DirectoryManager.getInstance().getSequenceFileFolder(0),
- processorName);
- List<File> modFiles = new ArrayList<>();
- for (File directory : fileNodeDir.listFiles()) {
- assertTrue(directory.isDirectory());
- if (directory.isDirectory()) {
- for (File file : directory.listFiles()) {
- if (file.getPath().endsWith(ModificationFile.FILE_SUFFIX)) {
- modFiles.add(file);
- }
- }
- }
- }
-
- assertEquals(1, modFiles.size());
-
- LocalTextModificationAccessor accessor =
- new LocalTextModificationAccessor(modFiles.get(0).getPath());
- try {
- Collection<Modification> modifications = accessor.read();
- assertEquals(3, modifications.size());
- int i = 0;
- for (Modification modification : modifications) {
- TestCase.assertEquals(modification, realModifications[i++]);
- }
- } finally {
- accessor.close();
- }
- }
-
- @Test
- public void testDeleteInOverflowCache()
- throws StorageEngineException, QueryProcessException, IOException {
- // insert sequence data
- for (int i = 101; i <= 200; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- // insert unsequence data
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
-
- StorageEngine.getInstance().delete(processorName, measurements[3], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 50);
- StorageEngine.getInstance().delete(processorName, measurements[5], 30);
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
-
- SingleSeriesExpression expression = new SingleSeriesExpression(new Path(processorName,
- measurements[5]), null);
-
- QueryDataSource dataSource = QueryResourceManager.getInstance()
- .getQueryDataSource(expression.getSeriesPath(), TEST_QUERY_CONTEXT, null);
-
- List<ReadOnlyMemChunk> timeValuePairs =
- dataSource.getUnseqResources().get(0).getReadOnlyMemChunk();
- int count = 0;
- for (ReadOnlyMemChunk chunk : timeValuePairs) {
- IPointReader iterator = chunk.getPointReader();
- while (iterator.hasNextTimeValuePair()) {
- iterator.nextTimeValuePair();
- count++;
- }
- }
- assertEquals(50, count);
-
- QueryResourceManager.getInstance().endQuery(TEST_QUERY_JOB_ID);
- }
-
- @Test
- public void testDeleteInOverflowFile()
- throws StorageEngineException, QueryProcessException, IOException {
- // insert into BufferWrite
- for (int i = 101; i <= 200; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- // insert into Overflow
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 40);
- StorageEngine.getInstance().delete(processorName, measurements[3], 30);
-
- Modification[] realModifications = new Modification[]{
- new Deletion(new Path(processorName, measurements[5]), 301, 50),
- new Deletion(new Path(processorName, measurements[4]), 302, 40),
- new Deletion(new Path(processorName, measurements[3]), 303, 30),
- };
-
- File fileNodeDir = new File(DirectoryManager.getInstance().getNextFolderForUnSequenceFile(),
- processorName);
- List<File> modFiles = new ArrayList<>();
- for (File directory : fileNodeDir.listFiles()) {
- assertTrue(directory.isDirectory());
- if (directory.isDirectory()) {
- for (File file : directory.listFiles()) {
- if (file.getPath().endsWith(ModificationFile.FILE_SUFFIX)) {
- modFiles.add(file);
- }
- }
- }
- }
- assertEquals(1, modFiles.size());
-
- LocalTextModificationAccessor accessor =
- new LocalTextModificationAccessor(modFiles.get(0).getPath());
- Collection<Modification> modifications = accessor.read();
- assertEquals(3, modifications.size());
- int i = 0;
- for (Modification modification : modifications) {
- TestCase.assertEquals(modification, realModifications[i++]);
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/modification/DeletionQueryTest.java b/server/src/test/java/org/apache/iotdb/db/engine/modification/DeletionQueryTest.java
deleted file mode 100644
index 9e4f16a..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/modification/DeletionQueryTest.java
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.modification;
-
-import static org.apache.iotdb.db.utils.EnvironmentUtils.TEST_QUERY_CONTEXT;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.iotdb.db.engine.StorageEngine;
-import org.apache.iotdb.db.exception.StartupException;
-import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.query.PathException;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.exception.storageGroup.StorageGroupException;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
-import org.apache.iotdb.db.qp.physical.crud.RawDataQueryPlan;
-import org.apache.iotdb.db.query.executor.QueryRouter;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-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.DoubleDataPoint;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class DeletionQueryTest {
-
- private String processorName = "root.test";
-
- private static String[] measurements = new String[10];
- private String dataType = TSDataType.DOUBLE.toString();
- private String encoding = TSEncoding.PLAIN.toString();
- private QueryRouter router = new QueryRouter();
-
- static {
- for (int i = 0; i < 10; i++) {
- measurements[i] = "m" + i;
- }
- }
-
- @Before
- public void setup() throws MetadataException,
- PathException, IOException, StorageEngineException, StartupException, StorageGroupException {
- EnvironmentUtils.envSetUp();
-
- MManager.getInstance().setStorageGroup(processorName);
- for (int i = 0; i < 10; i++) {
- MManager.getInstance().createTimeseries(processorName + "." + measurements[i], dataType,
- encoding);
- StorageEngine.getInstance()
- .addTimeSeries(new Path(processorName, measurements[i]), TSDataType.valueOf(dataType),
- TSEncoding.valueOf(encoding),
- TSFileDescriptor.getInstance().getConfig().getCompressor(),
- Collections.emptyMap());
- }
- }
-
- @After
- public void teardown() throws IOException, StorageEngineException {
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void testDeleteInBufferWriteCache() throws
- StorageEngineException, IOException, QueryProcessException {
-
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
-
- StorageEngine.getInstance().delete(processorName, measurements[3], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 50);
- StorageEngine.getInstance().delete(processorName, measurements[5], 30);
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
-
- List<Path> pathList = new ArrayList<>();
- pathList.add(new Path(processorName, measurements[3]));
- pathList.add(new Path(processorName, measurements[4]));
- pathList.add(new Path(processorName, measurements[5]));
- List<TSDataType> dataTypes = new ArrayList<>();
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
-
- RawDataQueryPlan queryPlan = new RawDataQueryPlan();
- queryPlan.setDeduplicatedDataTypes(dataTypes);
- queryPlan.setDeduplicatedPaths(pathList);
- QueryDataSet dataSet = router.rawDataQuery(queryPlan, TEST_QUERY_CONTEXT);
-
- int count = 0;
- while (dataSet.hasNext()) {
- dataSet.next();
- count++;
- }
- assertEquals(50, count);
- }
-
- @Test
- public void testDeleteInBufferWriteFile()
- throws StorageEngineException, IOException, QueryProcessException {
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 40);
- StorageEngine.getInstance().delete(processorName, measurements[3], 30);
-
- List<Path> pathList = new ArrayList<>();
- pathList.add(new Path(processorName, measurements[3]));
- pathList.add(new Path(processorName, measurements[4]));
- pathList.add(new Path(processorName, measurements[5]));
-
- List<TSDataType> dataTypes = new ArrayList<>();
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
-
- RawDataQueryPlan queryPlan = new RawDataQueryPlan();
- queryPlan.setDeduplicatedDataTypes(dataTypes);
- queryPlan.setDeduplicatedPaths(pathList);
- QueryDataSet dataSet = router.rawDataQuery(queryPlan, TEST_QUERY_CONTEXT);
-
- int count = 0;
- while (dataSet.hasNext()) {
- dataSet.next();
- count++;
- }
- assertEquals(70, count);
- }
-
- @Test
- public void testDeleteInOverflowCache()
- throws StorageEngineException, IOException, QueryProcessException {
- // insert into BufferWrite
- for (int i = 101; i <= 200; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- // insert into Overflow
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
-
- StorageEngine.getInstance().delete(processorName, measurements[3], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 50);
- StorageEngine.getInstance().delete(processorName, measurements[5], 30);
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
-
- List<Path> pathList = new ArrayList<>();
- pathList.add(new Path(processorName, measurements[3]));
- pathList.add(new Path(processorName, measurements[4]));
- pathList.add(new Path(processorName, measurements[5]));
- List<TSDataType> dataTypes = new ArrayList<>();
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
-
- RawDataQueryPlan queryPlan = new RawDataQueryPlan();
- queryPlan.setDeduplicatedDataTypes(dataTypes);
- queryPlan.setDeduplicatedPaths(pathList);
- QueryDataSet dataSet = router.rawDataQuery(queryPlan, TEST_QUERY_CONTEXT);
-
- int count = 0;
- while (dataSet.hasNext()) {
- dataSet.next();
- count++;
- }
- assertEquals(150, count);
- }
-
- @Test
- public void testDeleteInOverflowFile()
- throws StorageEngineException, IOException, QueryProcessException {
- // insert into BufferWrite
- for (int i = 101; i <= 200; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- // insert into Overflow
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 40);
- StorageEngine.getInstance().delete(processorName, measurements[3], 30);
-
- List<Path> pathList = new ArrayList<>();
- pathList.add(new Path(processorName, measurements[3]));
- pathList.add(new Path(processorName, measurements[4]));
- pathList.add(new Path(processorName, measurements[5]));
-
- List<TSDataType> dataTypes = new ArrayList<>();
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
-
- RawDataQueryPlan queryPlan = new RawDataQueryPlan();
- queryPlan.setDeduplicatedDataTypes(dataTypes);
- queryPlan.setDeduplicatedPaths(pathList);
- QueryDataSet dataSet = router.rawDataQuery(queryPlan, TEST_QUERY_CONTEXT);
-
- int count = 0;
- while (dataSet.hasNext()) {
- dataSet.next();
- count++;
- }
- assertEquals(170, count);
- }
-
- @Test
- public void testSuccessiveDeletion()
- throws StorageEngineException, IOException, QueryProcessException {
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
-
- StorageEngine.getInstance().delete(processorName, measurements[3], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 50);
- StorageEngine.getInstance().delete(processorName, measurements[5], 30);
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
-
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- for (int i = 101; i <= 200; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
-
- StorageEngine.getInstance().delete(processorName, measurements[3], 250);
- StorageEngine.getInstance().delete(processorName, measurements[4], 250);
- StorageEngine.getInstance().delete(processorName, measurements[5], 230);
- StorageEngine.getInstance().delete(processorName, measurements[5], 250);
-
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- for (int i = 201; i <= 300; i++) {
- TSRecord record = new TSRecord(i, processorName);
- for (int j = 0; j < 10; j++) {
- record.addTuple(new DoubleDataPoint(measurements[j], i * 1.0));
- }
- StorageEngine.getInstance().insert(new InsertPlan(record));
- }
-
- StorageEngine.getInstance().delete(processorName, measurements[3], 50);
- StorageEngine.getInstance().delete(processorName, measurements[4], 50);
- StorageEngine.getInstance().delete(processorName, measurements[5], 30);
- StorageEngine.getInstance().delete(processorName, measurements[5], 50);
-
- StorageEngine.getInstance().syncCloseAllProcessor();
-
- List<Path> pathList = new ArrayList<>();
- pathList.add(new Path(processorName, measurements[3]));
- pathList.add(new Path(processorName, measurements[4]));
- pathList.add(new Path(processorName, measurements[5]));
- List<TSDataType> dataTypes = new ArrayList<>();
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
- dataTypes.add(TSDataType.valueOf(dataType));
-
- RawDataQueryPlan queryPlan = new RawDataQueryPlan();
- queryPlan.setDeduplicatedDataTypes(dataTypes);
- queryPlan.setDeduplicatedPaths(pathList);
- QueryDataSet dataSet = router.rawDataQuery(queryPlan, TEST_QUERY_CONTEXT);
-
- int count = 0;
- while (dataSet.hasNext()) {
- dataSet.next();
- count++;
- }
- assertEquals(100, count);
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/modification/ModificationFileTest.java b/server/src/test/java/org/apache/iotdb/db/engine/modification/ModificationFileTest.java
deleted file mode 100644
index d6cf510..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/modification/ModificationFileTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.modification;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.tsfile.read.common.Path;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class ModificationFileTest {
-
- @Test
- public void readMyWrite() {
- String tempFileName = TestConstant.BASE_OUTPUT_PATH.concat("mod.temp");
- Modification[] modifications = new Modification[]{
- new Deletion(new Path("d1", "s1"), 1, 1),
- new Deletion(new Path("d1", "s2"), 2, 2),
- new Deletion(new Path("d1", "s3"), 3, 3),
- new Deletion(new Path("d1", "s41"), 4, 4)
- };
- try (ModificationFile mFile = new ModificationFile(tempFileName)) {
- for (int i = 0; i < 2; i++) {
- mFile.write(modifications[i]);
- }
- List<Modification> modificationList = (List<Modification>) mFile.getModifications();
- for (int i = 0; i < 2; i++) {
- assertEquals(modifications[i], modificationList.get(i));
- }
-
- for (int i = 2; i < 4; i++) {
- mFile.write(modifications[i]);
- }
- modificationList = (List<Modification>) mFile.getModifications();
- for (int i = 0; i < 4; i++) {
- assertEquals(modifications[i], modificationList.get(i));
- }
- } catch (IOException e) {
- fail(e.getMessage());
- } finally {
- new File(tempFileName).delete();
- }
- }
-
- @Test
- public void testAbort() {
- String tempFileName = TestConstant.BASE_OUTPUT_PATH.concat("mod.temp");
- Modification[] modifications = new Modification[]{
- new Deletion(new Path("d1", "s1"), 1, 1),
- new Deletion(new Path("d1", "s2"), 2, 2),
- new Deletion(new Path("d1", "s3"), 3, 3),
- new Deletion(new Path("d1", "s41"), 4, 4),
- };
- try (ModificationFile mFile = new ModificationFile(tempFileName)) {
- for (int i = 0; i < 2; i++) {
- mFile.write(modifications[i]);
- }
- List<Modification> modificationList = (List<Modification>) mFile.getModifications();
- for (int i = 0; i < 2; i++) {
- assertEquals(modifications[i], modificationList.get(i));
- }
-
- for (int i = 2; i < 4; i++) {
- mFile.write(modifications[i]);
- }
- modificationList = (List<Modification>) mFile.getModifications();
- mFile.abort();
-
- for (int i = 0; i < 3; i++) {
- assertEquals(modifications[i], modificationList.get(i));
- }
- } catch (IOException e) {
- fail(e.getMessage());
- } finally {
- new File(tempFileName).delete();
- }
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/modification/io/LocalTextModificationAccessorTest.java b/server/src/test/java/org/apache/iotdb/db/engine/modification/io/LocalTextModificationAccessorTest.java
deleted file mode 100644
index 063b753..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/modification/io/LocalTextModificationAccessorTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.modification.io;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.modification.Deletion;
-import org.apache.iotdb.db.engine.modification.Modification;
-import org.apache.iotdb.tsfile.read.common.Path;
-import org.junit.Test;
-
-public class LocalTextModificationAccessorTest {
-
- @Test
- public void readMyWrite() {
- String tempFileName = TestConstant.BASE_OUTPUT_PATH.concat("mod.temp");
- Modification[] modifications = new Modification[]{
- new Deletion(new Path("d1", "s1"), 1, 1),
- new Deletion(new Path("d1", "s2"), 2, 2),
- new Deletion(new Path("d1", "s3"), 3, 3),
- new Deletion(new Path("d1", "s4"), 4, 4),
- };
- try (LocalTextModificationAccessor accessor = new LocalTextModificationAccessor(tempFileName)) {
- for (int i = 0; i < 2; i++) {
- accessor.write(modifications[i]);
- }
- List<Modification> modificationList = (List<Modification>) accessor.read();
- for (int i = 0; i < 2; i++) {
- assertEquals(modifications[i], modificationList.get(i));
- }
-
- for (int i = 2; i < 4; i++) {
- accessor.write(modifications[i]);
- }
- modificationList = (List<Modification>) accessor.read();
- for (int i = 0; i < 4; i++) {
- assertEquals(modifications[i], modificationList.get(i));
- }
- } catch (IOException e) {
- fail(e.getMessage());
- } finally {
- new File(tempFileName).delete();
- }
- }
-
- @Test
- public void readNull() throws IOException {
- String tempFileName = TestConstant.BASE_OUTPUT_PATH.concat("mod.temp");
- LocalTextModificationAccessor accessor;
- accessor = new LocalTextModificationAccessor(tempFileName);
- new File(tempFileName).delete();
- Collection<Modification> modifications = accessor.read();
- assertEquals(new ArrayList<>(), modifications);
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/FileNodeManagerBenchmark.java b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/FileNodeManagerBenchmark.java
deleted file mode 100644
index 7fea61d..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/FileNodeManagerBenchmark.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine.storagegroup;
-
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicLong;
-import org.apache.iotdb.db.engine.StorageEngine;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.query.PathException;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.exception.storageGroup.StorageGroupException;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.db.utils.RandomNum;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.write.record.TSRecord;
-import org.apache.iotdb.tsfile.write.record.datapoint.LongDataPoint;
-
-/**
- * Bench The storage group manager with mul-thread and get its performance.
- */
-public class FileNodeManagerBenchmark {
-
- private static int numOfWorker = 10;
- private static int numOfDevice = 10;
- private static int numOfMeasurement = 10;
- private static long numOfTotalLine = 10000000;
- private static CountDownLatch latch = new CountDownLatch(numOfWorker);
- private static AtomicLong atomicLong = new AtomicLong();
-
- private static String[] devices = new String[numOfDevice];
- private static String prefix = "root.bench";
- private static String[] measurements = new String[numOfMeasurement];
-
- static {
- for (int i = 0; i < numOfDevice; i++) {
- devices[i] = prefix + "." + "device_" + i;
- }
- }
-
- static {
- for (int i = 0; i < numOfMeasurement; i++) {
- measurements[i] = "measurement_" + i;
- }
- }
-
- private static void prepare()
- throws MetadataException, PathException, IOException, StorageGroupException {
- MManager manager = MManager.getInstance();
- manager.setStorageGroup(prefix);
- for (String device : devices) {
- for (String measurement : measurements) {
- manager.createTimeseries(device + "." + measurement, TSDataType.INT64.toString(),
- TSEncoding.PLAIN.toString());
- }
- }
- }
-
- private static void tearDown() throws IOException, StorageEngineException {
- EnvironmentUtils.cleanEnv();
- }
-
- public static void main(String[] args)
- throws InterruptedException, IOException, MetadataException,
- PathException, StorageEngineException, StorageGroupException {
- tearDown();
- prepare();
- long startTime = System.currentTimeMillis();
- for (int i = 0; i < numOfWorker; i++) {
- Worker worker = new Worker();
- worker.start();
- }
- latch.await();
- long endTime = System.currentTimeMillis();
- System.out.println("Elapsed time: " + (endTime - startTime) + "ms");
- tearDown();
- }
-
- private static TSRecord getRecord(String deltaObjectId, long timestamp) {
- TSRecord tsRecord = new TSRecord(timestamp, deltaObjectId);
- for (String measurement : measurements) {
- tsRecord.addTuple(new LongDataPoint(measurement, timestamp));
- }
- return tsRecord;
- }
-
- private static class Worker extends Thread {
-
- @Override
- public void run() {
- try {
- while (true) {
- long seed = atomicLong.addAndGet(1);
- if (seed > numOfTotalLine) {
- break;
- }
- long time = RandomNum.getRandomLong(1, seed);
- String deltaObject = devices[(int) (time % numOfDevice)];
- TSRecord tsRecord = getRecord(deltaObject, time);
- StorageEngine.getInstance().insert(new InsertPlan(tsRecord));
- }
- } catch (QueryProcessException | StorageEngineException e) {
- e.printStackTrace();
- } finally {
- latch.countDown();
- }
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessorTest.java b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessorTest.java
deleted file mode 100644
index 7617ab5..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessorTest.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine.storagegroup;
-
-import org.apache.iotdb.db.conf.adapter.ActiveTimeSeriesCounter;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.MetadataManagerHelper;
-import org.apache.iotdb.db.engine.flush.TsFileFlushPolicy;
-import org.apache.iotdb.db.engine.merge.manage.MergeManager;
-import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
-import org.apache.iotdb.db.engine.querycontext.ReadOnlyMemChunk;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.exception.storageGroup.StorageGroupProcessorException;
-import org.apache.iotdb.db.qp.physical.crud.BatchInsertPlan;
-import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
-import org.apache.iotdb.db.query.context.QueryContext;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.tsfile.read.reader.IPointReader;
-import org.apache.iotdb.tsfile.read.TimeValuePair;
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.utils.Pair;
-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;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static org.junit.Assert.assertFalse;
-
-public class StorageGroupProcessorTest {
-
- private String storageGroup = "root.vehicle.d0";
- private String systemDir = TestConstant.OUTPUT_DATA_DIR.concat("info");
- private String deviceId = "root.vehicle.d0";
- private String measurementId = "s0";
- private StorageGroupProcessor processor;
- private QueryContext context = EnvironmentUtils.TEST_QUERY_CONTEXT;
- private AtomicLong mergeLock;
-
- @Before
- public void setUp() throws Exception {
- MetadataManagerHelper.initMetadata();
- EnvironmentUtils.envSetUp();
- ActiveTimeSeriesCounter.getInstance().init(storageGroup);
- processor = new DummySGP(systemDir, storageGroup);
- MergeManager.getINSTANCE().start();
- }
-
- @After
- public void tearDown() throws Exception {
- processor.syncDeleteDataFiles();
- EnvironmentUtils.cleanEnv();
- EnvironmentUtils.cleanDir(TestConstant.OUTPUT_DATA_DIR);
- MergeManager.getINSTANCE().stop();
- EnvironmentUtils.cleanEnv();
- }
-
-
- @Test
- public void testUnseqUnsealedDelete() throws QueryProcessException, IOException {
- TSRecord record = new TSRecord(10000, deviceId);
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(1000)));
- processor.insert(new InsertPlan(record));
- processor.waitForAllCurrentTsFileProcessorsClosed();
-
- for (int j = 1; j <= 10; j++) {
- record = new TSRecord(j, deviceId);
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
- processor.insert(new InsertPlan(record));
- }
-
- for (TsFileProcessor tsfileProcessor : processor.getWorkUnsequenceTsFileProcessor()) {
- tsfileProcessor.syncFlush();
- }
-
- for (int j = 11; j <= 20; j++) {
- record = new TSRecord(j, deviceId);
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
- processor.insert(new InsertPlan(record));
- }
-
- processor.delete(deviceId, measurementId, 15L);
-
- Pair<List<ReadOnlyMemChunk>, List<ChunkMetaData>> pair = null;
- for (TsFileProcessor tsfileProcessor : processor.getWorkUnsequenceTsFileProcessor()) {
- pair = tsfileProcessor
- .query(deviceId, measurementId, TSDataType.INT32, TSEncoding.RLE, Collections.emptyMap(),
- new QueryContext());
- break;
- }
-
- List<ReadOnlyMemChunk> memChunks = pair.left;
-
- long time = 16;
- for (ReadOnlyMemChunk memChunk : memChunks) {
- IPointReader iterator = memChunk.getPointReader();
- while (iterator.hasNextTimeValuePair()) {
- TimeValuePair timeValuePair = iterator.nextTimeValuePair();
- Assert.assertEquals(time++, timeValuePair.getTimestamp());
- }
- }
-
- Assert.assertEquals(0, pair.right.size());
- }
-
- @Test
- public void testSequenceSyncClose() throws QueryProcessException {
- for (int j = 1; j <= 10; j++) {
- TSRecord record = new TSRecord(j, deviceId);
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
- processor.insert(new InsertPlan(record));
- processor.putAllWorkingTsFileProcessorIntoClosingList();
- }
-
- processor.waitForAllCurrentTsFileProcessorsClosed();
- QueryDataSource queryDataSource = processor.query(deviceId, measurementId, context,
- null, null);
-
- Assert.assertEquals(10, queryDataSource.getSeqResources().size());
- for (TsFileResource resource : queryDataSource.getSeqResources()) {
- Assert.assertTrue(resource.isClosed());
- }
- }
-
- @Test
- public void testIoTDBRowBatchWriteAndSyncClose() throws QueryProcessException {
-
- String[] measurements = new String[2];
- measurements[0] = "s0";
- measurements[1] = "s1";
- List<Integer> dataTypes = new ArrayList<>();
- dataTypes.add(TSDataType.INT32.ordinal());
- dataTypes.add(TSDataType.INT64.ordinal());
-
- BatchInsertPlan batchInsertPlan1 = new BatchInsertPlan("root.vehicle.d0", measurements,
- dataTypes);
-
- long[] times = new long[100];
- Object[] columns = new Object[2];
- columns[0] = new int[100];
- columns[1] = new long[100];
-
- for (int r = 0; r < 100; r++) {
- times[r] = r;
- ((int[]) columns[0])[r] = 1;
- ((long[]) columns[1])[r] = 1;
- }
- batchInsertPlan1.setTimes(times);
- batchInsertPlan1.setColumns(columns);
- batchInsertPlan1.setRowCount(times.length);
-
- processor.insertBatch(batchInsertPlan1);
- processor.putAllWorkingTsFileProcessorIntoClosingList();
-
- BatchInsertPlan batchInsertPlan2 = new BatchInsertPlan("root.vehicle.d0", measurements,
- dataTypes);
-
- for (int r = 50; r < 149; r++) {
- times[r - 50] = r;
- ((int[]) columns[0])[r - 50] = 1;
- ((long[]) columns[1])[r - 50] = 1;
- }
- batchInsertPlan2.setTimes(times);
- batchInsertPlan2.setColumns(columns);
- batchInsertPlan2.setRowCount(times.length);
-
- processor.insertBatch(batchInsertPlan2);
- processor.putAllWorkingTsFileProcessorIntoClosingList();
- processor.waitForAllCurrentTsFileProcessorsClosed();
-
- QueryDataSource queryDataSource = processor.query(deviceId, measurementId, context,
- null, null);
-
- Assert.assertEquals(2, queryDataSource.getSeqResources().size());
- Assert.assertEquals(1, queryDataSource.getUnseqResources().size());
- for (TsFileResource resource : queryDataSource.getSeqResources()) {
- Assert.assertTrue(resource.isClosed());
- }
- }
-
-
- @Test
- public void testSeqAndUnSeqSyncClose() throws QueryProcessException {
-
- for (int j = 21; j <= 30; j++) {
- TSRecord record = new TSRecord(j, deviceId);
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
- processor.insert(new InsertPlan(record));
- processor.putAllWorkingTsFileProcessorIntoClosingList();
- }
- processor.waitForAllCurrentTsFileProcessorsClosed();
-
- for (int j = 10; j >= 1; j--) {
- TSRecord record = new TSRecord(j, deviceId);
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
- processor.insert(new InsertPlan(record));
- processor.putAllWorkingTsFileProcessorIntoClosingList();
- }
-
- processor.waitForAllCurrentTsFileProcessorsClosed();
-
- QueryDataSource queryDataSource = processor.query(deviceId, measurementId, context,
- null, null);
- Assert.assertEquals(10, queryDataSource.getSeqResources().size());
- Assert.assertEquals(10, queryDataSource.getUnseqResources().size());
- for (TsFileResource resource : queryDataSource.getSeqResources()) {
- Assert.assertTrue(resource.isClosed());
- }
- for (TsFileResource resource : queryDataSource.getUnseqResources()) {
- Assert.assertTrue(resource.isClosed());
- }
- }
-
- @Test
- public void testMerge() throws QueryProcessException {
-
- mergeLock = new AtomicLong(0);
- for (int j = 21; j <= 30; j++) {
- TSRecord record = new TSRecord(j, deviceId);
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
- processor.insert(new InsertPlan(record));
- processor.putAllWorkingTsFileProcessorIntoClosingList();
- }
- processor.waitForAllCurrentTsFileProcessorsClosed();
-
- for (int j = 10; j >= 1; j--) {
- TSRecord record = new TSRecord(j, deviceId);
- record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
- processor.insert(new InsertPlan(record));
- processor.putAllWorkingTsFileProcessorIntoClosingList();
- }
-
- processor.waitForAllCurrentTsFileProcessorsClosed();
- processor.merge(true);
- while (mergeLock.get() == 0) {
- // wait
- }
-
- QueryDataSource queryDataSource = processor.query(deviceId, measurementId, context,
- null, null);
- Assert.assertEquals(10, queryDataSource.getSeqResources().size());
- Assert.assertEquals(0, queryDataSource.getUnseqResources().size());
- for (TsFileResource resource : queryDataSource.getSeqResources()) {
- Assert.assertTrue(resource.isClosed());
- }
- for (TsFileResource resource : queryDataSource.getUnseqResources()) {
- Assert.assertTrue(resource.isClosed());
- }
- }
-
- class DummySGP extends StorageGroupProcessor {
-
- DummySGP(String systemInfoDir, String storageGroupName)
- throws StorageGroupProcessorException, MetadataException {
- super(systemInfoDir, storageGroupName, new TsFileFlushPolicy.DirectFlushPolicy());
- }
-
- @Override
- protected void mergeEndAction(List<TsFileResource> seqFiles, List<TsFileResource> unseqFiles,
- File mergeLog) {
- super.mergeEndAction(seqFiles, unseqFiles, mergeLog);
- mergeLock.incrementAndGet();
- assertFalse(mergeLog.exists());
- }
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java
deleted file mode 100644
index 15ce293..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.iotdb.db.engine.storagegroup;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.iotdb.db.conf.IoTDBConstant;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.conf.directories.DirectoryManager;
-import org.apache.iotdb.db.engine.flush.TsFileFlushPolicy.DirectFlushPolicy;
-import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
-import org.apache.iotdb.db.exception.StartupException;
-import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.query.OutOfTTLException;
-import org.apache.iotdb.db.exception.query.PathException;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.exception.storageGroup.StorageGroupException;
-import org.apache.iotdb.db.exception.storageGroup.StorageGroupProcessorException;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.db.metadata.mnode.StorageGroupMNode;
-import org.apache.iotdb.db.qp.Planner;
-import org.apache.iotdb.db.qp.executor.PlanExecutor;
-import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTTLPlan;
-import org.apache.iotdb.db.qp.physical.sys.ShowTTLPlan;
-import org.apache.iotdb.db.query.control.QueryResourceManager;
-import org.apache.iotdb.db.query.reader.series.SeriesRawDataBatchReader;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
-import org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.read.common.BatchData;
-import org.apache.iotdb.tsfile.read.common.Path;
-import org.apache.iotdb.tsfile.read.common.RowRecord;
-import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
-import org.apache.iotdb.tsfile.read.reader.IBatchReader;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class TTLTest {
-
- private String sg1 = "root.TTL_SG1";
- private String sg2 = "root.TTL_SG2";
- private long ttl = 12345;
- private StorageGroupProcessor storageGroupProcessor;
- private String s1 = "s1";
- private String g1s1 = sg1 + IoTDBConstant.PATH_SEPARATOR + s1;
-
- @Before
- public void setUp()
- throws MetadataException, IOException, StartupException, PathException, StorageGroupProcessorException {
- IoTDBDescriptor.getInstance().getConfig().setPartitionInterval(86400);
- EnvironmentUtils.envSetUp();
- createSchemas();
- }
-
- @After
- public void tearDown() throws IOException, StorageEngineException {
- storageGroupProcessor.waitForAllCurrentTsFileProcessorsClosed();
- EnvironmentUtils.cleanEnv();
- }
-
- private void createSchemas()
- throws MetadataException, StorageGroupProcessorException {
- MManager.getInstance().setStorageGroup(sg1);
- MManager.getInstance().setStorageGroup(sg2);
- storageGroupProcessor = new StorageGroupProcessor(IoTDBDescriptor.getInstance().getConfig()
- .getSystemDir(), sg1, new DirectFlushPolicy());
- MManager.getInstance().createTimeseries(g1s1, TSDataType.INT64, TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED, Collections.emptyMap());
- storageGroupProcessor.addMeasurement("s1", TSDataType.INT64, TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED, Collections.emptyMap());
- }
-
- @Test
- public void testSetMetaTTL() throws IOException, MetadataException {
- // exception is expected when setting ttl to a non-exist storage group
- boolean caught = false;
- try {
- MManager.getInstance().setTTL(sg1 + ".notExist", ttl);
- } catch (MetadataException e) {
- caught = true;
- }
- assertTrue(caught);
-
- // normally set ttl
- MManager.getInstance().setTTL(sg1, ttl);
- StorageGroupMNode mNode = MManager.getInstance().getStorageGroupNode(sg1);
- assertEquals(ttl, mNode.getDataTTL());
-
- // default ttl
- mNode = MManager.getInstance().getStorageGroupNode(sg2);
- assertEquals(Long.MAX_VALUE, mNode.getDataTTL());
- }
-
- @Test
- public void testTTLWrite() throws QueryProcessException {
- InsertPlan insertPlan = new InsertPlan();
- insertPlan.setDeviceId(sg1);
- insertPlan.setTime(System.currentTimeMillis());
- insertPlan.setMeasurements(new String[]{"s1"});
- insertPlan.setValues(new String[]{"1"});
- insertPlan.setDataTypes(new TSDataType[]{TSDataType.INT64});
-
- // ok without ttl
- storageGroupProcessor.insert(insertPlan);
-
- storageGroupProcessor.setDataTTL(1000);
- // with ttl
- insertPlan.setTime(System.currentTimeMillis() - 1001);
- boolean caught = false;
- try {
- storageGroupProcessor.insert(insertPlan);
- } catch (OutOfTTLException e) {
- caught = true;
- }
- assertTrue(caught);
- insertPlan.setTime(System.currentTimeMillis() - 900);
- storageGroupProcessor.insert(insertPlan);
- }
-
- private void prepareData() throws QueryProcessException {
- InsertPlan insertPlan = new InsertPlan();
- insertPlan.setDeviceId(sg1);
- insertPlan.setTime(System.currentTimeMillis());
- insertPlan.setMeasurements(new String[]{"s1"});
- insertPlan.setValues(new String[]{"1"});
- insertPlan.setDataTypes(new TSDataType[]{TSDataType.INT64});
-
- long initTime = System.currentTimeMillis();
- // sequence data
- for (int i = 1000; i < 2000; i++) {
- insertPlan.setTime(initTime - 2000 + i);
- storageGroupProcessor.insert(insertPlan);
- if ((i + 1) % 300 == 0) {
- storageGroupProcessor.putAllWorkingTsFileProcessorIntoClosingList();
- }
- }
- // unsequence data
- for (int i = 0; i < 1000; i++) {
- insertPlan.setTime(initTime - 2000 + i);
- storageGroupProcessor.insert(insertPlan);
- if ((i + 1) % 300 == 0) {
- storageGroupProcessor.putAllWorkingTsFileProcessorIntoClosingList();
- }
- }
- }
-
- @Test
- public void testTTLRead() throws IOException, QueryProcessException, StorageEngineException {
- prepareData();
-
- // files before ttl
- QueryDataSource dataSource = storageGroupProcessor
- .query(sg1, s1, EnvironmentUtils.TEST_QUERY_CONTEXT, null, null);
- List<TsFileResource> seqResource = dataSource.getSeqResources();
- List<TsFileResource> unseqResource = dataSource.getUnseqResources();
- assertEquals(4, seqResource.size());
- assertEquals(4, unseqResource.size());
-
- storageGroupProcessor.setDataTTL(500);
-
- // files after ttl
- dataSource = storageGroupProcessor
- .query(sg1, s1, EnvironmentUtils.TEST_QUERY_CONTEXT, null, null);
- seqResource = dataSource.getSeqResources();
- unseqResource = dataSource.getUnseqResources();
- assertTrue(seqResource.size() < 4);
- assertEquals(0, unseqResource.size());
- Path path = new Path(sg1, s1);
- IBatchReader reader = new SeriesRawDataBatchReader(path, TSDataType.INT64,
- EnvironmentUtils.TEST_QUERY_CONTEXT, dataSource, null, null, null);
-
- int cnt = 0;
- while (reader.hasNextBatch()) {
- BatchData batchData = reader.nextBatch();
- while (batchData.hasCurrent()) {
- batchData.next();
- cnt++;
- }
- }
- reader.close();
- // we cannot offer the exact number since when exactly ttl will be checked is unknown
- assertTrue(cnt <= 1000);
-
- storageGroupProcessor.setDataTTL(0);
- dataSource = storageGroupProcessor.query(sg1, s1, EnvironmentUtils.TEST_QUERY_CONTEXT
- , null, null);
- seqResource = dataSource.getSeqResources();
- unseqResource = dataSource.getUnseqResources();
- assertEquals(0, seqResource.size());
- assertEquals(0, unseqResource.size());
-
- QueryResourceManager.getInstance().endQuery(EnvironmentUtils.TEST_QUERY_JOB_ID);
- }
-
- @Test
- public void testTTLRemoval() throws StorageEngineException, QueryProcessException {
- prepareData();
-
- storageGroupProcessor.waitForAllCurrentTsFileProcessorsClosed();
-
- // files before ttl
- File seqDir = new File(DirectoryManager.getInstance().getNextFolderForSequenceFile(), sg1);
- File unseqDir = new File(DirectoryManager.getInstance().getNextFolderForUnSequenceFile(), sg1);
-
- List<File> seqFiles = new ArrayList<>();
- for (File directory : seqDir.listFiles()) {
- if (directory.isDirectory()) {
- for (File file : directory.listFiles()) {
- if (file.getPath().endsWith(TsFileConstant.TSFILE_SUFFIX)) {
- seqFiles.add(file);
- }
- }
- }
- }
-
- List<File> unseqFiles = new ArrayList<>();
- for (File directory : unseqDir.listFiles()) {
- if (directory.isDirectory()) {
- for (File file : directory.listFiles()) {
- if (file.getPath().endsWith(TsFileConstant.TSFILE_SUFFIX)) {
- unseqFiles.add(file);
- }
- }
- }
- }
-
- assertEquals(4, seqFiles.size());
- assertEquals(4, unseqFiles.size());
-
- storageGroupProcessor.setDataTTL(500);
- storageGroupProcessor.checkFilesTTL();
-
- // files after ttl
- seqFiles = new ArrayList<>();
- for (File directory : seqDir.listFiles()) {
- if (directory.isDirectory()) {
- for (File file : directory.listFiles()) {
- if (file.getPath().endsWith(TsFileConstant.TSFILE_SUFFIX)) {
- seqFiles.add(file);
- }
- }
- }
- }
-
- unseqFiles = new ArrayList<>();
- for (File directory : unseqDir.listFiles()) {
- if (directory.isDirectory()) {
- for (File file : directory.listFiles()) {
- if (file.getPath().endsWith(TsFileConstant.TSFILE_SUFFIX)) {
- unseqFiles.add(file);
- }
- }
- }
- }
-
- assertTrue(seqFiles.size() <= 2);
- assertEquals(0, unseqFiles.size());
- }
-
- @Test
- public void testParseSetTTL() throws QueryProcessException {
- Planner planner = new Planner();
- SetTTLPlan plan = (SetTTLPlan) planner
- .parseSQLToPhysicalPlan("SET TTL TO " + sg1 + " 10000");
- assertEquals(sg1, plan.getStorageGroup());
- assertEquals(10000, plan.getDataTTL());
-
- plan = (SetTTLPlan) planner.parseSQLToPhysicalPlan("UNSET TTL TO " + sg2);
- assertEquals(sg2, plan.getStorageGroup());
- assertEquals(Long.MAX_VALUE, plan.getDataTTL());
- }
-
- @Test
- public void testParseShowTTL() throws QueryProcessException {
- Planner planner = new Planner();
- ShowTTLPlan plan = (ShowTTLPlan) planner.parseSQLToPhysicalPlan("SHOW ALL TTL");
- assertTrue(plan.getStorageGroups().isEmpty());
-
- List<String> sgs = new ArrayList<>();
- sgs.add("root.sg1");
- sgs.add("root.sg2");
- sgs.add("root.sg3");
- plan = (ShowTTLPlan) planner
- .parseSQLToPhysicalPlan("SHOW TTL ON root.sg1,root.sg2,root.sg3");
- assertEquals(sgs, plan.getStorageGroups());
- }
-
- @Test
- public void testShowTTL()
- throws IOException, QueryProcessException, QueryFilterOptimizationException,
- StorageEngineException, MetadataException {
- MManager.getInstance().setTTL(sg1, ttl);
-
- ShowTTLPlan plan = new ShowTTLPlan(Collections.emptyList());
- PlanExecutor executor = new PlanExecutor();
- QueryDataSet queryDataSet = executor.processQuery(plan, EnvironmentUtils.TEST_QUERY_CONTEXT);
- RowRecord rowRecord = queryDataSet.next();
- assertEquals(sg1, rowRecord.getFields().get(0).getStringValue());
- assertEquals(ttl, rowRecord.getFields().get(1).getLongV());
-
- rowRecord = queryDataSet.next();
- assertEquals(sg2, rowRecord.getFields().get(0).getStringValue());
- assertEquals("null", rowRecord.getFields().get(1).getStringValue());
- }
-
- @Test
- public void testTTLCleanFile() throws QueryProcessException {
- prepareData();
- storageGroupProcessor.waitForAllCurrentTsFileProcessorsClosed();
-
- assertEquals(4, storageGroupProcessor.getSequenceFileTreeSet().size());
- assertEquals(4, storageGroupProcessor.getUnSequenceFileList().size());
-
- storageGroupProcessor.setDataTTL(0);
- assertEquals(0, storageGroupProcessor.getSequenceFileTreeSet().size());
- assertEquals(0, storageGroupProcessor.getUnSequenceFileList().size());
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessorTest.java b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessorTest.java
deleted file mode 100644
index 1c926d9..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessorTest.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.engine.storagegroup;
-
-import static junit.framework.TestCase.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.apache.iotdb.db.conf.adapter.ActiveTimeSeriesCounter;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.apache.iotdb.db.engine.MetadataManagerHelper;
-import org.apache.iotdb.db.engine.fileSystem.SystemFileFactory;
-import org.apache.iotdb.db.engine.querycontext.ReadOnlyMemChunk;
-import org.apache.iotdb.db.engine.version.SysTimeVersionController;
-import org.apache.iotdb.db.exception.TsFileProcessorException;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.qp.physical.crud.InsertPlan;
-import org.apache.iotdb.db.query.context.QueryContext;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.db.utils.SchemaUtils;
-import org.apache.iotdb.tsfile.file.metadata.ChunkGroupMetaData;
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.read.reader.IPointReader;
-import org.apache.iotdb.tsfile.read.TimeValuePair;
-import org.apache.iotdb.tsfile.utils.Pair;
-import org.apache.iotdb.tsfile.write.record.TSRecord;
-import org.apache.iotdb.tsfile.write.record.datapoint.DataPoint;
-import org.apache.iotdb.tsfile.write.writer.RestorableTsFileIOWriter;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TsFileProcessorTest {
-
- private TsFileProcessor processor;
- private String storageGroup = "storage_group1";
- private String filePath = TestConstant.OUTPUT_DATA_DIR
- .concat("testUnsealedTsFileProcessor.tsfile");
- private String deviceId = "root.vehicle.d0";
- private String measurementId = "s0";
- private TSDataType dataType = TSDataType.INT32;
- private TSEncoding encoding = TSEncoding.RLE;
- private Map<String, String> props = Collections.emptyMap();
- private QueryContext context;
- private static Logger logger = LoggerFactory.getLogger(TsFileProcessorTest.class);
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- MetadataManagerHelper.initMetadata();
- ActiveTimeSeriesCounter.getInstance().init(storageGroup);
- context = EnvironmentUtils.TEST_QUERY_CONTEXT;
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- EnvironmentUtils.cleanDir(TestConstant.OUTPUT_DATA_DIR);
- }
-
- @Test
- public void testWriteAndFlush() throws IOException, QueryProcessException, MetadataException {
- logger.info("testWriteAndFlush begin..");
- processor = new TsFileProcessor(storageGroup, SystemFileFactory.INSTANCE.getFile(filePath),
- SchemaUtils.constructSchema(deviceId), SysTimeVersionController.INSTANCE, this::closeTsFileProcessor,
- (tsFileProcessor) -> true, true);
-
- Pair<List<ReadOnlyMemChunk>, List<ChunkMetaData>> pair = processor
- .query(deviceId, measurementId, dataType, encoding, props, context);
- List<ReadOnlyMemChunk> left = pair.left;
- List<ChunkMetaData> right = pair.right;
- assertTrue(left.isEmpty());
- assertEquals(0, right.size());
-
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, deviceId);
- record.addTuple(DataPoint.getDataPoint(dataType, measurementId, String.valueOf(i)));
- processor.insert(new InsertPlan(record));
- }
-
- // query data in memory
- pair = processor.query(deviceId, measurementId, dataType, encoding, props, context);
- left = pair.left;
- assertFalse(left.isEmpty());
- int num = 1;
- for (; num <= 100; num++) {
- for (ReadOnlyMemChunk chunk : left) {
- IPointReader iterator = chunk.getPointReader();
- iterator.hasNextTimeValuePair();
- TimeValuePair timeValuePair = iterator.nextTimeValuePair();
- assertEquals(num, timeValuePair.getTimestamp());
- assertEquals(num, timeValuePair.getValue().getInt());
- }
- }
-
- // flush synchronously
- processor.syncFlush();
-
- pair = processor.query(deviceId, measurementId, dataType, encoding, props, context);
- left = pair.left;
- right = pair.right;
- assertTrue(left.isEmpty());
- assertEquals(1, right.size());
- assertEquals(measurementId, right.get(0).getMeasurementUid());
- assertEquals(dataType, right.get(0).getDataType());
- processor.syncClose();
- }
-
- @Test
- public void testWriteAndRestoreMetadata()
- throws IOException, QueryProcessException, MetadataException {
- logger.info("testWriteAndRestoreMetadata begin..");
- processor = new TsFileProcessor(storageGroup, SystemFileFactory.INSTANCE.getFile(filePath),
- SchemaUtils.constructSchema(deviceId), SysTimeVersionController.INSTANCE, this::closeTsFileProcessor,
- (tsFileProcessor) -> true, true);
-
- Pair<List<ReadOnlyMemChunk>, List<ChunkMetaData>> pair = processor
- .query(deviceId, measurementId, dataType, encoding, props, context);
- List<ReadOnlyMemChunk> left = pair.left;
- List<ChunkMetaData> right = pair.right;
- assertTrue(left.isEmpty());
- assertEquals(0, right.size());
-
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, deviceId);
- record.addTuple(DataPoint.getDataPoint(dataType, measurementId, String.valueOf(i)));
- processor.insert(new InsertPlan(record));
- }
-
- // query data in memory
- pair = processor.query(deviceId, measurementId, dataType, encoding, props, context);
- left = pair.left;
- assertFalse(left.isEmpty());
- int num = 1;
-
- for (ReadOnlyMemChunk chunk : left) {
- IPointReader iterator = chunk.getPointReader();
- for (; num <= 100; num++) {
- iterator.hasNextTimeValuePair();
- TimeValuePair timeValuePair = iterator.nextTimeValuePair();
- assertEquals(num, timeValuePair.getTimestamp());
- assertEquals(num, timeValuePair.getValue().getInt());
- }
- }
- logger.info("syncFlush..");
- // flush synchronously
- processor.syncFlush();
-
- pair = processor.query(deviceId, measurementId, dataType, encoding, props, context);
- left = pair.left;
- right = pair.right;
- assertTrue(left.isEmpty());
- assertEquals(1, right.size());
- assertEquals(measurementId, right.get(0).getMeasurementUid());
- assertEquals(dataType, right.get(0).getDataType());
-
- RestorableTsFileIOWriter tsFileIOWriter = processor.getWriter();
- List<ChunkGroupMetaData> chunkGroupMetaDataList = tsFileIOWriter.getChunkGroupMetaDatas();
- RestorableTsFileIOWriter restorableTsFileIOWriter = new RestorableTsFileIOWriter(
- SystemFileFactory.INSTANCE.getFile(filePath));
- List<ChunkGroupMetaData> restoredChunkGroupMetaDataList = restorableTsFileIOWriter
- .getChunkGroupMetaDatas();
- assertEquals(chunkGroupMetaDataList.size(), restoredChunkGroupMetaDataList.size());
- for (int i = 0; i < chunkGroupMetaDataList.size(); i++) {
- ChunkGroupMetaData chunkGroupMetaData = chunkGroupMetaDataList.get(i);
- ChunkGroupMetaData chunkGroupMetaDataRestore = restoredChunkGroupMetaDataList.get(i);
- for (int j = 0; j < chunkGroupMetaData.getChunkMetaDataList().size(); j++) {
- ChunkMetaData chunkMetaData = chunkGroupMetaData.getChunkMetaDataList().get(j);
- ChunkMetaData chunkMetaDataRestore = chunkGroupMetaDataRestore.getChunkMetaDataList()
- .get(j);
- assertEquals(chunkMetaData, chunkMetaDataRestore);
- }
- }
- restorableTsFileIOWriter.close();
- logger.info("syncClose..");
- processor.syncClose();
- //we need to close the tsfile writer first and then reopen it.
- }
-
-
- @Test
- public void testMultiFlush() throws IOException, QueryProcessException, MetadataException {
- logger.info("testWriteAndRestoreMetadata begin..");
- processor = new TsFileProcessor(storageGroup, SystemFileFactory.INSTANCE.getFile(filePath),
- SchemaUtils.constructSchema(deviceId), SysTimeVersionController.INSTANCE, this::closeTsFileProcessor,
- (tsFileProcessor) -> true, true);
-
- Pair<List<ReadOnlyMemChunk>, List<ChunkMetaData>> pair = processor
- .query(deviceId, measurementId, dataType, encoding, props, context);
- List<ReadOnlyMemChunk> left = pair.left;
- List<ChunkMetaData> right = pair.right;
- assertTrue(left.isEmpty());
- assertEquals(0, right.size());
-
- for (int flushId = 0; flushId < 10; flushId++) {
- for (int i = 1; i <= 10; i++) {
- TSRecord record = new TSRecord(i, deviceId);
- record.addTuple(DataPoint.getDataPoint(dataType, measurementId, String.valueOf(i)));
- processor.insert(new InsertPlan(record));
- }
- processor.asyncFlush();
- }
- processor.syncFlush();
-
- pair = processor.query(deviceId, measurementId, dataType, encoding, props, context);
- left = pair.left;
- right = pair.right;
- assertTrue(left.isEmpty());
- assertEquals(10, right.size());
- assertEquals(measurementId, right.get(0).getMeasurementUid());
- assertEquals(dataType, right.get(0).getDataType());
- processor.syncClose();
- }
-
-
- @Test
- public void testWriteAndClose() throws IOException, QueryProcessException, MetadataException {
- logger.info("testWriteAndRestoreMetadata begin..");
- processor = new TsFileProcessor(storageGroup, SystemFileFactory.INSTANCE.getFile(filePath),
- SchemaUtils.constructSchema(deviceId), SysTimeVersionController.INSTANCE,
- this::closeTsFileProcessor, (tsFileProcessor) -> true, true);
-
- Pair<List<ReadOnlyMemChunk>, List<ChunkMetaData>> pair = processor
- .query(deviceId, measurementId, dataType, encoding, props, context);
- List<ReadOnlyMemChunk> left = pair.left;
- List<ChunkMetaData> right = pair.right;
- assertTrue(left.isEmpty());
- assertEquals(0, right.size());
-
- for (int i = 1; i <= 100; i++) {
- TSRecord record = new TSRecord(i, deviceId);
- record.addTuple(DataPoint.getDataPoint(dataType, measurementId, String.valueOf(i)));
- processor.insert(new InsertPlan(record));
- }
-
- // query data in memory
- pair = processor.query(deviceId, measurementId, dataType, encoding, props, context);
- left = pair.left;
- assertFalse(left.isEmpty());
- int num = 1;
-
- for (; num <= 100; num++) {
- for (ReadOnlyMemChunk chunk : left) {
- IPointReader iterator = chunk.getPointReader();
- iterator.hasNextTimeValuePair();
- TimeValuePair timeValuePair = iterator.nextTimeValuePair();
- assertEquals(num, timeValuePair.getTimestamp());
- assertEquals(num, timeValuePair.getValue().getInt());
- }
- }
-
- // close synchronously
- processor.syncClose();
-
- assertTrue(processor.getTsFileResource().isClosed());
-
- }
- private void closeTsFileProcessor(TsFileProcessor unsealedTsFileProcessor) throws TsFileProcessorException {
- TsFileResource resource = unsealedTsFileProcessor.getTsFileResource();
- synchronized (resource) {
- for (Entry<String, Long> startTime : resource.getStartTimeMap().entrySet()) {
- String deviceId = startTime.getKey();
- resource.getEndTimeMap().put(deviceId, resource.getStartTimeMap().get(deviceId));
- }
- try {
- resource.close();
- } catch (IOException e) {
- throw new TsFileProcessorException(e);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/version/SimpleFileVersionControllerTest.java b/server/src/test/java/org/apache/iotdb/db/engine/version/SimpleFileVersionControllerTest.java
deleted file mode 100644
index a514ae9..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/version/SimpleFileVersionControllerTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.version;
-
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.db.constant.TestConstant;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class SimpleFileVersionControllerTest {
- @Test
- public void test() throws IOException {
- String tempFilePath = TestConstant.BASE_OUTPUT_PATH.concat("version.tmp");
-
- try {
- if (!new File(tempFilePath).mkdir()) {
- Assert.fail("can not create version.tmp folder");
- }
- VersionController versionController = new SimpleFileVersionController(tempFilePath, 1);
- assertEquals(SimpleFileVersionController.getSaveInterval(), versionController.currVersion());
- for (int i = 0; i < 150; i++) {
- versionController.nextVersion();
- }
- assertEquals(SimpleFileVersionController.getSaveInterval() + 150,
- versionController.currVersion());
- versionController = new SimpleFileVersionController(tempFilePath, 1);
- assertEquals(SimpleFileVersionController.getSaveInterval() + 200,
- versionController.currVersion());
- } finally {
- FileUtils.deleteDirectory(new File(tempFilePath));
- }
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java b/server/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java
deleted file mode 100644
index e9629af..0000000
--- a/server/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.version;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-public class SysTimeVersionControllerTest {
-
- @Test
- public void test() {
- VersionController versionController = SysTimeVersionController.INSTANCE;
- long diff = versionController.currVersion() - System.currentTimeMillis();
- // to aovid the test failure on a poor machine, we bear 200ms difference here.
- assertTrue(diff >= -200 && diff <= 200);
- diff = versionController.nextVersion();
- try {
- Thread.sleep(200);
- diff -= System.currentTimeMillis();
- assertTrue(diff >= -1000 && diff <= -200);
- } catch (InterruptedException e) {
- //do nothing
- }
- }
-}
\ No newline at end of file
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IOTDBGroupByIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IOTDBGroupByIT.java
deleted file mode 100644
index 586174a..0000000
--- a/server/src/test/java/org/apache/iotdb/db/integration/IOTDBGroupByIT.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.integration;
-
-import static org.apache.iotdb.db.integration.TestConstant.avg;
-import static org.apache.iotdb.db.integration.TestConstant.count;
-import static org.apache.iotdb.db.integration.TestConstant.first_value;
-import static org.apache.iotdb.db.integration.TestConstant.last_value;
-import static org.apache.iotdb.db.integration.TestConstant.max_time;
-import static org.apache.iotdb.db.integration.TestConstant.max_value;
-import static org.apache.iotdb.db.integration.TestConstant.min_time;
-import static org.apache.iotdb.db.integration.TestConstant.min_value;
-import static org.apache.iotdb.db.integration.TestConstant.sum;
-import static org.junit.Assert.fail;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.jdbc.Config;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IOTDBGroupByIT {
-
-
- private static String[] dataSet1 = new String[]{
- "SET STORAGE GROUP TO root.ln.wf01.wt01",
- "CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
- "CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=DOUBLE, ENCODING=PLAIN",
- "CREATE TIMESERIES root.ln.wf01.wt01.hardware WITH DATATYPE=INT32, ENCODING=PLAIN",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(1, 1.1, false, 11)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(2, 2.2, true, 22)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(3, 3.3, false, 33 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(4, 4.4, false, 44)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(5, 5.5, false, 55)",
- "flush",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(100, 100.1, false, 110)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(150, 200.2, true, 220)",
- "flush",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(200, 300.3, false, 330 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(250, 400.4, false, 440)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(300, 500.5, false, 550)",
- "flush",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(10, 10.1, false, 110)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(20, 20.2, true, 220)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(30, 30.3, false, 330 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(40, 40.4, false, 440)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(50, 50.5, false, 550)",
- "flush",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(500, 100.1, false, 110)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(510, 200.2, true, 220)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(520, 300.3, false, 330 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(530, 400.4, false, 440)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(540, 500.5, false, 550)",
- "flush",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(580, 100.1, false, 110)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(590, 200.2, true, 220)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(600, 300.3, false, 330 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(610, 400.4, false, 440)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(620, 500.5, false, 550)",
- };
-
- private static final String TIMESTAMP_STR = "Time";
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.closeStatMonitor();
- EnvironmentUtils.envSetUp();
- IoTDBDescriptor.getInstance().getConfig().setPartitionInterval(1000);
- Class.forName(Config.JDBC_DRIVER_NAME);
- prepareData();
- }
-
- @After
- public void tearDown() throws Exception {
- IoTDBDescriptor.getInstance().getConfig().setPartitionInterval(86400);
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void countSumAvgTest() throws SQLException {
- String[] retArray1 = new String[]{
- "5,3,35.8,11.933333333333332",
- "25,2,70.7,35.35",
- "45,1,50.5,50.5",
- "65,0,0.0,null",
- "85,1,100.1,100.1",
- "105,0,0.0,null",
- "125,0,0.0,null",
- "145,1,200.2,200.2"
- };
- String[] retArray2 = new String[]{
- "50,1,50.5,50.5",
- "60,0,0.0,null",
- "70,0,0.0,null",
- "80,0,0.0,null",
- "90,0,0.0,null",
- "100,1,100.1,100.1",
- "110,0,0.0,null",
- "120,0,0.0,null",
- "130,0,0.0,null",
- "140,0,0.0,null",
- "150,1,200.2,200.2"
- };
- String[] retArray3 = new String[]{
- "25,2,70.7,35.35",
- "45,1,50.5,50.5",
- "65,0,0.0,null",
- "85,1,100.1,100.1",
- "105,0,0.0,null",
- "125,0,0.0,null",
- "145,1,200.2,200.2",
- "165,0,0.0,null",
- "185,1,300.3,300.3",
- "205,0,0.0,null",
- "225,0,0.0,null",
- "245,1,400.4,400.4",
- "265,0,0.0,null",
- "285,1,500.5,500.5",
- "305,0,0.0,null"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 where time > 3 "
- + "GROUP BY ([5, 160), 20ms)");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(count("root.ln.wf01.wt01.temperature")) + "," +
- resultSet.getString(sum("root.ln.wf01.wt01.temperature")) + "," + resultSet
- .getString(avg("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray1[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(retArray1.length, cnt);
- }
-
- hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 where temperature > 3 "
- + "GROUP BY ([50, 160), 10ms)");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(count("root.ln.wf01.wt01.temperature")) + "," +
- resultSet.getString(sum("root.ln.wf01.wt01.temperature")) + "," + resultSet
- .getString(avg("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray2[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(retArray2.length, cnt);
- }
-
- hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 where temperature > 3 "
- + "GROUP BY ([25, 314), 20ms)");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(count("root.ln.wf01.wt01.temperature")) + "," +
- resultSet.getString(sum("root.ln.wf01.wt01.temperature")) + "," + resultSet
- .getString(avg("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray3[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(retArray3.length, cnt);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void maxMinValeTimeTest() throws SQLException {
- String[] retArray1 = new String[]{
- "2,null,null,null,null",
- "4,5.5,4.4,5,4",
- "6,null,null,null,null",
- "8,null,null,null,null",
- "10,10.1,10.1,10,10",
- "12,null,null,null,null",
- "14,null,null,null,null",
- "16,null,null,null,null",
- "18,null,null,null,null",
- "20,20.2,20.2,20,20",
- "22,null,null,null,null",
- "24,null,null,null,null",
- "26,null,null,null,null",
- "28,null,null,null,null"
- };
- String[] retArray2 = new String[]{
- "2,20.2,3.3,20,3",
- "22,40.4,30.3,40,30",
- "42,50.5,50.5,50,50",
- "62,null,null,null,null",
- "82,100.1,100.1,100,100",
- "102,null,null,null,null",
- "122,null,null,null,null",
- "142,200.2,200.2,150,150",
- "162,null,null,null,null",
- "182,300.3,300.3,200,200",
- "202,null,null,null,null",
- "222,null,null,null,null",
- "242,400.4,400.4,250,250",
- "262,null,null,null,null",
- "282,null,null,null,null",
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute(
- "select max_value(temperature), min_value(temperature), max_time(temperature), "
- + "min_time(temperature) from root.ln.wf01.wt01 where time > 3 "
- + "GROUP BY ([2,30), 2ms)");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(max_value("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(min_value("root.ln.wf01.wt01.temperature")) + ","
- + resultSet.getString(max_time("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(min_time("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray1[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(retArray1.length, cnt);
- }
-
- hasResultSet = statement.execute(
- "select max_value(temperature), min_value(temperature), max_time(temperature), "
- + "min_time(temperature) from root.ln.wf01.wt01 where temperature > 3 "
- + "GROUP BY ([2,300), 20ms)");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(max_value("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(min_value("root.ln.wf01.wt01.temperature")) + ","
- + resultSet.getString(max_time("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(min_time("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray2[cnt], ans);
- cnt++;
- }
- }
- Assert.assertEquals(retArray2.length, cnt);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void firstLastTest() throws SQLException {
- String[] retArray1 = new String[]{
- "2,5.5,4.4",
- "6,null,null",
- "10,10.1,10.1",
- "14,null,null",
- "18,20.2,20.2",
- "22,null,null",
- "26,null,null"
- };
- String[] retArray2 = new String[]{
- "2,20.2,3.3",
- "22,40.4,30.3",
- "42,50.5,50.5",
- "62,null,null",
- "82,100.1,100.1",
- "102,null,null",
- "122,null,null",
- "142,200.2,200.2",
- "162,null,null",
- "182,300.3,300.3",
- "202,null,null",
- "222,null,null",
- "242,400.4,400.4",
- "262,null,null",
- "282,null,null"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select last_value(temperature), first_value(temperature) from root.ln.wf01.wt01 where time > 3 "
- + "GROUP BY ([2,30), 4ms)");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(last_value("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(first_value("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray1[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(retArray1.length, cnt);
- }
-
- hasResultSet = statement.execute(
- "select first_value(temperature), last_value(temperature) from root.ln.wf01.wt01 "
- + "where temperature > 3 "
- + "GROUP BY ([2,300), 20ms)");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(last_value("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(first_value("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray2[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(retArray2.length, cnt);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void largeIntervalTest() throws SQLException {
- String[] retArray1 = new String[]{
- "0,4.4,12,300,4",
- "340,100.1,10,620,500"
- };
- String[] retArray2 = new String[]{
- "0,3.3,13,300,3",
- "340,100.1,10,620,500"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select min_value(temperature), count(temperature), max_time(temperature), "
- + "min_time(temperature) from root.ln.wf01.wt01 where time > 3 GROUP BY "
- + "([0, 680), 340ms)");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(min_value("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(count("root.ln.wf01.wt01.temperature")) + "," +
- resultSet.getString(max_time("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(min_time("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray1[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(retArray1.length, cnt);
- }
-
- hasResultSet = statement.execute(
- "select min_value(temperature), count (temperature), max_time(temperature), "
- + "min_time(temperature) from root.ln.wf01.wt01 where temperature > 3 GROUP BY "
- + "([0, 680), 340ms)");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(min_value("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(count("root.ln.wf01.wt01.temperature")) + ","
- + resultSet.getString(max_time("root.ln.wf01.wt01.temperature"))
- + "," + resultSet.getString(min_time("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray2[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(retArray2.length, cnt);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void countSumAvgInnerIntervalTest() {
- String[] retArray1 = new String[]{
- "0,2,7.7,3.85",
- "30,1,30.3,30.3",
- "60,0,0.0,null",
- "90,0,0.0,null",
- "120,0,0.0,null",
- "150,1,200.2,200.2",
- "180,0,0.0,null",
- "210,0,0.0,null",
- "240,0,0.0,null",
- "270,0,0.0,null",
- "300,1,500.5,500.5",
- "330,0,0.0,null",
- "360,0,0.0,null",
- "390,0,0.0,null",
- "420,0,0.0,null",
- "450,0,0.0,null",
- "480,0,0.0,null",
- "510,1,200.2,200.2",
- "540,1,500.5,500.5",
- "570,0,0.0,null"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 where temperature > 3 "
- + "GROUP BY ([0, 600), 5ms, 30ms)");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(count("root.ln.wf01.wt01.temperature")) + "," +
- resultSet.getString(sum("root.ln.wf01.wt01.temperature")) + "," + resultSet
- .getString(avg("root.ln.wf01.wt01.temperature"));
- Assert.assertEquals(retArray1[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(retArray1.length, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void prepareData() {
- try (Connection connection = DriverManager
- .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
- "root");
- Statement statement = connection.createStatement();) {
-
- for (String sql : dataSet1) {
- statement.execute(sql);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IOTDBGroupByInnerIntervalIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IOTDBGroupByInnerIntervalIT.java
deleted file mode 100644
index 6060caf1..0000000
--- a/server/src/test/java/org/apache/iotdb/db/integration/IOTDBGroupByInnerIntervalIT.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.integration;
-
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.jdbc.IoTDBSQLException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.sql.*;
-
-import static org.apache.iotdb.db.integration.TestConstant.*;
-import static org.junit.Assert.*;
-
-public class IOTDBGroupByInnerIntervalIT {
-
- private static String[] dataSet1 = new String[]{
- "SET STORAGE GROUP TO root.ln.wf01.wt01",
- "CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
- "CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=DOUBLE, ENCODING=PLAIN",
- "CREATE TIMESERIES root.ln.wf01.wt01.hardware WITH DATATYPE=INT32, ENCODING=PLAIN",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(1, 1.1, false, 11)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(2, 2.2, true, 22)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(3, 3.3, false, 33 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(4, 4.4, false, 44)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(5, 5.5, false, 55)",
- "flush",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(6, 6.6, false, 66)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(7, 7.7, true, 77)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(8, 8.8, false, 88)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(9, 9.9, false, 99)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(10, 10.0, false, 110)",
- "flush",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(11, 11.1, false, 121)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(12, 12.2, true, 220)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(13, 13.3, false, 330)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(14, 14.4, false, 440)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(15, 15.5, false, 550)",
- "flush",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(16, 16.6, false, 660)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(18, 18.8, true, 780)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(22, 22.2, false, 220 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(23, 23.3, false, 650)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(24, 24.4, false, 760)",
- "flush",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(25, 25.5, false, 550)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(26, 20.2, true, 220)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(27, 30.3, false, 330 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(28, 40.4, false, 440)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(29, 50.5, false, 550)",
- };
-
- private static final String TIMESTAMP_STR = "Time";
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.closeStatMonitor();
- EnvironmentUtils.envSetUp();
- Class.forName(Config.JDBC_DRIVER_NAME);
- prepareData();
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void countSumAvgInnerIntervalTest() {
- String[] retArray1 = new String[]{
- "1,3,6.6,2.2",
- "6,3,23.1,7.7",
- "11,3,36.599999999999994,12.2",
- "16,2,35.400000000000006,17.700000000000003",
- "21,2,45.5,22.75",
- "26,3,90.9,30.299999999999997"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 "
- + "GROUP BY ([1, 30), 3ms, 5ms)");
-
- assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(count("root.ln.wf01.wt01.temperature")) + "," +
- resultSet.getString(sum("root.ln.wf01.wt01.temperature")) + "," + resultSet
- .getString(avg("root.ln.wf01.wt01.temperature"));
- assertEquals(retArray1[cnt], ans);
- cnt++;
- }
- assertEquals(retArray1.length, cnt);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void countSumAvgInnerIntervalTestWithValueFilter() {
- String[] retArray1 = new String[]{
- "1,1,3.3,3.3",
- "6,3,23.1,7.7",
- "11,3,36.599999999999994,12.2",
- "16,2,35.400000000000006,17.700000000000003",
- "21,2,45.5,22.75",
- "26,3,90.9,30.299999999999997"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 where temperature > 3"
- + " GROUP BY ([1, 30), 3ms, 5ms)");
-
- assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(count("root.ln.wf01.wt01.temperature")) + "," +
- resultSet.getString(sum("root.ln.wf01.wt01.temperature")) + "," + resultSet
- .getString(avg("root.ln.wf01.wt01.temperature"));
- assertEquals(retArray1[cnt], ans);
- cnt++;
- }
- assertEquals(retArray1.length, cnt);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void countSumAvgInnerIntervalTestWithTimeFilter() {
- String[] retArray1 = new String[]{
- "1,0,0.0,null",
- "6,3,23.1,7.7",
- "11,3,36.599999999999994,12.2",
- "16,2,35.400000000000006,17.700000000000003",
- "21,2,45.5,22.75",
- "26,3,90.9,30.299999999999997"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 where time > 3"
- + " GROUP BY ([1, 30), 3ms, 5ms)");
-
- assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
- .getString(count("root.ln.wf01.wt01.temperature")) + "," +
- resultSet.getString(sum("root.ln.wf01.wt01.temperature")) + "," + resultSet
- .getString(avg("root.ln.wf01.wt01.temperature"));
- assertEquals(retArray1[cnt], ans);
- cnt++;
- }
- assertEquals(retArray1.length, cnt);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void negativeOrZeroTimeInterval() {
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 where time > 3"
- + "GROUP BY ([1, 30), 0ms)");
- fail();
- } catch (Exception e) {
- assertTrue(e instanceof IoTDBSQLException);
- }
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 where time > 3"
- + "GROUP BY ([1, 30), -1ms)");
- fail();
- } catch (Exception e) {
- assertTrue(e instanceof SQLException);
- }
- }
-
- @Test
- public void slidingStepLessThanTimeInterval() {
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select count(temperature), sum(temperature), avg(temperature) from "
- + "root.ln.wf01.wt01 where time > 3"
- + "GROUP BY ([1, 30), 2ms, 1ms)");
- fail();
- } catch (Exception e) {
- assertTrue(e instanceof IoTDBSQLException);
- }
- }
-
- private void prepareData() {
- try (Connection connection = DriverManager
- .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
- "root");
- Statement statement = connection.createStatement();) {
-
- for (String sql : dataSet1) {
- statement.execute(sql);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java
deleted file mode 100644
index c270267..0000000
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationIT.java
+++ /dev/null
@@ -1,649 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.integration;
-
-import static org.apache.iotdb.db.integration.TestConstant.avg;
-import static org.apache.iotdb.db.integration.TestConstant.count;
-import static org.apache.iotdb.db.integration.TestConstant.first_value;
-import static org.apache.iotdb.db.integration.TestConstant.last_value;
-import static org.apache.iotdb.db.integration.TestConstant.max_time;
-import static org.apache.iotdb.db.integration.TestConstant.max_value;
-import static org.apache.iotdb.db.integration.TestConstant.min_time;
-import static org.apache.iotdb.db.integration.TestConstant.min_value;
-import static org.apache.iotdb.db.integration.TestConstant.sum;
-import static org.junit.Assert.fail;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Locale;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.jdbc.Config;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IoTDBAggregationIT {
-
- private static final String TIMESTAMP_STR = "Time";
- private static final String TEMPERATURE_STR = "root.ln.wf01.wt01.temperature";
-
- private static String[] creationSqls = new String[]{
- "SET STORAGE GROUP TO root.vehicle.d0",
- "SET STORAGE GROUP TO root.vehicle.d1",
-
- "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s1 WITH DATATYPE=INT64, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s2 WITH DATATYPE=FLOAT, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s3 WITH DATATYPE=TEXT, ENCODING=PLAIN",
- "CREATE TIMESERIES root.vehicle.d0.s4 WITH DATATYPE=BOOLEAN, ENCODING=PLAIN"
- };
- private static String[] dataSet2 = new String[]{
- "SET STORAGE GROUP TO root.ln.wf01.wt01",
- "CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
- "CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=PLAIN",
- "CREATE TIMESERIES root.ln.wf01.wt01.hardware WITH DATATYPE=INT32, ENCODING=PLAIN",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(1, 1.1, false, 11)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(2, 2.2, true, 22)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(3, 3.3, false, 33 )",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(4, 4.4, false, 44)",
- "INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
- + "values(5, 5.5, false, 55)"
- };
- private final String d0s0 = "root.vehicle.d0.s0";
- private final String d0s1 = "root.vehicle.d0.s1";
- private final String d0s2 = "root.vehicle.d0.s2";
- private final String d0s3 = "root.vehicle.d0.s3";
- private String insertTemplate = "INSERT INTO root.vehicle.d0(timestamp,s0,s1,s2,s3,s4)"
- + " VALUES(%d,%d,%d,%f,%s,%s)";
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.closeStatMonitor();
- EnvironmentUtils.envSetUp();
- IoTDBDescriptor.getInstance().getConfig().setPartitionInterval(1000);
- Class.forName(Config.JDBC_DRIVER_NAME);
- prepareData();
- }
-
- @After
- public void tearDown() throws Exception {
- IoTDBDescriptor.getInstance().getConfig().setPartitionInterval(86400);
- EnvironmentUtils.cleanEnv();
- }
-
- //add test for part of points in page don't satisfy filter
- //details in: https://issues.apache.org/jira/projects/IOTDB/issues/IOTDB-54
- @Test
- public void test() throws SQLException {
- String[] retArray = new String[]{
- "0,2",
- "0,4",
- "0,3"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute(
- "SELECT count(temperature) FROM root.ln.wf01.wt01 WHERE time > 3");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet();) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," +
- resultSet.getString(count(TEMPERATURE_STR));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
-
- hasResultSet = statement.execute(
- "SELECT min_time(temperature) FROM root.ln.wf01.wt01 WHERE time > 3");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," +
- resultSet.getString(min_time(TEMPERATURE_STR));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(2, cnt);
- }
-
- hasResultSet = statement.execute(
- "SELECT min_time(temperature) FROM root.ln.wf01.wt01 WHERE temperature > 3");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," +
- resultSet.getString(min_time(TEMPERATURE_STR));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(3, cnt);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void countTest() throws SQLException {
- String[] retArray = new String[]{
- "0,2001,2001,2001,2001",
- "0,7500,7500,7500,7500"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute("SELECT count(s0),count(s1),count(s2),count(s3) " +
- "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet();) {
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(count(d0s0))
- + "," + resultSet.getString(count(d0s1)) + "," + resultSet.getString(count(d0s2))
- + "," + resultSet.getString(count(d0s3));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
-
- hasResultSet = statement.execute("SELECT count(s0),count(s1),count(s2),count(s3) " +
- "FROM root.vehicle.d0");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(count(d0s0))
- + "," + resultSet.getString(count(d0s1)) + "," + resultSet.getString(count(d0s2))
- + "," + resultSet.getString(count(d0s3));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(2, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void firstTest() {
- String[] retArray = new String[]{
- "0,2000,2000,2000.0,2000",
- "0,500,500,500.0,500"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement
- .execute("SELECT first_value(s0),first_value(s1),first_value(s2),first_value(s3) " +
- "FROM root.vehicle.d0 WHERE time >= 1500 AND time <= 9000");
-
- Assert.assertTrue(hasResultSet);
-
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(first_value(d0s0))
- + "," + resultSet.getString(first_value(d0s1)) + "," + resultSet
- .getString(first_value(d0s2))
- + "," + resultSet.getString(first_value(d0s3));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
-
- hasResultSet = statement
- .execute("SELECT first_value(s0),first_value(s1),first_value(s2),first_value(s3) " +
- "FROM root.vehicle.d0");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(first_value(d0s0))
- + "," + resultSet.getString(first_value(d0s1)) + "," + resultSet
- .getString(first_value(d0s2))
- + "," + resultSet.getString(first_value(d0s3));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(2, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void lastTest() throws SQLException {
- String[] retArray = new String[]{
- "0,8499,8499.0",
- "0,1499,1499.0",
- "0,2200,2200.0"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("SELECT last_value(s0),last_value(s2) " +
- "FROM root.vehicle.d0 WHERE time >= 1500 AND time < 9000");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(last_value(d0s0))
- + "," + resultSet.getString(last_value(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
-
- hasResultSet = statement.execute("SELECT last_value(s0),last_value(s2) " +
- "FROM root.vehicle.d0 WHERE time <= 1600");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(last_value(d0s0))
- + "," + resultSet.getString(last_value(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(2, cnt);
- }
-
- hasResultSet = statement.execute("SELECT last_value(s0),last_value(s2) " +
- "FROM root.vehicle.d0 WHERE time <= 2200");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(last_value(d0s0))
- + "," + resultSet.getString(last_value(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(3, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void maxminTimeTest() throws SQLException {
- String[] retArray = new String[]{
- "0,8499,500",
- "0,2499,2000"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("SELECT max_time(s0),min_time(s2) " +
- "FROM root.vehicle.d0 WHERE time >= 100 AND time < 9000");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(max_time(d0s0))
- + "," + resultSet.getString(min_time(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
-
- hasResultSet = statement.execute("SELECT max_time(s0),min_time(s2) " +
- "FROM root.vehicle.d0 WHERE time <= 2500 AND time > 1800");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(max_time(d0s0))
- + "," + resultSet.getString(min_time(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(2, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void maxminValueTest() throws SQLException {
- String[] retArray = new String[]{
- "0,8499,500.0",
- "0,2499,500.0"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("SELECT max_value(s0),min_value(s2) " +
- "FROM root.vehicle.d0 WHERE time >= 100 AND time < 9000");
-
- Assert.assertTrue(hasResultSet);
- int cnt;
- try (ResultSet resultSet = statement.getResultSet()) {
- cnt = 0;
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(max_value(d0s0))
- + "," + resultSet.getString(min_value(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
-
- hasResultSet = statement.execute("SELECT max_value(s0),min_value(s2) " +
- "FROM root.vehicle.d0 WHERE time < 2500");
-
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(max_value(d0s0))
- + "," + resultSet.getString(min_value(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(2, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void avgSumTest() {
- String[] retArray = new String[]{
- "0,1.4508E7,7250.374812593702",
- "0,626750.0,1250.9980039920158"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("SELECT sum(s0),avg(s2)" +
- "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000");
-
- Assert.assertTrue(hasResultSet);
- int cnt = 0;
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(sum(d0s0))
- + "," + resultSet.getString(avg(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
-
- hasResultSet = statement.execute("SELECT sum(s0),avg(s2)" +
- "FROM root.vehicle.d0 WHERE time >= 1000 AND time <= 2000");
- Assert.assertTrue(hasResultSet);
-
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(sum(d0s0))
- + "," + resultSet.getString(avg(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(2, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
-
- fail(e.getMessage());
- }
- }
-
- @Test
- public void avgSumErrorTest() throws SQLException {
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- try {
- statement.execute("SELECT avg(s3)" +
- "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000");
- ResultSet resultSet = statement.getResultSet();
- resultSet.next();
- fail();
- } catch (Exception e) {
- Assert.assertEquals("500: Unsupported data type in aggregation AVG : TEXT", e.getMessage());
- }
- try {
- statement.execute("SELECT sum(s3)" +
- "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000");
- ResultSet resultSet = statement.getResultSet();
- resultSet.next();
- fail();
- } catch (Exception e) {
- Assert.assertEquals("500: Unsupported data type in aggregation SUM : TEXT", e.getMessage());
- }
- try {
- statement.execute("SELECT avg(s4)" +
- "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000");
- ResultSet resultSet = statement.getResultSet();
- resultSet.next();
- fail();
- } catch (Exception e) {
- Assert.assertEquals("500: Unsupported data type in aggregation AVG : BOOLEAN", e.getMessage());
- }
- try {
- statement.execute("SELECT sum(s4)" +
- "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000");
- ResultSet resultSet = statement.getResultSet();
- resultSet.next();
- fail();
- } catch (Exception e) {
- Assert.assertEquals("500: Unsupported data type in aggregation SUM : BOOLEAN", e.getMessage());
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- /**
- * test aggregation query with more than one functions on one series
- */
- @Test
- public void mergeAggrOnOneSeriesTest() {
- String[] retArray = new String[]{
- "0,1.4508E7,7250.374812593702,7250.374812593702,1.4508E7",
- "0,626750.0,1250.9980039920158,1250.9980039920158,626750.0",
- "0,1.4508E7,2001,7250.374812593702,7250.374812593702",
- "0,1.4508E7,2001,7250.374812593702,7250.374812593702,2001,1.4508E7"
-
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("SELECT sum(s0), avg(s2), avg(s0), sum(s2)" +
- "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000");
-
- Assert.assertTrue(hasResultSet);
- int cnt = 0;
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(sum(d0s0))
- + "," + resultSet.getString(avg(d0s2)) + "," + resultSet.getString(avg(d0s0))
- + "," + resultSet.getString(sum(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
-
- hasResultSet = statement.execute("SELECT sum(s0), avg(s2), avg(s0), sum(s2)" +
- "FROM root.vehicle.d0 WHERE time >= 1000 AND time <= 2000");
- Assert.assertTrue(hasResultSet);
-
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(sum(d0s0))
- + "," + resultSet.getString(avg(d0s2)) + "," + resultSet.getString(avg(d0s0))
- + "," + resultSet.getString(sum(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(2, cnt);
- }
-
- hasResultSet = statement.execute("SELECT sum(s0), count(s0), avg(s2), avg(s0)" +
- "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000");
- Assert.assertTrue(hasResultSet);
-
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(sum(d0s0))
- + "," + resultSet.getString(count(d0s0)) + "," + resultSet.getString(avg(d0s2))
- + "," + resultSet.getString(avg(d0s0));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(3, cnt);
- }
-
- hasResultSet = statement
- .execute("SELECT sum(s2), count(s0), avg(s2), avg(s1), count(s2),sum(s0)" +
- "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000");
- Assert.assertTrue(hasResultSet);
-
- try (ResultSet resultSet = statement.getResultSet()) {
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(sum(d0s2))
- + "," + resultSet.getString(count(d0s0)) + "," + resultSet.getString(avg(d0s2))
- + "," + resultSet.getString(avg(d0s1)) + "," + resultSet.getString(count(d0s2))
- + "," + resultSet.getString(sum(d0s0));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(4, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
-
- private void prepareData() throws SQLException {
- try (Connection connection = DriverManager
- .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
- "root");
- Statement statement = connection.createStatement()) {
-
- for (String sql : creationSqls) {
- statement.execute(sql);
- }
-
- for (String sql : dataSet2) {
- statement.execute(sql);
- }
-
- // prepare BufferWrite file
- for (int i = 5000; i < 7000; i++) {
- statement.execute(String
- .format(Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "\'" + i + "\'", "true"));
- }
- statement.execute("FLUSH");
- for (int i = 7500; i < 8500; i++) {
- statement.execute(String
- .format(Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "\'" + i + "\'", "false"));
- }
- statement.execute("FLUSH");
- // prepare Unseq-File
- for (int i = 500; i < 1500; i++) {
- statement.execute(String
- .format(Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "\'" + i + "\'", "true"));
- }
- statement.execute("FLUSH");
- for (int i = 3000; i < 6500; i++) {
- statement.execute(String
- .format(Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "\'" + i + "\'", "false"));
- }
- statement.execute("merge");
-
- // prepare BufferWrite cache
- for (int i = 9000; i < 10000; i++) {
- statement.execute(String
- .format(Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "\'" + i + "\'", "true"));
- }
- // prepare Overflow cache
- for (int i = 2000; i < 2500; i++) {
- statement.execute(String
- .format(Locale.ENGLISH, insertTemplate, i, i, i, (double) i, "\'" + i + "\'", "false"));
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationLargeDataIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationLargeDataIT.java
deleted file mode 100644
index db7d868..0000000
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationLargeDataIT.java
+++ /dev/null
@@ -1,785 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.integration;
-
-import static org.apache.iotdb.db.integration.TestConstant.avg;
-import static org.apache.iotdb.db.integration.TestConstant.count;
-import static org.apache.iotdb.db.integration.TestConstant.first_value;
-import static org.apache.iotdb.db.integration.TestConstant.last_value;
-import static org.apache.iotdb.db.integration.TestConstant.max_time;
-import static org.apache.iotdb.db.integration.TestConstant.max_value;
-import static org.apache.iotdb.db.integration.TestConstant.min_time;
-import static org.apache.iotdb.db.integration.TestConstant.min_value;
-import static org.apache.iotdb.db.integration.TestConstant.sum;
-import static org.junit.Assert.fail;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.jdbc.Config;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IoTDBAggregationLargeDataIT {
-
- private static final String TIMESTAMP_STR = "Time";
- private final String d0s0 = "root.vehicle.d0.s0";
- private final String d0s1 = "root.vehicle.d0.s1";
- private final String d0s2 = "root.vehicle.d0.s2";
- private final String d0s3 = "root.vehicle.d0.s3";
- private final String d0s4 = "root.vehicle.d0.s4";
-
- private static String[] createSql = new String[]{
- "SET STORAGE GROUP TO root.vehicle",
- "CREATE TIMESERIES root.vehicle.d1.s0 WITH DATATYPE=INT32, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s2 WITH DATATYPE=FLOAT, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s3 WITH DATATYPE=TEXT, ENCODING=PLAIN",
- "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s1 WITH DATATYPE=INT64, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s4 WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
- };
-
- private static String[] insertSql = new String[]{
- "insert into root.vehicle.d0(timestamp,s0) values(1,101)",
- "insert into root.vehicle.d0(timestamp,s0) values(2,198)",
- "insert into root.vehicle.d0(timestamp,s0) values(100,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(101,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(102,80)",
- "insert into root.vehicle.d0(timestamp,s0) values(103,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(104,90)",
- "insert into root.vehicle.d0(timestamp,s0) values(105,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(106,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(2,10000)",
- "insert into root.vehicle.d0(timestamp,s0) values(50,10000)",
- "insert into root.vehicle.d0(timestamp,s0) values(1000,22222)",
- "insert into root.vehicle.d0(timestamp,s0) values(106,199)",
- "DELETE FROM root.vehicle.d0.s0 WHERE time < 104",
-
- "insert into root.vehicle.d0(timestamp,s1) values(1,1101)",
- "insert into root.vehicle.d0(timestamp,s1) values(2,198)",
- "insert into root.vehicle.d0(timestamp,s1) values(100,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(101,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(102,180)",
- "insert into root.vehicle.d0(timestamp,s1) values(103,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(104,190)",
- "insert into root.vehicle.d0(timestamp,s1) values(105,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(2,40000)",
- "insert into root.vehicle.d0(timestamp,s1) values(50,50000)",
- "insert into root.vehicle.d0(timestamp,s1) values(1000,55555)",
-
- "insert into root.vehicle.d0(timestamp,s2) values(1000,55555)",
- "insert into root.vehicle.d0(timestamp,s2) values(2,2.22)",
- "insert into root.vehicle.d0(timestamp,s2) values(3,3.33)",
- "insert into root.vehicle.d0(timestamp,s2) values(4,4.44)",
- "insert into root.vehicle.d0(timestamp,s2) values(102,10.00)",
- "insert into root.vehicle.d0(timestamp,s2) values(105,11.11)",
- "insert into root.vehicle.d0(timestamp,s2) values(1000,1000.11)",
-
- "insert into root.vehicle.d0(timestamp,s3) values(60,'aaaaa')",
- "insert into root.vehicle.d0(timestamp,s3) values(70,'bbbbb')",
- "insert into root.vehicle.d0(timestamp,s3) values(80,'ccccc')",
- "insert into root.vehicle.d0(timestamp,s3) values(101,'ddddd')",
- "insert into root.vehicle.d0(timestamp,s3) values(102,'fffff')",
-
- "insert into root.vehicle.d1(timestamp,s0) values(1,999)",
- "insert into root.vehicle.d1(timestamp,s0) values(1000,888)",
-
- "insert into root.vehicle.d0(timestamp,s4) values(100, false)",
- "insert into root.vehicle.d0(timestamp,s4) values(100, true)",
- };
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.closeStatMonitor();
- EnvironmentUtils.envSetUp();
- }
-
- @After
- public void tearDown() throws Exception {
- IoTDBDescriptor.getInstance().getConfig().setPartitionInterval(86400);
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void test() throws ClassNotFoundException, SQLException {
- insertSQL();
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");) {
- lastValueAggreWithSingleFilterTest();
- avgAggreWithSingleFilterTest();
- sumAggreWithSingleFilterTest();
- firstAggreWithSingleFilterTest();
- countAggreWithSingleFilterTest();
- minMaxTimeAggreWithSingleFilterTest();
- minValueAggreWithSingleFilterTest();
- maxValueAggreWithSingleFilterTest();
-
- lastValueAggreWithMultiFilterTest();
- countAggreWithMultiFilterTest();
- minTimeAggreWithMultiFilterTest();
- maxTimeAggreWithMultiFilterTest();
- minValueAggreWithMultiFilterTest();
- maxValueAggreWithMultiFilterTest();
- avgAggreWithMultiFilterTest();
- sumAggreWithMultiFilterTest();
- firstAggreWithMultiFilterTest();
- }
- }
-
- private void lastValueAggreWithMultiFilterTest() throws SQLException {
- String[] retArray = new String[]{
- "0,9,39,63.0,E,true"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute(
- "select last_value(s0),last_value(s1),last_value(s2),last_value(s3),last_value(s4)" +
- " from root.vehicle.d0 where s1 >= 0");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," +
- resultSet.getString(last_value(d0s0)) + "," + resultSet
- .getString(last_value(d0s1))
- + "," + resultSet.getString(last_value(d0s2)) + "," +
- resultSet.getString(last_value(d0s3)) + "," + resultSet
- .getString(last_value(d0s4));
- // System.out.println("============ " + ans);
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void lastValueAggreWithSingleFilterTest() throws SQLException {
- String[] retArray = new String[]{
- "0,9,39,63.0"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute("select last_value(s0),last_value(s1),last_value(s2)" +
- " from root.vehicle.d0 where s1 >= 0");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," +
- resultSet.getString(last_value(d0s0)) + ","
- + resultSet.getString(last_value(d0s1)) + "," +
- resultSet.getString(last_value(d0s2));
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void sumAggreWithSingleFilterTest() {
- String[] retArray = new String[]{
- "0,55061.0,156752.0,20254"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select sum(s0),sum(s1),sum(s2)" +
- " from root.vehicle.d0 where s1 >= 0");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(sum(d0s0)) + ","
- + resultSet.getString(sum(d0s1)) + "," + Math
- .round(resultSet.getDouble(sum(d0s2)));
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void firstAggreWithSingleFilterTest() {
- String[] retArray = new String[]{
- "0,90,1101,2.22,ddddd,true"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select first_value(s0),first_value(s1),first_value(s2),first_value(s3),"
- + "first_value(s4) from root.vehicle.d0 where s1 >= 0");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," +
- resultSet.getString(first_value(d0s0)) + ","
- + resultSet.getString(first_value(d0s1)) + "," +
- resultSet.getString(first_value(d0s2))
- + "," + resultSet.getString(first_value(d0s3)) + "," +
- resultSet.getString(first_value(d0s4));
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void avgAggreWithSingleFilterTest() {
- String[] retArray = new String[]{
- "0,75,212,28"
- };
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement();) {
-
- boolean hasResultSet = statement.execute(
- "select avg(s0),avg(s1),avg(s2) from root.vehicle.d0 where s1 >= 0");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- int cnt = 0;
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + Math.round(resultSet.getDouble(avg(d0s0)))
- + "," + Math.round(resultSet.getDouble(avg(d0s1))) + "," +
- Math.round(resultSet.getDouble(avg(d0s2)));
- //System.out.println("!!!!!============ " + ans);
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void countAggreWithSingleFilterTest() throws SQLException {
- String[] retArray = new String[]{
- "0,733,740,734"
- };
-
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute(
- "select count(s0),count(s1),count(s2) from root.vehicle.d0 where s1 >= 0");
- Assert.assertTrue(hasResultSet);
- try (ResultSet resultSet = statement.getResultSet()) {
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(count(d0s0))
- + "," + resultSet.getString(count(d0s1)) + "," + resultSet.getString(count(d0s2));
- //System.out.println("!!!!!============ " + ans);
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void minMaxTimeAggreWithSingleFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,104,1,2,101,100"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute(
- "select min_time(s0),min_time(s1),min_time(s2),min_time(s3),min_time(s4)" +
- " from root.vehicle.d0 where s1 >= 0");
- Assert.assertTrue(hasResultSet);
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," +
- resultSet.getString(min_time(d0s0)) + "," +
- resultSet.getString(min_time(d0s1)) + "," +
- resultSet.getString(min_time(d0s2)) +
- "," + resultSet.getString(min_time(d0s3)) +
- "," + resultSet.getString(min_time(d0s4));
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
-
- retArray = new String[]{
- "0,3999,3999,3999,3599,100"
- };
- hasResultSet = statement.execute("select max_time(s0),max_time(s1),max_time(s2),"
- + "max_time(s3),max_time(s4) from root.vehicle.d0 " +
- "where s1 < 50000 and s1 != 100");
- Assert.assertTrue(hasResultSet);
- resultSet = statement.getResultSet();
- cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(max_time(d0s0))
- + "," + resultSet.getString(max_time(d0s1)) + "," + resultSet.getString(max_time(d0s2))
- + "," + resultSet.getString(max_time(d0s3)) + "," + resultSet.getString(max_time(d0s4));
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void minValueAggreWithSingleFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,0,0,0.0,B,true"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager
- .getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- boolean hasResultSet = statement.execute("select min_value(s0),min_value(s1),min_value(s2),"
- + "min_value(s3),min_value(s4) from root.vehicle.d0 " +
- "where s1 < 50000 and s1 != 100");
-
- if (hasResultSet) {
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(min_value(d0s0))
- + "," + resultSet.getString(min_value(d0s1)) + "," + resultSet
- .getString(min_value(d0s2))
- + "," + resultSet.getString(min_value(d0s3)) + "," + resultSet
- .getString(min_value(d0s4));
- //System.out.println("============ " + ans);
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void maxValueAggreWithSingleFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,99,40000,122.0,fffff,true"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select max_value(s0),max_value(s1),max_value(s2),"
- + "max_value(s3),max_value(s4) from root.vehicle.d0 " +
- "where s1 < 50000 and s1 != 100");
-
- if (hasResultSet) {
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(max_value(d0s0))
- + "," + resultSet.getString(max_value(d0s1)) + "," + resultSet
- .getString(max_value(d0s2))
- + "," + resultSet.getString(max_value(d0s3)) + "," + resultSet
- .getString(max_value(d0s4));
- //System.out.println("============ " + ans);
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void avgAggreWithMultiFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,55061.0,733,75,212,28"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select sum(s0),count(s0),avg(s0),avg(s1),"
- + "avg(s2) from root.vehicle.d0 " +
- "where s1 >= 0 or s2 < 10");
- Assert.assertTrue(hasResultSet);
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans =
- resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(sum(d0s0)) + "," +
- resultSet.getString(count(d0s0)) + "," + Math.round(resultSet.getDouble(avg(d0s0)))
- + "," +
- Math.round(resultSet.getDouble(avg(d0s1))) + "," + Math
- .round(resultSet.getDouble(avg(d0s2)));
- //System.out.println("!!!!!============ " + ans);
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void sumAggreWithMultiFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,55061.0,156752.0,20262"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select sum(s0),sum(s1),sum(s2) from root.vehicle.d0"
- + " where s1 >= 0 or s2 < 10");
- Assert.assertTrue(hasResultSet);
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(sum(d0s0))
- + "," + resultSet.getString(sum(d0s1)) + "," + Math
- .round(resultSet.getDouble(sum(d0s2)));
- //String ans = resultSet.getString(sum(d0s3));
- //System.out.println("!!!!!============ " + ans);
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void firstAggreWithMultiFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,90,1101,2.22,ddddd,true"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select first_value(s0),first_value(s1),first_value(s2),first_value(s3),"
- + "first_value(s4) from root.vehicle.d0 where s1 >= 0 or s2 < 10");
- Assert.assertTrue(hasResultSet);
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(first_value(d0s0))
- + "," + resultSet.getString(first_value(d0s1)) + "," + resultSet.getString(first_value(d0s2))
- + "," + resultSet.getString(first_value(d0s3)) + "," + resultSet.getString(first_value(d0s4));
- //String ans = resultSet.getString(first_value(d0s3));
- //System.out.println("!!!!!============ " + ans);
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void countAggreWithMultiFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,733,740,736,482,1"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select count(s0),count(s1),count(s2),count(s3),"
- + "count(s4) from root.vehicle.d0 where s1 >= 0 or s2 < 10");
- Assert.assertTrue(hasResultSet);
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(count(d0s0))
- + "," + resultSet.getString(count(d0s1)) + "," + resultSet.getString(count(d0s2))
- + "," + resultSet.getString(count(d0s3)) + "," + resultSet.getString(count(d0s4));
- //String ans = resultSet.getString(count(d0s3));
- //System.out.println("!!!!!============ " + ans);
- Assert.assertEquals(retArray[cnt], ans);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void minTimeAggreWithMultiFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,104,1,2,101,100"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select min_time(s0),min_time(s1),min_time(s2),"
- + "min_time(s3),min_time(s4) from root.vehicle.d0 where s1 >= 0");
- Assert.assertTrue(hasResultSet);
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," +
- resultSet.getString(min_time(d0s0)) + "," +
- resultSet.getString(min_time(d0s1)) + "," +
- resultSet.getString(min_time(d0s2)) + "," +
- resultSet.getString(min_time(d0s3)) + "," +
- resultSet.getString(min_time(d0s4));
- // System.out.println("============ " + ans);
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void maxTimeAggreWithMultiFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,3999,3999,3999,3599,100"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select max_time(s0),max_time(s1),max_time(s2),"
- + "max_time(s3),max_time(s4) from root.vehicle.d0 " +
- "where s1 < 50000 and s1 != 100");
- Assert.assertTrue(hasResultSet);
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(max_time(d0s0))
- + "," + resultSet.getString(max_time(d0s1)) + "," + resultSet.getString(max_time(d0s2))
- + "," + resultSet.getString(max_time(d0s3)) + "," + resultSet.getString(max_time(d0s4));
- //System.out.println("============ " + ans);
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void minValueAggreWithMultiFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,0,0,0.0,B,true"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select min_value(s0),min_value(s1),min_value(s2),"
- + "min_value(s3),min_value(s4) from root.vehicle.d0 " +
- "where s1 < 50000 and s1 != 100");
- Assert.assertTrue(hasResultSet);
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(min_value(d0s0))
- + "," + resultSet.getString(min_value(d0s1)) + "," + resultSet
- .getString(min_value(d0s2))
- + "," + resultSet.getString(min_value(d0s3)) + "," + resultSet
- .getString(min_value(d0s4));
- //System.out.println("============ " + ans);
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void maxValueAggreWithMultiFilterTest() throws ClassNotFoundException, SQLException {
- String[] retArray = new String[]{
- "0,99,40000,122.0,fffff,true"
- };
-
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- boolean hasResultSet = statement.execute("select max_value(s0),max_value(s1),max_value(s2),"
- + "max_value(s3),max_value(s4) from root.vehicle.d0 where s1 < 50000 and s1 != 100");
- Assert.assertTrue(hasResultSet);
- ResultSet resultSet = statement.getResultSet();
- int cnt = 0;
- while (resultSet.next()) {
- String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString(max_value(d0s0))
- + "," + resultSet.getString(max_value(d0s1)) + "," + resultSet
- .getString(max_value(d0s2))
- + "," + resultSet.getString(max_value(d0s3)) + "," + resultSet
- .getString(max_value(d0s4));
- Assert.assertEquals(ans, retArray[cnt]);
- cnt++;
- }
- Assert.assertEquals(1, cnt);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private static String[] stringValue = new String[]{"A", "B", "C", "D", "E"};
-
- public static void insertSQL() throws ClassNotFoundException, SQLException {
- Class.forName(Config.JDBC_DRIVER_NAME);
- double d0s0sum = 0.0, d0s1sum = 0.0, d0s2sum = 0.0;
- int cnt = 0;
- try (Connection connection = DriverManager.
- getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
-Statement statement = connection.createStatement()) {
-
- for (String sql : createSql) {
- statement.execute(sql);
- }
-
- // insert large amount of data
- for (int time = 3000; time < 3600; time++) {
- if (time % 5 == 0) {
- continue;
- }
-
- String sql = String.format("insert into root.vehicle.d0(timestamp,s0) values(%s,%s)",
- time, time % 100);
- statement.execute(sql);
- sql = String.format("insert into root.vehicle.d0(timestamp,s1) values(%s,%s)",
- time, time % 17);
- statement.execute(sql);
- sql = String.format("insert into root.vehicle.d0(timestamp,s2) values(%s,%s)",
- time, time % 22);
- statement.execute(sql);
- sql = String.format("insert into root.vehicle.d0(timestamp,s3) values(%s,'%s')",
- time, stringValue[time % 5]);
- statement.execute(sql);
- cnt++;
- d0s0sum += time % 100;
- d0s1sum += time % 17;
- d0s2sum += time % 22;
- }
-
- statement.execute("flush");
-
- // insert large amount of data
- for (int time = 3700; time < 4000; time++) {
- if (time % 6 == 0) {
- continue;
- }
-
- String sql = String.format("insert into root.vehicle.d0(timestamp,s0) values(%s,%s)",
- time, time % 70);
- statement.execute(sql);
- sql = String.format("insert into root.vehicle.d0(timestamp,s1) values(%s,%s)",
- time, time % 40);
- statement.execute(sql);
- sql = String.format("insert into root.vehicle.d0(timestamp,s2) values(%s,%s)",
- time, time % 123);
- statement.execute(sql);
-
- cnt++;
- d0s0sum += time % 70;
- d0s1sum += time % 40;
- d0s2sum += time % 123;
- }
-
- statement.execute("merge");
- for (String sql : insertSql) {
- statement.execute(sql);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationSmallDataIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationSmallDataIT.java
deleted file mode 100644
index 821a5ed..0000000
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBAggregationSmallDataIT.java
+++ /dev/null
@@ -1,686 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.integration;
-
-import static org.apache.iotdb.db.integration.TestConstant.avg;
-import static org.apache.iotdb.db.integration.TestConstant.count;
-import static org.apache.iotdb.db.integration.TestConstant.first_value;
-import static org.apache.iotdb.db.integration.TestConstant.last_value;
-import static org.apache.iotdb.db.integration.TestConstant.max_time;
-import static org.apache.iotdb.db.integration.TestConstant.max_value;
-import static org.apache.iotdb.db.integration.TestConstant.min_time;
-import static org.apache.iotdb.db.integration.TestConstant.min_value;
-import static org.apache.iotdb.db.integration.TestConstant.sum;
-import static org.junit.Assert.fail;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.jdbc.IoTDBSQLException;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Multiple aggregation with filter test.
- */
-public class IoTDBAggregationSmallDataIT {
-
- private static final String TIMESTAMP_STR = "Time";
- private final String d0s0 = "root.vehicle.d0.s0";
- private final String d0s1 = "root.vehicle.d0.s1";
- private final String d0s2 = "root.vehicle.d0.s2";
- private final String d0s3 = "root.vehicle.d0.s3";
- private final String d0s4 = "root.vehicle.d0.s4";
- private final String d1s0 = "root.vehicle.d1.s0";
- private final String d1s1 = "root.vehicle.d1.s1";
-
- private static String[] sqls = new String[]{
- "SET STORAGE GROUP TO root.vehicle",
- "CREATE TIMESERIES root.vehicle.d1.s0 WITH DATATYPE=INT32, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d1.s1 WITH DATATYPE=INT64, ENCODING=RLE",
-
- "CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s1 WITH DATATYPE=INT64, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s2 WITH DATATYPE=FLOAT, ENCODING=RLE",
- "CREATE TIMESERIES root.vehicle.d0.s3 WITH DATATYPE=TEXT, ENCODING=PLAIN",
- "CREATE TIMESERIES root.vehicle.d0.s4 WITH DATATYPE=BOOLEAN, ENCODING=PLAIN",
-
- "insert into root.vehicle.d0(timestamp,s0) values(1,101)",
- "insert into root.vehicle.d0(timestamp,s0) values(2,198)",
- "insert into root.vehicle.d0(timestamp,s0) values(100,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(101,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(102,80)",
- "insert into root.vehicle.d0(timestamp,s0) values(103,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(104,90)",
- "insert into root.vehicle.d0(timestamp,s0) values(105,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(106,99)",
- "insert into root.vehicle.d0(timestamp,s0) values(2,10000)",
- "insert into root.vehicle.d0(timestamp,s0) values(50,10000)",
- "insert into root.vehicle.d0(timestamp,s0) values(1000,22222)",
- "insert into root.vehicle.d0(timestamp,s0) values(106,199)",
- "DELETE FROM root.vehicle.d0.s0 WHERE time < 104",
-
- "insert into root.vehicle.d0(timestamp,s1) values(1,1101)",
- "insert into root.vehicle.d0(timestamp,s1) values(2,198)",
- "insert into root.vehicle.d0(timestamp,s1) values(100,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(101,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(102,180)",
- "insert into root.vehicle.d0(timestamp,s1) values(103,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(104,190)",
- "insert into root.vehicle.d0(timestamp,s1) values(105,199)",
- "insert into root.vehicle.d0(timestamp,s1) values(2,40000)",
- "insert into root.vehicle.d0(timestamp,s1) values(50,50000)",
- "insert into root.vehicle.d0(timestamp,s1) values(1000,55555)",
-
- "insert into root.vehicle.d0(timestamp,s2) values(1000,55555)",
- "insert into root.vehicle.d0(timestamp,s2) values(2,2.22)",
... 31124 lines suppressed ...