diff --git a/jre/src/main/java/com/azure/data/cosmos/core/Utf8String.java b/jre/src/main/java/com/azure/data/cosmos/core/Utf8String.java index f983da3..16755af 100644 --- a/jre/src/main/java/com/azure/data/cosmos/core/Utf8String.java +++ b/jre/src/main/java/com/azure/data/cosmos/core/Utf8String.java @@ -42,16 +42,23 @@ import static java.nio.charset.StandardCharsets.UTF_8; public final class Utf8String implements CharSequence, Comparable { public static final Utf8String EMPTY = new Utf8String(Unpooled.EMPTY_BUFFER, 0); + public static final Utf8String NULL = new Utf8String(); private static final PooledByteBufAllocator allocator = PooledByteBufAllocator.DEFAULT; private final ByteBuf buffer; private final int length; - private Utf8String(final ByteBuf buffer) { + private Utf8String() { + this.buffer = null; + this.length = -1; + } + + private Utf8String(@Nonnull final ByteBuf buffer) { this(buffer, decodedLength(buffer)); } - private Utf8String(final ByteBuf buffer, final int decodedLength) { + private Utf8String(@Nonnull final ByteBuf buffer, final int decodedLength) { + checkNotNull(buffer); this.buffer = buffer.asReadOnly(); this.length = decodedLength; } @@ -63,6 +70,13 @@ public final class Utf8String implements CharSequence, Comparable { return this.length == 0; } + /** + * {@code true} if this instance is null + */ + public final boolean isNull() { + return this.buffer == null; + } + @Override public char charAt(final int index) { throw new UnsupportedOperationException(); @@ -87,13 +101,29 @@ public final class Utf8String implements CharSequence, Comparable { } public final int compareTo(@Nonnull final Utf8String other) { + checkNotNull(other); + + if (other.buffer == this.buffer) { + return 0; + } + + if (other.buffer == null) { + return 1; + } + + if (this.buffer == null) { + return -1; + } + return this.buffer.compareTo(other.buffer); } - public final int compareTo(@Nonnull final String other) { + public final int compareTo(final String other) { - checkNotNull(other); + if (this.buffer == null) { + return other == null ? 0 : -1; + } final int length = this.length(); final int otherLength = other.length(); @@ -250,6 +280,10 @@ public final class Utf8String implements CharSequence, Comparable { return this.buffer.getCharSequence(0, this.buffer.capacity(), UTF_8).toString(); } + public String toUtf16() { + return this.buffer.getCharSequence(0, this.buffer.capacity(), UTF_8).toString(); + } + /** * Creates a {@link Utf8String} from a UTF16 encoding string. * diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowHeader.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowHeader.java index 1764757..b79a22d 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowHeader.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowHeader.java @@ -17,7 +17,7 @@ public final class HybridRowHeader { /** * Size (in bytes) of a serialized header. */ - public static final int Size = (HybridRowVersion.SIZE / Byte.SIZE) + com.azure.data.cosmos.serialization.hybridrow.SchemaId.Size; + public static final int SIZE = (HybridRowVersion.SIZE / Byte.SIZE) + com.azure.data.cosmos.serialization.hybridrow.SchemaId.SIZE; /** * The unique identifier of the schema whose layout was used to write this row. */ diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/NullValue.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/NullValue.java index a00af52..e22657d 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/NullValue.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/NullValue.java @@ -10,11 +10,7 @@ package com.azure.data.cosmos.serialization.hybridrow; * May be stored hybrid row to indicate the literal null value. Typically this value should * not be used and the corresponding column should be absent from the row. */ -//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ -// from the original: -//ORIGINAL LINE: public readonly struct NullValue : IEquatable -//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct: -public final class NullValue implements IEquatable { +public final class NullValue { /** * The default null literal. * This is the same value as default({@link NullValue}). @@ -22,7 +18,7 @@ public final class NullValue implements IEquatable { public static final NullValue Default = new NullValue(); /** - * Returns true if this is the same value as {@link other}. + * Returns true if this is the same value as {@code other}. * * @param other The value to compare against. * @return True if the two values are the same. @@ -31,37 +27,16 @@ public final class NullValue implements IEquatable { return true; } - /** - * {@link object.Equals(object)} overload. - */ @Override - public boolean equals(Object obj) { - if (null == obj) { + public boolean equals(Object other) { + if (null == other) { return false; } - - return obj instanceof NullValue && this.equals((NullValue)obj); + return other instanceof NullValue && this.equals((NullValue)other); } - /** - * {@link object.GetHashCode} overload. - */ @Override public int hashCode() { return 42; } - - /** - * Operator == overload. - */ - public static boolean opEquals(NullValue left, NullValue right) { - return left.equals(right.clone()); - } - - /** - * Operator != overload. - */ - public static boolean opNotEquals(NullValue left, NullValue right) { - return !left.equals(right.clone()); - } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java index a33e6ca..8f18521 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java @@ -6,15 +6,48 @@ package com.azure.data.cosmos.serialization.hybridrow; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; +import com.azure.data.cosmos.serialization.hybridrow.io.RowWriter; import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutArray; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutBinary; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutBit; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutBoolean; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutColumn; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutDateTime; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutDecimal; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutFloat128; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutFloat32; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutFloat64; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutGuid; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutInt16; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutInt32; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutInt64; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutInt8; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutMongoDbObjectId; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutNull; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutNullable; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutObject; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutResolver; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutScope; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTagged; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTagged2; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTuple; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTypedArray; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTypedMap; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTypedSet; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTypedTuple; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutUDT; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutUInt16; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutUInt32; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutUInt64; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutUInt8; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutUnixDateTime; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutUtf8; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutVarInt; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutVarUInt; import com.azure.data.cosmos.serialization.hybridrow.layouts.StringToken; import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument; import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList; @@ -24,17 +57,15 @@ import java.io.InputStream; import java.io.OutputStream; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.Optional; import java.util.UUID; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType.MongoDbObjectId; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Strings.lenientFormat; -//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ -// from the original: -//ORIGINAL LINE: public ref struct RowBuffer -//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# ref struct: +//import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType.MongoDbObjectId; + public final class RowBuffer { /** * A sequence of bytes managed by this {@link RowBuffer}. @@ -45,9 +76,6 @@ public final class RowBuffer { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: private Span buffer; private Span buffer; - /** - * The length of row in bytes. - */ private int length; /** * Resizer for growing the memory buffer. @@ -74,15 +102,12 @@ public final class RowBuffer { public RowBuffer() { } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public RowBuffer(int capacity, ISpanResizer resizer = default) - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: public RowBuffer(int capacity, ISpanResizer resizer) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: this.resizer = resizer != null ? resizer : DefaultSpanResizer.Default; this.resizer = resizer != null ? resizer : DefaultSpanResizer < Byte >.Default; this.buffer = this.resizer.Resize(capacity); - this.length = 0; + this.length(0); this.resolver = null; } @@ -105,11 +130,11 @@ public final class RowBuffer { // ISpanResizer resizer = default) //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: public RowBuffer(Span buffer, HybridRowVersion version, LayoutResolver resolver, ISpanResizer resizer) { - checkArgument(buffer.Length >= HybridRowHeader.Size); + checkArgument(buffer.Length >= HybridRowHeader.SIZE); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: this.resizer = resizer != null ? resizer : DefaultSpanResizer.Default; this.resizer = resizer != null ? resizer : DefaultSpanResizer < Byte >.Default; - this.length = buffer.Length; + this.length(buffer.Length); this.buffer = buffer; this.resolver = resolver; @@ -117,66 +142,147 @@ public final class RowBuffer { checkState(header.getVersion() == version); Layout layout = resolver.Resolve(header.getSchemaId().clone()); checkState(SchemaId.opEquals(header.getSchemaId().clone(), layout.schemaId().clone())); - checkState(HybridRowHeader.Size + layout.size() <= this.length); + checkState(HybridRowHeader.SIZE + layout.size() <= this.length()); } /** - * The root header for the row. - */ - public HybridRowHeader getHeader() { - return this.ReadHeader(0).clone(); - } - - /** - * The length of row in bytes. - */ - public int getLength() { - return this.length; - } - - /** - * The resolver for UDTs. - */ - public LayoutResolver getResolver() { - return this.resolver; - } - - /** - * Compute the byte offset from the beginning of the row for a given variable column's value. + * Initializes a row to the minimal size for the given layout. * - * @param layout The (optional) layout of the current scope. - * @param scopeOffset The 0-based offset to the beginning of the scope's value. - * @param varIndex The 0-based index of the variable column within the variable segment. - * @return The byte offset from the beginning of the row where the variable column's value should be - * located. + * @param version The version of the Hybrid Row format to use for encoding this row. + * @param layout The layout that describes the column layout of the row. + * @param resolver The resolver for UDTs. + *

+ * The row is initialized to default row for the given layout. All fixed columns have their + * default values. All variable columns are null. No sparse columns are present. The row is + * valid. */ - public int ComputeVariableValueOffset(Layout layout, int scopeOffset, int varIndex) { - if (layout == null) { - return scopeOffset; - } + public void InitLayout(HybridRowVersion version, Layout layout, LayoutResolver resolver) { + checkArgument(layout != null); + this.resolver = resolver; - int index = layout.numFixed() + varIndex; - ReadOnlySpan columns = layout.columns(); - checkState(index <= columns.Length); - int offset = scopeOffset + layout.size(); - for (int i = layout.numFixed(); i < index; i++) { - LayoutColumn col = columns[i]; - if (this.ReadBit(scopeOffset, col.getNullBit().clone())) { - int lengthSizeInBytes; - Out tempOut_lengthSizeInBytes = new Out(); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: ulong valueSizeInBytes = this.Read7BitEncodedUInt(offset, out int lengthSizeInBytes); - long valueSizeInBytes = this.Read7BitEncodedUInt(offset, tempOut_lengthSizeInBytes); - lengthSizeInBytes = tempOut_lengthSizeInBytes.get(); - if (col.getType().getIsVarint()) { - offset += lengthSizeInBytes; + // Ensure sufficient space for fixed schema fields. + this.Ensure(HybridRowHeader.SIZE + layout.size()); + this.length(HybridRowHeader.SIZE + layout.size()); + + // Clear all presence bits. + this.buffer.Slice(HybridRowHeader.SIZE, layout.size()).Fill(0); + + // Set the header. + this.WriteHeader(0, new HybridRowHeader(version, layout.schemaId().clone())); + } + + /** + * Compute the byte offsets from the beginning of the row for a given sparse field insertion + * into a set/map. + * + * @param scope The sparse scope to insert into. + * @param srcEdit The field to move into the set/map. + * @return The prepared edit context. + */ + public RowCursor PrepareSparseMove(Reference scope, Reference srcEdit) { + checkArgument(scope.get().scopeType().isUniqueScope()); + + checkArgument(scope.get().index() == 0); + RowCursor dstEdit; + // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these + // cannot be converted using the 'Out' helper class unless the method is within the code being modified: + scope.get().Clone(out dstEdit); + + dstEdit.metaOffset(scope.get().valueOffset()); + int srcSize = this.SparseComputeSize(srcEdit); + int srcBytes = srcSize - (srcEdit.get().valueOffset() - srcEdit.get().metaOffset()); + while (dstEdit.index() < dstEdit.count()) { + Reference tempReference_dstEdit = + new Reference(dstEdit); + this.ReadSparseMetadata(tempReference_dstEdit); + dstEdit = tempReference_dstEdit.get(); + Contract.Assert(dstEdit.pathOffset == + default) + + int elmSize = -1; // defer calculating the full size until needed. + int cmp; + if (scope.get().scopeType() instanceof LayoutTypedMap) { + cmp = this.CompareKeyValueFieldValue(srcEdit.get().clone(), dstEdit); } else { - offset += (int)valueSizeInBytes + lengthSizeInBytes; + Reference tempReference_dstEdit2 = + new Reference(dstEdit); + elmSize = this.SparseComputeSize(tempReference_dstEdit2); + dstEdit = tempReference_dstEdit2.get(); + int elmBytes = elmSize - (dstEdit.valueOffset() - dstEdit.metaOffset()); + cmp = this.CompareFieldValue(srcEdit.get().clone(), srcBytes, dstEdit, elmBytes); } - } + + if (cmp <= 0) { + dstEdit.exists = cmp == 0; + return dstEdit; + } + + Reference tempReference_dstEdit3 = + new Reference(dstEdit); + elmSize = (elmSize == -1) ? this.SparseComputeSize(tempReference_dstEdit3) : elmSize; + dstEdit = tempReference_dstEdit3.get(); + dstEdit.index(dstEdit.index() + 1); + dstEdit.metaOffset(dstEdit.metaOffset() + elmSize); } - return offset; + dstEdit.exists = false; + dstEdit.cellType = LayoutType.EndScope; + dstEdit.valueOffset(dstEdit.metaOffset()); + return dstEdit; + } + + /** + * Reads in the contents of the RowBuffer from an input stream and initializes the row buffer + * with the associated layout and rowVersion. + * + * @return true if the serialization succeeded. false if the input stream was corrupted. + */ + public boolean ReadFrom(InputStream inputStream, int bytesCount, HybridRowVersion rowVersion, + LayoutResolver resolver) { + checkArgument(inputStream != null); + checkState(bytesCount >= HybridRowHeader.SIZE); + + this.Reset(); + this.resolver = resolver; + this.Ensure(bytesCount); + checkState(this.buffer.Length >= bytesCount); + this.length(bytesCount); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: Span active = this.buffer.Slice(0, bytesCount); + Span active = this.buffer.Slice(0, bytesCount); + int bytesRead; + do { + bytesRead = inputStream.Read(active); + active = active.Slice(bytesRead); + } while (bytesRead != 0); + + if (active.Length != 0) { + return false; + } + + return this.InitReadFrom(rowVersion); + } + + /** + * Reads in the contents of the RowBuffer from an existing block of memory and initializes + * the row buffer with the associated layout and rowVersion. + * + * @return true if the serialization succeeded. false if the input stream was corrupted. + */ + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: public bool ReadFrom(ReadOnlySpan input, HybridRowVersion rowVersion, LayoutResolver + // resolver) + public boolean ReadFrom(ReadOnlySpan input, HybridRowVersion rowVersion, LayoutResolver resolver) { + int bytesCount = input.Length; + checkState(bytesCount >= HybridRowHeader.SIZE); + + this.Reset(); + this.resolver = resolver; + this.Ensure(bytesCount); + checkState(this.buffer.Length >= bytesCount); + input.CopyTo(this.buffer); + this.length(bytesCount); + return this.InitReadFrom(rowVersion); } /** @@ -216,7 +322,7 @@ public final class RowBuffer { * * @param edit The field to delete. */ - public void DeleteSparse(Reference edit) { + public void deleteSparse(Reference edit) { // If the field doesn't exist, then nothing to do. if (!edit.get().exists) { return; @@ -234,7 +340,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); _ = tempOut__2.get(); _ = tempOut__.get(); - this.length += shift; + this.length(this.length() + shift); } public void DeleteVariable(int offset, boolean isVarint) { @@ -248,8 +354,8 @@ public final class RowBuffer { spaceAvailable += (int)existingValueBytes; // "size" already in spaceAvailable } - this.buffer.Slice(offset + spaceAvailable, this.length - (offset + spaceAvailable)).CopyTo(this.buffer.Slice(offset)); - this.length -= spaceAvailable; + this.buffer.Slice(offset + spaceAvailable, this.length() - (offset + spaceAvailable)).CopyTo(this.buffer.Slice(offset)); + this.length(this.length() - spaceAvailable); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -260,90 +366,24 @@ public final class RowBuffer { MemoryMarshal.Cast(this.buffer.Slice(offset))[0] += increment; } - /** - * Initializes a row to the minimal size for the given layout. - * - * @param version The version of the Hybrid Row format to use for encoding this row. - * @param layout The layout that describes the column layout of the row. - * @param resolver The resolver for UDTs. - *

- * The row is initialized to default row for the given layout. All fixed columns have their - * default values. All variable columns are null. No sparse columns are present. The row is - * valid. - */ - public void InitLayout(HybridRowVersion version, Layout layout, LayoutResolver resolver) { - checkArgument(layout != null); - this.resolver = resolver; - - // Ensure sufficient space for fixed schema fields. - this.Ensure(HybridRowHeader.Size + layout.size()); - this.length = HybridRowHeader.Size + layout.size(); - - // Clear all presence bits. - this.buffer.Slice(HybridRowHeader.Size, layout.size()).Fill(0); - - // Set the header. - this.WriteHeader(0, new HybridRowHeader(version, layout.schemaId().clone())); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal ReadOnlySpan ReadSparseBinary(ref RowCursor edit) + public ReadOnlySpan ReadSparseBinary(Reference edit) { + this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Binary); + int sizeLenInBytes; + Out tempOut_sizeLenInBytes = new Out(); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: ReadOnlySpan span = this.ReadBinary(edit.valueOffset, out int sizeLenInBytes); + ReadOnlySpan span = this.ReadBinary(edit.get().valueOffset(), tempOut_sizeLenInBytes); + sizeLenInBytes = tempOut_sizeLenInBytes.get(); + edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes + span.Length; + return span; } - /** - * Compute the byte offsets from the beginning of the row for a given sparse field insertion - * into a set/map. - * - * @param scope The sparse scope to insert into. - * @param srcEdit The field to move into the set/map. - * @return The prepared edit context. - */ - public RowCursor PrepareSparseMove(Reference scope, Reference srcEdit) { - checkArgument(scope.get().scopeType.IsUniqueScope); - - checkArgument(scope.get().index == 0); - RowCursor dstEdit; - // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these - // cannot be converted using the 'Out' helper class unless the method is within the code being modified: - scope.get().Clone(out dstEdit); - - dstEdit.metaOffset = scope.get().valueOffset; - int srcSize = this.SparseComputeSize(srcEdit); - int srcBytes = srcSize - (srcEdit.get().valueOffset - srcEdit.get().metaOffset); - while (dstEdit.index < dstEdit.count) { - Reference tempReference_dstEdit = - new Reference(dstEdit); - this.ReadSparseMetadata(tempReference_dstEdit); - dstEdit = tempReference_dstEdit.get(); - Contract.Assert(dstEdit.pathOffset == - default) - - int elmSize = -1; // defer calculating the full size until needed. - int cmp; - if (scope.get().scopeType instanceof LayoutTypedMap) { - cmp = this.CompareKeyValueFieldValue(srcEdit.get().clone(), dstEdit); - } else { - Reference tempReference_dstEdit2 = - new Reference(dstEdit); - elmSize = this.SparseComputeSize(tempReference_dstEdit2); - dstEdit = tempReference_dstEdit2.get(); - int elmBytes = elmSize - (dstEdit.valueOffset - dstEdit.metaOffset); - cmp = this.CompareFieldValue(srcEdit.get().clone(), srcBytes, dstEdit, elmBytes); - } - - if (cmp <= 0) { - dstEdit.exists = cmp == 0; - return dstEdit; - } - - Reference tempReference_dstEdit3 = - new Reference(dstEdit); - elmSize = (elmSize == -1) ? this.SparseComputeSize(tempReference_dstEdit3) : elmSize; - dstEdit = tempReference_dstEdit3.get(); - dstEdit.index++; - dstEdit.metaOffset += elmSize; - } - - dstEdit.exists = false; - dstEdit.cellType = LayoutType.EndScope; - dstEdit.valueOffset = dstEdit.metaOffset; - return dstEdit; + public boolean ReadSparseBool(Reference edit) { + this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Boolean); + edit.get().endOffset = edit.get().valueOffset(); + return edit.get().cellType == LayoutType.Boolean; } public long Read7BitEncodedInt(int offset, Out lenInBytes) { @@ -419,58 +459,17 @@ public final class RowBuffer { return MemoryMarshal.Read(this.buffer.Slice(offset)); } - /** - * Reads in the contents of the RowBuffer from an input stream and initializes the row buffer - * with the associated layout and rowVersion. - * - * @return true if the serialization succeeded. false if the input stream was corrupted. - */ - public boolean ReadFrom(InputStream inputStream, int bytesCount, HybridRowVersion rowVersion, - LayoutResolver resolver) { - checkArgument(inputStream != null); - checkState(bytesCount >= HybridRowHeader.Size); - - this.Reset(); - this.resolver = resolver; - this.Ensure(bytesCount); - checkState(this.buffer.Length >= bytesCount); - this.length = bytesCount; - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: Span active = this.buffer.Slice(0, bytesCount); - Span active = this.buffer.Slice(0, bytesCount); - int bytesRead; - do { - bytesRead = inputStream.Read(active); - active = active.Slice(bytesRead); - } while (bytesRead != 0); - - if (active.Length != 0) { - return false; - } - - return this.InitReadFrom(rowVersion); + public LocalDateTime ReadSparseDateTime(Reference edit) { + this.ReadSparsePrimitiveTypeCode(edit, LayoutType.DateTime); + edit.get().endOffset = edit.get().valueOffset() + 8; + return this.ReadDateTime(edit.get().valueOffset()); } - /** - * Reads in the contents of the RowBuffer from an existing block of memory and initializes - * the row buffer with the associated layout and rowVersion. - * - * @return true if the serialization succeeded. false if the input stream was corrupted. - */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public bool ReadFrom(ReadOnlySpan input, HybridRowVersion rowVersion, LayoutResolver - // resolver) - public boolean ReadFrom(ReadOnlySpan input, HybridRowVersion rowVersion, LayoutResolver resolver) { - int bytesCount = input.Length; - checkState(bytesCount >= HybridRowHeader.Size); - - this.Reset(); - this.resolver = resolver; - this.Ensure(bytesCount); - checkState(this.buffer.Length >= bytesCount); - input.CopyTo(this.buffer); - this.length = bytesCount; - return this.InitReadFrom(rowVersion); + public BigDecimal ReadSparseDecimal(Reference edit) { + this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Decimal); + // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': + edit.get().endOffset = edit.get().valueOffset() + sizeof(BigDecimal); + return this.ReadDecimal(edit.get().valueOffset()); } public UUID ReadGuid(int offset) { @@ -507,97 +506,64 @@ public final class RowBuffer { return new SchemaId(this.ReadInt32(offset)); } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal ReadOnlySpan ReadSparseBinary(ref RowCursor edit) - public ReadOnlySpan ReadSparseBinary(Reference edit) { - this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Binary); - int sizeLenInBytes; - Out tempOut_sizeLenInBytes = new Out(); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: ReadOnlySpan span = this.ReadBinary(edit.valueOffset, out int sizeLenInBytes); - ReadOnlySpan span = this.ReadBinary(edit.get().valueOffset, tempOut_sizeLenInBytes); - sizeLenInBytes = tempOut_sizeLenInBytes.get(); - edit.get().endOffset = edit.get().valueOffset + sizeLenInBytes + span.Length; - return span; - } - - public boolean ReadSparseBool(Reference edit) { - this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Boolean); - edit.get().endOffset = edit.get().valueOffset; - return edit.get().cellType == LayoutType.Boolean; - } - - public LocalDateTime ReadSparseDateTime(Reference edit) { - this.ReadSparsePrimitiveTypeCode(edit, LayoutType.DateTime); - edit.get().endOffset = edit.get().valueOffset + 8; - return this.ReadDateTime(edit.get().valueOffset); - } - - public BigDecimal ReadSparseDecimal(Reference edit) { - this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Decimal); - // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': - edit.get().endOffset = edit.get().valueOffset + sizeof(BigDecimal); - return this.ReadDecimal(edit.get().valueOffset); - } - public Float128 ReadSparseFloat128(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Float128); - edit.get().endOffset = edit.get().valueOffset + Float128.Size; - return this.ReadFloat128(edit.get().valueOffset).clone(); + edit.get().endOffset = edit.get().valueOffset() + Float128.Size; + return this.ReadFloat128(edit.get().valueOffset()).clone(); } public float ReadSparseFloat32(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Float32); - edit.get().endOffset = edit.get().valueOffset + (Float.SIZE / Byte.SIZE); - return this.ReadFloat32(edit.get().valueOffset); + edit.get().endOffset = edit.get().valueOffset() + (Float.SIZE / Byte.SIZE); + return this.ReadFloat32(edit.get().valueOffset()); } public double ReadSparseFloat64(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Float64); - edit.get().endOffset = edit.get().valueOffset + (Double.SIZE / Byte.SIZE); - return this.ReadFloat64(edit.get().valueOffset); + edit.get().endOffset = edit.get().valueOffset() + (Double.SIZE / Byte.SIZE); + return this.ReadFloat64(edit.get().valueOffset()); } public UUID ReadSparseGuid(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Guid); - edit.get().endOffset = edit.get().valueOffset + 16; - return this.ReadGuid(edit.get().valueOffset); + edit.get().endOffset = edit.get().valueOffset() + 16; + return this.ReadGuid(edit.get().valueOffset()); } public short ReadSparseInt16(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Int16); - edit.get().endOffset = edit.get().valueOffset + (Short.SIZE / Byte.SIZE); - return this.ReadInt16(edit.get().valueOffset); + edit.get().endOffset = edit.get().valueOffset() + (Short.SIZE / Byte.SIZE); + return this.ReadInt16(edit.get().valueOffset()); } public int ReadSparseInt32(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Int32); - edit.get().endOffset = edit.get().valueOffset + (Integer.SIZE / Byte.SIZE); - return this.ReadInt32(edit.get().valueOffset); + edit.get().endOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); + return this.ReadInt32(edit.get().valueOffset()); } public long ReadSparseInt64(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Int64); - edit.get().endOffset = edit.get().valueOffset + (Long.SIZE / Byte.SIZE); - return this.ReadInt64(edit.get().valueOffset); + edit.get().endOffset = edit.get().valueOffset() + (Long.SIZE / Byte.SIZE); + return this.ReadInt64(edit.get().valueOffset()); } public byte ReadSparseInt8(Reference edit) { // TODO: Remove calls to ReadSparsePrimitiveTypeCode once moved to V2 read. this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Int8); - edit.get().endOffset = edit.get().valueOffset + (Byte.SIZE / Byte.SIZE); - return this.ReadInt8(edit.get().valueOffset); + edit.get().endOffset = edit.get().valueOffset() + (Byte.SIZE / Byte.SIZE); + return this.ReadInt8(edit.get().valueOffset()); } public MongoDbObjectId ReadSparseMongoDbObjectId(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, MongoDbObjectId); - edit.get().endOffset = edit.get().valueOffset + MongoDbObjectId.Size; - return this.ReadMongoDbObjectId(edit.get().valueOffset).clone(); + edit.get().endOffset = edit.get().valueOffset() + MongoDbObjectId.Size; + return this.ReadMongoDbObjectId(edit.get().valueOffset()).clone(); } public NullValue ReadSparseNull(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Null); - edit.get().endOffset = edit.get().valueOffset; + edit.get().endOffset = edit.get().valueOffset(); return NullValue.Default; } @@ -606,17 +572,50 @@ public final class RowBuffer { Out tempOut_path = new Out(); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: if (edit.layout.Tokenizer.TryFindString((ulong)edit.pathToken, out Utf8String path)) - if (edit.get().layout.getTokenizer().TryFindString(edit.get().longValue().pathToken, tempOut_path)) { + if (edit.get().layout().getTokenizer().TryFindString(edit.get().longValue().pathToken, tempOut_path)) { path = tempOut_path.get(); return path.Span; } else { path = tempOut_path.get(); } - int numBytes = edit.get().pathToken - edit.get().layout.getTokenizer().getCount(); + int numBytes = edit.get().pathToken - edit.get().layout().getTokenizer().getCount(); return Utf8Span.UnsafeFromUtf8BytesNoValidation(this.buffer.Slice(edit.get().pathOffset, numBytes)); } + public Utf8Span ReadSparseString(Reference edit) { + this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Utf8); + int sizeLenInBytes; + Out tempOut_sizeLenInBytes = new Out(); + Utf8Span span = this.ReadString(edit.get().valueOffset(), tempOut_sizeLenInBytes); + sizeLenInBytes = tempOut_sizeLenInBytes.get(); + edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes + span.Length; + return span; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal LayoutType ReadSparseTypeCode(int + // offset) + public LayoutType ReadSparseTypeCode(int offset) { + return LayoutType.FromCode(LayoutCode.forValue(this.ReadUInt8(offset))); + } + + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal ushort ReadSparseUInt16(ref RowCursor edit) + public short ReadSparseUInt16(Reference edit) { + this.ReadSparsePrimitiveTypeCode(edit, LayoutType.UInt16); + edit.get().endOffset = edit.get().valueOffset() + (Short.SIZE / Byte.SIZE); + return this.ReadUInt16(edit.get().valueOffset()); + } + + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal uint ReadSparseUInt32(ref RowCursor edit) + public int ReadSparseUInt32(Reference edit) { + this.ReadSparsePrimitiveTypeCode(edit, LayoutType.UInt32); + edit.get().endOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); + return this.ReadUInt32(edit.get().valueOffset()); + } + public int ReadSparsePathLen(Layout layout, int offset, Out pathLenInBytes, Out pathOffset) { int sizeLenInBytes; @@ -635,68 +634,35 @@ public final class RowBuffer { return token; } - public Utf8Span ReadSparseString(Reference edit) { - this.ReadSparsePrimitiveTypeCode(edit, LayoutType.Utf8); - int sizeLenInBytes; - Out tempOut_sizeLenInBytes = new Out(); - Utf8Span span = this.ReadString(edit.get().valueOffset, tempOut_sizeLenInBytes); - sizeLenInBytes = tempOut_sizeLenInBytes.get(); - edit.get().endOffset = edit.get().valueOffset + sizeLenInBytes + span.Length; - return span; - } - - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal LayoutType ReadSparseTypeCode(int - // offset) - public LayoutType ReadSparseTypeCode(int offset) { - return LayoutType.FromCode(LayoutCode.forValue(this.ReadUInt8(offset))); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal ushort ReadSparseUInt16(ref RowCursor edit) - public short ReadSparseUInt16(Reference edit) { - this.ReadSparsePrimitiveTypeCode(edit, LayoutType.UInt16); - edit.get().endOffset = edit.get().valueOffset + (Short.SIZE / Byte.SIZE); - return this.ReadUInt16(edit.get().valueOffset); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal uint ReadSparseUInt32(ref RowCursor edit) - public int ReadSparseUInt32(Reference edit) { - this.ReadSparsePrimitiveTypeCode(edit, LayoutType.UInt32); - edit.get().endOffset = edit.get().valueOffset + (Integer.SIZE / Byte.SIZE); - return this.ReadUInt32(edit.get().valueOffset); - } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: internal ulong ReadSparseUInt64(ref RowCursor edit) public long ReadSparseUInt64(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.UInt64); - edit.get().endOffset = edit.get().valueOffset + (Long.SIZE / Byte.SIZE); - return this.ReadUInt64(edit.get().valueOffset); + edit.get().endOffset = edit.get().valueOffset() + (Long.SIZE / Byte.SIZE); + return this.ReadUInt64(edit.get().valueOffset()); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: internal byte ReadSparseUInt8(ref RowCursor edit) public byte ReadSparseUInt8(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.UInt8); - edit.get().endOffset = edit.get().valueOffset + 1; - return this.ReadUInt8(edit.get().valueOffset); + edit.get().endOffset = edit.get().valueOffset() + 1; + return this.ReadUInt8(edit.get().valueOffset()); } public UnixDateTime ReadSparseUnixDateTime(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.UnixDateTime); - edit.get().endOffset = edit.get().valueOffset + 8; - return this.ReadUnixDateTime(edit.get().valueOffset).clone(); + edit.get().endOffset = edit.get().valueOffset() + 8; + return this.ReadUnixDateTime(edit.get().valueOffset()).clone(); } public long ReadSparseVarInt(Reference edit) { this.ReadSparsePrimitiveTypeCode(edit, LayoutType.VarInt); int sizeLenInBytes; Out tempOut_sizeLenInBytes = new Out(); - long value = this.Read7BitEncodedInt(edit.get().valueOffset, tempOut_sizeLenInBytes); + long value = this.Read7BitEncodedInt(edit.get().valueOffset(), tempOut_sizeLenInBytes); sizeLenInBytes = tempOut_sizeLenInBytes.get(); - edit.get().endOffset = edit.get().valueOffset + sizeLenInBytes; + edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes; return value; } @@ -708,12 +674,336 @@ public final class RowBuffer { Out tempOut_sizeLenInBytes = new Out(); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: ulong value = this.Read7BitEncodedUInt(edit.valueOffset, out int sizeLenInBytes); - long value = this.Read7BitEncodedUInt(edit.get().valueOffset, tempOut_sizeLenInBytes); + long value = this.Read7BitEncodedUInt(edit.get().valueOffset(), tempOut_sizeLenInBytes); sizeLenInBytes = tempOut_sizeLenInBytes.get(); - edit.get().endOffset = edit.get().valueOffset + sizeLenInBytes; + edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes; return value; } + /** + * Move a sparse iterator to the next field within the same sparse scope. + * + * @param edit The iterator to advance. + * + * + * On success, the path of the field at the given offset, otherwise + * undefined. + * + * + * If found, the offset to the metadata of the field, otherwise a + * location to insert the field. + * + * + * If found, the layout code of the matching field found, otherwise + * undefined. + * + * + * If found, the offset to the value of the field, otherwise + * undefined. + * . + * @return True if there is another field, false if there are no more. + */ + public boolean SparseIteratorMoveNext(Reference edit) { + if (edit.get().cellType != null) { + // Move to the next element of an indexed scope. + if (edit.get().scopeType().isIndexedScope()) { + edit.get().index(edit.get().index() + 1); + } + + // Skip forward to the end of the current value. + if (edit.get().endOffset != 0) { + edit.get().metaOffset(edit.get().endOffset); + edit.get().endOffset = 0; + } else { + edit.get().metaOffset(edit.get().metaOffset() + this.SparseComputeSize(edit)); + } + } + + // Check if reached end of buffer. + if (edit.get().metaOffset() < this.length()) { + // Check if reached end of sized scope. + if (!edit.get().scopeType().isSizedScope() || (edit.get().index() != edit.get().count())) { + // Read the metadata. + this.ReadSparseMetadata(edit); + + // Check if reached end of sparse scope. + if (!(edit.get().cellType instanceof LayoutEndScope)) { + edit.get().exists = true; + return true; + } + } + } + + edit.get().cellType = LayoutType.EndScope; + edit.get().exists = false; + edit.get().valueOffset(edit.get().metaOffset()); + return false; + } + + /** + * Produce a new scope from the current iterator position. + * + * @param edit An initialized iterator pointing at a scope. + * @param immutable True if the new scope should be marked immutable (read-only). + * @return A new scope beginning at the current iterator position. + */ + public RowCursor SparseIteratorReadScope(Reference edit, boolean immutable) { + + LayoutScope scopeType = edit.get().cellType instanceof LayoutScope ? (LayoutScope) edit.get().cellType : null; + + if (scopeType instanceof LayoutObject || scopeType instanceof LayoutArray) { + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.get().cellTypeArgs) + .start(edit.get().valueOffset()) + .valueOffset(edit.get().valueOffset()) + .metaOffset(edit.get().valueOffset()) + .layout(edit.get().layout()) + .immutable(immutable); + } + + if (scopeType instanceof LayoutTypedArray || scopeType instanceof LayoutTypedSet || scopeType instanceof LayoutTypedMap) { + + final int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.get().cellTypeArgs) + .start(edit.get().valueOffset()) + .valueOffset(valueOffset) + .metaOffset(valueOffset) + .layout(edit.get().layout()) + .immutable(immutable) + .count(this.ReadUInt32(edit.get().valueOffset())); + } + + if (scopeType instanceof LayoutTypedTuple || scopeType instanceof LayoutTuple || scopeType instanceof LayoutTagged || scopeType instanceof LayoutTagged2) { + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.get().cellTypeArgs) + .start(edit.get().valueOffset()) + .valueOffset(edit.get().valueOffset()) + .metaOffset(edit.get().valueOffset()) + .layout(edit.get().layout()) + .immutable(immutable) + .count(edit.get().cellTypeArgs.count()); + } + + if (scopeType instanceof LayoutNullable) { + + boolean hasValue = this.ReadInt8(edit.get().valueOffset()) != 0; + + if (hasValue) { + + // Start at the T so it can be read. + final int valueOffset = edit.get().valueOffset() + 1; + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.get().cellTypeArgs) + .start(edit.get().valueOffset()) + .valueOffset(valueOffset) + .metaOffset(valueOffset) + .layout(edit.get().layout()) + .immutable(immutable) + .count(2) + .index(1); + } else { + + // Start at the end of the scope, instead of at the T, so the T will be skipped. + final TypeArgument typeArg = edit.get().cellTypeArgs.get(0); + final int valueOffset = edit.get().valueOffset() + 1 + this.countDefaultValue(typeArg.type(), + typeArg.typeArgs()); + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.get().cellTypeArgs) + .start(edit.get().valueOffset()) + .valueOffset(valueOffset) + .metaOffset(valueOffset) + .layout(edit.get().layout()) + .immutable(immutable) + .count(2) + .index(2); + } + } + + if (scopeType instanceof LayoutUDT) { + + final Layout udt = this.resolver.Resolve(edit.get().cellTypeArgs.schemaId()); + final int valueOffset = this.computeVariableValueOffset(udt, edit.get().valueOffset(), udt.numVariable()); + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.get().cellTypeArgs) + .start(edit.get().valueOffset()) + .valueOffset(valueOffset) + .metaOffset(valueOffset) + .layout(udt) + .immutable(immutable); + } + + throw new IllegalStateException(lenientFormat("Not a scope type: %s", scopeType)); + } + + public void TypedCollectionMoveField(Reference dstEdit, Reference srcEdit + , RowOptions options) { + int encodedSize = this.SparseComputeSize(srcEdit); + int numBytes = encodedSize - (srcEdit.get().valueOffset() - srcEdit.get().metaOffset()); + + // Insert the field metadata into its new location. + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shiftInsert; + Out tempOut_shiftInsert = new Out(); + this.EnsureSparse(dstEdit, srcEdit.get().cellType, srcEdit.get().cellTypeArgs.clone(), numBytes, + options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shiftInsert); + shiftInsert = tempOut_shiftInsert.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + + this.WriteSparseMetadata(dstEdit, srcEdit.get().cellType, srcEdit.get().cellTypeArgs.clone(), metaBytes); + checkState(spaceNeeded == metaBytes + numBytes); + if (srcEdit.get().metaOffset() >= dstEdit.get().metaOffset()) { + srcEdit.get().metaOffset(srcEdit.get().metaOffset() + shiftInsert); + srcEdit.get().valueOffset(srcEdit.get().valueOffset() + shiftInsert); + } + + // Copy the value bits from the old location. + this.buffer.Slice(srcEdit.get().valueOffset(), numBytes).CopyTo(this.buffer.Slice(dstEdit.get().valueOffset())); + this.length(this.length() + shiftInsert); + + // Delete the old location. + Out tempOut_metaBytes2 = new Out(); + Out tempOut_spaceNeeded2 = new Out(); + int shiftDelete; + Out tempOut_shiftDelete = new Out(); + this.EnsureSparse(srcEdit, srcEdit.get().cellType, srcEdit.get().cellTypeArgs.clone(), numBytes, + RowOptions.Delete, tempOut_metaBytes2, tempOut_spaceNeeded2, tempOut_shiftDelete); + shiftDelete = tempOut_shiftDelete.get(); + spaceNeeded = tempOut_spaceNeeded2.get(); + metaBytes = tempOut_metaBytes2.get(); + + checkState(shiftDelete < 0); + this.length(this.length() + shiftDelete); + } + + /** + * Rebuild the unique index for a set/map scope. + * + * @param scope The sparse scope to rebuild an index for. + * @return Success if the index could be built, an error otherwise. + *

+ * The MUST be a set or map scope. + *

+ * The scope may have been built (e.g. via RowWriter) with relaxed uniqueness constraint checking. + * This operation rebuilds an index to support verification of uniqueness constraints during + * subsequent partial updates. If the appropriate uniqueness constraints cannot be established (i.e. + * a duplicate exists), this operation fails. Before continuing, the resulting scope should either: + * + * + * + * Be repaired (e.g. by deleting duplicates) and the index rebuild operation should be + * run again. + * + * + * Be deleted. The entire scope should be removed including its items. + * + * Failure to perform one of these actions will leave the row is potentially in a corrupted + * state where partial updates may subsequent fail. + *

+ *

+ * The target may or may not have already been indexed. This + * operation is idempotent. + *

+ */ + public Result TypedCollectionUniqueIndexRebuild(Reference scope) { + checkArgument(scope.get().scopeType().isUniqueScope()); + checkArgument(scope.get().index() == 0); + RowCursor dstEdit; + // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these + // cannot be + // converted using the 'Out' helper class unless the method is within the code being modified: + scope.get().Clone(out dstEdit); + if (dstEdit.count() <= 1) { + return Result.Success; + } + + // Compute Index Elements. + // TODO: C# TO JAVA CONVERTER: There is no equivalent to 'stackalloc' in Java: + UniqueIndexItem item; + Span uniqueIndex = dstEdit.count() < 100 ? stackalloc UniqueIndexItem[dstEdit.count()] : + new UniqueIndexItem[dstEdit.count()]; + dstEdit.metaOffset(scope.get().valueOffset()); + for (; dstEdit.index() < dstEdit.count(); dstEdit.index(dstEdit.index() + 1)) { + Reference tempReference_dstEdit = + new Reference(dstEdit); + this.ReadSparseMetadata(tempReference_dstEdit); + dstEdit = tempReference_dstEdit.get(); + Contract.Assert(dstEdit.pathOffset == + default) + Reference tempReference_dstEdit2 = + new Reference(dstEdit); + int elmSize = this.SparseComputeSize(tempReference_dstEdit2); + dstEdit = tempReference_dstEdit2.get(); + + UniqueIndexItem tempVar = new UniqueIndexItem(); + tempVar.code(dstEdit.cellType.LayoutCode); + tempVar.metaOffset(dstEdit.metaOffset()); + tempVar.valueOffset(dstEdit.valueOffset()); + tempVar.size(elmSize); + uniqueIndex[dstEdit.index()] = tempVar.clone(); + + dstEdit.metaOffset(dstEdit.metaOffset() + elmSize); + } + + // Create scratch space equal to the sum of the sizes of the scope's values. + // Implementation Note: theoretically this scratch space could be eliminated by + // performing the item move operations directly during the Insertion Sort, however, + // doing so might result in moving the same item multiple times. Under the assumption + // that items are relatively large, using scratch space requires each item to be moved + // AT MOST once. Given that row buffer memory is likely reused, scratch space is + // relatively memory efficient. + int shift = dstEdit.metaOffset() - scope.get().valueOffset(); + + // Sort and check for duplicates. + // TODO: C# TO JAVA CONVERTER: C# 'unsafe' code is not converted by C# to Java Converter: + // unsafe + // { + // Span p = new Span(Unsafe.AsPointer(ref uniqueIndex + // .GetPinnableReference()), uniqueIndex.Length); + // if (!this.InsertionSort(ref scope, ref dstEdit, p)) + // { + // return Result.Exists; + // } + // } + + // Move elements. + int metaOffset = scope.get().valueOffset(); + this.Ensure(this.length() + shift); + this.buffer.Slice(metaOffset, this.length() - metaOffset).CopyTo(this.buffer.Slice(metaOffset + shift)); + for (UniqueIndexItem x : uniqueIndex) { + this.buffer.Slice(x.metaOffset() + shift, x.size()).CopyTo(this.buffer.Slice(metaOffset)); + metaOffset += x.size(); + } + + // Delete the scratch space (if necessary - if it doesn't just fall off the end of the row). + if (metaOffset != this.length()) { + this.buffer.Slice(metaOffset + shift, this.length() - metaOffset).CopyTo(this.buffer.Slice(metaOffset)); + } + + // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: + //#if DEBUG + // Fill deleted bits (in debug builds) to detect overflow/alignment errors. + this.buffer.Slice(this.length(), shift).Fill(0xFF); + //#endif + + return Result.Success; + } + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: internal ushort ReadUInt16(int offset) public short ReadUInt16(int offset) { @@ -794,7 +1084,7 @@ public final class RowBuffer { * Clears all content from the row. The row is empty after this method. */ public void Reset() { - this.length = 0; + this.length(0); this.resolver = null; } @@ -870,218 +1160,44 @@ public final class RowBuffer { this.buffer[bit.GetOffset(offset)] |= (byte)(1 << bit.GetBit()); } - /** - * Move a sparse iterator to the next field within the same sparse scope. - * - * @param edit The iterator to advance. - * - * - * On success, the path of the field at the given offset, otherwise - * undefined. - * - * - * If found, the offset to the metadata of the field, otherwise a - * location to insert the field. - * - * - * If found, the layout code of the matching field found, otherwise - * undefined. - * - * - * If found, the offset to the value of the field, otherwise - * undefined. - * . - * @return True if there is another field, false if there are no more. - */ - public boolean SparseIteratorMoveNext(Reference edit) { - if (edit.get().cellType != null) { - // Move to the next element of an indexed scope. - if (edit.get().scopeType.IsIndexedScope) { - edit.get().index++; - } - - // Skip forward to the end of the current value. - if (edit.get().endOffset != 0) { - edit.get().metaOffset = edit.get().endOffset; - edit.get().endOffset = 0; - } else { - edit.get().metaOffset += this.SparseComputeSize(edit); - } + public void WriteNullable(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs, + UpdateOptions options, boolean hasValue, Out newScope) { + int numBytes = this.countDefaultValue(scopeType, typeArgs.clone()); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); + int numWritten = this.WriteDefaultValue(edit.get().valueOffset(), scopeType, typeArgs.clone()); + checkState(numBytes == numWritten); + checkState(spaceNeeded == metaBytes + numBytes); + if (hasValue) { + this.WriteInt8(edit.get().valueOffset(), (byte) 1); } - // Check if reached end of buffer. - if (edit.get().metaOffset < this.length) { - // Check if reached end of sized scope. - if (!edit.get().scopeType.IsSizedScope || (edit.get().index != edit.get().count)) { - // Read the metadata. - this.ReadSparseMetadata(edit); + int valueOffset = edit.get().valueOffset() + 1; + newScope.setAndGet(new RowCursor()); + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(typeArgs.clone()); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(valueOffset); + newScope.get().metaOffset(valueOffset); + newScope.get().layout(edit.get().layout()); + newScope.get().count(2); + newScope.get().index(1); - // Check if reached end of sparse scope. - if (!(edit.get().cellType instanceof LayoutEndScope)) { - edit.get().exists = true; - return true; - } - } - } - - edit.get().cellType = LayoutType.EndScope; - edit.get().exists = false; - edit.get().valueOffset = edit.get().metaOffset; - return false; - } - - /** - * Produce a new scope from the current iterator position. - * - * @param edit An initialized iterator pointing at a scope. - * @param immutable True if the new scope should be marked immutable (read-only). - * @return A new scope beginning at the current iterator position. - */ - public RowCursor SparseIteratorReadScope(Reference edit, boolean immutable) { - LayoutScope scopeType = edit.get().cellType instanceof LayoutScope ? (LayoutScope)edit.get().cellType : - null; - switch (scopeType) { - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutObject _: - case LayoutObject - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutArray _: - case LayoutArray _: - { - RowCursor tempVar = new RowCursor(); - tempVar.scopeType = scopeType; - tempVar.scopeTypeArgs = edit.get().cellTypeArgs.clone(); - tempVar.start = edit.get().valueOffset; - tempVar.valueOffset = edit.get().valueOffset; - tempVar.metaOffset = edit.get().valueOffset; - tempVar.layout = edit.get().layout; - tempVar.immutable = immutable; - return tempVar.clone(); - - break; - } - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedArray _: - case LayoutTypedArray - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedSet _: - case LayoutTypedSet _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedMap _: - case LayoutTypedMap _: - { - int valueOffset = edit.get().valueOffset + (Integer.SIZE / Byte.SIZE); // Point after the Size - RowCursor tempVar2 = new RowCursor(); - tempVar2.scopeType = scopeType; - tempVar2.scopeTypeArgs = edit.get().cellTypeArgs.clone(); - tempVar2.start = edit.get().valueOffset; - tempVar2.valueOffset = valueOffset; - tempVar2.metaOffset = valueOffset; - tempVar2.layout = edit.get().layout; - tempVar2.immutable = immutable; - tempVar2.count = this.ReadUInt32(edit.get().valueOffset); - return tempVar2.clone(); - - break; - } - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedTuple _: - case LayoutTypedTuple - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTuple _: - case LayoutTuple _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTagged _: - case LayoutTagged _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTagged2 _: - case LayoutTagged2 _: - { - RowCursor tempVar3 = new RowCursor(); - tempVar3.scopeType = scopeType; - tempVar3.scopeTypeArgs = edit.get().cellTypeArgs.clone(); - tempVar3.start = edit.get().valueOffset; - tempVar3.valueOffset = edit.get().valueOffset; - tempVar3.metaOffset = edit.get().valueOffset; - tempVar3.layout = edit.get().layout; - tempVar3.immutable = immutable; - tempVar3.count = edit.get().cellTypeArgs.getCount(); - return tempVar3.clone(); - - break; - } - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutNullable _: - case LayoutNullable - _: - { - boolean hasValue = this.ReadInt8(edit.get().valueOffset) != 0; - if (hasValue) { - // Start at the T so it can be read. - int valueOffset = edit.get().valueOffset + 1; - RowCursor tempVar4 = new RowCursor(); - tempVar4.scopeType = scopeType; - tempVar4.scopeTypeArgs = edit.get().cellTypeArgs.clone(); - tempVar4.start = edit.get().valueOffset; - tempVar4.valueOffset = valueOffset; - tempVar4.metaOffset = valueOffset; - tempVar4.layout = edit.get().layout; - tempVar4.immutable = immutable; - tempVar4.count = 2; - tempVar4.index = 1; - return tempVar4.clone(); - } else { - // Start at the end of the scope, instead of at the T, so the T will be skipped. - TypeArgument typeArg = edit.get().cellTypeArgs.get(0).clone(); - int valueOffset = edit.get().valueOffset + 1 + this.CountDefaultValue(typeArg.getType(), - typeArg.getTypeArgs().clone()); - RowCursor tempVar5 = new RowCursor(); - tempVar5.scopeType = scopeType; - tempVar5.scopeTypeArgs = edit.get().cellTypeArgs.clone(); - tempVar5.start = edit.get().valueOffset; - tempVar5.valueOffset = valueOffset; - tempVar5.metaOffset = valueOffset; - tempVar5.layout = edit.get().layout; - tempVar5.immutable = immutable; - tempVar5.count = 2; - tempVar5.index = 2; - return tempVar5.clone(); - } - - break; - } - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUDT _: - case LayoutUDT - _: - { - Layout udt = this.resolver.Resolve(edit.get().cellTypeArgs.getSchemaId().clone()); - int valueOffset = this.ComputeVariableValueOffset(udt, edit.get().valueOffset, - udt.numVariable()); - RowCursor tempVar6 = new RowCursor(); - tempVar6.scopeType = scopeType; - tempVar6.scopeTypeArgs = edit.get().cellTypeArgs.clone(); - tempVar6.start = edit.get().valueOffset; - tempVar6.valueOffset = valueOffset; - tempVar6.metaOffset = valueOffset; - tempVar6.layout = udt; - tempVar6.immutable = immutable; - return tempVar6.clone(); - - break; - } - - default: - throw new IllegalStateException("Not a scope type."); - return null; - } + this.length(this.length() + shift); + Reference tempReference_this = + new Reference(this); + RowCursorExtensions.MoveNext(newScope.get().clone(), tempReference_this); + this = tempReference_this.get(); } /** @@ -1090,164 +1206,66 @@ public final class RowBuffer { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public byte[] ToArray() public byte[] ToArray() { - return this.buffer.Slice(0, this.length).ToArray(); + return this.buffer.Slice(0, this.length()).ToArray(); } - public void TypedCollectionMoveField(Reference dstEdit, Reference srcEdit - , RowOptions options) { - int encodedSize = this.SparseComputeSize(srcEdit); - int numBytes = encodedSize - (srcEdit.get().valueOffset - srcEdit.get().metaOffset); + public void WriteSchemaId(int offset, SchemaId value) { + this.WriteInt32(offset, value.id()); + } - // Insert the field metadata into its new location. + public void WriteSparseArray(Reference edit, LayoutScope scopeType, UpdateOptions options, + Out newScope) { + int numBytes = (LayoutCode.SIZE / Byte.SIZE); // end scope type code. + TypeArgumentList typeArgs = TypeArgumentList.EMPTY; int metaBytes; Out tempOut_metaBytes = new Out(); int spaceNeeded; Out tempOut_spaceNeeded = new Out(); - int shiftInsert; - Out tempOut_shiftInsert = new Out(); - this.EnsureSparse(dstEdit, srcEdit.get().cellType, srcEdit.get().cellTypeArgs.clone(), numBytes, - options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shiftInsert); - shiftInsert = tempOut_shiftInsert.get(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - - this.WriteSparseMetadata(dstEdit, srcEdit.get().cellType, srcEdit.get().cellTypeArgs.clone(), metaBytes); + this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); + this.WriteSparseTypeCode(edit.get().valueOffset(), LayoutCode.END_SCOPE); checkState(spaceNeeded == metaBytes + numBytes); - if (srcEdit.get().metaOffset >= dstEdit.get().metaOffset) { - srcEdit.get().metaOffset += shiftInsert; - srcEdit.get().valueOffset += shiftInsert; - } + newScope.setAndGet(new RowCursor()); + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(typeArgs.clone()); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(edit.get().valueOffset()); + newScope.get().metaOffset(edit.get().valueOffset()); + newScope.get().layout(edit.get().layout()); - // Copy the value bits from the old location. - this.buffer.Slice(srcEdit.get().valueOffset, numBytes).CopyTo(this.buffer.Slice(dstEdit.get().valueOffset)); - this.length += shiftInsert; - - // Delete the old location. - Out tempOut_metaBytes2 = new Out(); - Out tempOut_spaceNeeded2 = new Out(); - int shiftDelete; - Out tempOut_shiftDelete = new Out(); - this.EnsureSparse(srcEdit, srcEdit.get().cellType, srcEdit.get().cellTypeArgs.clone(), numBytes, - RowOptions.Delete, tempOut_metaBytes2, tempOut_spaceNeeded2, tempOut_shiftDelete); - shiftDelete = tempOut_shiftDelete.get(); - spaceNeeded = tempOut_spaceNeeded2.get(); - metaBytes = tempOut_metaBytes2.get(); - - checkState(shiftDelete < 0); - this.length += shiftDelete; + this.length(this.length() + shift); } - /** - * Rebuild the unique index for a set/map scope. - * - * @param scope The sparse scope to rebuild an index for. - * @return Success if the index could be built, an error otherwise. - *

- * The MUST be a set or map scope. - *

- * The scope may have been built (e.g. via RowWriter) with relaxed uniqueness constraint checking. - * This operation rebuilds an index to support verification of uniqueness constraints during - * subsequent partial updates. If the appropriate uniqueness constraints cannot be established (i.e. - * a duplicate exists), this operation fails. Before continuing, the resulting scope should either: - * - * - * - * Be repaired (e.g. by deleting duplicates) and the index rebuild operation should be - * run again. - * - * - * Be deleted. The entire scope should be removed including its items. - * - * Failure to perform one of these actions will leave the row is potentially in a corrupted - * state where partial updates may subsequent fail. - *

- *

- * The target may or may not have already been indexed. This - * operation is idempotent. - *

- */ - public Result TypedCollectionUniqueIndexRebuild(Reference scope) { - checkArgument(scope.get().scopeType.IsUniqueScope); - checkArgument(scope.get().index == 0); - RowCursor dstEdit; - // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these - // cannot be - // converted using the 'Out' helper class unless the method is within the code being modified: - scope.get().Clone(out dstEdit); - if (dstEdit.count <= 1) { - return Result.Success; - } - - // Compute Index Elements. - // TODO: C# TO JAVA CONVERTER: There is no equivalent to 'stackalloc' in Java: - UniqueIndexItem item; - Span uniqueIndex = dstEdit.count < 100 ? stackalloc UniqueIndexItem[dstEdit.count] : - new UniqueIndexItem[dstEdit.count]; - dstEdit.metaOffset = scope.get().valueOffset; - for (; dstEdit.index < dstEdit.count; dstEdit.index++) { - Reference tempReference_dstEdit = - new Reference(dstEdit); - this.ReadSparseMetadata(tempReference_dstEdit); - dstEdit = tempReference_dstEdit.get(); - Contract.Assert(dstEdit.pathOffset == - default) - Reference tempReference_dstEdit2 = - new Reference(dstEdit); - int elmSize = this.SparseComputeSize(tempReference_dstEdit2); - dstEdit = tempReference_dstEdit2.get(); - - UniqueIndexItem tempVar = new UniqueIndexItem(); - tempVar.Code = dstEdit.cellType.LayoutCode; - tempVar.MetaOffset = dstEdit.metaOffset; - tempVar.ValueOffset = dstEdit.valueOffset; - tempVar.Size = elmSize; - uniqueIndex[dstEdit.index] = tempVar.clone(); - - dstEdit.metaOffset += elmSize; - } - - // Create scratch space equal to the sum of the sizes of the scope's values. - // Implementation Note: theoretically this scratch space could be eliminated by - // performing the item move operations directly during the Insertion Sort, however, - // doing so might result in moving the same item multiple times. Under the assumption - // that items are relatively large, using scratch space requires each item to be moved - // AT MOST once. Given that row buffer memory is likely reused, scratch space is - // relatively memory efficient. - int shift = dstEdit.metaOffset - scope.get().valueOffset; - - // Sort and check for duplicates. - // TODO: C# TO JAVA CONVERTER: C# 'unsafe' code is not converted by C# to Java Converter: - // unsafe - // { - // Span p = new Span(Unsafe.AsPointer(ref uniqueIndex - // .GetPinnableReference()), uniqueIndex.Length); - // if (!this.InsertionSort(ref scope, ref dstEdit, p)) - // { - // return Result.Exists; - // } - // } - - // Move elements. - int metaOffset = scope.get().valueOffset; - this.Ensure(this.length + shift); - this.buffer.Slice(metaOffset, this.length - metaOffset).CopyTo(this.buffer.Slice(metaOffset + shift)); - for (UniqueIndexItem x : uniqueIndex) { - this.buffer.Slice(x.MetaOffset + shift, x.Size).CopyTo(this.buffer.Slice(metaOffset)); - metaOffset += x.Size; - } - - // Delete the scratch space (if necessary - if it doesn't just fall off the end of the row). - if (metaOffset != this.length) { - this.buffer.Slice(metaOffset + shift, this.length - metaOffset).CopyTo(this.buffer.Slice(metaOffset)); - } - - // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: - //#if DEBUG - // Fill deleted bits (in debug builds) to detect overflow/alignment errors. - this.buffer.Slice(this.length, shift).Fill(0xFF); - //#endif - - return Result.Success; + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal void WriteSparseBinary(ref RowCursor edit, ReadOnlySpan value, UpdateOptions + // options) + public void WriteSparseBinary(Reference edit, ReadOnlySpan value, UpdateOptions options) { + int len = value.Length; + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: int numBytes = len + RowBuffer.Count7BitEncodedUInt((ulong)len); + int numBytes = len + RowBuffer.Count7BitEncodedUInt(len); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Binary, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.WriteSparseMetadata(edit, LayoutType.Binary, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.WriteBinary(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void UnsetBit(int offset, LayoutBit bit) { @@ -1383,105 +1401,6 @@ public final class RowBuffer { value = tempReference_value.get(); } - public void WriteNullable(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs, - UpdateOptions options, boolean hasValue, Out newScope) { - int numBytes = this.CountDefaultValue(scopeType, typeArgs.clone()); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); - int numWritten = this.WriteDefaultValue(edit.get().valueOffset, scopeType, typeArgs.clone()); - checkState(numBytes == numWritten); - checkState(spaceNeeded == metaBytes + numBytes); - if (hasValue) { - this.WriteInt8(edit.get().valueOffset, (byte)1); - } - - int valueOffset = edit.get().valueOffset + 1; - newScope.setAndGet(new RowCursor()); - newScope.get().scopeType = scopeType; - newScope.get().scopeTypeArgs = typeArgs.clone(); - newScope.get().start = edit.get().valueOffset; - newScope.get().valueOffset = valueOffset; - newScope.get().metaOffset = valueOffset; - newScope.get().layout = edit.get().layout; - newScope.get().count = 2; - newScope.get().index = 1; - - this.length += shift; - Reference tempReference_this = - new Reference(this); - RowCursorExtensions.MoveNext(newScope.get().clone(), tempReference_this); - this = tempReference_this.get(); - } - - public void WriteSchemaId(int offset, SchemaId value) { - this.WriteInt32(offset, value.getId()); - } - - public void WriteSparseArray(Reference edit, LayoutScope scopeType, UpdateOptions options, - Out newScope) { - int numBytes = (LayoutCode.SIZE / Byte.SIZE); // end scope type code. - TypeArgumentList typeArgs = TypeArgumentList.Empty; - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); - this.WriteSparseTypeCode(edit.get().valueOffset, LayoutCode.EndScope); - checkState(spaceNeeded == metaBytes + numBytes); - newScope.setAndGet(new RowCursor()); - newScope.get().scopeType = scopeType; - newScope.get().scopeTypeArgs = typeArgs.clone(); - newScope.get().start = edit.get().valueOffset; - newScope.get().valueOffset = edit.get().valueOffset; - newScope.get().metaOffset = edit.get().valueOffset; - newScope.get().layout = edit.get().layout; - - this.length += shift; - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal void WriteSparseBinary(ref RowCursor edit, ReadOnlySpan value, UpdateOptions - // options) - public void WriteSparseBinary(Reference edit, ReadOnlySpan value, UpdateOptions options) { - int len = value.Length; - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: int numBytes = len + RowBuffer.Count7BitEncodedUInt((ulong)len); - int numBytes = len + RowBuffer.Count7BitEncodedUInt(len); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Binary, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Binary, TypeArgumentList.Empty, metaBytes); - int sizeLenInBytes = this.WriteBinary(edit.get().valueOffset, value); - checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; - } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: internal void WriteSparseBinary(ref RowCursor edit, ReadOnlySequence value, UpdateOptions // options) @@ -1497,16 +1416,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Binary, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Binary, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Binary, TypeArgumentList.Empty, metaBytes); - int sizeLenInBytes = this.WriteBinary(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Binary, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.WriteBinary(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseBool(Reference edit, boolean value, UpdateOptions options) { @@ -1517,16 +1436,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.Empty, + this.EnsureSparse(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.Empty, + this.WriteSparseMetadata(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.EMPTY, metaBytes); checkState(spaceNeeded == metaBytes); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseDateTime(Reference edit, LocalDateTime value, UpdateOptions options) { @@ -1537,16 +1456,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.DateTime, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.DateTime, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.DateTime, TypeArgumentList.Empty, metaBytes); - this.WriteDateTime(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.DateTime, TypeArgumentList.EMPTY, metaBytes); + this.WriteDateTime(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + 8); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseDecimal(Reference edit, BigDecimal value, UpdateOptions options) { @@ -1558,17 +1477,17 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Decimal, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Decimal, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Decimal, TypeArgumentList.Empty, metaBytes); - this.WriteDecimal(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Decimal, TypeArgumentList.EMPTY, metaBytes); + this.WriteDecimal(edit.get().valueOffset(), value); // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': checkState(spaceNeeded == metaBytes + sizeof(BigDecimal)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseFloat128(Reference edit, Float128 value, UpdateOptions options) { @@ -1579,16 +1498,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Float128, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Float128, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Float128, TypeArgumentList.Empty, metaBytes); - this.WriteFloat128(edit.get().valueOffset, value.clone()); + this.WriteSparseMetadata(edit, LayoutType.Float128, TypeArgumentList.EMPTY, metaBytes); + this.WriteFloat128(edit.get().valueOffset(), value.clone()); checkState(spaceNeeded == metaBytes + Float128.Size); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseFloat32(Reference edit, float value, UpdateOptions options) { @@ -1599,16 +1518,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Float32, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Float32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Float32, TypeArgumentList.Empty, metaBytes); - this.WriteFloat32(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Float32, TypeArgumentList.EMPTY, metaBytes); + this.WriteFloat32(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Float.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseFloat64(Reference edit, double value, UpdateOptions options) { @@ -1619,16 +1538,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Float64, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Float64, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Float64, TypeArgumentList.Empty, metaBytes); - this.WriteFloat64(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Float64, TypeArgumentList.EMPTY, metaBytes); + this.WriteFloat64(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Double.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseGuid(Reference edit, UUID value, UpdateOptions options) { @@ -1639,16 +1558,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Guid, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Guid, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Guid, TypeArgumentList.Empty, metaBytes); - this.WriteGuid(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Guid, TypeArgumentList.EMPTY, metaBytes); + this.WriteGuid(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + 16); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseInt16(Reference edit, short value, UpdateOptions options) { @@ -1659,16 +1578,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Int16, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Int16, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Int16, TypeArgumentList.Empty, metaBytes); - this.WriteInt16(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Int16, TypeArgumentList.EMPTY, metaBytes); + this.WriteInt16(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Short.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseInt32(Reference edit, int value, UpdateOptions options) { @@ -1679,16 +1598,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Int32, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Int32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Int32, TypeArgumentList.Empty, metaBytes); - this.WriteInt32(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Int32, TypeArgumentList.EMPTY, metaBytes); + this.WriteInt32(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Integer.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseInt64(Reference edit, long value, UpdateOptions options) { @@ -1699,16 +1618,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Int64, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Int64, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Int64, TypeArgumentList.Empty, metaBytes); - this.WriteInt64(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Int64, TypeArgumentList.EMPTY, metaBytes); + this.WriteInt64(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Long.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseInt8(Reference edit, byte value, UpdateOptions options) { @@ -1719,17 +1638,17 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Int8, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Int8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Int8, TypeArgumentList.Empty, metaBytes); - this.WriteInt8(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Int8, TypeArgumentList.EMPTY, metaBytes); + this.WriteInt8(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Byte.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseMongoDbObjectId(Reference edit, MongoDbObjectId value, @@ -1741,17 +1660,17 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, MongoDbObjectId, TypeArgumentList.Empty, numBytes, options, + this.EnsureSparse(edit, MongoDbObjectId, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, MongoDbObjectId, TypeArgumentList.Empty, metaBytes); - this.WriteMongoDbObjectId(edit.get().valueOffset, value.clone()); + this.WriteSparseMetadata(edit, MongoDbObjectId, TypeArgumentList.EMPTY, metaBytes); + this.WriteMongoDbObjectId(edit.get().valueOffset(), value.clone()); checkState(spaceNeeded == metaBytes + MongoDbObjectId.Size); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseNull(Reference edit, NullValue value, UpdateOptions options) { @@ -1762,21 +1681,21 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Null, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Null, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Null, TypeArgumentList.Empty, metaBytes); + this.WriteSparseMetadata(edit, LayoutType.Null, TypeArgumentList.EMPTY, metaBytes); checkState(spaceNeeded == metaBytes); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseObject(Reference edit, LayoutScope scopeType, UpdateOptions options, Out newScope) { int numBytes = (LayoutCode.SIZE / Byte.SIZE); // end scope type code. - TypeArgumentList typeArgs = TypeArgumentList.Empty; + TypeArgumentList typeArgs = TypeArgumentList.EMPTY; int metaBytes; Out tempOut_metaBytes = new Out(); int spaceNeeded; @@ -1788,18 +1707,18 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, TypeArgumentList.Empty, metaBytes); - this.WriteSparseTypeCode(edit.get().valueOffset, LayoutCode.EndScope); + this.WriteSparseMetadata(edit, scopeType, TypeArgumentList.EMPTY, metaBytes); + this.WriteSparseTypeCode(edit.get().valueOffset(), LayoutCode.END_SCOPE); checkState(spaceNeeded == metaBytes + numBytes); newScope.setAndGet(new RowCursor()); - newScope.get().scopeType = scopeType; - newScope.get().scopeTypeArgs = TypeArgumentList.Empty; - newScope.get().start = edit.get().valueOffset; - newScope.get().valueOffset = edit.get().valueOffset; - newScope.get().metaOffset = edit.get().valueOffset; - newScope.get().layout = edit.get().layout; + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(TypeArgumentList.EMPTY); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(edit.get().valueOffset()); + newScope.get().metaOffset(edit.get().valueOffset()); + newScope.get().layout(edit.get().layout()); - this.length += shift; + this.length(this.length() + shift); } public void WriteSparseString(Reference edit, Utf8Span value, UpdateOptions options) { @@ -1813,21 +1732,21 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Utf8, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.Utf8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Utf8, TypeArgumentList.Empty, metaBytes); - int sizeLenInBytes = this.WriteString(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.Utf8, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.WriteString(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseTuple(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs , UpdateOptions options, Out newScope) { - int numBytes = (LayoutCode.SIZE / Byte.SIZE) * (1 + typeArgs.getCount()); // nulls for each element. + int numBytes = (LayoutCode.SIZE / Byte.SIZE) * (1 + typeArgs.count()); // nulls for each element. int metaBytes; Out tempOut_metaBytes = new Out(); int spaceNeeded; @@ -1840,33 +1759,33 @@ public final class RowBuffer { spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); - int valueOffset = edit.get().valueOffset; - for (int i = 0; i < typeArgs.getCount(); i++) { - this.WriteSparseTypeCode(valueOffset, LayoutCode.Null); + int valueOffset = edit.get().valueOffset(); + for (int i = 0; i < typeArgs.count(); i++) { + this.WriteSparseTypeCode(valueOffset, LayoutCode.NULL); valueOffset += (LayoutCode.SIZE / Byte.SIZE); } - this.WriteSparseTypeCode(valueOffset, LayoutCode.EndScope); + this.WriteSparseTypeCode(valueOffset, LayoutCode.END_SCOPE); checkState(spaceNeeded == metaBytes + numBytes); newScope.setAndGet(new RowCursor()); - newScope.get().scopeType = scopeType; - newScope.get().scopeTypeArgs = typeArgs.clone(); - newScope.get().start = edit.get().valueOffset; - newScope.get().valueOffset = edit.get().valueOffset; - newScope.get().metaOffset = edit.get().valueOffset; - newScope.get().layout = edit.get().layout; - newScope.get().count = typeArgs.getCount(); + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(typeArgs.clone()); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(edit.get().valueOffset()); + newScope.get().metaOffset(edit.get().valueOffset()); + newScope.get().layout(edit.get().layout()); + newScope.get().count(typeArgs.count()); - this.length += shift; + this.length(this.length() + shift); } // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal void WriteSparseTypeCode(int offset, - // LayoutCode code) + // LayoutCode code) public void WriteSparseTypeCode(int offset, LayoutCode code) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: this.WriteUInt8(offset, (byte)code); - this.WriteUInt8(offset, (byte)code.getValue()); + this.WriteUInt8(offset, (byte) code.value()); } public void WriteSparseUDT(Reference edit, LayoutScope scopeType, Layout udt, @@ -1887,21 +1806,21 @@ public final class RowBuffer { this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); // Clear all presence bits. - this.buffer.Slice(edit.get().valueOffset, udt.size()).Fill(0); + this.buffer.Slice(edit.get().valueOffset(), udt.size()).Fill(0); // Write scope terminator. - int valueOffset = edit.get().valueOffset + udt.size(); - this.WriteSparseTypeCode(valueOffset, LayoutCode.EndScope); + int valueOffset = edit.get().valueOffset() + udt.size(); + this.WriteSparseTypeCode(valueOffset, LayoutCode.END_SCOPE); checkState(spaceNeeded == metaBytes + numBytes); newScope.setAndGet(new RowCursor()); - newScope.get().scopeType = scopeType; - newScope.get().scopeTypeArgs = typeArgs.clone(); - newScope.get().start = edit.get().valueOffset; - newScope.get().valueOffset = valueOffset; - newScope.get().metaOffset = valueOffset; - newScope.get().layout = udt; + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(typeArgs.clone()); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(valueOffset); + newScope.get().metaOffset(valueOffset); + newScope.get().layout(udt); - this.length += shift; + this.length(this.length() + shift); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -1914,16 +1833,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.UInt16, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.UInt16, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UInt16, TypeArgumentList.Empty, metaBytes); - this.WriteUInt16(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.UInt16, TypeArgumentList.EMPTY, metaBytes); + this.WriteUInt16(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Short.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -1936,16 +1855,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.UInt32, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.UInt32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UInt32, TypeArgumentList.Empty, metaBytes); - this.WriteUInt32(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.UInt32, TypeArgumentList.EMPTY, metaBytes); + this.WriteUInt32(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Integer.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -1958,16 +1877,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.UInt64, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.UInt64, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UInt64, TypeArgumentList.Empty, metaBytes); - this.WriteUInt64(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.UInt64, TypeArgumentList.EMPTY, metaBytes); + this.WriteUInt64(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Long.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -1980,16 +1899,16 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.UInt8, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.UInt8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UInt8, TypeArgumentList.Empty, metaBytes); - this.WriteUInt8(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.UInt8, TypeArgumentList.EMPTY, metaBytes); + this.WriteUInt8(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + 1); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseUnixDateTime(Reference edit, UnixDateTime value, UpdateOptions options) { @@ -2000,17 +1919,17 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.UnixDateTime, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes + this.EnsureSparse(edit, LayoutType.UnixDateTime, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes , tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UnixDateTime, TypeArgumentList.Empty, metaBytes); - this.WriteUnixDateTime(edit.get().valueOffset, value.clone()); + this.WriteSparseMetadata(edit, LayoutType.UnixDateTime, TypeArgumentList.EMPTY, metaBytes); + this.WriteUnixDateTime(edit.get().valueOffset(), value.clone()); checkState(spaceNeeded == metaBytes + 8); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseVarInt(Reference edit, long value, UpdateOptions options) { @@ -2021,17 +1940,17 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.VarInt, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.VarInt, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.VarInt, TypeArgumentList.Empty, metaBytes); - int sizeLenInBytes = this.Write7BitEncodedInt(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.VarInt, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.Write7BitEncodedInt(edit.get().valueOffset(), value); checkState(sizeLenInBytes == numBytes); checkState(spaceNeeded == metaBytes + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -2044,24 +1963,17 @@ public final class RowBuffer { Out tempOut_spaceNeeded = new Out(); int shift; Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.VarUInt, TypeArgumentList.Empty, numBytes, options, tempOut_metaBytes, + this.EnsureSparse(edit, LayoutType.VarUInt, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.VarUInt, TypeArgumentList.Empty, metaBytes); - int sizeLenInBytes = this.Write7BitEncodedUInt(edit.get().valueOffset, value); + this.WriteSparseMetadata(edit, LayoutType.VarUInt, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.Write7BitEncodedUInt(edit.get().valueOffset(), value); checkState(sizeLenInBytes == numBytes); checkState(spaceNeeded == metaBytes + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset + spaceNeeded; - this.length += shift; - } - - /** - * Copies the content of the buffer into the target stream. - */ - public void WriteTo(OutputStream stream) { - stream.Write(this.buffer.Slice(0, this.length)); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteTypedArray(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs, @@ -2080,17 +1992,17 @@ public final class RowBuffer { metaBytes = tempOut_metaBytes.get(); this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); checkState(spaceNeeded == metaBytes + numBytes); - this.WriteUInt32(edit.get().valueOffset, 0); - int valueOffset = edit.get().valueOffset + (Integer.SIZE / Byte.SIZE); // Point after the Size + this.WriteUInt32(edit.get().valueOffset(), 0); + int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size newScope.setAndGet(new RowCursor()); - newScope.get().scopeType = scopeType; - newScope.get().scopeTypeArgs = typeArgs.clone(); - newScope.get().start = edit.get().valueOffset; - newScope.get().valueOffset = valueOffset; - newScope.get().metaOffset = valueOffset; - newScope.get().layout = edit.get().layout; + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(typeArgs.clone()); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(valueOffset); + newScope.get().metaOffset(valueOffset); + newScope.get().layout(edit.get().layout()); - this.length += shift; + this.length(this.length() + shift); } public void WriteTypedMap(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs, @@ -2109,17 +2021,17 @@ public final class RowBuffer { metaBytes = tempOut_metaBytes.get(); this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); checkState(spaceNeeded == metaBytes + numBytes); - this.WriteUInt32(edit.get().valueOffset, 0); - int valueOffset = edit.get().valueOffset + (Integer.SIZE / Byte.SIZE); // Point after the Size + this.WriteUInt32(edit.get().valueOffset(), 0); + int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size newScope.setAndGet(new RowCursor()); - newScope.get().scopeType = scopeType; - newScope.get().scopeTypeArgs = typeArgs.clone(); - newScope.get().start = edit.get().valueOffset; - newScope.get().valueOffset = valueOffset; - newScope.get().metaOffset = valueOffset; - newScope.get().layout = edit.get().layout; + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(typeArgs.clone()); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(valueOffset); + newScope.get().metaOffset(valueOffset); + newScope.get().layout(edit.get().layout()); - this.length += shift; + this.length(this.length() + shift); } public void WriteTypedSet(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs, @@ -2138,22 +2050,29 @@ public final class RowBuffer { metaBytes = tempOut_metaBytes.get(); this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); checkState(spaceNeeded == metaBytes + numBytes); - this.WriteUInt32(edit.get().valueOffset, 0); - int valueOffset = edit.get().valueOffset + (Integer.SIZE / Byte.SIZE); // Point after the Size + this.WriteUInt32(edit.get().valueOffset(), 0); + int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size newScope.setAndGet(new RowCursor()); - newScope.get().scopeType = scopeType; - newScope.get().scopeTypeArgs = typeArgs.clone(); - newScope.get().start = edit.get().valueOffset; - newScope.get().valueOffset = valueOffset; - newScope.get().metaOffset = valueOffset; - newScope.get().layout = edit.get().layout; + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(typeArgs.clone()); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(valueOffset); + newScope.get().metaOffset(valueOffset); + newScope.get().layout(edit.get().layout()); - this.length += shift; + this.length(this.length() + shift); + } + + /** + * Copies the content of the buffer into the target stream. + */ + public void WriteTo(OutputStream stream) { + stream.Write(this.buffer.Slice(0, this.length())); } public void WriteTypedTuple(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs, UpdateOptions options, Out newScope) { - int numBytes = this.CountDefaultValue(scopeType, typeArgs.clone()); + int numBytes = this.countDefaultValue(scopeType, typeArgs.clone()); int metaBytes; Out tempOut_metaBytes = new Out(); int spaceNeeded; @@ -2166,25 +2085,90 @@ public final class RowBuffer { spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); - int numWritten = this.WriteDefaultValue(edit.get().valueOffset, scopeType, typeArgs.clone()); + int numWritten = this.WriteDefaultValue(edit.get().valueOffset(), scopeType, typeArgs.clone()); checkState(numBytes == numWritten); checkState(spaceNeeded == metaBytes + numBytes); newScope.setAndGet(new RowCursor()); - newScope.get().scopeType = scopeType; - newScope.get().scopeTypeArgs = typeArgs.clone(); - newScope.get().start = edit.get().valueOffset; - newScope.get().valueOffset = edit.get().valueOffset; - newScope.get().metaOffset = edit.get().valueOffset; - newScope.get().layout = edit.get().layout; - newScope.get().count = typeArgs.getCount(); + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(typeArgs.clone()); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(edit.get().valueOffset()); + newScope.get().metaOffset(edit.get().valueOffset()); + newScope.get().layout(edit.get().layout()); + newScope.get().count(typeArgs.count()); - this.length += shift; + this.length(this.length() + shift); Reference tempReference_this = new Reference(this); RowCursorExtensions.MoveNext(newScope.get().clone(), tempReference_this); this = tempReference_this.get(); } + /** + * Compute the byte offset from the beginning of the row for a given variable column's value. + * + * @param layout The (optional) layout of the current scope. + * @param scopeOffset The 0-based offset to the beginning of the scope's value. + * @param varIndex The 0-based index of the variable column within the variable segment. + * @return The byte offset from the beginning of the row where the variable column's value should be + * located. + */ + public int computeVariableValueOffset(Layout layout, int scopeOffset, int varIndex) { + if (layout == null) { + return scopeOffset; + } + + int index = layout.numFixed() + varIndex; + ReadOnlySpan columns = layout.columns(); + checkState(index <= columns.Length); + int offset = scopeOffset + layout.size(); + for (int i = layout.numFixed(); i < index; i++) { + LayoutColumn col = columns[i]; + if (this.ReadBit(scopeOffset, col.getNullBit().clone())) { + int lengthSizeInBytes; + Out tempOut_lengthSizeInBytes = new Out(); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: ulong valueSizeInBytes = this.Read7BitEncodedUInt(offset, out int lengthSizeInBytes); + long valueSizeInBytes = this.Read7BitEncodedUInt(offset, tempOut_lengthSizeInBytes); + lengthSizeInBytes = tempOut_lengthSizeInBytes.get(); + if (col.getType().getIsVarint()) { + offset += lengthSizeInBytes; + } else { + offset += (int) valueSizeInBytes + lengthSizeInBytes; + } + } + } + + return offset; + } + + /** + * The root header for the row. + */ + public HybridRowHeader header() { + return this.ReadHeader(0); + } + + /** + * The length of row in bytes. + */ /** + * The length of row in bytes. + */ + public int length() { + return this.length; + } + + public void length(int length) { + this.length = length; + } + + /** + * The resolver for UDTs. + */ + public LayoutResolver resolver() { + return this.resolver; + } + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: internal void WriteUInt16(int offset, ushort value) public void WriteUInt16(int offset, short value) { @@ -2242,7 +2226,7 @@ public final class RowBuffer { int sizeLenInBytes = this.WriteBinary(offset, value); checkState(spaceNeeded == numBytes + sizeLenInBytes); - this.length += shift.get(); + this.length(this.length() + shift.get()); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -2258,7 +2242,7 @@ public final class RowBuffer { int sizeLenInBytes = this.WriteBinary(offset, value); checkState(spaceNeeded == numBytes + sizeLenInBytes); - this.length += shift.get(); + this.length(this.length() + shift.get()); } public void WriteVariableInt(int offset, long value, boolean exists, Out shift) { @@ -2271,7 +2255,7 @@ public final class RowBuffer { int sizeLenInBytes = this.Write7BitEncodedInt(offset, value); checkState(sizeLenInBytes == numBytes); checkState(spaceNeeded == numBytes); - this.length += shift.get(); + this.length(this.length() + shift.get()); } public void WriteVariableString(int offset, Utf8Span value, boolean exists, Out shift) { @@ -2283,7 +2267,7 @@ public final class RowBuffer { int sizeLenInBytes = this.WriteString(offset, value); checkState(spaceNeeded == numBytes + sizeLenInBytes); - this.length += shift.get(); + this.length(this.length() + shift.get()); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -2298,7 +2282,7 @@ public final class RowBuffer { int sizeLenInBytes = this.Write7BitEncodedUInt(offset, value); checkState(sizeLenInBytes == numBytes); checkState(spaceNeeded == numBytes); - this.length += shift.get(); + this.length(this.length() + shift.get()); } public RowBuffer clone() { @@ -2307,7 +2291,7 @@ public final class RowBuffer { varCopy.resizer = this.resizer; varCopy.buffer = this.buffer; varCopy.resolver = this.resolver; - varCopy.length = this.length; + varCopy.length(this.length()); return varCopy; } @@ -2343,7 +2327,7 @@ public final class RowBuffer { } if (leftLen == rightLen) { - return this.buffer.Slice(left.valueOffset, leftLen).SequenceCompareTo(this.buffer.Slice(right.valueOffset, rightLen)); + return this.buffer.Slice(left.valueOffset(), leftLen).SequenceCompareTo(this.buffer.Slice(right.valueOffset(), rightLen)); } } @@ -2373,16 +2357,16 @@ public final class RowBuffer { (LayoutTypedTuple)right.cellType : null; checkArgument(leftScopeType != null); checkArgument(rightScopeType != null); - checkArgument(left.cellTypeArgs.getCount() == 2); + checkArgument(left.cellTypeArgs.count() == 2); checkArgument(left.cellTypeArgs.equals(right.cellTypeArgs.clone())); RowCursor leftKey = new RowCursor(); - leftKey.layout = left.layout; - leftKey.scopeType = leftScopeType; - leftKey.scopeTypeArgs = left.cellTypeArgs.clone(); - leftKey.start = left.valueOffset; - leftKey.metaOffset = left.valueOffset; - leftKey.index = 0; + leftKey.layout(left.layout()); + leftKey.scopeType(leftScopeType); + leftKey.scopeTypeArgs(left.cellTypeArgs.clone()); + leftKey.start(left.valueOffset()); + leftKey.metaOffset(left.valueOffset()); + leftKey.index(0); Reference tempReference_leftKey = new Reference(leftKey); @@ -2391,16 +2375,17 @@ public final class RowBuffer { checkState(leftKey.pathOffset == 0); Reference tempReference_leftKey2 = new Reference(leftKey); - int leftKeyLen = this.SparseComputeSize(tempReference_leftKey2) - (leftKey.valueOffset - leftKey.metaOffset); + int leftKeyLen = + this.SparseComputeSize(tempReference_leftKey2) - (leftKey.valueOffset() - leftKey.metaOffset()); leftKey = tempReference_leftKey2.get(); RowCursor rightKey = new RowCursor(); - rightKey.layout = right.layout; - rightKey.scopeType = rightScopeType; - rightKey.scopeTypeArgs = right.cellTypeArgs.clone(); - rightKey.start = right.valueOffset; - rightKey.metaOffset = right.valueOffset; - rightKey.index = 0; + rightKey.layout(right.layout()); + rightKey.scopeType(rightScopeType); + rightKey.scopeTypeArgs(right.cellTypeArgs.clone()); + rightKey.start(right.valueOffset()); + rightKey.metaOffset(right.valueOffset()); + rightKey.index(0); Reference tempReference_rightKey = new Reference(rightKey); @@ -2409,7 +2394,7 @@ public final class RowBuffer { checkState(rightKey.pathOffset == 0); Reference tempReference_rightKey2 = new Reference(rightKey); - int rightKeyLen = this.SparseComputeSize(tempReference_rightKey2) - (rightKey.valueOffset - rightKey.metaOffset); + int rightKeyLen = this.SparseComputeSize(tempReference_rightKey2) - (rightKey.valueOffset() - rightKey.metaOffset()); rightKey = tempReference_rightKey2.get(); return this.CompareFieldValue(leftKey.clone(), leftKeyLen, rightKey.clone(), rightKeyLen); @@ -2426,255 +2411,31 @@ public final class RowBuffer { return RowBuffer.Count7BitEncodedUInt(RowBuffer.RotateSignToLsb(value)); } - /** - * Return the size (in bytes) of the default sparse value for the type. - * - * @param code The type of the default value. - * @param typeArgs - */ - private int CountDefaultValue(LayoutType code, TypeArgumentList typeArgs) { - // JTHTODO: convert to a virtual? - switch (code) { - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutNull _: - case LayoutNull - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutBoolean _: - case LayoutBoolean _: - return 1; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutInt8 _: - case LayoutInt8 - _: - return LayoutType.Int8.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutInt16 _: - case LayoutInt16 - _: - return LayoutType.Int16.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutInt32 _: - case LayoutInt32 - _: - return LayoutType.Int32.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutInt64 _: - case LayoutInt64 - _: - return LayoutType.Int64.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUInt8 _: - case LayoutUInt8 - _: - return LayoutType.UInt8.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUInt16 _: - case LayoutUInt16 - _: - return LayoutType.UInt16.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUInt32 _: - case LayoutUInt32 - _: - return LayoutType.UInt32.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUInt64 _: - case LayoutUInt64 - _: - return LayoutType.UInt64.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutFloat32 _: - case LayoutFloat32 - _: - return LayoutType.Float32.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutFloat64 _: - case LayoutFloat64 - _: - return LayoutType.Float64.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutFloat128 _: - case LayoutFloat128 - _: - return LayoutType.Float128.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutDecimal _: - case LayoutDecimal - _: - return LayoutType.Decimal.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutDateTime _: - case LayoutDateTime - _: - return LayoutType.DateTime.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUnixDateTime _: - case LayoutUnixDateTime - _: - return LayoutType.UnixDateTime.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutGuid _: - case LayoutGuid - _: - return LayoutType.Guid.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutMongoDbObjectId _: - case LayoutMongoDbObjectId - _: - return MongoDbObjectId.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUtf8 _: - case LayoutUtf8 - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutBinary _: - case LayoutBinary _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutVarInt _: - case LayoutVarInt _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutVarUInt _: - case LayoutVarUInt _: - - // Variable length types preceded by their varuint size take 1 byte for a size of 0. - return 1; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutObject _: - case LayoutObject - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutArray _: - case LayoutArray _: - - // Variable length sparse collection scopes take 1 byte for the end-of-scope terminator. - return (LayoutCode.SIZE / Byte.SIZE); - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedArray _: - case LayoutTypedArray - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedSet _: - case LayoutTypedSet _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedMap _: - case LayoutTypedMap _: - - // Variable length typed collection scopes preceded by their scope size take sizeof(uint) for a size of 0. - return (Integer.SIZE / Byte.SIZE); - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTuple _: - case LayoutTuple - _: - - // Fixed arity sparse collections take 1 byte for end-of-scope plus a null for each element. - return (LayoutCode.SIZE / Byte.SIZE) + ((LayoutCode.SIZE / Byte.SIZE) * typeArgs.getCount()); - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedTuple _: - case LayoutTypedTuple - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTagged _: - case LayoutTagged _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTagged2 _: - case LayoutTagged2 _: - - // Fixed arity typed collections take the sum of the default values of each element. The scope size is implied by the arity. - int sum = 0; - for (TypeArgument arg : typeArgs) { - sum += this.CountDefaultValue(arg.getType(), arg.getTypeArgs().clone()); - } - - return sum; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutNullable _: - case LayoutNullable - _: - - // Nullables take the default values of the value plus null. The scope size is implied by the arity. - return 1 + this.CountDefaultValue(typeArgs.get(0).getType(), typeArgs.get(0).getTypeArgs().clone()); - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUDT _: - case LayoutUDT - _: - Layout udt = this.resolver.Resolve(typeArgs.getSchemaId().clone()); - return udt.getSize() + (LayoutCode.SIZE / Byte.SIZE); - - default: - throw new IllegalStateException(lenientFormat("Not Implemented: %s", code)); - return 0; - } - } - private static int CountSparsePath(Reference edit) { - if (!edit.get().writePathToken.getIsNull()) { - return edit.get().writePathToken.Varint.length; + + if (!edit.get().writePathToken().isNull()) { + return edit.get().writePathToken().varint.length; } - Out tempOut_writePathToken = - new Out(); - if (edit.get().layout.getTokenizer().TryFindToken(edit.get().writePath, tempOut_writePathToken)) { - edit.get().argValue.writePathToken = tempOut_writePathToken.get(); - return edit.get().writePathToken.Varint.length; - } else { - edit.get().argValue.writePathToken = tempOut_writePathToken.get(); + Optional token = edit.get().layout().tokenizer().findToken(edit.get().writePath()); + + if (token.isPresent()) { + edit.get().writePathToken(token.get()); + return token.get().varint.length; } - int numBytes = edit.get().writePath.ToUtf8String().Length; - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: int sizeLenInBytes = RowBuffer.Count7BitEncodedUInt((ulong)(edit.layout.Tokenizer.Count + - // numBytes)); - int sizeLenInBytes = - RowBuffer.Count7BitEncodedUInt((long)(edit.get().layout.getTokenizer().getCount() + numBytes)); + int numBytes = edit.get().writePath().toUtf8().length(); + int sizeLenInBytes = RowBuffer.Count7BitEncodedUInt((long) (edit.get().layout().tokenizer().count() + numBytes)); + return sizeLenInBytes + numBytes; } private void Ensure(int size) { - if (this.buffer.Length < size) { + if (this.buffer.length() < size) { this.buffer = this.resizer.Resize(size, this.buffer); } } - /** - * - * . - */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] private void EnsureSparse(ref RowCursor edit, - // LayoutType cellType, TypeArgumentList typeArgs, int numBytes, UpdateOptions options, out int metaBytes, out - // int spaceNeeded, out int shift) - private void EnsureSparse(Reference edit, LayoutType cellType, TypeArgumentList typeArgs, - int numBytes, UpdateOptions options, Out metaBytes, - Out spaceNeeded, Out shift) { - this.EnsureSparse(edit, cellType, typeArgs.clone(), numBytes, RowOptions.forValue(options), metaBytes, - spaceNeeded, shift); - } - /** * Ensure that sufficient space exists in the row buffer to write the current value. * @@ -2695,18 +2456,18 @@ public final class RowBuffer { int numBytes, RowOptions options, Out metaBytes, Out spaceNeeded, Out shift) { - int metaOffset = edit.get().metaOffset; + int metaOffset = edit.get().metaOffset(); int spaceAvailable = 0; // Compute the metadata offsets - if (edit.get().scopeType.HasImplicitTypeCode(edit)) { + if (edit.get().scopeType().HasImplicitTypeCode(edit)) { metaBytes.setAndGet(0); } else { metaBytes.setAndGet(cellType.CountTypeArgument(typeArgs.clone())); } - if (!edit.get().scopeType.IsIndexedScope) { - checkState(edit.get().writePath != null); + if (!edit.get().scopeType().isIndexedScope()) { + checkState(edit.get().writePath() != null); int pathLenInBytes = RowBuffer.CountSparsePath(edit); metaBytes.setAndGet(metaBytes.get() + pathLenInBytes); } @@ -2719,31 +2480,31 @@ public final class RowBuffer { spaceNeeded.setAndGet(options == RowOptions.Delete ? 0 : metaBytes.get() + numBytes); shift.setAndGet(spaceNeeded.get() - spaceAvailable); if (shift.get() > 0) { - this.Ensure(this.length + shift.get()); + this.Ensure(this.length() + shift.get()); } - this.buffer.Slice(metaOffset + spaceAvailable, this.length - (metaOffset + spaceAvailable)).CopyTo(this.buffer.Slice(metaOffset + spaceNeeded.get())); + this.buffer.Slice(metaOffset + spaceAvailable, this.length() - (metaOffset + spaceAvailable)).CopyTo(this.buffer.Slice(metaOffset + spaceNeeded.get())); // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: //#if DEBUG if (shift.get() < 0) { // Fill deleted bits (in debug builds) to detect overflow/alignment errors. - this.buffer.Slice(this.length + shift.get(), -shift.get()).Fill(0xFF); + this.buffer.Slice(this.length() + shift.get(), -shift.get()).Fill(0xFF); } //#endif // Update the stored size (fixed arity scopes don't store the size because it is implied by the type args). - if (edit.get().scopeType.IsSizedScope && !edit.get().scopeType.IsFixedArity) { + if (edit.get().scopeType().isSizedScope() && !edit.get().scopeType().isFixedArity()) { if ((options == RowOptions.Insert) || (options == RowOptions.InsertAt) || ((options == RowOptions.Upsert) && !edit.get().exists)) { // Add one to the current scope count. checkState(!edit.get().exists); - this.IncrementUInt32(edit.get().start, 1); - edit.get().count++; + this.IncrementUInt32(edit.get().start(), 1); + edit.get().count(edit.get().count() + 1); } else if ((options == RowOptions.Delete) && edit.get().exists) { // Subtract one from the current scope count. - checkState(this.ReadUInt32(edit.get().start) > 0); - this.DecrementUInt32(edit.get().start, 1); - edit.get().count--; + checkState(this.ReadUInt32(edit.get().start()) > 0); + this.DecrementUInt32(edit.get().start(), 1); + edit.get().count(edit.get().count() - 1); } } @@ -2758,6 +2519,35 @@ public final class RowBuffer { } } + /** + * + * . + */ + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] private void EnsureSparse(ref RowCursor edit, + // LayoutType cellType, TypeArgumentList typeArgs, int numBytes, UpdateOptions options, out int metaBytes, out + // int spaceNeeded, out int shift) + private void EnsureSparse(Reference edit, LayoutType cellType, TypeArgumentList typeArgs, + int numBytes, UpdateOptions options, Out metaBytes, + Out spaceNeeded, Out shift) { + this.EnsureSparse(edit, cellType, typeArgs.clone(), numBytes, RowOptions.forValue(options), metaBytes, + spaceNeeded, shift); + } + + /** + * Reads in the contents of the RowBuffer from an input stream and initializes the row buffer + * with the associated layout and rowVersion. + * + * @return true if the serialization succeeded. false if the input stream was corrupted. + */ + private boolean InitReadFrom(HybridRowVersion rowVersion) { + HybridRowHeader header = this.ReadHeader(0).clone(); + Layout layout = this.resolver.Resolve(header.getSchemaId().clone()); + checkState(SchemaId.opEquals(header.getSchemaId().clone(), layout.schemaId().clone())); + return (header.getVersion() == rowVersion) && (HybridRowHeader.SIZE + layout.size() <= this.length()); + } + private void EnsureVariable(int offset, boolean isVarint, int numBytes, boolean exists, Out spaceNeeded, Out shift) { int spaceAvailable = 0; @@ -2781,26 +2571,13 @@ public final class RowBuffer { shift.setAndGet(spaceNeeded.get() - spaceAvailable); if (shift.get() > 0) { - this.Ensure(this.length + shift.get()); - this.buffer.Slice(offset + spaceAvailable, this.length - (offset + spaceAvailable)).CopyTo(this.buffer.Slice(offset + spaceNeeded.get())); + this.Ensure(this.length() + shift.get()); + this.buffer.Slice(offset + spaceAvailable, this.length() - (offset + spaceAvailable)).CopyTo(this.buffer.Slice(offset + spaceNeeded.get())); } else if (shift.get() < 0) { - this.buffer.Slice(offset + spaceAvailable, this.length - (offset + spaceAvailable)).CopyTo(this.buffer.Slice(offset + spaceNeeded.get())); + this.buffer.Slice(offset + spaceAvailable, this.length() - (offset + spaceAvailable)).CopyTo(this.buffer.Slice(offset + spaceNeeded.get())); } } - /** - * Reads in the contents of the RowBuffer from an input stream and initializes the row buffer - * with the associated layout and rowVersion. - * - * @return true if the serialization succeeded. false if the input stream was corrupted. - */ - private boolean InitReadFrom(HybridRowVersion rowVersion) { - HybridRowHeader header = this.ReadHeader(0).clone(); - Layout layout = this.resolver.Resolve(header.getSchemaId().clone()); - checkState(SchemaId.opEquals(header.getSchemaId().clone(), layout.schemaId().clone())); - return (header.getVersion() == rowVersion) && (HybridRowHeader.Size + layout.size() <= this.length); - } - /** * Sorts the array structure using the hybrid row binary * collation. @@ -2834,24 +2611,24 @@ public final class RowBuffer { for (int i = 1; i < uniqueIndex.Length; i++) { UniqueIndexItem x = uniqueIndex[i]; - leftEdit.cellType = LayoutType.FromCode(x.Code); - leftEdit.metaOffset = x.MetaOffset; - leftEdit.valueOffset = x.ValueOffset; - int leftBytes = x.Size - (x.ValueOffset - x.MetaOffset); + leftEdit.cellType = LayoutType.FromCode(x.code()); + leftEdit.metaOffset(x.metaOffset()); + leftEdit.valueOffset(x.valueOffset()); + int leftBytes = x.size() - (x.valueOffset() - x.metaOffset()); // Walk backwards searching for the insertion point for the item as position i. int j; for (j = i - 1; j >= 0; j--) { UniqueIndexItem y = uniqueIndex[j]; - rightEdit.cellType = LayoutType.FromCode(y.Code); - rightEdit.metaOffset = y.MetaOffset; - rightEdit.valueOffset = y.ValueOffset; + rightEdit.cellType = LayoutType.FromCode(y.code()); + rightEdit.metaOffset(y.metaOffset()); + rightEdit.valueOffset(y.valueOffset()); int cmp; - if (scope.get().scopeType instanceof LayoutTypedMap) { + if (scope.get().scopeType() instanceof LayoutTypedMap) { cmp = this.CompareKeyValueFieldValue(leftEdit.clone(), rightEdit.clone()); } else { - int rightBytes = y.Size - (y.ValueOffset - y.MetaOffset); + int rightBytes = y.size() - (y.valueOffset() - y.metaOffset()); cmp = this.CompareFieldValue(leftEdit.clone(), leftBytes, rightEdit.clone(), rightBytes); } @@ -2878,7 +2655,7 @@ public final class RowBuffer { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: private ReadOnlySpan ReadBinary(int offset, out int sizeLenInBytes) private ReadOnlySpan ReadBinary(int offset, Out sizeLenInBytes) { - int numBytes = (int)this.Read7BitEncodedUInt(offset, sizeLenInBytes); + int numBytes = (int) this.Read7BitEncodedUInt(offset, sizeLenInBytes); return this.buffer.Slice(offset + sizeLenInBytes.get(), numBytes); } @@ -2909,18 +2686,18 @@ public final class RowBuffer { * . */ private void ReadSparseMetadata(Reference edit) { - if (edit.get().scopeType.HasImplicitTypeCode(edit)) { - edit.get().scopeType.SetImplicitTypeCode(edit); - edit.get().valueOffset = edit.get().metaOffset; + if (edit.get().scopeType().HasImplicitTypeCode(edit)) { + edit.get().scopeType().SetImplicitTypeCode(edit); + edit.get().valueOffset(edit.get().metaOffset()); } else { - edit.get().cellType = this.ReadSparseTypeCode(edit.get().metaOffset); - edit.get().valueOffset = edit.get().metaOffset + (LayoutCode.SIZE / Byte.SIZE); - edit.get().cellTypeArgs = TypeArgumentList.Empty; + edit.get().cellType = this.ReadSparseTypeCode(edit.get().metaOffset()); + edit.get().valueOffset(edit.get().metaOffset() + (LayoutCode.SIZE / Byte.SIZE)); + edit.get().cellTypeArgs = TypeArgumentList.EMPTY; if (edit.get().cellType instanceof LayoutEndScope) { // Reached end of current scope without finding another field. edit.get().pathToken = 0; edit.get().pathOffset = 0; - edit.get().valueOffset = edit.get().metaOffset; + edit.get().valueOffset(edit.get().metaOffset()); return; } @@ -2928,16 +2705,16 @@ public final class RowBuffer { new Reference(this); int sizeLenInBytes; Out tempOut_sizeLenInBytes = new Out(); - edit.get().cellTypeArgs = edit.get().cellType.ReadTypeArgumentList(tempReference_this, - edit.get().valueOffset, tempOut_sizeLenInBytes).clone(); + edit.get().cellTypeArgs = edit.get().cellType.readTypeArgumentList(tempReference_this, + edit.get().valueOffset(), tempOut_sizeLenInBytes).clone(); sizeLenInBytes = tempOut_sizeLenInBytes.get(); this = tempReference_this.get(); - edit.get().valueOffset += sizeLenInBytes; + edit.get().valueOffset(edit.get().valueOffset() + sizeLenInBytes); } Reference tempReference_this2 = new Reference(this); - edit.get().scopeType.ReadSparsePath(tempReference_this2, edit); + edit.get().scopeType().ReadSparsePath(tempReference_this2, edit); this = tempReference_this2.get(); } @@ -2947,31 +2724,31 @@ public final class RowBuffer { private void ReadSparsePrimitiveTypeCode(Reference edit, LayoutType code) { checkState(edit.get().exists); - if (edit.get().scopeType.HasImplicitTypeCode(edit)) { - if (edit.get().scopeType instanceof LayoutNullable) { - checkState(edit.get().scopeTypeArgs.getCount() == 1); - checkState(edit.get().index == 1); - checkState(edit.get().scopeTypeArgs.get(0).getType() == code); - checkState(edit.get().scopeTypeArgs.get(0).getTypeArgs().getCount() == 0); - } else if (edit.get().scopeType.IsFixedArity) { - checkState(edit.get().scopeTypeArgs.getCount() > edit.get().index); - checkState(edit.get().scopeTypeArgs.get(edit.get().index).getType() == code); - checkState(edit.get().scopeTypeArgs.get(edit.get().index).getTypeArgs().getCount() == 0); + if (edit.get().scopeType().HasImplicitTypeCode(edit)) { + if (edit.get().scopeType() instanceof LayoutNullable) { + checkState(edit.get().scopeTypeArgs().count() == 1); + checkState(edit.get().index() == 1); + checkState(edit.get().scopeTypeArgs().get(0).type() == code); + checkState(edit.get().scopeTypeArgs().get(0).typeArgs().count() == 0); + } else if (edit.get().scopeType().isFixedArity()) { + checkState(edit.get().scopeTypeArgs().count() > edit.get().index()); + checkState(edit.get().scopeTypeArgs().get(edit.get().index()).type() == code); + checkState(edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().count() == 0); } else { - checkState(edit.get().scopeTypeArgs.getCount() == 1); - checkState(edit.get().scopeTypeArgs.get(0).getType() == code); - checkState(edit.get().scopeTypeArgs.get(0).getTypeArgs().getCount() == 0); + checkState(edit.get().scopeTypeArgs().count() == 1); + checkState(edit.get().scopeTypeArgs().get(0).type() == code); + checkState(edit.get().scopeTypeArgs().get(0).typeArgs().count() == 0); } } else { if (code == LayoutType.Boolean) { - code = this.ReadSparseTypeCode(edit.get().metaOffset); + code = this.ReadSparseTypeCode(edit.get().metaOffset()); checkState(code == LayoutType.Boolean || code == LayoutType.BooleanFalse); } else { - checkState(this.ReadSparseTypeCode(edit.get().metaOffset) == code); + checkState(this.ReadSparseTypeCode(edit.get().metaOffset()) == code); } } - if (edit.get().scopeType.IsIndexedScope) { + if (edit.get().scopeType().isIndexedScope()) { checkState(edit.get().pathOffset == 0); checkState(edit.get().pathToken == 0); } else { @@ -2979,8 +2756,8 @@ public final class RowBuffer { Out tempOut__ = new Out(); int pathOffset; Out tempOut_pathOffset = new Out(); - int token = this.ReadSparsePathLen(edit.get().layout, - edit.get().metaOffset + (LayoutCode.SIZE / Byte.SIZE), tempOut__, tempOut_pathOffset); + int token = this.ReadSparsePathLen(edit.get().layout(), + edit.get().metaOffset() + (LayoutCode.SIZE / Byte.SIZE), tempOut__, tempOut_pathOffset); pathOffset = tempOut_pathOffset.get(); _ = tempOut__.get(); checkState(edit.get().pathOffset == pathOffset); @@ -2989,7 +2766,7 @@ public final class RowBuffer { } private Utf8Span ReadString(int offset, Out sizeLenInBytes) { - int numBytes = (int)this.Read7BitEncodedUInt(offset, sizeLenInBytes); + int numBytes = (int) this.Read7BitEncodedUInt(offset, sizeLenInBytes); return Utf8Span.UnsafeFromUtf8BytesNoValidation(this.buffer.Slice(offset + sizeLenInBytes.get(), numBytes)); } @@ -3003,11 +2780,33 @@ public final class RowBuffer { while (this.SparseIteratorMoveNext(edit)) { } - if (!edit.get().scopeType.IsSizedScope) { - edit.get().metaOffset += (LayoutCode.SIZE / Byte.SIZE); // Move past the end of scope marker. + if (!edit.get().scopeType().isSizedScope()) { + edit.get().metaOffset(edit.get().metaOffset() + (LayoutCode.SIZE / Byte.SIZE)); // Move past the end of + // scope marker. } - return edit.get().metaOffset; + return edit.get().metaOffset(); + } + + /** + * Compute the size of a sparse field. + * + * @param edit The edit structure describing the field to measure. + * @return The length (in bytes) of the encoded field including the metadata and the value. + */ + private int SparseComputeSize(Reference edit) { + if (!(edit.get().cellType instanceof LayoutScope)) { + return this.SparseComputePrimitiveSize(edit.get().cellType, edit.get().metaOffset(), + edit.get().valueOffset()); + } + + // Compute offset to end of value for current value. + RowCursor newScope = this.SparseIteratorReadScope(edit, true).clone(); + Reference tempReference_newScope = + new Reference(newScope); + int tempVar = this.SkipScope(tempReference_newScope) - edit.get().metaOffset(); + newScope = tempReference_newScope.get(); + return tempVar; } /** @@ -3024,65 +2823,65 @@ public final class RowBuffer { int metaBytes = valueOffset - metaOffset; LayoutCode code = cellType.LayoutCode; switch (code) { - case Null: + case NULL: checkState(LayoutType.Null.Size == 0); return metaBytes; - case Boolean: - case BooleanFalse: + case BOOLEAN: + case BOOLEAN_FALSE: checkState(LayoutType.Boolean.Size == 0); return metaBytes; - case Int8: + case INT_8: return metaBytes + LayoutType.Int8.Size; - case Int16: + case INT_16: return metaBytes + LayoutType.Int16.Size; - case Int32: + case INT_32: return metaBytes + LayoutType.Int32.Size; - case Int64: + case INT_64: return metaBytes + LayoutType.Int64.Size; - case UInt8: + case UINT_8: return metaBytes + LayoutType.UInt8.Size; - case UInt16: + case UINT_16: return metaBytes + LayoutType.UInt16.Size; - case UInt32: + case UINT_32: return metaBytes + LayoutType.UInt32.Size; - case UInt64: + case UINT_64: return metaBytes + LayoutType.UInt64.Size; - case Float32: + case FLOAT_32: return metaBytes + LayoutType.Float32.Size; - case Float64: + case FLOAT_64: return metaBytes + LayoutType.Float64.Size; - case Float128: + case FLOAT_128: return metaBytes + LayoutType.Float128.Size; - case Decimal: + case DECIMAL: return metaBytes + LayoutType.Decimal.Size; - case DateTime: + case DATE_TIME: return metaBytes + LayoutType.DateTime.Size; - case UnixDateTime: + case UNIX_DATE_TIME: return metaBytes + LayoutType.UnixDateTime.Size; - case Guid: + case GUID: return metaBytes + LayoutType.Guid.Size; - case MongoDbObjectId: + case MONGODB_OBJECT_ID: return metaBytes + MongoDbObjectId.Size; - case Utf8: - case Binary: + case UTF_8: + case BINARY: // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: ///#pragma warning disable SA1137 // Elements should have the same indentation { @@ -3093,8 +2892,8 @@ public final class RowBuffer { return metaBytes + sizeLenInBytes + numBytes; } - case VarInt: - case VarUInt: { + case VAR_INT: + case VAR_UINT: { int sizeLenInBytes; Out tempOut_sizeLenInBytes2 = new Out(); this.Read7BitEncodedUInt(metaOffset + metaBytes, tempOut_sizeLenInBytes2); @@ -3110,33 +2909,12 @@ public final class RowBuffer { } } - /** - * Compute the size of a sparse field. - * - * @param edit The edit structure describing the field to measure. - * @return The length (in bytes) of the encoded field including the metadata and the value. - */ - private int SparseComputeSize(Reference edit) { - if (!(edit.get().cellType instanceof LayoutScope)) { - return this.SparseComputePrimitiveSize(edit.get().cellType, edit.get().metaOffset, - edit.get().valueOffset); - } - - // Compute offset to end of value for current value. - RowCursor newScope = this.SparseIteratorReadScope(edit, true).clone(); - Reference tempReference_newScope = - new Reference(newScope); - int tempVar = this.SkipScope(tempReference_newScope) - edit.get().metaOffset; - newScope = tempReference_newScope.get(); - return tempVar; - } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: private int WriteBinary(int offset, ReadOnlySpan value) private int WriteBinary(int offset, ReadOnlySpan value) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length); - int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (long)value.Length); + int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (long) value.Length); value.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); return sizeLenInBytes; } @@ -3146,7 +2924,7 @@ public final class RowBuffer { private int WriteBinary(int offset, ReadOnlySequence value) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length); - int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (long)value.Length); + int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (long) value.Length); value.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); return sizeLenInBytes; } @@ -3165,7 +2943,7 @@ public final class RowBuffer { //ORIGINAL LINE: case LayoutBoolean _: case LayoutBoolean _: - this.WriteSparseTypeCode(offset, LayoutCode.BooleanFalse); + this.WriteSparseTypeCode(offset, LayoutCode.BOOLEAN_FALSE); return 1; // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: @@ -3306,7 +3084,7 @@ public final class RowBuffer { case LayoutArray _: // Variable length sparse collection scopes take 1 byte for the end-of-scope terminator. - this.WriteSparseTypeCode(offset, LayoutCode.EndScope); + this.WriteSparseTypeCode(offset, LayoutCode.END_SCOPE); return (LayoutCode.SIZE / Byte.SIZE); // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: @@ -3330,12 +3108,12 @@ public final class RowBuffer { _: // Fixed arity sparse collections take 1 byte for end-of-scope plus a null for each element. - for (int i = 0; i < typeArgs.getCount(); i++) { - this.WriteSparseTypeCode(offset, LayoutCode.Null); + for (int i = 0; i < typeArgs.count(); i++) { + this.WriteSparseTypeCode(offset, LayoutCode.NULL); } - this.WriteSparseTypeCode(offset, LayoutCode.EndScope); - return (LayoutCode.SIZE / Byte.SIZE) + ((LayoutCode.SIZE / Byte.SIZE) * typeArgs.getCount()); + this.WriteSparseTypeCode(offset, LayoutCode.END_SCOPE); + return (LayoutCode.SIZE / Byte.SIZE) + ((LayoutCode.SIZE / Byte.SIZE) * typeArgs.count()); // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: //ORIGINAL LINE: case LayoutTypedTuple _: @@ -3351,7 +3129,7 @@ public final class RowBuffer { // Fixed arity typed collections take the sum of the default values of each element. The scope size is implied by the arity. int sum = 0; for (TypeArgument arg : typeArgs) { - sum += this.WriteDefaultValue(offset + sum, arg.getType(), arg.getTypeArgs().clone()); + sum += this.WriteDefaultValue(offset + sum, arg.type(), arg.typeArgs().clone()); } return sum; @@ -3363,7 +3141,7 @@ public final class RowBuffer { // Nullables take the default values of the value plus null. The scope size is implied by the arity. this.WriteInt8(offset, (byte)0); - return 1 + this.WriteDefaultValue(offset + 1, typeArgs.get(0).getType(), typeArgs.get(0).getTypeArgs().clone()); + return 1 + this.WriteDefaultValue(offset + 1, typeArgs.get(0).type(), typeArgs.get(0).typeArgs().clone()); // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: //ORIGINAL LINE: case LayoutUDT _: @@ -3371,11 +3149,11 @@ public final class RowBuffer { _: // Clear all presence bits. - Layout udt = this.resolver.Resolve(typeArgs.getSchemaId().clone()); + Layout udt = this.resolver.Resolve(typeArgs.schemaId().clone()); this.buffer.Slice(offset, udt.getSize()).Fill(0); // Write scope terminator. - this.WriteSparseTypeCode(offset + udt.getSize(), LayoutCode.EndScope); + this.WriteSparseTypeCode(offset + udt.getSize(), LayoutCode.END_SCOPE); return udt.getSize() + (LayoutCode.SIZE / Byte.SIZE); default: @@ -3386,22 +3164,22 @@ public final class RowBuffer { private void WriteSparseMetadata(Reference edit, LayoutType cellType, TypeArgumentList typeArgs, int metaBytes) { - int metaOffset = edit.get().metaOffset; - if (!edit.get().scopeType.HasImplicitTypeCode(edit)) { + int metaOffset = edit.get().metaOffset(); + if (!edit.get().scopeType().HasImplicitTypeCode(edit)) { Reference tempReference_this = new Reference(this); - metaOffset += cellType.WriteTypeArgument(tempReference_this, metaOffset, typeArgs.clone()); + metaOffset += cellType.writeTypeArgument(tempReference_this, metaOffset, typeArgs.clone()); this = tempReference_this.get(); } this.WriteSparsePath(edit, metaOffset); - edit.get().valueOffset = edit.get().metaOffset + metaBytes; - checkState(edit.get().valueOffset == edit.get().metaOffset + metaBytes); + edit.get().valueOffset(edit.get().metaOffset() + metaBytes); + checkState(edit.get().valueOffset() == edit.get().metaOffset() + metaBytes); } private void WriteSparsePath(Reference edit, int offset) { // Some scopes don't encode paths, therefore the cost is always zero. - if (edit.get().scopeType.IsIndexedScope) { + if (edit.get().scopeType().isIndexedScope()) { edit.get().pathToken = 0; edit.get().pathOffset = 0; return; @@ -3410,16 +3188,16 @@ public final class RowBuffer { StringToken _; Out tempOut__ = new Out(); - checkState(!edit.get().layout.getTokenizer().TryFindToken(edit.get().writePath, tempOut__) || !edit.get().writePathToken.getIsNull()); + checkState(!edit.get().layout().getTokenizer().TryFindToken(edit.get().writePath(), tempOut__) || !edit.get().writePathToken().isNull()); _ = tempOut__.get(); - if (!edit.get().writePathToken.getIsNull()) { - edit.get().writePathToken.Varint.CopyTo(this.buffer.Slice(offset)); + if (!edit.get().writePathToken().isNull()) { + edit.get().writePathToken().varint.CopyTo(this.buffer.Slice(offset)); edit.get().pathToken = edit.get().intValue().writePathToken.Id; edit.get().pathOffset = offset; } else { // TODO: It would be better if we could avoid allocating here when the path is UTF16. - Utf8Span span = edit.get().writePath.ToUtf8String(); - edit.get().pathToken = edit.get().layout.getTokenizer().getCount() + span.Length; + Utf8Span span = edit.get().writePath().ToUtf8String(); + edit.get().pathToken = edit.get().layout().getTokenizer().getCount() + span.Length; //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)edit.pathToken); int sizeLenInBytes = this.Write7BitEncodedUInt(offset, edit.get().longValue().pathToken); @@ -3428,6 +3206,102 @@ public final class RowBuffer { } } + /** + * Return the size (in bytes) of the default sparse value for the type. + * + * @param code The type of the default value. + * @param typeArgs + */ + private int countDefaultValue(LayoutType code, TypeArgumentList typeArgs) { + + // TODO: JTH: convert to a virtual? + + switch (code) { + if (code instanceof LayoutNull || code instanceof LayoutBoolean) { + return 1; + } + if (code instanceof LayoutInt8) { + return LayoutType.Int8.Size; + } + if (code instanceof LayoutInt16) { + return LayoutType.Int16.Size; + } + if (code instanceof LayoutInt32) { + return LayoutType.Int32.Size; + } + if (code instanceof LayoutInt64) { + return LayoutType.Int64.Size; + } + if (code instanceof LayoutUInt8) { + return LayoutType.UInt8.Size; + } + if (code instanceof LayoutUInt16) { + return LayoutType.UInt16.Size; + } + if (code instanceof LayoutUInt32) { + return LayoutType.UInt32.Size; + } + if (code instanceof LayoutUInt64) { + return LayoutType.UInt64.Size; + } + if (code instanceof LayoutFloat32) { + return LayoutType.Float32.Size; + } + if (code instanceof LayoutFloat64) { + return LayoutType.Float64.Size; + } + if (code instanceof LayoutFloat128) { + return LayoutType.Float128.Size; + } + if (code instanceof LayoutDecimal) { + return LayoutType.Decimal.Size; + } + if (code instanceof LayoutDateTime) { + return LayoutType.DateTime.Size; + if (code instanceof LayoutUnixDateTime) { + return LayoutType.UnixDateTime.Size; + if (code instanceof LayoutGuid) { + return LayoutType.Guid.Size; + if (code instanceof LayoutMongoDbObjectId) { + // return MongoDbObjectId.Size; + throw new UnsupportedOperationException(); + } + if (code instanceof LayoutUtf8 || code instanceof LayoutBinary || code instanceof LayoutVarInt || code instanceof LayoutVarUInt) { + // Variable length types preceded by their varuint size take 1 byte for a size of 0. + return 1; + } + if (code instanceof LayoutObject || code instanceof LayoutArray) { + // Variable length sparse collection scopes take 1 byte for the end-of-scope terminator. + return (LayoutCode.SIZE / Byte.SIZE); + } + if (code instanceof LayoutTypedArray || code instanceof LayoutTypedSet || code instanceof LayoutTypedMap) { + // Variable length typed collection scopes preceded by their scope size take sizeof(uint) for a size of 0. + return (Integer.SIZE / Byte.SIZE); + } + if (code instanceof LayoutTuple) { + // Fixed arity sparse collections take 1 byte for end-of-scope plus a null for each element. + return (LayoutCode.SIZE / Byte.SIZE) + ((LayoutCode.SIZE / Byte.SIZE) * typeArgs.count()); + } + if (code instanceof LayoutTypedTuple || code instanceof LayoutTagged || code instanceof LayoutTagged2) { + // Fixed arity typed collections take the sum of the default values of each element. The scope size is + // implied by the arity. + int sum = 0; + for (TypeArgument arg : typeArgs) { + sum += this.countDefaultValue(arg.type(), arg.typeArgs().clone()); + } + return sum; + } + if (code instanceof LayoutNullable) { + // Nullables take the default values of the value plus null. The scope size is implied by the arity. + return 1 + this.countDefaultValue(typeArgs.get(0).type(), typeArgs.get(0).typeArgs()); + } + if (code instanceof LayoutUDT) { + Layout udt = this.resolver.Resolve(typeArgs.schemaId()); + return udt.getSize() + (LayoutCode.SIZE / Byte.SIZE); + } + throw new IllegalStateException(lenientFormat("Not Implemented: %s", code)); + } + private int WriteString(int offset, Utf8Span value) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length); @@ -3437,48 +3311,64 @@ public final class RowBuffer { } /** - * {@link UniqueIndexItem} represents a single item within a set/map scope that needs - * to be indexed. + * Represents a single item within a set/map scope that needs to be indexed *

- *

- * This structure is used when rebuilding a set/map index during row streaming via - * {@link IO.RowWriter}. - * - * Each item encodes its offsets and length within the row. + * This structure is used when rebuilding a set/map index during row streaming via {@link RowWriter}.Each item + * encodes its offsets and length within the row. */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [DebuggerDisplay("{MetaOffset}/{ValueOffset}")] private struct UniqueIndexItem - //C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ from the original: - //ORIGINAL LINE: [DebuggerDisplay("{MetaOffset}/{ValueOffset}")] private struct UniqueIndexItem static final class UniqueIndexItem { + + private LayoutCode Code = LayoutCode.values()[0]; + private int MetaOffset; + private int Size; + private int ValueOffset; + /** * The layout code of the value. */ - public LayoutCode Code = LayoutCode.values()[0]; + public LayoutCode code() { + return Code; + } + + public UniqueIndexItem code(LayoutCode code) { + Code = code; + return this; + } /** - * If existing, the offset to the metadata of the existing field, otherwise the location to - * insert a new field. + * If existing, the offset to the metadata of the existing field, otherwise the location to insert a new field */ - public int MetaOffset; + public int metaOffset() { + return MetaOffset; + } + + public UniqueIndexItem metaOffset(int metaOffset) { + MetaOffset = metaOffset; + return this; + } + /** - * Size of the target element. + * Size of the target element */ - public int Size; + public int size() { + return Size; + } + + public UniqueIndexItem size(int size) { + Size = size; + return this; + } + /** - * If existing, the offset to the value of the existing field, otherwise undefined. + * If existing, the offset to the value of the existing field, otherwise undefined */ - public int ValueOffset; + public int valueOffset() { + return ValueOffset; + } - public UniqueIndexItem clone() { - UniqueIndexItem varCopy = new UniqueIndexItem(); - - varCopy.Code = this.Code; - varCopy.MetaOffset = this.MetaOffset; - varCopy.ValueOffset = this.ValueOffset; - varCopy.Size = this.Size; - - return varCopy; + public UniqueIndexItem valueOffset(int valueOffset) { + ValueOffset = valueOffset; + return this; } } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java index 99054af..0cce4e6 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java @@ -4,27 +4,21 @@ package com.azure.data.cosmos.serialization.hybridrow; -// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: -///#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter - -// ReSharper disable InconsistentNaming - import com.azure.data.cosmos.core.Reference; +import com.azure.data.cosmos.core.UtfAnyString; import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutScope; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTuple; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType; import com.azure.data.cosmos.serialization.hybridrow.layouts.StringToken; import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument; import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList; -// ReSharper disable UseNameofExpression -// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: -//ORIGINAL LINE: [DebuggerDisplay("{ToString()}")] public struct RowCursor -//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ -// from the original: -//ORIGINAL LINE: [DebuggerDisplay("{ToString()}")] public struct RowCursor +import static com.google.common.base.Strings.lenientFormat; + public final class RowCursor { + /** * If existing, the layout code of the existing field, otherwise undefined. */ @@ -33,10 +27,6 @@ public final class RowCursor { * For types with generic parameters (e.g. {@link LayoutTuple}, the type parameters. */ public TypeArgumentList cellTypeArgs = new TypeArgumentList(); - /** - * For sized scopes (e.g. Typed Array), the number of elements. - */ - public int count; /** * If true, this scope is an unique index scope whose index will be built after its items are written. */ @@ -50,24 +40,6 @@ public final class RowCursor { * True if an existing field matching the search criteria was found. */ public boolean exists; - /** - * If true, this scope's nested fields cannot be updated individually. - * The entire scope can still be replaced. - */ - public boolean immutable; - /** - * For indexed scopes (e.g. Array), the 0-based index into the scope of the sparse field. - */ - public int index; - /** - * The layout describing the contents of the scope, or null if the scope is unschematized. - */ - public Layout layout; - /** - * If existing, the offset to the metadata of the existing field, otherwise the location to - * insert a new field. - */ - public int metaOffset; /** * If existing, the offset scope relative path for reading. */ @@ -76,60 +48,60 @@ public final class RowCursor { * If existing, the layout string token of scope relative path for reading. */ public int pathToken; - /** - * The kind of scope within which this edit was prepared. - */ - public LayoutScope scopeType; - /** - * The type parameters of the scope within which this edit was prepared. - */ - public TypeArgumentList scopeTypeArgs = new TypeArgumentList(); - /** - * The 0-based byte offset from the beginning of the row where the first sparse field within - * the scope begins. - */ - public int start; - /** - * If existing, the offset to the value of the existing field, otherwise undefined. - */ - public int valueOffset; - /** - * If existing, the scope relative path for writing. - */ - public UtfAnyString writePath; - /** - * If WritePath is tokenized, then its token. - */ - public StringToken writePathToken = new StringToken(); + private int count; + private boolean immutable; + private int index; + private Layout layout; + private int metaOffset; + private LayoutScope scopeType; + private TypeArgumentList scopeTypeArgs = new TypeArgumentList(); + private int start; + private int valueOffset; + private UtfAnyString writePath; + private StringToken writePathToken = new StringToken(); public static RowCursor Create(Reference row) { - SchemaId schemaId = row.get().ReadSchemaId(1).clone(); - Layout layout = row.get().getResolver().Resolve(schemaId.clone()); - int sparseSegmentOffset = row.get().ComputeVariableValueOffset(layout, HybridRowHeader.Size, + + final SchemaId schemaId = row.get().ReadSchemaId(1); + final Layout layout = row.get().resolver().Resolve(schemaId); + final int sparseSegmentOffset = row.get().computeVariableValueOffset(layout, HybridRowHeader.SIZE, layout.numVariable()); - RowCursor tempVar = new RowCursor(); - tempVar.layout = layout; - tempVar.scopeType = LayoutType.UDT; - tempVar.scopeTypeArgs = new TypeArgumentList(schemaId.clone()); - tempVar.start = HybridRowHeader.Size; - tempVar.metaOffset = sparseSegmentOffset; - tempVar.valueOffset = sparseSegmentOffset; - return tempVar.clone(); + + final RowCursor cursor = new RowCursor() + .layout(layout) + .scopeType(LayoutType.UDT) + .scopeTypeArgs(new TypeArgumentList(schemaId)) + .start(HybridRowHeader.SIZE) + .metaOffset(sparseSegmentOffset) + .valueOffset(sparseSegmentOffset); + + return cursor; } - // TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter: - // public static ref RowCursor Create(ref RowBuffer row, out RowCursor cursor) - // { - // SchemaId schemaId = row.ReadSchemaId(1); - // Layout layout = row.Resolver.Resolve(schemaId); - // int sparseSegmentOffset = row.ComputeVariableValueOffset(layout, HybridRowHeader.Size, layout - // .NumVariable); - // cursor = new RowCursor { layout = layout, scopeType = LayoutType.UDT, scopeTypeArgs = new - // TypeArgumentList(schemaId), start = HybridRowHeader.Size, metaOffset = sparseSegmentOffset, - // valueOffset = sparseSegmentOffset}; - // - // return ref cursor; - // } + public static RowCursor Create(RowBuffer row) { + + final SchemaId schemaId = row.ReadSchemaId(1); + final Layout layout = row.Resolver.Resolve(schemaId); + final int sparseSegmentOffset = row.computeVariableValueOffset(layout, HybridRowHeader.Size, + layout.NumVariable); + + return new RowCursor() + .layout(layout) + .scopeType(LayoutType.UDT) + .scopeTypeArgs(new TypeArgumentList(schemaId, HybridRowHeader.SIZE, sparseSegmentOffset, sparseSegmentOffset); + } + + /** + * For sized scopes (e.g. Typed Array), the number of elements. + */ + public int count() { + return count; + } + + public RowCursor count(int count) { + this.count = count; + return this; + } // TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter: // public static ref RowCursor CreateForAppend(ref RowBuffer row, out RowCursor cursor) @@ -143,94 +115,157 @@ public final class RowCursor { // return ref cursor; // } - public RowCursor clone() { - RowCursor varCopy = new RowCursor(); + /** + * If {@code true}, this scope's nested fields cannot be updated individually + *

+ * The entire scope can still be replaced. + */ + public boolean immutable() { + return immutable; + } - varCopy.layout = this.layout; - varCopy.scopeType = this.scopeType; - varCopy.scopeTypeArgs = this.scopeTypeArgs.clone(); - varCopy.immutable = this.immutable; - varCopy.deferUniqueIndex = this.deferUniqueIndex; - varCopy.start = this.start; - varCopy.exists = this.exists; - varCopy.writePath = this.writePath; - varCopy.writePathToken = this.writePathToken.clone(); - varCopy.pathOffset = this.pathOffset; - varCopy.pathToken = this.pathToken; - varCopy.metaOffset = this.metaOffset; - varCopy.cellType = this.cellType; - varCopy.valueOffset = this.valueOffset; - varCopy.endOffset = this.endOffset; - varCopy.count = this.count; - varCopy.index = this.index; - varCopy.cellTypeArgs = this.cellTypeArgs.clone(); + public RowCursor immutable(boolean immutable) { + this.immutable = immutable; + return this; + } - return varCopy; + /** + * For indexed scopes (e.g. an Array scope), the zero-based index into the scope of the sparse field + */ + public int index() { + return index; + } + + public RowCursor index(int index) { + this.index = index; + return this; + } + + /** + * The layout describing the contents of the scope, or {@code null} if the scope is unschematized. + */ + public Layout layout() { + return layout; + } + + public RowCursor layout(Layout layout) { + this.layout = layout; + return this; + } + + /** + * If existing, the offset to the metadata of the existing field, otherwise the location to + * insert a new field. + */ + public int metaOffset() { + return metaOffset; + } + + public RowCursor metaOffset(int metaOffset) { + this.metaOffset = metaOffset; + return this; + } + + /** + * The kind of scope within which this edit was prepared + */ + public LayoutScope scopeType() { + return scopeType; + } + + public RowCursor scopeType(LayoutScope scopeType) { + this.scopeType = scopeType; + return this; + } + + /** + * The type parameters of the scope within which this edit was prepared + */ + public TypeArgumentList scopeTypeArgs() { + return scopeTypeArgs; + } + + public RowCursor scopeTypeArgs(TypeArgumentList scopeTypeArgs) { + this.scopeTypeArgs = scopeTypeArgs; + return this; + } + + /** + * The 0-based byte offset from the beginning of the row where the first sparse field within + * the scope begins. + */ + public int start() { + return start; + } + + public RowCursor start(int start) { + this.start = start; + return this; } @Override public String toString() { + try { - if (this.scopeType == null) { + + if (this.scopeType() == null) { return ""; } - TypeArgument scopeTypeArg = (this.scopeType == null) || (this.scopeType instanceof LayoutEndScope) ? - default: - new TypeArgument(this.scopeType, this.scopeTypeArgs.clone()); + TypeArgument scopeTypeArg = (this.scopeType() instanceof LayoutEndScope) + ? new TypeArgument() + : new TypeArgument(this.scopeType(), this.scopeTypeArgs().clone()); - TypeArgument typeArg = (this.cellType == null) || (this.cellType instanceof LayoutEndScope) ? - default: - new TypeArgument(this.cellType, this.cellTypeArgs.clone()); + TypeArgument typeArg = (this.cellType == null) || (this.cellType instanceof LayoutEndScope) + ? new TypeArgument() + : new TypeArgument(this.cellType, this.cellTypeArgs.clone()); - String pathOrIndex = !this.writePath.IsNull ? this.writePath.toString() : String.valueOf(this.index); - return String.format("%1$s[%2$s] : %3$s@%4$s/%5$s", scopeTypeArg.clone(), pathOrIndex, - typeArg.clone(), this.metaOffset, this.valueOffset) + (this.immutable ? " immutable" : ""); - } catch (java.lang.Exception e) { + String pathOrIndex = this.writePath().isNull() ? String.valueOf(this.index()) : this.writePath().toString(); + + return lenientFormat("%s[%s] : %s@%s/%s%s", + scopeTypeArg.clone(), + pathOrIndex, + typeArg.clone(), + this.metaOffset(), + this.valueOffset(), + this.immutable() ? " immutable" : ""); + + } catch (Exception ignored) { return ""; } } /** - * If true, this scope's nested fields cannot be updated individually. - * The entire scope can still be replaced. + * If existing, the offset to the value of the existing field, otherwise undefined. */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public bool Immutable - boolean getImmutable() + public int valueOffset() { + return valueOffset; + } + + public RowCursor valueOffset(int valueOffset) { + this.valueOffset = valueOffset; + return this; + } /** - * For indexed scopes (e.g. Array), the 0-based index into the scope of the next insertion. + * If existing, the scope relative path for writing. */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public int Index - int getIndex() + public UtfAnyString writePath() { + return writePath; + } + + public void writePath(UtfAnyString writePath) { + this.writePath = writePath; + } /** - * The layout describing the contents of the scope, or null if the scope is unschematized. + * If WritePath is tokenized, then its token. */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Layout Layout - Layout getLayout() + public StringToken writePathToken() { + return writePathToken; + } - /** - * The kind of scope. - */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public LayoutType ScopeType - LayoutType getScopeType() - - /** - * For types with generic parameters (e.g. {@link LayoutTuple}, the type parameters. - */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public TypeArgumentList ScopeTypeArgs - TypeArgumentList getScopeTypeArgs() - - /** - * The full logical type. - */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public TypeArgument TypeArg - TypeArgument getTypeArg() + public void writePathToken(StringToken writePathToken) { + this.writePathToken = writePathToken; + } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursorExtensions.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursorExtensions.java index d31ae66..4739d5c 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursorExtensions.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursorExtensions.java @@ -79,14 +79,14 @@ public final class RowCursorExtensions { // return ref edit; // } public static boolean MoveNext(Reference edit, Reference row) { - edit.get().writePath = null; - edit.get().writePathToken = null; + edit.get().writePath(null); + edit.get().writePathToken(null); return row.get().SparseIteratorMoveNext(edit); } public static boolean MoveNext(Reference edit, Reference row, Reference childScope) { - if (childScope.get().scopeType != null) { + if (childScope.get().scopeType() != null) { RowCursorExtensions.Skip(edit.get().clone(), row, childScope); } @@ -94,10 +94,10 @@ public final class RowCursorExtensions { } public static boolean MoveTo(Reference edit, Reference row, int index) { - checkState(edit.get().index <= index); - edit.get().writePath = null; - edit.get().writePathToken = null; - while (edit.get().index < index) { + checkState(edit.get().index() <= index); + edit.get().writePath(null); + edit.get().writePathToken(null); + while (edit.get().index() < index) { if (!row.get().SparseIteratorMoveNext(edit)) { return false; } @@ -108,16 +108,16 @@ public final class RowCursorExtensions { public static void Skip(Reference edit, Reference row, Reference childScope) { - checkArgument(childScope.get().start == edit.get().valueOffset); + checkArgument(childScope.get().start() == edit.get().valueOffset()); if (!(childScope.get().cellType instanceof LayoutEndScope)) { while (row.get().SparseIteratorMoveNext(childScope)) { } } - if (childScope.get().scopeType.IsSizedScope) { - edit.get().endOffset = childScope.get().metaOffset; + if (childScope.get().scopeType().isSizedScope()) { + edit.get().endOffset = childScope.get().metaOffset(); } else { - edit.get().endOffset = childScope.get().metaOffset + (LayoutCode.SIZE / Byte.SIZE); // Move past the end of scope marker. + edit.get().endOffset = childScope.get().metaOffset() + (LayoutCode.SIZE / Byte.SIZE); // Move past the end of scope marker. } // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java index d515442..9a62058 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java @@ -4,124 +4,114 @@ package com.azure.data.cosmos.serialization.hybridrow; -import Newtonsoft.Json.*; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.exc.MismatchedInputException; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import static com.google.common.base.Preconditions.checkArgument; +import java.io.IOException; + +import static com.google.common.base.Strings.lenientFormat; /** - * The unique identifier for a schema. + * The unique identifier for a schema * Identifiers must be unique within the scope of the database in which they are used. */ -// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: -//ORIGINAL LINE: [JsonConverter(typeof(SchemaIdConverter))][DebuggerDisplay("{" + nameof(SchemaId.Id) + "}") -// ][StructLayout(LayoutKind.Sequential, Pack = 1)] public readonly struct SchemaId : IEquatable -//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ -// from the original: -//ORIGINAL LINE: [JsonConverter(typeof(SchemaIdConverter))][DebuggerDisplay("{" + nameof(SchemaId.Id) + "}") -// ][StructLayout(LayoutKind.Sequential, Pack = 1)] public readonly struct SchemaId : IEquatable -//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct: -public final class SchemaId implements IEquatable { - public static final SchemaId Invalid = null; - public static final int Size = (Integer.SIZE / Byte.SIZE); - /** - * The underlying identifier. - */ - private int Id; +@JsonDeserialize(using = SchemaId.JsonDeserializer.class) +@JsonSerialize(using = SchemaId.JsonSerializer.class) +public final class SchemaId { + + public static final SchemaId INVALID = null; + public static final SchemaId NONE = new SchemaId(); + public static final int SIZE = (Integer.SIZE / Byte.SIZE); + private static long MAX_VALUE = 0x00000000FFFFFFFFL; + private final int id; /** * Initializes a new instance of the {@link SchemaId} struct. * * @param id The underlying globally unique identifier of the schema. */ - public SchemaId() { - } - public SchemaId(int id) { - this.Id = id; + this.id = id; } - public int getId() { - return Id; + private SchemaId() { + this.id = -1; } - /** - * {@link object.Equals(object)} overload. - */ @Override - public boolean equals(Object obj) { - if (null == obj) { - return false; - } - - return obj instanceof SchemaId && this.equals((SchemaId)obj); + public boolean equals(Object other) { + return other instanceof SchemaId && this.equals((SchemaId) other); } /** - * Returns true if this is the same {@link SchemaId} as {@link other}. + * {@code true} if this is the same {@link SchemaId} as {@code other} * * @param other The value to compare against. * @return True if the two values are the same. */ public boolean equals(SchemaId other) { - return this.getId() == other.getId(); + if (null == other) { + return false; + } + return this.id() == other.id(); } - /** - * {@link object.GetHashCode} overload. - */ @Override public int hashCode() { - return (new Integer(this.getId())).hashCode(); + return Integer.valueOf(this.id()).hashCode(); } /** - * Operator == overload. + * The underlying integer value of this {@link SchemaId} + * + * @return The integer value of this {@link SchemaId} */ - public static boolean opEquals(SchemaId left, SchemaId right) { - return left.equals(right.clone()); + public int id() { + return id; } - /** - * Operator != overload. - */ - public static boolean opNotEquals(SchemaId left, SchemaId right) { - return !left.equals(right.clone()); - } - - /** - * {@link object.ToString} overload. - */ @Override public String toString() { - return String.valueOf(this.getId()); + return String.valueOf(this.id()); } - /** - * Helper class for parsing {@link SchemaId} from JSON. - */ - public static class SchemaIdConverter extends JsonConverter { - @Override - public boolean getCanWrite() { - return true; + static final class JsonDeserializer extends StdDeserializer { + + private JsonDeserializer() { + super(SchemaId.class); } @Override - public boolean CanConvert(java.lang.Class objectType) { - return objectType.isAssignableFrom(SchemaId.class); + public SchemaId deserialize(final JsonParser parser, final DeserializationContext context) throws IOException, JsonProcessingException { + + final long value = parser.getLongValue(); + + if (value < 0 || value > MAX_VALUE) { + String message = lenientFormat("expected integer value in [0, 4294967295], not %s", value); + throw MismatchedInputException.from(parser, SchemaId.class, message); + } + + return new SchemaId((int) value); + } + } + + static final class JsonSerializer extends StdSerializer { + + private JsonSerializer() { + super(SchemaId.class); } @Override - public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue, - JsonSerializer serializer) { - checkArgument(reader.TokenType == JsonToken.Integer); - // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'checked' in this context: - //ORIGINAL LINE: return new SchemaId(checked((int)(long)reader.Value)); - return new SchemaId((int)(long)reader.Value); - } - - @Override - public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) { - writer.WriteValue((long)((SchemaId)value).getId()); + public void serialize(final SchemaId value, final JsonGenerator generator, final SerializerProvider provider) throws IOException { + generator.writeNumber((long) value.id() & MAX_VALUE); } } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java index e99282e..c49f806 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java @@ -6,13 +6,14 @@ package com.azure.data.cosmos.serialization.hybridrow.io; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; +import com.azure.data.cosmos.core.UtfAnyString; import com.azure.data.cosmos.serialization.hybridrow.Float128; import com.azure.data.cosmos.serialization.hybridrow.NullValue; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; -import com.azure.data.cosmos.serialization.hybridrow.UnixDateTime; import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions; +import com.azure.data.cosmos.serialization.hybridrow.UnixDateTime; import com.azure.data.cosmos.serialization.hybridrow.layouts.ILayoutSpanReadable; import com.azure.data.cosmos.serialization.hybridrow.layouts.ILayoutUtf8SpanReadable; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutBinary; @@ -76,53 +77,56 @@ public final class RowReader { private RowCursor cursor = new RowCursor(); private RowBuffer row = new RowBuffer(); private int schematizedCount; + // State that can be checkpointed. private States state = States.values()[0]; - /** - * Initializes a new instance of the {@link RowReader} struct. - * - * @param row The row to be read. - * @param scope The scope whose fields should be enumerated. - *

- * A {@link RowReader} instance traverses all of the top-level fields of a given - * scope. If the root scope is provided then all top-level fields in the row are enumerated. Nested - * child {@link RowReader} instances can be access through the {@link ReadScope} method - * to process nested content. - */ public RowReader() { } /** * Initializes a new instance of the {@link RowReader} struct. * - * @param row The row to be read. - * @param scope The scope whose fields should be enumerated. - *

- * A {@link RowReader} instance traverses all of the top-level fields of a given - * scope. If the root scope is provided then all top-level fields in the row are enumerated. Nested - * child {@link RowReader} instances can be access through the {@link ReadScope} method - * to process nested content. + * @param row The row to be read */ public RowReader(Reference row) { this(row, RowCursor.Create(row)); } + /** + * Initializes a new instance of the {@link RowReader} struct. + * + * @param row The row to be read + * @param checkpoint Initial state of the reader + */ public RowReader(Reference row, final Checkpoint checkpoint) { + this.row = row.get().clone(); - this.columns = checkpoint.Cursor.layout.columns(); - this.schematizedCount = checkpoint.Cursor.layout.numFixed() + checkpoint.Cursor.layout.numVariable(); + this.columns = checkpoint.Cursor.layout().columns(); + this.schematizedCount = checkpoint.Cursor.layout().numFixed() + checkpoint.Cursor.layout().numVariable(); this.state = checkpoint.State; this.cursor = checkpoint.Cursor.clone(); this.columnIndex = checkpoint.ColumnIndex; } + /** + * Initializes a new instance of the {@link RowReader} struct. + * + * @param row The row to be read + * @param scope The scope whose fields should be enumerated + *

+ * A {@link RowReader} instance traverses all of the top-level fields of a given scope. If the + * root scope is provided then all top-level fields in the row are enumerated. Nested child + * {@link RowReader} instances can be access through the {@link RowReader#ReadScope} method to + * process nested content. + */ private RowReader(Reference row, final RowCursor scope) { + this.cursor = scope.clone(); this.row = row.get().clone(); - this.columns = this.cursor.layout.columns(); - this.schematizedCount = this.cursor.layout.numFixed() + this.cursor.layout.numVariable(); + this.columns = this.cursor.layout().columns(); + this.schematizedCount = this.cursor.layout().numFixed() + this.cursor.layout().numVariable(); this.state = States.None; this.columnIndex = -1; @@ -136,25 +140,26 @@ public final class RowReader { * is set (even though its values is set to null). */ public boolean getHasValue() { + switch (this.state) { + case Schematized: return true; + case Sparse: if (this.cursor.cellType instanceof LayoutNullable) { - Reference tempReference_cursor = - new Reference(this.cursor); - RowCursor nullableScope = this.row.SparseIteratorReadScope(tempReference_cursor, true).clone(); - this.cursor = tempReference_cursor.get(); - Reference tempReference_row = - new Reference(this.row); - Reference tempReference_nullableScope = new Reference(nullableScope); - boolean tempVar = LayoutNullable.HasValue(tempReference_row, tempReference_nullableScope) == Result.Success; + Reference cursor = new Reference<>(this.cursor); + RowCursor nullableScope = this.row.SparseIteratorReadScope(cursor, true).clone(); + this.cursor = cursor.get(); + Reference row = new Reference<>(this.row); + Reference tempReference_nullableScope = new Reference<>(nullableScope); + boolean tempVar = LayoutNullable.HasValue(row, tempReference_nullableScope) == Result.Success; nullableScope = tempReference_nullableScope.get(); - this.row = tempReference_row.get(); + this.row = row.get(); return tempVar; } - return true; + default: return false; } @@ -171,7 +176,7 @@ public final class RowReader { case Schematized: return 0; case Sparse: - return this.cursor.index; + return this.cursor.index(); default: return 0; } @@ -181,7 +186,7 @@ public final class RowReader { * The length of row in bytes. */ public int getLength() { - return this.row.getLength(); + return this.row.length(); } /** @@ -210,8 +215,7 @@ public final class RowReader { } /** - * The path, relative to the scope, of the field (if positioned on a field, undefined - * otherwise). + * The path, relative to the scope, of the field (if positioned on a field, undefined otherwise) *

* When enumerating an indexed scope, this value is always null (see {@link Index}). */ @@ -268,7 +272,7 @@ public final class RowReader { case Sparse: return this.cursor.cellTypeArgs.clone(); default: - return TypeArgumentList.Empty; + return TypeArgumentList.EMPTY; } } @@ -281,7 +285,7 @@ public final class RowReader { switch (this.state) { case None: { - if (this.cursor.scopeType instanceof LayoutUDT) { + if (this.cursor.scopeType() instanceof LayoutUDT) { this.state = States.Schematized; // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: // goto case States.Schematized; @@ -301,10 +305,10 @@ public final class RowReader { // goto case States.Sparse; } - checkState(this.cursor.scopeType instanceof LayoutUDT); + checkState(this.cursor.scopeType() instanceof LayoutUDT); LayoutColumn col = this.columns[this.columnIndex]; - if (!this.row.ReadBit(this.cursor.start, col.getNullBit().clone())) { + if (!this.row.ReadBit(this.cursor.start(), col.getNullBit().clone())) { // Skip schematized values if they aren't present. // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: // goto case States.Schematized; @@ -1067,7 +1071,7 @@ public final class RowReader { * {@link ReaderFunc{TContext}} is not an option, such as when TContext is a ref struct. */ public Result SkipScope(Reference nestedReader) { - if (nestedReader.get().cursor.start != this.cursor.valueOffset) { + if (nestedReader.get().cursor.start() != this.cursor.valueOffset()) { return Result.Failure; } @@ -1116,14 +1120,14 @@ public final class RowReader { new Reference(this.row); Reference tempReference_cursor = new Reference(this.cursor); - Result tempVar = t.>TypeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value); + Result tempVar = t.>typeAs().readFixed(tempReference_row, tempReference_cursor, col, value); this.cursor = tempReference_cursor.get(); this.row = tempReference_row.get(); return tempVar; case Variable: Reference tempReference_row2 = new Reference(this.row); Reference tempReference_cursor2 = new Reference(this.cursor); - Result tempVar2 = t.>TypeAs().ReadVariable(tempReference_row2, tempReference_cursor2, col, value); + Result tempVar2 = t.>typeAs().readVariable(tempReference_row2, tempReference_cursor2, col, value); this.cursor = tempReference_cursor2.get(); this.row = tempReference_row2.get(); return tempVar2; @@ -1152,14 +1156,14 @@ public final class RowReader { case Fixed: Reference tempReference_row = new Reference(this.row); Reference tempReference_cursor = new Reference(this.cursor); - Result tempVar = t.TypeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value); + Result tempVar = t.typeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value); this.cursor = tempReference_cursor.get(); this.row = tempReference_row.get(); return tempVar; case Variable: Reference tempReference_row2 = new Reference(this.row); Reference tempReference_cursor2 = new Reference(this.cursor); - Result tempVar2 = t.TypeAs().ReadVariable(tempReference_row2, + Result tempVar2 = t.typeAs().ReadVariable(tempReference_row2, tempReference_cursor2, col, value); this.cursor = tempReference_cursor2.get(); this.row = tempReference_row2.get(); @@ -1190,14 +1194,14 @@ public final class RowReader { case Fixed: Reference tempReference_row = new Reference(this.row); Reference tempReference_cursor = new Reference(this.cursor); - Result tempVar = t.>TypeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value); + Result tempVar = t.>typeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value); this.cursor = tempReference_cursor.get(); this.row = tempReference_row.get(); return tempVar; case Variable: Reference tempReference_row2 = new Reference(this.row); Reference tempReference_cursor2 = new Reference(this.cursor); - Result tempVar2 = t.>TypeAs().ReadVariable(tempReference_row2, tempReference_cursor2, col, value); + Result tempVar2 = t.>typeAs().ReadVariable(tempReference_row2, tempReference_cursor2, col, value); this.cursor = tempReference_cursor2.get(); this.row = tempReference_row2.get(); return tempVar2; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java index 3e34909..2dbd3ae 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java @@ -54,21 +54,21 @@ public final class RowWriter { * The active layout of the current writer scope. */ public Layout getLayout() { - return this.cursor.layout; + return this.cursor.layout(); } /** * The length of row in bytes. */ public int getLength() { - return this.row.getLength(); + return this.row.length(); } /** * The resolver for UDTs. */ public LayoutResolver getResolver() { - return this.row.getResolver(); + return this.row.resolver(); } /** @@ -168,7 +168,7 @@ public final class RowWriter { RowWriter writer = new RowWriter(row, tempReference_scope); scope = tempReference_scope.get(); TypeArgument typeArg = new TypeArgument(LayoutType.UDT, - new TypeArgumentList(scope.layout.schemaId().clone())); + new TypeArgumentList(scope.layout().schemaId().clone())); Reference tempReference_writer = new Reference(writer); // TODO: C# TO JAVA CONVERTER: The following line could not be converted: @@ -371,7 +371,7 @@ public final class RowWriter { public Result WriteScope(UtfAnyString path, TypeArgument typeArg, TContext context, WriterFunc func) { - LayoutType type = typeArg.getType(); + LayoutType type = typeArg.type(); Result result = this.PrepareSparseWrite(path, typeArg.clone()); if (result != Result.Success) { return result; @@ -411,7 +411,7 @@ public final class RowWriter { new Reference(this.cursor); Out tempOut_nestedScope3 = new Out(); - this.row.WriteTypedArray(tempRef_cursor3, scopeType, typeArg.getTypeArgs().clone(), + this.row.WriteTypedArray(tempRef_cursor3, scopeType, typeArg.typeArgs().clone(), UpdateOptions.Upsert, tempOut_nestedScope3); nestedScope = tempOut_nestedScope3.get(); this.cursor = tempRef_cursor3.argValue; @@ -425,7 +425,7 @@ public final class RowWriter { new Reference(this.cursor); Out tempOut_nestedScope4 = new Out(); - this.row.WriteSparseTuple(tempRef_cursor4, scopeType, typeArg.getTypeArgs().clone(), + this.row.WriteSparseTuple(tempRef_cursor4, scopeType, typeArg.typeArgs().clone(), UpdateOptions.Upsert, tempOut_nestedScope4); nestedScope = tempOut_nestedScope4.get(); this.cursor = tempRef_cursor4.argValue; @@ -439,7 +439,7 @@ public final class RowWriter { new Reference(this.cursor); Out tempOut_nestedScope5 = new Out(); - this.row.WriteTypedTuple(tempRef_cursor5, scopeType, typeArg.getTypeArgs().clone(), + this.row.WriteTypedTuple(tempRef_cursor5, scopeType, typeArg.typeArgs().clone(), UpdateOptions.Upsert, tempOut_nestedScope5); nestedScope = tempOut_nestedScope5.get(); this.cursor = tempRef_cursor5.argValue; @@ -453,7 +453,7 @@ public final class RowWriter { new Reference(this.cursor); Out tempOut_nestedScope6 = new Out(); - this.row.WriteTypedTuple(tempRef_cursor6, scopeType, typeArg.getTypeArgs().clone(), + this.row.WriteTypedTuple(tempRef_cursor6, scopeType, typeArg.typeArgs().clone(), UpdateOptions.Upsert, tempOut_nestedScope6); nestedScope = tempOut_nestedScope6.get(); this.cursor = tempRef_cursor6.argValue; @@ -467,7 +467,7 @@ public final class RowWriter { new Reference(this.cursor); Out tempOut_nestedScope7 = new Out(); - this.row.WriteTypedTuple(tempRef_cursor7, scopeType, typeArg.getTypeArgs().clone(), + this.row.WriteTypedTuple(tempRef_cursor7, scopeType, typeArg.typeArgs().clone(), UpdateOptions.Upsert, tempOut_nestedScope7); nestedScope = tempOut_nestedScope7.get(); this.cursor = tempRef_cursor7.argValue; @@ -481,7 +481,7 @@ public final class RowWriter { new Reference(this.cursor); Out tempOut_nestedScope8 = new Out(); - this.row.WriteNullable(tempRef_cursor8, scopeType, typeArg.getTypeArgs().clone(), + this.row.WriteNullable(tempRef_cursor8, scopeType, typeArg.typeArgs().clone(), UpdateOptions.Upsert, func != null, tempOut_nestedScope8); nestedScope = tempOut_nestedScope8.get(); this.cursor = tempRef_cursor8.argValue; @@ -491,7 +491,7 @@ public final class RowWriter { //ORIGINAL LINE: case LayoutUDT scopeType: case LayoutUDT scopeType: - Layout udt = this.row.getResolver().Resolve(typeArg.getTypeArgs().getSchemaId().clone()); + Layout udt = this.row.resolver().Resolve(typeArg.typeArgs().schemaId().clone()); Reference tempReference_cursor9 = new Reference(this.cursor); Out tempOut_nestedScope9 = @@ -509,7 +509,7 @@ public final class RowWriter { new Reference(this.cursor); Out tempOut_nestedScope10 = new Out(); - this.row.WriteTypedSet(tempRef_cursor10, scopeType, typeArg.getTypeArgs().clone(), + this.row.WriteTypedSet(tempRef_cursor10, scopeType, typeArg.typeArgs().clone(), UpdateOptions.Upsert, tempOut_nestedScope10); nestedScope = tempOut_nestedScope10.get(); this.cursor = tempRef_cursor10.argValue; @@ -523,7 +523,7 @@ public final class RowWriter { new Reference(this.cursor); Out tempOut_nestedScope11 = new Out(); - this.row.WriteTypedMap(tempRef_cursor11, scopeType, typeArg.getTypeArgs().clone(), + this.row.WriteTypedMap(tempRef_cursor11, scopeType, typeArg.typeArgs().clone(), UpdateOptions.Upsert, tempOut_nestedScope11); nestedScope = tempOut_nestedScope11.get(); this.cursor = tempRef_cursor11.argValue; @@ -547,7 +547,7 @@ public final class RowWriter { result = func == null ? null : func.Invoke(ref nestedWriter, typeArg, context) ??Result.Success; nestedWriter = tempReference_nestedWriter.get(); this.row = nestedWriter.row.clone(); - nestedScope.count = nestedWriter.cursor.count; + nestedScope.count(nestedWriter.cursor.count()); if (result != Result.Success) { // TODO: what about unique violations here? @@ -764,24 +764,24 @@ public final class RowWriter { * @return Success if the write is permitted, the error code otherwise. */ private Result PrepareSparseWrite(UtfAnyString path, TypeArgument typeArg) { - if (this.cursor.scopeType.IsFixedArity && !(this.cursor.scopeType instanceof LayoutNullable)) { - if ((this.cursor.index < this.cursor.scopeTypeArgs.getCount()) && !typeArg.equals(this.cursor.scopeTypeArgs.get(this.cursor.index).clone())) { + if (this.cursor.scopeType().isFixedArity() && !(this.cursor.scopeType() instanceof LayoutNullable)) { + if ((this.cursor.index() < this.cursor.scopeTypeArgs().count()) && !typeArg.equals(this.cursor.scopeTypeArgs().get(this.cursor.index()).clone())) { return Result.TypeConstraint; } - } else if (this.cursor.scopeType instanceof LayoutTypedMap) { + } else if (this.cursor.scopeType() instanceof LayoutTypedMap) { Reference tempReference_cursor = new Reference(this.cursor); - if (!typeArg.equals(this.cursor.scopeType.TypeAs().FieldType(tempReference_cursor).clone())) { + if (!typeArg.equals(this.cursor.scopeType().typeAs().FieldType(tempReference_cursor).clone())) { this.cursor = tempReference_cursor.get(); return Result.TypeConstraint; } else { this.cursor = tempReference_cursor.get(); } - } else if (this.cursor.scopeType.IsTypedScope && !typeArg.equals(this.cursor.scopeTypeArgs.get(0).clone())) { + } else if (this.cursor.scopeType().isTypedScope() && !typeArg.equals(this.cursor.scopeTypeArgs().get(0).clone())) { return Result.TypeConstraint; } - this.cursor.writePath = path; + this.cursor.writePath(path); return Result.Success; } @@ -797,7 +797,7 @@ public final class RowWriter { */ private & ILayoutUtf8SpanWritable> Result WritePrimitive(UtfAnyString path, Utf8Span value, TLayoutType type, AccessUtf8SpanMethod sparse) { Result result = Result.NotFound; - if (this.cursor.scopeType instanceof LayoutUDT) { + if (this.cursor.scopeType() instanceof LayoutUDT) { result = this.WriteSchematizedValue(path, value); } @@ -836,7 +836,7 @@ public final class RowWriter { */ private & ILayoutSpanWritable, TElement> Result WritePrimitive(UtfAnyString path, ReadOnlySpan value, TLayoutType type, AccessReadOnlySpanMethod sparse) { Result result = Result.NotFound; - if (this.cursor.scopeType instanceof LayoutUDT) { + if (this.cursor.scopeType() instanceof LayoutUDT) { result = this.WriteSchematizedValue(path, value); } @@ -875,7 +875,7 @@ public final class RowWriter { */ private & ILayoutSequenceWritable, TElement> Result WritePrimitive(UtfAnyString path, ReadOnlySequence value, TLayoutType type, AccessMethod> sparse) { Result result = Result.NotFound; - if (this.cursor.scopeType instanceof LayoutUDT) { + if (this.cursor.scopeType() instanceof LayoutUDT) { result = this.WriteSchematizedValue(path, value); } @@ -914,7 +914,7 @@ public final class RowWriter { private Result WritePrimitive(UtfAnyString path, TValue value, LayoutType type, AccessMethod sparse) { Result result = Result.NotFound; - if (this.cursor.scopeType instanceof LayoutUDT) { + if (this.cursor.scopeType() instanceof LayoutUDT) { result = this.WriteSchematizedValue(path, value); } @@ -953,7 +953,7 @@ public final class RowWriter { LayoutColumn col; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: - if (!this.cursor.layout.TryFind(path, out col)) { + if (!this.cursor.layout().TryFind(path, out col)) { return Result.NotFound; } @@ -967,14 +967,14 @@ public final class RowWriter { case StorageKind.Fixed: Reference tempReference_row = new Reference(this.row); - Result tempVar2 = t.WriteFixed(ref this.row, ref this.cursor, col, value) + Result tempVar2 = t.writeFixed(ref this.row, ref this.cursor, col, value) this.row = tempReference_row.get(); return tempVar2; case StorageKind.Variable: Reference tempReference_row2 = new Reference(this.row); - Result tempVar3 = t.WriteVariable(ref this.row, ref this.cursor, col, value) + Result tempVar3 = t.writeVariable(ref this.row, ref this.cursor, col, value) this.row = tempReference_row2.get(); return tempVar3; @@ -996,7 +996,7 @@ public final class RowWriter { LayoutColumn col; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: - if (!this.cursor.layout.TryFind(path, out col)) { + if (!this.cursor.layout().TryFind(path, out col)) { return Result.NotFound; } @@ -1011,7 +1011,7 @@ public final class RowWriter { new Reference(this.row); Reference tempReference_cursor = new Reference(this.cursor); - Result tempVar = t.TypeAs().WriteFixed(tempReference_row, tempReference_cursor, col, + Result tempVar = t.typeAs().WriteFixed(tempReference_row, tempReference_cursor, col, value); this.cursor = tempReference_cursor.get(); this.row = tempReference_row.get(); @@ -1021,7 +1021,7 @@ public final class RowWriter { new Reference(this.row); Reference tempReference_cursor2 = new Reference(this.cursor); - Result tempVar2 = t.TypeAs().WriteVariable(tempReference_row2, + Result tempVar2 = t.typeAs().WriteVariable(tempReference_row2, tempReference_cursor2, col, value); this.cursor = tempReference_cursor2.get(); @@ -1043,7 +1043,7 @@ public final class RowWriter { private Result WriteSchematizedValue(UtfAnyString path, ReadOnlySpan value) { LayoutColumn col; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified: - if (!this.cursor.layout.TryFind(path, out col)) { + if (!this.cursor.layout().TryFind(path, out col)) { return Result.NotFound; } @@ -1056,14 +1056,14 @@ public final class RowWriter { case StorageKind.Fixed: Reference tempReference_row = new Reference(this.row); Reference tempReference_cursor = new Reference(this.cursor); - Result tempVar = t.>TypeAs().WriteFixed(tempReference_row, tempReference_cursor, col, value); + Result tempVar = t.>typeAs().WriteFixed(tempReference_row, tempReference_cursor, col, value); this.cursor = tempReference_cursor.get(); this.row = tempReference_row.get(); return tempVar; case StorageKind.Variable: Reference tempReference_row2 = new Reference(this.row); Reference tempReference_cursor2 = new Reference(this.cursor); - Result tempVar2 = t.>TypeAs().WriteVariable(tempReference_row2, tempReference_cursor2, col, value); + Result tempVar2 = t.>typeAs().WriteVariable(tempReference_row2, tempReference_cursor2, col, value); this.cursor = tempReference_cursor2.get(); this.row = tempReference_row2.get(); return tempVar2; @@ -1083,7 +1083,7 @@ public final class RowWriter { private Result WriteSchematizedValue(UtfAnyString path, ReadOnlySequence value) { LayoutColumn col; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified: - if (!this.cursor.layout.TryFind(path, out col)) { + if (!this.cursor.layout().TryFind(path, out col)) { return Result.NotFound; } @@ -1096,14 +1096,14 @@ public final class RowWriter { case StorageKind.Fixed: Reference tempReference_row = new Reference(this.row); Reference tempReference_cursor = new Reference(this.cursor); - Result tempVar = t.>TypeAs().WriteFixed(tempReference_row, tempReference_cursor, col, value); + Result tempVar = t.>typeAs().WriteFixed(tempReference_row, tempReference_cursor, col, value); this.cursor = tempReference_cursor.get(); this.row = tempReference_row.get(); return tempVar; case StorageKind.Variable: Reference tempReference_row2 = new Reference(this.row); Reference tempReference_cursor2 = new Reference(this.cursor); - Result tempVar2 = t.>TypeAs().WriteVariable(tempReference_row2, tempReference_cursor2, col, value); + Result tempVar2 = t.>typeAs().WriteVariable(tempReference_row2, tempReference_cursor2, col, value); this.cursor = tempReference_cursor2.get(); this.row = tempReference_row2.get(); return tempVar2; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java index dc9dfcb..588ee79 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java @@ -10,23 +10,22 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ArrayScope; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableArrayScope; +import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ARRAY_SCOPE; +import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_ARRAY_SCOPE; public final class LayoutArray extends LayoutIndexedScope { private TypeArgument TypeArg = new TypeArgument(); public LayoutArray(boolean immutable) { - super(immutable ? ImmutableArrayScope : ArrayScope, immutable, false, false, false, false); + super(immutable ? IMMUTABLE_ARRAY_SCOPE : ARRAY_SCOPE, immutable, false, false, false, false); this.TypeArg = new TypeArgument(this); } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_array" : "array"; } - public TypeArgument getTypeArg() { + public TypeArgument typeArg() { return TypeArg; } @@ -46,7 +45,7 @@ public final class LayoutArray extends LayoutIndexedScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { value.setAndGet(null); return result; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java index 4d3ae8e..056a178 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java @@ -18,16 +18,14 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutBinary extends LayoutType implements ILayoutSpanWritable, ILayoutSpanReadable, ILayoutSequenceWritable { public LayoutBinary() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Binary, 0); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.BINARY, 0); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return false; } - @Override - public String getName() { + public String name() { return "binary"; } @@ -35,7 +33,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // byte[] value) @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { ReadOnlySpan span; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these @@ -53,21 +51,21 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa // ReadOnlySpan value) public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, Out> value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); + checkArgument(scope.get().scopeType() instanceof LayoutUDT); checkArgument(col.getSize() >= 0); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(null); return Result.NotFound; } - value.setAndGet(b.get().ReadFixedBinary(scope.get().start + col.getOffset(), col.getSize())); + value.setAndGet(b.get().ReadFixedBinary(scope.get().start() + col.getOffset(), col.getSize())); return Result.Success; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out byte[] value) @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { ReadOnlySpan span; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified: @@ -82,7 +80,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ReadOnlySpan value) public Result ReadSparse(Reference b, Reference edit, Out> value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(null); return result; @@ -96,7 +94,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //ORIGINAL LINE: public override Result ReadVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // byte[] value) @Override - public Result ReadVariable(Reference b, Reference scope, LayoutColumn col + public Result readVariable(Reference b, Reference scope, LayoutColumn col , Out value) { ReadOnlySpan span; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these @@ -114,13 +112,13 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa // ReadOnlySpan value) public Result ReadVariable(Reference b, Reference scope, LayoutColumn col , Out> value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(null); return Result.NotFound; } - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), col.getOffset()); value.setAndGet(b.get().ReadVariableBinary(varOffset)); return Result.Success; @@ -130,7 +128,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //ORIGINAL LINE: public override Result WriteFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, byte[] // value) @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, + public Result writeFixed(Reference b, Reference scope, LayoutColumn col, byte[] value) { checkArgument(value != null); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -143,15 +141,15 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa // ReadOnlySpan value) public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, ReadOnlySpan value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); + checkArgument(scope.get().scopeType() instanceof LayoutUDT); checkArgument(col.getSize() >= 0); checkArgument(value.Length == col.getSize()); - if (scope.get().immutable) { + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteFixedBinary(scope.get().start + col.getOffset(), value, col.getSize()); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteFixedBinary(scope.get().start() + col.getOffset(), value, col.getSize()); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -160,21 +158,21 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa // ReadOnlySequence value) public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, ReadOnlySequence value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); + checkArgument(scope.get().scopeType() instanceof LayoutUDT); checkArgument(col.getSize() >= 0); checkArgument(value.Length == col.getSize()); - if (scope.get().immutable) { + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteFixedBinary(scope.get().start + col.getOffset(), value, col.getSize()); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteFixedBinary(scope.get().start() + col.getOffset(), value, col.getSize()); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @Override - public Result WriteSparse(Reference b, Reference edit, byte[] value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(Reference b, Reference edit, byte[] value) { + return writeSparse(b, edit, value, UpdateOptions.Upsert); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: @@ -182,7 +180,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa // UpdateOptions options = UpdateOptions.Upsert) //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @Override - public Result WriteSparse(Reference b, Reference edit, byte[] value, + public Result writeSparse(Reference b, Reference edit, byte[] value, UpdateOptions options) { checkArgument(value != null); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -201,7 +199,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: public Result WriteSparse(Reference b, Reference edit, ReadOnlySpan value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -221,7 +219,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: public Result WriteSparse(Reference b, Reference edit, ReadOnlySequence value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -234,7 +232,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //ORIGINAL LINE: public override Result WriteVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, // byte[] value) @Override - public Result WriteVariable(Reference b, Reference scope, + public Result writeVariable(Reference b, Reference scope, LayoutColumn col, byte[] value) { checkArgument(value != null); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -247,8 +245,8 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa // ReadOnlySpan value) public Result WriteVariable(Reference b, Reference scope, LayoutColumn col, ReadOnlySpan value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } @@ -257,16 +255,16 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa return Result.TooBig; } - boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, + boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone()); + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), col.getOffset()); int shift; Out tempOut_shift = new Out(); b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift); shift = tempOut_shift.get(); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); - scope.get().metaOffset += shift; - scope.get().valueOffset += shift; + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); + scope.get().metaOffset(scope.get().metaOffset() + shift); + scope.get().valueOffset(scope.get().valueOffset() + shift); return Result.Success; } @@ -275,8 +273,8 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa // ReadOnlySequence value) public Result WriteVariable(Reference b, Reference scope, LayoutColumn col, ReadOnlySequence value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } @@ -285,16 +283,16 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa return Result.TooBig; } - boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, + boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone()); + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), col.getOffset()); int shift; Out tempOut_shift = new Out(); b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift); shift = tempOut_shift.get(); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); - scope.get().metaOffset += shift; - scope.get().valueOffset += shift; + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); + scope.get().metaOffset(scope.get().metaOffset() + shift); + scope.get().valueOffset(scope.get().valueOffset() + shift); return Result.Success; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java index 57b26cd..f501895 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java @@ -17,38 +17,35 @@ public final class LayoutBoolean extends LayoutType { super(, 0); } - @Override - public boolean getIsBool() { + public boolean isBoolean() { return true; } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "bool"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(false); return Result.NotFound; } - value.setAndGet(b.get().ReadBit(scope.get().start, col.getBoolBit().clone())); + value.setAndGet(b.get().ReadBit(scope.get().start(), col.getBoolBit().clone())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(false); return result; @@ -61,18 +58,18 @@ public final class LayoutBoolean extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, boolean value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } if (value) { - b.get().SetBit(scope.get().start, col.getBoolBit().clone()); + b.get().SetBit(scope.get().start(), col.getBoolBit().clone()); } else { - b.get().UnsetBit(scope.get().start, col.getBoolBit().clone()); + b.get().UnsetBit(scope.get().start(), col.getBoolBit().clone()); } - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -82,7 +79,7 @@ public final class LayoutBoolean extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, boolean value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java index f4a88f4..9531451 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java @@ -51,16 +51,16 @@ public final class LayoutBuilder { if (type.getIsNull()) { checkArgument(nullable); LayoutBit nullbit = this.bitallocator.Allocate().clone(); - col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Fixed, this.getParent(), + col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Fixed, this.getParent(), this.fixedCount, 0, nullbit.clone(), LayoutBit.Invalid, 0); } else if (type.getIsBool()) { LayoutBit nullbit = nullable ? this.bitallocator.Allocate() : LayoutBit.Invalid; LayoutBit boolbit = this.bitallocator.Allocate().clone(); - col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Fixed, this.getParent(), + col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Fixed, this.getParent(), this.fixedCount, 0, nullbit.clone(), boolbit.clone(), 0); } else { LayoutBit nullBit = nullable ? this.bitallocator.Allocate() : LayoutBit.Invalid; - col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Fixed, this.getParent(), + col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Fixed, this.getParent(), this.fixedCount, this.fixedSize, nullBit.clone(), LayoutBit.Invalid, length); this.fixedSize += type.getIsFixed() ? type.Size : length; @@ -71,7 +71,7 @@ public final class LayoutBuilder { } public void AddObjectScope(String path, LayoutType type) { - LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Sparse, this.getParent(), + LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Sparse, this.getParent(), this.sparseCount, -1, LayoutBit.Invalid, LayoutBit.Invalid, 0); this.sparseCount++; @@ -80,7 +80,7 @@ public final class LayoutBuilder { } public void AddSparseColumn(String path, LayoutType type) { - LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Sparse, this.getParent(), + LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Sparse, this.getParent(), this.sparseCount, -1, LayoutBit.Invalid, LayoutBit.Invalid, 0); this.sparseCount++; @@ -102,7 +102,7 @@ public final class LayoutBuilder { checkArgument(length >= 0); checkArgument(type.getAllowVariable()); - LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Variable, + LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Variable, this.getParent(), this.varCount, this.varCount, this.bitallocator.Allocate().clone(), LayoutBit.Invalid, length); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java index b111d1a..75abce4 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java @@ -8,104 +8,109 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; ///#pragma warning disable CA1028 // Enum Storage should be Int32 +import java.util.HashMap; +import java.util.Map; + /** * Type coded used in the binary encoding to indicate the formatting of succeeding bytes. */ //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public enum LayoutCode : byte public enum LayoutCode { - Invalid((byte)0), - Null((byte)1), - BooleanFalse((byte)2), - Boolean((byte)3), + INVALID((byte)0), - Int8((byte)5), - Int16((byte)6), - Int32((byte)7), - Int64((byte)8), - UInt8((byte)9), + NULL((byte)1), + BOOLEAN_FALSE((byte)2), + BOOLEAN((byte)3), + + INT_8((byte)5), + INT_16((byte)6), + INT_32((byte)7), + INT_64((byte)8), + UINT_8((byte)9), //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: UInt16 = 10, - UInt16((byte)10), + UINT_16((byte)10), //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: UInt32 = 11, - UInt32((byte)11), + UINT_32((byte)11), //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: UInt64 = 12, - UInt64((byte)12), - VarInt((byte)13), - VarUInt((byte)14), + UINT_64((byte)12), + VAR_INT((byte)13), + VAR_UINT((byte)14), - Float32((byte)15), - Float64((byte)16), - Decimal((byte)17), + FLOAT_32((byte)15), + FLOAT_64((byte)16), + DECIMAL((byte)17), - DateTime((byte)18), - Guid((byte)19), + DATE_TIME((byte)18), + GUID((byte)19), - Utf8((byte)20), - Binary((byte)21), + UTF_8((byte)20), + BINARY((byte)21), - Float128((byte)22), - UnixDateTime((byte)23), - MongoDbObjectId((byte)24), + FLOAT_128((byte)22), + UNIX_DATE_TIME((byte)23), + MONGODB_OBJECT_ID((byte)24), - ObjectScope((byte)30), - ImmutableObjectScope((byte)31), - ArrayScope((byte)32), - ImmutableArrayScope((byte)33), - TypedArrayScope((byte)34), - ImmutableTypedArrayScope((byte)35), - TupleScope((byte)36), - ImmutableTupleScope((byte)37), - TypedTupleScope((byte)38), - ImmutableTypedTupleScope((byte)39), - MapScope((byte)40), - ImmutableMapScope((byte)41), - TypedMapScope((byte)42), - ImmutableTypedMapScope((byte)43), - SetScope((byte)44), - ImmutableSetScope((byte)45), - TypedSetScope((byte)46), - ImmutableTypedSetScope((byte)47), - NullableScope((byte)48), - ImmutableNullableScope((byte)49), - TaggedScope((byte)50), - ImmutableTaggedScope((byte)51), - Tagged2Scope((byte)52), - ImmutableTagged2Scope((byte)53), + OBJECT_SCOPE((byte)30), + IMMUTABLE_OBJECT_SCOPE((byte)31), + ARRAY_SCOPE((byte)32), + IMMUTABLE_ARRAY_SCOPE((byte)33), + TYPED_ARRAY_SCOPE((byte)34), + IMMUTABLE_TYPED_ARRAY_SCOPE((byte)35), + TUPLE_SCOPE((byte)36), + IMMUTABLE_TUPLE_SCOPE((byte)37), + TYPED_TUPLE_SCOPE((byte)38), + IMMUTABLE_TYPED_TUPLE_SCOPE((byte)39), + MAP_SCOPE((byte)40), + IMMUTABLE_MAP_SCOPE((byte)41), + TYPED_MAP_SCOPE((byte)42), + IMMUTABLE_TYPED_MAP_SCOPE((byte)43), + SET_SCOPE((byte)44), + IMMUTABLE_SET_SCOPE((byte)45), + TYPED_SET_SCOPE((byte)46), + IMMUTABLE_TYPED_SET_SCOPE((byte)47), + NULLABLE_SCOPE((byte)48), + IMMUTABLE_NULLABLE_SCOPE((byte)49), + TAGGED_SCOPE((byte)50), + IMMUTABLE_TAGGED_SCOPE((byte)51), + TAGGED2_SCOPE((byte)52), + IMMUTABLE_TAGGED2_SCOPE((byte)53), /** * Nested row. */ - Schema((byte)68), - ImmutableSchema((byte)69), + SCHEMA((byte)68), + IMMUTABLE_SCHEMA((byte)69), - EndScope((byte)70); + END_SCOPE((byte)70); - public static final int SIZE = java.lang.Byte.SIZE; - private static java.util.HashMap mappings; - private byte byteValue; + public static final int SIZE = Byte.SIZE; + + private static Map mappings; + private byte value; LayoutCode(byte value) { - byteValue = value; - getMappings().put(value, this); + this.value = value; + mappings().put(value, this); } - public byte getValue() { - return byteValue; + public byte value() { + return value; } public static LayoutCode forValue(byte value) { - return getMappings().get(value); + return mappings().get(value); } - private static java.util.HashMap getMappings() { + private static Map mappings() { if (mappings == null) { synchronized (LayoutCode.class) { if (mappings == null) { - mappings = new java.util.HashMap(); + mappings = new HashMap(); } } } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java index a5ea7f9..be90949 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java @@ -12,7 +12,7 @@ public final class LayoutCodeTraits { * @param code The element type code. */ public static boolean AlwaysRequiresTypeCode(LayoutCode code) { - return (code == LayoutCode.Boolean) || (code == LayoutCode.BooleanFalse) || (code == LayoutCode.Null); + return (code == LayoutCode.BOOLEAN) || (code == LayoutCode.BOOLEAN_FALSE) || (code == LayoutCode.NULL); } /** @@ -25,7 +25,7 @@ public final class LayoutCodeTraits { * @param code The code to canonicalize. */ public static LayoutCode Canonicalize(LayoutCode code) { - return (code == LayoutCode.BooleanFalse) ? LayoutCode.Boolean : code; + return (code == LayoutCode.BOOLEAN_FALSE) ? LayoutCode.BOOLEAN : code; } /** @@ -37,6 +37,6 @@ public final class LayoutCodeTraits { //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] public static LayoutCode ClearImmutableBit // (LayoutCode code) public static LayoutCode ClearImmutableBit(LayoutCode code) { - return code.getValue() & LayoutCode.forValue((byte)0xFE).getValue(); + return code.value() & LayoutCode.forValue((byte)0xFE).value(); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java index 040bf60..3395163 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java @@ -7,8 +7,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Utf8String; import com.azure.data.cosmos.serialization.hybridrow.schemas.StorageKind; -import static com.google.common.base.Strings.lenientFormat; - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: //ORIGINAL LINE: [DebuggerDisplay("{FullPath + \": \" + Type.Name + TypeArgs.ToString()}")] public sealed class // LayoutColumn @@ -107,7 +105,7 @@ public final class LayoutColumn { this.offset = offset; this.nullBit = nullBit.clone(); this.boolBit = boolBit.clone(); - this.size = this.typeArg.getType().getIsFixed() ? type.Size : length; + this.size = this.typeArg.type().getIsFixed() ? type.Size : length; } /** @@ -187,7 +185,7 @@ public final class LayoutColumn { // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: //ORIGINAL LINE: [DebuggerHidden] public T TypeAs() where T : ILayoutType public T TypeAs() { - return this.type.TypeAs(); + return this.type.typeAs(); } /** @@ -230,13 +228,13 @@ public final class LayoutColumn { private static String GetFullPath(LayoutColumn parent, String path) { if (parent != null) { switch (LayoutCodeTraits.ClearImmutableBit(parent.type.LayoutCode)) { - case ObjectScope: - case Schema: + case OBJECT_SCOPE: + case SCHEMA: return parent.getFullPath().toString() + "." + path; - case ArrayScope: - case TypedArrayScope: - case TypedSetScope: - case TypedMapScope: + case ARRAY_SCOPE: + case TYPED_ARRAY_SCOPE: + case TYPED_SET_SCOPE: + case TYPED_MAP_SCOPE: return parent.getFullPath().toString() + "[]" + path; default: throw new IllegalStateException(lenientFormat("Parent scope type not supported: %s", parent.type.LayoutCode)); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java index 4f070f7..0c8298a 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java @@ -44,7 +44,7 @@ public final class LayoutCompiler { checkArgument(ns.getSchemas().contains(schema)); LayoutBuilder builder = new LayoutBuilder(schema.getName(), schema.getSchemaId().clone()); - LayoutCompiler.AddProperties(builder, ns, LayoutCode.Schema, schema.getProperties()); + LayoutCompiler.AddProperties(builder, ns, LayoutCode.SCHEMA, schema.getProperties()); return builder.Build(); } @@ -58,7 +58,7 @@ public final class LayoutCompiler { LayoutType type = LayoutCompiler.LogicalToPhysicalType(ns, p.getPropertyType(), tempOut_typeArgs); typeArgs = tempOut_typeArgs.get(); switch (LayoutCodeTraits.ClearImmutableBit(type.LayoutCode)) { - case ObjectScope: { + case OBJECT_SCOPE: { if (!p.getPropertyType().getNullable()) { throw new LayoutCompilationException("Non-nullable sparse column are not supported."); } @@ -70,17 +70,17 @@ public final class LayoutCompiler { break; } - case ArrayScope: - case TypedArrayScope: - case SetScope: - case TypedSetScope: - case MapScope: - case TypedMapScope: - case TupleScope: - case TypedTupleScope: - case TaggedScope: - case Tagged2Scope: - case Schema: { + case ARRAY_SCOPE: + case TYPED_ARRAY_SCOPE: + case SET_SCOPE: + case TYPED_SET_SCOPE: + case MAP_SCOPE: + case TYPED_MAP_SCOPE: + case TUPLE_SCOPE: + case TYPED_TUPLE_SCOPE: + case TAGGED_SCOPE: + case TAGGED2_SCOPE: + case SCHEMA: { if (!p.getPropertyType().getNullable()) { throw new LayoutCompilationException("Non-nullable sparse column are not supported."); } @@ -89,7 +89,7 @@ public final class LayoutCompiler { break; } - case NullableScope: { + case NULLABLE_SCOPE: { throw new LayoutCompilationException("Nullables cannot be explicitly declared as columns."); } @@ -100,7 +100,7 @@ public final class LayoutCompiler { if (pp != null) { switch (pp.getStorage()) { case Fixed: - if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.Schema) { + if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) { throw new LayoutCompilationException("Cannot have fixed storage within a sparse " + "scope."); } @@ -113,7 +113,7 @@ public final class LayoutCompiler { builder.AddFixedColumn(p.getPath(), type, pp.getNullable(), pp.getLength()); break; case Variable: - if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.Schema) { + if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) { throw new LayoutCompilationException("Cannot have variable storage within a " + "sparse scope."); } @@ -150,7 +150,7 @@ public final class LayoutCompiler { private static LayoutType LogicalToPhysicalType(Namespace ns, PropertyType logicalType, Out typeArgs) { - typeArgs.setAndGet(TypeArgumentList.Empty); + typeArgs.setAndGet(TypeArgumentList.EMPTY); boolean tempVar = (logicalType instanceof ScopePropertyType ? (ScopePropertyType)logicalType : null).getImmutable(); boolean immutable = @@ -313,7 +313,7 @@ public final class LayoutCompiler { } TypeArgument[] tgArgs = new TypeArgument[tg.getItems().size() + 1]; - tgArgs[0] = new TypeArgument(LayoutType.UInt8, TypeArgumentList.Empty); + tgArgs[0] = new TypeArgument(LayoutType.UInt8, TypeArgumentList.EMPTY); for (int i = 0; i < tg.getItems().size(); i++) { TypeArgumentList itemTypeArgs = new TypeArgumentList(); Out tempOut_itemTypeArgs4 = new Out(); @@ -342,7 +342,7 @@ public final class LayoutCompiler { case Schema: UdtPropertyType up = (UdtPropertyType)logicalType; Schema udtSchema; - if (SchemaId.opEquals(up.getSchemaId().clone(), SchemaId.Invalid)) { + if (SchemaId.opEquals(up.getSchemaId().clone(), SchemaId.INVALID)) { udtSchema = tangible.ListHelper.find(ns.getSchemas(), s = up.getName().equals( > s.Name)) } else { udtSchema = tangible.ListHelper.find(ns.getSchemas(), s = diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java index 283a8c5..20fa66b 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java @@ -16,36 +16,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutDateTime extends LayoutType { public LayoutDateTime() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.DateTime, 8); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.DATE_TIME, 8); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "datetime"; } @Override public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(LocalDateTime.MIN); return Result.NotFound; } - value.setAndGet(b.get().ReadDateTime(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadDateTime(scope.get().start() + col.getOffset())); return Result.Success; } @Override public Result ReadSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(LocalDateTime.MIN); return result; @@ -58,23 +56,22 @@ public final class LayoutDateTime extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, LocalDateTime value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteDateTime(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteDateTime(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, DateTime value, // UpdateOptions options = UpdateOptions.Upsert) - @Override - public Result WriteSparse(Reference b, Reference edit, + public Result writeSparse(Reference b, Reference edit, LocalDateTime value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -84,7 +81,7 @@ public final class LayoutDateTime extends LayoutType { } @Override - public Result WriteSparse(Reference b, Reference edit, DateTime value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(Reference b, Reference edit, DateTime value) { + return writeSparse(b, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java index 29388d6..f6becb7 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java @@ -17,36 +17,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutDecimal extends LayoutType { public LayoutDecimal() { // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Decimal, sizeof(BigDecimal)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.DECIMAL, sizeof(BigDecimal)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "decimal"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(new BigDecimal(0)); return Result.NotFound; } - value.setAndGet(b.get().ReadDecimal(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadDecimal(scope.get().start() + col.getOffset())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(new BigDecimal(0)); return result; @@ -57,15 +55,15 @@ public final class LayoutDecimal extends LayoutType { } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, + public Result writeFixed(Reference b, Reference scope, LayoutColumn col, BigDecimal value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteDecimal(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteDecimal(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -73,9 +71,9 @@ public final class LayoutDecimal extends LayoutType { //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, decimal value, // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, BigDecimal value, + public Result writeSparse(Reference b, Reference edit, BigDecimal value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -85,8 +83,8 @@ public final class LayoutDecimal extends LayoutType { } @Override - public Result WriteSparse(Reference b, Reference edit, + public Result writeSparse(Reference b, Reference edit, java.math.BigDecimal value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + return writeSparse(b, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java index 1b09922..f224714 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java @@ -16,12 +16,11 @@ public final class LayoutEndScope extends LayoutScope { // following line: //ORIGINAL LINE: base(LayoutCode.EndScope, false, isSizedScope: false, isIndexedScope: false, isFixedArity: // false, isUniqueScope: false, isTypedScope: false); - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.EndScope, false, isSizedScope:false, isIndexedScope:false, isFixedArity:false, isUniqueScope: - false, isTypedScope:false) + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.END_SCOPE, false, isSizedScope():false, isIndexedScope():false, isFixedArity():false, isUniqueScope(): + false, isTypedScope():false) } - @Override - public String getName() { + public String name() { return "end"; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java index 19211df..5314e08 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java @@ -15,36 +15,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutFloat128 extends LayoutType { public LayoutFloat128() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Float128, HybridRow.Float128.Size); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.FLOAT_128, HybridRow.Float128.Size); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "float128"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(null); return Result.NotFound; } - value.setAndGet(b.get().ReadFloat128(scope.get().start + col.getOffset()).clone()); + value.setAndGet(b.get().ReadFloat128(scope.get().start() + col.getOffset()).clone()); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(null); return result; @@ -55,15 +53,15 @@ public final class LayoutFloat128 extends LayoutType b, Reference scope, LayoutColumn col, + public Result writeFixed(Reference b, Reference scope, LayoutColumn col, Float128 value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteFloat128(scope.get().start + col.getOffset(), value.clone()); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteFloat128(scope.get().start() + col.getOffset(), value.clone()); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -71,9 +69,9 @@ public final class LayoutFloat128 extends LayoutType b, Reference edit, Float128 value, + public Result writeSparse(Reference b, Reference edit, Float128 value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -83,7 +81,7 @@ public final class LayoutFloat128 extends LayoutType b, Reference edit, Float128 value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(Reference b, Reference edit, Float128 value) { + return writeSparse(b, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java index 040cf28..c4386b9 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java @@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutFloat32 extends LayoutType { public LayoutFloat32() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Float32, (Float.SIZE / Byte.SIZE)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.FLOAT_32, (Float.SIZE / Byte.SIZE)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "float32"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadFloat32(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadFloat32(scope.get().start() + col.getOffset())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -56,13 +54,13 @@ public final class LayoutFloat32 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, float value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteFloat32(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteFloat32(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -72,7 +70,7 @@ public final class LayoutFloat32 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, float value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java index 2bce34a..09482d1 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java @@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutFloat64 extends LayoutType { public LayoutFloat64() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Float64, (Double.SIZE / Byte.SIZE)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.FLOAT_64, (Double.SIZE / Byte.SIZE)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "float64"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadFloat64(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadFloat64(scope.get().start() + col.getOffset())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -56,13 +54,13 @@ public final class LayoutFloat64 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, double value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteFloat64(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteFloat64(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -72,7 +70,7 @@ public final class LayoutFloat64 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, double value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java index 3a570e6..b8caf1d 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java @@ -16,36 +16,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutGuid extends LayoutType { public LayoutGuid() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Guid, 16); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.GUID, 16); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "guid"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(null); return Result.NotFound; } - value.setAndGet(b.get().ReadGuid(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadGuid(scope.get().start() + col.getOffset())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(null); return result; @@ -56,15 +54,15 @@ public final class LayoutGuid extends LayoutType { } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, + public Result writeFixed(Reference b, Reference scope, LayoutColumn col, UUID value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteGuid(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteGuid(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -72,9 +70,9 @@ public final class LayoutGuid extends LayoutType { //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, Guid value, // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, UUID value, + public Result writeSparse(Reference b, Reference edit, UUID value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -84,8 +82,8 @@ public final class LayoutGuid extends LayoutType { } @Override - public Result WriteSparse(Reference b, Reference edit, + public Result writeSparse(Reference b, Reference edit, java.util.UUID value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + return writeSparse(b, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java index 67a0384..ff8d4f2 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java @@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutInt16 extends LayoutType { public LayoutInt16() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int16, (Short.SIZE / Byte.SIZE)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_16, (Short.SIZE / Byte.SIZE)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "int16"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadInt16(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadInt16(scope.get().start() + col.getOffset())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -56,13 +54,13 @@ public final class LayoutInt16 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, short value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteInt16(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteInt16(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -72,7 +70,7 @@ public final class LayoutInt16 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, short value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java index 0f7d8a3..eb19ee5 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java @@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutInt32 extends LayoutType { public LayoutInt32() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int32, (Integer.SIZE / Byte.SIZE)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_32, (Integer.SIZE / Byte.SIZE)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "int32"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadInt32(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadInt32(scope.get().start() + col.getOffset())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -56,13 +54,13 @@ public final class LayoutInt32 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, int value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteInt32(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteInt32(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -72,7 +70,7 @@ public final class LayoutInt32 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, int value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java index ca6cfb4..4230b98 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java @@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutInt64 extends LayoutType { public LayoutInt64() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int64, (Long.SIZE / Byte.SIZE)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_64, (Long.SIZE / Byte.SIZE)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "int64"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadInt64(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadInt64(scope.get().start() + col.getOffset())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -56,13 +54,13 @@ public final class LayoutInt64 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, long value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteInt64(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteInt64(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -72,7 +70,7 @@ public final class LayoutInt64 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, long value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java index 1d70dc0..d698ab5 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java @@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutInt8 extends LayoutType { public LayoutInt8() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int8, (Byte.SIZE / Byte.SIZE)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_8, (Byte.SIZE / Byte.SIZE)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "int8"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadInt8(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadInt8(scope.get().start() + col.getOffset())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -56,13 +54,13 @@ public final class LayoutInt8 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, byte value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteInt8(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteInt8(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -72,7 +70,7 @@ public final class LayoutInt8 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, byte value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java index dab475e..97ed8da 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java @@ -14,37 +14,35 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutMongoDbObjectId extends LayoutType { public LayoutMongoDbObjectId() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.MongoDbObjectId, azure.data.cosmos.serialization.hybridrow.MongoDbObjectId.Size); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.MONGODB_OBJECT_ID, azure.data.cosmos.serialization.hybridrow.MongoDbObjectId.Size); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } // ReSharper disable once StringLiteralTypo - @Override - public String getName() { + public String name() { return "mongodbobjectid"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(null); return Result.NotFound; } - value.setAndGet(b.get().ReadMongoDbObjectId(scope.get().start + col.getOffset()).clone()); + value.setAndGet(b.get().ReadMongoDbObjectId(scope.get().start() + col.getOffset()).clone()); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(null); return result; @@ -55,15 +53,15 @@ public final class LayoutMongoDbObjectId extends LayoutType { } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, + public Result writeFixed(Reference b, Reference scope, LayoutColumn col, MongoDbObjectId value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteMongoDbObjectId(scope.get().start + col.getOffset(), value.clone()); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteMongoDbObjectId(scope.get().start() + col.getOffset(), value.clone()); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -71,9 +69,9 @@ public final class LayoutMongoDbObjectId extends LayoutType { //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, MongoDbObjectId value, // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, + public Result writeSparse(Reference b, Reference edit, MongoDbObjectId value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -83,8 +81,8 @@ public final class LayoutMongoDbObjectId extends LayoutType { } @Override - public Result WriteSparse(Reference b, Reference edit, + public Result writeSparse(Reference b, Reference edit, MongoDbObjectId value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + return writeSparse(b, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java index fdc1bbb..40c467b 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java @@ -15,30 +15,27 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutNull extends LayoutType { public LayoutNull() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Null, 0); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.NULL, 0); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public boolean getIsNull() { + public boolean isNull() { return true; } - @Override - public String getName() { + public String name() { return "null"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); + checkArgument(scope.get().scopeType() instanceof LayoutUDT); value.setAndGet(NullValue.Default); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { return Result.NotFound; } @@ -46,9 +43,9 @@ public final class LayoutNull extends LayoutType { } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(null); return result; @@ -59,14 +56,14 @@ public final class LayoutNull extends LayoutType { } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, + public Result writeFixed(Reference b, Reference scope, LayoutColumn col, NullValue value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -74,9 +71,9 @@ public final class LayoutNull extends LayoutType { //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, NullValue value, // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, NullValue value, + public Result writeSparse(Reference b, Reference edit, NullValue value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -86,7 +83,7 @@ public final class LayoutNull extends LayoutType { } @Override - public Result WriteSparse(Reference b, Reference edit, NullValue value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(Reference b, Reference edit, NullValue value) { + return writeSparse(b, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java index fba4b1b..0e5f281 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java @@ -15,48 +15,46 @@ import static com.google.common.base.Preconditions.checkState; public final class LayoutNullable extends LayoutIndexedScope { public LayoutNullable(boolean immutable) { - super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableNullableScope : - com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.NullableScope, immutable, true, true, false, true); + super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_NULLABLE_SCOPE : + com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.NULLABLE_SCOPE, immutable, true, true, false, true); } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_nullable" : "nullable"; } - @Override - public int CountTypeArgument(TypeArgumentList value) { - checkState(value.getCount() == 1); - return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone()); + public int countTypeArgument(TypeArgumentList value) { + checkState(value.count() == 1); + return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).type().CountTypeArgument(value.get(0).typeArgs().clone()); } @Override public boolean HasImplicitTypeCode(Reference edit) { - checkState(edit.get().index >= 0); - checkState(edit.get().scopeTypeArgs.getCount() == 1); - checkState(edit.get().index == 1); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(0).getType().LayoutCode); + checkState(edit.get().index() >= 0); + checkState(edit.get().scopeTypeArgs().count() == 1); + checkState(edit.get().index() == 1); + return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode); } public static Result HasValue(Reference b, Reference scope) { - checkArgument(scope.get().scopeType instanceof LayoutNullable); - checkState(scope.get().index == 1 || scope.get().index == 2, "Nullable scopes always point at the value"); - checkState(scope.get().scopeTypeArgs.getCount() == 1); - boolean hasValue = b.get().ReadInt8(scope.get().start) != 0; + checkArgument(scope.get().scopeType() instanceof LayoutNullable); + checkState(scope.get().index() == 1 || scope.get().index() == 2, "Nullable scopes always point at the value"); + checkState(scope.get().scopeTypeArgs().count() == 1); + boolean hasValue = b.get().ReadInt8(scope.get().start()) != 0; return hasValue ? Result.Success : Result.NotFound; } @Override - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { - return new TypeArgumentList(new TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) }); + return new TypeArgumentList(new TypeArgument[] { LayoutType.readTypeArgument(row, offset, lenInBytes) }); } @Override public void SetImplicitTypeCode(Reference edit) { - checkState(edit.get().index == 1); - edit.get().cellType = edit.get().scopeTypeArgs.get(0).getType(); - edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone(); + checkState(edit.get().index() == 1); + edit.get().cellType = edit.get().scopeTypeArgs().get(0).type(); + edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone(); } public Result WriteScope(Reference b, Reference edit, @@ -70,7 +68,7 @@ public final class LayoutNullable extends LayoutIndexedScope { public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, boolean hasValue, Out value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); return result; @@ -96,12 +94,12 @@ public final class LayoutNullable extends LayoutIndexedScope { } @Override - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { - checkState(value.getCount() == 1); + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { + checkState(value.count() == 1); row.get().WriteSparseTypeCode(offset, this.LayoutCode); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); - lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes, - value.get(0).getTypeArgs().clone()); + lenInBytes += value.get(0).type().writeTypeArgument(row, offset + lenInBytes, + value.get(0).typeArgs().clone()); return lenInBytes; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java index 5db5c59..e7e7851 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java @@ -14,17 +14,16 @@ public final class LayoutObject extends LayoutPropertyScope { private TypeArgument TypeArg = new TypeArgument(); public LayoutObject(boolean immutable) { - super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableObjectScope : - com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ObjectScope, immutable); + super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_OBJECT_SCOPE : + com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.OBJECT_SCOPE, immutable); this.TypeArg = new TypeArgument(this); } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_object" : "object"; } - public TypeArgument getTypeArg() { + public TypeArgument typeArg() { return TypeArg; } @@ -41,7 +40,7 @@ public final class LayoutObject extends LayoutPropertyScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { value.setAndGet(null); return result; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java index e043b6b..f1eb410 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java @@ -50,7 +50,7 @@ public final class LayoutResolverNamespace extends LayoutResolver { // ConcurrentDictionary method: // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: - if (this.layoutCache.TryGetValue(schemaId.getId(), out layout)) { + if (this.layoutCache.TryGetValue(schemaId.id(), out layout)) { return layout; } @@ -58,7 +58,7 @@ public final class LayoutResolverNamespace extends LayoutResolver { if (SchemaId.opEquals(s.getSchemaId().clone(), schemaId.clone())) { layout = s.Compile(this.schemaNamespace); - layout = this.layoutCache.putIfAbsent(schemaId.getId(), layout); + layout = this.layoutCache.putIfAbsent(schemaId.id(), layout); return layout; } } @@ -67,7 +67,7 @@ public final class LayoutResolverNamespace extends LayoutResolver { if (layout != null) { // TODO: C# TO JAVA CONVERTER: There is no Java ConcurrentHashMap equivalent to this .NET // ConcurrentDictionary method: - boolean succeeded = this.layoutCache.TryAdd(schemaId.getId(), layout); + boolean succeeded = this.layoutCache.TryAdd(schemaId.id(), layout); checkState(succeeded); return layout; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java index a264340..7b8bb08 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java @@ -13,51 +13,70 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions; import sun.reflect.generics.reflectiveObjects.NotImplementedException; public abstract class LayoutScope extends LayoutType { - /** - * Returns true if this is a fixed arity scope. - */ - public boolean IsFixedArity; - /** - * Returns true if this is an indexed scope. - */ - public boolean IsIndexedScope; - /** - * Returns true if this is a sized scope. - */ - public boolean IsSizedScope; - /** - * Returns true if this is a typed scope. - */ - public boolean IsTypedScope; - /** - * Returns true if the scope's elements cannot be updated directly. - */ - public boolean IsUniqueScope; + + private boolean isFixedArity; + private boolean isIndexedScope; + private boolean isSizedScope; + private boolean isTypedScope; + private boolean isUniqueScope; protected LayoutScope( LayoutCode code, boolean immutable, boolean isSizedScope, boolean isIndexedScope, boolean isFixedArity, boolean isUniqueScope, boolean isTypedScope ) { super(code, immutable, 0); - this.IsSizedScope = isSizedScope; - this.IsIndexedScope = isIndexedScope; - this.IsFixedArity = isFixedArity; - this.IsUniqueScope = isUniqueScope; - this.IsTypedScope = isTypedScope; + + this.isSizedScope = isSizedScope; + this.isIndexedScope = isIndexedScope; + this.isFixedArity = isFixedArity; + this.isUniqueScope = isUniqueScope; + this.isTypedScope = isTypedScope; } - @Override - public final boolean getIsFixed() { - return false; + /** + * Returns true if this is a fixed arity scope. + */ + public boolean isFixedArity() { + return this.isFixedArity; + } + + /** + * Returns true if this is an indexed scope. + */ + public boolean isIndexedScope() { + return this.isIndexedScope; + } + + /** + * Returns true if this is a sized scope. + */ + public boolean isSizedScope() { + return this.isSizedScope; + } + + /** + * Returns true if this is a typed scope. + */ + public boolean isTypedScope() { + return this.isTypedScope; + } + + /** + * Returns true if the scope's elements cannot be updated directly. + */ + public boolean isUniqueScope() { + return this.isUniqueScope; } public final Result DeleteScope(Reference b, Reference edit) { - Result result = LayoutType.PrepareSparseDelete(b, edit, this.LayoutCode); + + Result result = LayoutType.prepareSparseDelete(b, edit, this.LayoutCode); + if (result != Result.Success) { return result; } - b.get().DeleteSparse(edit); + b.get().deleteSparse(edit); return Result.Success; } @@ -72,16 +91,18 @@ public abstract class LayoutScope extends LayoutType { return false; } - public final Result ReadScope(Reference b, Reference edit, - Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + public final Result ReadScope(Reference b, Reference edit, Out value) { + + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + if (result != Result.Success) { value.setAndGet(null); return result; } value.setAndGet(b.get().SparseIteratorReadScope(edit, - this.Immutable || edit.get().immutable || edit.get().scopeType.IsUniqueScope).clone()); + this.Immutable || edit.get().immutable() || edit.get().scopeType().isUniqueScope()).clone()); + return Result.Success; } @@ -89,10 +110,10 @@ public abstract class LayoutScope extends LayoutType { int pathLenInBytes; Out tempOut_pathLenInBytes = new Out(); Out tempOut_pathOffset = new Out(); - edit.get().pathToken = row.get().ReadSparsePathLen(edit.get().layout, edit.get().valueOffset, tempOut_pathLenInBytes, tempOut_pathOffset); - edit.get().argValue.pathOffset = tempOut_pathOffset.get(); + edit.get().pathToken = row.get().ReadSparsePathLen(edit.get().layout(), edit.get().valueOffset(), tempOut_pathLenInBytes, tempOut_pathOffset); + edit.get().pathOffset = tempOut_pathOffset.get(); pathLenInBytes = tempOut_pathLenInBytes.get(); - edit.get().valueOffset += pathLenInBytes; + edit.get().valueOffset(edit.get().valueOffset() + pathLenInBytes); } public void SetImplicitTypeCode(Reference edit) { diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java index 6d29803..a019a75 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java @@ -10,45 +10,43 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTaggedScope; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TaggedScope; +import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TAGGED_SCOPE; +import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TAGGED_SCOPE; public final class LayoutTagged extends LayoutIndexedScope { public LayoutTagged(boolean immutable) { - super(immutable ? ImmutableTaggedScope : TaggedScope, immutable, true, true, false, true); + super(immutable ? IMMUTABLE_TAGGED_SCOPE : TAGGED_SCOPE, immutable, true, true, false, true); } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_tagged_t" : "tagged_t"; } - @Override - public int CountTypeArgument(TypeArgumentList value) { - checkState(value.getCount() == 2); - return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(1).getType().CountTypeArgument(value.get(1).getTypeArgs().clone()); + public int countTypeArgument(TypeArgumentList value) { + checkState(value.count() == 2); + return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(1).type().CountTypeArgument(value.get(1).typeArgs().clone()); } @Override public boolean HasImplicitTypeCode(Reference edit) { - checkArgument(edit.get().index >= 0); - checkArgument(edit.get().scopeTypeArgs.getCount() > edit.get().index); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(edit.get().index).getType().LayoutCode); + checkArgument(edit.get().index() >= 0); + checkArgument(edit.get().scopeTypeArgs().count() > edit.get().index()); + return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode); } @Override - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { TypeArgument[] retval = new TypeArgument[2]; - retval[0] = new TypeArgument(UInt8, TypeArgumentList.Empty); - retval[1] = ReadTypeArgument(row, offset, lenInBytes); + retval[0] = new TypeArgument(UInt8, TypeArgumentList.EMPTY); + retval[1] = readTypeArgument(row, offset, lenInBytes); return new TypeArgumentList(retval); } @Override public void SetImplicitTypeCode(Reference edit) { - edit.get().cellType = edit.get().scopeTypeArgs.get(edit.get().index).getType(); - edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(edit.get().index).getTypeArgs().clone(); + edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type(); + edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone(); } @Override @@ -63,7 +61,7 @@ public final class LayoutTagged extends LayoutIndexedScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); return result; @@ -74,12 +72,12 @@ public final class LayoutTagged extends LayoutIndexedScope { } @Override - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { - checkArgument(value.getCount() == 2); + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { + checkArgument(value.count() == 2); row.get().WriteSparseTypeCode(offset, this.LayoutCode); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); - lenInBytes += value.get(1).getType().WriteTypeArgument(row, offset + lenInBytes, - value.get(1).getTypeArgs().clone()); + lenInBytes += value.get(1).type().writeTypeArgument(row, offset + lenInBytes, + value.get(1).typeArgs().clone()); return lenInBytes; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java index 81f1e06..0b158ce 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java @@ -12,23 +12,21 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursor; public final class LayoutTagged2 extends LayoutIndexedScope { public LayoutTagged2(boolean immutable) { - super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTagged2Scope : - com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Tagged2Scope, immutable, isSizedScope: - true, isFixedArity:true, isUniqueScope:false, isTypedScope:true) + super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TAGGED2_SCOPE : + com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TAGGED2_SCOPE, immutable, isSizedScope(): + true, isFixedArity():true, isUniqueScope():false, isTypedScope():true) } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_tagged2_t" : "tagged2_t"; } - @Override - public int CountTypeArgument(TypeArgumentList value) { - checkState(value.getCount() == 3); + public int countTypeArgument(TypeArgumentList value) { + checkState(value.count() == 3); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); - for (int i = 1; i < value.getCount(); i++) { + for (int i = 1; i < value.count(); i++) { TypeArgument arg = value.get(i).clone(); - lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone()); + lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone()); } return lenInBytes; @@ -36,21 +34,21 @@ public final class LayoutTagged2 extends LayoutIndexedScope { @Override public boolean HasImplicitTypeCode(Reference edit) { - checkState(edit.get().index >= 0); - checkState(edit.get().scopeTypeArgs.getCount() > edit.get().index); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(edit.get().index).getType().LayoutCode); + checkState(edit.get().index() >= 0); + checkState(edit.get().scopeTypeArgs().count() > edit.get().index()); + return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode); } @Override - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { lenInBytes.setAndGet(0); TypeArgument[] retval = new TypeArgument[3]; - retval[0] = new TypeArgument(UInt8, TypeArgumentList.Empty); + retval[0] = new TypeArgument(UInt8, TypeArgumentList.EMPTY); for (int i = 1; i < 3; i++) { int itemLenInBytes; Out tempOut_itemLenInBytes = new Out(); - retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); + retval[i] = readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); } @@ -60,8 +58,8 @@ public final class LayoutTagged2 extends LayoutIndexedScope { @Override public void SetImplicitTypeCode(Reference edit) { - edit.get().cellType = edit.get().scopeTypeArgs.get(edit.get().index).getType(); - edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(edit.get().index).getTypeArgs().clone(); + edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type(); + edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone(); } @Override @@ -76,7 +74,7 @@ public final class LayoutTagged2 extends LayoutIndexedScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); return result; @@ -87,13 +85,13 @@ public final class LayoutTagged2 extends LayoutIndexedScope { } @Override - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { - checkState(value.getCount() == 3); + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { + checkState(value.count() == 3); row.get().WriteSparseTypeCode(offset, this.LayoutCode); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); - for (int i = 1; i < value.getCount(); i++) { + for (int i = 1; i < value.count(); i++) { TypeArgument arg = value.get(i).clone(); - lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone()); + lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone()); } return lenInBytes; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java index 6413762..a1c9e79 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java @@ -10,41 +10,39 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTupleScope; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TupleScope; +import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TUPLE_SCOPE; +import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TUPLE_SCOPE; public final class LayoutTuple extends LayoutIndexedScope { public LayoutTuple(boolean immutable) { - super(immutable ? ImmutableTupleScope : TupleScope, immutable, false, true, false, false); + super(immutable ? IMMUTABLE_TUPLE_SCOPE : TUPLE_SCOPE, immutable, false, true, false, false); } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_tuple" : "tuple"; } - @Override - public int CountTypeArgument(TypeArgumentList value) { + public int countTypeArgument(TypeArgumentList value) { int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count); - lenInBytes += RowBuffer.Count7BitEncodedUInt(value.getCount()); + lenInBytes += RowBuffer.Count7BitEncodedUInt(value.count()); for (TypeArgument arg : value) { - lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone()); + lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone()); } return lenInBytes; } @Override - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes); TypeArgument[] retval = new TypeArgument[numTypeArgs]; for (int i = 0; i < numTypeArgs; i++) { int itemLenInBytes; Out tempOut_itemLenInBytes = new Out(); - retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); + retval[i] = readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); } @@ -64,7 +62,7 @@ public final class LayoutTuple extends LayoutIndexedScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); return result; @@ -75,14 +73,14 @@ public final class LayoutTuple extends LayoutIndexedScope { } @Override - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { row.get().WriteSparseTypeCode(offset, this.LayoutCode); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: lenInBytes += row.Write7BitEncodedUInt(offset + lenInBytes, (ulong)value.Count); - lenInBytes += row.get().Write7BitEncodedUInt(offset + lenInBytes, value.getCount()); + lenInBytes += row.get().Write7BitEncodedUInt(offset + lenInBytes, value.count()); for (TypeArgument arg : value) { - lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone()); + lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone()); } return lenInBytes; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java index 1689ccc..42cdeac 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java @@ -13,327 +13,171 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursor; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Strings.lenientFormat; -// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: -///#pragma warning disable SA1402 // FileMayOnlyContainASingleType -// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: -///#pragma warning disable SA1201 // Elements should appear in the correct order -// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: -///#pragma warning disable SA1401 // Fields should be private -// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: -///#pragma warning disable CA1040 // Avoid empty interfaces -// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: -///#pragma warning disable CA1051 // Do not declare visible instance fields - - /** - * The abstract base class for typed hybrid row field descriptors. - * {@link LayoutType} is immutable. + * Describes the physical byte layout of a hybrid row field of a specific physical type {@code T} + * + * {@link LayoutType} is an immutable, stateless, helper class. It provides methods for manipulating hybrid row + * fields of a particular type, and properties that describe the layout of fields of that type. + *

+ * {@param } The specific physical type whose byte layout is represented by this class. */ -// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: -//ORIGINAL LINE: [DebuggerDisplay("{" + nameof(LayoutType.Name) + "}")] public abstract class LayoutType : ILayoutType -public abstract class LayoutType implements ILayoutType { - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutArray Array = new LayoutArray(immutable: - // false); - public static final LayoutArray Array = new LayoutArray(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutBinary Binary = new LayoutBinary(); - public static final LayoutBinary Binary = new LayoutBinary(); - /** - * The number of bits in a single byte on the current architecture. - */ - public static final int BitsPerByte = 8; - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutBoolean Boolean = new LayoutBoolean(true); - public static final LayoutBoolean Boolean = new LayoutBoolean(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutBoolean BooleanFalse = new LayoutBoolean - // (false); - public static final LayoutBoolean BooleanFalse = new LayoutBoolean(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutDateTime DateTime = new LayoutDateTime(); - public static final LayoutDateTime DateTime = new LayoutDateTime(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutDecimal Decimal = new LayoutDecimal(); - public static final LayoutDecimal Decimal = new LayoutDecimal(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] internal static readonly LayoutEndScope EndScope = new LayoutEndScope(); - public static final LayoutEndScope EndScope = new LayoutEndScope(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutFloat128 Float128 = new LayoutFloat128(); - public static final LayoutFloat128 Float128 = new LayoutFloat128(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutFloat32 Float32 = new LayoutFloat32(); - public static final LayoutFloat32 Float32 = new LayoutFloat32(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutFloat64 Float64 = new LayoutFloat64(); - public static final LayoutFloat64 Float64 = new LayoutFloat64(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutArray ImmutableArray = new LayoutArray - // (immutable: true); - public static final LayoutArray ImmutableArray = new LayoutArray(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutNullable ImmutableNullable = new - // LayoutNullable(immutable: true); - public static final LayoutNullable ImmutableNullable = new LayoutNullable(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutObject ImmutableObject = new LayoutObject - // (immutable: true); - public static final LayoutObject ImmutableObject = new LayoutObject(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTagged ImmutableTagged = new LayoutTagged - // (immutable: true); - public static final LayoutTagged ImmutableTagged = new LayoutTagged(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTagged2 ImmutableTagged2 = new - // LayoutTagged2(immutable: true); - public static final LayoutTagged2 ImmutableTagged2 = new LayoutTagged2(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTuple ImmutableTuple = new LayoutTuple - // (immutable: true); - public static final LayoutTuple ImmutableTuple = new LayoutTuple(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTypedArray ImmutableTypedArray = new - // LayoutTypedArray(immutable: true); - public static final LayoutTypedArray ImmutableTypedArray = new LayoutTypedArray(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTypedMap ImmutableTypedMap = new - // LayoutTypedMap(immutable: true); - public static final LayoutTypedMap ImmutableTypedMap = new LayoutTypedMap(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTypedSet ImmutableTypedSet = new - // LayoutTypedSet(immutable: true); - public static final LayoutTypedSet ImmutableTypedSet = new LayoutTypedSet(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTypedTuple ImmutableTypedTuple = new - // LayoutTypedTuple(immutable: true); - public static final LayoutTypedTuple ImmutableTypedTuple = new LayoutTypedTuple(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUDT ImmutableUDT = new LayoutUDT - // (immutable: true); - public static final LayoutUDT ImmutableUDT = new LayoutUDT(true); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutInt16 Int16 = new LayoutInt16(); - public static final LayoutInt16 Int16 = new LayoutInt16(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutInt32 Int32 = new LayoutInt32(); - public static final LayoutInt32 Int32 = new LayoutInt32(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutInt64 Int64 = new LayoutInt64(); - public static final LayoutInt64 Int64 = new LayoutInt64(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutInt8 Int8 = new LayoutInt8(); - public static final LayoutInt8 Int8 = new LayoutInt8(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutMongoDbObjectId MongoDbObjectId = new - // LayoutMongoDbObjectId(); - public static final LayoutMongoDbObjectId MongoDbObjectId = new LayoutMongoDbObjectId(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutNull Null = new LayoutNull(); - public static final LayoutNull Null = new LayoutNull(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutNullable Nullable = new LayoutNullable - // (immutable: false); - public static final LayoutNullable Nullable = new LayoutNullable(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutObject Object = new LayoutObject - // (immutable: false); - public static final LayoutObject Object = new LayoutObject(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTagged Tagged = new LayoutTagged - // (immutable: false); - public static final LayoutTagged Tagged = new LayoutTagged(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTagged2 Tagged2 = new LayoutTagged2 - // (immutable: false); - public static final LayoutTagged2 Tagged2 = new LayoutTagged2(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTuple Tuple = new LayoutTuple(immutable: - // false); - public static final LayoutTuple Tuple = new LayoutTuple(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTypedArray TypedArray = new - // LayoutTypedArray(immutable: false); - public static final LayoutTypedArray TypedArray = new LayoutTypedArray(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTypedMap TypedMap = new LayoutTypedMap - // (immutable: false); - public static final LayoutTypedMap TypedMap = new LayoutTypedMap(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTypedSet TypedSet = new LayoutTypedSet - // (immutable: false); - public static final LayoutTypedSet TypedSet = new LayoutTypedSet(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutTypedTuple TypedTuple = new - // LayoutTypedTuple(immutable: false); - public static final LayoutTypedTuple TypedTuple = new LayoutTypedTuple(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUDT UDT = new LayoutUDT(immutable: false); - public static final LayoutUDT UDT = new LayoutUDT(false); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUInt16 UInt16 = new LayoutUInt16(); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUInt16 UInt16 = new LayoutUInt16(); - public static final LayoutUInt16 UInt16 = new LayoutUInt16(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUInt32 UInt32 = new LayoutUInt32(); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUInt32 UInt32 = new LayoutUInt32(); - public static final LayoutUInt32 UInt32 = new LayoutUInt32(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUInt64 UInt64 = new LayoutUInt64(); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUInt64 UInt64 = new LayoutUInt64(); - public static final LayoutUInt64 UInt64 = new LayoutUInt64(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUInt8 UInt8 = new LayoutUInt8(); - public static final LayoutUInt8 UInt8 = new LayoutUInt8(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutGuid Guid = new LayoutGuid(); - public static final LayoutGuid Guid = new LayoutGuid(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUnixDateTime UnixDateTime = new - // LayoutUnixDateTime(); - public static final LayoutUnixDateTime UnixDateTime = new LayoutUnixDateTime(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutUtf8 Utf8 = new LayoutUtf8(); - public static final LayoutUtf8 Utf8 = new LayoutUtf8(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutVarInt VarInt = new LayoutVarInt(); - public static final LayoutVarInt VarInt = new LayoutVarInt(); - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", - // Justification = "Type is immutable.")] public static readonly LayoutVarUInt VarUInt = new LayoutVarUInt(); - public static final LayoutVarUInt VarUInt = new LayoutVarUInt(); - private static final LayoutType[] CodeIndex = new LayoutType[com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.EndScope.getValue() + 1]; - /** - * If true, this edit's nested fields cannot be updated individually. - * The entire edit can still be replaced. - */ - public boolean Immutable; - /** - * The physical layout code used to represent the type within the serialization. - */ - public LayoutCode LayoutCode = com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.values()[0]; - /** - * If fixed, the fixed size of the type's serialization in bytes, otherwise undefined. - */ - public int Size; +public abstract class LayoutType implements ILayoutType { + + private static final LayoutType[] CodeIndex = new LayoutType[LayoutCode.END_SCOPE.value() + 1]; + + private final boolean immutable; + private final LayoutCode layoutCode; + private final int size; + private final TypeArgument typeArg; /** - * Initializes a new instance of the {@link LayoutType} class. + * Initializes a new instance of the {@link LayoutType} class. */ - public LayoutType(LayoutCode code, boolean immutable, int size) { - this.LayoutCode = code; - this.Immutable = immutable; - this.Size = size; - LayoutType.CodeIndex[code.getValue()] = this; + protected LayoutType(LayoutCode code, boolean immutable, int size) { + this.layoutCode = code; + this.immutable = immutable; + this.size = size; + this.typeArg = new TypeArgument(this); + CodeIndex[code.value()] = this; } /** - * True if this type can be used in the variable-length segment. + * Initializes a new instance of the {@link LayoutType} class. */ - public final boolean getAllowVariable() { - return !this.getIsFixed(); + protected LayoutType(LayoutCode code, int size) { + this(code, false, size); } /** * True if this type is a boolean. */ - public boolean getIsBool() { + public boolean isBoolean() { return false; } /** * True if this type is always fixed length. */ - public abstract boolean getIsFixed(); + public abstract boolean isFixed(); + + /** + * If true, this edit's nested fields cannot be updated individually. + * The entire edit can still be replaced. + */ + public boolean isImmutable() { + return immutable; + } /** * True if this type is a literal null. */ - public boolean getIsNull() { + public boolean isNull() { return false; } /** * True if this type is a variable-length encoded integer type (either signed or unsigned). */ - public boolean getIsVarint() { + public boolean isVarint() { return false; } + /** + * True if this type can be used in the variable-length segment. + */ + public final boolean allowVariable() { + return !this.isFixed(); + } + + public int countTypeArgument(TypeArgumentList value) { + return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); + } + + public final Result deleteFixed(Reference b, Reference scope, LayoutColumn col) { + + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + + if (scope.get().immutable()) { + return Result.InsufficientPermissions; + } + + if (col.getNullBit().getIsInvalid()) { + // Cannot delete a non-nullable fixed column. + return Result.TypeMismatch; + } + + b.get().UnsetBit(scope.get().start(), col.getNullBit().clone()); + return Result.Success; + } + + /** + * Delete an existing value. + *

+ * If a value exists, then it is removed. The remainder of the row is resized to accomodate + * a decrease in required space. If no value exists this operation is a no-op. + */ + public final Result deleteSparse(Reference b, Reference edit) { + + Result result = LayoutType.prepareSparseDelete(b, edit, this.layoutCode()); + + if (result != Result.Success) { + return result; + } + + b.get().deleteSparse(edit); + return Result.Success; + } + + /** + * Delete an existing value. + *

+ * If a value exists, then it is removed. The remainder of the row is resized to accommodate a decrease in + * required space. If no value exists this operation is a no-op. + */ + public final Result deleteVariable(Reference b, Reference scope, LayoutColumn col) { + + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + + if (scope.get().immutable()) { + return Result.InsufficientPermissions; + } + + boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit()); + + if (exists) { + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), + col.getOffset()); + b.get().DeleteVariable(varOffset, this.isVarint()); + b.get().UnsetBit(scope.get().start(), col.getNullBit().clone()); + } + + return Result.Success; + } + + public static LayoutType fromCode(LayoutCode code) { + LayoutType type = LayoutType.CodeIndex[code.value()]; + assert type != null : lenientFormat("Not Implemented: %s", code); + return type; + } + + public final Result hasValue(Reference b, Reference scope, LayoutColumn col) { + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { + return Result.NotFound; + } + return Result.Success; + } + + /** + * The physical layout code used to represent the type within the serialization. + */ + public LayoutCode layoutCode() { + return this.layoutCode; + } + /** * Human readable name of the type. */ - public abstract String getName(); - - public int CountTypeArgument(TypeArgumentList value) { - return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); - } - - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static LayoutType FromCode - // (LayoutCode code) - public static LayoutType FromCode(LayoutCode code) { - LayoutType type = LayoutType.CodeIndex[code.getValue()]; - // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: - //#if DEBUG - if (type == null) { - throw new IllegalStateException(lenientFormat("Not Implemented: %s", code)); - } - //#endif - - return type; - } + public abstract String name(); /** * Helper for preparing the delete of a sparse field. @@ -343,17 +187,16 @@ public abstract class LayoutType implements ILayoutType { * @param code The expected type of the field. * @return Success if the delete is permitted, the error code otherwise. */ - public static Result PrepareSparseDelete(Reference b, Reference edit, - LayoutCode code) { - if (edit.get().scopeType.IsFixedArity) { + public static Result prepareSparseDelete(Reference b, Reference edit, LayoutCode code) { + if (edit.get().scopeType().isFixedArity()) { return Result.TypeConstraint; } - if (edit.get().immutable) { + if (edit.get().immutable()) { return Result.InsufficientPermissions; } - if (edit.get().exists && LayoutCodeTraits.Canonicalize(edit.get().cellType.LayoutCode) != code) { + if (edit.get().exists && LayoutCodeTraits.Canonicalize(edit.get().cellType.layoutCode()) != code) { return Result.TypeMismatch; } @@ -373,16 +216,21 @@ public abstract class LayoutType implements ILayoutType { * @return Success if the move is permitted, the error code otherwise. * The source field is delete if the move prepare fails with a destination error. */ - public static Result PrepareSparseMove(Reference b, - Reference destinationScope, - LayoutScope destinationCode, TypeArgument elementType, - Reference srcEdit, UpdateOptions options, - Out dstEdit) { - checkArgument(destinationScope.get().scopeType == destinationCode); - checkArgument(destinationScope.get().index == 0, "Can only insert into a edit at the root"); + public static Result prepareSparseMove( + Reference b, + Reference destinationScope, + LayoutScope destinationCode, + TypeArgument elementType, + Reference srcEdit, + UpdateOptions options, + Out dstEdit + ) { + checkArgument(destinationScope.get().scopeType() == destinationCode); + checkArgument(destinationScope.get().index() == 0, "Can only insert into a edit at the root"); + + // Prepare the delete of the source + Result result = LayoutType.prepareSparseDelete(b, srcEdit, elementType.type().layoutCode()); - // Prepare the delete of the source. - Result result = LayoutType.PrepareSparseDelete(b, srcEdit, elementType.getType().LayoutCode); if (result != Result.Success) { dstEdit.setAndGet(null); return result; @@ -393,34 +241,34 @@ public abstract class LayoutType implements ILayoutType { return Result.NotFound; } - if (destinationScope.get().immutable) { - b.get().DeleteSparse(srcEdit); + if (destinationScope.get().immutable()) { + b.get().deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.InsufficientPermissions; } - if (!srcEdit.get().cellTypeArgs.equals(elementType.getTypeArgs().clone())) { - b.get().DeleteSparse(srcEdit); + if (!srcEdit.get().cellTypeArgs.equals(elementType.typeArgs())) { + b.get().deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.TypeConstraint; } if (options == UpdateOptions.InsertAt) { - b.get().DeleteSparse(srcEdit); + b.get().deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.TypeConstraint; } // Prepare the insertion at the destination. - dstEdit.setAndGet(b.get().PrepareSparseMove(destinationScope, srcEdit).clone()); + dstEdit.setAndGet(b.get().PrepareSparseMove(destinationScope, srcEdit)); if ((options == UpdateOptions.Update) && (!dstEdit.get().exists)) { - b.get().DeleteSparse(srcEdit); + b.get().deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.NotFound; } if ((options == UpdateOptions.Insert) && dstEdit.get().exists) { - b.get().DeleteSparse(srcEdit); + b.get().deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.Exists; } @@ -436,13 +284,13 @@ public abstract class LayoutType implements ILayoutType { * @param code The expected type of the field. * @return Success if the read is permitted, the error code otherwise. */ - public static Result PrepareSparseRead(Reference b, Reference edit, - LayoutCode code) { + public static Result prepareSparseRead(Reference b, Reference edit, LayoutCode code) { + if (!edit.get().exists) { return Result.NotFound; } - if (LayoutCodeTraits.Canonicalize(edit.get().cellType.LayoutCode) != code) { + if (LayoutCodeTraits.Canonicalize(edit.get().cellType.layoutCode()) != code) { return Result.TypeMismatch; } @@ -458,29 +306,29 @@ public abstract class LayoutType implements ILayoutType { * @param options The write options. * @return Success if the write is permitted, the error code otherwise. */ - public static Result PrepareSparseWrite(Reference b, Reference edit, + public static Result prepareSparseWrite(Reference b, Reference edit, TypeArgument typeArg, UpdateOptions options) { - if (edit.get().immutable || (edit.get().scopeType.IsUniqueScope && !edit.get().deferUniqueIndex)) { + if (edit.get().immutable() || (edit.get().scopeType().isUniqueScope() && !edit.get().deferUniqueIndex)) { return Result.InsufficientPermissions; } - if (edit.get().scopeType.IsFixedArity && !(edit.get().scopeType instanceof LayoutNullable)) { - if ((edit.get().index < edit.get().scopeTypeArgs.getCount()) && !typeArg.equals(edit.get().scopeTypeArgs.get(edit.get().index).clone())) { + if (edit.get().scopeType().isFixedArity() && !(edit.get().scopeType() instanceof LayoutNullable)) { + if ((edit.get().index() < edit.get().scopeTypeArgs().count()) && !typeArg.equals(edit.get().scopeTypeArgs().get(edit.get().index()))) { return Result.TypeConstraint; } - } else if (edit.get().scopeType instanceof LayoutTypedMap) { - if (!((typeArg.getType() instanceof LayoutTypedTuple) && typeArg.getTypeArgs().equals(edit.get().scopeTypeArgs.clone()))) { + } else if (edit.get().scopeType() instanceof LayoutTypedMap) { + if (!((typeArg.type() instanceof LayoutTypedTuple) && typeArg.typeArgs().equals(edit.get().scopeTypeArgs()))) { return Result.TypeConstraint; } - } else if (edit.get().scopeType.IsTypedScope && !typeArg.equals(edit.get().scopeTypeArgs.get(0).clone())) { + } else if (edit.get().scopeType().isTypedScope() && !typeArg.equals(edit.get().scopeTypeArgs().get(0))) { return Result.TypeConstraint; } - if ((options == UpdateOptions.InsertAt) && edit.get().scopeType.IsFixedArity) { + if ((options == UpdateOptions.InsertAt) && edit.get().scopeType().isFixedArity()) { return Result.TypeConstraint; } - if ((options == UpdateOptions.InsertAt) && !edit.get().scopeType.IsFixedArity) { + if ((options == UpdateOptions.InsertAt) && !edit.get().scopeType().isFixedArity()) { edit.get().exists = false; // InsertAt never overwrites an existing item. } @@ -495,34 +343,61 @@ public abstract class LayoutType implements ILayoutType { return Result.Success; } - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static TypeArgument ReadTypeArgument(ref RowBuffer row, int offset, out int lenInBytes) - public static TypeArgument ReadTypeArgument(Reference row, int offset, Out lenInBytes) { + public abstract Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value); + + public abstract Result readSparse(Reference b, Reference edit, Out value); + + public static TypeArgument readTypeArgument(Reference row, int offset, Out lenInBytes) { LayoutType itemCode = row.get().ReadSparseTypeCode(offset); int argsLenInBytes; Out tempOut_argsLenInBytes = new Out(); - TypeArgumentList itemTypeArgs = itemCode.ReadTypeArgumentList(row, offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), tempOut_argsLenInBytes).clone(); + TypeArgumentList itemTypeArgs = itemCode.readTypeArgumentList(row, offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), tempOut_argsLenInBytes); argsLenInBytes = tempOut_argsLenInBytes.get(); lenInBytes.setAndGet((com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + argsLenInBytes); - return new TypeArgument(itemCode, itemTypeArgs.clone()); + return new TypeArgument(itemCode, itemTypeArgs); } - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, Out lenInBytes) { + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { lenInBytes.setAndGet(0); - return TypeArgumentList.Empty; + return TypeArgumentList.EMPTY; + } + + public Result readVariable(Reference b, Reference scope, LayoutColumn col, Out value) { + value.setAndGet(null); + return Result.Failure; + } + + /** + * If fixed, the fixed size of the type's serialization in bytes, otherwise undefined. + */ + public int size() { + return size; } /** * The physical layout type of the field cast to the specified type. */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [DebuggerHidden] public T TypeAs() where T : ILayoutType - public final T TypeAs() { - return (T)this; + @SuppressWarnings("unchecked") + public final Value typeAs() { + return (Value)this; } - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { - row.get().WriteSparseTypeCode(offset, this.LayoutCode); + public abstract Result writeFixed(Reference b, Reference scope, LayoutColumn col, T value); + + public abstract Result writeSparse(Reference b, Reference edit, T value); + + public abstract Result writeSparse(Reference b, Reference edit, T value, UpdateOptions options); + + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { + row.get().WriteSparseTypeCode(offset, this.layoutCode()); return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); } -} \ No newline at end of file + + public Result writeVariable(Reference b, Reference scope, LayoutColumn col, T value) { + return Result.Failure; + } + + TypeArgument typeArg() { + return this.typeArg; + } +} diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType1.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType1.java deleted file mode 100644 index 03be1cb..0000000 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType1.java +++ /dev/null @@ -1,126 +0,0 @@ -//------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -//------------------------------------------------------------ - -package com.azure.data.cosmos.serialization.hybridrow.layouts; - -import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.serialization.hybridrow.Result; -import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; -import com.azure.data.cosmos.serialization.hybridrow.RowCursor; - -import static com.google.common.base.Preconditions.checkArgument; - -/** - * Describes the physical byte layout of a hybrid row field of a specific physical type - * . - * - * - * {@link LayoutType{T}} is an immutable, stateless, helper class. It provides - * methods for manipulating hybrid row fields of a particular type, and properties that describe the - * layout of fields of that type. - * - * {@link LayoutType{T}} is immutable. - */ -public abstract class LayoutType extends LayoutType { - private TypeArgument typeArg = new TypeArgument(); - - public LayoutType(LayoutCode code, int size) { - super(code, false, size); - this.typeArg = new TypeArgument(this); - } - - public final Result DeleteFixed(Reference b, Reference scope, - LayoutColumn col) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { - return Result.InsufficientPermissions; - } - - if (col.getNullBit().getIsInvalid()) { - // Cannot delete a non-nullable fixed column. - return Result.TypeMismatch; - } - - b.get().UnsetBit(scope.get().start, col.getNullBit().clone()); - return Result.Success; - } - - /** - * Delete an existing value. - *

- * If a value exists, then it is removed. The remainder of the row is resized to accomodate - * a decrease in required space. If no value exists this operation is a no-op. - */ - public final Result DeleteSparse(Reference b, Reference edit) { - Result result = LayoutType.PrepareSparseDelete(b, edit, this.LayoutCode); - if (result != Result.Success) { - return result; - } - - b.get().DeleteSparse(edit); - return Result.Success; - } - - /** - * Delete an existing value. - *

- * If a value exists, then it is removed. The remainder of the row is resized to accomodate - * a decrease in required space. If no value exists this operation is a no-op. - */ - public final Result DeleteVariable(Reference b, Reference scope, - LayoutColumn col) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { - return Result.InsufficientPermissions; - } - - boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); - if (exists) { - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, - col.getOffset()); - b.get().DeleteVariable(varOffset, this.getIsVarint()); - b.get().UnsetBit(scope.get().start, col.getNullBit().clone()); - } - - return Result.Success; - } - - public final Result HasValue(Reference b, Reference scope, - LayoutColumn col) { - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - return Result.NotFound; - } - - return Result.Success; - } - - public abstract Result ReadFixed(Reference b, Reference scope, - LayoutColumn col, Out value); - - public abstract Result ReadSparse(Reference b, Reference edit, Out value); - - public Result ReadVariable(Reference b, Reference scope, LayoutColumn col - , Out value) { - value.setAndGet(null); - return Result.Failure; - } - - public abstract Result WriteFixed(Reference b, Reference scope, - LayoutColumn col, T value); - - public abstract Result WriteSparse(Reference b, Reference edit, T value); - - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public abstract Result WriteSparse(ref RowBuffer b, ref RowCursor edit, T value, UpdateOptions - // options = UpdateOptions.Upsert); - public abstract Result WriteSparse(Reference b, Reference edit, T value, UpdateOptions options); - - public Result WriteVariable(Reference b, Reference scope, - LayoutColumn col, T value) { - return Result.Failure; - } - - abstract TypeArgument getTypeArg(); -} \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java index 45972f8..de9d445 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java @@ -12,38 +12,36 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursor; public final class LayoutTypedArray extends LayoutIndexedScope { public LayoutTypedArray(boolean immutable) { - super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedArrayScope : - com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedArrayScope, immutable, true, false, false, true); + super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_ARRAY_SCOPE : + com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_ARRAY_SCOPE, immutable, true, false, false, true); } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_array_t" : "array_t"; } - @Override - public int CountTypeArgument(TypeArgumentList value) { - checkState(value.getCount() == 1); - return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone()); + public int countTypeArgument(TypeArgumentList value) { + checkState(value.count() == 1); + return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).type().CountTypeArgument(value.get(0).typeArgs().clone()); } @Override public boolean HasImplicitTypeCode(Reference edit) { - checkState(edit.get().index >= 0); - checkState(edit.get().scopeTypeArgs.getCount() == 1); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(0).getType().LayoutCode); + checkState(edit.get().index() >= 0); + checkState(edit.get().scopeTypeArgs().count() == 1); + return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode); } @Override - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { - return new TypeArgumentList(new TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) }); + return new TypeArgumentList(new TypeArgument[] { LayoutType.readTypeArgument(row, offset, lenInBytes) }); } @Override public void SetImplicitTypeCode(Reference edit) { - edit.get().cellType = edit.get().scopeTypeArgs.get(0).getType(); - edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone(); + edit.get().cellType = edit.get().scopeTypeArgs().get(0).type(); + edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone(); } @Override @@ -58,7 +56,7 @@ public final class LayoutTypedArray extends LayoutIndexedScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); return result; @@ -69,12 +67,12 @@ public final class LayoutTypedArray extends LayoutIndexedScope { } @Override - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { - checkState(value.getCount() == 1); + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { + checkState(value.count() == 1); row.get().WriteSparseTypeCode(offset, this.LayoutCode); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); - lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes, - value.get(0).getTypeArgs().clone()); + lenInBytes += value.get(0).type().writeTypeArgument(row, offset + lenInBytes, + value.get(0).typeArgs().clone()); return lenInBytes; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java index f8b07ce..184c016 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java @@ -12,22 +12,20 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursor; public final class LayoutTypedMap extends LayoutUniqueScope { public LayoutTypedMap(boolean immutable) { - super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedMapScope : - com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedMapScope, immutable, isSizedScope: - true, isTypedScope:true) + super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_MAP_SCOPE : + com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_MAP_SCOPE, immutable, isSizedScope(): + true, isTypedScope():true) } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_map_t" : "map_t"; } - @Override - public int CountTypeArgument(TypeArgumentList value) { - checkState(value.getCount() == 2); + public int countTypeArgument(TypeArgumentList value) { + checkState(value.count() == 2); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); for (TypeArgument arg : value) { - lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone()); + lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone()); } return lenInBytes; @@ -35,8 +33,8 @@ public final class LayoutTypedMap extends LayoutUniqueScope { @Override public TypeArgument FieldType(Reference scope) { - return new TypeArgument(scope.get().scopeType.Immutable ? ImmutableTypedTuple : - TypedTuple, scope.get().scopeTypeArgs.clone()); + return new TypeArgument(scope.get().scopeType().Immutable ? ImmutableTypedTuple : + TypedTuple, scope.get().scopeTypeArgs().clone()); } @Override @@ -45,14 +43,14 @@ public final class LayoutTypedMap extends LayoutUniqueScope { } @Override - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { lenInBytes.setAndGet(0); TypeArgument[] retval = new TypeArgument[2]; for (int i = 0; i < 2; i++) { int itemLenInBytes; Out tempOut_itemLenInBytes = new Out(); - retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); + retval[i] = readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); } @@ -62,9 +60,9 @@ public final class LayoutTypedMap extends LayoutUniqueScope { @Override public void SetImplicitTypeCode(Reference edit) { - edit.get().cellType = edit.get().scopeType.Immutable ? ImmutableTypedTuple : + edit.get().cellType = edit.get().scopeType().Immutable ? ImmutableTypedTuple : TypedTuple; - edit.get().cellTypeArgs = edit.get().scopeTypeArgs.clone(); + edit.get().cellTypeArgs = edit.get().scopeTypeArgs().clone(); } @Override @@ -79,7 +77,7 @@ public final class LayoutTypedMap extends LayoutUniqueScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); return result; @@ -90,12 +88,12 @@ public final class LayoutTypedMap extends LayoutUniqueScope { } @Override - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { - checkState(value.getCount() == 2); + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { + checkState(value.count() == 2); row.get().WriteSparseTypeCode(offset, this.LayoutCode); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); for (TypeArgument arg : value) { - lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone()); + lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone()); } return lenInBytes; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java index cc1065f..fff6b4c 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java @@ -10,47 +10,45 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedSetScope; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedSetScope; +import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_SET_SCOPE; +import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_SET_SCOPE; public final class LayoutTypedSet extends LayoutUniqueScope { public LayoutTypedSet(boolean immutable) { - super(immutable ? ImmutableTypedSetScope : TypedSetScope, immutable, true, true); + super(immutable ? IMMUTABLE_TYPED_SET_SCOPE : TYPED_SET_SCOPE, immutable, true, true); } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_set_t" : "set_t"; } - @Override - public int CountTypeArgument(TypeArgumentList value) { - checkState(value.getCount() == 1); - return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone()); + public int countTypeArgument(TypeArgumentList value) { + checkState(value.count() == 1); + return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).type().CountTypeArgument(value.get(0).typeArgs().clone()); } @Override public TypeArgument FieldType(Reference scope) { - return scope.get().scopeTypeArgs.get(0).clone(); + return scope.get().scopeTypeArgs().get(0).clone(); } @Override public boolean HasImplicitTypeCode(Reference edit) { - checkState(edit.get().index >= 0); - checkState(edit.get().scopeTypeArgs.getCount() == 1); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(0).getType().LayoutCode); + checkState(edit.get().index() >= 0); + checkState(edit.get().scopeTypeArgs().count() == 1); + return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode); } @Override - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { - return new TypeArgumentList(new TypeArgument[] { ReadTypeArgument(row, offset, lenInBytes) }); + return new TypeArgumentList(new TypeArgument[] { readTypeArgument(row, offset, lenInBytes) }); } @Override public void SetImplicitTypeCode(Reference edit) { - edit.get().cellType = edit.get().scopeTypeArgs.get(0).getType(); - edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone(); + edit.get().cellType = edit.get().scopeTypeArgs().get(0).type(); + edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone(); } @Override @@ -65,7 +63,7 @@ public final class LayoutTypedSet extends LayoutUniqueScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); return result; @@ -76,12 +74,12 @@ public final class LayoutTypedSet extends LayoutUniqueScope { } @Override - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { - checkArgument(value.getCount() == 1); + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { + checkArgument(value.count() == 1); row.get().WriteSparseTypeCode(offset, this.LayoutCode); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); - lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes, - value.get(0).getTypeArgs().clone()); + lenInBytes += value.get(0).type().writeTypeArgument(row, offset + lenInBytes, + value.get(0).typeArgs().clone()); return lenInBytes; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java index 5cb3d6c..795ac78 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java @@ -14,23 +14,21 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutTypedTuple extends LayoutIndexedScope { public LayoutTypedTuple(boolean immutable) { - super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedTupleScope : - com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedTupleScope, immutable, true, true, false, true); + super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_TUPLE_SCOPE : + com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_TUPLE_SCOPE, immutable, true, true, false, true); } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_tuple_t" : "tuple_t"; } - @Override - public int CountTypeArgument(TypeArgumentList value) { + public int countTypeArgument(TypeArgumentList value) { int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count); - lenInBytes += RowBuffer.Count7BitEncodedUInt(value.getCount()); + lenInBytes += RowBuffer.Count7BitEncodedUInt(value.count()); for (TypeArgument arg : value) { - lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone()); + lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone()); } return lenInBytes; @@ -38,20 +36,20 @@ public final class LayoutTypedTuple extends LayoutIndexedScope { @Override public boolean HasImplicitTypeCode(Reference edit) { - checkArgument(edit.get().index >= 0); - checkArgument(edit.get().scopeTypeArgs.getCount() > edit.get().index); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(edit.get().index).getType().LayoutCode); + checkArgument(edit.get().index() >= 0); + checkArgument(edit.get().scopeTypeArgs().count() > edit.get().index()); + return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode); } @Override - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes); TypeArgument[] retval = new TypeArgument[numTypeArgs]; for (int i = 0; i < numTypeArgs; i++) { int itemLenInBytes; Out tempOut_itemLenInBytes = new Out(); - retval[i] = LayoutType.ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); + retval[i] = LayoutType.readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); } @@ -61,8 +59,8 @@ public final class LayoutTypedTuple extends LayoutIndexedScope { @Override public void SetImplicitTypeCode(Reference edit) { - edit.get().cellType = edit.get().scopeTypeArgs.get(edit.get().index).getType(); - edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(edit.get().index).getTypeArgs().clone(); + edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type(); + edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone(); } @Override @@ -77,7 +75,7 @@ public final class LayoutTypedTuple extends LayoutIndexedScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); return result; @@ -88,14 +86,14 @@ public final class LayoutTypedTuple extends LayoutIndexedScope { } @Override - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { row.get().WriteSparseTypeCode(offset, this.LayoutCode); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: lenInBytes += row.Write7BitEncodedUInt(offset + lenInBytes, (ulong)value.Count); - lenInBytes += row.get().Write7BitEncodedUInt(offset + lenInBytes, value.getCount()); + lenInBytes += row.get().Write7BitEncodedUInt(offset + lenInBytes, value.count()); for (TypeArgument arg : value) { - lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone()); + lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone()); } return lenInBytes; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java new file mode 100644 index 0000000..a474e79 --- /dev/null +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java @@ -0,0 +1,58 @@ +//------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +//------------------------------------------------------------ + +package com.azure.data.cosmos.serialization.hybridrow.layouts; + +/** + * Layout type definitions + */ +public abstract class LayoutTypes { + public static final LayoutArray Array = new LayoutArray(false); + public static final LayoutBinary Binary = new LayoutBinary(); + public static final int BitsPerByte = 8; + public static final LayoutBoolean Boolean = new LayoutBoolean(true); + public static final LayoutBoolean BooleanFalse = new LayoutBoolean(false); + public static final LayoutDateTime DateTime = new LayoutDateTime(); + public static final LayoutDecimal Decimal = new LayoutDecimal(); + public static final LayoutEndScope EndScope = new LayoutEndScope(); + public static final LayoutFloat128 Float128 = new LayoutFloat128(); + public static final LayoutFloat32 Float32 = new LayoutFloat32(); + public static final LayoutFloat64 Float64 = new LayoutFloat64(); + public static final LayoutGuid Guid = new LayoutGuid(); + public static final LayoutArray ImmutableArray = new LayoutArray(true); + public static final LayoutNullable ImmutableNullable = new LayoutNullable(true); + public static final LayoutObject ImmutableObject = new LayoutObject(true); + public static final LayoutTagged ImmutableTagged = new LayoutTagged(true); + public static final LayoutTagged2 ImmutableTagged2 = new LayoutTagged2(true); + public static final LayoutTuple ImmutableTuple = new LayoutTuple(true); + public static final LayoutTypedArray ImmutableTypedArray = new LayoutTypedArray(true); + public static final LayoutTypedMap ImmutableTypedMap = new LayoutTypedMap(true); + public static final LayoutTypedSet ImmutableTypedSet = new LayoutTypedSet(true); + public static final LayoutTypedTuple ImmutableTypedTuple = new LayoutTypedTuple(true); + public static final LayoutUDT ImmutableUDT = new LayoutUDT(true); + public static final LayoutInt16 Int16 = new LayoutInt16(); + public static final LayoutInt32 Int32 = new LayoutInt32(); + public static final LayoutInt64 Int64 = new LayoutInt64(); + public static final LayoutInt8 Int8 = new LayoutInt8(); + public static final LayoutMongoDbObjectId MongoDbObjectId = new LayoutMongoDbObjectId(); + public static final LayoutNull Null = new LayoutNull(); + public static final LayoutNullable Nullable = new LayoutNullable(false); + public static final LayoutObject Object = new LayoutObject(false); + public static final LayoutTagged Tagged = new LayoutTagged(false); + public static final LayoutTagged2 Tagged2 = new LayoutTagged2(false); + public static final LayoutTuple Tuple = new LayoutTuple(false); + public static final LayoutTypedArray TypedArray = new LayoutTypedArray(false); + public static final LayoutTypedMap TypedMap = new LayoutTypedMap(false); + public static final LayoutTypedSet TypedSet = new LayoutTypedSet(false); + public static final LayoutTypedTuple TypedTuple = new LayoutTypedTuple(false); + public static final LayoutUDT UDT = new LayoutUDT(false); + public static final LayoutUInt16 UInt16 = new LayoutUInt16(); + public static final LayoutUInt32 UInt32 = new LayoutUInt32(); + public static final LayoutUInt64 UInt64 = new LayoutUInt64(); + public static final LayoutUInt8 UInt8 = new LayoutUInt8(); + public static final LayoutUnixDateTime UnixDateTime = new LayoutUnixDateTime(); + public static final LayoutUtf8 Utf8 = new LayoutUtf8(); + public static final LayoutVarInt VarInt = new LayoutVarInt(); + public static final LayoutVarUInt VarUInt = new LayoutVarUInt(); +} diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java index d7d1fc5..2518a10 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java @@ -13,25 +13,23 @@ import com.azure.data.cosmos.serialization.hybridrow.SchemaId; public final class LayoutUDT extends LayoutPropertyScope { public LayoutUDT(boolean immutable) { - super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableSchema : - com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Schema, immutable); + super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_SCHEMA : + com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SCHEMA, immutable); } - @Override - public String getName() { + public String name() { return this.Immutable ? "im_udt" : "udt"; } - @Override - public int CountTypeArgument(TypeArgumentList value) { - return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.Size; + public int countTypeArgument(TypeArgumentList value) { + return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.SIZE; } @Override - public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, + public TypeArgumentList readTypeArgumentList(Reference row, int offset, Out lenInBytes) { SchemaId schemaId = row.get().ReadSchemaId(offset).clone(); - lenInBytes.setAndGet(SchemaId.Size); + lenInBytes.setAndGet(SchemaId.SIZE); return new TypeArgumentList(schemaId.clone()); } @@ -47,8 +45,8 @@ public final class LayoutUDT extends LayoutPropertyScope { @Override public Result WriteScope(Reference b, Reference edit, TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Layout udt = b.get().getResolver().Resolve(typeArgs.getSchemaId().clone()); - Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Layout udt = b.get().resolver().Resolve(typeArgs.schemaId().clone()); + Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); return result; @@ -59,9 +57,9 @@ public final class LayoutUDT extends LayoutPropertyScope { } @Override - public int WriteTypeArgument(Reference row, int offset, TypeArgumentList value) { + public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { row.get().WriteSparseTypeCode(offset, this.LayoutCode); - row.get().WriteSchemaId(offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), value.getSchemaId().clone()); - return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.Size; + row.get().WriteSchemaId(offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), value.schemaId().clone()); + return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.SIZE; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java index 8914966..ba852bd 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java @@ -16,16 +16,14 @@ import static com.google.common.base.Preconditions.checkArgument; //ORIGINAL LINE: public sealed class LayoutUInt16 : LayoutType public final class LayoutUInt16 extends LayoutType { public LayoutUInt16() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UInt16, (Short.SIZE / Byte.SIZE)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UINT_16, (Short.SIZE / Byte.SIZE)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "uint16"; } @@ -33,24 +31,24 @@ public final class LayoutUInt16 extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // ushort value) @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadUInt16(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadUInt16(scope.get().start() + col.getOffset())); return Result.Success; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ushort value) @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -66,13 +64,13 @@ public final class LayoutUInt16 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, short value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteUInt16(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteUInt16(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -83,7 +81,7 @@ public final class LayoutUInt16 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, short value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java index 504911e..f4870ed 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java @@ -16,16 +16,14 @@ import static com.google.common.base.Preconditions.checkArgument; //ORIGINAL LINE: public sealed class LayoutUInt32 : LayoutType public final class LayoutUInt32 extends LayoutType { public LayoutUInt32() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UInt32, (Integer.SIZE / Byte.SIZE)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UINT_32, (Integer.SIZE / Byte.SIZE)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "uint32"; } @@ -33,24 +31,24 @@ public final class LayoutUInt32 extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // uint value) @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadUInt32(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadUInt32(scope.get().start() + col.getOffset())); return Result.Success; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out uint value) @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -66,13 +64,13 @@ public final class LayoutUInt32 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, int value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteUInt32(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteUInt32(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -83,7 +81,7 @@ public final class LayoutUInt32 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, int value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java index 8465935..0c19c03 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java @@ -16,16 +16,14 @@ import static com.google.common.base.Preconditions.checkArgument; //ORIGINAL LINE: public sealed class LayoutUInt64 : LayoutType public final class LayoutUInt64 extends LayoutType { public LayoutUInt64() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UInt64, (Long.SIZE / Byte.SIZE)); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UINT_64, (Long.SIZE / Byte.SIZE)); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "uint64"; } @@ -33,24 +31,24 @@ public final class LayoutUInt64 extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // ulong value) @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadUInt64(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadUInt64(scope.get().start() + col.getOffset())); return Result.Success; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ulong value) @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -66,13 +64,13 @@ public final class LayoutUInt64 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, long value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteUInt64(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteUInt64(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -83,7 +81,7 @@ public final class LayoutUInt64 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, long value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java index 6927f9a..245446b 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java @@ -16,16 +16,14 @@ import static com.google.common.base.Preconditions.checkArgument; //ORIGINAL LINE: public sealed class LayoutUInt8 : LayoutType public final class LayoutUInt8 extends LayoutType { public LayoutUInt8() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UInt8, 1); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UINT_8, 1); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "uint8"; } @@ -33,24 +31,24 @@ public final class LayoutUInt8 extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // byte value) @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - value.setAndGet(b.get().ReadUInt8(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadUInt8(scope.get().start() + col.getOffset())); return Result.Success; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out byte value) @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -66,13 +64,13 @@ public final class LayoutUInt8 extends LayoutType { @Override public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, byte value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteUInt8(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteUInt8(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -83,7 +81,7 @@ public final class LayoutUInt8 extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, byte value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java index 6e035f8..115e183 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; @@ -38,14 +37,14 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope { */ public final Result Find(Reference b, Reference scope, Reference patternScope, Out value) { - Result result = LayoutType.PrepareSparseMove(b, scope, this, this.FieldType(scope).clone(), patternScope, UpdateOptions.Update, value.clone()); + Result result = LayoutType.prepareSparseMove(b, scope, this, this.FieldType(scope).clone(), patternScope, UpdateOptions.Update, value.clone()); if (result != Result.Success) { return result; } // Check if the search found the result. - b.get().DeleteSparse(patternScope); + b.get().deleteSparse(patternScope); return Result.Success; } @@ -58,7 +57,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope { RowCursor dstEdit; Out tempOut_dstEdit = new Out(); - Result result = LayoutType.PrepareSparseMove(b, destinationScope, this, + Result result = LayoutType.prepareSparseMove(b, destinationScope, this, this.FieldType(destinationScope).clone(), sourceEdit, options, tempOut_dstEdit); dstEdit = tempOut_dstEdit.get(); @@ -74,7 +73,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope { // TODO: it would be "better" if the destinationScope were updated to point to the // highest item seen. Then we would avoid the maximum reparse. - destinationScope.get().count = dstEdit.count; + destinationScope.get().count(dstEdit.count()); return Result.Success; } @@ -129,7 +128,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope { return r; } - uniqueScope.count = childScope.count; + uniqueScope.count(childScope.count()); Reference tempReference_uniqueScope = new Reference(uniqueScope); r = b.get().TypedCollectionUniqueIndexRebuild(tempReference_uniqueScope); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java index 01a91e5..9dac80e 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java @@ -15,37 +15,35 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutUnixDateTime extends LayoutType { public LayoutUnixDateTime() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UnixDateTime, + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UNIX_DATE_TIME, com.azure.data.cosmos.serialization.hybridrow.UnixDateTime.Size); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return true; } - @Override - public String getName() { + public String name() { return "unixdatetime"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(null); return Result.NotFound; } - value.setAndGet(b.get().ReadUnixDateTime(scope.get().start + col.getOffset()).clone()); + value.setAndGet(b.get().ReadUnixDateTime(scope.get().start() + col.getOffset()).clone()); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(null); return result; @@ -56,15 +54,15 @@ public final class LayoutUnixDateTime extends LayoutType b, Reference scope, LayoutColumn col, + public Result writeFixed(Reference b, Reference scope, LayoutColumn col, UnixDateTime value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteUnixDateTime(scope.get().start + col.getOffset(), value.clone()); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteUnixDateTime(scope.get().start() + col.getOffset(), value.clone()); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @@ -72,9 +70,9 @@ public final class LayoutUnixDateTime extends LayoutType b, Reference edit, UnixDateTime value + public Result writeSparse(Reference b, Reference edit, UnixDateTime value , UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -84,7 +82,7 @@ public final class LayoutUnixDateTime extends LayoutType b, Reference edit, UnixDateTime value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(Reference b, Reference edit, UnixDateTime value) { + return writeSparse(b, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java index ed121f8..fa65f36 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java @@ -14,21 +14,19 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8SpanWritable, ILayoutUtf8SpanReadable { public LayoutUtf8() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Utf8, 0); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UTF_8, 0); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return false; } - @Override - public String getName() { + public String name() { return "utf8"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { Utf8Span span; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these @@ -41,19 +39,19 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); + checkArgument(scope.get().scopeType() instanceof LayoutUDT); checkArgument(col.getSize() >= 0); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(null); return Result.NotFound; } - value.setAndGet(b.get().ReadFixedString(scope.get().start + col.getOffset(), col.getSize())); + value.setAndGet(b.get().ReadFixedString(scope.get().start() + col.getOffset(), col.getSize())); return Result.Success; } @Override - public Result ReadSparse(Reference b, Reference edit, + public Result readSparse(Reference b, Reference edit, Out value) { Utf8Span span; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these @@ -65,7 +63,7 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S } public Result ReadSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(null); return result; @@ -76,7 +74,7 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S } @Override - public Result ReadVariable(Reference b, Reference scope, LayoutColumn col + public Result readVariable(Reference b, Reference scope, LayoutColumn col , Out value) { Utf8Span span; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these @@ -89,20 +87,20 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S public Result ReadVariable(Reference b, Reference scope, LayoutColumn col , Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(null); return Result.NotFound; } - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), col.getOffset()); value.setAndGet(b.get().ReadVariableString(varOffset)); return Result.Success; } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, + public Result writeFixed(Reference b, Reference scope, LayoutColumn col, String value) { checkArgument(value != null); return this.WriteFixed(b, scope, col, Utf8Span.TranscodeUtf16(value)); @@ -110,28 +108,28 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, Utf8Span value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); + checkArgument(scope.get().scopeType() instanceof LayoutUDT); checkArgument(col.getSize() >= 0); checkArgument(value.Length == col.getSize()); - if (scope.get().immutable) { + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - b.get().WriteFixedString(scope.get().start + col.getOffset(), value); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); + b.get().WriteFixedString(scope.get().start() + col.getOffset(), value); + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); return Result.Success; } @Override - public Result WriteSparse(Reference b, Reference edit, String value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(Reference b, Reference edit, String value) { + return writeSparse(b, edit, value, UpdateOptions.Upsert); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, string value, // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, String value, + public Result writeSparse(Reference b, Reference edit, String value, UpdateOptions options) { checkArgument(value != null); return this.WriteSparse(b, edit, Utf8Span.TranscodeUtf16(value), options); @@ -147,7 +145,7 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S // options = UpdateOptions.Upsert) public Result WriteSparse(Reference b, Reference edit, Utf8Span value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -157,7 +155,7 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S } @Override - public Result WriteVariable(Reference b, Reference scope, + public Result writeVariable(Reference b, Reference scope, LayoutColumn col, String value) { checkArgument(value != null); return this.WriteVariable(b, scope, col, Utf8Span.TranscodeUtf16(value)); @@ -165,8 +163,8 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S public Result WriteVariable(Reference b, Reference scope, LayoutColumn col, Utf8Span value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } @@ -175,16 +173,16 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S return Result.TooBig; } - boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, + boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone()); + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), col.getOffset()); int shift; Out tempOut_shift = new Out(); b.get().WriteVariableString(varOffset, value, exists, tempOut_shift); shift = tempOut_shift.get(); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); - scope.get().metaOffset += shift; - scope.get().valueOffset += shift; + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); + scope.get().metaOffset(scope.get().metaOffset() + shift); + scope.get().valueOffset(scope.get().valueOffset() + shift); return Result.Success; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java index ec5e341..d72bb8a 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java @@ -14,26 +14,23 @@ import static com.google.common.base.Preconditions.checkArgument; public final class LayoutVarInt extends LayoutType { public LayoutVarInt() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.VarInt, 0); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.VAR_INT, 0); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return false; } - @Override - public boolean getIsVarint() { + public boolean isVarint() { return true; } - @Override - public String getName() { + public String name() { return "varint"; } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { Contract.Fail("Not Implemented"); value.setAndGet(0); @@ -41,8 +38,8 @@ public final class LayoutVarInt extends LayoutType { } @Override - public Result ReadSparse(Reference b, Reference edit, Out value) { - Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); + public Result readSparse(Reference b, Reference edit, Out value) { + Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -53,14 +50,14 @@ public final class LayoutVarInt extends LayoutType { } @Override - public Result ReadVariable(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + public Result readVariable(Reference b, Reference scope, LayoutColumn col, Out value) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), col.getOffset()); value.setAndGet(b.get().ReadVariableInt(varOffset)); return Result.Success; @@ -79,7 +76,7 @@ public final class LayoutVarInt extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, long value, UpdateOptions options) { - Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -96,21 +93,21 @@ public final class LayoutVarInt extends LayoutType { @Override public Result WriteVariable(Reference b, Reference scope, LayoutColumn col, long value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, + boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone()); + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), col.getOffset()); int shift; Out tempOut_shift = new Out(); b.get().WriteVariableInt(varOffset, value, exists, tempOut_shift); shift = tempOut_shift.get(); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); - scope.get().metaOffset += shift; - scope.get().valueOffset += shift; + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); + scope.get().metaOffset(scope.get().metaOffset() + shift); + scope.get().valueOffset(scope.get().valueOffset() + shift); return Result.Success; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java index cc935a3..4026879 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java @@ -16,21 +16,18 @@ import static com.google.common.base.Preconditions.checkArgument; //ORIGINAL LINE: public sealed class LayoutVarUInt : LayoutType public final class LayoutVarUInt extends LayoutType { public LayoutVarUInt() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.VarUInt, 0); + super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.VAR_UINT, 0); } - @Override - public boolean getIsFixed() { + public boolean isFixed() { return false; } - @Override - public boolean getIsVarint() { + public boolean isVarint() { return true; } - @Override - public String getName() { + public String name() { return "varuint"; } @@ -38,7 +35,7 @@ public final class LayoutVarUInt extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // ulong value) @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result readFixed(Reference b, Reference scope, LayoutColumn col, Out value) { Contract.Fail("Not Implemented"); value.setAndGet(0); @@ -48,8 +45,8 @@ public final class LayoutVarUInt extends LayoutType { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ulong value) @Override - public Result ReadSparse(Reference b, Reference edit, Out value) { - Result result = PrepareSparseRead(b, edit, this.LayoutCode); + public Result readSparse(Reference b, Reference edit, Out value) { + Result result = prepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { value.setAndGet(0); return result; @@ -63,14 +60,14 @@ public final class LayoutVarUInt extends LayoutType { //ORIGINAL LINE: public override Result ReadVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // ulong value) @Override - public Result ReadVariable(Reference b, Reference scope, LayoutColumn col, Out value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { + public Result readVariable(Reference b, Reference scope, LayoutColumn col, Out value) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) { value.setAndGet(0); return Result.NotFound; } - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), col.getOffset()); value.setAndGet(b.get().ReadVariableUInt(varOffset)); return Result.Success; @@ -93,7 +90,7 @@ public final class LayoutVarUInt extends LayoutType { @Override public Result WriteSparse(Reference b, Reference edit, long value, UpdateOptions options) { - Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); + Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { return result; } @@ -113,21 +110,21 @@ public final class LayoutVarUInt extends LayoutType { @Override public Result WriteVariable(Reference b, Reference scope, LayoutColumn col, long value) { - checkArgument(scope.get().scopeType instanceof LayoutUDT); - if (scope.get().immutable) { + checkArgument(scope.get().scopeType() instanceof LayoutUDT); + if (scope.get().immutable()) { return Result.InsufficientPermissions; } - boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); - int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, + boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone()); + int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), col.getOffset()); int shift; Out tempOut_shift = new Out(); b.get().WriteVariableUInt(varOffset, value, exists, tempOut_shift); shift = tempOut_shift.get(); - b.get().SetBit(scope.get().start, col.getNullBit().clone()); - scope.get().metaOffset += shift; - scope.get().valueOffset += shift; + b.get().SetBit(scope.get().start(), col.getNullBit().clone()); + scope.get().metaOffset(scope.get().metaOffset() + shift); + scope.get().valueOffset(scope.get().valueOffset() + shift); return Result.Success; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java index 13dc863..0343476 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java @@ -6,87 +6,65 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Utf8String; -//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ -// from the original: -//ORIGINAL LINE: public readonly struct StringToken -//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct: -public final class StringToken { - // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: - ///#pragma warning disable CA1051 // Do not declare visible instance fields - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public readonly ulong Id; - public long Id; - public Utf8String Path; - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public readonly byte[] Varint; - public byte[] Varint; - // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: - ///#pragma warning restore CA1051 // Do not declare visible instance fields +public final class StringToken implements Cloneable { + + public long id; + public Utf8String path; + public byte[] varint; public StringToken() { } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public StringToken(ulong id, Utf8String path) public StringToken(long id, Utf8String path) { - this.Id = id; - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: this.Varint = new byte[StringToken.Count7BitEncodedUInt(id)]; - this.Varint = new byte[StringToken.Count7BitEncodedUInt(id)]; - StringToken.Write7BitEncodedUInt(this.Varint.AsSpan(), id); - this.Path = path; + this.varint = new byte[StringToken.Count7BitEncodedUInt(id)]; + StringToken.Write7BitEncodedUInt(this.varint, id); + this.path = path; + this.id = id; } + @Override public StringToken clone() { - StringToken varCopy = new StringToken(); - varCopy.Id = this.Id; - varCopy.Varint = this.Varint; - varCopy.Path = this.Path; - - return varCopy; + try { + final StringToken token = (StringToken)super.clone(); + token.id = this.id; + token.path = this.path; + token.varint = this.varint; + return token; + } catch (CloneNotSupportedException error) { + assert false : error; + throw new IllegalStateException(error); + } } - boolean getIsNull() + public boolean isNull() { + return this.varint == null; + } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: private static int Count7BitEncodedUInt(ulong value) private static int Count7BitEncodedUInt(long value) { + // Count the number of bytes needed to write out an int 7 bits at a time. int i = 0; + while (value >= 0x80L) { i++; - //C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift - // operator since the left operand was originally of an unsigned type, but you should confirm this replacement: value >>>= 7; } - i++; - return i; + return ++i; } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: private static int Write7BitEncodedUInt(Span buffer, ulong value) - private static int Write7BitEncodedUInt(Span buffer, long value) { - // Write out an unsigned long 7 bits at a time. The high bit of the byte, - // when set, indicates there are more bytes. + private static int Write7BitEncodedUInt(byte[] buffer, long value) { + + // Write an unsigned long 7 bits at a time. The high bit of the byte, when set, indicates there are more bytes. int i = 0; + while (value >= 0x80L) { - // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context: - //ORIGINAL LINE: buffer[i] = unchecked((byte)(value | 0x80)); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - buffer[i] = (byte)(value | 0x80); - i++; - //C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift - // operator since the left operand was originally of an unsigned type, but you should confirm this - // replacement: + buffer[i++] = (byte) (value | 0x80); value >>>= 7; } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: buffer[i] = (byte)value; - buffer[i] = (byte)value; - i++; + buffer[i++] = (byte) value; return i; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java index 471bec3..ec6e908 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java @@ -9,9 +9,8 @@ import com.azure.data.cosmos.core.Utf8String; import com.azure.data.cosmos.core.UtfAnyString; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; -import java.util.Map; +import java.util.Optional; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; @@ -29,13 +28,15 @@ public final class StringTokenizer { */ public StringTokenizer() { - this.tokens = new HashMap( - Map.ofEntries(Map.entry(Utf8String.EMPTY, new StringToken(0, Utf8String.EMPTY)))); + this.tokens = new HashMap<>(); + this.tokens.put(Utf8String.EMPTY, new StringToken(0, Utf8String.EMPTY)); - this.stringTokens = new HashMap( - Map.ofEntries(Map.entry("", new StringToken(0, Utf8String.EMPTY)))); + this.stringTokens = new HashMap<>(); + this.stringTokens.put("", new StringToken(0, Utf8String.EMPTY)); + + this.strings = new ArrayList<>(); + this.strings.add(Utf8String.EMPTY); - this.strings = new ArrayList(Collections.singletonList(Utf8String.EMPTY)); this.count = 1; } @@ -61,41 +62,33 @@ public final class StringTokenizer { * Looks up a string's corresponding token. * * @param path The string to look up. - * @param token If successful, the string's assigned token. - * @return True if successful, false otherwise. + * @return {@code true} if successful, {@code false} otherwise. */ - public boolean tryFindToken(UtfAnyString path, Out token) { + public Optional findToken(UtfAnyString path) { if (path.isNull()) { - token.setAndGet(null); - return false; + return Optional.empty(); } if (path.isUtf8()) { - return (this.tokens.containsKey(path.toUtf8()) && (token.setAndGet(this.tokens.get(path.toUtf8()))) == token.get()); + return Optional.ofNullable(this.tokens.get(path.toUtf8())); } - return (this.stringTokens.containsKey(path.toUtf16()) && (token.setAndGet(this.stringTokens.get(path.toUtf16()))) == token.get()); + return Optional.ofNullable(this.stringTokens.get(path.toUtf16())); } /** - * Assign a token to the string. + * Assign a token to a string + *

* If the string already has a token, that token is returned instead. * * @param path The string to assign a new token. * @return The token assigned to the string. */ public StringToken add(Utf8String path) { - checkArgument(path != null); - StringToken token; - - if (this.tokens.containsKey(path) && (token = this.tokens.get(path)) == token) { - return token; - } - - token = this.allocateToken(path).clone(); - return token; + final StringToken token = this.tokens.get(path); + return token == null ? this.allocateToken(path) : token; } /** @@ -113,14 +106,13 @@ public final class StringTokenizer { */ private StringToken allocateToken(Utf8String path) { - final long id = this.count++; - final StringToken token = new StringToken(id, path); + final StringToken token = new StringToken(this.count++, path); - this.tokens.put(path, token.clone()); - this.stringTokens.put(path.toString(), token.clone()); + this.stringTokens.put(path.toUtf16(), token); + this.tokens.put(path, token); this.strings.add(path); - checkState((long)this.strings.size() - 1 == id); - return token.clone(); + checkState((long)this.strings.size() - 1 == token.id); + return token; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgument.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgument.java index 9044aff..b4c59de 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgument.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgument.java @@ -4,33 +4,22 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; -import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; -// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: -//ORIGINAL LINE: [DebuggerDisplay("{this.type == null ? null : ToString()}")] public readonly struct TypeArgument : -// IEquatable -//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ -// from the original: -//ORIGINAL LINE: [DebuggerDisplay("{this.type == null ? null : ToString()}")] public readonly struct TypeArgument : -// IEquatable -//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct: -public final class TypeArgument implements IEquatable { - private LayoutType type; - private TypeArgumentList typeArgs = new TypeArgumentList(); +public final class TypeArgument { + + private final LayoutType type; + private final TypeArgumentList typeArgs; /** * Initializes a new instance of the {@link TypeArgument} struct. * * @param type The type of the constraint. */ - public TypeArgument() { - } - public TypeArgument(LayoutType type) { - checkArgument(type != null); - + checkNotNull(type); this.type = type; - this.typeArgs = TypeArgumentList.Empty; + this.typeArgs = TypeArgumentList.EMPTY; } /** @@ -40,78 +29,28 @@ public final class TypeArgument implements IEquatable { * @param typeArgs For generic types the type parameters. */ public TypeArgument(LayoutType type, TypeArgumentList typeArgs) { - checkArgument(type != null); - + checkNotNull(type); this.type = type; - this.typeArgs = typeArgs.clone(); - } - - /** - * The physical layout type. - */ - public LayoutType getType() { - return this.type; - } - - /** - * If the type argument is itself generic, then its type arguments. - */ - public TypeArgumentList getTypeArgs() { - return this.typeArgs.clone(); - } - - /** - * The physical layout type of the field cast to the specified type. - */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [DebuggerHidden] public T TypeAs() where T : ILayoutType - public T TypeAs() { - return this.type.TypeAs(); - } - - public TypeArgument clone() { - TypeArgument varCopy = new TypeArgument(); - - varCopy.type = this.type; - varCopy.typeArgs = this.typeArgs.clone(); - - return varCopy; - } - - public boolean equals(TypeArgument other) { - return this.type.equals(other.type) && this.typeArgs.equals(other.typeArgs.clone()); + this.typeArgs = typeArgs; } @Override - public boolean equals(Object obj) { - if (null == obj) { + public boolean equals(Object other) { + + if (null == other) { return false; } - boolean tempVar = obj instanceof TypeArgument; - TypeArgument ota = tempVar ? (TypeArgument)obj : null; - if (tempVar) { - return this.equals(ota); - } - - return false; + return other instanceof TypeArgument && this.equals((TypeArgument) other); } @Override public int hashCode() { - // TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java: - unchecked - { - return (this.type.hashCode() * 397) ^ this.typeArgs.hashCode(); - } + return (this.type.hashCode() * 397) ^ this.typeArgs.hashCode(); } - public static boolean opEquals(TypeArgument left, TypeArgument right) { - return left.equals(right.clone()); - } - - public static boolean opNotEquals(TypeArgument left, TypeArgument right) { - return !left.equals(right.clone()); + public boolean equals(TypeArgument other) { + return this.type.equals(other.type) && this.typeArgs.equals(other.typeArgs); } @Override @@ -119,7 +58,20 @@ public final class TypeArgument implements IEquatable { if (this.type == null) { return ""; } + return this.type.name() + this.typeArgs.toString(); + } - return this.type.getName() + this.typeArgs.toString(); + /** + * The physical layout type. + */ + public LayoutType type() { + return this.type; + } + + /** + * If the type argument is itself generic, then its type arguments. + */ + public TypeArgumentList typeArgs() { + return this.typeArgs; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgumentList.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgumentList.java index c448f23..0f841e3 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgumentList.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgumentList.java @@ -6,38 +6,26 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.serialization.hybridrow.SchemaId; +import java.util.Arrays; + import static com.google.common.base.Preconditions.checkArgument; -// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: -///#pragma warning disable CA1034 // Nested types should not be visible +public final class TypeArgumentList +{ + public static final TypeArgumentList EMPTY = new TypeArgumentList(); + private final TypeArgument[] args; + private final SchemaId schemaId; -// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: -//ORIGINAL LINE: [DebuggerDisplay("{this.args == null ? null : ToString()}")] public readonly struct TypeArgumentList -// : IEquatable -//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ -// from the original: -//ORIGINAL LINE: [DebuggerDisplay("{this.args == null ? null : ToString()}")] public readonly struct TypeArgumentList -// : IEquatable -//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct: -public final class TypeArgumentList implements IEquatable { - public static final TypeArgumentList Empty = new TypeArgumentList(Array.Empty()); - - private TypeArgument[] args; - - /** - * For UDT fields, the schema id of the nested layout. - */ - private SchemaId schemaId = new SchemaId(); - - public TypeArgumentList() { + private TypeArgumentList() { + this.args = new TypeArgument[] {}; + this.schemaId = SchemaId.NONE; } public TypeArgumentList(TypeArgument[] args) { checkArgument(args != null); - this.args = args; - this.schemaId = getSchemaId().Invalid; + this.schemaId = SchemaId.INVALID; } /** @@ -45,20 +33,20 @@ public final class TypeArgumentList implements IEquatable { * * @param schemaId For UDT fields, the schema id of the nested layout. */ - public TypeArgumentList(SchemaId schemaId) { - this.args = Array.Empty(); - this.schemaId = schemaId.clone(); + public TypeArgumentList(SchemaId schemaId, TypeArgument...args) { + this.args = args.length == 0 ? EMPTY.args : args; + this.schemaId = schemaId; } - public int getCount() { + public int count() { return this.args.length; } /** * For UDT fields, the schema id of the nested layout. */ - public SchemaId getSchemaId() { - return this.schemaId.clone(); + public SchemaId schemaId() { + return this.schemaId; } /** @@ -68,35 +56,19 @@ public final class TypeArgumentList implements IEquatable { return new Enumerator(this.args); } - public TypeArgumentList clone() { - TypeArgumentList varCopy = new TypeArgumentList(); - - varCopy.args = this.args.clone(); - varCopy.schemaId = this.schemaId.clone(); - - return varCopy; - } - public boolean equals(TypeArgumentList other) { - //C# TO JAVA CONVERTER WARNING: Java Arrays.equals is not always identical to LINQ 'SequenceEqual': - //ORIGINAL LINE: return (this.schemaId == other.schemaId) && this.args.SequenceEqual(other.args); - return (SchemaId.opEquals(this.schemaId.clone(), - other.schemaId.clone())) && Arrays.equals(this.args, other.args); + if (null == other) { + return false; + } + if (this == other) { + return true; + } + return this.schemaId().equals(other.schemaId()) && Arrays.equals(this.args, other.args); } @Override - public boolean equals(Object obj) { - if (null == obj) { - return false; - } - - boolean tempVar = obj instanceof TypeArgumentList; - TypeArgumentList ota = tempVar ? (TypeArgumentList)obj : null; - if (tempVar) { - return this.equals(ota); - } - - return false; + public boolean equals(Object other) { + return other instanceof TypeArgumentList && this.equals((TypeArgumentList) other); } public TypeArgument get(int i) { @@ -105,32 +77,30 @@ public final class TypeArgumentList implements IEquatable { @Override public int hashCode() { - // TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java: - unchecked - { - int hash = 19; - hash = (hash * 397) ^ this.schemaId.hashCode(); - for (TypeArgument a : this.args) { - hash = (hash * 397) ^ a.hashCode(); - } - return hash; + int hash = 19; + hash = (hash * 397) ^ this.schemaId().hashCode(); + + for (TypeArgument a : this.args) { + hash = (hash * 397) ^ a.hashCode(); } + + return hash; } public static boolean opEquals(TypeArgumentList left, TypeArgumentList right) { - return left.equals(right.clone()); + return left.equals(right); } public static boolean opNotEquals(TypeArgumentList left, TypeArgumentList right) { - return !left.equals(right.clone()); + return !left.equals(right); } @Override public String toString() { - if (SchemaId.opNotEquals(this.schemaId.clone(), - getSchemaId().Invalid)) { - return String.format("<%1$s>", this.schemaId.toString()); + + if (this.schemaId.equals(SchemaId.INVALID)) { + return String.format("<%1$s>", this.schemaId().toString()); } if (this.args == null || this.args == null ? null : this.args.length == 0) { diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java index 7faf5b1..04d77dc 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java @@ -28,7 +28,7 @@ public final class RecordIOFormatter { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: resizer = resizer != null ? resizer : DefaultSpanResizer.Default; resizer = resizer != null ? resizer : DefaultSpanResizer < Byte >.Default; - int estimatedSize = HybridRowHeader.Size + RecordIOFormatter.RecordLayout.getSize() + body.Length; + int estimatedSize = HybridRowHeader.SIZE + RecordIOFormatter.RecordLayout.getSize() + body.Length; //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: uint crc32 = Crc32.Update(0, body.Span); int crc32 = Crc32.Update(0, body.Span); @@ -50,7 +50,7 @@ public final class RecordIOFormatter { //ORIGINAL LINE: resizer = resizer != null ? resizer : DefaultSpanResizer.Default; resizer = resizer != null ? resizer : DefaultSpanResizer < Byte >.Default; int estimatedSize = - HybridRowHeader.Size + RecordIOFormatter.SegmentLayout.getSize() + segment.Comment == null ? null : + HybridRowHeader.SIZE + RecordIOFormatter.SegmentLayout.getSize() + segment.Comment == null ? null : segment.Comment.length() != null ? segment.Comment.length() : 0 + segment.SDL == null ? null : segment.SDL.length() != null ? segment.SDL.length() : 0 + 20; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java index b9aedce..bd041db 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java @@ -71,7 +71,7 @@ public final class RecordIOParser { this.state = State.NeedSegmentLength; // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: case NeedSegmentLength: { - int minimalSegmentRowSize = HybridRowHeader.Size + RecordIOFormatter.SegmentLayout.getSize(); + int minimalSegmentRowSize = HybridRowHeader.SIZE + RecordIOFormatter.SegmentLayout.getSize(); if (b.Length < minimalSegmentRowSize) { need.setAndGet(minimalSegmentRowSize); consumed.setAndGet(buffer.Length - b.Length); @@ -138,8 +138,8 @@ public final class RecordIOParser { } case NeedHeader: { - if (b.Length < HybridRowHeader.Size) { - need.setAndGet(HybridRowHeader.Size); + if (b.Length < HybridRowHeader.SIZE) { + need.setAndGet(HybridRowHeader.SIZE); consumed.setAndGet(buffer.Length - b.Length); return Result.InsufficientBuffer; } @@ -171,7 +171,7 @@ public final class RecordIOParser { } case NeedRecord: { - int minimalRecordRowSize = HybridRowHeader.Size + RecordIOFormatter.RecordLayout.getSize(); + int minimalRecordRowSize = HybridRowHeader.SIZE + RecordIOFormatter.RecordLayout.getSize(); if (b.Length < minimalRecordRowSize) { need.setAndGet(minimalRecordRowSize); consumed.setAndGet(buffer.Length - b.Length); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java index 4889fd5..eb55325 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java @@ -120,7 +120,7 @@ HashMap ids up: ValidateAssert.Exists((up.Name, up.SchemaId), schemas, "Schema reference", "Namespace") if (SchemaId.opNotEquals(up.SchemaId, - SchemaId.Invalid)) { + SchemaId.INVALID)) { Schema s = ValidateAssert.Exists(up.SchemaId, ids, "Schema id", "Namespace"); ValidateAssert.AreEqual(up.Name, s.getName(), String.format("Schema name '%1$s' does not match " + "the name of schema with id '%2$s': %3$s", up.Name, up.SchemaId, s.getName())); @@ -154,7 +154,7 @@ HashMap ids // Enable id-less Schema references for all types with a unique version in the namespace. for (Schema s : ns.getSchemas()) { if (nameVersioningCheck.get(s.getName()).equals(1)) { - ValidateAssert.DuplicateCheck((s.getName(), SchemaId.Invalid), s, nameDupCheck, "Schema reference", + ValidateAssert.DuplicateCheck((s.getName(), SchemaId.INVALID), s, nameDupCheck, "Schema reference", "Namespace") } } @@ -269,7 +269,7 @@ private static void Visit(PropertyType p, PropertyType parent, HashMap<(String, * @param label Diagnostic label describing . */ public static void IsValidSchemaId(SchemaId id, String label) { - if (SchemaId.opEquals(id.clone(), SchemaId.Invalid)) { + if (SchemaId.opEquals(id.clone(), SchemaId.INVALID)) { throw new SchemaException(String.format("%1$s cannot be 0", label)); } } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java index 0f7f285..c676099 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java @@ -38,7 +38,7 @@ public class UdtPropertyType extends ScopePropertyType { private com.azure.data.cosmos.serialization.hybridrow.SchemaId SchemaId = new SchemaId(); public UdtPropertyType() { - this.setSchemaId(com.azure.data.cosmos.serialization.hybridrow.SchemaId.Invalid); + this.setSchemaId(com.azure.data.cosmos.serialization.hybridrow.SchemaId.INVALID); } public final String getName() { diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java index 0926713..f505c18 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java @@ -74,18 +74,18 @@ public final class BsonRowGenerator implements Closeable { private void DispatchArray(TypeArgument typeArg, Object value) { - checkArgument(typeArg.getTypeArgs().getCount() == 1); + checkArgument(typeArg.typeArgs().count() == 1); this.writer.writeStartArray(); for (Object item : (ArrayList)value) { - this.LayoutCodeSwitch(null, typeArg.getTypeArgs().get(0).clone(), item); + this.LayoutCodeSwitch(null, typeArg.typeArgs().get(0).clone(), item); } this.writer.writeEndArray(); } private void DispatchMap(TypeArgument typeArg, Object value) { - checkArgument(typeArg.getTypeArgs().getCount() == 2); + checkArgument(typeArg.typeArgs().count() == 2); this.writer.writeStartArray(); for (Object item : (ArrayList)value) { @@ -96,10 +96,10 @@ public final class BsonRowGenerator implements Closeable { } private void DispatchNullable(TypeArgument typeArg, Object value) { - checkArgument(typeArg.getTypeArgs().getCount() == 1); + checkArgument(typeArg.typeArgs().count() == 1); if (value != null) { - this.LayoutCodeSwitch(null, typeArg.getTypeArgs().get(0).clone(), value); + this.LayoutCodeSwitch(null, typeArg.typeArgs().get(0).clone(), value); } else { this.writer.writeNull(); } @@ -112,25 +112,25 @@ public final class BsonRowGenerator implements Closeable { } private void DispatchSet(TypeArgument typeArg, Object value) { - checkArgument(typeArg.getTypeArgs().getCount() == 1); + checkArgument(typeArg.typeArgs().count() == 1); this.writer.WriteStartArray(); for (Object item : (ArrayList)value) { - this.LayoutCodeSwitch(null, typeArg.getTypeArgs().get(0).clone(), item); + this.LayoutCodeSwitch(null, typeArg.typeArgs().get(0).clone(), item); } this.writer.WriteEndArray(); } private void DispatchTuple(TypeArgument typeArg, Object value) { - checkArgument(typeArg.getTypeArgs().getCount() >= 2); + checkArgument(typeArg.typeArgs().count() >= 2); ArrayList items = (ArrayList)value; - checkArgument(items.size() == typeArg.getTypeArgs().getCount()); + checkArgument(items.size() == typeArg.typeArgs().count()); this.writer.WriteStartArray(); for (int i = 0; i < items.size(); i++) { Object item = items.get(i); - this.LayoutCodeSwitch(null, typeArg.getTypeArgs().get(i).clone(), item); + this.LayoutCodeSwitch(null, typeArg.typeArgs().get(i).clone(), item); } this.writer.WriteEndArray(); @@ -140,7 +140,7 @@ public final class BsonRowGenerator implements Closeable { this.writer.WriteStartDocument(); HashMap dict = (HashMap)value; - Layout udt = this.resolver.Resolve(typeArg.getTypeArgs().getSchemaId().clone()); + Layout udt = this.resolver.Resolve(typeArg.typeArgs().schemaId().clone()); for (LayoutColumn c : udt.columns()) { this.LayoutCodeSwitch(c.getPath(), c.getTypeArg().clone(), dict.get(c.getPath())); } @@ -153,7 +153,7 @@ public final class BsonRowGenerator implements Closeable { this.writer.WriteName(path); } - switch (typeArg.getType().LayoutCode) { + switch (typeArg.type().LayoutCode) { case Null: this.writer.WriteNull(); return; diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java index 9bd97e4..4ba589b 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java @@ -73,13 +73,13 @@ public final class CodeGenRowGenerator { } public int getLength() { - return this.row.getLength(); + return this.row.length(); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public Result ReadBuffer(byte[] buffer) public Result ReadBuffer(byte[] buffer) { - this.row = new RowBuffer(buffer.AsSpan(), HybridRowVersion.V1, this.row.getResolver()); + this.row = new RowBuffer(buffer.AsSpan(), HybridRowVersion.V1, this.row.resolver()); Reference tempReference_row = new Reference(this.row); RowCursor root = RowCursor.Create(tempReference_row); @@ -95,8 +95,8 @@ public final class CodeGenRowGenerator { } public void Reset() { - Layout layout = this.row.getResolver().Resolve(this.row.getHeader().getSchemaId().clone()); - this.row.InitLayout(HybridRowVersion.V1, layout, this.row.getResolver()); + Layout layout = this.row.resolver().Resolve(this.row.header().getSchemaId().clone()); + this.row.InitLayout(HybridRowVersion.V1, layout, this.row.resolver()); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -157,7 +157,7 @@ public final class CodeGenRowGenerator { Out tempOut_postalCodeToken = new Out(); layout.getTokenizer().TryFindToken(this.postalCode.getPath(), tempOut_postalCodeToken); this.postalCodeToken = tempOut_postalCodeToken.get(); - this.postalCodeSerializer = new PostalCodeHybridRowSerializer(resolver.Resolve(this.postalCode.getTypeArgs().getSchemaId().clone()), resolver); + this.postalCodeSerializer = new PostalCodeHybridRowSerializer(resolver.Resolve(this.postalCode.getTypeArgs().schemaId().clone()), resolver); } @Override @@ -353,7 +353,7 @@ public final class CodeGenRowGenerator { this.addresses.getTypeArgs().clone()) }); this.addressSerializer = - new AddressHybridRowSerializer(resolver.Resolve(this.addresses.getTypeArgs().get(1).getTypeArgs().getSchemaId().clone()), resolver); + new AddressHybridRowSerializer(resolver.Resolve(this.addresses.getTypeArgs().get(1).typeArgs().schemaId().clone()), resolver); this.addressSerializerWriter = (Reference b, Reference scope, HashMap context) -> addressSerializer.WriteBuffer(b, scope, context); @@ -363,7 +363,7 @@ public final class CodeGenRowGenerator { public Result ReadBuffer(Reference row, Reference root) { java.util.UUID _; Out tempOut__ = new Out(); - Result r = LayoutType.Guid.ReadFixed(row, root, this.guestId, tempOut__); + Result r = LayoutType.Guid.readFixed(row, root, this.guestId, tempOut__); _ = tempOut__.get(); if (r != Result.Success) { return r; @@ -550,7 +550,7 @@ public final class CodeGenRowGenerator { //ORIGINAL LINE: case 0 when key.Equals(GuestsHybridRowSerializer.GuestIdName): case 0 if (value != null) { - r = LayoutType.Guid.WriteFixed(row, root, this.guestId, (UUID)value); + r = LayoutType.Guid.writeFixed(row, root, this.guestId, (UUID)value); if (r != Result.Success) { return r; } @@ -796,7 +796,7 @@ public final class CodeGenRowGenerator { layout.getTokenizer().TryFindToken(this.address.getPath(), tempOut_addressToken); this.addressToken = tempOut_addressToken.get(); this.addressSerializer = - new AddressHybridRowSerializer(resolver.Resolve(this.address.getTypeArgs().getSchemaId().clone()), + new AddressHybridRowSerializer(resolver.Resolve(this.address.getTypeArgs().schemaId().clone()), resolver); } @@ -974,7 +974,7 @@ public final class CodeGenRowGenerator { public Result ReadBuffer(Reference row, Reference root) { int _; Out tempOut__ = new Out(); - Result r = LayoutType.Int32.ReadFixed(row, root, this.zip, tempOut__); + Result r = LayoutType.Int32.readFixed(row, root, this.zip, tempOut__); _ = tempOut__.get(); if (r != Result.Success) { return r; @@ -983,7 +983,7 @@ public final class CodeGenRowGenerator { root.get().Find(row, this.plus4Token.clone()); short _; Out tempOut__2 = new Out(); - Result tempVar = LayoutType.Int16.ReadSparse(row, root, tempOut__2); + Result tempVar = LayoutType.Int16.readSparse(row, root, tempOut__2); _ = tempOut__2.get(); return tempVar; } @@ -1083,7 +1083,7 @@ public final class CodeGenRowGenerator { Out tempOut__2 = new Out(); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: r = LayoutType.UInt8.ReadFixed(ref row, ref root, this.roomNumber, out byte _); - r = LayoutType.UInt8.ReadFixed(row, root, this.roomNumber, tempOut__2); + r = LayoutType.UInt8.readFixed(row, root, this.roomNumber, tempOut__2); _ = tempOut__2.get(); if (r != Result.Success) { return r; @@ -1091,7 +1091,7 @@ public final class CodeGenRowGenerator { boolean _; Out tempOut__3 = new Out(); - Result tempVar = LayoutType.Boolean.ReadFixed(row, root, this.isAvailable, tempOut__3); + Result tempVar = LayoutType.Boolean.readFixed(row, root, this.isAvailable, tempOut__3); _ = tempOut__3.get(); return tempVar; } diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/JsonModelRowGenerator.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/JsonModelRowGenerator.java index 2485fc9..a34d0cf 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/JsonModelRowGenerator.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/JsonModelRowGenerator.java @@ -4,7 +4,6 @@ package com.azure.data.cosmos.serialization.hybridrow.perf; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.ISpanResizer; @@ -49,7 +48,7 @@ public final class JsonModelRowGenerator { } public int getLength() { - return this.row.getLength(); + return this.row.length(); } public RowReader GetReader() { @@ -63,12 +62,12 @@ public final class JsonModelRowGenerator { // TODO: C# TO JAVA CONVERTER: C# to Java Converter cannot determine whether this System.IO.Stream is input or // output: public boolean ReadFrom(InputStream stream, int length) { - return this.row.ReadFrom(stream, length, HybridRowVersion.V1, this.row.getResolver()); + return this.row.ReadFrom(stream, length, HybridRowVersion.V1, this.row.resolver()); } public void Reset() { - Layout layout = this.row.getResolver().Resolve(this.row.getHeader().getSchemaId().clone()); - this.row.InitLayout(HybridRowVersion.V1, layout, this.row.getResolver()); + Layout layout = this.row.resolver().Resolve(this.row.header().getSchemaId().clone()); + this.row.InitLayout(HybridRowVersion.V1, layout, this.row.resolver()); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/RowReaderExtensions.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/RowReaderExtensions.java index c588522..c475db7 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/RowReaderExtensions.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/RowReaderExtensions.java @@ -4,11 +4,10 @@ package com.azure.data.cosmos.serialization.hybridrow.perf; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; -import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTagged2Scope; +import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TAGGED2_SCOPE; public final class RowReaderExtensions { public static Result VisitReader(Reference reader) { @@ -68,7 +67,7 @@ public final class RowReaderExtensions { case TaggedScope: case ImmutableTaggedScope: case Tagged2Scope: - case ImmutableTagged2Scope: { + case IMMUTABLE_TAGGED2_SCOPE: { // TODO: C# TO JAVA CONVERTER: The following lambda contained an unresolved 'ref' keyword - these are not converted by C# to Java Converter: Result r = reader.get().ReadScope(null, (ref RowReader child, Object _) -> child.VisitReader()); if (r != Result.Success) { diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/DeleteRowDispatcher.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/DeleteRowDispatcher.java index df71922..eb68560 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/DeleteRowDispatcher.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/DeleteRowDispatcher.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutIndexedScope; @@ -31,21 +30,21 @@ public final class DeleteRowDispatcher implements IDispatcher { public , TValue> void Dispatch(Reference dispatcher, Reference root, LayoutColumn col, LayoutType t, TValue value) { Reference tempReference_Row = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().DeleteSparse(tempReference_Row, root)); + ResultAssert.IsSuccess(t.typeAs().deleteSparse(tempReference_Row, root)); dispatcher.get().argValue.Row = tempReference_Row.get(); } public void DispatchArray(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 1); + checkArgument(typeArgs.count() == 1); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor arrayScope; Out tempOut_arrayScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadScope(tempReference_Row, scope, tempOut_arrayScope)); + ResultAssert.IsSuccess(t.typeAs().ReadScope(tempReference_Row, scope, tempOut_arrayScope)); arrayScope = tempOut_arrayScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); @@ -59,28 +58,28 @@ public final class DeleteRowDispatcher implements IDispatcher { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - // these cannot be converted using the 'Ref' helper class unless the method is within the code // being modified: - dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).getType(), - typeArgs.get(0).getTypeArgs().clone(), item); + dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).type(), + typeArgs.get(0).typeArgs().clone(), item); } } Reference tempReference_Row3 = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().DeleteScope(tempReference_Row3, scope)); + ResultAssert.IsSuccess(t.typeAs().DeleteScope(tempReference_Row3, scope)); dispatcher.get().argValue.Row = tempReference_Row3.get(); } public void DispatchMap(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 2); + checkArgument(typeArgs.count() == 2); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor mapScope; Out tempOut_mapScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadScope(tempReference_Row, scope, tempOut_mapScope)); + ResultAssert.IsSuccess(t.typeAs().ReadScope(tempReference_Row, scope, tempOut_mapScope)); mapScope = tempOut_mapScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); if (!mapScope.Immutable) { @@ -99,17 +98,17 @@ public final class DeleteRowDispatcher implements IDispatcher { Reference tempReference_Row3 = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().DeleteScope(tempReference_Row3, scope)); + ResultAssert.IsSuccess(t.typeAs().DeleteScope(tempReference_Row3, scope)); dispatcher.get().argValue.Row = tempReference_Row3.get(); } public void DispatchNullable(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 1); + checkArgument(typeArgs.count() == 1); Reference tempReference_Row = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().DeleteScope(tempReference_Row, scope)); + ResultAssert.IsSuccess(t.typeAs().DeleteScope(tempReference_Row, scope)); dispatcher.get().argValue.Row = tempReference_Row.get(); } @@ -120,14 +119,14 @@ public final class DeleteRowDispatcher implements IDispatcher { public void DispatchSet(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 1); + checkArgument(typeArgs.count() == 1); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor setScope; Out tempOut_setScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadScope(tempReference_Row, scope, tempOut_setScope)); + ResultAssert.IsSuccess(t.typeAs().ReadScope(tempReference_Row, scope, tempOut_setScope)); setScope = tempOut_setScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); if (!setScope.Immutable) { @@ -140,30 +139,30 @@ public final class DeleteRowDispatcher implements IDispatcher { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - // these cannot be converted using the 'Ref' helper class unless the method is within the code // being modified: - dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).getType(), - typeArgs.get(0).getTypeArgs().clone(), item); + dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).type(), + typeArgs.get(0).typeArgs().clone(), item); } } Reference tempReference_Row3 = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().DeleteScope(tempReference_Row3, scope)); + ResultAssert.IsSuccess(t.typeAs().DeleteScope(tempReference_Row3, scope)); dispatcher.get().argValue.Row = tempReference_Row3.get(); } public void DispatchTuple(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() >= 2); + checkArgument(typeArgs.count() >= 2); Reference tempReference_Row = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().DeleteScope(tempReference_Row, scope)); + ResultAssert.IsSuccess(t.typeAs().DeleteScope(tempReference_Row, scope)); dispatcher.get().argValue.Row = tempReference_Row.get(); } public void DispatchUDT(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { Reference tempReference_Row = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().DeleteScope(tempReference_Row, scope)); + ResultAssert.IsSuccess(t.typeAs().DeleteScope(tempReference_Row, scope)); dispatcher.get().argValue.Row = tempReference_Row.get(); } } \ No newline at end of file diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutCompilerUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutCompilerUnitTests.java index 9aa064d..03ae0a3 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutCompilerUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutCompilerUnitTests.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Float128; import com.azure.data.cosmos.serialization.hybridrow.NullValue; import com.azure.data.cosmos.serialization.hybridrow.Result; @@ -1779,7 +1778,7 @@ private final static class RoundTripSparseArray extends TestActionDispatcher tempReference_field3 = new Reference(field); - r = LayoutType.Null.WriteSparse(row, tempReference_field3, NullValue.Default); + r = LayoutType.Null.writeSparse(row, tempReference_field3, NullValue.Default); field = tempReference_field3.get(); ResultAssert.IsSuccess(r, tag); Reference tempReference_field4 = @@ -2010,7 +2009,7 @@ private final static class RoundTripSparseObject extends TestActionDispatcher tempReference_field4 = new Reference(field); - r = LayoutType.Null.WriteSparse(row, tempReference_field4, NullValue.Default); + r = LayoutType.Null.writeSparse(row, tempReference_field4, NullValue.Default); field = tempReference_field4.get(); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json); Reference tempReference_field5 = @@ -2189,7 +2188,7 @@ private final static class RoundTripSparseObjectMulti extends TestActionDispatch } else { Reference tempReference_nestedField2 = new Reference(nestedField); - r = LayoutType.Null.WriteSparse(row, tempReference_nestedField2, NullValue.Default); + r = LayoutType.Null.writeSparse(row, tempReference_nestedField2, NullValue.Default); nestedField = tempReference_nestedField2.get(); ResultAssert.IsSuccess(r, tag); } @@ -2257,12 +2256,12 @@ private final static class RoundTripSparseObjectMulti extends TestActionDispatch RowCursor _; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: - Assert.AreEqual(scope2.AsReadOnly(out _).start, scope3.start, tag); + Assert.AreEqual(scope2.AsReadOnly(out _).start, scope3.start(), tag); // Overwrite the nested field. Reference tempReference_nestedField4 = new Reference(nestedField); - r = LayoutType.Null.WriteSparse(row, tempReference_nestedField4, NullValue.Default); + r = LayoutType.Null.writeSparse(row, tempReference_nestedField4, NullValue.Default); nestedField = tempReference_nestedField4.get(); ResultAssert.IsSuccess(r, tag); @@ -2383,7 +2382,7 @@ private final static class RoundTripSparseObjectNested extends TestActionDispatc } else { Reference tempReference_field2 = new Reference(field); - r = LayoutType.Null.WriteSparse(row, tempReference_field2, NullValue.Default); + r = LayoutType.Null.writeSparse(row, tempReference_field2, NullValue.Default); field = tempReference_field2.get(); ResultAssert.IsSuccess(r, tag); } @@ -2519,7 +2518,7 @@ private final static class RoundTripSparseOrdering extends TestActionDispatcher< } else { Reference tempReference_field2 = new Reference(field); - r = LayoutType.Null.WriteSparse(row, tempReference_field2, NullValue.Default); + r = LayoutType.Null.writeSparse(row, tempReference_field2, NullValue.Default); field = tempReference_field2.get(); ResultAssert.IsSuccess(r, "Json: {0}", json); Out tempOut_value3 = new Out(); @@ -2681,7 +2680,7 @@ private final static class RoundTripSparseSet extends TestActionDispatcher tempReference_field9 = new Reference(field); - r = LayoutType.Null.WriteSparse(row, tempReference_field9, NullValue.Default); + r = LayoutType.Null.writeSparse(row, tempReference_field9, NullValue.Default); field = tempReference_field9.get(); ResultAssert.IsSuccess(r, tag); Reference tempReference_field10 = new Reference(field); @@ -2984,7 +2983,7 @@ private final static class RoundTripSparseSimple extends TestActionDispatcher tempReference_field2 = new Reference(field); - r = LayoutType.Null.WriteSparse(row, tempReference_field2, NullValue.Default); + r = LayoutType.Null.writeSparse(row, tempReference_field2, NullValue.Default); field = tempReference_field2.get(); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json); // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these @@ -3071,7 +3070,7 @@ private static class RoundTripVariable extends TestActionDispatcher tempOut_value = new Out(); - Result r = t.ReadVariable(row, root, col, tempOut_value); + Result r = t.readVariable(row, root, col, tempOut_value); value = tempOut_value.get(); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json); boolean tempVar = exValue instanceof Array; @@ -3086,7 +3085,7 @@ private static class RoundTripVariable extends TestActionDispatcher, TValue> void RoundTrip(Reference row, Reference root, LayoutColumn col, Object exValue, Expected expected) { TLayout t = (TLayout)col.getType(); - Result r = t.WriteVariable(row, root, col, (TValue)exValue); + Result r = t.writeVariable(row, root, col, (TValue)exValue); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json); this.Compare(row, root, col, exValue, expected.clone()); @@ -3096,7 +3095,7 @@ private static class RoundTripVariable extends TestActionDispatcher tempReference_roRoot = new Reference(roRoot); - ResultAssert.InsufficientPermissions(t.WriteVariable(row, tempReference_roRoot, col, (TValue)expected.Value)); + ResultAssert.InsufficientPermissions(t.writeVariable(row, tempReference_roRoot, col, (TValue)expected.Value)); roRoot = tempReference_roRoot.get(); } @@ -3169,16 +3168,16 @@ private final static class VariableInterleaving extends RoundTripVariable { this.RoundTrip(row, root, c, expected.Value, expected.clone()); // Make the var column shorter. - int rowSizeBeforeShrink = row.get().getLength(); + int rowSizeBeforeShrink = row.get().length(); this.RoundTrip(row, root, a, expected.Short, expected.clone()); this.Compare(row, root, c, expected.Value, expected.clone()); - int rowSizeAfterShrink = row.get().getLength(); + int rowSizeAfterShrink = row.get().length(); Assert.IsTrue(rowSizeAfterShrink < rowSizeBeforeShrink, "Json: {0}", expected.Json); // Make the var column longer. this.RoundTrip(row, root, a, expected.Long, expected.clone()); this.Compare(row, root, c, expected.Value, expected.clone()); - int rowSizeAfterGrow = row.get().getLength(); + int rowSizeAfterGrow = row.get().length(); Assert.IsTrue(rowSizeAfterGrow > rowSizeAfterShrink, "Json: {0}", expected.Json); Assert.IsTrue(rowSizeAfterGrow > rowSizeBeforeShrink, "Json: {0}", expected.Json); @@ -3202,13 +3201,13 @@ private final static class VariableInterleaving extends RoundTripVariable { root.get().AsReadOnly(out roRoot); Reference tempReference_roRoot = new Reference(roRoot); - ResultAssert.InsufficientPermissions(t.DeleteVariable(row, tempReference_roRoot, col)); + ResultAssert.InsufficientPermissions(t.deleteVariable(row, tempReference_roRoot, col)); roRoot = tempReference_roRoot.get(); - Result r = t.DeleteVariable(row, root, col); + Result r = t.deleteVariable(row, root, col); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json); TValue _; Out tempOut__ = new Out(); - r = t.ReadVariable(row, root, col, tempOut__); + r = t.readVariable(row, root, col, tempOut__); _ = tempOut__.get(); ResultAssert.NotFound(r, "Json: {0}", expected.Json); } @@ -3216,7 +3215,7 @@ private final static class VariableInterleaving extends RoundTripVariable { private , TValue> void TooBig(Reference row, Reference root, LayoutColumn col, Expected expected) { TLayout t = (TLayout)col.getType(); - Result r = t.WriteVariable(row, root, col, (TValue)expected.TooBig); + Result r = t.writeVariable(row, root, col, (TValue)expected.TooBig); Assert.AreEqual(Result.TooBig, r, "Json: {0}", expected.Json); } @@ -3231,7 +3230,7 @@ private final static class VariableInterleaving extends RoundTripVariable { TLayout t = (TLayout)col.Type; TValue _; Out tempOut__ = new Out(); - Result r = t.ReadVariable(row, root, col, tempOut__); + Result r = t.readVariable(row, root, col, tempOut__); _ = tempOut__.get(); ResultAssert.NotFound(r, "Json: {0}", expected.Json); return col; diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ReadRowDispatcher.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ReadRowDispatcher.java index 9a29464..3d2468e 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ReadRowDispatcher.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ReadRowDispatcher.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType; @@ -35,7 +34,7 @@ public final class ReadRowDispatcher implements IDispatcher { Reference tempReference_Row = new Reference(dispatcher.get().Row); Out tempOut_value = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadFixed(tempReference_Row, root, col, tempOut_value)); + ResultAssert.IsSuccess(t.typeAs().readFixed(tempReference_Row, root, col, tempOut_value)); value = tempOut_value.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); break; @@ -43,7 +42,7 @@ public final class ReadRowDispatcher implements IDispatcher { Reference tempReference_Row2 = new Reference(dispatcher.get().Row); Out tempOut_value2 = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadVariable(tempReference_Row2, root, col, tempOut_value2)); + ResultAssert.IsSuccess(t.typeAs().readVariable(tempReference_Row2, root, col, tempOut_value2)); value = tempOut_value2.get(); dispatcher.get().argValue.Row = tempReference_Row2.get(); break; @@ -51,7 +50,7 @@ public final class ReadRowDispatcher implements IDispatcher { Reference tempReference_Row3 = new Reference(dispatcher.get().Row); Out tempOut_value3 = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadSparse(tempReference_Row3, root, tempOut_value3)); + ResultAssert.IsSuccess(t.typeAs().readSparse(tempReference_Row3, root, tempOut_value3)); value = tempOut_value3.get(); dispatcher.get().argValue.Row = tempReference_Row3.get(); break; @@ -67,14 +66,14 @@ public final class ReadRowDispatcher implements IDispatcher { public void DispatchArray(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 1); + checkArgument(typeArgs.count() == 1); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor arrayScope; Out tempOut_arrayScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadScope(tempReference_Row, scope, tempOut_arrayScope)); + ResultAssert.IsSuccess(t.typeAs().ReadScope(tempReference_Row, scope, tempOut_arrayScope)); arrayScope = tempOut_arrayScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); @@ -87,8 +86,8 @@ public final class ReadRowDispatcher implements IDispatcher { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these // cannot be converted using the 'Ref' helper class unless the method is within the code being // modified: - dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).getType(), - typeArgs.get(0).getTypeArgs().clone(), items.get(i++)); + dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).type(), + typeArgs.get(0).typeArgs().clone(), items.get(i++)); } dispatcher.get().argValue.Row = tempReference_Row2.get(); } @@ -96,14 +95,14 @@ public final class ReadRowDispatcher implements IDispatcher { public void DispatchMap(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 2); + checkArgument(typeArgs.count() == 2); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor mapScope; Out tempOut_mapScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadScope(tempReference_Row, scope, tempOut_mapScope)); + ResultAssert.IsSuccess(t.typeAs().ReadScope(tempReference_Row, scope, tempOut_mapScope)); mapScope = tempOut_mapScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); int i = 0; @@ -124,14 +123,14 @@ public final class ReadRowDispatcher implements IDispatcher { public void DispatchNullable(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 1); + checkArgument(typeArgs.count() == 1); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor nullableScope; Out tempOut_nullableScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadScope(tempReference_Row, scope, tempOut_nullableScope)); + ResultAssert.IsSuccess(t.typeAs().ReadScope(tempReference_Row, scope, tempOut_nullableScope)); nullableScope = tempOut_nullableScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); @@ -150,8 +149,8 @@ public final class ReadRowDispatcher implements IDispatcher { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these // cannot be converted using the 'Ref' helper class unless the method is within the code being // modified: - dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).getType(), - typeArgs.get(0).getTypeArgs().clone(), value); + dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).type(), + typeArgs.get(0).typeArgs().clone(), value); } else { Reference tempReference_Row4 = new Reference(dispatcher.get().Row); @@ -170,14 +169,14 @@ public final class ReadRowDispatcher implements IDispatcher { public void DispatchSet(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 1); + checkArgument(typeArgs.count() == 1); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor setScope; Out tempOut_setScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadScope(tempReference_Row, scope, tempOut_setScope)); + ResultAssert.IsSuccess(t.typeAs().ReadScope(tempReference_Row, scope, tempOut_setScope)); setScope = tempOut_setScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); int i = 0; @@ -189,8 +188,8 @@ public final class ReadRowDispatcher implements IDispatcher { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these // cannot be converted using the 'Ref' helper class unless the method is within the code being // modified: - dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).getType(), - typeArgs.get(0).getTypeArgs().clone(), items.get(i++)); + dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).type(), + typeArgs.get(0).typeArgs().clone(), items.get(i++)); } dispatcher.get().argValue.Row = tempReference_Row2.get(); } @@ -198,18 +197,18 @@ public final class ReadRowDispatcher implements IDispatcher { public void DispatchTuple(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() >= 2); + checkArgument(typeArgs.count() >= 2); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor tupleScope; Out tempOut_tupleScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadScope(tempReference_Row, scope, tempOut_tupleScope)); + ResultAssert.IsSuccess(t.typeAs().ReadScope(tempReference_Row, scope, tempOut_tupleScope)); tupleScope = tempOut_tupleScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); - for (int i = 0; i < typeArgs.getCount(); i++) { + for (int i = 0; i < typeArgs.count(); i++) { Reference tempReference_Row2 = new Reference(dispatcher.get().Row); tupleScope.MoveNext(tempReference_Row2); @@ -218,8 +217,8 @@ public final class ReadRowDispatcher implements IDispatcher { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these // cannot be converted using the 'Ref' helper class unless the method is within the code being // modified: - dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).getType(), - typeArgs.get(i).getTypeArgs().clone(), valueAccessor.GetValue(value)); + dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).type(), + typeArgs.get(i).typeArgs().clone(), valueAccessor.GetValue(value)); } } @@ -229,7 +228,7 @@ public final class ReadRowDispatcher implements IDispatcher { Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor udtScope; Out tempOut_udtScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().ReadScope(tempReference_Row, scope, tempOut_udtScope)); + ResultAssert.IsSuccess(t.typeAs().ReadScope(tempReference_Row, scope, tempOut_udtScope)); udtScope = tempOut_udtScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); IDispatchable valueDispatcher = value instanceof IDispatchable ? (IDispatchable)value : null; diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java index 94c171d..6c532d6 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java @@ -237,7 +237,7 @@ public class RecordIOUnitTests { return r; } - buffer.setAndGet(resizer.getMemory().Slice(0, row.getLength())); + buffer.setAndGet(resizer.getMemory().Slice(0, row.length())); return Result.Success; } } \ No newline at end of file diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java index 7c5471c..cd77fa0 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Float128; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.MemorySpanResizer; @@ -182,7 +181,7 @@ public final class RowReaderUnitTests { Tuple.Create(3.0, new Point(5, 6)) }) RowReader reader = d.GetReader().clone(); - assert reader.getLength() == d.Row.getLength(); + assert reader.getLength() == d.Row.length(); Reference tempReference_reader = new Reference(reader); RowReaderUnitTests.PrintReader(tempReference_reader, 0); diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaIdUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaIdUnitTests.java index de2aa25..bff6a3e 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaIdUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaIdUnitTests.java @@ -17,10 +17,10 @@ public class SchemaIdUnitTests { SchemaId b = new SchemaId(2); SchemaId c = new SchemaId(); - assert 1 == a.getId(); - assert 2 == b.getId(); - assert SchemaId.Invalid == c.clone(); - assert 2 != a.getId(); + assert 1 == a.id(); + assert 2 == b.id(); + assert SchemaId.INVALID == c.clone(); + assert 2 != a.id(); assert a.clone() != b.clone(); assert SchemaId.opEquals(a.clone(), a.clone()); assert SchemaId.opNotEquals(a.clone(), b.clone()); diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java index b3bcd04..220798c 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java @@ -72,7 +72,7 @@ public final class SerializerUnitTest { Result r = RowWriter.WriteBuffer(tempReference_row, request, BatchRequestSerializer.Write); row = tempReference_row.get(); assert Result.Success == r; - System.out.printf("Length of serialized row: %1$s" + "\r\n", row.getLength()); + System.out.printf("Length of serialized row: %1$s" + "\r\n", row.length()); // Read the row back again. Reference tempReference_row2 = diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java index fb650ba..54b1b2b 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; @@ -344,7 +343,7 @@ public final class TupleUnitTests { RowCursor _; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: - assert valueScope.AsReadOnly(out _).start == valueScope2.start; + assert valueScope.AsReadOnly(out _).start == valueScope2.start(); RowCursor _; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: @@ -878,7 +877,7 @@ public final class TupleUnitTests { } private static void WriteCoord(Reference row, Reference coordScope, TypeArgumentList typeArgs, Coord cd) { - Layout coordLayout = row.get().getResolver().Resolve(typeArgs.getSchemaId().clone()); + Layout coordLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone()); LayoutColumn c; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified: assert coordLayout.TryFind("lat", out c); diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java index 9d5d85c..af5a8d4 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; @@ -333,7 +332,7 @@ public final class TypedArrayUnitTests { private static void WriteSimilarMatch(Reference row, Reference matchScope , TypeArgumentList typeArgs, SimilarMatch m) { - Layout matchLayout = row.get().getResolver().Resolve(typeArgs.getSchemaId().clone()); + Layout matchLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone()); LayoutColumn c; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java index fd3157d..04b2bb7 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java @@ -1179,7 +1179,7 @@ public final class TypedMapUnitTests { } private static void WriteEarnings(Reference row, Reference udtScope, TypeArgumentList typeArgs, Earnings m) { - Layout udt = row.get().getResolver().Resolve(typeArgs.getSchemaId().clone()); + Layout udt = row.get().resolver().Resolve(typeArgs.getSchemaId().clone()); LayoutColumn c; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified: assert udt.TryFind("domestic", out c); @@ -1338,7 +1338,7 @@ public final class TypedMapUnitTests { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - // these cannot be converted using the 'Ref' helper class unless the method is within the code // being modified: - ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().TypeAs().WriteSparse(row, + ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().typeAs().WriteSparse(row, ref tupleScope, item.Key)); assert tupleScope.MoveNext(row); TypeArgument valueType = c.getTypeArgs().get(1).clone(); @@ -1421,7 +1421,7 @@ public final class TypedMapUnitTests { out tupleScope)); Reference tempReference_tupleScope = new Reference(tupleScope); - ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().TypeAs().WriteSparse(row, + ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().typeAs().WriteSparse(row, tempReference_tupleScope, item.Key)); tupleScope = tempReference_tupleScope.get(); assert tupleScope.MoveNext(row); diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java index 7913edf..e46100d 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; @@ -1467,7 +1466,7 @@ public final class TypedSetUnitTests { } private static void WriteShoppingItem(Reference row, Reference matchScope, TypeArgumentList typeArgs, ShoppingItem m) { - Layout matchLayout = row.get().getResolver().Resolve(typeArgs.getSchemaId().clone()); + Layout matchLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone()); LayoutColumn c; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified: assert matchLayout.TryFind("label", out c); @@ -1507,7 +1506,7 @@ public final class TypedSetUnitTests { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - // these cannot be converted using the 'Ref' helper class unless the method is within the code // being modified: - ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().TypeAs().WriteSparse(row, + ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().typeAs().WriteSparse(row, ref tempCursor, item)); Reference tempReference_attendScope = new Reference(attendScope); @@ -1546,7 +1545,7 @@ public final class TypedSetUnitTests { root.get().Clone(out tempCursor).Find(row, Utf8String.Empty); Reference tempReference_tempCursor2 = new Reference(tempCursor); - ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().TypeAs().WriteSparse(row, + ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().typeAs().WriteSparse(row, tempReference_tempCursor2, item)); tempCursor = tempReference_tempCursor2.get(); Reference tempReference_projScope = @@ -1586,7 +1585,7 @@ public final class TypedSetUnitTests { root.get().Clone(out tempCursor).Find(row, Utf8String.Empty); Reference tempReference_tempCursor4 = new Reference(tempCursor); - ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().TypeAs().WriteSparse(row, + ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().typeAs().WriteSparse(row, tempReference_tempCursor4, item)); tempCursor = tempReference_tempCursor4.get(); Reference tempReference_checkboxScope = diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java index ed3cc6a..b9f9b2d 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType; @@ -33,19 +32,19 @@ public final class WriteRowDispatcher implements IDispatcher { case Fixed: Reference tempReference_Row = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().WriteFixed(tempReference_Row, field, col, value)); + ResultAssert.IsSuccess(t.typeAs().writeFixed(tempReference_Row, field, col, value)); dispatcher.get().argValue.Row = tempReference_Row.get(); break; case Variable: Reference tempReference_Row2 = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().WriteVariable(tempReference_Row2, field, col, value)); + ResultAssert.IsSuccess(t.typeAs().writeVariable(tempReference_Row2, field, col, value)); dispatcher.get().argValue.Row = tempReference_Row2.get(); break; default: Reference tempReference_Row3 = new Reference(dispatcher.get().Row); - ResultAssert.IsSuccess(t.TypeAs().WriteSparse(tempReference_Row3, field, value)); + ResultAssert.IsSuccess(t.typeAs().writeSparse(tempReference_Row3, field, value)); dispatcher.get().argValue.Row = tempReference_Row3.get(); break; } @@ -54,14 +53,14 @@ public final class WriteRowDispatcher implements IDispatcher { public void DispatchArray(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 1); + checkArgument(typeArgs.count() == 1); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor arrayScope; Out tempOut_arrayScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), + ResultAssert.IsSuccess(t.typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), tempOut_arrayScope)); arrayScope = tempOut_arrayScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); @@ -71,8 +70,8 @@ public final class WriteRowDispatcher implements IDispatcher { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these // cannot be converted using the 'Ref' helper class unless the method is within the code being // modified: - dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).getType(), - typeArgs.get(0).getTypeArgs().clone(), item); + dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).type(), + typeArgs.get(0).typeArgs().clone(), item); Reference tempReference_Row2 = new Reference(dispatcher.get().Row); arrayScope.MoveNext(tempReference_Row2); @@ -83,20 +82,20 @@ public final class WriteRowDispatcher implements IDispatcher { public void DispatchMap(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 2); + checkArgument(typeArgs.count() == 2); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor mapScope; Out tempOut_mapScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), + ResultAssert.IsSuccess(t.typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), tempOut_mapScope)); mapScope = tempOut_mapScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); Reference tempReference_mapScope = new Reference(mapScope); - TypeArgument fieldType = t.TypeAs().FieldType(tempReference_mapScope).clone(); + TypeArgument fieldType = t.typeAs().FieldType(tempReference_mapScope).clone(); mapScope = tempReference_mapScope.get(); List pairs = (List)value; for (Object pair : pairs) { @@ -122,7 +121,7 @@ public final class WriteRowDispatcher implements IDispatcher { new Reference(mapScope); Reference tempReference_tempCursor = new Reference(tempCursor); - ResultAssert.IsSuccess(t.TypeAs().MoveField(tempReference_Row3, tempReference_mapScope2, + ResultAssert.IsSuccess(t.typeAs().MoveField(tempReference_Row3, tempReference_mapScope2, tempReference_tempCursor)); tempCursor = tempReference_tempCursor.get(); mapScope = tempReference_mapScope2.get(); @@ -133,14 +132,14 @@ public final class WriteRowDispatcher implements IDispatcher { public void DispatchNullable(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 1); + checkArgument(typeArgs.count() == 1); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor nullableScope; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: - ResultAssert.IsSuccess(t.TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), + ResultAssert.IsSuccess(t.typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), value != null, out nullableScope)); dispatcher.get().argValue.Row = tempReference_Row.get(); @@ -148,8 +147,8 @@ public final class WriteRowDispatcher implements IDispatcher { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these // cannot be converted using the 'Ref' helper class unless the method is within the code being // modified: - dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).getType(), - typeArgs.get(0).getTypeArgs().clone(), value); + dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).type(), + typeArgs.get(0).typeArgs().clone(), value); } } @@ -160,14 +159,14 @@ public final class WriteRowDispatcher implements IDispatcher { public void DispatchSet(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() == 1); + checkArgument(typeArgs.count() == 1); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor setScope; Out tempOut_setScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), + ResultAssert.IsSuccess(t.typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), tempOut_setScope)); setScope = tempOut_setScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); @@ -185,8 +184,8 @@ public final class WriteRowDispatcher implements IDispatcher { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these // cannot be converted using the 'Ref' helper class unless the method is within the code being // modified: - dispatcher.get().LayoutCodeSwitch(ref tempCursor, elmPath, typeArgs.get(0).getType(), - typeArgs.get(0).getTypeArgs().clone(), item); + dispatcher.get().LayoutCodeSwitch(ref tempCursor, elmPath, typeArgs.get(0).type(), + typeArgs.get(0).typeArgs().clone(), item); // Move item into the set. Reference tempReference_Row3 = @@ -195,7 +194,7 @@ public final class WriteRowDispatcher implements IDispatcher { new Reference(setScope); Reference tempReference_tempCursor = new Reference(tempCursor); - ResultAssert.IsSuccess(t.TypeAs().MoveField(tempReference_Row3, tempReference_setScope, + ResultAssert.IsSuccess(t.typeAs().MoveField(tempReference_Row3, tempReference_setScope, tempReference_tempCursor)); tempCursor = tempReference_tempCursor.get(); setScope = tempReference_setScope.get(); @@ -206,24 +205,24 @@ public final class WriteRowDispatcher implements IDispatcher { public void DispatchTuple(Reference dispatcher, Reference scope, LayoutType t, TypeArgumentList typeArgs, Object value) { - checkArgument(typeArgs.getCount() >= 2); + checkArgument(typeArgs.count() >= 2); Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor tupleScope; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: - ResultAssert.IsSuccess(t.TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), + ResultAssert.IsSuccess(t.typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), out tupleScope)); dispatcher.get().argValue.Row = tempReference_Row.get(); - for (int i = 0; i < typeArgs.getCount(); i++) { + for (int i = 0; i < typeArgs.count(); i++) { PropertyInfo valueAccessor = value.getClass().GetProperty(String.format("Item%1$s", i + 1)); // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these // cannot be converted using the 'Ref' helper class unless the method is within the code being // modified: - dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).getType(), - typeArgs.get(i).getTypeArgs().clone(), valueAccessor.GetValue(value)); + dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).type(), + typeArgs.get(i).typeArgs().clone(), valueAccessor.GetValue(value)); Reference tempReference_Row2 = new Reference(dispatcher.get().Row); tupleScope.MoveNext(tempReference_Row2); @@ -237,7 +236,7 @@ public final class WriteRowDispatcher implements IDispatcher { Reference tempReference_Row = new Reference(dispatcher.get().Row); RowCursor udtScope; Out tempOut_udtScope = new Out(); - ResultAssert.IsSuccess(t.TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), tempOut_udtScope)); + ResultAssert.IsSuccess(t.typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), tempOut_udtScope)); udtScope = tempOut_udtScope.get(); dispatcher.get().argValue.Row = tempReference_Row.get(); IDispatchable valueDispatcher = value instanceof IDispatchable ? (IDispatchable)value : null;