From 93380aee9ef90371ee9a6c92c38268b69c43796c Mon Sep 17 00:00:00 2001 From: David Noble Date: Sat, 7 Sep 2019 00:57:17 -0700 Subject: [PATCH] Progressed on dotnet port to java --- .../azure/data/cosmos/core/UtfAnyString.java | 129 +- .../serialization/hybridrow/RowBuffer.java | 2 +- .../serialization/hybridrow/RowCursor.java | 4 +- .../serialization/hybridrow/io/RowReader.java | 1779 ++++++++--------- .../serialization/hybridrow/io/RowWriter.java | 2 +- .../json/RowReaderJsonExtensions.java | 46 +- .../hybridrow/layouts/Layout.java | 4 +- .../hybridrow/layouts/LayoutBuilder.java | 14 +- .../hybridrow/layouts/LayoutColumn.java | 4 +- .../hybridrow/layouts/LayoutCompiler.java | 6 +- .../hybridrow/recordio/SegmentSerializer.java | 8 +- .../hybridrow/schemas/SchemaValidator.java | 4 +- .../hybridrow/schemas/StorageKind.java | 13 +- .../hybridrow/perf/CodeGenRowGenerator.java | 4 +- .../unit/CustomerExampleUnitTests.java | 24 +- .../hybridrow/unit/NullableUnitTests.java | 8 +- .../unit/RowOperationDispatcher.java | 4 +- .../hybridrow/unit/RowReaderUnitTests.java | 34 +- .../hybridrow/unit/RowWriterUnitTests.java | 2 +- .../hybridrow/unit/SchemaUnitTests.java | 4 +- .../hybridrow/unit/SerializerUnitTest.java | 18 +- .../hybridrow/unit/TaggedUnitTests.java | 4 +- .../hybridrow/unit/TupleUnitTests.java | 32 +- .../hybridrow/unit/TypedArrayUnitTests.java | 4 +- .../hybridrow/unit/TypedMapUnitTests.java | 18 +- .../hybridrow/unit/TypedSetUnitTests.java | 34 +- .../hybridrow/unit/WriteRowDispatcher.java | 4 +- .../customerschema/AddressSerializer.java | 4 +- .../customerschema/PostalCodeSerializer.java | 8 +- 29 files changed, 1030 insertions(+), 1191 deletions(-) diff --git a/java/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java b/java/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java index 6fc57c5..cb1cf74 100644 --- a/java/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java +++ b/java/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java @@ -22,9 +22,6 @@ public final class UtfAnyString implements CharSequence, Comparable { + final int ignored = ((String) this.buffer).codePoints().reduce(0, (index, codePoint) -> { if (index % 2 == 0) { hash[0] = ((hash[0] << 5) + hash[0]) ^ codePoint; } else { @@ -247,126 +240,6 @@ public final class UtfAnyString implements CharSequence, Comparable 0; - } - - public static boolean opGreaterThan(UtfAnyString left, String right) { - return left.compareTo(right) > 0; - } - - public static boolean opGreaterThan(String left, UtfAnyString right) { - return right.compareTo(left) <= 0; - } - - public static boolean opGreaterThan(UtfAnyString left, Utf8String right) { - return left.compareTo(right) > 0; - } - - public static boolean opGreaterThan(Utf8String left, UtfAnyString right) { - return right.compareTo(left) <= 0; - } - - public static boolean opGreaterThanOrEquals(UtfAnyString left, UtfAnyString right) { - return left.compareTo(right.clone()) >= 0; - } - - public static boolean opGreaterThanOrEquals(UtfAnyString left, String right) { - return left.compareTo(right) >= 0; - } - - public static boolean opGreaterThanOrEquals(String left, UtfAnyString right) { - return right.compareTo(left) < 0; - } - - public static boolean opGreaterThanOrEquals(UtfAnyString left, Utf8String right) { - return left.compareTo(right) >= 0; - } - - public static boolean opGreaterThanOrEquals(Utf8String left, UtfAnyString right) { - return right.compareTo(left) < 0; - } - - public static boolean opLessThan(UtfAnyString left, UtfAnyString right) { - return left.compareTo(right.clone()) < 0; - } - - public static boolean opLessThan(UtfAnyString left, String right) { - return left.compareTo(right) < 0; - } - - public static boolean opLessThan(String left, UtfAnyString right) { - return right.compareTo(left) >= 0; - } - - public static boolean opLessThan(UtfAnyString left, Utf8String right) { - return left.compareTo(right) < 0; - } - - public static boolean opLessThan(Utf8String left, UtfAnyString right) { - return right.compareTo(left) >= 0; - } - - public static boolean opLessThanOrEquals(UtfAnyString left, UtfAnyString right) { - return left.compareTo(right.clone()) <= 0; - } - - public static boolean opLessThanOrEquals(UtfAnyString left, String right) { - return left.compareTo(right) <= 0; - } - - public static boolean opLessThanOrEquals(String left, UtfAnyString right) { - return right.compareTo(left) > 0; - } - - public static boolean opLessThanOrEquals(UtfAnyString left, Utf8String right) { - return left.compareTo(right) <= 0; - } - - public static boolean opLessThanOrEquals(Utf8String left, UtfAnyString right) { - return right.compareTo(left) > 0; - } - - public static boolean opNotEquals(UtfAnyString left, UtfAnyString right) { - return !left.equals(right.clone()); - } - - public static boolean opNotEquals(UtfAnyString left, String right) { - return !left.equals(right); - } - - public static boolean opNotEquals(String left, UtfAnyString right) { - return !right.equals(left); - } - - public static boolean opNotEquals(UtfAnyString left, Utf8String right) { - return !left.equals(right); - } - - public static boolean opNotEquals(Utf8String left, UtfAnyString right) { - return !right.equals(left); - } - /** * Returns a {@code CharSequence} that is a subsequence of this sequence *

diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java index a843abd..42126af 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java @@ -2900,7 +2900,7 @@ public final class RowBuffer { private ByteBuf readVariableBinary() { long length = this.read7BitEncodedUInt(); checkState(length <= Integer.MAX_VALUE, "expected length <= %s, not %s", Integer.MAX_VALUE, length); - return this.buffer.readSlice((int)length); + return this.buffer.readSlice((int)length).asReadOnly(); } private void shift(int destination, int source, int length) { diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java index 851b65a..089ad08 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java @@ -48,7 +48,7 @@ public final class RowCursor implements Cloneable { } } - public static RowCursor Create(RowBuffer row) { + public static RowCursor create(RowBuffer row) { final SchemaId schemaId = row.readSchemaId(1); final Layout layout = row.resolver().resolve(schemaId); @@ -63,7 +63,7 @@ public final class RowCursor implements Cloneable { .valueOffset(sparseSegmentOffset); } - public static RowCursor CreateForAppend(RowBuffer row) { + public static RowCursor createForAppend(RowBuffer row) { final SchemaId schemaId = row.readSchemaId(1); final Layout layout = row.resolver().resolve(schemaId); diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java index 3b579f2..6788fe8 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java @@ -44,77 +44,81 @@ 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.TypeArgumentList; import com.azure.data.cosmos.serialization.hybridrow.schemas.StorageKind; +import com.google.common.base.Strings; +import io.netty.buffer.ByteBuf; +import javax.annotation.Nonnull; import java.math.BigDecimal; -import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.util.List; import java.util.UUID; import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Strings.lenientFormat; /** * A forward-only, streaming, field reader for {@link RowBuffer}. *

- * A {@link RowReader} allows the traversal in a streaming, left to right fashion, of - * an entire HybridRow. The row's layout provides decoding for any schematized portion of the row. - * However, unschematized sparse fields are read directly from the sparse segment with or without - * schematization allowing all fields within the row, both known and unknown, to be read. - * - * Modifying a {@link RowBuffer} invalidates any reader or child reader associated with it. In - * general {@link RowBuffer}'s should not be mutated while being enumerated. + * A {@link RowReader} allows the traversal in a streaming, left to right fashion, of an entire HybridRow. The row's + * layout provides decoding for any schematized portion of the row. However, unschematized sparse fields are read + * directly from the sparse segment with or without schematization allowing all fields within the row, both known and + * unknown, to be read. + *

+ * Modifying a {@link RowBuffer} invalidates any reader or child reader associated with it. In general{@link RowBuffer}s + * should not be mutated while being enumerated. */ public final class RowReader { private int columnIndex; - private ReadOnlySpan columns; + private List columns; private RowCursor cursor; private RowBuffer row; private int schematizedCount; private States state; // checkpoint state + /** + * Initializes a new instance of the {@link RowReader} class + * + * @param row The row to be read + */ + public RowReader(RowBuffer row) { + this(row, RowCursor.create(row)); + } + + /** + * Initializes a new instance of the {@link RowReader} class. + * @param row The row to be read + * @param checkpoint Initial state of the reader + */ + public RowReader(@Nonnull final RowBuffer row, @Nonnull final Checkpoint checkpoint) { + + this.row = row; + this.columns = checkpoint.cursor().layout().columns(); + this.schematizedCount = checkpoint.cursor().layout().numFixed() + checkpoint.cursor().layout().numVariable(); + + this.state = checkpoint.state(); + this.cursor = checkpoint.cursor(); + this.columnIndex = checkpoint.columnIndex(); + } + private RowReader() { } /** - * Initializes a new instance of the {@link RowReader} struct. + * Initializes a new instance of the {@link RowReader} class * * @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.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 + * @param scope Cursor defining the scope of the fields to be read *

- * 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 + * 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) { + private RowReader(RowBuffer row, RowCursor scope) { - this.cursor = scope.clone(); - this.row = row.get().clone(); + this.cursor = scope; + this.row = row; this.columns = this.cursor.layout().columns(); this.schematizedCount = this.cursor.layout().numFixed() + this.cursor.layout().numVariable(); @@ -122,562 +126,6 @@ public final class RowReader { this.columnIndex = -1; } - /** - * True if field has a value (if positioned on a field, undefined otherwise). - *

- * If the current field is a Nullable scope, this method return true if the value is not - * null. If the current field is a nullable Null primitive value, this method return true if the value - * 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 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 = row.get(); - return tempVar; - } - return true; - - default: - return false; - } - } - - /** - * The 0-based index, relative to the start of the scope, of the field (if positioned on a - * field, undefined otherwise). - *

- * When enumerating a non-indexed scope, this value is always 0 (see {@link Path}). - */ - public int getIndex() { - switch (this.state) { - case Schematized: - return 0; - case Sparse: - return this.cursor.index(); - default: - return 0; - } - } - - /** - * The length of row in bytes. - */ - public int getLength() { - return this.row.length(); - } - - /** - * 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}). - */ - public UtfAnyString getPath() { - switch (this.state) { - case Schematized: - return this.columns[this.columnIndex].Path; - case Sparse: - if (this.cursor.pathOffset() == 0) { - return null; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - Utf8Span span = this.row.readSparsePath(tempReference_cursor); - this.cursor = tempReference_cursor.get(); - return Utf8String.CopyFrom(span); - default: - return null; - } - } - - /** - * 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}). - */ - public Utf8Span getPathSpan() { - switch (this.state) { - case Schematized: - return this.columns[this.columnIndex].Path.Span; - case Sparse: - Reference tempReference_cursor = - new Reference(this.cursor); - Utf8Span tempVar = this.row.readSparsePath(tempReference_cursor); - this.cursor = tempReference_cursor.get(); - return tempVar; - default: - return null; - } - } - - /** - * The storage placement of the field (if positioned on a field, undefined otherwise). - */ - public StorageKind getStorage() { - switch (this.state) { - case Schematized: - return this.columns[this.columnIndex].Storage; - case Sparse: - return StorageKind.Sparse; - default: - return null; - } - } - - /** - * The type of the field (if positioned on a field, undefined otherwise). - */ - public LayoutType getType() { - switch (this.state) { - case Schematized: - return this.columns[this.columnIndex].Type; - case Sparse: - return this.cursor.cellType(); - default: - return null; - } - } - - /** - * The type arguments of the field (if positioned on a field, undefined otherwise). - */ - public TypeArgumentList getTypeArgs() { - switch (this.state) { - case Schematized: - return this.columns[this.columnIndex].TypeArgs; - case Sparse: - return this.cursor.cellTypeArgs().clone(); - default: - return TypeArgumentList.EMPTY; - } - } - - /** - * Advances the reader to the next field. - * - * @return True, if there is another field to be read, false otherwise. - */ - public boolean Read() { - - switch (this.state) { - case None: { - 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; - } else { - this.state = States.Sparse; - // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: - // goto case States.Sparse; - } - } - case Schematized: { - - this.columnIndex++; - - if (this.columnIndex >= this.schematizedCount) { - this.state = States.Sparse; - // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: - // goto case States.Sparse; - } - - checkState(this.cursor.scopeType() instanceof LayoutUDT); - LayoutColumn col = this.columns[this.columnIndex]; - - 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; - } - - return true; - } - - case Sparse: { - - Reference tempReference_row = new Reference(this.row); - - if (!RowCursors.moveNext(this.cursor.clone(), - tempReference_row)) { - this.row = tempReference_row.get(); - this.state = States.Done; - // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: - // goto case States.Done; - } else { - this.row = tempReference_row.get(); - } - - return true; - } - - case Done: { - return false; - } - } - - return false; - } - - /** - * Read the current field as a variable length, sequence of bytes. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result ReadBinary(out byte[] value) - public Result ReadBinary(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: - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: Result r = this.ReadBinary(out ReadOnlySpan span); - Result r = this.ReadBinary(out span); - value.setAndGet((r == Result.SUCCESS) ? span.ToArray() :) - default - return r; - } - - /** - * Read the current field as a variable length, sequence of bytes. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result ReadBinary(out ReadOnlySpan value) - public Result ReadBinary(Out> value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutBinary)) { - value.setAndGet(null); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseBinary(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(null); - return Result.FAILURE; - } - } - - /** - * Read the current field as a {@link bool}. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadBool(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutBoolean)) { - value.setAndGet(false); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseBoolean(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(false); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length {@link DateTime} value. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadDateTime(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutDateTime)) { - value.setAndGet(LocalDateTime.MIN); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseDateTime(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(LocalDateTime.MIN); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length {@link decimal} value. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadDecimal(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutDecimal)) { - value.setAndGet(new BigDecimal(0)); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseDecimal(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(new BigDecimal(0)); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 128-bit, IEEE-encoded floating point value. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadFloat128(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value.clone()); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutFloat128)) { - value.setAndGet(null); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseFloat128(tempReference_cursor).clone()); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(null); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 32-bit, IEEE-encoded floating point value. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadFloat32(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutFloat32)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseFloat32(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 64-bit, IEEE-encoded floating point value. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadFloat64(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutFloat64)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseFloat64(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length {@link Guid} value. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadGuid(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutGuid)) { - value.setAndGet(null); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseGuid(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(null); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 16-bit, signed integer. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadInt16(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutInt16)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseInt16(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 32-bit, signed integer. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadInt32(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutInt32)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseInt32(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 64-bit, signed integer. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadInt64(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutInt64)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseInt64(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 8-bit, signed integer. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadInt8(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutInt8)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseInt8(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - /** * Read the current field as a fixed length {@link MongoDbObjectId} value. * @@ -685,74 +133,26 @@ public final class RowReader { * @return Success if the read is successful, an error code otherwise. */ public Result ReadMongoDbObjectId(Out value) { + switch (this.state) { + case Schematized: - return this.ReadPrimitiveValue(value.clone()); + return this.readPrimitiveValue(value); + case Sparse: if (!(this.cursor.cellType() instanceof LayoutMongoDbObjectId)) { - value.setAndGet(null); + value.set(null); return Result.TYPE_MISMATCH; } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.ReadSparseMongoDbObjectId(tempReference_cursor).clone()); - this.cursor = tempReference_cursor.get(); + value.set(this.row.readSparseMongoDbObjectId(this.cursor)); return Result.SUCCESS; + default: - value.setAndGet(null); + value.set(null); return Result.FAILURE; } } - /** - * Read the current field as a null. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadNull(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value.clone()); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutNull)) { - value.setAndGet(null); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseNull(tempReference_cursor).clone()); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(null); - return Result.FAILURE; - } - } - - /** - * Read the current field as a nested, structured, sparse scope. - *

- * Child readers can be used to read all sparse scope types including typed and untyped - * objects, arrays, tuples, set, and maps. - * - * Nested child readers are independent of their parent. - */ - public RowReader ReadScope() { - Reference tempReference_cursor = - new Reference(this.cursor); - RowCursor newScope = this.row.sparseIteratorReadScope(tempReference_cursor, true).clone(); - this.cursor = tempReference_cursor.get(); - Reference tempReference_row = - new Reference(this.row); - // TODO: C# TO JAVA CONVERTER: The following line could not be converted: - return new RowReader(ref this.row, newScope) - this.row = tempReference_row.get(); - return tempVar; - } - /** * Read the current field as a nested, structured, sparse scope. *

@@ -800,7 +200,7 @@ public final class RowReader { // 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: Result r = this.ReadString(out span); - value.setAndGet((r == Result.SUCCESS) ? span.toString() :) + value.set((r == Result.SUCCESS) ? span.toString() :) default return r; } @@ -812,181 +212,22 @@ public final class RowReader { * @return Success if the read is successful, an error code otherwise. */ public Result ReadString(Out value) { - Utf8Span 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: - Result r = this.ReadString(out span); - value.setAndGet((r == Result.SUCCESS) ? Utf8String.CopyFrom(span) :) - default - return r; - } - /** - * Read the current field as a variable length, UTF8 encoded, string value. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadString(Out value) { switch (this.state) { + case Schematized: - return this.ReadPrimitiveValue(value); + return this.readPrimitiveValue(value); + case Sparse: if (!(this.cursor.cellType() instanceof LayoutUtf8)) { - value.setAndGet(null); + value.set(null); return Result.TYPE_MISMATCH; } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseString(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); + value.set(this.row.readSparseString(this.cursor)); return Result.SUCCESS; + default: - value.setAndGet(null); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 16-bit, unsigned integer. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result ReadUInt16(out ushort value) - public Result ReadUInt16(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutUInt16)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseUInt16(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 32-bit, unsigned integer. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result ReadUInt32(out uint value) - public Result ReadUInt32(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutUInt32)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseUInt32(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 64-bit, unsigned integer. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result ReadUInt64(out ulong value) - public Result ReadUInt64(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutUInt64)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseUInt64(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length, 8-bit, unsigned integer. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result ReadUInt8(out byte value) - public Result ReadUInt8(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutUInt8)) { - value.setAndGet(0); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseUInt8(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(0); - return Result.FAILURE; - } - } - - /** - * Read the current field as a fixed length {@link UnixDateTime} value. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadUnixDateTime(Out value) { - switch (this.state) { - case Schematized: - return this.ReadPrimitiveValue(value.clone()); - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutUnixDateTime)) { - value.setAndGet(null); - return Result.TYPE_MISMATCH; - } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseUnixDateTime(tempReference_cursor).clone()); - this.cursor = tempReference_cursor.get(); - return Result.SUCCESS; - default: - value.setAndGet(null); + value.set(null); return Result.FAILURE; } } @@ -998,22 +239,22 @@ public final class RowReader { * @return Success if the read is successful, an error code otherwise. */ public Result ReadVarInt(Out value) { + switch (this.state) { + case Schematized: - return this.ReadPrimitiveValue(value); + return this.readPrimitiveValue(value); + case Sparse: if (!(this.cursor.cellType() instanceof LayoutVarInt)) { - value.setAndGet(0); + value.set(0L); return Result.TYPE_MISMATCH; } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseVarInt(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); + value.set(this.row.readSparseVarInt(this.cursor)); return Result.SUCCESS; + default: - value.setAndGet(0); + value.set(0L); return Result.FAILURE; } } @@ -1024,31 +265,29 @@ public final class RowReader { * @param value On success, receives the value, undefined otherwise. * @return Success if the read is successful, an error code otherwise. */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result ReadVarUInt(out ulong value) public Result ReadVarUInt(Out value) { + switch (this.state) { + case Schematized: - return this.ReadPrimitiveValue(value); + return this.readPrimitiveValue(value); + case Sparse: if (!(this.cursor.cellType() instanceof LayoutVarUInt)) { - value.setAndGet(0); + value.set(0L); return Result.TYPE_MISMATCH; } - - Reference tempReference_cursor = - new Reference(this.cursor); - value.setAndGet(this.row.readSparseVarUInt(tempReference_cursor)); - this.cursor = tempReference_cursor.get(); + value.set(this.row.readSparseVarUInt(this.cursor)); return Result.SUCCESS; + default: - value.setAndGet(0); + value.set(0L); return Result.FAILURE; } } public Checkpoint SaveCheckpoint() { - return new Checkpoint(this.state, this.columnIndex, this.cursor.clone()); + return new Checkpoint(this.state, this.columnIndex, this.cursor); } /** @@ -1057,7 +296,7 @@ public final class RowReader { *

*

* The reader must not have been advanced since the child reader was created with ReadScope. - * This method can be used when the overload of {@link ReadScope} that takes a + * This method can be used when the overload of {@link #readScope} that takes a * {@link ReaderFunc{TContext}} is not an option, such as when TContext is a ref struct. */ public Result SkipScope(Reference nestedReader) { @@ -1089,6 +328,719 @@ public final class RowReader { return varCopy; } + /** + * {@code true} if field has a value--if positioned on a field--undefined otherwise + *

+ * If the current field is a Nullable scope, this method return true if the value is not null. If the current field + * is a nullable Null primitive value, this method return true if the value is set (even though its values is set + * to null). + */ + public boolean hasValue() { + + switch (this.state) { + + case Schematized: + return true; + + case Sparse: + if (this.cursor.cellType() instanceof LayoutNullable) { + RowCursor nullableScope = this.row.sparseIteratorReadScope(this.cursor, true); + return LayoutNullable.hasValue(this.row, nullableScope) == Result.SUCCESS; + } + return true; + + default: + return false; + } + } + + /** + * Zero-based index, relative to the scope, of the field--if positioned on a field--undefined otherwise + *

+ * When enumerating a non-indexed scope, this value is always 0 (see {@link #path}). + */ + public int index() { + return this.state == States.Sparse ? this.cursor.index() : 0; + } + + /** + * The length of row in bytes. + */ + public int length() { + return this.row.length(); + } + + /** + * 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}). + */ + public UtfAnyString path() { + + Utf8String value; + + switch (this.state) { + + case Schematized: + value = this.columns.get(this.columnIndex).path(); + break; + + case Sparse: + value = this.cursor.pathOffset() == 0 ? null : this.row.readSparsePath(this.cursor); + break; + + default: + value = null; + break; + } + + return new UtfAnyString(value); + } + + /** + * 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}). + */ + public Utf8String pathSpan() { + switch (this.state) { + case Schematized: + return this.columns.get(this.columnIndex).path(); + case Sparse: + return this.row.readSparsePath(this.cursor); + default: + return null; + } + } + + /** + * Advances the reader to the next field. + * + * @return True, if there is another field to be read, false otherwise. + */ + public boolean read() { + + switch (this.state) { + + case None: { + 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; + } else { + this.state = States.Sparse; + // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: + // goto case States.Sparse; + } + } + case Schematized: { + + this.columnIndex++; + + if (this.columnIndex >= this.schematizedCount) { + this.state = States.Sparse; + // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: + // goto case States.Sparse; + } + + checkState(this.cursor.scopeType() instanceof LayoutUDT); + LayoutColumn column = this.columns.get(this.columnIndex); + + if (!this.row.readBit(this.cursor.start(), column.nullBit())) { + // Skip schematized values if they aren't present + // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: + // goto case States.Schematized; + } + + return true; + } + + case Sparse: { + + if (!RowCursors.moveNext(this.cursor, this.row)) { + this.state = States.Done; + // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: + // goto case States.Done; + } + return true; + } + + case Done: { + return false; + } + } + + return false; + } + + /** + * Read the current field as a variable length, sequence of bytes. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readBinary(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + + if (!(this.cursor.cellType() instanceof LayoutBinary)) { + value.set(null); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseBinary(this.cursor)); + return Result.SUCCESS; + + default: + value.set(null); + return Result.FAILURE; + } + } + + /** + * Read the current field as a variable length, sequence of bytes + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readBinaryArray(Out value) { + + Out buffer = new Out<>(); + Result result = this.readBinary(buffer); + + if (result == Result.SUCCESS) { + byte[] array = new byte[buffer.get().writerIndex()]; + buffer.get().getBytes(0, array); + value.set(array); + } + + return result; + } + + /** + * Read the current field as a {@link Boolean}. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readBoolean(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutBoolean)) { + value.set(false); + return Result.TYPE_MISMATCH; + } + + value.set(this.row.readSparseBoolean(this.cursor)); + return Result.SUCCESS; + + default: + value.set(false); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length {@code DateTime} value. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readDateTime(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutDateTime)) { + value.set(OffsetDateTime.MIN); + return Result.TYPE_MISMATCH; + } + + value.set(this.row.readSparseDateTime(this.cursor)); + return Result.SUCCESS; + + default: + value.set(OffsetDateTime.MIN); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length decimal value + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readDecimal(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutDecimal)) { + value.set(new BigDecimal(0)); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseDecimal(this.cursor)); + return Result.SUCCESS; + + default: + value.set(new BigDecimal(0)); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 128-bit, IEEE-encoded floating point value. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readFloat128(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutFloat128)) { + value.setAndGet(null); + return Result.TYPE_MISMATCH; + } + value.setAndGet(this.row.readSparseFloat128(this.cursor)); + return Result.SUCCESS; + + default: + value.setAndGet(null); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 32-bit, IEEE-encoded floating point value. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readFloat32(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutFloat32)) { + value.set(0F); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseFloat32(this.cursor)); + return Result.SUCCESS; + + default: + value.set(0F); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 64-bit, IEEE-encoded floating point value. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readFloat64(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutFloat64)) { + value.set(0D); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseFloat64(this.cursor)); + return Result.SUCCESS; + + default: + value.set(0D); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length GUID value. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readGuid(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutGuid)) { + value.set(null); + return Result.TYPE_MISMATCH; + } + + value.set(this.row.readSparseGuid(this.cursor)); + return Result.SUCCESS; + + default: + value.set(null); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 16-bit, signed integer. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readInt16(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutInt16)) { + value.set((short)0); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseInt16(this.cursor)); + return Result.SUCCESS; + + default: + value.set((short)0); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 32-bit, signed integer. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readInt32(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutInt32)) { + value.set(0); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseInt32(this.cursor)); + return Result.SUCCESS; + + default: + value.set(0); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 64-bit, signed integer. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readInt64(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutInt64)) { + value.setAndGet(0L); + return Result.TYPE_MISMATCH; + } + value.setAndGet(this.row.readSparseInt64(this.cursor)); + return Result.SUCCESS; + + default: + value.setAndGet(0L); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 8-bit, signed integer. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readInt8(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutInt8)) { + value.set((byte)0); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseInt8(this.cursor)); + return Result.SUCCESS; + + default: + value.set((byte)0); + return Result.FAILURE; + } + } + + /** + * Read the current field as a null. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readNull(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutNull)) { + value.set(null); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseNull(this.cursor)); + return Result.SUCCESS; + + default: + value.set(null); + return Result.FAILURE; + } + } + + /** + * Read the current field as a nested, structured, sparse scope + *

+ * Child readers can be used to read all sparse scope types including typed and untyped objects, arrays, tuples, + * set, and maps. + *

+ * Nested child readers are independent of their parent. + */ + public @Nonnull RowReader readScope() { + RowCursor newScope = this.row.sparseIteratorReadScope(this.cursor, true); + return new RowReader(this.row, newScope); + } + + /** + * Read the current field as a fixed length, 16-bit, unsigned integer. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readUInt16(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutUInt16)) { + value.set(0); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseUInt16(this.cursor)); + return Result.SUCCESS; + + default: + value.set(0); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 32-bit, unsigned integer. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readUInt32(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutUInt32)) { + value.set(0L); + return Result.TYPE_MISMATCH; + } + + value.set(this.row.readSparseUInt32(this.cursor)); + return Result.SUCCESS; + + default: + value.set(0L); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 64-bit, unsigned integer. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readUInt64(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutUInt64)) { + value.set(0L); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseUInt64(this.cursor)); + return Result.SUCCESS; + + default: + value.set(0L); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length, 8-bit, unsigned integer. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readUInt8(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutUInt8)) { + value.set((short)0); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseUInt8(this.cursor)); + return Result.SUCCESS; + + default: + value.set((short)0); + return Result.FAILURE; + } + } + + /** + * Read the current field as a fixed length {@link UnixDateTime} value. + * + * @param value On success, receives the value, undefined otherwise. + * @return Success if the read is successful, an error code otherwise. + */ + public Result readUnixDateTime(Out value) { + + switch (this.state) { + + case Schematized: + return this.readPrimitiveValue(value); + + case Sparse: + if (!(this.cursor.cellType() instanceof LayoutUnixDateTime)) { + value.set(null); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseUnixDateTime(this.cursor)); + return Result.SUCCESS; + + default: + value.set(null); + return Result.FAILURE; + } + } + + /** + * The storage placement of the field--if positioned on a field--undefined otherwise + */ + public StorageKind storage() { + switch (this.state) { + case Schematized: + return this.columns.get(this.columnIndex).storage(); + case Sparse: + return StorageKind.SPARSE; + default: + return null; + } + } + + /** + * The type of the field--if positioned on a field--undefined otherwise + */ + public LayoutType type() { + + switch (this.state) { + case Schematized: + return this.columns.get(this.columnIndex).type(); + case Sparse: + return this.cursor.cellType(); + default: + return null; + } + } + + /** + * The type arguments of the field (if positioned on a field, undefined otherwise). + */ + public TypeArgumentList typeArgs() { + + switch (this.state) { + case Schematized: + return this.columns.get(this.columnIndex).typeArgs(); + case Sparse: + return this.cursor.cellTypeArgs(); + default: + return TypeArgumentList.EMPTY; + } + } + /** * Read a generic schematized field value via the scope's layout. * The expected type of the field. @@ -1096,34 +1048,26 @@ public final class RowReader { * @param value On success, receives the value, undefined otherwise. * @return Success if the read is successful, an error code otherwise. */ - private Result ReadPrimitiveValue(Out value) { - LayoutColumn col = this.columns[this.columnIndex]; - LayoutType t = this.columns[this.columnIndex].Type; - if (!(t instanceof LayoutType)) { - value.setAndGet(null); + private Result readPrimitiveValue(Out value) { + + final LayoutColumn column = this.columns.get(this.columnIndex); + final LayoutType type = this.columns.get(this.columnIndex).type(); + + if (!(type instanceof LayoutType)) { + value.set(null); return Result.TYPE_MISMATCH; } - switch (col == null ? null : col.storage()) { - 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); - 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); - this.cursor = tempReference_cursor2.get(); - this.row = tempReference_row2.get(); - return tempVar2; + final StorageKind storage = column == null ? StorageKind.NONE : column.storage(); + + switch (storage) { + case FIXED: + return type.>typeAs().readFixed(this.row, this.cursor, column, value); + case VARIABLE: + return type.>typeAs().readVariable(this.row, this.cursor, column, value); default: - throw new IllegalStateException(); - value.setAndGet(null); + assert false : lenientFormat("expected FIXED or VARIABLE column storage, not %s", storage); + value.set(null); return Result.FAILURE; } } @@ -1134,33 +1078,33 @@ public final class RowReader { * @param value On success, receives the value, undefined otherwise. * @return Success if the read is successful, an error code otherwise. */ - private Result ReadPrimitiveValue(Out value) { - LayoutColumn col = this.columns[this.columnIndex]; - LayoutType t = this.columns[this.columnIndex].Type; + private Result readPrimitiveValue(Out value) { + LayoutColumn column = this.columns.get(this.columnIndex); + LayoutType t = this.columns.get(this.columnIndex).Type; if (!(t instanceof ILayoutUtf8SpanReadable)) { - value.setAndGet(null); + value.set(null); return Result.TYPE_MISMATCH; } - switch (col == null ? null : col.storage()) { - case Fixed: + switch (column == null ? null : column.storage()) { + 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, column, value); this.cursor = tempReference_cursor.get(); this.row = tempReference_row.get(); return tempVar; - case Variable: + 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); + tempReference_cursor2, column, value); this.cursor = tempReference_cursor2.get(); this.row = tempReference_row2.get(); return tempVar2; default: throw new IllegalStateException(); - value.setAndGet(null); + value.set(null); return Result.FAILURE; } } @@ -1172,32 +1116,36 @@ public final class RowReader { * @param value On success, receives the value, undefined otherwise. * @return Success if the read is successful, an error code otherwise. */ - private Result ReadPrimitiveValue(Out> value) { - LayoutColumn col = this.columns[this.columnIndex]; - LayoutType t = this.columns[this.columnIndex].Type; + private Result readPrimitiveValue(Out> value) { + + LayoutColumn column = this.columns.get(this.columnIndex); + LayoutType t = this.columns.get(this.columnIndex).type(); + if (!(t instanceof ILayoutSpanReadable)) { - value.setAndGet(null); + value.set(null); return Result.TYPE_MISMATCH; } - switch (col == null ? null : col.storage()) { - case Fixed: + switch (column == null ? null : column.storage()) { + 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, column, value); this.cursor = tempReference_cursor.get(); this.row = tempReference_row.get(); return tempVar; - case Variable: + 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, column, value); this.cursor = tempReference_cursor2.get(); this.row = tempReference_row2.get(); return tempVar2; default: throw new IllegalStateException(); - value.setAndGet(null); + value.set(null); return Result.FAILURE; } } @@ -1205,8 +1153,6 @@ public final class RowReader { /** * The current traversal state of the reader. */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal enum States : byte public enum States { /** * The reader has not be started yet. @@ -1228,19 +1174,20 @@ public final class RowReader { */ Done; - public static final int SIZE = java.lang.Byte.SIZE; + public static final int BYTES = Byte.BYTES; - public byte getValue() { - return this.ordinal(); + public static States from(byte value) { + return values()[value]; } - public static States forValue(byte value) { - return values()[value]; + public byte value() { + return (byte) this.ordinal(); } } /** * A function to reader content from a {@link RowBuffer}. + *

* The type of the context value passed by the caller. * * @param reader A forward-only cursor for writing content. @@ -1256,31 +1203,43 @@ public final class RowReader { * An encapsulation of the current state of a {@link RowReader} that can be used to * recreate the {@link RowReader} in the same logical position. */ - //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 Checkpoint - //C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct: public final static class Checkpoint { - public int ColumnIndex; - public RowCursor Cursor = new RowCursor(); - public States State = States.values()[0]; - public Checkpoint() { - } + private int columnIndex; + private RowCursor cursor; + private States state; public Checkpoint(States state, int columnIndex, RowCursor cursor) { - this.State = state; - this.ColumnIndex = columnIndex; - this.Cursor = cursor.clone(); + this.state(state); + this.columnIndex(columnIndex); + this.cursor(cursor); } - public Checkpoint clone() { - Checkpoint varCopy = new Checkpoint(); + public int columnIndex() { + return this.columnIndex; + } - varCopy.State = this.State; - varCopy.ColumnIndex = this.ColumnIndex; - varCopy.Cursor = this.Cursor.clone(); + public Checkpoint columnIndex(int columnIndex) { + this.columnIndex = columnIndex; + return this; + } - return varCopy; + public RowCursor cursor() { + return this.cursor; + } + + public Checkpoint cursor(RowCursor cursor) { + this.cursor = cursor; + return this; + } + + public States state() { + return this.state; + } + + public Checkpoint state(States state) { + this.state = state; + return this; } } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java index 6c99c00..199dc3e 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java @@ -161,7 +161,7 @@ public final class RowWriter { */ public static Result WriteBuffer(Reference row, TContext context, WriterFunc func) { - RowCursor scope = RowCursor.Create(row); + RowCursor scope = RowCursor.create(row); Reference tempReference_scope = new Reference(scope); RowWriter writer = new RowWriter(row, tempReference_scope); diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java index 768ad7a..3db4646 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java @@ -53,9 +53,9 @@ public final class RowReaderJsonExtensions { private static Result ToJson(Reference reader, ReaderStringContext ctx) { int index = 0; - while (reader.get().Read()) { - String path = !reader.get().getPath().IsNull ? String.format("%1$s%2$s%3$s:", ctx.Settings.QuoteChar, - reader.get().getPath(), ctx.Settings.QuoteChar) : null; + while (reader.get().read()) { + String path = !reader.get().path().IsNull ? String.format("%1$s%2$s%3$s:", ctx.Settings.QuoteChar, + reader.get().path(), ctx.Settings.QuoteChar) : null; if (index != 0) { ctx.Builder.append(','); } @@ -71,12 +71,12 @@ public final class RowReaderJsonExtensions { Result r; char scopeBracket = '\0'; char scopeCloseBracket = '\0'; - switch (reader.get().getType().LayoutCode) { + switch (reader.get().type().LayoutCode) { case Null: { NullValue _; Out tempOut__ = new Out(); - r = reader.get().ReadNull(tempOut__); + r = reader.get().readNull(tempOut__); _ = tempOut__.get(); if (r != Result.SUCCESS) { return r; @@ -89,7 +89,7 @@ public final class RowReaderJsonExtensions { case Boolean: { boolean value; Out tempOut_value = new Out(); - r = reader.get().ReadBool(tempOut_value); + r = reader.get().readBoolean(tempOut_value); value = tempOut_value.get(); if (r != Result.SUCCESS) { return r; @@ -102,7 +102,7 @@ public final class RowReaderJsonExtensions { case Int8: { byte value; Out tempOut_value2 = new Out(); - r = reader.get().ReadInt8(tempOut_value2); + r = reader.get().readInt8(tempOut_value2); value = tempOut_value2.get(); if (r != Result.SUCCESS) { return r; @@ -115,7 +115,7 @@ public final class RowReaderJsonExtensions { case Int16: { short value; Out tempOut_value3 = new Out(); - r = reader.get().ReadInt16(tempOut_value3); + r = reader.get().readInt16(tempOut_value3); value = tempOut_value3.get(); if (r != Result.SUCCESS) { return r; @@ -128,7 +128,7 @@ public final class RowReaderJsonExtensions { case Int32: { int value; Out tempOut_value4 = new Out(); - r = reader.get().ReadInt32(tempOut_value4); + r = reader.get().readInt32(tempOut_value4); value = tempOut_value4.get(); if (r != Result.SUCCESS) { return r; @@ -141,7 +141,7 @@ public final class RowReaderJsonExtensions { case Int64: { long value; Out tempOut_value5 = new Out(); - r = reader.get().ReadInt64(tempOut_value5); + r = reader.get().readInt64(tempOut_value5); value = tempOut_value5.get(); if (r != Result.SUCCESS) { return r; @@ -156,7 +156,7 @@ public final class RowReaderJsonExtensions { Out tempOut_value6 = new Out(); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: r = reader.ReadUInt8(out byte value); - r = reader.get().ReadUInt8(tempOut_value6); + r = reader.get().readUInt8(tempOut_value6); value = tempOut_value6.get(); if (r != Result.SUCCESS) { return r; @@ -171,7 +171,7 @@ public final class RowReaderJsonExtensions { Out tempOut_value7 = new Out(); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: r = reader.ReadUInt16(out ushort value); - r = reader.get().ReadUInt16(tempOut_value7); + r = reader.get().readUInt16(tempOut_value7); value = tempOut_value7.get(); if (r != Result.SUCCESS) { return r; @@ -186,7 +186,7 @@ public final class RowReaderJsonExtensions { Out tempOut_value8 = new Out(); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: r = reader.ReadUInt32(out uint value); - r = reader.get().ReadUInt32(tempOut_value8); + r = reader.get().readUInt32(tempOut_value8); value = tempOut_value8.get(); if (r != Result.SUCCESS) { return r; @@ -201,7 +201,7 @@ public final class RowReaderJsonExtensions { Out tempOut_value9 = new Out(); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: r = reader.ReadUInt64(out ulong value); - r = reader.get().ReadUInt64(tempOut_value9); + r = reader.get().readUInt64(tempOut_value9); value = tempOut_value9.get(); if (r != Result.SUCCESS) { return r; @@ -242,7 +242,7 @@ public final class RowReaderJsonExtensions { case Float32: { float value; Out tempOut_value12 = new Out(); - r = reader.get().ReadFloat32(tempOut_value12); + r = reader.get().readFloat32(tempOut_value12); value = tempOut_value12.get(); if (r != Result.SUCCESS) { return r; @@ -255,7 +255,7 @@ public final class RowReaderJsonExtensions { case Float64: { double value; Out tempOut_value13 = new Out(); - r = reader.get().ReadFloat64(tempOut_value13); + r = reader.get().readFloat64(tempOut_value13); value = tempOut_value13.get(); if (r != Result.SUCCESS) { return r; @@ -269,7 +269,7 @@ public final class RowReaderJsonExtensions { Float128 _; Out tempOut__2 = new Out(); - r = reader.get().ReadFloat128(tempOut__2); + r = reader.get().readFloat128(tempOut__2); _ = tempOut__2.get(); if (r != Result.SUCCESS) { return r; @@ -283,7 +283,7 @@ public final class RowReaderJsonExtensions { case Decimal: { java.math.BigDecimal value; Out tempOut_value14 = new Out(); - r = reader.get().ReadDecimal(tempOut_value14); + r = reader.get().readDecimal(tempOut_value14); value = tempOut_value14.get(); if (r != Result.SUCCESS) { return r; @@ -296,7 +296,7 @@ public final class RowReaderJsonExtensions { case DateTime: { java.time.LocalDateTime value; Out tempOut_value15 = new Out(); - r = reader.get().ReadDateTime(tempOut_value15); + r = reader.get().readDateTime(tempOut_value15); value = tempOut_value15.get(); if (r != Result.SUCCESS) { return r; @@ -312,7 +312,7 @@ public final class RowReaderJsonExtensions { UnixDateTime value; Out tempOut_value16 = new Out(); - r = reader.get().ReadUnixDateTime(tempOut_value16); + r = reader.get().readUnixDateTime(tempOut_value16); value = tempOut_value16.get(); if (r != Result.SUCCESS) { return r; @@ -325,7 +325,7 @@ public final class RowReaderJsonExtensions { case Guid: { java.util.UUID value; Out tempOut_value17 = new Out(); - r = reader.get().ReadGuid(tempOut_value17); + r = reader.get().readGuid(tempOut_value17); value = tempOut_value17.get(); if (r != Result.SUCCESS) { return r; @@ -389,7 +389,7 @@ public final class RowReaderJsonExtensions { case NullableScope: case ImmutableNullableScope: { - if (!reader.get().getHasValue()) { + if (!reader.get().hasValue()) { ctx.Builder.append("null"); break; } @@ -443,7 +443,7 @@ public final class RowReaderJsonExtensions { } default: { - throw new IllegalStateException(lenientFormat("Unknown type will be ignored: %s", reader.get().getType().LayoutCode)); + throw new IllegalStateException(lenientFormat("Unknown type will be ignored: %s", reader.get().type().LayoutCode)); break; } } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java index 047aab4..edcbf81 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java @@ -80,9 +80,9 @@ public final class Layout { this.pathMap.put(column.fullPath(), column); this.pathStringMap.put(column.fullPath().toString(), column); - if (column.storage() == StorageKind.Fixed) { + if (column.storage() == StorageKind.FIXED) { numFixed++; - } else if (column.storage() == StorageKind.Variable) { + } else if (column.storage() == StorageKind.VARIABLE) { numVariable++; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java index 4faad48..75c1225 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java @@ -45,16 +45,16 @@ public final class LayoutBuilder { if (type.isNull()) { checkArgument(nullable); LayoutBit nullBit = this.bitAllocator.Allocate(); - column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Fixed, this.parent(), + column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.FIXED, this.parent(), this.fixedCount, 0, nullBit, LayoutBit.INVALID, 0); } else if (type.isBoolean()) { LayoutBit nullBit = nullable ? this.bitAllocator.Allocate() : LayoutBit.INVALID; LayoutBit boolbit = this.bitAllocator.Allocate(); - column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Fixed, this.parent(), + column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.FIXED, this.parent(), this.fixedCount, 0, nullBit, boolbit, 0); } else { LayoutBit nullBit = nullable ? this.bitAllocator.Allocate() : LayoutBit.INVALID; - column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Fixed, this.parent(), + column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.FIXED, this.parent(), this.fixedCount, this.fixedSize, nullBit, LayoutBit.INVALID, length); this.fixedSize += type.isFixed() ? type.size() : length; @@ -66,7 +66,7 @@ public final class LayoutBuilder { public void addObjectScope(String path, LayoutType type) { - LayoutColumn column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Sparse, this.parent(), + LayoutColumn column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.SPARSE, this.parent(), this.sparseCount, -1, LayoutBit.INVALID, LayoutBit.INVALID, 0); this.sparseCount++; @@ -76,7 +76,7 @@ public final class LayoutBuilder { public void addSparseColumn(String path, LayoutType type) { - LayoutColumn column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Sparse, this.parent(), + LayoutColumn column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.SPARSE, this.parent(), this.sparseCount, -1, LayoutBit.INVALID, LayoutBit.INVALID, 0); this.sparseCount++; @@ -85,7 +85,7 @@ public final class LayoutBuilder { public void addTypedScope(String path, LayoutType type, TypeArgumentList typeArgs) { - LayoutColumn col = new LayoutColumn(path, type, typeArgs, StorageKind.Sparse, this.parent(), this.sparseCount, + LayoutColumn col = new LayoutColumn(path, type, typeArgs, StorageKind.SPARSE, this.parent(), this.sparseCount, -1, LayoutBit.INVALID, LayoutBit.INVALID, 0); this.sparseCount++; @@ -97,7 +97,7 @@ public final class LayoutBuilder { checkArgument(length >= 0); checkArgument(type.allowVariable()); - LayoutColumn column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Variable, this.parent(), + LayoutColumn column = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.VARIABLE, this.parent(), this.varCount, this.varCount, this.bitAllocator.Allocate(), LayoutBit.INVALID, length); this.varCount++; diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java index 84df3be..6046f88 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java @@ -101,9 +101,9 @@ public final class LayoutColumn { } /** - * If {@link #storage} equals {@link StorageKind#Fixed} then the byte offset to the field location. + * If {@link #storage} equals {@link StorageKind#FIXED} then the byte offset to the field location. *

- * If {@link #storage} equals {@link StorageKind#Variable} then the zero-based index of the field from the + * If {@link #storage} equals {@link StorageKind#VARIABLE} then the zero-based index of the field from the * beginning of the variable length segment. *

* For all other values of {@link #storage}, {@link #offset} is ignored. diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java index ee2364d..33742b6 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java @@ -98,7 +98,7 @@ public final class LayoutCompiler { (PrimitivePropertyType)tempVar : null; if (pp != null) { switch (pp.storage()) { - case Fixed: + case FIXED: if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) { throw new LayoutCompilationException("Cannot have fixed storage within a sparse " + "scope."); @@ -111,7 +111,7 @@ public final class LayoutCompiler { builder.addFixedColumn(p.path(), type, pp.nullable(), pp.length()); break; - case Variable: + case VARIABLE: if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) { throw new LayoutCompilationException("Cannot have variable storage within a " + "sparse scope."); @@ -124,7 +124,7 @@ public final class LayoutCompiler { builder.addVariableColumn(p.path(), type, pp.length()); break; - case Sparse: + case SPARSE: if (!pp.nullable()) { throw new LayoutCompilationException("Non-nullable sparse columns are not " + "supported."); diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java index 2dc7519..c78eaef 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java @@ -28,14 +28,14 @@ public final class SegmentSerializer { public static Result Read(Reference reader, Out obj) { obj.setAndGet(null); - while (reader.get().Read()) { + while (reader.get().read()) { Result r; // TODO: use Path tokens here. - switch (reader.get().getPath().toString()) { + switch (reader.get().path().toString()) { case "length": Out tempOut_Length = new Out(); - r = reader.get().ReadInt32(tempOut_Length); + r = reader.get().readInt32(tempOut_Length); obj.get().argValue.Length = tempOut_Length.get(); if (r != Result.SUCCESS) { return r; @@ -43,7 +43,7 @@ public final class SegmentSerializer { // If the RowBuffer isn't big enough to contain the rest of the header, then just // return the length. - if (reader.get().getLength() < obj.get().Length) { + if (reader.get().length() < obj.get().Length) { return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java index 4431dab..d62de26 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java @@ -57,8 +57,8 @@ HashMap ids pp: ValidateAssert.IsTrue(pp.Length >= 0, "Length MUST be positive"); if (parent != null) { - ValidateAssert.AreEqual(pp.Storage, StorageKind.Sparse, String.format("Nested fields MUST have " + - "storage %1$s", StorageKind.Sparse)); + ValidateAssert.AreEqual(pp.Storage, StorageKind.SPARSE, String.format("Nested fields MUST have " + + "storage %1$s", StorageKind.SPARSE)); } break; diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StorageKind.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StorageKind.java index 294d41b..0658b7d 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StorageKind.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StorageKind.java @@ -7,6 +7,13 @@ package com.azure.data.cosmos.serialization.hybridrow.schemas; * Describes the storage placement for primitive properties. */ public enum StorageKind { + /** + * The property does not define a column + *

+ * This is indicative of an error in the the column specification. + */ + NONE(-1), + /** * The property defines a sparse column *

@@ -14,14 +21,14 @@ public enum StorageKind { * linked list at the end of the row. Access time for sparse columns is proportional to the number of sparse columns * in the row. */ - Sparse(0), + SPARSE(0), /** * The property is a fixed-length, space-reserved column *

* The column will consume 1 null-bit, and its byte-width regardless of whether the value is present in the row. */ - Fixed(1), + FIXED(1), /** * The property is a variable-length column. @@ -32,7 +39,7 @@ public enum StorageKind { * When a long value is marked variable then a null-bit is reserved and the value is optionally encoded as * variable if small enough to fit, otherwise the null-bit is set and the value is encoded as sparse. */ - Variable(2); + VARIABLE(2); public static final int SIZE = java.lang.Integer.SIZE; private static java.util.HashMap mappings; diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java index 369eb36..ce04f08 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java @@ -81,7 +81,7 @@ public final class CodeGenRowGenerator { this.row = new RowBuffer(buffer.AsSpan(), HybridRowVersion.V1, this.row.resolver()); Reference tempReference_row = new Reference(this.row); - RowCursor root = RowCursor.Create(tempReference_row); + RowCursor root = RowCursor.create(tempReference_row); this.row = tempReference_row.get(); Reference tempReference_row2 = new Reference(this.row); @@ -107,7 +107,7 @@ public final class CodeGenRowGenerator { public Result WriteBuffer(HashMap tableValue) { Reference tempReference_row = new Reference(this.row); - RowCursor root = RowCursor.Create(tempReference_row); + RowCursor root = RowCursor.create(tempReference_row); this.row = tempReference_row.get(); Reference tempReference_row2 = new Reference(this.row); diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CustomerExampleUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CustomerExampleUnitTests.java index 011d9ce..0d1bde6 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CustomerExampleUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CustomerExampleUnitTests.java @@ -68,7 +68,7 @@ public final class CustomerExampleUnitTests { Reference tempReference_row = new Reference(row); - RowCursor rc1 = RowCursor.Create(tempReference_row); + RowCursor rc1 = RowCursor.create(tempReference_row); row = tempReference_row.get(); Reference tempReference_row2 = new Reference(row); @@ -79,7 +79,7 @@ public final class CustomerExampleUnitTests { row = tempReference_row2.get(); Reference tempReference_row3 = new Reference(row); - RowCursor rc2 = RowCursor.Create(tempReference_row3); + RowCursor rc2 = RowCursor.create(tempReference_row3); row = tempReference_row3.get(); Reference tempReference_row4 = new Reference(row); @@ -93,7 +93,7 @@ public final class CustomerExampleUnitTests { // Append an item to an existing list. Reference tempReference_row5 = new Reference(row); - RowCursor rc3 = RowCursor.Create(tempReference_row5); + RowCursor rc3 = RowCursor.create(tempReference_row5); row = tempReference_row5.get(); Reference tempReference_row6 = new Reference(row); @@ -106,7 +106,7 @@ public final class CustomerExampleUnitTests { g1.Emails.add("vice_president@whitehouse.gov"); Reference tempReference_row7 = new Reference(row); - RowCursor rc4 = RowCursor.Create(tempReference_row7); + RowCursor rc4 = RowCursor.create(tempReference_row7); row = tempReference_row7.get(); Reference tempReference_row8 = new Reference(row); @@ -120,7 +120,7 @@ public final class CustomerExampleUnitTests { // Prepend an item to an existing list. Reference tempReference_row9 = new Reference(row); - RowCursor rc5 = RowCursor.Create(tempReference_row9); + RowCursor rc5 = RowCursor.create(tempReference_row9); row = tempReference_row9.get(); Reference tempReference_row10 = new Reference(row); @@ -135,7 +135,7 @@ public final class CustomerExampleUnitTests { } Reference tempReference_row11 = new Reference(row); - RowCursor rc6 = RowCursor.Create(tempReference_row11); + RowCursor rc6 = RowCursor.create(tempReference_row11); row = tempReference_row11.get(); Reference tempReference_row12 = new Reference(row); @@ -149,7 +149,7 @@ public final class CustomerExampleUnitTests { // InsertAt an item to an existing list. Reference tempReference_row13 = new Reference(row); - RowCursor rc7 = RowCursor.Create(tempReference_row13); + RowCursor rc7 = RowCursor.create(tempReference_row13); row = tempReference_row13.get(); Reference tempReference_row14 = new Reference(row); @@ -166,7 +166,7 @@ public final class CustomerExampleUnitTests { Reference tempReference_row15 = new Reference(row); - RowCursor rc8 = RowCursor.Create(tempReference_row15); + RowCursor rc8 = RowCursor.create(tempReference_row15); row = tempReference_row15.get(); Reference tempReference_row16 = new Reference(row); @@ -187,7 +187,7 @@ public final class CustomerExampleUnitTests { Hotel h1 = this.hotelExample; Reference tempReference_row = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row); + RowCursor root = RowCursor.create(tempReference_row); row = tempReference_row.get(); Reference tempReference_row2 = new Reference(row); @@ -199,7 +199,7 @@ public final class CustomerExampleUnitTests { Reference tempReference_row3 = new Reference(row); - root = RowCursor.Create(tempReference_row3); + root = RowCursor.create(tempReference_row3); row = tempReference_row3.get(); Reference tempReference_row4 = new Reference(row); @@ -221,7 +221,7 @@ public final class CustomerExampleUnitTests { Hotel h1 = this.hotelExample; Reference tempReference_row = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row); + RowCursor root = RowCursor.create(tempReference_row); row = tempReference_row.get(); Reference tempReference_row2 = new Reference(row); @@ -233,7 +233,7 @@ public final class CustomerExampleUnitTests { Reference tempReference_row3 = new Reference(row); - root = RowCursor.Create(tempReference_row3); + root = RowCursor.create(tempReference_row3); row = tempReference_row3.get(); Address tempVar = new Address(); tempVar.setStreet("300B Brownie Way"); diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java index 72039f8..773d6ee 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java @@ -59,7 +59,7 @@ public final class NullableUnitTests { 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: - this.WriteNullables(tempReference_row, RowCursor.Create(tempReference_row2, out _), t1); + this.WriteNullables(tempReference_row, RowCursor.create(tempReference_row2, out _), t1); row = tempReference_row2.get(); row = tempReference_row.get(); Reference tempReference_row3 = @@ -69,7 +69,7 @@ public final class NullableUnitTests { 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: - Nullables t2 = this.ReadNullables(tempReference_row3, RowCursor.Create(tempReference_row4, out _)); + Nullables t2 = this.ReadNullables(tempReference_row3, RowCursor.create(tempReference_row4, out _)); row = tempReference_row4.get(); row = tempReference_row3.get(); assert t1 == t2; @@ -516,7 +516,7 @@ public final class NullableUnitTests { // 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: - RowCursor.CreateForAppend(row, out temp).Find(row, ""); + RowCursor.createForAppend(row, out temp).Find(row, ""); Reference tempReference_temp = new Reference(temp); RowCursor _; @@ -632,7 +632,7 @@ public final class NullableUnitTests { // 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: - RowCursor.CreateForAppend(row, out temp).Find(row, ""); + RowCursor.createForAppend(row, out temp).Find(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 diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowOperationDispatcher.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowOperationDispatcher.java index e8fd058..cfce084 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowOperationDispatcher.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowOperationDispatcher.java @@ -122,7 +122,7 @@ public final class RowOperationDispatcher { public void LayoutCodeSwitch(String path, LayoutType type, TypeArgumentList typeArgs, Object value) { Reference tempReference_Row = new Reference(this.Row); - RowCursor root = RowCursor.Create(tempReference_Row); + RowCursor root = RowCursor.create(tempReference_Row); this.Row = tempReference_Row.get(); Reference tempReference_root = new Reference(root); @@ -164,7 +164,7 @@ public final class RowOperationDispatcher { typeArgs = col.typeArgs().clone(); } - if ((path != null) && (col == null || col.storage() == StorageKind.Sparse)) { + if ((path != null) && (col == null || col.storage() == StorageKind.SPARSE)) { Reference tempReference_Row = new Reference(this.Row); scope.get().Find(tempReference_Row, path); diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java index fcdc12a..66f387d 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java @@ -180,7 +180,7 @@ public final class RowReaderUnitTests { Tuple.Create(3.0, new Point(5, 6)) }) RowReader reader = d.GetReader().clone(); - assert reader.getLength() == d.Row.length(); + assert reader.length() == d.Row.length(); Reference tempReference_reader = new Reference(reader); RowReaderUnitTests.PrintReader(tempReference_reader, 0); @@ -235,14 +235,14 @@ public final class RowReaderUnitTests { new Reference(row); rowReader = new RowReader(tempReference_row5); row = tempReference_row5.get(); - assert rowReader.Read(); - assert rowReader.getType().LayoutCode == LayoutCode.ObjectScope; - RowReader nestedScope = rowReader.ReadScope().clone(); + assert rowReader.read(); + assert rowReader.type().LayoutCode == LayoutCode.ObjectScope; + RowReader nestedScope = rowReader.readScope().clone(); Reference tempReference_nestedScope = new Reference(nestedScope); ResultAssert.IsSuccess(RowReaderUnitTests.ReadNestedDocumentDelegate(tempReference_nestedScope, 0)); nestedScope = tempReference_nestedScope.get(); - assert rowReader.Read(); + assert rowReader.read(); Reference tempReference_nestedScope2 = new Reference(nestedScope); Result result = rowReader.SkipScope(tempReference_nestedScope2); @@ -251,8 +251,8 @@ public final class RowReaderUnitTests { } private static Result ReadNestedDocumentDelegate(Reference reader, int context) { - while (reader.get().Read()) { - switch (reader.get().getType().LayoutCode) { + while (reader.get().read()) { + switch (reader.get().type().LayoutCode) { case TupleScope: { ResultAssert.IsSuccess(reader.get().ReadScope(0, RowReaderUnitTests.ReadTuplePartial)); break; @@ -269,10 +269,10 @@ public final class RowReaderUnitTests { } private static Result ReadNestedDocumentNonDelegate(Reference reader, int context) { - while (reader.get().Read()) { - switch (reader.get().getType().LayoutCode) { + while (reader.get().read()) { + switch (reader.get().type().LayoutCode) { case TupleScope: { - RowReader nested = reader.get().ReadScope().clone(); + RowReader nested = reader.get().readScope().clone(); Reference tempReference_nested = new Reference(nested); ResultAssert.IsSuccess(RowReaderUnitTests.ReadTuplePartial(tempReference_nested, 0)); @@ -281,7 +281,7 @@ public final class RowReaderUnitTests { } case ObjectScope: { - RowReader nested = reader.get().ReadScope().clone(); + RowReader nested = reader.get().readScope().clone(); Reference tempReference_nested2 = new Reference(nested); ResultAssert.IsSuccess(RowReaderUnitTests.ReadNestedDocumentNonDelegate(tempReference_nested2, 0)); @@ -297,10 +297,10 @@ public final class RowReaderUnitTests { private static Result ReadNestedDocumentNonDelegateWithSkipScope(Reference reader, int context) { - while (reader.get().Read()) { - switch (reader.get().getType().LayoutCode) { + while (reader.get().read()) { + switch (reader.get().type().LayoutCode) { case TupleScope: { - RowReader nested = reader.get().ReadScope().clone(); + RowReader nested = reader.get().readScope().clone(); Reference tempReference_nested = new Reference(nested); ResultAssert.IsSuccess(RowReaderUnitTests.ReadTuplePartial(tempReference_nested, 0)); @@ -313,7 +313,7 @@ public final class RowReaderUnitTests { } case ObjectScope: { - RowReader nested = reader.get().ReadScope().clone(); + RowReader nested = reader.get().readScope().clone(); Reference tempReference_nested3 = new Reference(nested); ResultAssert.IsSuccess(RowReaderUnitTests.ReadNestedDocumentNonDelegate(tempReference_nested3, 0)); @@ -332,8 +332,8 @@ public final class RowReaderUnitTests { private static Result ReadTuplePartial(Reference reader, int unused) { // Read only part of our tuple - assert reader.get().Read(); - assert reader.get().Read(); + assert reader.get().read(); + assert reader.get().read(); return Result.SUCCESS; } diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowWriterUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowWriterUnitTests.java index 0343cbf..8407f7b 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowWriterUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowWriterUnitTests.java @@ -501,7 +501,7 @@ public final class RowWriterUnitTests { Reference tempReference_row2 = new Reference(row); RowReader reader = new RowReader(tempReference_row2); row = tempReference_row2.get(); - assert reader.getLength() == writerLength; + assert reader.length() == writerLength; Reference tempReference_reader = new Reference(reader); RowReaderUnitTests.PrintReader(tempReference_reader, 0); reader = tempReference_reader.get(); diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaUnitTests.java index 1c48f4d..e3ac29e 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaUnitTests.java @@ -136,8 +136,8 @@ public class SchemaUnitTests { Storage = _Storage; } } - Object[] expectedProps = new Object[] { AnonymousType("a", TypeKind.Int8, StorageKind.Fixed), - AnonymousType2("b", TypeKind.Utf8, StorageKind.Variable) }; + Object[] expectedProps = new Object[] { AnonymousType("a", TypeKind.Int8, StorageKind.FIXED), + AnonymousType2("b", TypeKind.Utf8, StorageKind.VARIABLE) }; for (int i = 0; i < n1.getSchemas().get(0).getProperties().size(); i++) { Property p = n1.getSchemas().get(0).getProperties().get(i); diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java index f71458d..393af36 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java @@ -138,12 +138,12 @@ public final class SerializerUnitTest { public static Result Read(Reference reader, Out operation) { BatchOperation retval = new BatchOperation(); operation.setAndGet(null); - while (reader.get().Read()) { + while (reader.get().read()) { Result r; - switch (reader.get().getPath()) { + switch (reader.get().path()) { case "operationType": Out tempOut_OperationType = new Out(); - r = reader.get().ReadInt32(tempOut_OperationType); + r = reader.get().readInt32(tempOut_OperationType); retval.OperationType = tempOut_OperationType.get(); if (r != Result.SUCCESS) { return r; @@ -166,7 +166,7 @@ public final class SerializerUnitTest { break; case "resourceType": Out tempOut_ResourceType = new Out(); - r = reader.get().ReadInt32(tempOut_ResourceType); + r = reader.get().readInt32(tempOut_ResourceType); retval.ResourceType = tempOut_ResourceType.get(); if (r != Result.SUCCESS) { return r; @@ -244,11 +244,11 @@ public final class SerializerUnitTest { Out header) { BatchRequestHeaders retval = new BatchRequestHeaders(); header.setAndGet(null); - while (reader.get().Read()) { - switch (reader.get().getPath()) { + while (reader.get().read()) { + switch (reader.get().path()) { case "sampleRequestHeader": Out tempOut_SampleRequestHeader = new Out(); - Result r = reader.get().ReadInt64(tempOut_SampleRequestHeader); + Result r = reader.get().readInt64(tempOut_SampleRequestHeader); retval.SampleRequestHeader = tempOut_SampleRequestHeader.get(); if (r != Result.SUCCESS) { return r; @@ -273,8 +273,8 @@ public final class SerializerUnitTest { public static final TypeArgument OperationsTypeArg = new TypeArgument(LayoutType.TypedArray, new TypeArgumentList(new TypeArgument[] { BatchOperationSerializer.TypeArg })); public static Result Read(Reference reader, Out request) { - assert reader.get().Read(); - checkState(reader.get().getPath().equals("operations")); + assert reader.get().read(); + checkState(reader.get().path().equals("operations")); java.util.ArrayList operations; Out> tempOut_operations = new Out>(); diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TaggedUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TaggedUnitTests.java index b6ada00..a52d5bb 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TaggedUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TaggedUnitTests.java @@ -41,7 +41,7 @@ public final class TaggedUnitTests { 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: - this.WriteTaggedApi(tempReference_row, RowCursor.Create(tempReference_row2, out _), c1); + this.WriteTaggedApi(tempReference_row, RowCursor.create(tempReference_row2, out _), c1); row = tempReference_row2.get(); row = tempReference_row.get(); Reference tempReference_row3 = @@ -51,7 +51,7 @@ public final class TaggedUnitTests { 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: - TaggedApi c2 = this.ReadTaggedApi(tempReference_row3, RowCursor.Create(tempReference_row4, out _)); + TaggedApi c2 = this.ReadTaggedApi(tempReference_row3, RowCursor.create(tempReference_row4, out _)); row = tempReference_row4.get(); row = tempReference_row3.get(); assert c1 == c2; diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java index d537a5f..cbcc8b5 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java @@ -49,7 +49,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: - this.WriteCounter(tempReference_row, RowCursor.Create(tempReference_row2, out _), c1); + this.WriteCounter(tempReference_row, RowCursor.create(tempReference_row2, out _), c1); row = tempReference_row2.get(); row = tempReference_row.get(); Reference tempReference_row3 = @@ -59,7 +59,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: - PerfCounter c2 = this.ReadCounter(tempReference_row3, RowCursor.Create(tempReference_row4, out _)); + PerfCounter c2 = this.ReadCounter(tempReference_row3, RowCursor.create(tempReference_row4, out _)); row = tempReference_row4.get(); row = tempReference_row3.get(); assert c1 == c2; @@ -79,7 +79,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: - this.WriteCounter(tempReference_row, RowCursor.Create(tempReference_row2, out _), c1); + this.WriteCounter(tempReference_row, RowCursor.create(tempReference_row2, out _), c1); row = tempReference_row2.get(); row = tempReference_row.get(); Reference tempReference_row3 = @@ -89,7 +89,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: - PerfCounter c2 = this.ReadCounter(tempReference_row3, RowCursor.Create(tempReference_row4, out _)); + PerfCounter c2 = this.ReadCounter(tempReference_row3, RowCursor.create(tempReference_row4, out _)); row = tempReference_row4.get(); row = tempReference_row3.get(); assert c1 == c2; @@ -112,7 +112,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: - this.WriteCounter(tempReference_row, RowCursor.Create(tempReference_row2, out _), c1); + this.WriteCounter(tempReference_row, RowCursor.create(tempReference_row2, out _), c1); row = tempReference_row2.get(); row = tempReference_row.get(); Reference tempReference_row3 = @@ -122,7 +122,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: - PerfCounter c2 = this.ReadCounter(tempReference_row3, RowCursor.Create(tempReference_row4, out _)); + PerfCounter c2 = this.ReadCounter(tempReference_row3, RowCursor.create(tempReference_row4, out _)); row = tempReference_row4.get(); row = tempReference_row3.get(); assert c1 == c2; @@ -152,7 +152,7 @@ public final class TupleUnitTests { RowCursor history; // 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: - RowCursor.Create(tempReference_row, out history).Find(tempReference_row2, historyToken); + RowCursor.create(tempReference_row, out history).Find(tempReference_row2, historyToken); row = tempReference_row2.get(); row = tempReference_row.get(); int ctx = 1; // ignored @@ -289,7 +289,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: - this.WriteCounter(tempReference_row, RowCursor.Create(tempReference_row2, out _), c1); + this.WriteCounter(tempReference_row, RowCursor.create(tempReference_row2, out _), c1); row = tempReference_row2.get(); row = tempReference_row.get(); @@ -304,7 +304,7 @@ public final class TupleUnitTests { RowCursor valueScope; // 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: - RowCursor.Create(tempReference_row3, out valueScope).Find(tempReference_row4, c.Path); + RowCursor.create(tempReference_row3, out valueScope).Find(tempReference_row4, c.Path); row = tempReference_row4.get(); row = tempReference_row3.get(); Reference tempReference_row5 = @@ -323,7 +323,7 @@ public final class TupleUnitTests { RowCursor valueScope2; // 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: - RowCursor.Create(tempReference_row6, out valueScope2).Find(tempReference_row7, c.Path); + RowCursor.create(tempReference_row6, out valueScope2).Find(tempReference_row7, c.Path); row = tempReference_row7.get(); row = tempReference_row6.get(); Reference tempReference_row8 = @@ -388,7 +388,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: - this.WriteCounter(tempReference_row, RowCursor.Create(tempReference_row2, out _), c1); + this.WriteCounter(tempReference_row, RowCursor.create(tempReference_row2, out _), c1); row = tempReference_row2.get(); row = tempReference_row.get(); @@ -403,7 +403,7 @@ public final class TupleUnitTests { RowCursor valueScope; // 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: - RowCursor.Create(tempReference_row3, out valueScope).Find(tempReference_row4, c.Path); + RowCursor.create(tempReference_row3, out valueScope).Find(tempReference_row4, c.Path); row = tempReference_row4.get(); row = tempReference_row3.get(); Reference tempReference_row5 = @@ -473,7 +473,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: - this.WriteCounter(tempReference_row, RowCursor.Create(tempReference_row2, out _), c1); + this.WriteCounter(tempReference_row, RowCursor.create(tempReference_row2, out _), c1); row = tempReference_row2.get(); row = tempReference_row.get(); @@ -488,7 +488,7 @@ public final class TupleUnitTests { RowCursor valueScope; // 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: - RowCursor.Create(tempReference_row3, out valueScope).Find(tempReference_row4, c.Path); + RowCursor.create(tempReference_row3, out valueScope).Find(tempReference_row4, c.Path); row = tempReference_row4.get(); row = tempReference_row3.get(); Reference tempReference_row5 = @@ -552,7 +552,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: - this.WriteCounter(tempReference_row, RowCursor.Create(tempReference_row2, out _), c1); + this.WriteCounter(tempReference_row, RowCursor.create(tempReference_row2, out _), c1); row = tempReference_row2.get(); row = tempReference_row.get(); @@ -568,7 +568,7 @@ public final class TupleUnitTests { RowCursor valueScope; // 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: - RowCursor.Create(tempReference_row3, out valueScope).Find(tempReference_row4, c.Path); + RowCursor.create(tempReference_row3, out valueScope).Find(tempReference_row4, c.Path); row = tempReference_row4.get(); row = tempReference_row3.get(); Reference tempReference_row5 = diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java index a604ada..dc5ba36 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java @@ -61,7 +61,7 @@ public final class TypedArrayUnitTests { 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: - this.WriteTagged(tempReference_row, RowCursor.Create(tempReference_row2, out _), t1); + this.WriteTagged(tempReference_row, RowCursor.create(tempReference_row2, out _), t1); row = tempReference_row2.get(); row = tempReference_row.get(); Reference tempReference_row3 = @@ -71,7 +71,7 @@ public final class TypedArrayUnitTests { 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: - Tagged t2 = this.ReadTagged(tempReference_row3, RowCursor.Create(tempReference_row4, out _)); + Tagged t2 = this.ReadTagged(tempReference_row3, RowCursor.create(tempReference_row4, out _)); row = tempReference_row4.get(); row = tempReference_row3.get(); assert t1 == t2; diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java index 1582b68..1bd9c05 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java @@ -67,7 +67,7 @@ public final class TypedMapUnitTests { 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: - this.WriteMovie(tempReference_row, RowCursor.Create(tempReference_row2, out _), t1); + this.WriteMovie(tempReference_row, RowCursor.create(tempReference_row2, out _), t1); row = tempReference_row2.get(); row = tempReference_row.get(); Reference tempReference_row3 = @@ -77,7 +77,7 @@ public final class TypedMapUnitTests { 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: - Movie t2 = this.ReadMovie(tempReference_row3, RowCursor.Create(tempReference_row4, out _)); + Movie t2 = this.ReadMovie(tempReference_row3, RowCursor.create(tempReference_row4, out _)); row = tempReference_row4.get(); row = tempReference_row3.get(); assert t1 == t2; @@ -90,7 +90,7 @@ public final class TypedMapUnitTests { row.initLayout(HybridRowVersion.V1, this.layout, this.resolver); Reference tempReference_row = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row); + RowCursor root = RowCursor.create(tempReference_row); row = tempReference_row.get(); ArrayList expected = new ArrayList(Arrays.asList("Mark", "Harrison", "Carrie")); @@ -186,7 +186,7 @@ public final class TypedMapUnitTests { row.initLayout(HybridRowVersion.V1, this.layout, this.resolver); Reference tempReference_row = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row); + RowCursor root = RowCursor.create(tempReference_row); row = tempReference_row.get(); Movie t1 = new Movie(); @@ -194,7 +194,7 @@ public final class TypedMapUnitTests { Map.entry("Carrie", "Leia"))); Reference tempReference_row2 = new Reference(row); - RowCursor rc1 = RowCursor.Create(tempReference_row2); + RowCursor rc1 = RowCursor.create(tempReference_row2); row = tempReference_row2.get(); Reference tempReference_row3 = new Reference(row); @@ -286,7 +286,7 @@ public final class TypedMapUnitTests { row.initLayout(HybridRowVersion.V1, this.layout, this.resolver); Reference tempReference_row = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row); + RowCursor root = RowCursor.create(tempReference_row); row = tempReference_row.get(); Movie t1 = new Movie(); @@ -303,7 +303,7 @@ public final class TypedMapUnitTests { Reference tempReference_row2 = new Reference(row); - RowCursor rc1 = RowCursor.Create(tempReference_row2); + RowCursor rc1 = RowCursor.create(tempReference_row2); row = tempReference_row2.get(); Reference tempReference_row3 = new Reference(row); @@ -477,7 +477,7 @@ public final class TypedMapUnitTests { row.initLayout(HybridRowVersion.V1, this.layout, this.resolver); Reference tempReference_row = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row); + RowCursor root = RowCursor.create(tempReference_row); row = tempReference_row.get(); // Write a map and then try to write directly into it. @@ -679,7 +679,7 @@ public final class TypedMapUnitTests { row.initLayout(HybridRowVersion.V1, this.layout, this.resolver); Reference tempReference_row = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row); + RowCursor root = RowCursor.create(tempReference_row); row = tempReference_row.get(); ArrayList expected = new ArrayList(Arrays.asList("Mark", "Harrison", "Carrie")); diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java index 75d0897..226ae02 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java @@ -65,7 +65,7 @@ public final class TypedSetUnitTests { 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: - this.WriteTodo(tempReference_row, RowCursor.Create(tempReference_row2, out _), t1); + this.WriteTodo(tempReference_row, RowCursor.create(tempReference_row2, out _), t1); row = tempReference_row2.get(); row = tempReference_row.get(); Reference tempReference_row3 = @@ -75,7 +75,7 @@ public final class TypedSetUnitTests { 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: - Todo t2 = this.ReadTodo(tempReference_row3, RowCursor.Create(tempReference_row4, out _)); + Todo t2 = this.ReadTodo(tempReference_row3, RowCursor.create(tempReference_row4, out _)); row = tempReference_row4.get(); row = tempReference_row3.get(); assert t1 == t2; @@ -103,14 +103,14 @@ public final class TypedSetUnitTests { // 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: - this.WriteTodo(tempReference_row, RowCursor.Create(tempReference_row2, out _), t1); + this.WriteTodo(tempReference_row, RowCursor.create(tempReference_row2, out _), t1); row = tempReference_row2.get(); row = tempReference_row.get(); // Attempt to update each item in turn and then update it with itself. Reference tempReference_row3 = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row3); + RowCursor root = RowCursor.create(tempReference_row3); row = tempReference_row3.get(); LayoutColumn c; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these @@ -195,14 +195,14 @@ public final class TypedSetUnitTests { 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: - this.WriteTodo(tempReference_row, RowCursor.Create(tempReference_row2, out _), t1); + this.WriteTodo(tempReference_row, RowCursor.create(tempReference_row2, out _), t1); row = tempReference_row2.get(); row = tempReference_row.get(); // Attempt to find each item in turn. Reference tempReference_row3 = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row3); + RowCursor root = RowCursor.create(tempReference_row3); row = tempReference_row3.get(); LayoutColumn c; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these @@ -377,14 +377,14 @@ public final class TypedSetUnitTests { 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: - this.WriteTodo(tempReference_row, RowCursor.Create(tempReference_row2, out _), t1); + this.WriteTodo(tempReference_row, RowCursor.create(tempReference_row2, out _), t1); row = tempReference_row2.get(); row = tempReference_row.get(); // Attempt to insert duplicate items in existing sets. Reference tempReference_row3 = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row3); + RowCursor root = RowCursor.create(tempReference_row3); row = tempReference_row3.get(); LayoutColumn c; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these @@ -710,7 +710,7 @@ public final class TypedSetUnitTests { RowCursor setScope; // 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: - RowCursor.Create(tempReference_row, out setScope).Find(tempReference_row2, c.Path); + RowCursor.create(tempReference_row, out setScope).Find(tempReference_row2, c.Path); row = tempReference_row2.get(); row = tempReference_row.get(); Reference tempReference_row3 = @@ -736,7 +736,7 @@ public final class TypedSetUnitTests { RowCursor tempCursor; // 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: - RowCursor.Create(tempReference_row5, out tempCursor).Find(tempReference_row6, Utf8String.Empty); + RowCursor.create(tempReference_row5, out tempCursor).Find(tempReference_row6, Utf8String.Empty); row = tempReference_row6.get(); row = tempReference_row5.get(); Reference tempReference_row7 = @@ -777,7 +777,7 @@ public final class TypedSetUnitTests { new Reference(row); // 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: - RowCursor.Create(tempReference_row11, out setScope).Find(tempReference_row12, c.Path); + RowCursor.create(tempReference_row11, out setScope).Find(tempReference_row12, c.Path); row = tempReference_row12.get(); row = tempReference_row11.get(); Reference tempReference_row13 = @@ -799,7 +799,7 @@ public final class TypedSetUnitTests { RowCursor tempCursor1; // 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: - RowCursor.Create(tempReference_row14, out tempCursor1).Find(tempReference_row15, "prices.0"); + RowCursor.create(tempReference_row14, out tempCursor1).Find(tempReference_row15, "prices.0"); row = tempReference_row15.get(); row = tempReference_row14.get(); Reference tempReference_row16 = @@ -819,7 +819,7 @@ public final class TypedSetUnitTests { RowCursor tempCursor2; // 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: - RowCursor.Create(tempReference_row17, out tempCursor2).Find(tempReference_row18, "prices.0.0"); + RowCursor.create(tempReference_row17, out tempCursor2).Find(tempReference_row18, "prices.0.0"); row = tempReference_row18.get(); row = tempReference_row17.get(); Reference tempReference_row19 = @@ -910,7 +910,7 @@ public final class TypedSetUnitTests { // 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: - RowCursor.Create(tempReference_row2, out root); + RowCursor.create(tempReference_row2, out root); row = tempReference_row2.get(); Reference tempReference_row3 = new Reference(row); @@ -965,7 +965,7 @@ public final class TypedSetUnitTests { // 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: - Todo t2 = this.ReadTodo(tempReference_row8, RowCursor.Create(tempReference_row9, out _)); + Todo t2 = this.ReadTodo(tempReference_row8, RowCursor.create(tempReference_row9, out _)); row = tempReference_row9.get(); row = tempReference_row8.get(); assert t1 == t2; @@ -994,14 +994,14 @@ public final class TypedSetUnitTests { // 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: - this.WriteTodo(tempReference_row, RowCursor.Create(tempReference_row2, out _), t1); + this.WriteTodo(tempReference_row, RowCursor.create(tempReference_row2, out _), t1); row = tempReference_row2.get(); row = tempReference_row.get(); // Attempt to find each item in turn and then delete it. Reference tempReference_row3 = new Reference(row); - RowCursor root = RowCursor.Create(tempReference_row3); + RowCursor root = RowCursor.create(tempReference_row3); row = tempReference_row3.get(); LayoutColumn c; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java index 616ee44..7806383 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java @@ -105,7 +105,7 @@ public final class WriteRowDispatcher implements IDispatcher { // 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: - RowCursor.CreateForAppend(tempReference_Row2, out tempCursor); + RowCursor.createForAppend(tempReference_Row2, out tempCursor); dispatcher.get().argValue.Row = tempReference_Row2.get(); // 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 @@ -178,7 +178,7 @@ public final class WriteRowDispatcher implements IDispatcher { // 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: - RowCursor.CreateForAppend(tempReference_Row2, out tempCursor); + RowCursor.createForAppend(tempReference_Row2, out tempCursor); dispatcher.get().argValue.Row = tempReference_Row2.get(); // 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 diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java index 4af88ac..ab6689d 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java @@ -12,9 +12,9 @@ import com.azure.data.cosmos.serialization.hybridrow.io.RowReader; public final class AddressSerializer { public static Result Read(Reference reader, Out

obj) { obj.setAndGet(new Address()); - while (reader.get().Read()) { + while (reader.get().read()) { Result r; - switch (reader.get().getPath()) { + switch (reader.get().path()) { case "street": Out tempOut_Street = new Out(); r = reader.get().ReadString(tempOut_Street); diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java index 3fa8761..66b1463 100644 --- a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java @@ -23,12 +23,12 @@ public final class PostalCodeSerializer { public static Result Read(Reference reader, Out obj) { obj.setAndGet(new PostalCode()); - while (reader.get().Read()) { + while (reader.get().read()) { Result r; - switch (reader.get().getPath()) { + switch (reader.get().path()) { case "zip": Out tempOut_Zip = new Out(); - r = reader.get().ReadInt32(tempOut_Zip); + r = reader.get().readInt32(tempOut_Zip); obj.get().argValue.Zip = tempOut_Zip.get(); if (r != Result.SUCCESS) { return r; @@ -38,7 +38,7 @@ public final class PostalCodeSerializer { case "plus4": short value; Out tempOut_value = new Out(); - r = reader.get().ReadInt16(tempOut_value); + r = reader.get().readInt16(tempOut_value); value = tempOut_value.get(); if (r != Result.SUCCESS) { return r;