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 <andrey.mashen...@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());
         }
     }
 

Reply via email to