ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [1/4] ignite git commit: IGNITE-6331: Removed unused SQL-related code and fixed warnings. This closes #2760.
Date Wed, 27 Sep 2017 09:24:08 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 7f8234018 -> 4a095674e


http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
deleted file mode 100644
index 499d258..0000000
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
+++ /dev/null
@@ -1,454 +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.lang.ref.WeakReference;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.concurrent.TimeUnit;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteInterruptedException;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.h2.message.DbException;
-import org.h2.result.Row;
-import org.h2.result.SearchRow;
-import org.h2.value.CompareMode;
-import org.h2.value.Value;
-import org.h2.value.ValueNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Table row implementation based on {@link GridQueryTypeDescriptor}.
- */
-public abstract class GridH2AbstractKeyValueRow extends GridH2Row {
-    /** */
-    public static final int DEFAULT_COLUMNS_COUNT = 3;
-
-    /** Key column. */
-    public static final int KEY_COL = 0;
-
-    /** Value column. */
-    public static final int VAL_COL = 1;
-
-    /** Version column. */
-    public static final int VER_COL = 2;
-
-    /** */
-    protected final GridH2RowDescriptor desc;
-
-    /** */
-    @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
-    protected long expirationTime;
-
-    /** */
-    private Value key;
-
-    /** */
-    private volatile Value val;
-
-    /** */
-    private Value[] valCache;
-
-    /** */
-    private Value version;
-
-    /**
-     * Constructor.
-     *
-     * @param desc Row descriptor.
-     * @param key Key.
-     * @param keyType Key type.
-     * @param val Value.
-     * @param valType Value type.
-     * @param expirationTime Expiration time.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected GridH2AbstractKeyValueRow(GridH2RowDescriptor desc, Object key, int keyType, @Nullable Object val,
-                                        int valType, GridCacheVersion ver, long expirationTime) throws IgniteCheckedException {
-        this.desc = desc;
-        this.expirationTime = expirationTime;
-
-        setValue(KEY_COL, desc.wrap(key, keyType));
-
-        if (val != null) // We remove by key only, so value can be null here.
-            setValue(VAL_COL, desc.wrap(val, valType));
-
-        if (ver != null)
-            setValue(VER_COL, desc.wrap(ver, Value.JAVA_OBJECT));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Value[] getValueList() {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * Protected constructor for {@link GridH2KeyValueRowOffheap}
-     *
-     * @param desc Row descriptor.
-     */
-    protected GridH2AbstractKeyValueRow(GridH2RowDescriptor desc) {
-        this.desc = desc;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long expireTime() {
-        return expirationTime;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getColumnCount() {
-        return DEFAULT_COLUMNS_COUNT + desc.fieldsCount();
-    }
-
-    /**
-     * Atomically updates weak value.
-     *
-     * @param valObj New value.
-     * @return New value if old value is empty, old value otherwise.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected synchronized Value updateWeakValue(Object valObj) throws IgniteCheckedException {
-        Value res = peekValue(VAL_COL);
-
-        if (res != null && !(res instanceof WeakValue))
-            return res;
-
-        Value upd = desc.wrap(valObj, desc.valueType());
-
-        setValue(VAL_COL, new WeakValue(upd));
-
-        notifyAll();
-
-        return upd;
-    }
-
-    /**
-     * @param waitTime Time to await for value unswap.
-     * @return Synchronized value.
-     */
-    protected synchronized Value syncValue(long waitTime) {
-        Value v = peekValue(VAL_COL);
-
-        while (v == null && waitTime > 0) {
-            long start = System.nanoTime(); // This call must be quite rare, so performance is not a concern.
-
-            try {
-                wait(waitTime); // Wait for value arrival to allow other threads to make a progress.
-            }
-            catch (InterruptedException e) {
-                throw new IgniteInterruptedException(e);
-            }
-
-            long t = System.nanoTime() - start;
-
-            if (t > 0)
-                waitTime -= TimeUnit.NANOSECONDS.toMillis(t);
-
-            v = peekValue(VAL_COL);
-        }
-
-        return v;
-    }
-
-    /**
-     * @param col Column index.
-     * @return Value if exists.
-     */
-    protected final Value peekValue(int col) {
-        if (col == KEY_COL)
-            return key;
-        if (col == VAL_COL)
-            return val;
-
-        assert col == VER_COL;
-        return version;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Value getValue(int col) {
-        Value[] vCache = valCache;
-
-        if (vCache != null) {
-            Value v = vCache[col];
-
-            if (v != null)
-                return v;
-        }
-
-        Value v;
-
-        if (desc.isValueColumn(col)) {
-            v = peekValue(VAL_COL);
-
-            assert !(v instanceof WeakValue) : v;
-            return v;
-        }
-        else if (desc.isKeyColumn(col)) {
-            v = peekValue(KEY_COL);
-
-            if (v == null) {
-                v = getOffheapValue(KEY_COL);
-
-                assert v != null;
-
-                setValue(KEY_COL, v);
-
-                if (peekValue(VAL_COL) == null)
-                    cache();
-            }
-
-            assert !(v instanceof WeakValue) : v;
-            return v;
-        }
-        else if (col == VER_COL)
-            return version;
-
-        col -= DEFAULT_COLUMNS_COUNT;
-
-        assert col >= 0;
-
-        Value key = getValue(KEY_COL);
-        Value val = getValue(VAL_COL);
-
-        assert key != null;
-        assert val != null;
-
-        Object res = desc.columnValue(key.getObject(), val.getObject(), col);
-
-        if (res == null)
-            v = ValueNull.INSTANCE;
-        else {
-            try {
-                v = desc.wrap(res, desc.fieldType(col));
-            }
-            catch (IgniteCheckedException e) {
-                throw DbException.convert(e);
-            }
-        }
-
-        if (vCache != null)
-            vCache[col + DEFAULT_COLUMNS_COUNT] = v;
-
-        return v;
-    }
-
-    /**
-     * @param valCache Value cache.
-     */
-    public void valuesCache(Value[] valCache) {
-        if (valCache != null) {
-            desc.initValueCache(valCache, key, val, version);
-        }
-
-        this.valCache = valCache;
-    }
-
-    /**
-     * Caches this row for reuse.
-     */
-    protected abstract void cache();
-
-    /**
-     * @param col Column.
-     * @return Value read from offheap memory or null if it is impossible.
-     */
-    protected abstract Value getOffheapValue(int col);
-
-    /**
-     * Adds offheap row ID.
-     */
-    protected void addOffheapRowId(SB sb) {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        SB sb = new SB("Row@");
-
-        sb.a(Integer.toHexString(System.identityHashCode(this)));
-
-        addOffheapRowId(sb);
-
-        Value v = peekValue(KEY_COL);
-        sb.a("[ key: ").a(v == null ? "nil" : v.getString());
-
-        v = WeakValue.unwrap(peekValue(VAL_COL));
-        sb.a(", val: ").a(v == null ? "nil" : v.getString());
-
-        v = peekValue(VER_COL);
-        sb.a(", ver: ").a(v == null ? "nil" : v.getString());
-
-        sb.a(" ][ ");
-
-        if (v != null) {
-            for (int i = DEFAULT_COLUMNS_COUNT, cnt = getColumnCount(); i < cnt; i++) {
-                v = getValue(i);
-
-                if (i != DEFAULT_COLUMNS_COUNT)
-                    sb.a(", ");
-
-                if (!desc.isKeyValueOrVersionColumn(i))
-                    sb.a(v == null ? "nil" : v.getString());
-            }
-        }
-
-        sb.a(" ]");
-
-        return sb.toString();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setKeyAndVersion(SearchRow old) {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setKey(long key) {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Row getCopy() {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setDeleted(boolean deleted) {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getKey() {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setSessionId(int sesId) {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setVersion(int ver) {
-        throw new IllegalStateException();
-    }
-
-    /**
-     * Weak reference to value that was swapped but accessed in indexing SPI.
-     */
-    private static class WeakValue extends Value {
-        /**
-         * Unwraps value.
-         *
-         * @param v Value.
-         * @return Unwrapped value.
-         */
-        static Value unwrap(Value v) {
-            return (v instanceof WeakValue) ? ((WeakValue)v).get() : v;
-        }
-
-        /** */
-        private final WeakReference<Value> ref;
-
-        /**
-         * @param v Value.
-         */
-        private WeakValue(Value v) {
-            ref = new WeakReference<>(v);
-        }
-
-        /**
-         * @return Referenced value.
-         */
-        public Value get() {
-            return ref.get();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String getSQL() {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public int getType() {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public long getPrecision() {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public int getDisplaySize() {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String getString() {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object getObject() {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public void set(PreparedStatement preparedStatement, int i) throws SQLException {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override protected int compareSecure(Value val, CompareMode compareMode) {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            throw new IllegalStateException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            throw new IllegalStateException();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setValue(int idx, Value v) {
-        if (desc.isValueColumn(idx))
-            val = v;
-        else if (idx == VER_COL)
-            version = v;
-        else {
-            assert desc.isKeyColumn(idx) : idx + " " + v;
-
-            key = v;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public final int hashCode() {
-        throw new IllegalStateException();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java
index 5cb983c..800a2aa 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java
@@ -237,22 +237,9 @@ public final class GridH2CollocationModel {
     }
 
     /**
-     * @param i Index.
-     * @param f Table filter.
-     * @return {@code true} If the child is not a table or view.
-     */
-    private boolean isChildTableOrView(int i, TableFilter f) {
-        if (f == null)
-            f = childFilters[i];
-
-        Table t = f.getTable();
-
-        return t.isView() || t instanceof GridH2Table;
-    }
-
-    /**
      * Do the needed calculations.
      */
+    @SuppressWarnings("ConstantConditions")
     private void calculate() {
         if (type != null)
             return;
@@ -369,6 +356,7 @@ public final class GridH2CollocationModel {
      * @param f Current filter.
      * @return {@code true} If previous table is REPLICATED.
      */
+    @SuppressWarnings("SimplifiableIfStatement")
     private boolean previousReplicated(int f) {
         if (f > 0 && child(f - 1, true).type(true) == Type.REPLICATED)
             return true;
@@ -380,6 +368,7 @@ public final class GridH2CollocationModel {
      * @param f Filter.
      * @return Affinity join type.
      */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     private Affinity joinedWithCollocated(int f) {
         TableFilter tf = childFilters[f];
 
@@ -530,6 +519,7 @@ public final class GridH2CollocationModel {
      * @param withUnion With respect to union.
      * @return Multiplier.
      */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     private int multiplier(boolean withUnion) {
         calculate();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/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 919ff58..6568f13 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
@@ -72,8 +72,8 @@ import static java.util.Collections.emptyIterator;
 import static java.util.Collections.singletonList;
 import static org.apache.ignite.internal.processors.query.h2.opt.DistributedJoinMode.LOCAL_ONLY;
 import static org.apache.ignite.internal.processors.query.h2.opt.DistributedJoinMode.OFF;
-import static org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.KEY_COL;
-import static org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.VAL_COL;
+import static org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap.KEY_COL;
+import static org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap.VAL_COL;
 import static org.apache.ignite.internal.processors.query.h2.opt.GridH2CollocationModel.buildCollocationModel;
 import static org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryType.MAP;
 import static org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryType.PREPARE;
@@ -206,14 +206,6 @@ public abstract class GridH2IndexBase extends BaseIndex {
     }
 
     /**
-     * Finds a single row by the given row.
-     *
-     * @param row Search row.
-     * @return Search result.
-     */
-    public abstract GridH2Row findOne(GridH2Row row);
-
-    /**
      * @param ses Session.
      */
     private static void clearViewIndexCache(Session ses) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
deleted file mode 100644
index 3d92777..0000000
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
+++ /dev/null
@@ -1,328 +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.concurrent.locks.Lock;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.util.GridStripedLock;
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.h2.store.Data;
-import org.h2.value.Value;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Offheap row.
- */
-public class GridH2KeyValueRowOffheap extends GridH2AbstractKeyValueRow {
-    /** */
-    private static final GridStripedLock lock;
-
-    /**
-     * Init locks.
-     */
-    static {
-        int cpus = Runtime.getRuntime().availableProcessors();
-
-        lock = new GridStripedLock(cpus * cpus * 8);
-    }
-
-    /** */
-    private static final int OFFSET_KEY_SIZE = 4; // 4 after ref cnt int
-
-    /** */
-    private static final int OFFSET_VALUE_REF = OFFSET_KEY_SIZE + 4; // 8
-
-    /** */
-    private static final int OFFSET_EXPIRATION = OFFSET_VALUE_REF + 8; // 16
-
-    /** */
-    private static final int OFFSET_KEY = OFFSET_EXPIRATION + 8; // 24
-
-    /** */
-    private static final int OFFSET_VALUE = 4; // 4 on separate page after val size int
-
-    /** */
-    private static final Data SIZE_CALCULATOR = Data.create(null, null);
-
-    /** */
-    @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
-    private long ptr;
-
-    /**
-     * @param desc Row descriptor.
-     * @param ptr Pointer.
-     */
-    public GridH2KeyValueRowOffheap(GridH2RowDescriptor desc, long ptr) {
-        super(desc);
-
-        assert ptr > 0 : ptr;
-
-        this.ptr = ptr;
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param desc Row descriptor.
-     * @param key Key.
-     * @param keyType Key type.
-     * @param val Value.
-     * @param valType Value type.
-     * @param ver Version.
-     * @param expirationTime Expiration time.
-     * @throws IgniteCheckedException If failed.
-     */
-    public GridH2KeyValueRowOffheap(GridH2RowDescriptor desc, Object key, int keyType, @Nullable Object val, int valType,
-                                    GridCacheVersion ver, long expirationTime) throws IgniteCheckedException {
-        super(desc, key, keyType, val, valType, ver, expirationTime);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long expireTime() {
-        if (expirationTime == 0) {
-            long p = ptr;
-
-            assert p > 0 : p;
-
-            // We don't need any synchronization or volatility here because we publish via
-            // volatile write to tree node.
-            expirationTime = desc.memory().readLong(p + OFFSET_EXPIRATION);
-        }
-
-        return expirationTime;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void cache() {
-        desc.cache(this);
-    }
-
-    /**
-     * @param ptr Pointer to get lock for.
-     * @return Locked lock, must be released in {@code finally} block.
-     */
-    @SuppressWarnings("LockAcquiredButNotSafelyReleased")
-    private static Lock lock(long ptr) {
-        assert ptr > 0 : ptr;
-        assert (ptr & 7) == 0 : ptr; // Unsafe allocated pointers aligned.
-
-        Lock l = lock.getLock(ptr >>> 3);
-
-        l.lock();
-
-        return l;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("LockAcquiredButNotSafelyReleased")
-    @Override protected Value getOffheapValue(int col) {
-        GridUnsafeMemory mem = desc.memory();
-
-        long p = ptr;
-
-        assert p > 0 : p;
-
-        byte[] bytes = null;
-
-        if (col == KEY_COL) {
-            int size = mem.readInt(p + OFFSET_KEY_SIZE);
-
-            assert size > 0 : size;
-
-            bytes = mem.readBytes(p + OFFSET_KEY, size);
-        }
-        else if (col == VAL_COL) {
-            Lock l = lock(p);
-
-            desc.guard().begin();
-
-            try {
-                long valPtr = mem.readLongVolatile(p + OFFSET_VALUE_REF);
-
-                if (valPtr == 0) // Value was evicted.
-                    return null;
-
-                int size = mem.readInt(valPtr);
-
-                assert size > 0 : size;
-
-                bytes = mem.readBytes(valPtr + OFFSET_VALUE, size);
-            }
-            finally {
-                desc.guard().end();
-
-                l.unlock();
-            }
-        }
-        else
-            throw new IllegalStateException("Column: " + col);
-
-        Data data = Data.create(null, bytes);
-
-        return data.readValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long pointer() {
-        long p = ptr;
-
-        assert p > 0: p;
-
-        return p;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod")
-    @Override protected synchronized Value updateWeakValue(Object valObj) throws IgniteCheckedException {
-        Value val = peekValue(VAL_COL);
-
-        if (val != null)
-            return val;
-
-        Value upd = desc.wrap(valObj, desc.valueType());
-
-        setValue(VAL_COL, upd);
-
-        notifyAll();
-
-        return upd;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Value syncValue(long waitTime) {
-        Value v = super.syncValue(waitTime);
-
-        if (v != null)
-            return v;
-
-        return getOffheapValue(VAL_COL);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"NonPrivateFieldAccessedInSynchronizedContext"})
-    @Override public void incrementRefCount() {
-        long p = ptr;
-
-        GridUnsafeMemory mem = desc.memory();
-
-        if (p == 0) { // Serialize data to offheap memory.
-            Value key = peekValue(KEY_COL);
-            Value val = peekValue(VAL_COL);
-
-            assert key != null;
-            assert val != null;
-
-            Data data = Data.create(null, new byte[SIZE_CALCULATOR.getValueLen(key)]);
-
-            data.writeValue(key);
-
-            int keySize = data.length();
-
-            p = mem.allocate(keySize + OFFSET_KEY);
-
-            // We don't need any synchronization or volatility here because we publish via
-            // volatile write to tree node.
-            mem.writeInt(p, 1);
-            mem.writeLong(p + OFFSET_EXPIRATION, expirationTime);
-            mem.writeInt(p + OFFSET_KEY_SIZE, keySize);
-            mem.writeBytes(p + OFFSET_KEY, data.getBytes(), 0, keySize);
-
-            data = Data.create(null, new byte[SIZE_CALCULATOR.getValueLen(val)]);
-
-            data.writeValue(val);
-
-            int valSize = data.length();
-
-            long valPtr = mem.allocate(valSize + OFFSET_VALUE);
-
-            mem.writeInt(valPtr, valSize);
-            mem.writeBytes(valPtr + OFFSET_VALUE, data.getBytes(), 0, valSize);
-
-            mem.writeLongVolatile(p + OFFSET_VALUE_REF, valPtr);
-
-            ptr = p;
-
-            desc.cache(this);
-        }
-        else {
-            for (;;) {
-                int cnt = mem.readIntVolatile(p);
-
-                assert cnt > 0 : cnt;
-
-                if (mem.casInt(p, cnt, cnt + 1))
-                    break;
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void decrementRefCount() {
-        long p = ptr;
-
-        assert p > 0 : p;
-
-        GridUnsafeMemory mem = desc.memory();
-
-        for (;;) {
-            int cnt = mem.readIntVolatile(p);
-
-            assert cnt > 0 : cnt;
-
-            if (cnt == 1)
-                break;
-
-            if (mem.casInt(p, cnt, cnt - 1))
-                return;
-        }
-
-        desc.uncache(p);
-
-        // Deallocate off-heap memory.
-        long valPtr = mem.readLongVolatile(p + OFFSET_VALUE_REF);
-
-        assert valPtr >= 0 : valPtr;
-
-        if (valPtr != 0)
-            mem.release(valPtr, mem.readInt(valPtr) + OFFSET_VALUE);
-
-        mem.release(p, mem.readInt(p + OFFSET_KEY_SIZE) + OFFSET_KEY);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void addOffheapRowId(SB sb) {
-        sb.a('-').a(ptr);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-
-        if (obj instanceof GridH2KeyValueRowOffheap) {
-            GridH2KeyValueRowOffheap row = (GridH2KeyValueRowOffheap)obj;
-
-            if (pointer() == row.pointer())
-                return true;
-        }
-
-        return false;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOnheap.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOnheap.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOnheap.java
index 4975092..390015b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOnheap.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOnheap.java
@@ -17,16 +17,52 @@
 
 package org.apache.ignite.internal.processors.query.h2.opt;
 
-
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.h2.message.DbException;
+import org.h2.result.Row;
+import org.h2.result.SearchRow;
 import org.h2.value.Value;
+import org.h2.value.ValueNull;
 import org.jetbrains.annotations.Nullable;
 
 /**
- * Onheap row.
+ * Table row implementation based on {@link GridQueryTypeDescriptor}.
  */
-public class GridH2KeyValueRowOnheap extends GridH2AbstractKeyValueRow {
+public class GridH2KeyValueRowOnheap extends GridH2Row {
+    /** */
+    public static final int DEFAULT_COLUMNS_COUNT = 3;
+
+    /** Key column. */
+    public static final int KEY_COL = 0;
+
+    /** Value column. */
+    public static final int VAL_COL = 1;
+
+    /** Version column. */
+    public static final int VER_COL = 2;
+
+    /** */
+    protected final GridH2RowDescriptor desc;
+
+    /** */
+    @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
+    protected long expirationTime;
+
+    /** */
+    private Value key;
+
+    /** */
+    private volatile Value val;
+
+    /** */
+    private Value[] valCache;
+
+    /** */
+    private Value version;
+
     /**
      * Constructor.
      *
@@ -35,30 +71,206 @@ public class GridH2KeyValueRowOnheap extends GridH2AbstractKeyValueRow {
      * @param keyType Key type.
      * @param val Value.
      * @param valType Value type.
-     * @param ver Version.
      * @param expirationTime Expiration time.
      * @throws IgniteCheckedException If failed.
      */
-    public GridH2KeyValueRowOnheap(GridH2RowDescriptor desc, Object key, int keyType, @Nullable Object val, int valType,
-                                   GridCacheVersion ver, long expirationTime) throws IgniteCheckedException {
-        super(desc, key, keyType, val, valType, ver, expirationTime);
+    public GridH2KeyValueRowOnheap(GridH2RowDescriptor desc, Object key, int keyType, @Nullable Object val,
+        int valType, GridCacheVersion ver, long expirationTime) throws IgniteCheckedException {
+        this.desc = desc;
+        this.expirationTime = expirationTime;
+
+        setValue(KEY_COL, desc.wrap(key, keyType));
+
+        if (val != null) // We remove by key only, so value can be null here.
+            setValue(VAL_COL, desc.wrap(val, valType));
+
+        if (ver != null)
+            setValue(VER_COL, desc.wrap(ver, Value.JAVA_OBJECT));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Value[] getValueList() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long expireTime() {
+        return expirationTime;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getColumnCount() {
+        return DEFAULT_COLUMNS_COUNT + desc.fieldsCount();
+    }
+
+    /**
+     * @param col Column index.
+     * @return Value if exists.
+     */
+    protected final Value peekValue(int col) {
+        if (col == KEY_COL)
+            return key;
+
+        if (col == VAL_COL)
+            return val;
+
+        assert col == VER_COL;
+
+        return version;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Value getValue(int col) {
+        Value[] vCache = valCache;
+
+        if (vCache != null) {
+            Value v = vCache[col];
+
+            if (v != null)
+                return v;
+        }
+
+        Value v;
+
+        if (desc.isValueColumn(col)) {
+            v = peekValue(VAL_COL);
+
+            return v;
+        }
+        else if (desc.isKeyColumn(col)) {
+            v = peekValue(KEY_COL);
+
+            assert v != null;
+
+            return v;
+        }
+        else if (col == VER_COL)
+            return version;
+
+        col -= DEFAULT_COLUMNS_COUNT;
+
+        assert col >= 0;
+
+        Value key = getValue(KEY_COL);
+        Value val = getValue(VAL_COL);
+
+        assert key != null;
+        assert val != null;
+
+        Object res = desc.columnValue(key.getObject(), val.getObject(), col);
+
+        if (res == null)
+            v = ValueNull.INSTANCE;
+        else {
+            try {
+                v = desc.wrap(res, desc.fieldType(col));
+            }
+            catch (IgniteCheckedException e) {
+                throw DbException.convert(e);
+            }
+        }
+
+        if (vCache != null)
+            vCache[col + DEFAULT_COLUMNS_COUNT] = v;
+
+        return v;
+    }
+
+    /**
+     * @param valCache Value cache.
+     */
+    public void valuesCache(Value[] valCache) {
+        if (valCache != null) {
+            desc.initValueCache(valCache, key, val, version);
+        }
+
+        this.valCache = valCache;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        SB sb = new SB("Row@");
+
+        sb.a(Integer.toHexString(System.identityHashCode(this)));
+
+        Value v = peekValue(KEY_COL);
+        sb.a("[ key: ").a(v == null ? "nil" : v.getString());
+
+        v = peekValue(VAL_COL);
+        sb.a(", val: ").a(v == null ? "nil" : v.getString());
+
+        v = peekValue(VER_COL);
+        sb.a(", ver: ").a(v == null ? "nil" : v.getString());
+
+        sb.a(" ][ ");
+
+        if (v != null) {
+            for (int i = DEFAULT_COLUMNS_COUNT, cnt = getColumnCount(); i < cnt; i++) {
+                v = getValue(i);
+
+                if (i != DEFAULT_COLUMNS_COUNT)
+                    sb.a(", ");
+
+                if (!desc.isKeyValueOrVersionColumn(i))
+                    sb.a(v == null ? "nil" : v.getString());
+            }
+        }
+
+        sb.a(" ]");
+
+        return sb.toString();
     }
 
     /** {@inheritDoc} */
-    @Override protected void cache() {
-        // No-op.
+    @Override public void setKeyAndVersion(SearchRow old) {
+        throw new IllegalStateException();
     }
 
     /** {@inheritDoc} */
-    @Override protected Value getOffheapValue(int col) {
-        return null;
+    @Override public void setKey(long key) {
+        throw new IllegalStateException();
     }
 
     /** {@inheritDoc} */
-    @Override public long pointer() {
-        if (link == 0)
-            return super.pointer();
+    @Override public Row getCopy() {
+        throw new IllegalStateException();
+    }
 
-        return link;
+    /** {@inheritDoc} */
+    @Override public void setDeleted(boolean deleted) {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getKey() {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setSessionId(int sesId) {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setVersion(int ver) {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setValue(int idx, Value v) {
+        if (desc.isValueColumn(idx))
+            val = v;
+        else if (idx == VER_COL)
+            version = v;
+        else {
+            assert desc.isKeyColumn(idx) : idx + " " + v;
+
+            key = v;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public final int hashCode() {
+        throw new IllegalStateException();
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/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 2b4e180..91f0aef 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
@@ -380,6 +380,7 @@ public class GridH2QueryContext {
     /**
      * @param nodeStop Node is stopping.
      */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     public void clearContext(boolean nodeStop) {
         cleared = true;
 
@@ -583,6 +584,9 @@ public class GridH2QueryContext {
 
         /** {@inheritDoc} */
         @Override public boolean equals(Object o) {
+            if (o == null || !(o instanceof SourceKey))
+                return false;
+
             SourceKey srcKey = (SourceKey)o;
 
             return batchLookupId == srcKey.batchLookupId && segmentId == srcKey.segmentId &&

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
index bd64bce..fdeb009 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
@@ -29,7 +29,7 @@ import org.h2.value.Value;
 /**
  * Row with locking support needed for unique key conflicts resolution.
  */
-public abstract class GridH2Row implements GridSearchRowPointer, CacheDataRow, Row {
+public abstract class GridH2Row implements SearchRow, CacheDataRow, Row {
     /** */
     public long link; // TODO remove
 
@@ -46,21 +46,6 @@ public abstract class GridH2Row implements GridSearchRowPointer, CacheDataRow, R
     public int partId; // TODO remove
 
     /** {@inheritDoc} */
-    @Override public long pointer() {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void incrementRefCount() {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void decrementRefCount() {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
     @Override public KeyCacheObject key() {
         return key;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/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 d273e16..1f6ff88 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
@@ -18,16 +18,12 @@
 package org.apache.ignite.internal.processors.query.h2.opt;
 
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
 import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
-import org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSmartPointerFactory;
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeGuard;
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
 import org.h2.result.SearchRow;
 import org.h2.value.Value;
 import org.jetbrains.annotations.Nullable;
@@ -35,7 +31,7 @@ import org.jetbrains.annotations.Nullable;
 /**
  * Row descriptor.
  */
-public interface GridH2RowDescriptor extends GridOffHeapSmartPointerFactory<GridH2KeyValueRowOffheap> {
+public interface GridH2RowDescriptor {
     /**
      * Gets indexing.
      *
@@ -67,15 +63,8 @@ public interface GridH2RowDescriptor extends GridOffHeapSmartPointerFactory<Grid
      * @return Row.
      * @throws IgniteCheckedException If failed.
      */
-    public GridH2Row createRow(KeyCacheObject key, int part, @Nullable CacheObject val, GridCacheVersion ver, long expirationTime)
-        throws IgniteCheckedException;
-
-    /**
-     * @param link Link to get row for.
-     * @return Cached row.
-     */
-    public GridH2Row cachedRow(long link);
-
+    public GridH2Row createRow(KeyCacheObject key, int part, @Nullable CacheObject val, GridCacheVersion ver,
+        long expirationTime) throws IgniteCheckedException;
 
     /**
      * @return Value type.
@@ -124,26 +113,6 @@ public interface GridH2RowDescriptor extends GridOffHeapSmartPointerFactory<Grid
     public boolean isColumnKeyProperty(int col);
 
     /**
-     * @return Unsafe memory.
-     */
-    public GridUnsafeMemory memory();
-
-    /**
-     * @param row Deserialized offheap row to cache in heap.
-     */
-    public void cache(GridH2Row row);
-
-    /**
-     * @param ptr Offheap pointer to remove from cache.
-     */
-    public void uncache(long ptr);
-
-    /**
-     * @return Guard.
-     */
-    public GridUnsafeGuard guard();
-
-    /**
      * Wraps object to respective {@link Value}.
      *
      * @param o Object.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/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 549cbfb..79eed12 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
@@ -37,9 +37,7 @@ import org.apache.ignite.internal.processors.query.QueryField;
 import org.apache.ignite.internal.processors.query.h2.H2RowDescriptor;
 import org.apache.ignite.internal.processors.query.h2.database.H2RowFactory;
 import org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex;
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
 import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.lang.IgniteBiTuple;
 import org.h2.command.ddl.CreateTableData;
 import org.h2.engine.DbObject;
 import org.h2.engine.Session;
@@ -63,7 +61,7 @@ import org.jsr166.ConcurrentHashMap8;
 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.GridH2KeyValueRowOnheap.KEY_COL;
 
 /**
  * H2 Table implementation.
@@ -415,39 +413,18 @@ public class GridH2Table extends TableBase {
         row.link = link;
 
         if (!rmv)
-            ((GridH2AbstractKeyValueRow)row).valuesCache(new Value[getColumns().length]);
+            ((GridH2KeyValueRowOnheap)row).valuesCache(new Value[getColumns().length]);
 
         try {
             return doUpdate(row, rmv);
         }
         finally {
             if (!rmv)
-                ((GridH2AbstractKeyValueRow)row).valuesCache(null);
+                ((GridH2KeyValueRowOnheap)row).valuesCache(null);
         }
     }
 
     /**
-     * @param key Key to read.
-     * @return Read value.
-     * @throws IgniteCheckedException If failed.
-     */
-    public IgniteBiTuple<CacheObject, GridCacheVersion> read(
-        GridCacheContext cctx,
-        KeyCacheObject key,
-        int partId
-    ) throws IgniteCheckedException {
-        assert desc != null;
-
-        GridH2Row row = desc.createRow(key, partId, null, null, 0);
-
-        GridH2IndexBase primaryIdx = pk();
-
-        GridH2Row res = primaryIdx.findOne(row);
-
-        return res != null ? F.t(res.val, res.ver) : null;
-    }
-
-    /**
      * Gets index by index.
      *
      * @param idx Index in list.
@@ -478,13 +455,8 @@ public class GridH2Table extends TableBase {
     boolean doUpdate(final GridH2Row row, boolean del) throws IgniteCheckedException {
         // Here we assume that each key can't be updated concurrently and case when different indexes
         // getting updated from different threads with different rows with the same key is impossible.
-        GridUnsafeMemory mem = desc == null ? null : desc.memory();
-
         lock(false);
 
-        if (mem != null)
-            desc.guard().begin();
-
         try {
             ensureNotDestroyed();
 
@@ -543,9 +515,6 @@ public class GridH2Table extends TableBase {
         }
         finally {
             unlock(false);
-
-            if (mem != null)
-                desc.guard().end();
         }
     }
 
@@ -830,13 +799,6 @@ public class GridH2Table extends TableBase {
         return idxs;
     }
 
-    /**
-     * @return All indexes, even marked for rebuild.
-     */
-    public ArrayList<Index> getAllIndexes() {
-        return idxs;
-    }
-
     /** {@inheritDoc} */
     @Override public boolean isLockedExclusively() {
         return false;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneDirectory.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneDirectory.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneDirectory.java
index 96869c4..4994e61 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneDirectory.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneDirectory.java
@@ -133,7 +133,7 @@ public class GridLuceneDirectory extends BaseDirectory implements Accountable {
     @Override public IndexOutput createOutput(final String name, final IOContext context) throws IOException {
         ensureOpen();
 
-        GridLuceneFile file = newRAMFile(name);
+        GridLuceneFile file = new GridLuceneFile(this);
 
         // Lock for using in stream. Will be unlocked on stream closing.
         file.lockRef();
@@ -154,16 +154,6 @@ public class GridLuceneDirectory extends BaseDirectory implements Accountable {
         // Noop. No fsync needed as all data is in-memory.
     }
 
-    /**
-     * Returns a new {@link GridLuceneFile} for storing data. This method can be
-     * overridden to return different {@link GridLuceneFile} impls, that e.g. override.
-     *
-     * @return New ram file.
-     */
-    protected GridLuceneFile newRAMFile(String filename) {
-        return new GridLuceneFile(this, filename);
-    }
-
     /** {@inheritDoc} */
     @Override public IndexInput openInput(final String name, final IOContext context) throws IOException {
         ensureOpen();

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneFile.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneFile.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneFile.java
index 8f77f35..d7ae132 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneFile.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneFile.java
@@ -37,9 +37,6 @@ public class GridLuceneFile implements Accountable {
     private long length;
 
     /** */
-    private final String name;
-
-    /** */
     private final GridLuceneDirectory dir;
 
     /** */
@@ -56,9 +53,8 @@ public class GridLuceneFile implements Accountable {
      *
      * @param dir Directory.
      */
-    GridLuceneFile(GridLuceneDirectory dir, String name) {
+    GridLuceneFile(GridLuceneDirectory dir) {
         this.dir = dir;
-        this.name = name;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
index c9d0159..f8d3ef2 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
@@ -100,22 +100,20 @@ public class GridLuceneIndex implements AutoCloseable {
      * Constructor.
      *
      * @param ctx Kernal context.
-     * @param mem Unsafe memory.
      * @param cacheName Cache name.
      * @param type Type descriptor.
      * @throws IgniteCheckedException If failed.
      */
-    public GridLuceneIndex(GridKernalContext ctx, @Nullable GridUnsafeMemory mem,
-        @Nullable String cacheName, GridQueryTypeDescriptor type) throws IgniteCheckedException {
+    public GridLuceneIndex(GridKernalContext ctx, @Nullable String cacheName, GridQueryTypeDescriptor type)
+        throws IgniteCheckedException {
         this.ctx = ctx;
         this.cacheName = cacheName;
         this.type = type;
 
-        dir = new GridLuceneDirectory(mem == null ? new GridUnsafeMemory(0) : mem);
+        dir = new GridLuceneDirectory(new GridUnsafeMemory(0));
 
         try {
-            writer = new IndexWriter(dir,
-                new IndexWriterConfig(new StandardAnalyzer()));
+            writer = new IndexWriter(dir, new IndexWriterConfig(new StandardAnalyzer()));
         }
         catch (IOException e) {
             throw new IgniteCheckedException(e);
@@ -158,6 +156,7 @@ public class GridLuceneIndex implements AutoCloseable {
      * @param expires Expiration time.
      * @throws IgniteCheckedException If failed.
      */
+    @SuppressWarnings("ConstantConditions")
     public void store(CacheObject k, CacheObject v, GridCacheVersion ver, long expires) throws IgniteCheckedException {
         CacheObjectContext coctx = objectContext();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridSearchRowPointer.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridSearchRowPointer.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridSearchRowPointer.java
deleted file mode 100644
index e82143a..0000000
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridSearchRowPointer.java
+++ /dev/null
@@ -1,28 +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 org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSmartPointer;
-import org.h2.result.SearchRow;
-
-/**
- * Search row which supports pointer operations.
- */
-public interface GridSearchRowPointer extends SearchRow, GridOffHeapSmartPointer {
-    // No-op.
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java
index 5a1d412..edbf56b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/DmlAstUtils.java
@@ -26,7 +26,7 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.processors.query.IgniteSQLException;
 import org.apache.ignite.internal.processors.query.h2.dml.FastUpdateArgument;
 import org.apache.ignite.internal.processors.query.h2.dml.FastUpdateArguments;
-import org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow;
+import org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
 import org.apache.ignite.internal.util.lang.IgnitePair;
@@ -64,11 +64,10 @@ public final class DmlAstUtils {
      * @param cols Columns to insert values into.
      * @param rows Rows to create pseudo-SELECT upon.
      * @param subQry Subquery to use rather than rows.
-     * @param desc Row descriptor.
      * @return Subquery or pseudo-SELECT to evaluate inserted expressions.
      */
     public static GridSqlQuery selectForInsertOrMerge(GridSqlColumn[] cols, List<GridSqlElement[]> rows,
-        GridSqlQuery subQry, GridH2RowDescriptor desc) {
+        GridSqlQuery subQry) {
         if (!F.isEmpty(rows)) {
             assert !F.isEmpty(cols);
 
@@ -140,9 +139,9 @@ public final class DmlAstUtils {
 
         assert gridTbl != null : "Failed to determine target grid table for DELETE";
 
-        Column h2KeyCol = gridTbl.getColumn(GridH2AbstractKeyValueRow.KEY_COL);
+        Column h2KeyCol = gridTbl.getColumn(GridH2KeyValueRowOnheap.KEY_COL);
 
-        Column h2ValCol = gridTbl.getColumn(GridH2AbstractKeyValueRow.VAL_COL);
+        Column h2ValCol = gridTbl.getColumn(GridH2KeyValueRowOnheap.VAL_COL);
 
         GridSqlColumn keyCol = new GridSqlColumn(h2KeyCol, tbl, h2KeyCol.getName());
         keyCol.resultType(GridSqlType.fromColumn(h2KeyCol));
@@ -340,9 +339,9 @@ public final class DmlAstUtils {
 
         assert gridTbl != null : "Failed to determine target grid table for UPDATE";
 
-        Column h2KeyCol = gridTbl.getColumn(GridH2AbstractKeyValueRow.KEY_COL);
+        Column h2KeyCol = gridTbl.getColumn(GridH2KeyValueRowOnheap.KEY_COL);
 
-        Column h2ValCol = gridTbl.getColumn(GridH2AbstractKeyValueRow.VAL_COL);
+        Column h2ValCol = gridTbl.getColumn(GridH2KeyValueRowOnheap.VAL_COL);
 
         GridSqlColumn keyCol = new GridSqlColumn(h2KeyCol, tbl, h2KeyCol.getName());
         keyCol.resultType(GridSqlType.fromColumn(h2KeyCol));

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlArray.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlArray.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlArray.java
index 2f7e2f0..581c571 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlArray.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlArray.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.query.h2.sql;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
 import org.h2.util.StatementBuilder;
 
 /**
@@ -33,13 +32,6 @@ public class GridSqlArray extends GridSqlElement {
         super(size == 0 ? Collections.<GridSqlAst>emptyList() : new ArrayList<GridSqlAst>(size));
     }
 
-    /**
-     * @param children Initial child list.
-     */
-    public GridSqlArray(List<GridSqlAst> children) {
-        super(children);
-    }
-
     /** {@inheritDoc} */
     @Override public String getSQL() {
         if (size() == 0)

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlColumn.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlColumn.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlColumn.java
index 6f4141e..ef460e3 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlColumn.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlColumn.java
@@ -85,13 +85,6 @@ public class GridSqlColumn extends GridSqlElement {
     }
 
     /**
-     * @return Table alias.
-     */
-    public String tableAlias() {
-        return tblAlias;
-    }
-
-    /**
      * @param tblAlias Table alias.
      */
     public void tableAlias(String tblAlias) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
index 46a558a..a03cd46 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
@@ -36,7 +36,7 @@ public class GridSqlFunction extends GridSqlElement {
     /** */
     private static final Map<String, GridSqlFunctionType> TYPE_MAP = new HashMap<>();
 
-    /**
+    /*
      *
      */
     static {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
index 1578f9f..b20cbd5 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
@@ -80,6 +80,7 @@ import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlUnion.RI
 /**
  * Splits a single SQL query into two step map-reduce query.
  */
+@SuppressWarnings("ForLoopReplaceableByForEach")
 public class GridSqlQuerySplitter {
     /** */
     private static final String MERGE_TABLE_SCHEMA = "PUBLIC"; // Schema PUBLIC must always exist.
@@ -962,8 +963,6 @@ public class GridSqlQuerySplitter {
                 select.setColumn(i, expr);
             }
 
-            assert expr instanceof GridSqlAlias;
-
             if (isAllRelatedToTables(tblAliases, GridSqlQuerySplitter.<GridSqlAlias>newIdentityHashSet(), expr)) {
                 // Push down the whole expression.
                 pushDownColumn(tblAliases, cols, wrapAlias, expr, 0);
@@ -1739,9 +1738,6 @@ public class GridSqlQuerySplitter {
             normalizeExpression(from, 2);
         }
         else if (from instanceof GridSqlFunction) {
-            // TODO generate filtering function around the given function
-            // TODO SYSTEM_RANGE is a special case, it can not be wrapped
-
             // In case of alias parent we need to replace the alias itself.
             if (!prntAlias)
                 generateUniqueAlias(prnt, childIdx);
@@ -1754,6 +1750,7 @@ public class GridSqlQuerySplitter {
      * @param prnt Parent element.
      * @param childIdx Child index.
      */
+    @SuppressWarnings("StatementWithEmptyBody")
     private void normalizeExpression(GridSqlAst prnt, int childIdx) {
         GridSqlAst el = prnt.child(childIdx);
 
@@ -2321,8 +2318,6 @@ public class GridSqlQuerySplitter {
                 constant.value().getObject()), null, null, -1, -1);
         }
 
-        assert right instanceof GridSqlParameter;
-
         GridSqlParameter param = (GridSqlParameter) right;
 
         return new CacheQueryPartitionInfo(-1, tbl.cacheName(), tbl.getName(),
@@ -2349,8 +2344,7 @@ public class GridSqlQuerySplitter {
 
         ArrayList<CacheQueryPartitionInfo> list = new ArrayList<>(a.length + b.length);
 
-        for (CacheQueryPartitionInfo part: a)
-            list.add(part);
+        Collections.addAll(list, a);
 
         for (CacheQueryPartitionInfo part: b) {
             int i = 0;
@@ -2480,6 +2474,7 @@ public class GridSqlQuerySplitter {
         /**
          * @return The actual AST element for this model.
          */
+        @SuppressWarnings("TypeParameterHidesVisibleType")
         private <X extends GridSqlAst> X ast() {
             return prnt.child(childIdx);
         }
@@ -2526,6 +2521,7 @@ public class GridSqlQuerySplitter {
         /**
          * @return The actual AST element for this expression.
          */
+        @SuppressWarnings("TypeParameterHidesVisibleType")
         private <X extends GridSqlAst> X ast() {
             return prnt.child(childIdx);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
index 1c1cfaf..b70adb0 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
@@ -58,6 +58,7 @@ import static org.apache.ignite.IgniteSystemProperties.getInteger;
 /**
  * Merge index.
  */
+@SuppressWarnings("AtomicFieldUpdaterIssues")
 public abstract class GridMergeIndex extends BaseIndex {
     /** */
     private static final int MAX_FETCH_SIZE = getInteger(IGNITE_SQL_MERGE_TABLE_MAX_SIZE, 10_000);

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Geometry.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Geometry.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Geometry.java
index 581e88f..e93e392 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Geometry.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Geometry.java
@@ -34,7 +34,7 @@ public class GridH2Geometry extends GridH2ValueMessage {
     /** */
     private static final Method GEOMETRY_FROM_BYTES;
 
-    /**
+    /*
      * Initialize field.
      */
     static {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Null.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Null.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Null.java
index 38c4561..2407679 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Null.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Null.java
@@ -61,6 +61,7 @@ public class GridH2Null extends GridH2ValueMessage {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("SimplifiableIfStatement")
     @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
         reader.setBuffer(buf);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java
index 00f345e..4831d02 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java
@@ -42,7 +42,7 @@ import org.apache.ignite.internal.processors.query.QueryField;
 import org.apache.ignite.internal.processors.query.QuerySchema;
 import org.apache.ignite.internal.processors.query.QueryUtils;
 import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
-import org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow;
+import org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
 import org.apache.ignite.internal.util.typedef.F;
@@ -197,7 +197,7 @@ public abstract class DynamicColumnsAbstractTest extends GridCommonAbstractTest
 
                 try {
                     assertEquals(DataType.getTypeFromClass(Class.forName(col.typeName())),
-                        rowDesc.fieldType(i - GridH2AbstractKeyValueRow.DEFAULT_COLUMNS_COUNT));
+                        rowDesc.fieldType(i - GridH2KeyValueRowOnheap.DEFAULT_COLUMNS_COUNT));
                 }
                 catch (ClassNotFoundException e) {
                     throw new AssertionError(e);


Mime
View raw message