You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2021/04/21 20:26:10 UTC

[ignite-3] branch ignite-13670 updated (091605b -> 55df701)

This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a change to branch ignite-13670
in repository https://gitbox.apache.org/repos/asf/ignite-3.git.


 discard 091605b  Put RowFlags in order described in IEP.
     new 3355eda  Put RowFlags in order described in IEP.
     new 55df701  Minor refactoring.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (091605b)
            \
             N -- N -- N   refs/heads/ignite-13670 (55df701)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/ignite/internal/schema/BinaryRow.java     |  2 +-
 .../main/java/org/apache/ignite/internal/schema/Row.java | 16 ++++++++++++----
 .../org/apache/ignite/internal/schema/RowAssembler.java  | 11 +++++++----
 3 files changed, 20 insertions(+), 9 deletions(-)

[ignite-3] 02/02: Minor refactoring.

Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch ignite-13670
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit 55df701b77191056f4d6d0f4788d13966de447f3
Author: Andrew Mashenkov <an...@gmail.com>
AuthorDate: Wed Apr 21 23:24:06 2021 +0300

    Minor refactoring.
---
 .../main/java/org/apache/ignite/internal/schema/Row.java | 16 ++++++++++++----
 .../org/apache/ignite/internal/schema/RowAssembler.java  | 11 +++++++----
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/Row.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/Row.java
index b9cf9cd..2b736ad 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/Row.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/Row.java
@@ -38,6 +38,14 @@ public class Row implements BinaryRow {
     private final BinaryRow row;
 
     /**
+     * @param itemIdx Varlen table item index.
+     * @return Varlen item offset.
+     */
+    public static int varlenItemOffset(int itemIdx) {
+        return VARLEN_TABLE_SIZE_FIELD_SIZE + itemIdx * VARLEN_COLUMN_OFFSET_FIELD_SIZE;
+    }
+
+    /**
      * Constructor.
      *
      * @param schema Schema.
@@ -431,15 +439,15 @@ public class Row implements BinaryRow {
         idx -= cols.numberOfFixsizeColumns() + numNullsBefore;
         int vartableSize = readShort(vartableOffset(baseOff, cols));
 
-        int vartableOff = vartableOffset(baseOff, cols) + VARLEN_TABLE_SIZE_FIELD_SIZE;
+        int vartableOff = vartableOffset(baseOff, cols);
         // Offset of idx-th column is from base offset.
-        int resOff = readShort(vartableOff + VARLEN_COLUMN_OFFSET_FIELD_SIZE * idx);
+        int resOff = readShort(vartableOff + varlenItemOffset(idx));
 
         long len = idx == vartableSize - 1 ?
             // totalLength - columnStartOffset
             readInteger(baseOff) - resOff :
             // nextColumnStartOffset - columnStartOffset
-            readShort(vartableOff + VARLEN_COLUMN_OFFSET_FIELD_SIZE * (idx + 1)) - resOff;
+            readShort(vartableOff + varlenItemOffset(idx + 1)) - resOff;
 
         return (len << 32) | (resOff + baseOff);
     }
@@ -472,7 +480,7 @@ public class Row implements BinaryRow {
 
         final int vartableOffset = vartableOffset(baseOff, cols);
 
-        int vartableLen = VARLEN_TABLE_SIZE_FIELD_SIZE + readShort(vartableOffset) * VARLEN_COLUMN_OFFSET_FIELD_SIZE;
+        int vartableLen = varlenItemOffset(readShort(vartableOffset));
 
         return vartableOffset + vartableLen + off;
     }
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java
index 1d589d5..08d9a58 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java
@@ -24,6 +24,9 @@ import java.util.BitSet;
 import java.util.UUID;
 import org.apache.ignite.internal.schema.BinaryRow.RowFlags;
 
+import static org.apache.ignite.internal.schema.BinaryRow.VARLEN_COLUMN_OFFSET_FIELD_SIZE;
+import static org.apache.ignite.internal.schema.BinaryRow.VARLEN_TABLE_SIZE_FIELD_SIZE;
+
 /**
  * Utility class to build rows using column appending pattern. The external user of this class must consult
  * with the schema and provide the columns in strict internal column sort order during the row construction.
@@ -77,7 +80,7 @@ public class RowAssembler {
      * @return Total size of the varlen table.
      */
     public static int varlenTableSize(int nonNullVarlenCols) {
-        return nonNullVarlenCols * BinaryRow.VARLEN_COLUMN_OFFSET_FIELD_SIZE;
+        return VARLEN_TABLE_SIZE_FIELD_SIZE + nonNullVarlenCols * VARLEN_COLUMN_OFFSET_FIELD_SIZE;
     }
 
     /**
@@ -138,7 +141,7 @@ public class RowAssembler {
      */
     static int rowChunkSize(Columns cols, int nonNullVarlenCols, int nonNullVarlenSize) {
         int size = BinaryRow.CHUNK_LEN_FIELD_SIZE + cols.nullMapSize() +
-            BinaryRow.VARLEN_TABLE_SIZE_FIELD_SIZE + varlenTableSize(nonNullVarlenCols);
+            varlenTableSize(nonNullVarlenCols);
 
         for (int i = 0; i < cols.numberOfFixsizeColumns(); i++)
             size += cols.column(i).type().length();
@@ -379,7 +382,7 @@ public class RowAssembler {
     private void writeOffset(int tblEntryIdx, int off) {
         assert (flags & (baseOff == BinaryRow.KEY_CHUNK_OFFSET ? RowFlags.NO_VARLEN_KEY_COL : RowFlags.NO_VARLEN_VALUE_COL)) == 0;
 
-        buf.putShort(varlenTblOff + BinaryRow.VARLEN_COLUMN_OFFSET_FIELD_SIZE * tblEntryIdx, (short)off);
+        buf.putShort(varlenTblOff + Row.varlenItemOffset(tblEntryIdx), (short)off);
     }
 
     /**
@@ -473,7 +476,7 @@ public class RowAssembler {
         curVarlenTblEntry = 0;
 
         nullMapOff = baseOff + BinaryRow.CHUNK_LEN_FIELD_SIZE;
-        varlenTblOff = nullMapOff + curCols.nullMapSize() + BinaryRow.VARLEN_TABLE_SIZE_FIELD_SIZE;
+        varlenTblOff = nullMapOff + curCols.nullMapSize();
 
         curOff = varlenTblOff + varlenTableSize(nonNullVarlenCols);
     }

[ignite-3] 01/02: Put RowFlags in order described in IEP.

Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch ignite-13670
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit 3355eda6354e3da7089acdccc0f80de24eca70b4
Author: Andrew Mashenkov <an...@gmail.com>
AuthorDate: Wed Apr 21 22:59:19 2021 +0300

    Put RowFlags in order described in IEP.
---
 .../apache/ignite/internal/schema/BinaryRow.java   | 17 +++++++++---
 .../ignite/internal/schema/ByteBufferRow.java      |  2 +-
 .../ignite/internal/schema/RowAssembler.java       |  9 ++++--
 .../ignite/internal/schema/RowAssemblerTest.java   | 32 +++++++++++-----------
 4 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/BinaryRow.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/BinaryRow.java
index 776504a..577f50b 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/BinaryRow.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/BinaryRow.java
@@ -133,11 +133,20 @@ public interface BinaryRow {
      * Row flags.
      */
     final class RowFlags {
-        /** Tombstone flag. */
-        public static final int TOMBSTONE = 1;
+        /** Flag indicated is row has no value chunk. */
+        public static final int NO_VALUE = 1;
 
-        /** Null-value flag. */
-        public static final int NULL_VALUE = 1 << 1;
+        /** Flag indicates key chunk omits null map. */
+        public static final int NO_KEY_NULL_MAP = 1 << 1;
+
+        /** Flag indicates value chunk omits null map. */
+        public static final int NO_VALUE_NULL_MAP = 1 << 2;
+
+        /** Flag indicates key chunk omits varlen table. */
+        public static final int NO_VARLEN_KEY_COL = 1 << 3;
+
+        /** Flag indicates value chunk omits varlen table. */
+        public static final int NO_VARLEN_VALUE_COL = 1 << 4;
 
         /** Stub. */
         private RowFlags() {
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/ByteBufferRow.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/ByteBufferRow.java
index 86672c7..8b86bc7 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/ByteBufferRow.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/ByteBufferRow.java
@@ -57,7 +57,7 @@ public class ByteBufferRow implements BinaryRow {
     @Override public boolean hasValue() {
         short flags = readShort(FLAGS_FIELD_OFFSET);
 
-        return (flags & (RowFlags.NULL_VALUE | RowFlags.TOMBSTONE)) == 0;
+        return (flags & RowFlags.NO_VALUE) == 0;
     }
 
     /** {@inheritDoc} */
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java
index 8994ab1..1d589d5 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java
@@ -22,6 +22,7 @@ import java.nio.charset.CharsetEncoder;
 import java.nio.charset.StandardCharsets;
 import java.util.BitSet;
 import java.util.UUID;
+import org.apache.ignite.internal.schema.BinaryRow.RowFlags;
 
 /**
  * Utility class to build rows using column appending pattern. The external user of this class must consult
@@ -349,9 +350,9 @@ public class RowAssembler {
             throw new AssemblyException("Key column missed: colIdx=" + curCol);
         else {
             if (curCol == 0)
-                flags |= BinaryRow.RowFlags.NULL_VALUE;
+                flags |= RowFlags.NO_VALUE;
             else if (schema.valueColumns().length() != curCol)
-            throw new AssemblyException("Value column missed: colIdx=" + curCol);
+                throw new AssemblyException("Value column missed: colIdx=" + curCol);
         }
 
         buf.putShort(BinaryRow.FLAGS_FIELD_OFFSET, flags);
@@ -376,6 +377,8 @@ public class RowAssembler {
      * @param off Offset to write.
      */
     private void writeOffset(int tblEntryIdx, int off) {
+        assert (flags & (baseOff == BinaryRow.KEY_CHUNK_OFFSET ? RowFlags.NO_VARLEN_KEY_COL : RowFlags.NO_VARLEN_VALUE_COL)) == 0;
+
         buf.putShort(varlenTblOff + BinaryRow.VARLEN_COLUMN_OFFSET_FIELD_SIZE * tblEntryIdx, (short)off);
     }
 
@@ -407,6 +410,8 @@ public class RowAssembler {
      * @param colIdx Column index.
      */
     private void setNull(int colIdx) {
+        assert (flags & (baseOff == BinaryRow.KEY_CHUNK_OFFSET ? RowFlags.NO_KEY_NULL_MAP : RowFlags.NO_VALUE_NULL_MAP)) == 0;
+
         int byteInMap = colIdx / 8;
         int bitInByte = colIdx % 8;
 
diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
index f215855..8ca733e 100644
--- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
+++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
@@ -66,7 +66,7 @@ public class RowAssemblerTest {
 
             asm.appendInt(-33);
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, -33, -1, -1, -1}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, -33, -1, -1, -1}, asm.build());
         }
     }
 
@@ -91,7 +91,7 @@ public class RowAssemblerTest {
 
             asm.appendShort((short)-33);
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, -33, -1}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, -33, -1}, asm.build());
         }
     }
 
