ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [37/50] [abbrv] ignite git commit: ignite-db - filter backups
Date Tue, 19 Apr 2016 12:58:54 GMT
ignite-db - filter backups


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

Branch: refs/heads/ignite-db-x-10884
Commit: a5531f6b3ed9eedb7e31534889ef0abd6f72be39
Parents: 638458e
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Thu Apr 14 02:40:38 2016 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Thu Apr 14 02:40:38 2016 +0300

----------------------------------------------------------------------
 .../query/h2/database/H2TreeIndex.java          | 38 ++++++++++++++++++--
 1 file changed, 35 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a5531f6b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
index 6867789..5960586 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
@@ -29,6 +29,8 @@ import org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
 import org.apache.ignite.internal.util.lang.GridCursor;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.spi.indexing.IndexingQueryFilter;
 import org.h2.engine.Session;
 import org.h2.index.Cursor;
 import org.h2.index.IndexType;
@@ -98,7 +100,16 @@ public class H2TreeIndex extends GridH2IndexBase {
     /** {@inheritDoc} */
     @Override public Cursor find(Session ses, SearchRow lower, SearchRow upper) {
         try {
-            return new H2Cursor(tree.find(lower, upper));
+            IndexingQueryFilter f = filters.get();
+            IgniteBiPredicate<Object,Object> p = null;
+
+            if (f != null) {
+                String spaceName = ((GridH2Table)getTable()).spaceName();
+
+                p = f.forSpace(spaceName);
+            }
+
+            return new H2Cursor(tree.find(lower, upper), p);
         }
         catch (IgniteCheckedException e) {
             throw DbException.convert(e);
@@ -180,13 +191,18 @@ public class H2TreeIndex extends GridH2IndexBase {
         /** */
         final GridCursor<GridH2Row> cursor;
 
+        /** */
+        final IgniteBiPredicate<Object,Object> filter;
+
         /**
          * @param cursor Cursor.
+         * @param filter Filter.
          */
-        private H2Cursor(GridCursor<GridH2Row> cursor) {
+        private H2Cursor(GridCursor<GridH2Row> cursor, IgniteBiPredicate<Object,Object>
filter) {
             assert cursor != null;
 
             this.cursor = cursor;
+            this.filter = filter;
         }
 
         /** {@inheritDoc} */
@@ -207,7 +223,23 @@ public class H2TreeIndex extends GridH2IndexBase {
         /** {@inheritDoc} */
         @Override public boolean next() {
             try {
-                return cursor.next();
+                while (cursor.next()) {
+                    if (filter == null)
+                        return true;
+
+                    GridH2Row row = cursor.get();
+
+                    Object key = row.getValue(0).getObject();
+                    Object val = row.getValue(1).getObject();
+
+                    assert key != null;
+                    assert val != null;
+
+                    if (filter.apply(key, val))
+                        return true;
+                }
+
+                return false;
             }
             catch (IgniteCheckedException e) {
                 throw DbException.convert(e);


Mime
View raw message