You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/03/19 07:45:23 UTC

[GitHub] [ignite] AMashenkov commented on a change in pull request #7071: IGNITE-12248: Apache Calcite based query execution engine.

AMashenkov commented on a change in pull request #7071: IGNITE-12248: Apache Calcite based query execution engine.
URL: https://github.com/apache/ignite/pull/7071#discussion_r394839667
 
 

 ##########
 File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ClosableIteratorsHolder.java
 ##########
 @@ -0,0 +1,164 @@
+/*
+ * 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.ignite.internal.processors.query.calcite.exec;
+
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Consumer;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class ClosableIteratorsHolder {
+    /** */
+    private final ReferenceQueue refQueue;
+
+    /** */
+    private final Map<Reference, Object> refMap;
+
+    /** */
+    private final IgniteLogger log;
+
+    /** */
+    private volatile boolean stopped;
+
+    /** */
+    private Thread cleanWorker;
+
+    /** */
+    public ClosableIteratorsHolder(IgniteLogger log) {
+        this.log = log;
+
+        refQueue = new ReferenceQueue<>();
+        refMap = new ConcurrentHashMap<>();
+    }
+
+    /**
+     * @param src Closeable iterator.
+     * @return Weak closable iterator wrapper.
+     */
+    public <T> Iterator<T> iterator(final Iterator<T> src) {
+        cleanUp(false);
+
+        return new DelegatingIterator<>(src);
+    }
+
+    /** */
+    public void init() {
+        cleanWorker = new Thread(() -> cleanUp(true));
 
 Review comment:
   Let's use named-thread here or may be GridWorker.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services