ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject ignite git commit: IGNITE-2751 Optimize heap memory usage for counting queries by preventing unnecessary unswapping. - Fixes #689.
Date Tue, 17 May 2016 04:04:27 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1.6 1dc1d8561 -> c9f9d24e5


IGNITE-2751 Optimize heap memory usage for counting queries by preventing unnecessary unswapping.
- Fixes #689.

Signed-off-by: Sergi Vladykin <sergi.vladykin@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c9f9d24e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c9f9d24e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c9f9d24e

Branch: refs/heads/ignite-1.6
Commit: c9f9d24e572ea68dc5066ddb0c128896dbe46838
Parents: 1dc1d85
Author: Aleksei Scherbakov <alexey.scherbakoff@gmail.com>
Authored: Tue May 17 07:02:13 2016 +0300
Committer: Sergi Vladykin <sergi.vladykin@gmail.com>
Committed: Tue May 17 07:02:13 2016 +0300

----------------------------------------------------------------------
 .../cache/query/GridCacheQueryManager.java      |  4 +++
 .../spi/indexing/IndexingQueryFilter.java       |  9 +++++++
 .../processors/query/h2/IgniteH2Indexing.java   |  4 +++
 .../query/h2/opt/GridH2IndexBase.java           | 28 ++++++++++++--------
 4 files changed, 34 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c9f9d24e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 3028208..be2a85c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -2203,6 +2203,10 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                     }
                 };
             }
+
+            @Override public boolean isValueRequired() {
+                return false;
+            }
         };
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c9f9d24e/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingQueryFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingQueryFilter.java
b/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingQueryFilter.java
index 3ba36e7..98446ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingQueryFilter.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingQueryFilter.java
@@ -31,4 +31,13 @@ public interface IndexingQueryFilter {
      * @return Predicate or {@code null} if no filtering is needed.
      */
     @Nullable public <K, V> IgniteBiPredicate<K, V> forSpace(@Nullable String
spaceName);
+
+    /**
+     * Is the value required for filtering logic?
+     * If false then null instead of value will be passed
+     * to IgniteBiPredicate returned by {@link #forSpace(String)} method.
+     *
+     * @return true if value is required for filtering, false otherwise.
+     */
+    public boolean isValueRequired();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c9f9d24e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 74d3e74..0b0fe85 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1731,6 +1731,10 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                     }
                 };
             }
+
+            @Override public boolean isValueRequired() {
+                return false;
+            }
         };
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c9f9d24e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
index fe90dec..fbf7c7c 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
@@ -156,13 +156,7 @@ public abstract class GridH2IndexBase extends BaseIndex {
 
         IndexingQueryFilter f = filters.get();
 
-        if (f != null) {
-            String spaceName = ((GridH2Table)getTable()).spaceName();
-
-            p = f.forSpace(spaceName);
-        }
-
-        return new FilteringIterator(iter, U.currentTimeMillis(), p);
+        return new FilteringIterator(iter, U.currentTimeMillis(), f);
     }
 
     /** {@inheritDoc} */
@@ -210,16 +204,28 @@ public abstract class GridH2IndexBase extends BaseIndex {
         /** */
         private final long time;
 
+        /** Is value required for filtering predicate? */
+        private final boolean isValRequired;
+
         /**
          * @param iter Iterator.
          * @param time Time for expired rows filtering.
          */
         protected FilteringIterator(Iterator<GridH2Row> iter, long time,
-            IgniteBiPredicate<Object, Object> fltr) {
+            IndexingQueryFilter qryFilter) {
             super(iter);
 
             this.time = time;
-            this.fltr = fltr;
+
+            if (qryFilter != null) {
+                this.fltr = qryFilter.forSpace(((GridH2Table)getTable()).spaceName());
+
+                this.isValRequired = qryFilter.isValueRequired();
+            } else {
+                this.fltr = null;
+
+                this.isValRequired = false;
+            }
         }
 
         /**
@@ -237,10 +243,10 @@ public abstract class GridH2IndexBase extends BaseIndex {
                 return true;
 
             Object key = row.getValue(keyCol).getObject();
-            Object val = row.getValue(valCol).getObject();
+            Object val = isValRequired ? row.getValue(valCol).getObject() : null;
 
             assert key != null;
-            assert val != null;
+            assert !isValRequired || val != null;
 
             return fltr.apply(key, val);
         }


Mime
View raw message