@@ -125,7 +125,7 @@ public class RowAssemblerTest {
 
             asm.appendShort((short)33);
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 33, 0}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 33, 0}, asm.build());
         }
     }
 
@@ -150,7 +150,7 @@ public class RowAssemblerTest {
 
             asm.appendShort((short)33);
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 33, 0}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 33, 0}, asm.build());
         }
     }
 
@@ -184,7 +184,7 @@ public class RowAssemblerTest {
 
             asm.appendShort((short)33);
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 33, 0}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 33, 0}, asm.build());
         }
     }
 
@@ -236,7 +236,7 @@ public class RowAssemblerTest {
 
             asm.appendShort((short)1133);
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 109, 4}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 109, 4}, asm.build());
         }
     }
 
@@ -288,7 +288,7 @@ public class RowAssemblerTest {
 
             asm.appendInt(33);
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0}, asm.build());
         }
     }
 
@@ -322,7 +322,7 @@ public class RowAssemblerTest {
 
             asm.appendByte((byte)33);
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 33}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 33}, asm.build());
         }
     }
 
@@ -358,7 +358,7 @@ public class RowAssemblerTest {
 
             asm.appendString("key");
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
         }
     }
 
@@ -385,7 +385,7 @@ public class RowAssemblerTest {
 
             asm.appendString("key");
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
         }
     }
 
@@ -419,7 +419,7 @@ public class RowAssemblerTest {
 
             asm.appendString("key");
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
         }
     }
 
@@ -444,7 +444,7 @@ public class RowAssemblerTest {
 
             asm.appendString("key");
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
         }
     }
 
@@ -496,7 +496,7 @@ public class RowAssemblerTest {
 
             asm.appendString("key");
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
         }
     }
 
@@ -530,7 +530,7 @@ public class RowAssemblerTest {
 
             asm.appendString("key");
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
         }
     }
 
@@ -582,7 +582,7 @@ public class RowAssemblerTest {
 
             asm.appendString("key");
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121}, asm.build());
         }
     }
 
@@ -616,7 +616,7 @@ public class RowAssemblerTest {
 
             asm.appendString("key");
 
-            assertRowBytesEquals(new byte[] {42, 0, 2, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121,}, asm.build());
+            assertRowBytesEquals(new byte[] {42, 0, 1, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 1, 0, 9, 0, 107, 101, 121,}, asm.build());
         }
     }