From f976162d8e0613d4083e5d5dee368c98bfe9a1f3 Mon Sep 17 00:00:00 2001 From: David Noble Date: Tue, 17 Sep 2019 23:23:48 -0700 Subject: [PATCH] testLoadSchmea passes --- .../serialization/hybridrow/layouts/LayoutBit.java | 4 ++-- .../hybridrow/layouts/LayoutBuilder.java | 14 +++++++------- .../hybridrow/layouts/StringToken.java | 2 +- .../hybridrow/layouts/StringTokenizer.java | 4 ++-- .../hybridrow/schemas/PropertyType.java | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java index 49cfc39..d4e635d 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java @@ -103,7 +103,7 @@ public final class LayoutBit { /** * The number of bytes needed to hold all bits so far allocated. */ - public final int getNumBytes() { + public final int numBytes() { return LayoutBit.divCeiling(this.next, Byte.SIZE); } @@ -112,7 +112,7 @@ public final class LayoutBit { * * @return The allocated bit. */ - public final LayoutBit Allocate() { + public final LayoutBit allocate() { return new LayoutBit(this.next++); } } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java index 75c1225..cd976ac 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java @@ -44,16 +44,16 @@ public final class LayoutBuilder { LayoutColumn column; if (type.isNull()) { checkArgument(nullable); - LayoutBit nullBit = this.bitAllocator.Allocate(); + LayoutBit nullBit = this.bitAllocator.allocate(); column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.FIXED, this.parent(), this.fixedCount, 0, nullBit, LayoutBit.INVALID, 0); } else if (type.isBoolean()) { - LayoutBit nullBit = nullable ? this.bitAllocator.Allocate() : LayoutBit.INVALID; - LayoutBit boolbit = this.bitAllocator.Allocate(); + LayoutBit nullBit = nullable ? this.bitAllocator.allocate() : LayoutBit.INVALID; + LayoutBit boolbit = this.bitAllocator.allocate(); column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.FIXED, this.parent(), this.fixedCount, 0, nullBit, boolbit, 0); } else { - LayoutBit nullBit = nullable ? this.bitAllocator.Allocate() : LayoutBit.INVALID; + LayoutBit nullBit = nullable ? this.bitAllocator.allocate() : LayoutBit.INVALID; column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.FIXED, this.parent(), this.fixedCount, this.fixedSize, nullBit, LayoutBit.INVALID, length); @@ -98,7 +98,7 @@ public final class LayoutBuilder { checkArgument(type.allowVariable()); LayoutColumn column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.VARIABLE, this.parent(), - this.varCount, this.varCount, this.bitAllocator.Allocate(), LayoutBit.INVALID, length); + this.varCount, this.varCount, this.bitAllocator.allocate(), LayoutBit.INVALID, length); this.varCount++; this.varColumns.add(column); @@ -107,7 +107,7 @@ public final class LayoutBuilder { public Layout build() { // Compute offset deltas. Offset bools by the present byte count, and fixed fields by the sum of the present // and bool count. - int fixedDelta = this.bitAllocator.getNumBytes(); + int fixedDelta = this.bitAllocator.numBytes(); int varIndexDelta = this.fixedCount; // Update the fixedColumns with the delta before freezing them. @@ -127,7 +127,7 @@ public final class LayoutBuilder { updatedColumns.addAll(this.sparseColumns); - Layout layout = new Layout(this.name, this.schemaId, this.bitAllocator.getNumBytes(), this.fixedSize + fixedDelta, updatedColumns); + Layout layout = new Layout(this.name, this.schemaId, this.bitAllocator.numBytes(), this.fixedSize + fixedDelta, updatedColumns); this.reset(); return layout; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java index 18ac8ce..0aaf8d0 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java @@ -34,7 +34,7 @@ public final class StringToken implements Cloneable { private StringToken() { this.id = 0L; this.path = Utf8String.EMPTY; - this.varint = Unpooled.wrappedBuffer(new byte[1]).setInt(0, 0).asReadOnly(); + this.varint = Unpooled.wrappedBuffer(new byte[1]).asReadOnly(); } public boolean isNull() { diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java index f5326a9..82c81fa 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java @@ -27,10 +27,10 @@ public final class StringTokenizer { public StringTokenizer() { this.tokens = new HashMap<>(); - this.tokens.put(Utf8String.EMPTY, new StringToken(0, Utf8String.EMPTY)); + this.tokens.put(Utf8String.EMPTY, StringToken.NONE); this.stringTokens = new HashMap<>(); - this.stringTokens.put("", new StringToken(0, Utf8String.EMPTY)); + this.stringTokens.put("", StringToken.NONE); this.strings = new ArrayList<>(); this.strings.add(Utf8String.EMPTY); diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java index 94d2b1a..b767670 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java @@ -14,7 +14,7 @@ import java.util.PrimitiveIterator; /** * The base class for property types both primitive and complex. */ -@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonTypeInfo(use = Id.NAME, property = "type", visible = true) @JsonSubTypes({ // Composite types @Type(value = ArrayPropertyType.class, name = "array"),