sql-store-idx - replace on update
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/252296f7 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/252296f7 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/252296f7 Branch: refs/heads/sql-store Commit: 252296f783138c36c1482b57b9b31fcfee3b5c70 Parents: 8ad73cb Author: S.Vladykin <[email protected]> Authored: Mon Feb 1 03:30:35 2016 +0300 Committer: Alexey Goncharuk <[email protected]> Committed: Wed Feb 3 17:13:42 2016 +0300 ---------------------------------------------------------------------- .../processors/query/h2/IgniteH2Indexing.java | 32 +++++++++++++++----- .../processors/query/h2/opt/GridH2Row.java | 10 ++++-- .../query/h2/opt/GridH2RowDescriptor.java | 4 ++- .../processors/query/h2/opt/GridH2Table.java | 9 ++---- 4 files changed, 37 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/252296f7/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 4cd7cb6..79b081a 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 @@ -2441,21 +2441,39 @@ public class IgniteH2Indexing implements GridQueryIndexing { } /** {@inheritDoc} */ - @Override public GridH2Row createRow(CacheObject key, @Nullable CacheObject val, long expirationTime) - throws IgniteCheckedException { + @Override public GridH2Row createRow(CacheObject key, @Nullable CacheObject val, GridCacheVersion ver, + long expirationTime) throws IgniteCheckedException { + GridH2Row row; + try { if (val == null) // Only can happen for remove operation, can create simple search row. - return new GridH2Row(wrap(key, keyType), null); - - return schema.offheap == null ? - new GridH2KeyValueRowOnheap(this, key, keyType, val, valType, expirationTime) : - new GridH2KeyValueRowOffheap(this, key, keyType, val, valType, expirationTime); + row = new GridH2Row(wrap(key, keyType), null); + else + row = schema.offheap == null ? + new GridH2KeyValueRowOnheap(this, key, keyType, val, valType, expirationTime) : + new GridH2KeyValueRowOffheap(this, key, keyType, val, valType, expirationTime); } catch (ClassCastException e) { throw new IgniteCheckedException("Failed to convert key to SQL type. " + "Please make sure that you always store each value type with the same key type " + "or configure key type as common super class for all actual keys for this value type.", e); } + + if (val != null) { + row.ver = ver; + + CacheObjectContext coctx = cacheContext(schema.spaceName).cacheObjectContext(); + + try { + row.key = key.valueBytes(coctx); + row.val = val.valueBytes(coctx); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + } + + return row; } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/252296f7/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 a1aa728..d5b5e0d 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 @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.query.h2.opt; -import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.h2.result.Row; import org.h2.value.Value; @@ -29,10 +29,14 @@ public class GridH2Row extends Row implements GridSearchRowPointer { public long link; // TODO remove /** */ - public CacheObject key; // TODO remove + public byte[] key; // TODO remove /** */ - public CacheObject val; // TODO remove + public byte[] val; // TODO remove + + /** */ + public GridCacheVersion ver; // TODO remove + /** * @param data Column values. http://git-wip-us.apache.org/repos/asf/ignite/blob/252296f7/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 80dcfcb..530f68c 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 @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.query.h2.opt; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; 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; @@ -40,11 +41,12 @@ public interface GridH2RowDescriptor extends GridOffHeapSmartPointerFactory<Grid * * @param key Key. * @param val Value. + * @param ver Version. * @param expirationTime Expiration time in millis. * @return Row. * @throws IgniteCheckedException If failed. */ - public GridH2Row createRow(CacheObject key, @Nullable CacheObject val, long expirationTime) + public GridH2Row createRow(CacheObject key, @Nullable CacheObject val, GridCacheVersion ver, long expirationTime) throws IgniteCheckedException; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/252296f7/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 4a00296..b39cce0 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 @@ -169,7 +169,7 @@ public class GridH2Table extends TableBase { assert desc != null; - GridH2Row searchRow = desc.createRow(key, null, 0); + GridH2Row searchRow = desc.createRow(key, null, null, 0); GridUnsafeMemory mem = desc.memory(); @@ -335,12 +335,7 @@ public class GridH2Table extends TableBase { throws IgniteCheckedException { assert desc != null; - // TODO use version here. - - GridH2Row row = desc.createRow(key, val, expirationTime); - - row.key = key; - row.val = val; + GridH2Row row = desc.createRow(key, val, ver, expirationTime); return doUpdate(row, rmv); }
