ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [2/4] ignite git commit: IGNITE-6331: Removed unused SQL-related code and fixed warnings. This closes #2760.
Date Wed, 27 Sep 2017 09:24:09 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeCompoundMemory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeCompoundMemory.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeCompoundMemory.java
deleted file mode 100644
index 8b32ceb..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeCompoundMemory.java
+++ /dev/null
@@ -1,35 +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.util.offheap.unsafe;
-
-/**
- * Compound memory object. Contains one or more memory regions.
- */
-public interface GridUnsafeCompoundMemory {
-    /**
-     * Deallocates this compound memory object.
-     */
-    public void deallocate();
-
-    /**
-     * Merges another compound memory object with this one.
-     *
-     * @param compound Compound memory.
-     */
-    public void merge(GridUnsafeCompoundMemory compound);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeGuard.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeGuard.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeGuard.java
deleted file mode 100644
index c461cf1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeGuard.java
+++ /dev/null
@@ -1,376 +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.util.offheap.unsafe;
-
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Guards concurrent operations on offheap memory to make sure that no thread will access already deallocated pointer.
- * Typical usage is:
- * <pre>
- *     guard.begin();
- *
- *     try {
- *         guard.releaseLater(x);
- *     }
- *     finally {
- *         guard.end();
- *     }
- * </pre>
- *
- * while another thread can safely read the memory being deallocated:
- * <pre>
- *     guard.begin();
- *
- *     try {
- *         mem.readLong(x.getPointer());
- *     }
- *     finally {
- *         guard.end();
- *     }
- * </pre>
- */
-public class GridUnsafeGuard {
-    /** */
-    @GridToStringInclude
-    private final AtomicReference<Operation> head = new AtomicReference<>();
-
-    /** */
-    @GridToStringInclude
-    private final AtomicReference<Operation> tail = new AtomicReference<>();
-
-    /** */
-    @GridToStringExclude
-    private final ThreadLocal<Operation> currOp = new ThreadLocal<>();
-
-    /**
-     * Initialize head and tail with fake operation to avoid {@code null} handling.
-     */
-    {
-        Operation fake = new Operation();
-
-        fake.allowDeallocate();
-
-        head.set(fake);
-        tail.set(fake);
-    }
-
-    /**
-     * Begins concurrent memory operation.
-     */
-    public void begin() {
-        Operation op = currOp.get();
-
-        if (op != null) {
-            op.reentries++;
-
-            return;
-        }
-
-        op = new Operation();
-
-        currOp.set(op);
-
-        for (;;) {
-            Operation prev = head.get();
-
-            op.previous(prev);
-
-            if (head.compareAndSet(prev, op)) {
-                prev.next(op);
-
-                break;
-            }
-        }
-    }
-
-    /**
-     * Ends concurrent memory operation and releases resources.
-     */
-    public void end() {
-        Operation op = currOp.get();
-
-        assert op != null : "must be called after begin in the same thread";
-
-        if (op.reentries != 0) {
-            assert op.reentries > 0 : op.reentries;
-
-            op.reentries--;
-
-            return;
-        }
-
-        currOp.remove();
-
-        op.allowDeallocate();
-
-        // Start deallocating from tail.
-        op = tail.get();
-
-        int state;
-
-        // Go through the inactive ops and try to deallocate.
-        while ((state = op.state) != Operation.STATE_ACTIVE) {
-            if (state == Operation.STATE_MAY_DEALLOCATE)
-                op.finish();
-
-            // We need to keep op non-null, so don't use op = op.next;
-            Operation next = op.next;
-
-            if (next == null)
-                break;
-
-            op = next;
-        }
-
-        // Move tail forward.
-        for (;;) {
-            Operation t = tail.get();
-
-            if (op.id <= t.id || tail.compareAndSet(t, op))
-                break;
-        }
-    }
-
-    /**
-     * Releases memory in the future when it will be safe to do that.
-     * Gives no guarantees in which thread it will be executed.
-     *
-     * @param compound Compound memory.
-     */
-    public void releaseLater(GridUnsafeCompoundMemory compound) {
-        assert currOp.get() != null : "must be called in begin-end block";
-
-        head.get().add(compound);
-    }
-
-    /**
-     * Does finalization when it will be safe to deallocate offheap memory.
-     * Gives no guarantees in which thread it will be executed. Gives
-     * no guarantees about execution order of multiple passed finalizers as well.
-     *
-     * @param finalizer Finalizer.
-     */
-    public void finalizeLater(Runnable finalizer) {
-        assert currOp.get() != null : "must be called in begin-end block";
-
-        head.get().add(new Finalizer(finalizer));
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridUnsafeGuard.class, this, "currOp", currOp.get());
-    }
-
-    /**
-     * Memory operation which can be executed in parallel with other memory operations.
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    private static class Operation {
-        /** */
-        private static final int STATE_ACTIVE = 0;
-
-        /** */
-        private static final int STATE_MAY_DEALLOCATE = 1;
-
-        /** */
-        private static final int STATE_DEALLOCATED = 2;
-
-        /** */
-        private static final AtomicReferenceFieldUpdater<Operation, Finalizer> finUpdater =
-            AtomicReferenceFieldUpdater.newUpdater(Operation.class, Finalizer.class, "finHead");
-
-        /** */
-        private static final AtomicReferenceFieldUpdater<Operation, GridUnsafeCompoundMemory> compoundUpdater =
-            AtomicReferenceFieldUpdater.newUpdater(Operation.class, GridUnsafeCompoundMemory.class, "compound");
-
-        /** */
-        private static final AtomicIntegerFieldUpdater<Operation> stateUpdater =
-            AtomicIntegerFieldUpdater.newUpdater(Operation.class, "state");
-
-        /** */
-        private long id;
-
-        /** Reentries of the owner thread. */
-        private int reentries;
-
-        /** */
-        private volatile int state;
-
-        /** */
-        private volatile Finalizer finHead;
-
-        /** */
-        private volatile GridUnsafeCompoundMemory compound;
-
-        /** */
-        @GridToStringExclude
-        private volatile Operation next;
-
-        /**
-         * Adds runnable to the finalization queue.
-         *
-         * @param fin Finalizer.
-         */
-        private void add(Finalizer fin) {
-            for(;;) {
-                Finalizer prev = finHead;
-
-                fin.previous(prev);
-
-                if (finUpdater.compareAndSet(this, prev, fin))
-                    break;
-            }
-        }
-
-        /**
-         * Finish operation and release memory.
-         */
-        private void finish() {
-            if (!stateUpdater.compareAndSet(this, STATE_MAY_DEALLOCATE, STATE_DEALLOCATED))
-                return;
-
-            GridUnsafeCompoundMemory c = compound;
-
-            if (c != null) {
-                c.deallocate();
-
-                compoundUpdater.lazySet(this, null);
-            }
-
-            Finalizer fin = finHead;
-
-            if (fin != null) {
-                // Need to nullify because last deallocated operation object is still kept in memory.
-                finUpdater.lazySet(this, null);
-
-                do {
-                    fin.run();
-
-                    fin = fin.previous();
-                }
-                while(fin != null);
-            }
-        }
-
-        /**
-         * @return {@code true} If memory for this operation was already deallocated.
-         */
-        private boolean deallocated() {
-            return state == STATE_DEALLOCATED;
-        }
-
-        /**
-         * Adds compound memory for deallocation.
-         *
-         * @param c Compound memory.
-         */
-        private void add(GridUnsafeCompoundMemory c) {
-            GridUnsafeCompoundMemory existing = compound;
-
-            if (existing == null) {
-                if (compoundUpdater.compareAndSet(this, null, c))
-                    return;
-
-                existing = compound;
-            }
-
-            existing.merge(c);
-        }
-
-        /**
-         * @param prev Previous operation.
-         */
-        private void previous(Operation prev) {
-            id = prev.id + 1;
-        }
-
-        /**
-         * Sets flag indicating if memory may be deallocated for this operation.
-         */
-        private void allowDeallocate() {
-            stateUpdater.lazySet(this, STATE_MAY_DEALLOCATE);
-        }
-
-        /**
-         * @param next Next operation.
-         */
-        private void next(Operation next) {
-            this.next = next;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            Operation next0 = next;
-
-            return S.toString(Operation.class, this, "identity", System.identityHashCode(this), "next", next0 == null ?
-                null : Math.random() < 0.03 ? "other..." : next0);
-        }
-    }
-
-    /**
-     * Finalizer.
-     */
-    private static class Finalizer {
-        /** */
-        private Finalizer prev;
-
-        /** */
-        private final Runnable delegate;
-
-        /**
-         * @param delegate Actual finalizer.
-         */
-        private Finalizer(Runnable delegate) {
-            assert delegate != null;
-
-            this.delegate = delegate;
-        }
-
-        /**
-         * @return Previous finalizer.
-         */
-        private Finalizer previous() {
-            return prev;
-        }
-
-        /**
-         * @param prev Previous finalizer.
-         */
-        private void previous(Finalizer prev) {
-            this.prev = prev;
-        }
-
-        /**
-         * Run finalization.
-         */
-        private void run() {
-            delegate.run();
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(Finalizer.class, this);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridOffheapSnapTreeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridOffheapSnapTreeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridOffheapSnapTreeSelfTest.java
deleted file mode 100644
index 0d97d54..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridOffheapSnapTreeSelfTest.java
+++ /dev/null
@@ -1,326 +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.util.offheap.unsafe;
-
-import java.util.HashSet;
-import java.util.Random;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.internal.util.typedef.internal.D;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public class GridOffheapSnapTreeSelfTest extends GridCommonAbstractTest {
-    /**
-     * Test for memory leaks.
-     *
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("TypeMayBeWeakened")
-    public void testMemoryMultithreaded() throws Exception {
-        final TestPointerFactory f = new TestPointerFactory(1000);
-
-        final GridUnsafeMemory mem = new GridUnsafeMemory(25000);
-
-        final GridUnsafeGuard guard = new GridUnsafeGuard();
-
-        final GridOffHeapSnapTreeMap<TestPointer, TestPointer> m = new GridOffHeapSnapTreeMap<>(
-            f, f, mem, guard);
-
-        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
-
-        for (int j = 1; j < 20; j++) {
-            final int max = Math.min(1000, j * 20);
-
-            multithreaded(new Runnable() {
-                @SuppressWarnings({"LockAcquiredButNotSafelyReleased", "StatementWithEmptyBody",
-                    "UnusedDeclaration", "unchecked"})
-                @Override public void run()
-                {
-                    Random rnd = new Random();
-
-                    for (int i = 0; i < 100000; i++) {
-                        int x = 1 + rnd.nextInt(max);
-
-                        TestPointer fx = f.createPointer(x);
-
-                        boolean put = rnd.nextInt(2) != 0;
-
-                        lock.readLock().lock();
-
-                        guard.begin();
-
-                        try {
-                            if (put)
-                                m.put(fx, fx);
-                            else
-                                m.remove(fx);
-                        }
-                        finally {
-                            lock.readLock().unlock();
-
-                            guard.end();
-                        }
-
-                        if (i % 100 == 0) {
-                            lock.writeLock().lock();
-
-                            GridOffHeapSnapTreeMap<TestPointer, TestPointer> m2;
-
-                            try {
-                                m.validate();
-
-                                m2 = m.clone();
-
-                                assert m2.equals(m);
-                            }
-                            finally {
-                                lock.writeLock().unlock();
-                            }
-
-                            m2.validate();
-
-                            for (GridOffHeapSmartPointer p : m2.values())
-                                assertTrue(((TestPointer)p).refs.get() >= 2);
-
-                            m2.close();
-                        }
-                    }
-                }
-            }, 29);
-
-            m.validate();
-
-            assertEquals(m.size(), m.nodes(true));
-
-            assertFalse(mem.allocatedSize() == 0);
-
-            X.println(String.valueOf(mem.allocatedSize()));
-
-            int refs = 0;
-
-            for (TestPointer ptr : f.ptrs)
-                refs += ptr.refs.get();
-
-            assertEquals(m.size() * 2 + (m.nodes(false) - m.size()), refs);
-
-            if (j % 2 == 0)
-                continue;
-
-            guard.begin();
-
-            try {
-                for (int i = 1; i <= max; i++)
-                    m.remove(f.createPointer(i));
-            }
-            finally {
-                guard.end();
-            }
-
-            assertEquals(0, m.size());
-
-            assertTrue(m.isEmpty());
-
-            assertEquals(0, m.nodes(false));
-
-            for (TestPointer ptr : f.ptrs) {
-                refs = ptr.refs.get();
-
-                assertEquals(0, refs);
-            }
-        }
-        m.close();
-
-        assertEquals(0, mem.allocatedSize());
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testKeyLockMultithreaded() throws Exception {
-        final GridOffHeapSnapTreeMap.KeyLock lock = new GridOffHeapSnapTreeMap.KeyLock();
-
-        final int[] ints = new int[2000];
-
-        final int iterations = 1000000;
-
-        final int threads = 37;
-
-        final AtomicInteger sum0 = new AtomicInteger();
-
-        final ConcurrentMap<Integer, Object> locked = new ConcurrentHashMap<>();
-
-        multithreaded(new Runnable() {
-            @Override public void run() {
-                Random rnd = new Random();
-
-                for (int i = 0; i < iterations; i++)
-                    sum0.addAndGet(increment(rnd, 1 + rnd.nextInt(ints.length - 1), new HashSet<Integer>()));
-            }
-
-            /**
-             * @param rnd Random.
-             * @param idx Index.
-             * @param locIdxs Locked indexes.
-             * @return Count of incremented cells.
-             */
-            int increment(Random rnd, int idx, HashSet<Integer> locIdxs) {
-                if (idx >= ints.length)
-                    return 0;
-
-                int res = 1;
-
-                GridOffHeapSnapTreeMap.KeyLock.Lock l = lock.lock(idx);
-
-                try {
-                    assertTrue(locIdxs.add(idx));
-
-                    Object check = F.asList(l == null ? Boolean.TRUE : l, Thread.currentThread().getName(), idx);
-
-                    Object check2 = locked.putIfAbsent(idx, check);
-
-                    if (check2 != null)
-                        fail(">> " + check + " <><><> " + check2);
-
-                    ints[idx]++;
-
-                    assertNull(lock.lock(idx));
-
-                    if (rnd.nextInt(10) > 2) // Test reentrancy.
-                        res += increment(rnd, idx + 1 + rnd.nextInt(3), locIdxs);
-
-                    assertTrue(locIdxs.remove(idx));
-
-                    assertSame(check, locked.remove(idx));
-                }
-                finally {
-                    if (l != null)
-                        l.unlock();
-                }
-
-                return res;
-            }
-        }, threads);
-
-        int sum = 0;
-
-        for (int i = 1; i < ints.length; i++) {
-            GridOffHeapSnapTreeMap.KeyLock.Lock l = lock.lock(i);
-
-            assertNotNull(l);
-
-            sum += ints[i];
-
-            assertNull(lock.lock(i));
-
-            l.unlock();
-        }
-
-        assertEquals(sum0.get(), sum);
-
-        X.println("Sum: ", sum);
-    }
-
-    /**
-     * Test pointer factory.
-     */
-    private static final class TestPointerFactory implements GridOffHeapSmartPointerFactory<TestPointer> {
-        /** */
-        private TestPointer[] ptrs;
-
-        /**
-         * @param cnt Pointers count.
-         */
-        TestPointerFactory(int cnt) {
-            ptrs = new TestPointer[cnt];
-
-            for (int i = 0 ; i < ptrs.length; i++)
-                ptrs[i] = new TestPointer(i + 1);
-        }
-
-        /** {@inheritDoc} */
-        @Override public TestPointer createPointer(long ptr) {
-            assert ptr > 0 && ptr <= ptrs.length : ptr + " " + Long.toBinaryString(ptr);
-
-            return ptrs[((int)ptr) - 1];
-        }
-    }
-
-    /**
-     * Test pointer.
-     */
-    private static final class TestPointer implements GridOffHeapSmartPointer, Comparable<TestPointer> {
-        /** */
-        private final AtomicInteger refs = new AtomicInteger();
-
-        /** */
-        private final int ptr;
-
-        /**
-         * @param ptr Pointer.
-         */
-        private TestPointer(int ptr) {
-            this.ptr = ptr;
-        }
-
-        @Override public long pointer() {
-            return ptr;
-        }
-
-        @Override public void incrementRefCount() {
-            refs.incrementAndGet();
-        }
-
-        @Override public void decrementRefCount() {
-            int res = refs.decrementAndGet();
-
-            assert res >= 0 : D.dumpWithStop() + ptr;
-        }
-
-        @SuppressWarnings("SubtractionInCompareTo")
-        @Override public int compareTo(TestPointer o) {
-            assert o.refs.get() > 0 : o.refs.get();
-
-            return (int)(o.pointer() - pointer());
-        }
-
-        @Override public boolean equals(Object o) {
-            if (this == o) return true;
-
-            if (o == null || getClass() != o.getClass()) return false;
-
-            TestPointer that = (TestPointer)o;
-
-            return ptr == that.ptr;
-        }
-
-        @Override public int hashCode() {
-            throw new IllegalStateException();
-        }
-
-        @Override public String toString() {
-            return ptr + "(" + refs + ")";
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemoryPerformanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemoryPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemoryPerformanceTest.java
deleted file mode 100644
index b231a6f..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemoryPerformanceTest.java
+++ /dev/null
@@ -1,65 +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.util.offheap.unsafe;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public class GridUnsafeMemoryPerformanceTest extends GridCommonAbstractTest {
-    /**
-     * @throws Exception If failed.
-     */
-    public void testGuardedOpsPerformance() throws Exception {
-        final GridUnsafeGuard guard = new GridUnsafeGuard();
-
-        final AtomicInteger i = new AtomicInteger();
-
-        final AtomicBoolean run = new AtomicBoolean(true);
-
-        IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-            @Override public void run() {
-                int x = 0;
-
-                while (run.get()) {
-                    guard.begin();
-                    guard.end();
-
-                    x++;
-                }
-
-                i.addAndGet(x);
-            }
-        }, 4);
-
-        int time = 60;
-
-        Thread.sleep(time * 1000);
-
-        run.set(false);
-
-        fut.get();
-
-        X.println("Op/sec: " + (float) i.get() / time);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemorySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemorySelfTest.java
index ff278b2..47b0684 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemorySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemorySelfTest.java
@@ -21,17 +21,8 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Random;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReferenceArray;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.util.GridRandom;
 import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.jsr166.LongAdder8;
 
 /**
  * Tests unsafe memory.
@@ -267,189 +258,6 @@ public class GridUnsafeMemorySelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    public void testGuardedOpsSimple() throws Exception {
-        final GridUnsafeGuard guard = new GridUnsafeGuard();
-
-        final AtomicInteger i = new AtomicInteger();
-
-        guard.begin();
-
-        guard.finalizeLater(new Runnable() {
-            @Override public void run() {
-                i.incrementAndGet();
-            }
-        });
-
-        guard.begin();
-        assertEquals(0, i.get());
-        guard.end();
-
-        assertEquals(0, i.get());
-        guard.end();
-
-        X.println("__ " + guard);
-
-        assertEquals(1, i.get());
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testGuardedOps() throws Exception {
-        final int lineSize = 16;
-        final int ptrsCnt = 4;
-
-        final AtomicReferenceArray<CmpMem> ptrs = new AtomicReferenceArray<>(ptrsCnt * lineSize);
-
-        final AtomicBoolean finished = new AtomicBoolean();
-
-        final LongAdder8 cntr = new LongAdder8();
-
-        final GridUnsafeGuard guard = new GridUnsafeGuard();
-
-        GridRandom rnd = new GridRandom();
-
-        for (int a = 0; a < 7; a++) {
-            finished.set(false);
-
-            int threads = 2 + rnd.nextInt(37);
-            int time = rnd.nextInt(5);
-
-            X.println("__ starting threads: " + threads + " time: " + time + " sec");
-
-            final LongAdder8 locAdder = new LongAdder8();
-
-            IgniteInternalFuture<?> fut = multithreadedAsync(new Callable<Object>() {
-                @Override public Object call() throws Exception {
-                    Random rnd = new GridRandom();
-
-                    while (!finished.get()) {
-                        int idx = rnd.nextInt(ptrsCnt) * lineSize;
-
-                        guard.begin();
-
-                        try {
-                            final CmpMem old;
-
-                            CmpMem ptr = null;
-
-                            switch (rnd.nextInt(6)) {
-                                case 0:
-                                    ptr = new CmpMem(cntr);
-
-                                    //noinspection fallthrough
-                                case 1:
-                                    old = ptrs.getAndSet(idx, ptr);
-
-                                    if (old != null) {
-                                        guard.finalizeLater(new Runnable() {
-                                            @Override public void run() {
-                                                old.deallocate();
-                                            }
-                                        });
-                                    }
-
-                                    break;
-
-                                case 2:
-                                    if (rnd.nextBoolean())
-                                        ptr = new CmpMem(cntr);
-
-                                    old = ptrs.getAndSet(idx, ptr);
-
-                                    if (old != null)
-                                        guard.releaseLater(old);
-
-                                    break;
-
-                                default:
-                                    old = ptrs.get(idx);
-
-                                    if (old != null)
-                                        old.touch();
-                            }
-                        }
-                        finally {
-                            guard.end();
-
-                            locAdder.increment();
-                        }
-                    }
-
-                    return null;
-                }
-            }, threads);
-
-            Thread.sleep(1000 * time);
-
-            X.println("__ stopping ops...");
-
-            finished.set(true);
-
-            fut.get();
-
-            X.println("__ stopped, performed ops: " + locAdder.sum());
-
-            for (int i = 0; i < ptrs.length(); i++) {
-                CmpMem ptr = ptrs.getAndSet(i, null);
-
-                if (ptr != null) {
-                    ptr.touch();
-
-                    ptr.deallocate();
-                }
-            }
-
-            X.println("__ " + guard);
-
-            assertEquals(0, cntr.sum());
-        }
-    }
-
-    private static class CmpMem extends AtomicInteger implements GridUnsafeCompoundMemory {
-        /** */
-        private AtomicBoolean deallocated = new AtomicBoolean();
-
-        /** */
-        private LongAdder8 cntr;
-
-        /**
-         * @param cntr Counter.
-         */
-        CmpMem(LongAdder8 cntr) {
-            this.cntr = cntr;
-
-            cntr.increment();
-        }
-
-        public void touch() {
-            assert !deallocated.get();
-        }
-
-        @Override public void deallocate() {
-            boolean res = deallocated.compareAndSet(false, true);
-
-            assert res;
-
-            cntr.add(-get() - 1); // Merged plus this instance.
-        }
-
-        @Override public void merge(GridUnsafeCompoundMemory compound) {
-            touch();
-
-            CmpMem c = (CmpMem)compound;
-
-            c.touch();
-
-            assert c.get() == 0;
-
-            incrementAndGet();
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
     public void testCompare1() throws Exception {
         checkCompare("123");
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiIndexingSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiIndexingSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiIndexingSelfTestSuite.java
deleted file mode 100644
index a9fd618..0000000
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiIndexingSelfTestSuite.java
+++ /dev/null
@@ -1,38 +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.testsuites;
-
-import junit.framework.TestSuite;
-import org.apache.ignite.internal.util.offheap.unsafe.GridOffheapSnapTreeSelfTest;
-
-/**
- * Indexing SPI tests.
- */
-public class IgniteSpiIndexingSelfTestSuite extends TestSuite {
-    /**
-     * @return Failover SPI tests suite.
-     * @throws Exception If failed.
-     */
-    public static TestSuite suite() throws Exception {
-        TestSuite suite = new TestSuite("Ignite Indexing SPI Test Suite");
-
-        suite.addTest(new TestSuite(GridOffheapSnapTreeSelfTest.class));
-
-        return suite;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiTestSuite.java
index 7706684..5de61ae 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiTestSuite.java
@@ -56,9 +56,6 @@ public class IgniteSpiTestSuite extends TestSuite {
         // Communication.
         suite.addTest(IgniteSpiCommunicationSelfTestSuite.suite());
 
-        // Indexing.
-        suite.addTest(IgniteSpiIndexingSelfTestSuite.suite());
-
         // All other tests.
         suite.addTestSuite(GridNoopManagerSelfTest.class);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/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 d1f775e..2cd36b3 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
@@ -51,7 +51,7 @@ import org.h2.table.TableFilter;
 import org.h2.value.Value;
 import org.h2.value.ValueGeometry;
 
-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;
 
 /**
  * Spatial index.
@@ -97,6 +97,7 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
      * @param segmentsCnt Index segments count.
      * @param cols Columns.
      */
+    @SuppressWarnings("unchecked")
     public GridH2SpatialIndex(GridH2Table tbl, String idxName, int segmentsCnt, IndexColumn... cols) {
         if (cols.length > 1)
             throw DbException.getUnsupportedException("can only do one column");
@@ -157,7 +158,7 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
 
     /** {@inheritDoc} */
     @Override public GridH2Row put(GridH2Row row) {
-        assert row instanceof GridH2AbstractKeyValueRow : "requires key to be at 0";
+        assert row instanceof GridH2KeyValueRowOnheap : "requires key to be at 0";
 
         Lock l = lock.writeLock();
 
@@ -307,11 +308,6 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
     }
 
     /** {@inheritDoc} */
-    @Override public GridH2Row findOne(GridH2Row row) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean canGetFirstOrLast() {
         return true;
     }
@@ -321,6 +317,7 @@ public class GridH2SpatialIndex extends GridH2IndexBase implements SpatialIndex
      * @param filter Table filter.
      * @return Iterator over rows.
      */
+    @SuppressWarnings("unchecked")
     private GridCursor<GridH2Row> rowIterator(Iterator<SpatialKey> i, TableFilter filter) {
         if (!i.hasNext())
             return EMPTY_CURSOR;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryPartitionInfo.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryPartitionInfo.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryPartitionInfo.java
index 42bf070..12e9a39 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryPartitionInfo.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryPartitionInfo.java
@@ -114,6 +114,7 @@ public class CacheQueryPartitionInfo {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("SimplifiableIfStatement")
     @Override public boolean equals(Object obj) {
         if (this == obj)
             return true;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
index cbaa478..f2f2fd4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
@@ -96,7 +96,7 @@ import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.createJdbcSqlException;
 import static org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.UPDATE_RESULT_META;
-import static org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.DEFAULT_COLUMNS_COUNT;
+import static org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap.DEFAULT_COLUMNS_COUNT;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DatabaseType.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DatabaseType.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DatabaseType.java
index 8e4e639..3b75239 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DatabaseType.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DatabaseType.java
@@ -88,7 +88,7 @@ public enum H2DatabaseType {
     /** Map of Class to enum. */
     private static final Map<Class<?>, H2DatabaseType> map = new HashMap<>();
 
-    /**
+    /*
      * Initialize map of DB types.
      */
     static {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java
index 7b447dc..1b9aea3 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java
@@ -22,7 +22,6 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.NoSuchElementException;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.query.IgniteSQLException;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2ValueCacheObject;
 import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
@@ -39,7 +38,7 @@ public abstract class H2ResultSetIterator<T> extends GridCloseableIteratorAdapte
     /** */
     private static final Field RESULT_FIELD;
 
-    /**
+    /*
      * Initialize.
      */
     static {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/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 e59404e..8fb81ba 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
@@ -33,16 +33,12 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.processors.query.GridQueryProperty;
 import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
-import org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOffheap;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowFactory;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2ValueCacheObject;
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeGuard;
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
 import org.h2.message.DbException;
-import org.h2.mvstore.cache.CacheLongKeyLIRS;
 import org.h2.result.SearchRow;
 import org.h2.result.SimpleRow;
 import org.h2.util.LocalDateTimeUtils;
@@ -66,13 +62,12 @@ import org.h2.value.ValueString;
 import org.h2.value.ValueTime;
 import org.h2.value.ValueTimestamp;
 import org.h2.value.ValueUuid;
-import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.DEFAULT_COLUMNS_COUNT;
-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.GridH2AbstractKeyValueRow.VER_COL;
+import static org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap.DEFAULT_COLUMNS_COUNT;
+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.GridH2KeyValueRowOnheap.VER_COL;
 
 /**
  * Row descriptor.
@@ -100,12 +95,6 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
     private final int valType;
 
     /** */
-    private final H2Schema schema;
-
-    /** */
-    private final GridUnsafeGuard guard;
-
-    /** */
     private volatile GridQueryProperty[] props;
 
     /** Id of user-defined key column */
@@ -120,18 +109,13 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
      * @param idx Indexing.
      * @param tbl Table.
      * @param type Type descriptor.
-     * @param schema Schema.
      */
-    H2RowDescriptor(IgniteH2Indexing idx, H2TableDescriptor tbl, GridQueryTypeDescriptor type, H2Schema schema) {
+    H2RowDescriptor(IgniteH2Indexing idx, H2TableDescriptor tbl, GridQueryTypeDescriptor type) {
         assert type != null;
-        assert schema != null;
 
         this.idx = idx;
         this.tbl = tbl;
         this.type = type;
-        this.schema = schema;
-
-        guard = schema.offheap() == null ? null : new GridUnsafeGuard();
 
         keyType = DataType.getTypeFromClass(type.keyClass());
         valType = DataType.getTypeFromClass(type.valueClass());
@@ -192,30 +176,6 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
     }
 
     /** {@inheritDoc} */
-    @Override public GridUnsafeGuard guard() {
-        return guard;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void cache(GridH2Row row) {
-        long ptr = row.pointer();
-
-        assert ptr > 0 : ptr;
-
-        rowCache().put(ptr, row);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void uncache(long ptr) {
-        rowCache().remove(ptr);
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridUnsafeMemory memory() {
-        return schema.offheap();
-    }
-
-    /** {@inheritDoc} */
     @SuppressWarnings("ConstantConditions")
     @Override public Value wrap(Object obj, int type) throws IgniteCheckedException {
         assert obj != null;
@@ -305,9 +265,7 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
             if (val == null) // Only can happen for remove operation, can create simple search row.
                 row = GridH2RowFactory.create(wrap(key, keyType));
             else
-                row = schema.offheap() == null ?
-                    new GridH2KeyValueRowOnheap(this, key, keyType, val, valType, ver, expirationTime) :
-                    new GridH2KeyValueRowOffheap(this, key, keyType, val, valType, ver, expirationTime);
+                row = new GridH2KeyValueRowOnheap(this, key, keyType, val, valType, ver, expirationTime);
         }
         catch (ClassCastException e) {
             throw new IgniteCheckedException("Failed to convert key to SQL type. " +
@@ -365,24 +323,6 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
     }
 
     /** {@inheritDoc} */
-    @Override public GridH2KeyValueRowOffheap createPointer(long ptr) {
-        GridH2KeyValueRowOffheap row = (GridH2KeyValueRowOffheap)rowCache().get(ptr);
-
-        if (row != null) {
-            assert row.pointer() == ptr : ptr + " " + row.pointer();
-
-            return row;
-        }
-
-        return new GridH2KeyValueRowOffheap(this, ptr);
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridH2Row cachedRow(long link) {
-        return rowCache().get(link);
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean isKeyColumn(int colId) {
         assert colId >= 0;
         return colId == KEY_COL || colId == keyAliasColId;
@@ -488,11 +428,4 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
 
         return colId;
     }
-
-    /**
-     * @return Row cache.
-     */
-    @NotNull private CacheLongKeyLIRS<GridH2Row> rowCache() {
-        throw new UnsupportedOperationException(); // TODO: Unused for not.
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java
index 9c11099..3f39e6a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.query.h2;
 
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
 import org.jsr166.ConcurrentHashMap8;
 
 import java.util.Collection;
@@ -31,9 +30,6 @@ public class H2Schema {
     private final String schemaName;
 
     /** */
-    private final GridUnsafeMemory offheap = null;
-
-    /** */
     private final ConcurrentMap<String, H2TableDescriptor> tbls = new ConcurrentHashMap8<>();
 
     /** */
@@ -56,13 +52,6 @@ public class H2Schema {
     }
 
     /**
-     * @return Unsafe memory.
-     */
-    public GridUnsafeMemory offheap() {
-        return offheap;
-    }
-
-    /**
      * @return Tables.
      */
     public Collection<H2TableDescriptor> tables() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
index 5abfc4b..391b002 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
@@ -41,7 +41,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-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;
 
 /**
  * Information about table in database.
@@ -90,13 +90,6 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
     }
 
     /**
-     * @return Primary key hash index.
-     */
-    H2PkHashIndex primaryKeyHashIndex() {
-        return pkHashIdx;
-    }
-
-    /**
      * @return Table.
      */
     public GridH2Table table() {
@@ -207,7 +200,6 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
 
         // Add primary key index.
         Index pkIdx = idx.createSortedIndex(
-            schema,
             "_key_PK",
             tbl,
             true,
@@ -219,7 +211,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
 
         if (type().valueClass() == String.class) {
             try {
-                luceneIdx = new GridLuceneIndex(idx.kernalContext(), schema.offheap(), tbl.cacheName(), type);
+                luceneIdx = new GridLuceneIndex(idx.kernalContext(), tbl.cacheName(), type);
             }
             catch (IgniteCheckedException e1) {
                 throw new IgniteException(e1);
@@ -232,7 +224,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
 
         if (textIdx != null) {
             try {
-                luceneIdx = new GridLuceneIndex(idx.kernalContext(), schema.offheap(), tbl.cacheName(), type);
+                luceneIdx = new GridLuceneIndex(idx.kernalContext(), tbl.cacheName(), type);
             }
             catch (IgniteCheckedException e1) {
                 throw new IgniteException(e1);
@@ -258,7 +250,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
 
         // Add explicit affinity key index if nothing alike was found.
         if (affCol != null && !affIdxFound) {
-            idxs.add(idx.createSortedIndex(schema, "AFFINITY_KEY", tbl, false,
+            idxs.add(idx.createSortedIndex("AFFINITY_KEY", tbl, false,
                 H2Utils.treeIndexColumns(desc, new ArrayList<IndexColumn>(2), affCol, keyCol), -1));
         }
 
@@ -308,7 +300,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
         if (idxDesc.type() == QueryIndexType.SORTED) {
             cols = H2Utils.treeIndexColumns(desc, cols, keyCol, affCol);
 
-            return idx.createSortedIndex(schema, idxDesc.name(), tbl, false, cols, idxDesc.inlineSize());
+            return idx.createSortedIndex(idxDesc.name(), tbl, false, cols, idxDesc.inlineSize());
         }
         else if (idxDesc.type() == QueryIndexType.GEOSPATIAL)
             return H2Utils.createSpatialIndex(tbl, idxDesc.name(), cols.toArray(new IndexColumn[cols.size()]));

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java
index cc14abd..f345207 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java
@@ -62,6 +62,7 @@ public class H2TwoStepCachedQueryKey {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("SimplifiableIfStatement")
     @Override public boolean equals(Object o) {
         if (this == o)
             return true;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 03e2391..00a37ce 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -598,10 +598,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         Statement stmt = null;
 
         try {
-            // NOTE: there is no method dropIndex() for lucene engine correctly working.
-            // So we have to drop all lucene index.
-            // FullTextLucene.dropAll(c); TODO: GG-4015: fix this
-
             stmt = c.createStatement();
 
             String sql = "DROP TABLE IF EXISTS " + tbl.fullTableName();
@@ -756,15 +752,14 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     /**
      * Create sorted index.
      *
-     * @param schema Schema.
      * @param name Index name,
      * @param tbl Table.
      * @param pk Primary key flag.
      * @param cols Columns.
      * @return Index.
      */
-    public GridH2IndexBase createSortedIndex(H2Schema schema, String name, GridH2Table tbl, boolean pk,
-        List<IndexColumn> cols, int inlineSize) {
+    public GridH2IndexBase createSortedIndex(String name, GridH2Table tbl, boolean pk, List<IndexColumn> cols,
+        int inlineSize) {
         try {
             GridCacheContext cctx = tbl.cache();
 
@@ -1654,7 +1649,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         if (log.isDebugEnabled())
             log.debug("Creating DB table with SQL: " + sql);
 
-        H2RowDescriptor rowDesc = new H2RowDescriptor(this, tbl, tbl.type(), schema);
+        H2RowDescriptor rowDesc = new H2RowDescriptor(this, tbl, tbl.type());
 
         H2RowFactory rowFactory = tbl.rowFactory(rowDesc);
 
@@ -1877,7 +1872,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("NonThreadSafeLazyInitialization")
+    @SuppressWarnings({"NonThreadSafeLazyInitialization", "deprecation"})
     @Override public void start(GridKernalContext ctx, GridSpinBusyLock busyLock) throws IgniteCheckedException {
         if (log.isDebugEnabled())
             log.debug("Starting cache query index...");
@@ -1961,9 +1956,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             U.warn(log, "Custom H2 serialization is already configured, will override.");
 
         JdbcUtils.serializer = h2Serializer();
-
-        // TODO https://issues.apache.org/jira/browse/IGNITE-2139
-        // registerMBean(igniteInstanceName, this, GridH2IndexingSpiMBean.class);
     }
 
     /**
@@ -2127,7 +2119,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         mapQryExec.cancelLazyWorkers();
 
-//        unregisterMBean(); TODO https://issues.apache.org/jira/browse/IGNITE-2139
         if (ctx != null && !ctx.cache().context().database().persistenceEnabled()) {
             for (H2Schema schema : schemas.values())
                 schema.dropAll();

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/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 1937a4b..b32bfb8 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
@@ -121,23 +121,6 @@ public class H2PkHashIndex extends GridH2IndexBase {
     }
 
     /** {@inheritDoc} */
-    @Override public GridH2Row findOne(GridH2Row row) {
-        try {
-            for (IgniteCacheOffheapManager.CacheDataStore store : cctx.offheap().cacheDataStores()) {
-                CacheDataRow found = store.find(cctx, row.key);
-
-                if (found != null)
-                    tbl.rowDescriptor().createRow(row.key(), row.partition(), row.value(), row.version(), 0);
-            }
-
-            return null;
-        }
-        catch (IgniteCheckedException e) {
-            throw DbException.convert(e);
-        }
-    }
-
-    /** {@inheritDoc} */
     @SuppressWarnings("StatementWithEmptyBody")
     @Override public GridH2Row put(GridH2Row row) {
         // Should not be called directly. Rows are inserted into underlying cache data stores.
@@ -158,15 +141,6 @@ public class H2PkHashIndex extends GridH2IndexBase {
 
     /** {@inheritDoc} */
     @Override public double getCost(Session ses, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet<Column> allColumnsSet) {
-        long rowCnt = getRowCountApproximation();
-
-        double baseCost = getCostRangeIndex(masks, rowCnt, filters, filter, sortOrder, false, allColumnsSet);
-
-        int mul = getDistributedMultiplier(ses, filters, filter);
-
-        // TODO : How to calculate cost?
-
-//        return mul * baseCost;
         return Double.MAX_VALUE;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
index b60328d..6214be4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
@@ -158,6 +158,7 @@ public abstract class H2Tree extends BPlusTree<SearchRow, GridH2Row> {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     @Override protected int compare(BPlusIO<SearchRow> io, long pageAddr, int idx,
         SearchRow row) throws IgniteCheckedException {
         if (inlineSize() == 0)

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/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 de5dc75..5c3e1bd 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
@@ -186,20 +186,6 @@ public class H2TreeIndex extends GridH2IndexBase {
     }
 
     /** {@inheritDoc} */
-    @Override public GridH2Row findOne(GridH2Row row) {
-        try {
-            int seg = segmentForRow(row);
-
-            H2Tree tree = treeForRead(seg);
-
-            return tree.findOne(row);
-        }
-        catch (IgniteCheckedException e) {
-            throw DbException.convert(e);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public GridH2Row put(GridH2Row row) {
         try {
             InlineIndexHelper.setCurrentInlineIndexes(inlineIdxs);

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java
index 1789ac8..8ae3bc9 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java
@@ -866,7 +866,6 @@ public class InlineIndexHelper {
             }
 
             case Value.BYTES: {
-                byte[] s;
                 short size;
 
                 PageUtils.putByte(pageAddr, off, (byte)val.getType());
@@ -881,6 +880,7 @@ public class InlineIndexHelper {
                     PageUtils.putShort(pageAddr, off + 1, size);
                     PageUtils.putBytes(pageAddr, off + 3, Arrays.copyOfRange(val.getBytes(), 0, maxSize - 3));
                 }
+
                 return size + 3;
             }
 
@@ -917,6 +917,7 @@ public class InlineIndexHelper {
      * @param v2 Second value;
      * @return {@code true} if we can rely on compare result.
      */
+    @SuppressWarnings("RedundantIfStatement")
     protected boolean canRelyOnCompare(int c, Value shortVal, Value v2) {
         switch (type) {
             case Value.STRING:

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasInnerIO.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasInnerIO.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasInnerIO.java
index 0e8407c..7d41617 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasInnerIO.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasInnerIO.java
@@ -47,6 +47,7 @@ public class H2ExtrasInnerIO extends BPlusInnerIO<SearchRow> {
      * @param payload Payload size.
      * @return IOVersions for given payload.
      */
+    @SuppressWarnings("unchecked")
     public static IOVersions<? extends BPlusInnerIO<SearchRow>> getVersions(int payload) {
         assert payload >= 0 && payload <= PageIO.MAX_PAYLOAD_SIZE;
 
@@ -76,6 +77,7 @@ public class H2ExtrasInnerIO extends BPlusInnerIO<SearchRow> {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     @Override public void storeByOffset(long pageAddr, int off, SearchRow row) {
         GridH2Row row0 = (GridH2Row)row;
 
@@ -109,9 +111,7 @@ public class H2ExtrasInnerIO extends BPlusInnerIO<SearchRow> {
 
         assert link != 0;
 
-        GridH2Row r0 = ((H2Tree)tree).getRowFactory().getRow(link);
-
-        return r0;
+        return ((H2Tree)tree).getRowFactory().getRow(link);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasLeafIO.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasLeafIO.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasLeafIO.java
index 4a68739..3fe72b7 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasLeafIO.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2ExtrasLeafIO.java
@@ -47,6 +47,7 @@ public class H2ExtrasLeafIO extends BPlusLeafIO<SearchRow> {
      * @param payload Payload size.
      * @return IOVersions for given payload.
      */
+    @SuppressWarnings("unchecked")
     public static IOVersions<? extends BPlusLeafIO<SearchRow>> getVersions(int payload) {
         assert payload >= 0 && payload <= PageIO.MAX_PAYLOAD_SIZE;
 
@@ -76,6 +77,7 @@ public class H2ExtrasLeafIO extends BPlusLeafIO<SearchRow> {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     @Override public void storeByOffset(long pageAddr, int off, SearchRow row) {
         GridH2Row row0 = (GridH2Row)row;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/util/CompareUtils.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/util/CompareUtils.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/util/CompareUtils.java
deleted file mode 100644
index 565f566..0000000
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/util/CompareUtils.java
+++ /dev/null
@@ -1,332 +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.database.util;
-
-import java.math.BigDecimal;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.h2.util.MathUtils;
-import org.h2.value.Value;
-
-/**
- *
- */
-public class CompareUtils {
-    /** */
-    private static final int UTF_8_MIN_2_BYTES = 0x80;
-
-    /** */
-    private static final int UTF_8_MIN_3_BYTES = 0x800;
-
-    /** */
-    private static final int UTF_8_MIN_4_BYTES = 0x10000;
-
-    /** */
-    private static final int UTF_8_MAX_CODE_POINT = 0x10ffff;
-
-    /** */
-    private static final BigDecimal MAX_LONG_DECIMAL = BigDecimal.valueOf(Long.MAX_VALUE);
-
-    /** */
-    private static final BigDecimal MIN_LONG_DECIMAL = BigDecimal.valueOf(Long.MIN_VALUE);
-
-    /**
-     * @param x Value.
-     * @return Byte value.
-     */
-    public static byte convertToByte(long x) {
-        if (x > Byte.MAX_VALUE || x < Byte.MIN_VALUE)
-            throw new IgniteException("Numeric value out of range: " + x);
-
-        return (byte) x;
-    }
-
-    /**
-     * @param x Value.
-     * @return Short value.
-     */
-    public static short convertToShort(long x) {
-        if (x > Short.MAX_VALUE || x < Short.MIN_VALUE)
-            throw new IgniteException("Numeric value out of range: " + x);
-
-        return (short) x;
-    }
-
-    /**
-     * @param x Value.
-     * @return Int value.
-     */
-    public static int convertToInt(long x) {
-        if (x > Integer.MAX_VALUE || x < Integer.MIN_VALUE)
-            throw new IgniteException("Numeric value out of range: " + x);
-
-        return (int) x;
-    }
-
-    /**
-     * @param x Value.
-     * @return Long value.
-     */
-    public static long convertToLong(double x) {
-        if (x > Long.MAX_VALUE || x < Long.MIN_VALUE)
-            throw new IgniteException("Numeric value out of range: " + x);
-
-        return Math.round(x);
-    }
-
-    /**
-     * @param x Value.
-     * @return Long value.
-     */
-    public static long convertToLong(BigDecimal x) {
-        if (x.compareTo(MAX_LONG_DECIMAL) > 0 || x.compareTo(MIN_LONG_DECIMAL) < 0)
-            throw new IgniteException("Numeric value out of range: " + x);
-
-        return x.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
-    }
-
-    /**
-     * @param v Value1.
-     * @param val Value2.
-     * @return Compare result.
-     */
-    public static int compareBoolean(boolean v, Value val) {
-        boolean v2 = val.getBoolean();
-
-        return (v == v2) ? 0 : (v ? 1 : -1);
-    }
-
-    /**
-     * @param v Value1.
-     * @param val Value2.
-     * @return Compare result.
-     */
-    public static int compareByte(byte v, Value val) {
-        byte v2 = val.getByte();
-
-        return MathUtils.compareInt(v, v2);
-    }
-
-    /**
-     * @param val1Addr First string UTF-8 bytes address.
-     * @param val1Len Number of bytes in first string.
-     * @param val2Bytes Second string bytes.
-     * @param val2Off Second string offset.
-     * @param val2Len Number of bytes in second string.
-     * @return Compare result.
-     * @throws IgniteCheckedException In case of error.
-     */
-    public static int compareUtf8(long val1Addr,
-                                  int val1Len,
-                                  byte[] val2Bytes,
-                                  int val2Off,
-                                  int val2Len) throws IgniteCheckedException {
-        int len = Math.min(val1Len, val2Len);
-
-        for (int i = 0; i < len; i++) {
-            int b1 = GridUnsafe.getByte(val1Addr + i) & 0xFF;
-            int b2 = val2Bytes[val2Off + i] & 0xFF;
-
-            if (b1 != b2)
-                return b1 > b2 ? 1 : -1;
-        }
-
-        return Integer.compare(val1Len, val2Len);
-    }
-
-    /**
-     * @param addr UTF-8 bytes address.
-     * @param len Number of bytes to decode.
-     * @param str String to compare with.
-     * @return Compare result.
-     * @throws IgniteCheckedException In case of error.
-     */
-    public static int compareUtf8(long addr, int len, String str) throws IgniteCheckedException {
-        int pos = 0;
-
-        int cntr = 0;
-
-        int strLen = str.length();
-
-        // ASCII only optimized loop.
-        while (pos < len) {
-            byte ch = GridUnsafe.getByte(addr + pos);
-
-            if (ch >= 0) {
-                char c0 = (char)ch;
-
-                if (cntr < strLen) {
-                    char c1 = str.charAt(cntr);
-
-                    if (c0 != c1)
-                        return c0 - c1;
-                }
-                else
-                    return 1;
-
-                cntr++;
-
-                pos++;
-            }
-            else
-                break;
-        }
-
-        // TODO: check index bounds.
-
-        while (pos < len) {
-            int ch = GridUnsafe.getByte(addr + pos++) & 0xff;
-
-            // Convert UTF-8 to 21-bit codepoint.
-            if (ch < 0x80) {
-                // 0xxxxxxx -- length 1.
-            }
-            else if (ch < 0xc0) {
-                // 10xxxxxx -- illegal!
-                throw new IgniteException("Illegal UTF-8 sequence.");
-            }
-            else if (ch < 0xe0) {
-                // 110xxxxx 10xxxxxx
-                ch = ((ch & 0x1f) << 6);
-
-                checkByte(GridUnsafe.getByte(addr + pos));
-
-                ch |= (GridUnsafe.getByte(addr + pos++) & 0x3f);
-
-                checkMinimal(ch, UTF_8_MIN_2_BYTES);
-            }
-            else if (ch < 0xf0) {
-                // 1110xxxx 10xxxxxx 10xxxxxx
-                ch = ((ch & 0x0f) << 12);
-
-                checkByte(GridUnsafe.getByte(addr + pos));
-
-                ch |= ((GridUnsafe.getByte(addr + pos++) & 0x3f) << 6);
-
-                checkByte(GridUnsafe.getByte(addr + pos));
-
-                ch |= (GridUnsafe.getByte(addr + pos++) & 0x3f);
-
-                checkMinimal(ch, UTF_8_MIN_3_BYTES);
-            }
-            else if (ch < 0xf8) {
-                // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-                ch = ((ch & 0x07) << 18);
-
-                checkByte(GridUnsafe.getByte(addr + pos));
-
-                ch |= ((GridUnsafe.getByte(addr + pos++) & 0x3f) << 12);
-
-                checkByte(GridUnsafe.getByte(addr + pos));
-
-                ch |= ((GridUnsafe.getByte(addr + pos++) & 0x3f) << 6);
-
-                checkByte(GridUnsafe.getByte(addr + pos));
-
-                ch |= (GridUnsafe.getByte(addr + pos++) & 0x3f);
-
-                checkMinimal(ch, UTF_8_MIN_4_BYTES);
-            }
-            else
-                throw new IgniteException("Illegal UTF-8 sequence.");
-
-            if (ch > UTF_8_MAX_CODE_POINT)
-                throw new IgniteException("Illegal UTF-8 sequence.");
-
-            // Convert 21-bit codepoint to Java chars:
-            //   0..ffff are represented directly as a single char
-            //   10000..10ffff are represented as a "surrogate pair" of two chars
-            if (ch > 0xffff) {
-                // Use a surrogate pair to represent it.
-                ch -= 0x10000;  // ch is now 0..fffff (20 bits)
-
-                char c0 = (char)(0xd800 + (ch >> 10));   // Top 10 bits.
-
-                if (cntr < strLen) {
-                    char c1 = str.charAt(cntr);
-
-                    if (c0 != c1)
-                        return c0 - c1;
-                }
-                else
-                    return 1;
-
-                cntr++;
-
-                c0 = (char)(0xdc00 + (ch & 0x3ff)); // Bottom 10 bits.
-
-                if (cntr < strLen) {
-                    char c1 = str.charAt(cntr);
-
-                    if (c0 != c1)
-                        return c0 - c1;
-                }
-                else
-                    return 1;
-
-                cntr++;
-            }
-            else if (ch >= 0xd800 && ch < 0xe000)
-                // Not allowed to encode the surrogate range directly.
-                throw new IgniteException("Illegal UTF-8 sequence.");
-            else {
-                // Normal case.
-                char c0 = (char)ch;
-
-                if (cntr < strLen) {
-                    char c1 = str.charAt(cntr);
-
-                    if (c0 != c1)
-                        return c0 - c1;
-                }
-                else
-                    return 1;
-
-                cntr++;
-            }
-        }
-
-        // Check if we ran past the end without seeing an exception.
-        if (pos > len)
-            throw new IgniteException("Illegal UTF-8 sequence.");
-
-        return cntr - strLen;
-    }
-
-    /**
-     * @param ch UTF-8 byte.
-     * @throws IgniteException In case of error.
-     */
-    private static void checkByte(int ch) {
-        if ((ch & 0xc0) != 0x80)
-            throw new IgniteException("Illegal UTF-8 sequence.");
-    }
-
-    /**
-     * @param ch UTF-8 byte.
-     * @param minVal Minimum value.
-     * @throws IgniteException In case of error.
-     */
-    private static void checkMinimal(int ch, int minVal) {
-        if (ch >= minVal)
-            return;
-
-        throw new IgniteException("Illegal UTF-8 sequence.");
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a095674/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
index b304109..285a0b0 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
@@ -54,7 +54,7 @@ import org.h2.command.Prepared;
 import org.h2.table.Column;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.internal.processors.query.h2.opt.GridH2AbstractKeyValueRow.DEFAULT_COLUMNS_COUNT;
+import static org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap.DEFAULT_COLUMNS_COUNT;
 
 /**
  * Logic for building update plans performed by {@link DmlStatementsProcessor}.
@@ -115,7 +115,7 @@ public final class UpdatePlanBuilder {
             desc = tbl.dataTable().rowDescriptor();
 
             cols = ins.columns();
-            sel = DmlAstUtils.selectForInsertOrMerge(cols, ins.rows(), ins.query(), desc);
+            sel = DmlAstUtils.selectForInsertOrMerge(cols, ins.rows(), ins.query());
             isTwoStepSubqry = (ins.query() != null);
             rowsNum = isTwoStepSubqry ? 0 : ins.rows().size();
         }
@@ -136,7 +136,7 @@ public final class UpdatePlanBuilder {
                 throw new CacheException("SQL MERGE does not support arbitrary keys");
 
             cols = merge.columns();
-            sel = DmlAstUtils.selectForInsertOrMerge(cols, merge.rows(), merge.query(), desc);
+            sel = DmlAstUtils.selectForInsertOrMerge(cols, merge.rows(), merge.query());
             isTwoStepSubqry = (merge.query() != null);
             rowsNum = isTwoStepSubqry ? 0 : merge.rows().size();
         }


Mime
View raw message