ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [10/12] ignite git commit: Review minors.
Date Wed, 22 Feb 2017 10:18:15 GMT
Review minors.


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

Branch: refs/heads/ignite-1.9
Commit: 9bc776fef537d2fb749951cbbf186e81858c11b5
Parents: de6e52b
Author: Andrey V. Mashenkov <andrey.mashenkov@gmail.com>
Authored: Tue Feb 21 19:25:14 2017 +0300
Committer: Andrey V. Mashenkov <andrey.mashenkov@gmail.com>
Committed: Tue Feb 21 19:29:59 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    |  2 +-
 .../query/h2/opt/GridH2SpatialIndex.java        | 23 +++-------
 .../h2/GridH2IndexingSegmentedGeoSelfTest.java  |  2 +
 .../query/h2/opt/GridH2IndexBase.java           | 38 ++++++++++++++++-
 .../query/h2/opt/GridH2TreeIndex.java           | 44 +-------------------
 .../query/IgniteSqlSplitterSelfTest.java        |  2 +-
 6 files changed, 46 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9bc776fe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index c3e3f3b..50e1379 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -270,7 +270,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             cfg.setBackups(Integer.MAX_VALUE);
 
         if( cfg.getQueryParallelism() > 1 && cfg.getCacheMode() != PARTITIONED)
