[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-06 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r321639784
 
 

 ##
 File path: server/src/assembly/resources/conf/iotdb-engine.properties
 ##
 @@ -238,6 +238,16 @@ stat_monitor_retain_interval_in_second=600
 # This cache is used to improve insert speed where all path check and 
TSDataType will be cached in MManager with corresponding Path.
 schema_manager_cache_size=30
 
+
+### External sort Configuration
 
 Review comment:
   One last thought: How about adding a switch `external_sort_enable` ?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320542906
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/externalsort/ExternalSortJobPart.java
 ##
 @@ -0,0 +1,44 @@
+/**
+ * Copyright © 2019 Apache IoTDB(incubating) (d...@iotdb.apache.org)
+ *
+ * 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.query.externalsort;
+
+import java.io.IOException;
+import org.apache.iotdb.db.query.reader.IPointReader;
+
+
+public abstract class ExternalSortJobPart {
+
+  private ExternalSortJobPartType type;
+
+  public ExternalSortJobPart(ExternalSortJobPartType type) {
+this.type = type;
+  }
+
+  public abstract IPointReader executeWithGlobalTimeFilter() throws 
IOException;
 
 Review comment:
   I think `executeForIPointReader` is better than 
`executeWithGlobalTimeFilter`.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320543266
 
 

 ##
 File path: 
server/src/test/java/org/apache/iotdb/db/query/externalsort/SimpleTimeValuePairSerializerTest.java
 ##
 @@ -0,0 +1,146 @@
+/**
+ * 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.query.externalsort;
+
+import java.io.File;
+import java.io.IOException;
+import 
org.apache.iotdb.db.query.externalsort.serialize.TimeValuePairDeserializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.TimeValuePairSerializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.impl.FixLengthTimeValuePairDeserializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.impl.FixLengthTimeValuePairSerializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.impl.SimpleTimeValuePairDeserializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.impl.SimpleTimeValuePairSerializer;
+import org.apache.iotdb.db.utils.TimeValuePair;
+import org.apache.iotdb.db.utils.TsPrimitiveType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.utils.Binary;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Created by zhangjinrui on 2018/1/20.
+ */
+public class SimpleTimeValuePairSerializerTest {
 
 Review comment:
   The name can be changed because the deserializer is also tested.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320542612
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/externalsort/SingleSourceExternalSortJobPart.java
 ##
 @@ -0,0 +1,42 @@
+ /**
+ * Copyright © 2019 Apache IoTDB(incubating) (d...@iotdb.apache.org)
+ *
+ * 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.query.externalsort;
+
+ import java.io.IOException;
+ import org.apache.iotdb.db.query.reader.IPointReader;
+ import org.apache.iotdb.db.query.reader.chunkRelated.ChunkReaderWrap;
+
+
+ public class SingleSourceExternalSortJobPart extends ExternalSortJobPart {
+
+   private IPointReader timeValuePairReader;
+   private ChunkReaderWrap chunkReaderWrap;
+
+   public SingleSourceExternalSortJobPart(ChunkReaderWrap chunkReaderWrap) {
+ super(ExternalSortJobPartType.SINGLE_SOURCE);
+ this.chunkReaderWrap = chunkReaderWrap;
+   }
+
+   @Override
+   public IPointReader executeWithGlobalTimeFilter() throws IOException {
 
 Review comment:
   I think `executeForIPointReader` is better than 
`executeWithGlobalTimeFilter`.
   And here `timeValuePairReader` can be made a local variable.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320539389
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/externalsort/SimpleExternalSortEngine.java
 ##
 @@ -0,0 +1,160 @@
+ /**
+ * Copyright © 2019 Apache IoTDB(incubating) (d...@iotdb.apache.org)
+ *
+ * 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.query.externalsort;
+
+ import java.io.File;
+ import java.io.IOException;
+ 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.exception.StorageEngineFailureException;
+ import 
org.apache.iotdb.db.query.externalsort.adapter.ByTimestampReaderAdapter;
+ import org.apache.iotdb.db.query.reader.IPointReader;
+ import org.apache.iotdb.db.query.reader.IReaderByTimestamp;
+ import org.apache.iotdb.db.query.reader.chunkRelated.ChunkReaderWrap;
+
+
+ public class SimpleExternalSortEngine implements ExternalSortJobEngine {
+
+   private ExternalSortJobScheduler scheduler;
+
+   private String queryDir;
+   private int minExternalSortSourceCount;
+
+   private SimpleExternalSortEngine() {
+ queryDir = IoTDBDescriptor.getInstance().getConfig().getQueryDir();
+ minExternalSortSourceCount = IoTDBDescriptor.getInstance().getConfig()
+ .getExternalSortThreshold();
+ scheduler = ExternalSortJobScheduler.getInstance();
+
+ // create queryDir
+ try {
+   FileUtils.forceMkdir(new File(queryDir));
+ } catch (IOException e) {
+   throw new StorageEngineFailureException("create system directory 
failed!");
+ }
+   }
+
+   // This class is used in test.
+   public SimpleExternalSortEngine(String queryDir, int 
minExternalSortSourceCount) {
 
 Review comment:
   To test this class, I suggest using
   ```
   IoTDBDescriptor.getInstance().getConfig().setQueryDir(baseDir + "/");
   IoTDBDescriptor.getInstance().getConfig().setExternalSortThreshold(2);
   SimpleExternalSortEngine engine = SimpleExternalSortEngine.getInstance();
   ```
   instead of a useless constructor in the src code.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320543183
 
 

 ##
 File path: 
server/src/test/java/org/apache/iotdb/db/query/externalsort/SimpleTimeValuePairSerializerTest.java
 ##
 @@ -0,0 +1,146 @@
+/**
+ * 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.query.externalsort;
+
+import java.io.File;
+import java.io.IOException;
+import 
org.apache.iotdb.db.query.externalsort.serialize.TimeValuePairDeserializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.TimeValuePairSerializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.impl.FixLengthTimeValuePairDeserializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.impl.FixLengthTimeValuePairSerializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.impl.SimpleTimeValuePairDeserializer;
+import 
org.apache.iotdb.db.query.externalsort.serialize.impl.SimpleTimeValuePairSerializer;
+import org.apache.iotdb.db.utils.TimeValuePair;
+import org.apache.iotdb.db.utils.TsPrimitiveType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.utils.Binary;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Created by zhangjinrui on 2018/1/20.
 
 Review comment:
   This?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320542411
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/externalsort/SimpleExternalSortEngine.java
 ##
 @@ -0,0 +1,160 @@
+ /**
+ * Copyright © 2019 Apache IoTDB(incubating) (d...@iotdb.apache.org)
+ *
+ * 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.query.externalsort;
+
+ import java.io.File;
+ import java.io.IOException;
+ 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.exception.StorageEngineFailureException;
+ import 
org.apache.iotdb.db.query.externalsort.adapter.ByTimestampReaderAdapter;
+ import org.apache.iotdb.db.query.reader.IPointReader;
+ import org.apache.iotdb.db.query.reader.IReaderByTimestamp;
+ import org.apache.iotdb.db.query.reader.chunkRelated.ChunkReaderWrap;
+
+
+ public class SimpleExternalSortEngine implements ExternalSortJobEngine {
+
+   private ExternalSortJobScheduler scheduler;
+
+   private String queryDir;
+   private int minExternalSortSourceCount;
+
+   private SimpleExternalSortEngine() {
+ queryDir = IoTDBDescriptor.getInstance().getConfig().getQueryDir();
+ minExternalSortSourceCount = IoTDBDescriptor.getInstance().getConfig()
+ .getExternalSortThreshold();
+ scheduler = ExternalSortJobScheduler.getInstance();
+
+ // create queryDir
+ try {
+   FileUtils.forceMkdir(new File(queryDir));
+ } catch (IOException e) {
+   throw new StorageEngineFailureException("create system directory 
failed!");
+ }
+   }
+
+   // This class is used in test.
+   public SimpleExternalSortEngine(String queryDir, int 
minExternalSortSourceCount) {
+ this.queryDir = queryDir;
+ this.minExternalSortSourceCount = minExternalSortSourceCount;
+ scheduler = ExternalSortJobScheduler.getInstance();
+   }
+
+   @Override
+   public List executeForIPointReader(long queryId,
+   List chunkReaderWraps)
+   throws IOException {
+ if (chunkReaderWraps.size() < minExternalSortSourceCount) {
+   return generateIPointReader(chunkReaderWraps, 0, 
chunkReaderWraps.size());
+ }
+ ExternalSortJob job = createJob(queryId, chunkReaderWraps);
+ return job.executeWithGlobalTimeFilter();
 
 Review comment:
   I think `job.executeForIPointReader` is better than 
`job.executeWithGlobalTimeFilter`.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320544005
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/externalsort/serialize/impl/SimpleTimeValuePairDeserializer.java
 ##
 @@ -0,0 +1,84 @@
+/**
+ * Copyright © 2019 Apache IoTDB(incubating) (d...@iotdb.apache.org)
+ *
+ * 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.query.externalsort.serialize.impl;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import 
org.apache.iotdb.db.query.externalsort.serialize.TimeValuePairDeserializer;
+import org.apache.iotdb.db.utils.TimeValuePair;
+
+/**
+ * Deserializer TimeValuePair.
+ */
+public class SimpleTimeValuePairDeserializer implements 
TimeValuePairDeserializer {
 
 Review comment:
   This class is only used in test. Why do you keep it in the src code?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320542474
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/externalsort/SimpleExternalSortEngine.java
 ##
 @@ -0,0 +1,160 @@
+ /**
+ * Copyright © 2019 Apache IoTDB(incubating) (d...@iotdb.apache.org)
+ *
+ * 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.query.externalsort;
+
+ import java.io.File;
+ import java.io.IOException;
+ 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.exception.StorageEngineFailureException;
+ import 
org.apache.iotdb.db.query.externalsort.adapter.ByTimestampReaderAdapter;
+ import org.apache.iotdb.db.query.reader.IPointReader;
+ import org.apache.iotdb.db.query.reader.IReaderByTimestamp;
+ import org.apache.iotdb.db.query.reader.chunkRelated.ChunkReaderWrap;
+
+
+ public class SimpleExternalSortEngine implements ExternalSortJobEngine {
+
+   private ExternalSortJobScheduler scheduler;
+
+   private String queryDir;
+   private int minExternalSortSourceCount;
+
+   private SimpleExternalSortEngine() {
+ queryDir = IoTDBDescriptor.getInstance().getConfig().getQueryDir();
+ minExternalSortSourceCount = IoTDBDescriptor.getInstance().getConfig()
+ .getExternalSortThreshold();
+ scheduler = ExternalSortJobScheduler.getInstance();
+
+ // create queryDir
+ try {
+   FileUtils.forceMkdir(new File(queryDir));
+ } catch (IOException e) {
+   throw new StorageEngineFailureException("create system directory 
failed!");
+ }
+   }
+
+   // This class is used in test.
+   public SimpleExternalSortEngine(String queryDir, int 
minExternalSortSourceCount) {
+ this.queryDir = queryDir;
+ this.minExternalSortSourceCount = minExternalSortSourceCount;
+ scheduler = ExternalSortJobScheduler.getInstance();
+   }
+
+   @Override
+   public List executeForIPointReader(long queryId,
+   List chunkReaderWraps)
+   throws IOException {
+ if (chunkReaderWraps.size() < minExternalSortSourceCount) {
+   return generateIPointReader(chunkReaderWraps, 0, 
chunkReaderWraps.size());
+ }
+ ExternalSortJob job = createJob(queryId, chunkReaderWraps);
+ return job.executeWithGlobalTimeFilter();
+   }
+
+   @Override
+   public List executeForByTimestampReader(long queryId,
+   List chunkReaderWraps) throws IOException {
+ if (chunkReaderWraps.size() < minExternalSortSourceCount) {
+   return generateIReaderByTimestamp(chunkReaderWraps, 0, 
chunkReaderWraps.size());
+ }
+ ExternalSortJob job = createJob(queryId, chunkReaderWraps);
+ return convert(job.executeWithGlobalTimeFilter());
 
 Review comment:
   I think `job.executeForIPointReader` is better than 
`job.executeWithGlobalTimeFilter`.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320543563
 
 

 ##
 File path: 
server/src/test/java/org/apache/iotdb/db/query/externalsort/ExternalSortEngineTest.java
 ##
 @@ -0,0 +1,174 @@
+/**
+ * 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.query.externalsort;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import org.apache.iotdb.db.exception.StorageEngineException;
+import org.apache.iotdb.db.query.control.QueryResourceManager;
+import org.apache.iotdb.db.query.reader.IPointReader;
+import org.apache.iotdb.db.query.reader.chunkRelated.ChunkReaderWrap;
+import org.apache.iotdb.db.query.reader.universal.FakedSeriesReader;
+import org.apache.iotdb.db.query.reader.universal.PriorityMergeReader;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.db.utils.TimeValuePair;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ExternalSortEngineTest {
+
+  private String baseDir = "externalSortTestTmp";
+  private long queryId = EnvironmentUtils.TEST_QUERY_JOB_ID;
+
+  @After
+  public void after() throws IOException, StorageEngineException {
 
 Review comment:
   After running this test, the generated `data` directory is not deleted.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320537517
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/externalsort/ExternalSortJobEngine.java
 ##
 @@ -0,0 +1,55 @@
+/**
+ * Copyright © 2019 Apache IoTDB(incubating) (d...@iotdb.apache.org)
+ *
+ * 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.query.externalsort;
+
+import java.io.IOException;
+import java.util.List;
+import org.apache.iotdb.db.query.reader.IPointReader;
+import org.apache.iotdb.db.query.reader.IReaderByTimestamp;
+import org.apache.iotdb.db.query.reader.chunkRelated.ChunkReaderWrap;
+
+
+public interface ExternalSortJobEngine {
+
+ /**
+  * Receive a list of ChunkReaderWraps and judge whether it should be 
processed using external
+  * sort. If needed, do the merge sort for all ChunkReaderWraps using specific 
strategy.
+  *
+  * @param chunkReaderWraps A list include a set of ChunkReaderWraps
 
 Review comment:
   Simplified: A list of chunkReaderWrap


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320542963
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/externalsort/MultiSourceExternalSortJobPart.java
 ##
 @@ -0,0 +1,61 @@
+ /**
+ * Copyright © 2019 Apache IoTDB(incubating) (d...@iotdb.apache.org)
+ *
+ * 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.query.externalsort;
+
+ import java.io.IOException;
+ import java.util.ArrayList;
+ import java.util.List;
+ import org.apache.iotdb.db.query.reader.IPointReader;
+
+
+ public class MultiSourceExternalSortJobPart extends ExternalSortJobPart {
+
+   private String tmpFilePath;
+   private List source;
+   private long queryId;
+
+   public MultiSourceExternalSortJobPart(long queryId, String tmpFilePath,
+   List source) {
+ super(ExternalSortJobPartType.MULTIPLE_SOURCE);
+ this.source = source;
+ this.tmpFilePath = tmpFilePath;
+ this.queryId = queryId;
+   }
+
+   public MultiSourceExternalSortJobPart(long queryId, String tmpFilePath,
+   ExternalSortJobPart... externalSortJobParts) {
+ super(ExternalSortJobPartType.MULTIPLE_SOURCE);
+ source = new ArrayList<>();
+ for (ExternalSortJobPart externalSortJobPart : externalSortJobParts) {
+   source.add(externalSortJobPart);
+ }
+ this.tmpFilePath = tmpFilePath;
+   }
+
+   @Override
+   public IPointReader executeWithGlobalTimeFilter() throws IOException {
+ List prioritySeriesReaders = new ArrayList<>();
+ for (ExternalSortJobPart part : source) {
+   prioritySeriesReaders.add(part.executeWithGlobalTimeFilter());
 
 Review comment:
   I think `executeForIPointReader` is better than 
`executeWithGlobalTimeFilter`.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort

2019-09-03 Thread GitBox
LeiRui commented on a change in pull request #336: [ IOTDB-160]External sort
URL: https://github.com/apache/incubator-iotdb/pull/336#discussion_r320543977
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/externalsort/serialize/impl/SimpleTimeValuePairSerializer.java
 ##
 @@ -0,0 +1,66 @@
+/**
+ * Copyright © 2019 Apache IoTDB(incubating) (d...@iotdb.apache.org)
+ *
+ * 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.query.externalsort.serialize.impl;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import 
org.apache.iotdb.db.query.externalsort.serialize.TimeValuePairSerializer;
+import org.apache.iotdb.db.utils.TimeValuePair;
+
+/**
+ * Serializer timeValuePair.
+ */
+public class SimpleTimeValuePairSerializer implements TimeValuePairSerializer {
 
 Review comment:
   This class is only used in test. Why do you keep it in the src code?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services