You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/04/06 05:49:40 UTC
[GitHub] [iotdb] JackieTien97 commented on a diff in pull request #5402: [IOTDB-2846] Add Driver which implements ExecFragmentInstance interface
JackieTien97 commented on code in PR #5402:
URL: https://github.com/apache/iotdb/pull/5402#discussion_r843490294
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/DataDriver.java:
##########
@@ -0,0 +1,324 @@
+/*
+ * 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.mpp.execution;
+
+import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.db.engine.storagegroup.VirtualStorageGroupProcessor;
+import org.apache.iotdb.db.exception.query.QueryProcessException;
+import org.apache.iotdb.db.metadata.idtable.IDTable;
+import org.apache.iotdb.db.metadata.path.PartialPath;
+import org.apache.iotdb.db.mpp.buffer.ISinkHandle;
+import org.apache.iotdb.db.mpp.common.FragmentInstanceId;
+import org.apache.iotdb.db.mpp.operator.Operator;
+import org.apache.iotdb.db.mpp.operator.source.SourceOperator;
+import org.apache.iotdb.db.query.control.FileReaderManager;
+import org.apache.iotdb.tsfile.read.common.block.TsBlock;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import io.airlift.units.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.concurrent.NotThreadSafe;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+
+import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+import static org.apache.iotdb.db.mpp.operator.Operator.NOT_BLOCKED;
+
+@NotThreadSafe
+public class DataDriver implements ExecFragmentInstance {
+
+ private static final Logger logger = LoggerFactory.getLogger(DataDriver.class);
+
+ private final Operator root;
+ private final ISinkHandle sinkHandle;
+ private final DataDriverContext driverContext;
+
+ private boolean init;
+ private boolean closed;
+
+ /** closed tsfile used in this fragment instance */
+ private Set<TsFileResource> closedFilePaths;
+ /** unClosed tsfile used in this fragment instance */
+ private Set<TsFileResource> unClosedFilePaths;
+
+ private final AtomicReference<SettableFuture<Void>> driverBlockedFuture = new AtomicReference<>();
+
+ public DataDriver(Operator root, ISinkHandle sinkHandle, DataDriverContext driverContext) {
+ this.root = root;
+ this.sinkHandle = sinkHandle;
+ this.driverContext = driverContext;
+ this.closedFilePaths = new HashSet<>();
+ this.unClosedFilePaths = new HashSet<>();
+ // initially the driverBlockedFuture is not blocked (it is completed)
+ SettableFuture<Void> future = SettableFuture.create();
+ future.set(null);
+ driverBlockedFuture.set(future);
+ }
+
+ @Override
+ public boolean isFinished() {
+ try {
+ boolean isFinished =
+ closed || (driverBlockedFuture.get().isDone() && root != null && root.isFinished());
Review Comment:
That's true, i will fix that
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org