IGNITE-5993: Removed unused SQL-related classes and methods (old tree index, 
snapshots, etc). This closes #2414.


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

Branch: refs/heads/ignite-5872
Commit: ebed404bd1932fc8a937ce34140e5a2fd69f5f59
Parents: 870ecf8
Author: devozerov <voze...@gridgain.com>
Authored: Wed Aug 9 11:47:58 2017 +0300
Committer: devozerov <voze...@gridgain.com>
Committed: Wed Aug 9 11:47:58 2017 +0300

----------------------------------------------------------------------
 .../query/h2/opt/GridH2SpatialIndex.java        |   7 -
 .../processors/query/h2/H2RowDescriptor.java    |  11 -
 .../processors/query/h2/H2TableEngine.java      |   4 +-
 .../query/h2/database/H2PkHashIndex.java        |   7 -
 .../query/h2/database/H2TreeIndex.java          |  26 -
 .../query/h2/opt/GridH2IndexBase.java           |  93 +--
 .../query/h2/opt/GridH2QueryContext.java        |  59 --
 .../query/h2/opt/GridH2RowDescriptor.java       |   5 -
 .../processors/query/h2/opt/GridH2Table.java    | 186 +-----
 .../query/h2/opt/GridH2TreeIndex.java           | 602 -------------------
 .../query/h2/twostep/GridMapQueryExecutor.java  |  25 -
 .../query/h2/opt/GridH2TableSelfTest.java       | 172 ------
 12 files changed, 7 insertions(+), 1190 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/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 9389290..d83e860 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
@@ -31,7 +31,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.query.h2.H2Cursor;
 import org.apache.ignite.internal.util.GridCursorIteratorWrapper;
-import org.apache.ignite.internal.util.IgniteTree;
 import org.apache.ignite.internal.util.lang.GridCursor;
 import org.h2.engine.Session;
 import org.h2.index.Cursor;
@@ -51,7 +50,6 @@ import org.h2.table.IndexColumn;
 import org.h2.table.TableFilter;
 import org.h2.value.Value;
 import org.h2.value.ValueGeometry;
-import org.jetbrains.annotations.Nullable;
 
 import static 
org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.KEY_COL;
 
