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/20 14:58:19 UTC

[ignite-3] branch ignite-14557 created (now fe74545)

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

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


      at fe74545  Swap null-map and varlen-table.

This branch includes the following new commits:

     new fe74545  Swap null-map and varlen-table.

The 1 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.


[ignite-3] 01/01: Swap null-map and varlen-table.

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

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

commit fe745456e068044c8f5faf5b3f51ae4ed2fda2ed
Author: Andrew Mashenkov <an...@gmail.com>
AuthorDate: Tue Apr 20 17:58:07 2021 +0300

    Swap null-map and varlen-table.
---
 .../org/apache/ignite/internal/schema/BinaryRow.java  |  2 +-
 .../java/org/apache/ignite/internal/schema/README.md  | 16 ++++++++--------
 .../java/org/apache/ignite/internal/schema/Row.java   | 19 +++++++++++--------
 .../apache/ignite/internal/schema/RowAssembler.java   | 18 ++++++++++--------
 4 files changed, 30 insertions(+), 25 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 a1ef776..a89c42d 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
@@ -35,7 +35,7 @@ public interface BinaryRow {
     /** */
     int KEY_CHUNK_OFFSET = KEY_HASH_FIELD_OFFSET + 4;
     /** */
-    int TOTAL_LEN_FIELD_SIZE = 4;
+    int CHUNK_LEN_FIELD_SIZE = 4;
     /** */
     int VARLEN_TABLE_SIZE_FIELD_SIZE = 2;
     /** */
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/README.md b/modules/schema/src/main/java/org/apache/ignite/internal/schema/README.md
index 97fea08..1909628 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/README.md
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/README.md
@@ -57,14 +57,14 @@ Row structure has the following format:
 
 Each chunk section has the following structure:
 
-                                                 ┌──────────────────────────────────────────────────┐
-                                                 │                                                  │
-    ┌─────────┬─────────────────────────┬────────┴────────┬─────────────────────────┬──────────┬────⌄─────┐
-    │ Full    │ Varsize Columns Offsets │ Varsize Columns │ Null-Defaults           │ Fixsize  │ Varsize  │
-    │ Size    │ Table Size              │ Offsets Table   │ Map                     │ Columns  │ Columns  │
-    ├─────────┼─────────────────────────┼─────────────────┼─────────────────────────┼──────────┼──────────┤
-    │ 4 Bytes │ 2 Bytes                 │ Variable        │ ⌈Number of columns / 8⌉ │ Variable │ Variable │
-    └─────────┴─────────────────────────┴─────────────────┴─────────────────────────┴──────────┴──────────┘
+                                                                           ┌────────────────────────┐
+                                                                           │                        │
+    ┌─────────┬─────────────────────────┬─────────────────────────┬────────┴────────┬──────────┬────⌄─────┐
+    │ Full    │ Null-Defaults           │ Varsize Columns Offsets │ Varsize Columns │ Fixsize  │ Varsize  │
+    │ Size    │ Map                     │ Table Size              │ Offsets Table   │ Columns  │ Columns  │
+    ├─────────┼─────────────────────────┼─────────────────────────┼─────────────────┼──────────┼──────────┤
+    │ 4 Bytes │ ⌈Number of columns / 8⌉ │ 2 Bytes                 │ Variable        │ Variable │ Variable │
+    └─────────┴─────────────────────────┴─────────────────────────┴─────────────────┴──────────┴──────────┘
 All columns within a group are split into groups of fixed-size columns and variable-size columns. Withing the group of 
 fixsize columns, the columns are sorted by size, then by column name. Within the group of varsize columns, the columns 
 are sorted by column name. Inside a row default values and nulls are omitted and encoded in the null-defaults map 
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 a074733..b9cf9cd 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
@@ -429,9 +429,9 @@ public class Row implements BinaryRow {
         }
 
         idx -= cols.numberOfFixsizeColumns() + numNullsBefore;
-        int vartableSize = readShort(baseOff + TOTAL_LEN_FIELD_SIZE);
+        int vartableSize = readShort(vartableOffset(baseOff, cols));
 
-        int vartableOff = vartableOffset(baseOff);
+        int vartableOff = vartableOffset(baseOff, cols) + VARLEN_TABLE_SIZE_FIELD_SIZE;
         // Offset of idx-th column is from base offset.
         int resOff = readShort(vartableOff + VARLEN_COLUMN_OFFSET_FIELD_SIZE * idx);
 
@@ -470,7 +470,11 @@ public class Row implements BinaryRow {
 
         off += cols.foldFixedLength(nullMapIdx, readByte(nullMapOff + nullMapIdx) | mask);
 
-        return nullMapOff + cols.nullMapSize() + off;
+        final int vartableOffset = vartableOffset(baseOff, cols);
+
+        int vartableLen = VARLEN_TABLE_SIZE_FIELD_SIZE + readShort(vartableOffset) * VARLEN_COLUMN_OFFSET_FIELD_SIZE;
+
+        return vartableOffset + vartableLen + off;
     }
 
     /**
@@ -478,17 +482,16 @@ public class Row implements BinaryRow {
      * @return Null map offset from the row start for the chunk with the given base.
      */
     private int nullMapOffset(int baseOff) {
-        int varlenTblSize = readShort(baseOff + TOTAL_LEN_FIELD_SIZE);
-
-        return vartableOffset(baseOff) + varlenTblSize * VARLEN_COLUMN_OFFSET_FIELD_SIZE;
+        return baseOff + CHUNK_LEN_FIELD_SIZE;
     }
 
     /**
      * @param baseOff Chunk base offset.
+     * @param cols Columns.
      * @return Offset of the varlen table from the row start for the chunk with the given base.
      */
-    private int vartableOffset(int baseOff) {
-        return baseOff + TOTAL_LEN_FIELD_SIZE + VARLEN_TABLE_SIZE_FIELD_SIZE;
+    private int vartableOffset(int baseOff, Columns cols) {
+        return baseOff + CHUNK_LEN_FIELD_SIZE + cols.nullMapSize();
     }
 
     /** {@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 a42fe90..dcf0f4b 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
@@ -76,7 +76,7 @@ public class RowAssembler {
      * @return Total size of the varlen table.
      */
     public static int varlenTableSize(int nonNullVarlenCols) {
-        return nonNullVarlenCols * 2;
+        return nonNullVarlenCols * BinaryRow.VARLEN_COLUMN_OFFSET_FIELD_SIZE;
     }
 
     /**
@@ -114,8 +114,8 @@ public class RowAssembler {
      * @return Row's chunk size.
      */
     public static int rowChunkSize(Columns cols, int nonNullVarlenCols, int nonNullVarlenSize) {
-        int size = BinaryRow.TOTAL_LEN_FIELD_SIZE + BinaryRow.VARLEN_TABLE_SIZE_FIELD_SIZE +
-            varlenTableSize(nonNullVarlenCols) + cols.nullMapSize();
+        int size = BinaryRow.CHUNK_LEN_FIELD_SIZE + cols.nullMapSize() +
+            BinaryRow.VARLEN_TABLE_SIZE_FIELD_SIZE + varlenTableSize(nonNullVarlenCols);
 
         for (int i = 0; i < cols.numberOfFixsizeColumns(); i++)
             size += cols.column(i).type().length();
@@ -147,7 +147,7 @@ public class RowAssembler {
         initOffsets(BinaryRow.KEY_CHUNK_OFFSET, nonNullVarlenKeyCols);
 
         buf.putShort(0, (short)schema.version());
-        buf.putShort(baseOff + BinaryRow.TOTAL_LEN_FIELD_SIZE, (short)nonNullVarlenKeyCols);
+        buf.putShort(nullMapOff + curCols.nullMapSize(), (short)nonNullVarlenKeyCols);
     }
 
     /**
@@ -443,7 +443,8 @@ public class RowAssembler {
             buf.putShort(baseOff, (short)keyLen);
 
             if (schema.valueColumns() == curCols) {
-                buf.putShort(baseOff + BinaryRow.TOTAL_LEN_FIELD_SIZE, (short)nonNullVarlenValCols);
+                buf.putShort(nullMapOff + curCols.nullMapSize(), (short)nonNullVarlenValCols);
+
                 return; // No more columns.
             }
 
@@ -463,8 +464,9 @@ public class RowAssembler {
         curCol = 0;
         curVarlenTblEntry = 0;
 
-        varlenTblOff = baseOff + BinaryRow.TOTAL_LEN_FIELD_SIZE + BinaryRow.VARLEN_TABLE_SIZE_FIELD_SIZE;
-        nullMapOff = varlenTblOff + varlenTableSize(nonNullVarlenCols);
-        curOff = nullMapOff + curCols.nullMapSize();
+        nullMapOff = baseOff + BinaryRow.CHUNK_LEN_FIELD_SIZE;
+        varlenTblOff = nullMapOff + curCols.nullMapSize() + BinaryRow.VARLEN_TABLE_SIZE_FIELD_SIZE;
+
+        curOff = varlenTblOff + varlenTableSize(nonNullVarlenCols);
     }
 }