-            throw new IgniteCheckedException("Cache index segmentation is supported for PARTITIONED
mode only.");
+            throw new IgniteCheckedException("Segmented indices are supported for PARTITIONED
mode only.");
 
         if (cfg.getAffinityMapper() == null)
             cfg.setAffinityMapper(cacheObjCtx.defaultAffMapper());

http://git-wip-us.apache.org/repos/asf/ignite/blob/9bc776fe/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
b/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
index 096b82d..c3a1362 100644
--- a/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
+++ b/modules/geospatial/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2SpatialIndex.java
@@ -121,6 +121,8 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
 
         for (int i = 0; i < segmentsCnt; i++)
             segments[i] = store.openMap("spatialIndex-" + i, new MVRTreeMap.Builder<Long>());
+
+        ctx = tbl.rowDescriptor().context();
     }
 
     /**
@@ -156,13 +158,11 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
 
             assert key != null;
 
-            Long rowId = keyToId.get(key);
+            final int seg = segmentForRow(row);
 
-            int seg;
+            Long rowId = keyToId.get(key);
 
             if (rowId != null) {
-                seg = segmentForRowID(rowId);
-
                 Long oldRowId = segments[seg].remove(getEnvelope(idToRow.get(rowId), rowId));
 
                 assert rowId.equals(oldRowId);
@@ -170,8 +170,6 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
             else {
                 rowId = ++rowIds;
 
-                seg = segmentForRowID(rowId);
-
                 keyToId.put(key, rowId);
             }
 
@@ -190,17 +188,6 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
     }
 
     /**
-     * @param id Row ID.
-     *
-     * @return Segment ID for given row ID.
-     */
-    private int segmentForRowID(Long id) {
-        assert id != null;
-
-        return (int)(id % segmentsCount());
-    }
-
-    /**
      * @param row Row.
      * @param rowId Row id.
      * @return Envelope.
@@ -235,7 +222,7 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
 
             assert oldRow != null;
 
-            int seg = segmentForRowID(rowId);
+            final int seg = segmentForRow(row);
 
             if (!segments[seg].remove(getEnvelope(row, rowId), rowId))
                 throw DbException.throwInternalError("row not found");

http://git-wip-us.apache.org/repos/asf/ignite/blob/9bc776fe/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingSegmentedGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingSegmentedGeoSelfTest.java
b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingSegmentedGeoSelfTest.java
index b806321..e404f38 100644
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingSegmentedGeoSelfTest.java
+++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingSegmentedGeoSelfTest.java
@@ -27,4 +27,6 @@ public class GridH2IndexingSegmentedGeoSelfTest extends GridH2IndexingGeoSelfTes
     @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
         return super.cacheConfiguration(gridName).setQueryParallelism(7);
     }
+
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9bc776fe/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 31057c7..fc5eb4b 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
@@ -43,6 +43,7 @@ import org.apache.ignite.internal.GridTopic;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.managers.communication.GridIoPolicy;
 import org.apache.ignite.internal.managers.communication.GridMessageListener;
+import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridReservable;
 import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2IndexRangeRequest;
@@ -126,6 +127,8 @@ public abstract class GridH2IndexBase extends BaseIndex {
         }
     };
 
+    protected GridCacheContext<?, ?> ctx;
+
     /**
      * @param tbl Table.
      */
@@ -133,6 +136,8 @@ public abstract class GridH2IndexBase extends BaseIndex {
         final GridH2RowDescriptor desc = tbl.rowDescriptor();
 
         if (desc != null && desc.context() != null) {
+            ctx = desc.context();
+
             GridKernalContext ctx = desc.context().kernalContext();
 
             log = ctx.log(getClass());
@@ -183,11 +188,11 @@ public abstract class GridH2IndexBase extends BaseIndex {
      * @return Index segment ID for current query context.
      */
     protected int threadLocalSegment() {
-        GridH2QueryContext qctx = GridH2QueryContext.get();
-
         if(segmentsCount() == 1)
             return 0;
 
+        GridH2QueryContext qctx = GridH2QueryContext.get();
+
         if(qctx == null)
             throw new IllegalStateException("GridH2QueryContext is not initialized.");
 
@@ -864,6 +869,35 @@ public abstract class GridH2IndexBase extends BaseIndex {
     }
 
     /**
+     * @param row Table row.
+     * @return Segment ID for given row.
+     */
+    protected int segmentForRow(SearchRow row) {
+        assert row != null;
+
+        CacheObject key;
+
+        if (ctx != null) {
+            final Value keyColValue = row.getValue(KEY_COL);
+
+            assert keyColValue != null;
+
+            final Object o = keyColValue.getObject();
+
+            if (o instanceof CacheObject)
+                key = (CacheObject)o;
+            else
+                key = ctx.toCacheKeyObject(o);
+
+            return segmentForPartition(ctx.affinity().partition(key));
+        }
+
+        assert segmentsCount() == 1;
+
+        return 0;
+    }
+
+    /**
      * Simple cursor from a single node.
      */
     private static class UnicastCursor implements Cursor {

http://git-wip-us.apache.org/repos/asf/ignite/blob/9bc776fe/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
index 80597f2..2873211 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
@@ -17,15 +17,12 @@
 
 package org.apache.ignite.internal.processors.query.h2.opt;
 
-import java.lang.reflect.Field;
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 import java.util.NavigableMap;
 import java.util.concurrent.ConcurrentNavigableMap;
 import java.util.concurrent.ConcurrentSkipListMap;
-import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.util.GridEmptyIterator;
 import org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap;
 import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeGuard;
@@ -45,8 +42,6 @@ import org.h2.table.TableFilter;
 import org.h2.value.Value;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.KEY_COL;
-
 /**
  * Base class for snapshotable segmented tree indexes.
  */
@@ -58,9 +53,6 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
     /** */
     private final boolean snapshotEnabled;
 
-    /** */
-    private final GridH2RowDescriptor desc;
-
     /**
      * Constructor with index initialization. Creates index with single segment.
      *
@@ -91,8 +83,6 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
 
         IndexColumn.mapColumns(cols, tbl);
 
-        desc = tbl.rowDescriptor();
-
         initBaseIndex(tbl, 0, name, cols,
             pk ? IndexType.createPrimaryKey(false, false) : IndexType.createNonUnique(false,
false, false));
 
@@ -106,8 +96,7 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
             if (snapshotEnabled) {
                 for (int i = 0; i < segmentsCnt; i++) {
                     segments[i] = new SnapTreeMap<GridSearchRowPointer, GridH2Row>(this)
{
-                        @Override
-                        protected void afterNodeUpdate_nl(Node<GridSearchRowPointer, GridH2Row>
node, Object val) {
+                        @Override protected void afterNodeUpdate_nl(Node<GridSearchRowPointer,
GridH2Row> node, Object val) {
                             if (val != null)
                                 node.key = (GridSearchRowPointer)val;
                         }
@@ -426,37 +415,6 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
     }
 
     /**
-     * @param row Table row.
-     * @return Segment ID for given row.
-     */
-    private int segmentForRow(SearchRow row) {
-        assert row != null;
-
-        CacheObject key;
-
-        if (desc != null && desc.context() != null) {
-            GridCacheContext<?, ?> ctx = desc.context();
-
-            assert ctx != null;
-
-            final Value keyColValue = row.getValue(KEY_COL);
-
-            assert keyColValue != null;
-
-            final Object o = keyColValue.getObject();
-
-            if (o instanceof CacheObject)
-                key = (CacheObject)o;
-            else
-                key = ctx.toCacheKeyObject(o);
-
-            return segmentForPartition(ctx.affinity().partition(key));
-        }
-        else
-            return 0;
-    }
-
-    /**
      * Comparable row with bias. Will be used for queries to have correct bounds (in case
of multicolumn index
      * and query on few first columns we will multiple equal entries in tree).
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9bc776fe/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index 37dea47..69f66a5 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -824,7 +824,7 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest
{
 
                 return null;
             }
-        }, CacheException.class, "Cache index segmentation is supported for PARTITIONED mode
only.");
+        }, CacheException.class, " Segmented indices are supported for PARTITIONED mode only.");
     }
 
     /**


Mime
View raw message