@@ -158,11 +156,6 @@ public class GridH2SpatialIndex extends GridH2IndexBase 
implements SpatialIndex
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override protected IgniteTree doTakeSnapshot() {
-        return null; // TODO We do not support snapshots, but probably this is 
possible.
-    }
-
-    /** {@inheritDoc} */
     @Override public GridH2Row put(GridH2Row row) {
         assert row instanceof GridH2AbstractKeyValueRow : "requires key to be 
at 0";
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
index dab83d1..31f0e69 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
@@ -107,9 +107,6 @@ public class H2RowDescriptor implements GridH2RowDescriptor 
{
     private final GridUnsafeGuard guard;
 
     /** */
-    private final boolean snapshotableIdx;
-
-    /** */
     private final GridQueryProperty[] props;
 
     /** Id of user-defined key column */
@@ -170,9 +167,6 @@ public class H2RowDescriptor implements GridH2RowDescriptor 
{
 
         valueAliasColumnId =
             (type.valueFieldName() != null) ? DEFAULT_COLUMNS_COUNT + 
fieldsList.indexOf(type.valueFieldAlias()) : -1;
-
-        // Index is not snapshotable in db-x.
-        snapshotableIdx = false;
     }
 
     /** {@inheritDoc} */
@@ -382,11 +376,6 @@ public class H2RowDescriptor implements 
GridH2RowDescriptor {
     }
 
     /** {@inheritDoc} */
-    @Override public boolean snapshotableIndex() {
-        return snapshotableIdx;
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean isKeyColumn(int columnId) {
         assert columnId >= 0;
         return columnId == KEY_COL || columnId == keyAliasColumnId;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java
index 57b7ba0..6bdcc30 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java
@@ -56,8 +56,8 @@ public class H2TableEngine implements TableEngine {
      * @throws SQLException If failed.
      * @return Created table.
      */
-    public static synchronized GridH2Table createTable(Connection conn, String 
sql,
-        @Nullable GridH2RowDescriptor rowDesc, H2RowFactory rowFactory, 
H2TableDescriptor tblDesc)
+    public static synchronized GridH2Table createTable(Connection conn, String 
sql, GridH2RowDescriptor rowDesc,
+        H2RowFactory rowFactory, H2TableDescriptor tblDesc)
         throws SQLException {
         rowDesc0 = rowDesc;
         rowFactory0 = rowFactory;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java
index 2ae5868..1937a4b 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2PkHashIndex.java
@@ -30,7 +30,6 @@ import 
org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
 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.IgniteTree;
 import org.apache.ignite.internal.util.lang.GridCursor;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.spi.indexing.IndexingQueryFilter;
@@ -44,7 +43,6 @@ import org.h2.result.SortOrder;
 import org.h2.table.Column;
 import org.h2.table.IndexColumn;
 import org.h2.table.TableFilter;
-import org.jetbrains.annotations.Nullable;
 
 /**
  *
@@ -199,11 +197,6 @@ public class H2PkHashIndex extends GridH2IndexBase {
         throw new UnsupportedOperationException();
     }
 
-    /** {@inheritDoc} */
-    @Nullable @Override protected IgniteTree doTakeSnapshot() {
-        throw new AssertionError("This method must not be called for PK 
index");
-    }
-
     /**
      * Cursor.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/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 e02510f..eb579c3 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
@@ -215,25 +215,6 @@ public class H2TreeIndex extends GridH2IndexBase {
     }
 
     /** {@inheritDoc} */
-    @Override public boolean putx(GridH2Row row) {
-        try {
-            InlineIndexHelper.setCurrentInlineIndexes(inlineIdxs);
-
-            int seg = segmentForRow(row);
-
-            H2Tree tree = treeForRead(seg);
-
-            return tree.putx(row);
-        }
-        catch (IgniteCheckedException e) {
-            throw DbException.convert(e);
-        }
-        finally {
-            InlineIndexHelper.clearCurrentInlineIndexes();
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public GridH2Row remove(SearchRow row) {
         try {
             InlineIndexHelper.setCurrentInlineIndexes(inlineIdxs);
@@ -344,13 +325,6 @@ public class H2TreeIndex extends GridH2IndexBase {
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override protected IgniteTree<SearchRow, GridH2Row> 
doTakeSnapshot() {
-        int seg = threadLocalSegment();
-
-        return treeForRead(seg);
-    }
-
-    /** {@inheritDoc} */
     @Override protected H2Tree treeForRead(int segment) {
         return segments[segment];
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/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 542adf0..5d5fb56 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
@@ -22,7 +22,6 @@ import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
 import javax.cache.CacheException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteInterruptedException;
@@ -35,7 +34,6 @@ 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;
 import 
org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2IndexRangeResponse;
 import 
org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2RowMessage;
@@ -93,15 +91,6 @@ public abstract class GridH2IndexBase extends BaseIndex {
     private static final Object EXPLICIT_NULL = new Object();
 
     /** */
-    private static final AtomicLong idxIdGen = new AtomicLong();
-
-    /** */
-    protected final long idxId = idxIdGen.incrementAndGet();
-
-    /** */
-    private final ThreadLocal<Object> snapshot = new ThreadLocal<>();
-
-    /** */
     private Object msgTopic;
 
     /** */
@@ -198,16 +187,6 @@ public abstract class GridH2IndexBase extends BaseIndex {
     public abstract GridH2Row put(GridH2Row row);
 
     /**
-     * Puts row.
-     *
-     * @param row Row.
-     * @return {@code True} if replaced existing row.
-     */
-    public boolean putx(GridH2Row row) {
-        return put(row) != null;
-    }
-
-    /**
      * Remove row from index.
      *
      * @param row Row.
@@ -233,32 +212,6 @@ public abstract class GridH2IndexBase extends BaseIndex {
     public abstract GridH2Row findOne(GridH2Row row);
 
     /**
-     * Takes or sets existing snapshot to be used in current thread.
-     *
-     * @param s Optional existing snapshot to use.
-     * @param qctx Query context.
-     * @return Snapshot.
-     */
-    public final Object takeSnapshot(@Nullable Object s, GridH2QueryContext 
qctx) {
-        assert snapshot.get() == null;
-
-        if (s == null)
-            s = doTakeSnapshot();
-
-        if (s != null) {
-            if (s instanceof GridReservable && !((GridReservable)s).reserve())
-                return null;
-
-            snapshot.set(s);
-
-            if (qctx != null)
-                qctx.putSnapshot(idxId, s);
-        }
-
-        return s;
-    }
-
-    /**
      * @param ses Session.
      */
     private static void clearViewIndexCache(Session ses) {
@@ -303,38 +256,6 @@ public abstract class GridH2IndexBase extends BaseIndex {
     }
 
     /**
-     * Takes and returns actual snapshot or {@code null} if snapshots are not 
supported.
-     *
-     * @return Snapshot or {@code null}.
-     */
-    @Nullable protected abstract IgniteTree doTakeSnapshot();
-
-    /**
-     * @return Thread local snapshot.
-     */
-    @SuppressWarnings("unchecked")
-    protected <T> T threadLocalSnapshot() {
-        return (T)snapshot.get();
-    }
-
-    /**
-     * Releases snapshot for current thread.
-     */
-    public void releaseSnapshot() {
-        Object s = snapshot.get();
-
-        assert s != null;
-
-        snapshot.remove();
-
-        if (s instanceof GridReservable)
-            ((GridReservable)s).release();
-
-        if (s instanceof AutoCloseable)
-            U.closeQuiet((AutoCloseable)s);
-    }
-
-    /**
      * Filters rows from expired ones and using predicate.
      *
      * @param cursor GridCursor over rows.
@@ -498,11 +419,9 @@ public abstract class GridH2IndexBase extends BaseIndex {
 
                 if (msg.bounds() != null) {
                     // This is the first request containing all the search 
rows.
-                    IgniteTree snapshotTree = qctx.getSnapshot(idxId);
-
                     assert !msg.bounds().isEmpty() : "empty bounds";
 
-                    src = new RangeSource(msg.bounds(), msg.segment(), 
snapshotTree, qctx.filter());
+                    src = new RangeSource(msg.bounds(), msg.segment(), 
qctx.filter());
                 }
                 else {
                     // This is request to fetch next portion of data.
@@ -619,7 +538,7 @@ public abstract class GridH2IndexBase extends BaseIndex {
 
         if (isLocalQry) {
             if (partMap != null && !partMap.containsKey(cctx.localNodeId()))
-                return Collections.<SegmentKey>emptyList(); // Prevent remote 
index call for local queries.
+                return Collections.emptyList(); // Prevent remote index call 
for local queries.
 
             nodes = Collections.singletonList(cctx.localNode());
         }
@@ -1543,9 +1462,6 @@ public abstract class GridH2IndexBase extends BaseIndex {
         int curRangeId = -1;
 
         /** */
-        final IgniteTree tree;
-
-        /** */
         private final int segment;
 
         /** */
@@ -1556,18 +1472,15 @@ public abstract class GridH2IndexBase extends BaseIndex 
{
 
         /**
          * @param bounds Bounds.
-         * @param tree Snapshot.
          * @param filter Filter.
          */
         RangeSource(
             Iterable<GridH2RowRangeBounds> bounds,
             int segment,
-            IgniteTree tree,
             IndexingQueryFilter filter
         ) {
             this.segment = segment;
             this.filter = filter;
-            this.tree = tree;
             boundsIter = bounds.iterator();
         }
 
@@ -1623,7 +1536,7 @@ public abstract class GridH2IndexBase extends BaseIndex {
                 SearchRow first = toSearchRow(bounds.first());
                 SearchRow last = toSearchRow(bounds.last());
 
-                IgniteTree t = tree != null ? tree : treeForRead(segment);
+                IgniteTree t = treeForRead(segment);
 
                 iter = new CursorIteratorWrapper(doFind0(t, first, true, last, 
filter));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
index a7ee0dc..2b4e180 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
@@ -25,7 +25,6 @@ import java.util.concurrent.ConcurrentMap;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import 
org.apache.ignite.internal.processors.cache.distributed.dht.GridReservable;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.spi.indexing.IndexingQueryFilter;
@@ -51,10 +50,6 @@ public class GridH2QueryContext {
     /** */
     private volatile boolean cleared;
 
-    /** Index snapshots. */
-    @GridToStringInclude
-    private Map<Long, Object> snapshots;
-
     /** */
     private List<GridReservable> reservations;
 
@@ -248,51 +243,6 @@ public class GridH2QueryContext {
     }
 
     /**
-     * @param idxId Index ID.
-     * @param snapshot Index snapshot.
-     */
-    public void putSnapshot(long idxId, Object snapshot) {
-        assert snapshot != null;
-        assert get() == null : "need to snapshot indexes before setting query 
context for correct visibility";
-
-        if (snapshot instanceof GridReservable && 
!((GridReservable)snapshot).reserve())
-            throw new IllegalStateException("Must be already reserved 
before.");
-
-        if (snapshots == null)
-            snapshots = new HashMap<>();
-
-        if (snapshots.put(idxId, snapshot) != null)
-            throw new IllegalStateException("Index already snapshoted.");
-    }
-
-    /**
-     * Clear taken snapshots.
-     */
-    public void clearSnapshots() {
-        if (F.isEmpty(snapshots))
-            return;
-
-        for (Object snapshot : snapshots.values()) {
-            if (snapshot instanceof GridReservable)
-                ((GridReservable)snapshot).release();
-        }
-
-        snapshots = null;
-    }
-
-    /**
-     * @param idxId Index ID.
-     * @return Index snapshot or {@code null} if none.
-     */
-    @SuppressWarnings("unchecked")
-    public <T> T getSnapshot(long idxId) {
-        if (snapshots == null)
-            return null;
-
-        return (T)snapshots.get(idxId);
-    }
-
-    /**
      * @param batchLookupId Batch lookup ID.
      * @param streams Range streams.
      */
@@ -363,13 +313,6 @@ public class GridH2QueryContext {
     }
 
     /**
-     * @return If indexes were snapshotted before query execution.
-     */
-    public boolean hasIndexSnapshots() {
-        return snapshots != null;
-    }
-
-    /**
      * Sets current thread local context. This method must be called when all 
the non-volatile properties are
      * already set to ensure visibility for other threads.
      *
@@ -440,8 +383,6 @@ public class GridH2QueryContext {
     public void clearContext(boolean nodeStop) {
         cleared = true;
 
-        clearSnapshots();
-
         List<GridReservable> r = reservations;
 
         if (!nodeStop && !F.isEmpty(r)) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java
index ce73010..d273e16 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2RowDescriptor.java
@@ -154,11 +154,6 @@ public interface GridH2RowDescriptor extends 
GridOffHeapSmartPointerFactory<Grid
     public Value wrap(Object o, int type) throws IgniteCheckedException;
 
     /**
-     * @return {@code True} if index should support snapshots.
-     */
-    public boolean snapshotableIndex();
-
-    /**
      * Checks if provided column id matches key column or key alias.
      *
      * @param colId Column id.

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
index 76d0258..f76cb5f 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
@@ -22,8 +22,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReferenceArray;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -61,7 +59,6 @@ import org.jsr166.LongAdder8;
 
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static 
org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.KEY_COL;
-import static 
org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryType.MAP;
 
 /**
  * H2 Table implementation.
@@ -95,18 +92,12 @@ public class GridH2Table extends TableBase {
     private final ConcurrentMap<Session, Boolean> sessions = new 
ConcurrentHashMap8<>();
 
     /** */
-    private final AtomicReferenceArray<Object[]> actualSnapshot;
-
-    /** */
     private IndexColumn affKeyCol;
 
     /** */
     private final LongAdder8 size = new LongAdder8();
 
     /** */
-    private final boolean snapshotEnabled;
-
-    /** */
     private final H2RowFactory rowFactory;
 
     /** */
@@ -127,7 +118,7 @@ public class GridH2Table extends TableBase {
      * @param idxsFactory Indexes factory.
      * @param cctx Cache context.
      */
-    public GridH2Table(CreateTableData createTblData, @Nullable 
GridH2RowDescriptor desc, H2RowFactory rowFactory,
+    public GridH2Table(CreateTableData createTblData, GridH2RowDescriptor 
desc, H2RowFactory rowFactory,
         GridH2SystemIndexFactory idxsFactory, GridCacheContext cctx) {
         super(createTblData);
 
@@ -136,7 +127,7 @@ public class GridH2Table extends TableBase {
         this.desc = desc;
         this.cctx = cctx;
 
-        if (desc != null && desc.context() != null && 
!desc.context().customAffinityMapper()) {
+        if (desc.context() != null && !desc.context().customAffinityMapper()) {
             boolean affinityColExists = true;
 
             String affKey = desc.type().affinityKey();
@@ -186,18 +177,10 @@ public class GridH2Table extends TableBase {
         else
             idxs.add(0, new GridH2PrimaryScanIndex(this, index(0), null));
 
-        snapshotEnabled = desc == null || desc.snapshotableIndex();
-
         pkIndexPos = hasHashIndex ? 2 : 1;
 
         sysIdxsCnt = idxs.size();
 
-        final int segments = desc != null ? 
desc.context().config().getQueryParallelism() :
-            // Get index segments count from PK index. Null desc can be passed 
from tests.
-            index(pkIndexPos).segmentsCount();
-
-        actualSnapshot = snapshotEnabled ? new 
AtomicReferenceArray<Object[]>(Math.max(segments, 1)) : null;
-
         lock = new ReentrantReadWriteLock();
     }
 
@@ -259,79 +242,10 @@ public class GridH2Table extends TableBase {
             throw new IllegalStateException("Table " + identifierString() + " 
already destroyed.");
         }
 
-        if (snapshotInLock()) {
-            final GridH2QueryContext qctx = GridH2QueryContext.get();
-
-            assert qctx != null;
-
-            snapshotIndexes(null, qctx.segment());
-        }
-
         return false;
     }
 
     /**
-     * @return {@code True} If we must snapshot and release index snapshots in 
{@link #lock(Session, boolean, boolean)}
-     * and {@link #unlock(Session)} methods.
-     */
-    private boolean snapshotInLock() {
-        if (!snapshotEnabled)
-            return false;
-
-        GridH2QueryContext qctx = GridH2QueryContext.get();
-
-        // On MAP queries with distributed joins we lock tables before the 
queries.
-        return qctx == null || qctx.type() != MAP || !qctx.hasIndexSnapshots();
-    }
-
-    /**
-     * @param qctx Query context.
-     * @param segment id of index segment to be snapshoted.
-     */
-    public void snapshotIndexes(GridH2QueryContext qctx, int segment) {
-        if (!snapshotEnabled)
-            return;
-
-        Object[] segmentSnapshot;
-
-        // Try to reuse existing snapshots outside of the lock.
-        for (long waitTime = 200; ; waitTime *= 2) { // Increase wait time to 
avoid starvation.
-            segmentSnapshot = actualSnapshot.get(segment);
-
-            if (segmentSnapshot != null) { // Reuse existing snapshot without 
locking.
-                segmentSnapshot = doSnapshotIndexes(segment, segmentSnapshot, 
qctx);
-
-                if (segmentSnapshot != null)
-                    return; // Reused successfully.
-            }
-
-            if (tryLock(true, waitTime))
-                break;
-        }
-
-        try {
-            ensureNotDestroyed();
-
-            // Try again inside of the lock.
-            segmentSnapshot = actualSnapshot.get(segment);
-
-            if (segmentSnapshot != null) // Try reusing.
-                segmentSnapshot = doSnapshotIndexes(segment, segmentSnapshot, 
qctx);
-
-            if (segmentSnapshot == null) { // Reuse failed, produce new 
snapshots.
-                segmentSnapshot = doSnapshotIndexes(segment,null, qctx);
-
-                assert segmentSnapshot != null;
-
-                actualSnapshot.set(segment, segmentSnapshot);
-            }
-        }
-        finally {
-            unlock(true);
-        }
-    }
-
-    /**
      * @return Table identifier.
      */
     public QueryTable identifier() {
@@ -364,27 +278,6 @@ public class GridH2Table extends TableBase {
     }
 
     /**
-     * @param exclusive Exclusive lock.
-     * @param waitMillis Milliseconds to wait for the lock.
-     * @return Whether lock was acquired.
-     */
-    private boolean tryLock(boolean exclusive, long waitMillis) {
-        Lock l = exclusive ? lock.writeLock() : lock.readLock();
-
-        try {
-            if (!l.tryLock(waitMillis, TimeUnit.MILLISECONDS))
-                return false;
-        }
-        catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-
-            throw new IgniteInterruptedException("Thread got interrupted while 
trying to acquire table lock.", e);
-        }
-
-        return true;
-    }
-
-    /**
      * Release table lock.
      *
      * @param exclusive Exclusive flag.
@@ -403,55 +296,6 @@ public class GridH2Table extends TableBase {
             throw new IllegalStateException("Table " + identifierString() + " 
already destroyed.");
     }
 
-    /**
-     * Must be called inside of write lock because when using multiple indexes 
we have to ensure that all of them have
-     * the same contents at snapshot taking time.
-     *
-     * @param segment id of index segment snapshot.
-     * @param segmentSnapshot snapshot to be reused.
-     * @param qctx Query context.
-     * @return New indexes data snapshot.
-     */
-    @SuppressWarnings("unchecked")
-    private Object[] doSnapshotIndexes(int segment, Object[] segmentSnapshot, 
GridH2QueryContext qctx) {
-        assert snapshotEnabled;
-
-        //TODO: make HashIndex snapshotable or remove it at all?
-        if (segmentSnapshot == null) // Nothing to reuse, create new snapshots.
-            segmentSnapshot = new Object[idxs.size() - pkIndexPos];
-
-        // Take snapshots on all except first which is scan.
-        for (int i = pkIndexPos, len = idxs.size(); i < len; i++) {
-            Object s = segmentSnapshot[i - pkIndexPos];
-
-            boolean reuseExisting = s != null;
-
-            if (!(idxs.get(i) instanceof GridH2IndexBase))
-                continue;
-
-            s = index(i).takeSnapshot(s, qctx);
-
-            if (reuseExisting && s == null) { // Existing snapshot was 
invalidated before we were able to reserve it.
-                // Release already taken snapshots.
-                if (qctx != null)
-                    qctx.clearSnapshots();
-
-                for (int j = pkIndexPos; j < i; j++)
-                    if ((idxs.get(j) instanceof GridH2IndexBase))
-                        index(j).releaseSnapshot();
-
-                // Drop invalidated snapshot.
-                actualSnapshot.compareAndSet(segment, segmentSnapshot, null);
-
-                return null;
-            }
-
-            segmentSnapshot[i - pkIndexPos] = s;
-        }
-
-        return segmentSnapshot;
-    }
-
     /** {@inheritDoc} */
     @Override public void close(Session ses) {
         // No-op.
@@ -525,32 +369,10 @@ public class GridH2Table extends TableBase {
         if (exclusive == null)
             return;
 
-        if (snapshotInLock())
-            releaseSnapshots();
-
         unlock(exclusive);
     }
 
     /**
-     * Releases snapshots.
-     */
-    public void releaseSnapshots() {
-        if (!snapshotEnabled)
-            return;
-
-        releaseSnapshots0(idxs);
-    }
-
-    /**
-     * @param idxs Indexes.
-     */
-    private void releaseSnapshots0(ArrayList<Index> idxs) {
-        // Release snapshots on all except first which is scan and second 
which is hash.
-        for (int i = 2, len = idxs.size(); i < len; i++)
-            ((GridH2IndexBase)idxs.get(i)).releaseSnapshot();
-    }
-
-    /**
      * Updates table for given key. If value is null then row with given key 
will be removed from table,
      * otherwise value and expiration time will be updated or new row will be 
added.
      *
@@ -700,10 +522,6 @@ public class GridH2Table extends TableBase {
                     return false;
             }
 
-            // The snapshot is not actual after update.
-            if (actualSnapshot != null)
-                actualSnapshot.set(pk.segmentForRow(row), null);
-
             return true;
         }
         finally {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/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
deleted file mode 100644
index 03fedcb..0000000
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ /dev/null
@@ -1,602 +0,0 @@
-/*
- * 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.h2.opt;
-
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.NavigableMap;
-import java.util.concurrent.ConcurrentSkipListMap;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.query.h2.H2Cursor;
-import org.apache.ignite.internal.util.GridCursorIteratorWrapper;
-import org.apache.ignite.internal.util.IgniteTree;
-import org.apache.ignite.internal.util.lang.GridCursor;
-import org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap;
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeGuard;
-import org.apache.ignite.internal.util.snaptree.SnapTreeMap;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.apache.ignite.spi.indexing.IndexingQueryFilter;
-import org.h2.engine.Session;
-import org.h2.index.Cursor;
-import org.h2.index.IndexType;
-import org.h2.index.SingleRowCursor;
-import org.h2.message.DbException;
-import org.h2.result.SearchRow;
-import org.h2.result.SortOrder;
-import org.h2.table.Column;
-import org.h2.table.IndexColumn;
-import org.h2.table.TableFilter;
-import org.h2.value.Value;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Base class for snapshotable segmented tree indexes.
- */
-@SuppressWarnings("ComparatorNotSerializable")
-public class GridH2TreeIndex extends GridH2IndexBase implements 
Comparator<GridSearchRowPointer> {
-    /** */
-    private final IgniteNavigableMapTree[] segments;
-
-    /** */
-    private final boolean snapshotEnabled;
-
-    /**
-     * Constructor with index initialization. Creates index with single 
segment.
-     *
-     * @param name Index name.
-     * @param tbl Table.
-     * @param pk If this index is primary key.
-     * @param colsList Index columns list.
-     */
-    @SuppressWarnings("unchecked")
-    public GridH2TreeIndex(String name, GridH2Table tbl, boolean pk, 
List<IndexColumn> colsList) {
-        this(name, tbl, pk, colsList, 1);
-    }
-
-    /**
-     * Constructor with index initialization.
-     *
-     * @param name Index name.
-     * @param tbl Table.
-     * @param pk If this index is primary key.
-     * @param colsList Index columns list.
-     * @param segmentsCnt Number of segments.
-     */
-    @SuppressWarnings("unchecked")
-    public GridH2TreeIndex(String name, GridH2Table tbl, boolean pk, 
List<IndexColumn> colsList, int segmentsCnt) {
-        assert segmentsCnt > 0 : segmentsCnt;
-
-        IndexColumn[] cols = colsList.toArray(new 
IndexColumn[colsList.size()]);
-
-        IndexColumn.mapColumns(cols, tbl);
-
-        initBaseIndex(tbl, 0, name, cols,
-            pk ? IndexType.createPrimaryKey(false, false) : 
IndexType.createNonUnique(false, false, false));
-
-        segments = new IgniteNavigableMapTree[segmentsCnt];
-
-        final GridH2RowDescriptor desc = tbl.rowDescriptor();
-
-        if (desc == null || desc.memory() == null) {
-            snapshotEnabled = desc == null || desc.snapshotableIndex();
-
-            if (snapshotEnabled) {
-                for (int i = 0; i < segmentsCnt; i++) {
-                    segments[i] = new IgniteNavigableMapTree(new 
SnapTreeMap<GridSearchRowPointer, GridH2Row>(this) {
-                        @Override protected void 
afterNodeUpdate_nl(Node<GridSearchRowPointer, GridH2Row> node, Object val) {
-                            if (val != null)
-                                node.key = (GridSearchRowPointer)val;
-                        }
-
-                        @Override protected Comparable<? super 
GridSearchRowPointer> comparable(Object key) {
-                            if (key instanceof ComparableRow)
-                                return (Comparable<? super SearchRow>)key;
-
-                            return super.comparable(key);
-                        }
-                    });
-                }
-            }
-            else {
-                for (int i = 0; i < segmentsCnt; i++) {
-                    segments[i] = new IgniteNavigableMapTree(
-                    new ConcurrentSkipListMap<GridSearchRowPointer, GridH2Row>(
-                        new Comparator<GridSearchRowPointer>() {
-                            @Override public int compare(GridSearchRowPointer 
o1, GridSearchRowPointer o2) {
-                                if (o1 instanceof ComparableRow)
-                                    return ((ComparableRow)o1).compareTo(o2);
-
-                                if (o2 instanceof ComparableRow)
-                                    return -((ComparableRow)o2).compareTo(o1);
-
-                                return compareRows(o1, o2);
-                            }
-                        }
-                    ));
-                }
-            }
-        }
-        else {
-            assert desc.snapshotableIndex() : desc;
-
-            snapshotEnabled = true;
-
-            for (int i = 0; i < segmentsCnt; i++) {
-                segments[i] = new IgniteNavigableMapTree(new 
GridOffHeapSnapTreeMap<GridSearchRowPointer, GridH2Row>(desc, desc, 
desc.memory(), desc.guard(), this) {
-                    @Override protected void afterNodeUpdate_nl(long node, 
GridH2Row val) {
-                        final long oldKey = keyPtr(node);
-
-                        if (val != null) {
-                            key(node, val);
-
-                            guard.finalizeLater(new Runnable() {
-                                @Override public void run() {
-                                    
desc.createPointer(oldKey).decrementRefCount();
-                                }
-                            });
-                        }
-                    }
-
-                    @Override protected Comparable<? super 
GridSearchRowPointer> comparable(Object key) {
-                        if (key instanceof ComparableRow)
-                            return (Comparable<? super SearchRow>)key;
-
-                        return super.comparable(key);
-                    }
-                });
-            }
-        }
-
-        initDistributedJoinMessaging(tbl);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteTree doTakeSnapshot() {
-        assert snapshotEnabled;
-
-        int seg = threadLocalSegment();
-
-        IgniteNavigableMapTree tree = segments[seg];
-
-        return tree.clone();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected final IgniteTree treeForRead(int seg) {
-        if (!snapshotEnabled)
-            return segments[seg];
-
-        IgniteTree res = threadLocalSnapshot();
-
-        if (res == null)
-            return segments[seg];
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void destroy() {
-        assert threadLocalSnapshot() == null;
-
-        super.destroy();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getRowCount(@Nullable Session ses) {
-        IndexingQueryFilter f = threadLocalFilter();
-
-        int seg = threadLocalSegment();
-
-        // Fast path if we don't need to perform any filtering.
-        if (f == null || f.forCache((getTable()).cacheName()) == null)
-            try {
-                return treeForRead(seg).size();
-            } catch (IgniteCheckedException e) {
-                throw DbException.convert(e);
-            }
-
-        GridCursor<GridH2Row> cursor = doFind(null, false, null);
-
-        long size = 0;
-
-        try {
-            while (cursor.next())
-                size++;
-        }
-        catch (IgniteCheckedException e) {
-            throw DbException.convert(e);
-        }
-
-        return size;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getRowCountApproximation() {
-        return table.getRowCountApproximation();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int compare(GridSearchRowPointer r1, GridSearchRowPointer 
r2) {
-        // Second row here must be data row if first is a search row.
-        return -compareRows(r2, r1);
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        SB sb = new SB((indexType.isUnique() ? "Unique index '" : "Index '") + 
getName() + "' [");
-
-        boolean first = true;
-
-        for (IndexColumn col : getIndexColumns()) {
-            if (first)
-                first = false;
-            else
-                sb.a(", ");
-
-            sb.a(col.getSQL());
-        }
-
-        sb.a(" ]");
-
-        return sb.toString();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double getCost(Session ses, int[] masks, TableFilter[] 
filters, int filter,
-        SortOrder sortOrder, HashSet<Column> cols) {
-        long rowCnt = getRowCountApproximation();
-        double baseCost = getCostRangeIndex(masks, rowCnt, filters, filter, 
sortOrder, false, cols);
-        int mul = getDistributedMultiplier(ses, filters, filter);
-
-        return mul * baseCost;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean canFindNext() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Cursor find(Session ses, @Nullable SearchRow first, 
@Nullable SearchRow last) {
-        return new H2Cursor(doFind(first, true, last), null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Cursor findNext(Session ses, SearchRow higherThan, 
SearchRow last) {
-        return new H2Cursor(doFind(higherThan, false, last), null);
-    }
-
-    /**
-     * Finds row with key equal one in given search row.
-     * WARNING!! Method call must be protected by {@link 
GridUnsafeGuard#begin()}
-     * {@link GridUnsafeGuard#end()} block.
-     *
-     * @param row Search row.
-     * @return Row.
-     */
-    @Override public GridH2Row findOne(GridH2Row row) {
-        int seg = segmentForRow(row);
-
-        return segments[seg].findOne(row);
-    }
-
-    /**
-     * Returns sub-tree bounded by given values.
-     *
-     * @param first Lower bound.
-     * @param includeFirst Whether lower bound should be inclusive.
-     * @param last Upper bound always inclusive.
-     * @return Iterator over rows in given range.
-     */
-    @SuppressWarnings("unchecked")
-    private GridCursor<GridH2Row> doFind(@Nullable SearchRow first, boolean 
includeFirst, @Nullable SearchRow last) {
-        int seg = threadLocalSegment();
-
-        IgniteTree t = treeForRead(seg);
-
-        return doFind0(t, first, includeFirst, last, threadLocalFilter());
-    }
-
-    /** {@inheritDoc} */
-    @Override protected final GridCursor<GridH2Row> doFind0(
-        IgniteTree t,
-        @Nullable SearchRow first,
-        boolean includeFirst,
-        @Nullable SearchRow last,
-        IndexingQueryFilter filter
-    ) {
-        includeFirst &= first != null;
-
-        GridCursor<GridH2Row> range = subTree(t, comparable(first, 
includeFirst ? -1 : 1),
-            comparable(last, 1));
-
-        if (range == null)
-            return EMPTY_CURSOR;
-
-        return filter(range, filter);
-    }
-
-    /**
-     * @param row Row.
-     * @param bias Bias.
-     * @return Comparable row.
-     */
-    private GridSearchRowPointer comparable(SearchRow row, int bias) {
-        if (row == null)
-            return null;
-
-        if (bias == 0 && row instanceof GridH2Row)
-            return (GridSearchRowPointer)row;
-
-        return new ComparableRow(row, bias);
-    }
-
-    /**
-     * Takes sup-map from given one.
-     *
-     * @param tree Tree.
-     * @param first Lower bound.
-     * @param last Upper bound.
-     * @return Sub-map.
-     */
-    @SuppressWarnings({"IfMayBeConditional", "TypeMayBeWeakened"})
-    private GridCursor<GridH2Row> subTree(IgniteTree tree,
-        @Nullable GridSearchRowPointer first, @Nullable GridSearchRowPointer 
last) {
-
-        if (first != null && last != null && compare(first, last) > 0)
-            return null;
-
-        try {
-            // We take exclusive bounds because it is possible that one search 
row will be equal to multiple key rows
-            // in tree and we must return them all.
-            return tree.find(first, last);
-        }
-        catch (IgniteCheckedException e) {
-            throw DbException.convert(e);
-        }
-    }
-
-    /**
-     * Gets iterator over all rows in this index.
-     *
-     * @return Rows iterator.
-     */
-    GridCursor<GridH2Row> rows() {
-        return doFind(null, false, null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean canGetFirstOrLast() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Cursor findFirstOrLast(Session ses, boolean first) {
-        try {
-            int seg = threadLocalSegment();
-
-            IgniteTree t = treeForRead(seg);
-
-            GridH2Row row = (GridH2Row)(first ? t.findFirst() : t.findLast());
-
-            return new SingleRowCursor(row);
-        }
-        catch (IgniteCheckedException e) {
-            throw DbException.convert(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridH2Row put(GridH2Row row) {
-        int seg = segmentForRow(row);
-
-        return segments[seg].put(row);
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridH2Row remove(SearchRow row) {
-        GridSearchRowPointer comparable = comparable(row, 0);
-
-        int seg = segmentForRow(row);
-
-        return segments[seg].remove(comparable);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected int segmentsCount() {
-        return segments.length;
-    }
-
-    /**
-     * 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).
-     */
-    private final class ComparableRow implements GridSearchRowPointer, 
Comparable<SearchRow> {
-        /** */
-        private final SearchRow row;
-
-        /** */
-        private final int bias;
-
-        /**
-         * @param row Row.
-         * @param bias Bias.
-         */
-        private ComparableRow(SearchRow row, int bias) {
-            this.row = row;
-            this.bias = bias;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int compareTo(SearchRow o) {
-            int res = compareRows(o, row);
-
-            if (res == 0)
-                return bias;
-
-            return -res;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object obj) {
-            throw new IllegalStateException("Should never be called.");
-        }
-
-        /** {@inheritDoc} */
-        @Override public int getColumnCount() {
-            return row.getColumnCount();
-        }
-
-        /** {@inheritDoc} */
-        @Override public Value getValue(int idx) {
-            return row.getValue(idx);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void setValue(int idx, Value v) {
-            row.setValue(idx, v);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void setKeyAndVersion(SearchRow old) {
-            row.setKeyAndVersion(old);
-        }
-
-        /** {@inheritDoc} */
-        @Override public int getVersion() {
-            return row.getVersion();
-        }
-
-        /** {@inheritDoc} */
-        @Override public void setKey(long key) {
-            row.setKey(key);
-        }
-
-        /** {@inheritDoc} */
-        @Override public long getKey() {
-            return row.getKey();
-        }
-
-        /** {@inheritDoc} */
-        @Override public int getMemory() {
-            return row.getMemory();
-        }
-
-        /** {@inheritDoc} */
-        @Override public long pointer() {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public void incrementRefCount() {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public void decrementRefCount() {
-            throw new IllegalStateException();
-        }
-    }
-
-    /**
-     * Adapter from {@link NavigableMap} to {@link IgniteTree}.
-     */
-    private static final class IgniteNavigableMapTree implements 
IgniteTree<GridSearchRowPointer, GridH2Row>, Cloneable {
-        /** Tree. */
-        private final NavigableMap<GridSearchRowPointer, GridH2Row> tree;
-
-        /**
-         * @param tree Tree.
-         */
-        private IgniteNavigableMapTree(NavigableMap<GridSearchRowPointer, 
GridH2Row> tree) {
-            this.tree = tree;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void invoke(GridSearchRowPointer key, Object x, 
InvokeClosure<GridH2Row> c) {
-            throw new UnsupportedOperationException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public GridH2Row put(GridH2Row val) {
-            return tree.put(val, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public GridH2Row findOne(GridSearchRowPointer key) {
-            return tree.get(key);
-        }
-
-        /** {@inheritDoc} */
-        @Override public GridCursor<GridH2Row> find(GridSearchRowPointer 
lower, GridSearchRowPointer upper)
-            throws IgniteCheckedException {
-
-            Collection<GridH2Row> rows;
-
-            if (lower == null && upper == null)
-                rows = tree.values();
-            else if (lower != null && upper == null)
-                rows = tree.tailMap(lower).values();
-            else if (lower == null)
-                rows = tree.headMap(upper).values();
-            else
-                rows = tree.subMap(lower, false, upper, false).values();
-
-            return new GridCursorIteratorWrapper<>(rows.iterator());
-        }
-
-        /** {@inheritDoc} */
-        @Override public GridH2Row findFirst() throws IgniteCheckedException {
-            Map.Entry<GridSearchRowPointer, GridH2Row> first = 
tree.firstEntry();
-            return (first == null) ? null : first.getValue();
-        }
-
-        /** {@inheritDoc} */
-        @Override public GridH2Row findLast() throws IgniteCheckedException {
-            Map.Entry<GridSearchRowPointer, GridH2Row> last = tree.lastEntry();
-            return (last == null) ? null : last.getValue();
-        }
-
-        /** {@inheritDoc} */
-        @Override public GridH2Row remove(GridSearchRowPointer key) {
-            return tree.remove(key);
-        }
-
-        /** {@inheritDoc} */
-        @Override public long size() {
-            return tree.size();
-        }
-
-        /** {@inheritDoc} */
-        @Override public IgniteNavigableMapTree clone() {
-            IgniteNavigableMapTree cp;
-
-            try {
-                cp = (IgniteNavigableMapTree)super.clone();
-            }
-            catch (final CloneNotSupportedException e) {
-                throw DbException.convert(e);
-            }
-
-            return new IgniteNavigableMapTree(cp.tree);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index 19b628b..e717367 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -26,7 +26,6 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentMap;
@@ -59,7 +58,6 @@ import 
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
 import org.apache.ignite.internal.processors.query.h2.opt.DistributedJoinMode;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryContext;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2RetryException;
-import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
 import 
org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest;
 import 
org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse;
 import 
org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest;
@@ -545,22 +543,6 @@ public class GridMapQueryExecutor {
                 .topologyVersion(topVer)
                 .reservations(reserved);
 
-            List<GridH2Table> snapshotedTbls = null;
-
-            if (!F.isEmpty(tbls)) {
-                snapshotedTbls = new ArrayList<>(tbls.size());
-
-                for (QueryTable tbl : tbls) {
-                    GridH2Table h2Tbl = h2.dataTable(tbl);
-
-                    Objects.requireNonNull(h2Tbl, tbl.toString());
-
-                    h2Tbl.snapshotIndexes(qctx, segmentId);
-
-                    snapshotedTbls.add(h2Tbl);
-                }
-            }
-
             Connection conn = h2.connectionForSchema(schemaName);
 
             H2Utils.setupConnection(conn, distributedJoinMode != OFF, 
enforceJoinOrder);
@@ -596,8 +578,6 @@ public class GridMapQueryExecutor {
                             qr.queryCancel(qryIdx));
 
                         if (evt) {
-                            assert mainCctx != null;
-
                             ctx.event().record(new CacheQueryExecutedEvent<>(
                                 node,
                                 "SQL query executed.",
@@ -635,11 +615,6 @@ public class GridMapQueryExecutor {
 
                 if (distributedJoinMode == OFF)
                     qctx.clearContext(false);
-
-                if (!F.isEmpty(snapshotedTbls)) {
-                    for (GridH2Table dataTbl : snapshotedTbls)
-                        dataTbl.releaseSnapshots();
-                }
             }
         }
         catch (Throwable e) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebed404b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
index 88ff61e..a1a64e8 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
@@ -18,38 +18,20 @@
 package org.apache.ignite.internal.processors.query.h2.opt;
 
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashSet;
 import java.util.Random;
-import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.query.h2.database.H2PkHashIndex;
-import org.apache.ignite.internal.processors.query.h2.database.H2RowFactory;
-import org.apache.ignite.internal.util.lang.GridCursor;
-import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.h2.Driver;
-import org.h2.index.Cursor;
-import org.h2.index.Index;
-import org.h2.result.Row;
-import org.h2.result.SearchRow;
-import org.h2.result.SortOrder;
-import org.h2.table.IndexColumn;
 import org.h2.value.ValueLong;
 import org.h2.value.ValueString;
 import org.h2.value.ValueTimestamp;
 import org.h2.value.ValueUuid;
-import org.jetbrains.annotations.Nullable;
 
 /**
  * Tests H2 Table.
@@ -173,47 +155,6 @@ public class GridH2TableSelfTest extends 
GridCommonAbstractTest {
             assertEquals(MAX_X, idx.getRowCount(null));
         }
 
-        // Check correct rows order.
-        checkOrdered((GridH2TreeIndex)tbl.indexes().get(0), new 
Comparator<SearchRow>() {
-            @Override public int compare(SearchRow o1, SearchRow o2) {
-                UUID id1 = (UUID)o1.getValue(0).getObject();
-                UUID id2 = (UUID)o2.getValue(0).getObject();
-
-                return id1.compareTo(id2);
-            }
-        });
-
-        checkOrdered((GridH2TreeIndex)tbl.indexes().get(1), new 
Comparator<SearchRow>() {
-            @Override public int compare(SearchRow o1, SearchRow o2) {
-                Long x1 = (Long)o1.getValue(3).getObject();
-                Long x2 = (Long)o2.getValue(3).getObject();
-
-                int c = x2.compareTo(x1);
-
-                if (c != 0)
-                    return c;
-
-                Timestamp t1 = (Timestamp)o1.getValue(1).getObject();
-                Timestamp t2 = (Timestamp)o2.getValue(1).getObject();
-
-                return t1.compareTo(t2);
-            }
-        });
-
-        checkOrdered((GridH2TreeIndex)tbl.indexes().get(2), new 
Comparator<SearchRow>() {
-            @Override public int compare(SearchRow o1, SearchRow o2) {
-                String s1 = (String)o1.getValue(2).getObject();
-                String s2 = (String)o2.getValue(2).getObject();
-
-                return s2.compareTo(s1);
-            }
-        });
-
-        // Indexes data consistency.
-        ArrayList<? extends Index> idxs = tbl.indexes();
-
-        checkIndexesConsistent((ArrayList<Index>)idxs, null);
-
         // Check unique index.
         UUID id = UUID.randomUUID();
         UUID id2 = UUID.randomUUID();
@@ -405,54 +346,6 @@ public class GridH2TableSelfTest extends 
GridCommonAbstractTest {
 
 
     /**
-     * @throws Exception If failed.
-     */
-    public void testIndexFindFirstOrLast() throws Exception {
-        Index index = tbl.getIndexes().get(2);
-        assertTrue(index instanceof GridH2TreeIndex);
-        assertTrue(index.canGetFirstOrLast());
-
-        //find first on empty data
-        Cursor cursor = index.findFirstOrLast(null, true);
-        assertFalse(cursor.next());
-        assertNull(cursor.get());
-
-        //find last on empty data
-        cursor = index.findFirstOrLast(null, false);
-        assertFalse(cursor.next());
-        assertNull(cursor.get());
-
-        //fill with data
-        int rows = 100;
-        long t = System.currentTimeMillis();
-        Random rnd = new Random();
-        UUID min = null;
-        UUID max = null;
-
-        for (int i = 0 ; i < rows; i++) {
-            UUID id = UUID.randomUUID();
-            if (min == null || id.compareTo(min) < 0)
-                min = id;
-            if (max == null || id.compareTo(max) > 0)
-                max = id;
-            GridH2Row row = row(id, t++, id.toString(), rnd.nextInt(100));
-            ((GridH2TreeIndex)index).put(row);
-        }
-
-        //find first
-        cursor = index.findFirstOrLast(null, true);
-        assertTrue(cursor.next());
-        assertEquals(min, cursor.get().getValue(0).getObject());
-        assertFalse(cursor.next());
-
-        //find last
-        cursor = index.findFirstOrLast(null, false);
-        assertTrue(cursor.next());
-        assertEquals(max, cursor.get().getValue(0).getObject());
-        assertFalse(cursor.next());
-    }
-
-    /**
      * Check query plan to correctly select index.
      *
      * @param conn Connection.
@@ -473,69 +366,4 @@ public class GridH2TableSelfTest extends 
GridCommonAbstractTest {
             }
         }
     }
-
-    /**
-     * @param idxs Indexes.
-     * @param rowSet Rows.
-     * @return Rows.
-     */
-    private Set<Row> checkIndexesConsistent(ArrayList<Index> idxs, @Nullable 
Set<Row> rowSet) throws IgniteCheckedException {
-        for (Index idx : idxs) {
-            if (!(idx instanceof GridH2TreeIndex))
-                continue;
-
-            Set<Row> set = new HashSet<>();
-
-            GridCursor<GridH2Row> cursor = ((GridH2TreeIndex)idx).rows();
-
-            while(cursor.next())
-                assertTrue(set.add(cursor.get()));
-
-            //((GridH2SnapTreeSet)((GridH2Index)idx).tree).print();
-
-            if (rowSet == null || rowSet.isEmpty())
-                rowSet = set;
-            else
-                assertEquals(rowSet, set);
-        }
-
-        return rowSet;
-    }
-
-    /**
-     * @param idxs Indexes list.
-     */
-    private void checkOrdered(ArrayList<Index> idxs) throws 
IgniteCheckedException {
-        for (Index idx : idxs) {
-            if (!(idx instanceof GridH2TreeIndex))
-                continue;
-
-            GridH2TreeIndex h2Idx = (GridH2TreeIndex)idx;
-
-            checkOrdered(h2Idx, h2Idx);
-        }
-    }
-
-    /**
-     * @param idx Index.
-     * @param cmp Comparator.
-     */
-    private void checkOrdered(GridH2TreeIndex idx, Comparator<? super 
GridH2Row> cmp) throws IgniteCheckedException {
-        GridCursor<GridH2Row> cursor = idx.rows();
-
-        GridH2Row min = null;
-
-        while (cursor.next()) {
-            GridH2Row row = cursor.get();
-
-            System.out.println(row);
-
-            assertNotNull(row);
-
-            assertFalse("Incorrect row order in index: " + idx + "\n min: " + 
min + "\n row: " + row,
-                min != null && cmp.compare(min, row) > 0);
-
-            min = row;
-        }
-    }
 }
\ No newline at end of file

Reply via email to