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 42126af..9f54248 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 @@ -674,7 +674,7 @@ public final class RowBuffer { } public LayoutType readSparseTypeCode(int offset) { - return LayoutType.fromCode(LayoutCode.forValue(this.readInt8(offset))); + return LayoutType.fromCode(LayoutCode.from(this.readInt8(offset))); } public int readSparseUInt16(RowCursor edit) { @@ -1160,7 +1160,7 @@ public final class RowBuffer { this.buffer.setByte(index, this.buffer.getByte(index) & (byte) ~(1 << bit.bit())); } - public int write7BitEncodedInt(long value) { + public int write7BitEncodedInt(final long value) { return this.write7BitEncodedUInt(RowBuffer.rotateSignToLsb(value)); } @@ -3193,7 +3193,7 @@ public final class RowBuffer { return LayoutCode.BYTES; } - if (code == LayoutTypes.TYPED_ARRAY || code == LayoutTypes.TypedSet || code == LayoutTypes.TypedMap) { + if (code == LayoutTypes.TYPED_ARRAY || code == LayoutTypes.TYPED_SET || code == LayoutTypes.TYPED_MAP) { // Variable length typed collection scopes preceded by their scope size take sizeof(uint) for a size of 0. this.writeUInt32(offset, 0); return Integer.BYTES; 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 089ad08..82b52af 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 @@ -40,7 +40,7 @@ public final class RowCursor implements Cloneable { RowCursor() { } - protected RowCursor clone() { + public RowCursor clone() { try { return (RowCursor) super.clone(); } catch (CloneNotSupportedException error) { @@ -120,6 +120,11 @@ public final class RowCursor implements Cloneable { return this.deferUniqueIndex; } + public RowCursor deferUniqueIndex(boolean value) { + this.deferUniqueIndex = value; + return this; + } + /** * If existing, the offset to the end of the existing field. Used as a hint when skipping * forward. diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java index fb225f1..6ddba18 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java @@ -107,7 +107,8 @@ public final class RowCursors { return true; } - public static void skip(@Nonnull final RowCursor edit, @Nonnull final RowBuffer row, @Nonnull final RowCursor childScope) { + public static void skip( + @Nonnull final RowCursor edit, @Nonnull final RowBuffer row, @Nonnull final RowCursor childScope) { checkArgument(childScope.start() == edit.valueOffset()); diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/IRowSerializable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/IRowSerializable.java index 936d062..fa1f372 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/IRowSerializable.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/IRowSerializable.java @@ -13,11 +13,11 @@ import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument; */ public interface IRowSerializable { /** - * Writes the current instance into the row. + * Writes the current instance into the row * - * @param writer A writer for the current row scope. - * @param typeArg The schematized layout type, if a schema is available. - * @return Success if the write is successful, the error code otherwise. + * @param writer A writer for the current row scope + * @param typeArg The schematized layout type, if a schema is available + * @return Success if the write is successful, the error code otherwise */ Result write(Reference writer, TypeArgument typeArg); } \ No newline at end of file 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 6788fe8..dcc9d5a 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 @@ -4,7 +4,6 @@ package com.azure.data.cosmos.serialization.hybridrow.io; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.core.Utf8String; import com.azure.data.cosmos.core.UtfAnyString; import com.azure.data.cosmos.serialization.hybridrow.Float128; @@ -29,7 +28,6 @@ import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutInt16; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutInt32; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutInt64; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutInt8; -import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutMongoDbObjectId; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutNull; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutNullable; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType; @@ -44,10 +42,10 @@ 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 javax.annotation.Nullable; import java.math.BigDecimal; import java.time.OffsetDateTime; import java.util.List; @@ -57,7 +55,7 @@ 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 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 @@ -74,7 +72,7 @@ public final class RowReader { private RowCursor cursor; private RowBuffer row; private int schematizedCount; - private States state; // checkpoint state + private States state; /** * Initializes a new instance of the {@link RowReader} class @@ -86,8 +84,9 @@ public final class RowReader { } /** - * Initializes a new instance of the {@link RowReader} class. - * @param row The row to be read + * 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) { @@ -101,9 +100,6 @@ public final class RowReader { this.columnIndex = checkpoint.columnIndex(); } - private RowReader() { - } - /** * Initializes a new instance of the {@link RowReader} class * @@ -112,220 +108,62 @@ public final class RowReader { *

* 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. + * {@link RowReader} instances can be access through the {@link RowReader#readScope} method to process + * nested content. */ - private RowReader(RowBuffer row, RowCursor scope) { + private RowReader(@Nonnull final RowBuffer row, @Nonnull final RowCursor scope) { this.cursor = scope; this.row = row; this.columns = this.cursor.layout().columns(); this.schematizedCount = this.cursor.layout().numFixed() + this.cursor.layout().numVariable(); - this.state = States.None; + this.state = States.NONE; this.columnIndex = -1; } /** - * Read the current field as a fixed length {@link MongoDbObjectId} value. + * Read the current field as a fixed length {@code MongoDbObjectId} value * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. + * @param value On success, receives the value, undefined otherwise + * @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); - - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutMongoDbObjectId)) { - value.set(null); - return Result.TYPE_MISMATCH; - } - value.set(this.row.readSparseMongoDbObjectId(this.cursor)); - return Result.SUCCESS; - - default: - value.set(null); - return Result.FAILURE; - } + public Result ReadMongoDbObjectId(Out value) { + // TODO: DANOBLE: Resurrect this method + // switch (this.state) { + // + // case Schematized: + // return this.readPrimitiveValue(value); + // + // case Sparse: + // if (!(this.cursor.cellType() instanceof LayoutMongoDbObjectId)) { + // value.set(null); + // return Result.TYPE_MISMATCH; + // } + // value.set(this.row.readSparseMongoDbObjectId(this.cursor)); + // return Result.SUCCESS; + // + // default: + // value.set(null); + // return Result.FAILURE; + // } + throw new UnsupportedOperationException(); } /** - * 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. - */ - public Result ReadScope(TContext context, ReaderFunc func) { - Reference tempReference_cursor = - new Reference(this.cursor); - RowCursor childScope = this.row.sparseIteratorReadScope(tempReference_cursor, true).clone(); - this.cursor = tempReference_cursor.get(); - Reference tempReference_row = - new Reference(this.row); - RowReader nestedReader = new RowReader(tempReference_row, childScope.clone()); - this.row = tempReference_row.get(); - - Reference tempReference_nestedReader = - new Reference(nestedReader); - // TODO: C# TO JAVA CONVERTER: The following line could not be converted: - Result result = func == null ? null : func.Invoke(ref nestedReader, context) ??Result.SUCCESS; - nestedReader = tempReference_nestedReader.get(); - if (result != Result.SUCCESS) { - return result; - } - - Reference tempReference_row2 = - new Reference(this.row); - Reference tempReference_cursor2 = - new Reference(nestedReader.cursor); - RowCursors.skip(this.cursor.clone(), tempReference_row2, - tempReference_cursor2); - nestedReader.cursor = tempReference_cursor2.get(); - this.row = tempReference_row2.get(); - return Result.SUCCESS; - } - - /** - * Read the current field as a variable length, UTF8 encoded, string value. + * Read the current field as a variable length, UTF-8 encoded string value * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. + * @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) { - 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.set((r == Result.SUCCESS) ? span.toString() :) - 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) { + Out string = new Out<>(); + Result result = this.readString(string); + value.set((result == Result.SUCCESS) ? string.get().toUtf16() : null); + string.get().release(); - switch (this.state) { - - case Schematized: - return this.readPrimitiveValue(value); - - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutUtf8)) { - value.set(null); - return Result.TYPE_MISMATCH; - } - value.set(this.row.readSparseString(this.cursor)); - return Result.SUCCESS; - - default: - value.set(null); - return Result.FAILURE; - } - } - - /** - * Read the current field as a variable length, 7-bit encoded, signed integer. - * - * @param value On success, receives the value, undefined otherwise. - * @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); - - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutVarInt)) { - value.set(0L); - return Result.TYPE_MISMATCH; - } - value.set(this.row.readSparseVarInt(this.cursor)); - return Result.SUCCESS; - - default: - value.set(0L); - return Result.FAILURE; - } - } - - /** - * Read the current field as a variable length, 7-bit encoded, unsigned integer. - * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. - */ - public Result ReadVarUInt(Out value) { - - switch (this.state) { - - case Schematized: - return this.readPrimitiveValue(value); - - case Sparse: - if (!(this.cursor.cellType() instanceof LayoutVarUInt)) { - value.set(0L); - return Result.TYPE_MISMATCH; - } - value.set(this.row.readSparseVarUInt(this.cursor)); - return Result.SUCCESS; - - default: - value.set(0L); - return Result.FAILURE; - } - } - - public Checkpoint SaveCheckpoint() { - return new Checkpoint(this.state, this.columnIndex, this.cursor); - } - - /** - * Advance a reader to the end of a child reader. The child reader is also advanced to the - * end of its scope. - *

- *

- * 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 - * {@link ReaderFunc{TContext}} is not an option, such as when TContext is a ref struct. - */ - public Result SkipScope(Reference nestedReader) { - if (nestedReader.get().cursor.start() != this.cursor.valueOffset()) { - return Result.FAILURE; - } - - Reference tempReference_row = - new Reference(this.row); - Reference tempReference_cursor = - new Reference(nestedReader.get().cursor); - RowCursors.skip(this.cursor.clone(), tempReference_row, - tempReference_cursor); - nestedReader.get().argValue.cursor = tempReference_cursor.get(); - this.row = tempReference_row.get(); - return Result.SUCCESS; - } - - public RowReader clone() { - RowReader varCopy = new RowReader(); - - varCopy.schematizedCount = this.schematizedCount; - varCopy.columns = this.columns; - varCopy.row = this.row.clone(); - varCopy.state = this.state; - varCopy.columnIndex = this.columnIndex; - varCopy.cursor = this.cursor.clone(); - - return varCopy; + return result; } /** @@ -339,10 +177,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return true; - case Sparse: + case SPARSE: if (this.cursor.cellType() instanceof LayoutNullable) { RowCursor nullableScope = this.row.sparseIteratorReadScope(this.cursor, true); return LayoutNullable.hasValue(this.row, nullableScope) == Result.SUCCESS; @@ -357,14 +195,16 @@ public final class RowReader { /** * 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}). + * When enumerating a non-indexed scope, this value is always zero. + * + * @see #path */ public int index() { - return this.state == States.Sparse ? this.cursor.index() : 0; + return this.state == States.SPARSE ? this.cursor.index() : 0; } /** - * The length of row in bytes. + * The length of row in bytes */ public int length() { return this.row.length(); @@ -373,7 +213,9 @@ public final class RowReader { /** * 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}). + * When enumerating an indexed scope, this value is always null. + * + * @see #index */ public UtfAnyString path() { @@ -381,11 +223,11 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: value = this.columns.get(this.columnIndex).path(); break; - case Sparse: + case SPARSE: value = this.cursor.pathOffset() == 0 ? null : this.row.readSparsePath(this.cursor); break; @@ -400,13 +242,15 @@ public final class RowReader { /** * 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}). + * When enumerating an indexed scope, this value is always null. + * + * @see #index */ public Utf8String pathSpan() { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.columns.get(this.columnIndex).path(); - case Sparse: + case SPARSE: return this.row.readSparsePath(this.cursor); default: return null; @@ -414,31 +258,31 @@ public final class RowReader { } /** - * Advances the reader to the next field. + * Advances the reader to the next field * - * @return True, if there is another field to be read, false otherwise. + * @return {@code true}, if there is another field to be read; {@code false} otherwise */ public boolean read() { switch (this.state) { - case None: { + case NONE: { if (this.cursor.scopeType() instanceof LayoutUDT) { - this.state = States.Schematized; + this.state = States.SCHEMATIZED; // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: // goto case States.Schematized; } else { - this.state = States.Sparse; + this.state = States.SPARSE; // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: // goto case States.Sparse; } } - case Schematized: { + case SCHEMATIZED: { this.columnIndex++; if (this.columnIndex >= this.schematizedCount) { - this.state = States.Sparse; + this.state = States.SPARSE; // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: // goto case States.Sparse; } @@ -455,17 +299,17 @@ public final class RowReader { return true; } - case Sparse: { + case SPARSE: { if (!RowCursors.moveNext(this.cursor, this.row)) { - this.state = States.Done; + this.state = States.DONE; // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: // goto case States.Done; } return true; } - case Done: { + case DONE: { return false; } } @@ -474,7 +318,7 @@ public final class RowReader { } /** - * Read the current field as a variable length, sequence of bytes. + * 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. @@ -483,10 +327,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutBinary)) { value.set(null); @@ -522,7 +366,7 @@ public final class RowReader { } /** - * Read the current field as a {@link Boolean}. + * 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. @@ -531,10 +375,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutBoolean)) { value.set(false); return Result.TYPE_MISMATCH; @@ -550,7 +394,7 @@ public final class RowReader { } /** - * Read the current field as a fixed length {@code DateTime} value. + * 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. @@ -559,10 +403,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutDateTime)) { value.set(OffsetDateTime.MIN); return Result.TYPE_MISMATCH; @@ -587,10 +431,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutDecimal)) { value.set(new BigDecimal(0)); return Result.TYPE_MISMATCH; @@ -605,7 +449,7 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 128-bit, IEEE-encoded floating point value. + * 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. @@ -614,10 +458,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutFloat128)) { value.setAndGet(null); return Result.TYPE_MISMATCH; @@ -632,7 +476,7 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 32-bit, IEEE-encoded floating point value. + * 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. @@ -641,10 +485,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutFloat32)) { value.set(0F); return Result.TYPE_MISMATCH; @@ -659,7 +503,7 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 64-bit, IEEE-encoded floating point value. + * 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. @@ -668,10 +512,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutFloat64)) { value.set(0D); return Result.TYPE_MISMATCH; @@ -686,7 +530,7 @@ public final class RowReader { } /** - * Read the current field as a fixed length GUID value. + * 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. @@ -695,10 +539,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutGuid)) { value.set(null); return Result.TYPE_MISMATCH; @@ -714,7 +558,7 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 16-bit, signed integer. + * 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. @@ -723,10 +567,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutInt16)) { value.set((short)0); return Result.TYPE_MISMATCH; @@ -741,7 +585,7 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 32-bit, signed integer. + * 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. @@ -750,10 +594,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutInt32)) { value.set(0); return Result.TYPE_MISMATCH; @@ -768,7 +612,7 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 64-bit, signed integer. + * 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. @@ -777,10 +621,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutInt64)) { value.setAndGet(0L); return Result.TYPE_MISMATCH; @@ -795,7 +639,7 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 8-bit, signed integer. + * 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. @@ -804,10 +648,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutInt8)) { value.set((byte)0); return Result.TYPE_MISMATCH; @@ -822,7 +666,7 @@ public final class RowReader { } /** - * Read the current field as a null. + * 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. @@ -831,10 +675,10 @@ public final class RowReader { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutNull)) { value.set(null); return Result.TYPE_MISMATCH; @@ -848,6 +692,27 @@ public final class RowReader { } } + /** + * 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. + */ + @Nonnull + public Result readScope(@Nullable final TContext context, @Nullable final ReaderFunc func) { + + final RowCursor childScope = this.row.sparseIteratorReadScope(this.cursor, true); + final RowReader nestedReader = new RowReader(this.row, childScope); + final Result result = func == null ? null : func.invoke(nestedReader, context); + + if (!(result == null || result == Result.SUCCESS)) { + return result; + } + + RowCursors.skip(childScope, this.row, nestedReader.cursor); + return Result.SUCCESS; + } + /** * Read the current field as a nested, structured, sparse scope *

@@ -862,19 +727,46 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 16-bit, unsigned integer. + * Read the current field as a variable length, UTF-8 encoded, string value * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. + * @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); + + case SPARSE: + if (!(this.cursor.cellType() instanceof LayoutUtf8)) { + value.set(null); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseString(this.cursor)); + return Result.SUCCESS; + + default: + value.set(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 */ public Result readUInt16(Out value) { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutUInt16)) { value.set(0); return Result.TYPE_MISMATCH; @@ -889,19 +781,19 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 32-bit, unsigned integer. + * 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. + * @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: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutUInt32)) { value.set(0L); return Result.TYPE_MISMATCH; @@ -917,19 +809,19 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 64-bit, unsigned integer. + * 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. + * @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: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutUInt64)) { value.set(0L); return Result.TYPE_MISMATCH; @@ -944,19 +836,19 @@ public final class RowReader { } /** - * Read the current field as a fixed length, 8-bit, unsigned integer. + * 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. + * @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: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutUInt8)) { value.set((short)0); return Result.TYPE_MISMATCH; @@ -971,19 +863,19 @@ public final class RowReader { } /** - * Read the current field as a fixed length {@link UnixDateTime} value. + * 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. + * @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: + case SCHEMATIZED: return this.readPrimitiveValue(value); - case Sparse: + case SPARSE: if (!(this.cursor.cellType() instanceof LayoutUnixDateTime)) { value.set(null); return Result.TYPE_MISMATCH; @@ -997,14 +889,89 @@ public final class RowReader { } } + /** + * Read the current field as a variable length, 7-bit encoded, signed integer + * + * @param value On success, receives the value, undefined otherwise + * @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); + + case SPARSE: + if (!(this.cursor.cellType() instanceof LayoutVarInt)) { + value.set(0L); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseVarInt(this.cursor)); + return Result.SUCCESS; + + default: + value.set(0L); + return Result.FAILURE; + } + } + + /** + * Read the current field as a variable length, 7-bit encoded, unsigned integer + * + * @param value On success, receives the value, undefined otherwise + * @return Success if the read is successful, an error code otherwise + */ + public Result readVarUInt(Out value) { + + switch (this.state) { + + case SCHEMATIZED: + return this.readPrimitiveValue(value); + + case SPARSE: + if (!(this.cursor.cellType() instanceof LayoutVarUInt)) { + value.set(0L); + return Result.TYPE_MISMATCH; + } + value.set(this.row.readSparseVarUInt(this.cursor)); + return Result.SUCCESS; + + default: + value.set(0L); + return Result.FAILURE; + } + } + + public Checkpoint saveCheckpoint() { + return new Checkpoint(this.state, this.columnIndex, this.cursor); + } + + /** + * Advance a reader to the end of a child reader + *

+ * The child reader is also advanced to the end of its scope. The reader must not have been advanced since the child + * reader was created with {@link #readScope}. This method can be used when the overload of {@link #readScope} that + * takes a {@link ReaderFunc{TContext} is not an option. + * + * @param nestedReader nested (child) reader to be advanced + */ + public Result skipScope(@Nonnull final RowReader nestedReader) { + if (nestedReader.cursor.start() != this.cursor.valueOffset()) { + return Result.FAILURE; + } + RowCursors.skip(this.cursor, this.row, nestedReader.cursor); + return Result.SUCCESS; + } + /** * The storage placement of the field--if positioned on a field--undefined otherwise */ public StorageKind storage() { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.columns.get(this.columnIndex).storage(); - case Sparse: + case SPARSE: return StorageKind.SPARSE; default: return null; @@ -1017,9 +984,9 @@ public final class RowReader { public LayoutType type() { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.columns.get(this.columnIndex).type(); - case Sparse: + case SPARSE: return this.cursor.cellType(); default: return null; @@ -1027,14 +994,14 @@ public final class RowReader { } /** - * The type arguments of the field (if positioned on a field, undefined otherwise). + * The type arguments of the field (if positioned on a field, undefined otherwise) */ public TypeArgumentList typeArgs() { switch (this.state) { - case Schematized: + case SCHEMATIZED: return this.columns.get(this.columnIndex).typeArgs(); - case Sparse: + case SPARSE: return this.cursor.cellTypeArgs(); default: return TypeArgumentList.EMPTY; @@ -1042,11 +1009,10 @@ public final class RowReader { } /** - * Read a generic schematized field value via the scope's layout. - * The expected type of the field. + * Reads a generic schematized field value via the scope's layout * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. + * @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) { @@ -1073,78 +1039,67 @@ public final class RowReader { } /** - * Read a generic schematized field value via the scope's layout. + * Reads a generic schematized field value via the scope's layout * * @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) { + private Result readPrimitiveValue(Out value) { + LayoutColumn column = this.columns.get(this.columnIndex); - LayoutType t = this.columns.get(this.columnIndex).Type; - if (!(t instanceof ILayoutUtf8SpanReadable)) { + LayoutType type = this.columns.get(this.columnIndex).type(); + + if (!(type instanceof ILayoutUtf8SpanReadable)) { value.set(null); return Result.TYPE_MISMATCH; } - switch (column == null ? null : column.storage()) { + StorageKind storage = column == null ? StorageKind.NONE : column.storage(); + + switch (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, column, value); - this.cursor = tempReference_cursor.get(); - this.row = tempReference_row.get(); - return tempVar; + return type.typeAs().readFixed(this.row, this.cursor, column, value); + 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, column, value); - this.cursor = tempReference_cursor2.get(); - this.row = tempReference_row2.get(); - return tempVar2; + return type.typeAs().readVariable(this.row, this.cursor, column, value); + default: - throw new IllegalStateException(); + assert false : lenientFormat("expected FIXED or VARIABLE column storage, not %s", storage); value.set(null); return Result.FAILURE; } } /** - * Read a generic schematized field value via the scope's layout. - * The sub-element type of the field. + * Reads a generic schematized field value via the scope's layout * - * @param value On success, receives the value, undefined otherwise. - * @return Success if the read is successful, an error code otherwise. + * @param The sub-element type of the field + * @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) { + private Result readPrimitiveValue(Out> value) { LayoutColumn column = this.columns.get(this.columnIndex); - LayoutType t = this.columns.get(this.columnIndex).type(); + LayoutType type = this.columns.get(this.columnIndex).type(); - if (!(t instanceof ILayoutSpanReadable)) { + if (!(type instanceof ILayoutSpanReadable)) { value.set(null); return Result.TYPE_MISMATCH; } - switch (column == null ? null : column.storage()) { + StorageKind storage = column == null ? StorageKind.NONE : column.storage(); + + switch (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, column, value); - this.cursor = tempReference_cursor.get(); - this.row = tempReference_row.get(); - return tempVar; + return type.>typeAs().readFixed(this.row, this.cursor, column, value); + 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, column, value); - this.cursor = tempReference_cursor2.get(); - this.row = tempReference_row2.get(); - return tempVar2; + return type.>typeAs().readVariable(this.row, this.cursor, column, value); + default: - throw new IllegalStateException(); + assert false : lenientFormat("expected FIXED or VARIABLE column storage, not %s", storage); value.set(null); return Result.FAILURE; } @@ -1157,22 +1112,22 @@ public final class RowReader { /** * The reader has not be started yet. */ - None, + NONE, /** * Enumerating schematized fields (fixed and variable) from left to right. */ - Schematized, + SCHEMATIZED, /** * Enumerating top-level fields of the current scope. */ - Sparse, + SPARSE, /** * The reader has completed the scope. */ - Done; + DONE; public static final int BYTES = Byte.BYTES; @@ -1186,22 +1141,26 @@ public final class RowReader { } /** - * A function to reader content from a {@link RowBuffer}. - *

- * The type of the context value passed by the caller. + * A functional interface for reading content from a {@link RowBuffer} * - * @param reader A forward-only cursor for writing content. - * @param context A context value provided by the caller. - * @return The result. + * @param The type of the context value passed by the caller */ @FunctionalInterface public interface ReaderFunc { - Result invoke(Reference reader, TContext context); + /** + * The read {@link Result} + * + * @param reader the current reader + * @param context the current reader context + * @return the read result + */ + Result invoke(RowReader reader, TContext context); } /** - * An encapsulation of the current state of a {@link RowReader} that can be used to - * recreate the {@link RowReader} in the same logical position. + * An encapsulation of the current state of a {@link RowReader} + *

+ * This value can be used to recreate the {@link RowReader} in the same logical position. */ public final static class Checkpoint { diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java index 8715536..caf001e 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java @@ -31,7 +31,7 @@ public final class RowReaderExtensions { // All lambda's here are static. // TODO: C# TO JAVA CONVERTER: The following lambda contained an unresolved 'ref' keyword - these are not // converted by C# to Java Converter: - Result r = reader.get().ReadScope(ctx.clone(), (ref RowReader arrayReader, ListContext ctx1) -> + Result r = reader.get().readScope(ctx.clone(), (RowReader RowReader arrayReader, ListContext ctx1) -> { while (arrayReader.Read()) { Result r2 = arrayReader.ReadScope(ctx1.clone(), (ref RowReader itemReader, ListContext ctx2) -> 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 199dc3e..a3c2fa0 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 @@ -5,16 +5,18 @@ package com.azure.data.cosmos.serialization.hybridrow.io; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; +import com.azure.data.cosmos.core.UtfAnyString; import com.azure.data.cosmos.serialization.hybridrow.Float128; import com.azure.data.cosmos.serialization.hybridrow.NullValue; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; -import com.azure.data.cosmos.serialization.hybridrow.UnixDateTime; import com.azure.data.cosmos.serialization.hybridrow.RowCursors; +import com.azure.data.cosmos.serialization.hybridrow.UnixDateTime; import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutResolver; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType; +import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTypes; import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument; import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList; import com.azure.data.cosmos.serialization.hybridrow.layouts.UpdateOptions; @@ -23,50 +25,43 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.UUID; -//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ -// from the original: -//ORIGINAL LINE: public ref struct RowWriter -//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# ref struct: public final class RowWriter { - private RowCursor cursor = new RowCursor(); - private RowBuffer row = new RowBuffer(); + + private RowCursor cursor; + private RowBuffer row; /** - * Initializes a new instance of the {@link RowWriter} struct. + * Initializes a new instance of the {@link RowWriter} struct * * @param row The row to be read. * @param scope The scope into which items should be written. *

- * A {@link RowWriter} instance writes the fields of a given scope from left to right - * in a forward only manner. If the root scope is provided then all top-level fields in the row can be - * written. + * A {@link RowWriter} instance writes the fields of a given scope from left to right in a forward only + * manner. If the root scope is provided then all top-level fields in the row can be */ - public RowWriter() { - } - - private RowWriter(Reference row, Reference scope) { - this.row = row.get().clone(); - this.cursor = scope.get().clone(); + private RowWriter(RowBuffer row, RowCursor scope) { + this.row = row; + this.cursor = scope; } /** * The active layout of the current writer scope. */ - public Layout getLayout() { + public Layout layout() { return this.cursor.layout(); } /** * The length of row in bytes. */ - public int getLength() { + public int length() { return this.row.length(); } /** * The resolver for UDTs. */ - public LayoutResolver getResolver() { + public LayoutResolver resolver() { return this.row.resolver(); } @@ -77,8 +72,6 @@ public final class RowWriter { * @param value The value to write. * @return Success if the write is successful, an error code otherwise. */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result WriteBinary(UtfAnyString path, byte[] value) public Result WriteBinary(UtfAnyString path, byte[] value) { // TODO: C# TO JAVA CONVERTER: The following lambda contained an unresolved 'ref' keyword - these are not // converted by C# to Java Converter: @@ -87,7 +80,7 @@ public final class RowWriter { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: return this.WritePrimitive(path, value, LayoutType.Binary, (ref RowWriter w, byte[] v) => w // .row.WriteSparseBinary(ref w.cursor, v, UpdateOptions.Upsert)); - return this.WritePrimitive(path, value, LayoutType.Binary, + return this.WritePrimitive(path, value, LayoutTypes.BINARY, (ref RowWriter w, byte[] v) -> w.row.WriteSparseBinary(ref w.cursor, v, UpdateOptions.Upsert)); } 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 3db4646..1a8e8e1 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 @@ -214,7 +214,7 @@ public final class RowReaderJsonExtensions { case VarInt: { long value; Out tempOut_value10 = new Out(); - r = reader.get().ReadVarInt(tempOut_value10); + r = reader.get().readVarInt(tempOut_value10); value = tempOut_value10.get(); if (r != Result.SUCCESS) { return r; @@ -229,7 +229,7 @@ public final class RowReaderJsonExtensions { Out tempOut_value11 = new Out(); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: r = reader.ReadVarUInt(out ulong value); - r = reader.get().ReadVarUInt(tempOut_value11); + r = reader.get().readVarUInt(tempOut_value11); value = tempOut_value11.get(); if (r != Result.SUCCESS) { return r; @@ -428,7 +428,7 @@ public final class RowReaderJsonExtensions { case EndScope: { ctx.Builder.append(scopeBracket); int snapshot = ctx.Builder.length(); - r = reader.get().ReadScope(new ReaderStringContext(ctx.Builder, ctx.Settings.clone(), ctx.Indent + 1), RowReaderJsonExtensions.ToJson); + r = reader.get().readScope(new ReaderStringContext(ctx.Builder, ctx.Settings.clone(), ctx.Indent + 1), RowReaderJsonExtensions.ToJson); if (r != Result.SUCCESS) { return r; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSequenceWritable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSequenceWritable.java index 422124a..52ba528 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSequenceWritable.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSequenceWritable.java @@ -3,33 +3,24 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import java.util.List; + /** - * An optional interface that indicates a {@link LayoutType{T}} can also write using a {@link ReadOnlySequence{T}}. + * An optional interface that indicates a {@link LayoutType{T}} can also write using a read-only {@link List{T}}. * - * The sub-element type to be written. + * @param The sub-element type to be written */ public interface ILayoutSequenceWritable extends ILayoutType { - Result WriteFixed( - Reference b, Reference scope, LayoutColumn col, ReadOnlySequence value); + Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn col, List value); - Result WriteSparse( - Reference b, Reference edit, ReadOnlySequence value); + Result writeSparse(RowBuffer buffer, RowCursor edit, List value); - // C# TO JAVA CONVERTER NOTE: - // Java does not support optional parameters, hence overloaded method(s) are created - // ORIGINAL LINE: - // Result WriteSparse(ref RowBuffer b, ref RowCursor edit, ReadOnlySequence value, UpdateOptions - // options = UpdateOptions.Upsert); + Result writeSparse(RowBuffer buffer, RowCursor edit, List value, UpdateOptions options); - Result WriteSparse( - Reference b, Reference edit, ReadOnlySequence value, UpdateOptions options); - - Result WriteVariable( - Reference b, Reference scope, LayoutColumn col, ReadOnlySequence value); + Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, List value); } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanReadable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanReadable.java index 247dcb6..84ee0c8 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanReadable.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanReadable.java @@ -4,23 +4,22 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import java.util.List; + /** - * An optional interface that indicates a {@link LayoutType{T}} can also read using a {@link ReadOnlySpan{T}} + * An optional interface that indicates a {@link LayoutType{T}} can also read using a read-only {@link List{T}} * - * The sub-element type to be written. + * @param The sub-element type to be written */ public interface ILayoutSpanReadable extends ILayoutType { - Result ReadFixed( - Reference b, Reference scope, LayoutColumn col, Out> value); - Result ReadSparse( - Reference b, Reference scope, Out> value); + Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out> value); - Result ReadVariable( - Reference b, Reference scope, LayoutColumn col, Out> value); + Result readSparse(RowBuffer buffer, RowCursor scope, Out> value); + + Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out> value); } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanWritable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanWritable.java index 2c483a3..3d7bd15 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanWritable.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanWritable.java @@ -3,32 +3,24 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import java.util.List; + /** - * An optional interface that indicates a {@link LayoutType{T}} can also write using a - * {@link ReadOnlySpan{T}}. + * An optional interface that indicates a {@link LayoutType{T}} can also write using a {@link List{T}} * - * The sub-element type to be written. + * @param The sub-element type to be written */ public interface ILayoutSpanWritable extends ILayoutType { - Result WriteFixed( - Reference b, Reference scope, LayoutColumn col, ReadOnlySpan value); + Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, List value); - Result WriteSparse(Reference b, Reference edit, ReadOnlySpan value); + Result writeSparse(RowBuffer buffer, RowCursor edit, TElement value); - // C# TO JAVA CONVERTER NOTE: - // Java does not support optional parameters, hence overloaded method(s) are created. - // ORIGINAL LINE: - // Result WriteSparse(ref RowBuffer b, ref RowCursor edit, ReadOnlySpan value, UpdateOptions options = UpdateOptions.Upsert); + Result writeSparse(RowBuffer buffer, RowCursor edit, List value, UpdateOptions options); - Result WriteSparse( - Reference b, Reference edit, ReadOnlySpan value, UpdateOptions options); - - Result WriteVariable( - Reference b, Reference scope, LayoutColumn col, ReadOnlySpan value); + Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, List value); } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanReadable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanReadable.java index 6016a15..1c6b8fa 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanReadable.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanReadable.java @@ -4,19 +4,19 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; +import com.azure.data.cosmos.core.Utf8String; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; /** - * An optional interface that indicates a {@link LayoutType{T}} can also read using a {@link Utf8Span}. + * An optional interface that indicates a {@link LayoutType{T}} can also read using a {@link Utf8String}. */ public interface ILayoutUtf8SpanReadable extends ILayoutType { - Result ReadFixed(Reference b, Reference scope, LayoutColumn col, Out value); + Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value); - Result ReadSparse(Reference b, Reference scope, Out value); + Result readSparse(RowBuffer buffer, RowCursor scope, Out value); - Result ReadVariable(Reference b, Reference scope, LayoutColumn col, Out value); + Result ReadVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value); } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanWritable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanWritable.java index b28251e..52c3909 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanWritable.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanWritable.java @@ -3,26 +3,21 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; -import com.azure.data.cosmos.core.Reference; +import com.azure.data.cosmos.core.Utf8String; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; /** - * An optional interface that indicates a {@link LayoutType{T}} can also write using a {@link Utf8Span}. + * An optional interface that indicates a {@link LayoutType{T}} can also write using a {@link Utf8String} */ public interface ILayoutUtf8SpanWritable extends ILayoutType { - Result WriteFixed(Reference b, Reference scope, LayoutColumn col, Utf8Span value); + Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Utf8String value); - Result WriteSparse(Reference b, Reference edit, Utf8Span value); + Result writeSparse(RowBuffer buffer, RowCursor edit, Utf8String value); - // C# TO JAVA CONVERTER NOTE: - // Java does not support optional parameters, hence overloaded method(s) are created. - // ORIGINAL LINE: - // Result WriteSparse(ref RowBuffer b, ref RowCursor edit, Utf8Span value, UpdateOptions options = UpdateOptions.Upsert); + Result writeSparse(RowBuffer buffer, RowCursor edit, Utf8String value, UpdateOptions options); - Result WriteSparse(Reference b, Reference edit, Utf8Span value, UpdateOptions options); - - Result WriteVariable(Reference b, Reference scope, LayoutColumn col, Utf8Span value); + Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Utf8String value); } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java index 2bfb850..4c24de2 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java @@ -24,28 +24,28 @@ public final class LayoutArray extends LayoutIndexedScope { } @Override + @Nonnull public Result writeScope( - @Nonnull final RowBuffer b, + @Nonnull final RowBuffer buffer, @Nonnull final RowCursor edit, @Nonnull final TypeArgumentList typeArgs, - @Nonnull Out value - ) { - return this.writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + @Nonnull Out value) { + return this.writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList - // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, - TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Result result = prepareSparseWrite(b, edit, this.typeArg(), options); + @Nonnull + public Result writeScope( + RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { + + Result result = prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { - value.setAndGet(null); + value.set(null); return result; } - b.writeSparseArray(edit, this, options); + buffer.writeSparseArray(edit, this, options); return Result.SUCCESS; } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java index d0be5fe..6f8f1fe 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java @@ -9,15 +9,14 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import java.util.List; + import static com.google.common.base.Preconditions.checkArgument; -//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: -//ORIGINAL LINE: public sealed class LayoutBinary : LayoutType, ILayoutSpanWritable, -// ILayoutSpanReadable, ILayoutSequenceWritable -public final class LayoutBinary extends LayoutType implements ILayoutSpanWritable, - ILayoutSpanReadable, ILayoutSequenceWritable { +public final class LayoutBinary extends LayoutType implements ILayoutSpanWritable, ILayoutSpanReadable, ILayoutSequenceWritable { + public LayoutBinary() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.BINARY, 0); + super(LayoutCode.BINARY, 0); } public boolean isFixed() { @@ -28,64 +27,59 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa return "binary"; } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out - // byte[] value) @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, 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.ReadFixed(ref b, ref scope, col, out ReadOnlySpan span); - Result r = this.ReadFixed(b, scope, column, out span); - value.setAndGet((r == Result.SUCCESS) ? span.ToArray() :) + //ORIGINAL LINE: Result result = this.ReadFixed(ref b, ref scope, col, out ReadOnlySpan span); + Result result = this.ReadFixed(buffer, scope, column, out span); + value.set((result == Result.SUCCESS) ? span.ToArray() :) default - return r; + return result; } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out - // ReadOnlySpan value) - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, - Out> value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - checkArgument(col.getSize() >= 0); - if (!b.get().readBit(scope.get().start(), col.getNullBit().clone())) { - value.setAndGet(null); + public Result ReadFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out> value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + checkArgument(column.size() >= 0); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set(null); return Result.NOT_FOUND; } - value.setAndGet(b.get().readFixedBinary(scope.get().start() + col.getOffset(), col.getSize())); + value.set(buffer.readFixedBinary(scope.start() + column.offset(), column.size())); return Result.SUCCESS; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out byte[] value) @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { ReadOnlySpan span; // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: Result r = this.ReadSparse(ref b, ref edit, out ReadOnlySpan span); - Result r = this.ReadSparse(b, edit, out span); - value.setAndGet((r == Result.SUCCESS) ? span.ToArray() :) + Result r = this.ReadSparse(buffer, edit, out span); + value.set((r == Result.SUCCESS) ? span.ToArray() :) default return r; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ReadOnlySpan value) - public Result ReadSparse(Reference b, Reference edit, Out> value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + public Result ReadSparse(RowBuffer buffer, RowCursor edit, Out> value) { + + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { - value.setAndGet(null); + value.set(null); return result; } - value.setAndGet(b.get().readSparseBinary(edit)); + value.set(buffer.readSparseBinary(edit)); return Result.SUCCESS; } @@ -93,33 +87,30 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //ORIGINAL LINE: public override Result ReadVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // byte[] value) @Override - public Result readVariable(RowBuffer b, RowCursor scope, LayoutColumn column - , Out value) { + public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, 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.ReadVariable(ref b, ref scope, col, out ReadOnlySpan span); - Result r = this.ReadVariable(b, scope, column, out span); - value.setAndGet((r == Result.SUCCESS) ? span.ToArray() :) + Result r = this.ReadVariable(buffer, scope, column, out span); + value.set((r == Result.SUCCESS) ? span.ToArray() :) default return r; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result ReadVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out + //ORIGINAL LINE: public Result ReadVariable(ref RowBuffer buffer, ref RowCursor scope, LayoutColumn column, out // ReadOnlySpan value) - public Result ReadVariable(Reference b, Reference scope, LayoutColumn col - , Out> value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), col.getNullBit().clone())) { - value.setAndGet(null); + public Result ReadVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out> value) { + checkArgument(scope.scopeType() instanceof LayoutUDT); + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set(null); return Result.NOT_FOUND; } - int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), - col.getOffset()); - value.setAndGet(b.get().readVariableBinary(varOffset)); + int varOffset = buffer.computeVariableValueOffset(scope.layout(), scope.start(), column.offset()); + value.set(buffer.readVariableBinary(varOffset)); return Result.SUCCESS; } @@ -127,51 +118,50 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //ORIGINAL LINE: public override Result WriteFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, byte[] // value) @Override - public Result writeFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - byte[] value) { + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, byte[] value) { checkArgument(value != null); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: return this.WriteFixed(ref b, ref scope, col, new ReadOnlySpan(value)); - return this.WriteFixed(b, scope, column, new ReadOnlySpan(value)); + return this.writeFixed(buffer, scope, column, new ReadOnlySpan(value)); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public Result WriteFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, // ReadOnlySpan value) - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - ReadOnlySpan value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - checkArgument(col.getSize() >= 0); - checkArgument(value.Length == col.getSize()); - if (scope.get().immutable()) { + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, List value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + checkArgument(column.size() >= 0); + checkArgument(value.Length == column.size()); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().WriteFixedBinary(scope.get().start() + col.getOffset(), value, col.getSize()); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.writeFixedBinary(scope.start() + column.offset(), value, column.size()); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result WriteFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, + //ORIGINAL LINE: public Result WriteFixed(ref RowBuffer buffer, ref RowCursor scope, LayoutColumn col, // ReadOnlySequence value) - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - ReadOnlySequence value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - checkArgument(col.getSize() >= 0); - checkArgument(value.Length == col.getSize()); - if (scope.get().immutable()) { + public Result WriteFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, ReadOnlySequence value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + checkArgument(column.size() >= 0); + checkArgument(value.Length == column.size()); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().WriteFixedBinary(scope.get().start() + col.getOffset(), value, col.getSize()); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.writeFixedBinary(scope.start() + column.offset(), value, column.size()); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } @Override - public Result writeSparse(RowBuffer b, RowCursor edit, byte[] value) { - return writeSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(RowBuffer buffer, RowCursor edit, byte[] value) { + return writeSparse(buffer, edit, value, UpdateOptions.Upsert); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: @@ -179,51 +169,51 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa // UpdateOptions options = UpdateOptions.Upsert) //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @Override - public Result writeSparse(RowBuffer b, RowCursor edit, byte[] value, + public Result writeSparse(RowBuffer buffer, RowCursor edit, byte[] value, UpdateOptions options) { checkArgument(value != null); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: return this.WriteSparse(ref b, ref edit, new ReadOnlySpan(value), options); - return this.WriteSparse(b, edit, new ReadOnlySpan(value), options); + return this.WriteSparse(buffer, edit, new ReadOnlySpan(value), options); } - public Result WriteSparse(Reference b, Reference edit, - ReadOnlySpan value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(RowBuffer buffer, RowCursor edit, Byte value) { + return writeSparse(buffer, edit, value, UpdateOptions.Upsert); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public Result WriteSparse(ref RowBuffer b, ref RowCursor edit, ReadOnlySpan value, // UpdateOptions options = UpdateOptions.Upsert) //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - public Result WriteSparse(Reference b, Reference edit, - ReadOnlySpan value, UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + public Result writeSparse(RowBuffer buffer, RowCursor edit, List value, UpdateOptions options) { + + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().writeSparseBinary(edit, value, options); + buffer.writeSparseBinary(edit, value, options); return Result.SUCCESS; } - public Result WriteSparse(Reference b, Reference edit, - ReadOnlySequence value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result WriteSparse(RowBuffer b, RowCursor edit, ReadOnlySequence value) { + return writeSparse(b, edit, value, UpdateOptions.Upsert); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public Result WriteSparse(ref RowBuffer b, ref RowCursor edit, ReadOnlySequence value, // UpdateOptions options = UpdateOptions.Upsert) //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - public Result WriteSparse(Reference b, Reference edit, - ReadOnlySequence value, UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + public Result WriteSparse(RowBuffer b, RowCursor edit, ReadOnlySequence value, UpdateOptions options) { + + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().writeSparseBinary(edit, value, options); + b.writeSparseBinary(edit, value, options); return Result.SUCCESS; } @@ -231,67 +221,68 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //ORIGINAL LINE: public override Result WriteVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, // byte[] value) @Override - public Result writeVariable(Reference b, Reference scope, - LayoutColumn col, byte[] value) { + public Result writeVariable(RowBuffer buffer, RowCursor scope, + LayoutColumn column, byte[] value) { checkArgument(value != null); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: return this.WriteVariable(ref b, ref scope, col, new ReadOnlySpan(value)); - return this.WriteVariable(b, scope, col, new ReadOnlySpan(value)); + return this.writeVariable(buffer, scope, column, new ReadOnlySpan(value)); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public Result WriteVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, // ReadOnlySpan value) - public Result WriteVariable(Reference b, Reference scope, - LayoutColumn col, ReadOnlySpan value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + public Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, List value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } int length = value.Length; - if ((col.getSize() > 0) && (length > col.getSize())) { + + if ((column.size() > 0) && (length > column.size())) { return Result.TOO_BIG; } - boolean exists = b.get().readBit(scope.get().start(), col.getNullBit().clone()); - int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), - col.getOffset()); + boolean exists = buffer.readBit(scope.start(), column.nullBit()); + int varOffset = buffer.computeVariableValueOffset(scope.layout(), scope.start(), + column.offset()); int shift; Out tempOut_shift = new Out(); - b.get().writeVariableBinary(varOffset, value, exists, tempOut_shift); + buffer.writeVariableBinary(varOffset, value, exists, tempOut_shift); shift = tempOut_shift.get(); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); - scope.get().metaOffset(scope.get().metaOffset() + shift); - scope.get().valueOffset(scope.get().valueOffset() + shift); + buffer.setBit(scope.start(), column.nullBit()); + scope.metaOffset(scope.metaOffset() + shift); + scope.valueOffset(scope.valueOffset() + shift); return Result.SUCCESS; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public Result WriteVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, + //ORIGINAL LINE: public Result WriteVariable(ref RowBuffer buffer, ref RowCursor scope, LayoutColumn column, // ReadOnlySequence value) - public Result WriteVariable(Reference b, Reference scope, - LayoutColumn col, ReadOnlySequence value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + public Result WriteVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, ReadOnlySequence value) { + checkArgument(scope.scopeType() instanceof LayoutUDT); + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } int length = (int)value.Length; - if ((col.getSize() > 0) && (length > col.getSize())) { + if ((column.size() > 0) && (length > column.size())) { return Result.TOO_BIG; } - boolean exists = b.get().readBit(scope.get().start(), col.getNullBit().clone()); - int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), - col.getOffset()); + boolean exists = buffer.readBit(scope.start(), column.nullBit()); + int varOffset = buffer.computeVariableValueOffset(scope.layout(), scope.start(), + column.offset()); int shift; Out tempOut_shift = new Out(); - b.get().writeVariableBinary(varOffset, value, exists, tempOut_shift); - shift = tempOut_shift.get(); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); - scope.get().metaOffset(scope.get().metaOffset() + shift); - scope.get().valueOffset(scope.get().valueOffset() + shift); + buffer.writeVariableBinary(varOffset, value, exists, tempOut_shift); + shift = tempOut_shift; + buffer.setBit(scope.start(), column.nullBit()); + scope.metaOffset(scope.metaOffset() + shift); + scope.valueOffset(scope.valueOffset() + shift); return Result.SUCCESS; } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java index 2c970ee..d4bef84 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java @@ -4,91 +4,136 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; public final class LayoutBoolean extends LayoutType { + public LayoutBoolean(boolean value) { - super(, 0); + super(value ? LayoutCode.BOOLEAN : LayoutCode.BOOLEAN_FALSE, 0); } + @Override public boolean isBoolean() { return true; } + @Override public boolean isFixed() { return true; } + @Override public String name() { return "bool"; } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { - value.setAndGet(false); + @Nonnull + public Result readFixed( + @Nonnull final RowBuffer buffer, + @Nonnull final RowCursor scope, + @Nonnull final LayoutColumn column, + @Nonnull final Out value) { + + checkNotNull(buffer, "expected non-null buffer"); + checkNotNull(scope, "expected non-null scope"); + checkNotNull(column, "expected non-null column"); + checkNotNull(value, "expected non-null value"); + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set(false); return Result.NOT_FOUND; } - value.setAndGet(b.get().readBit(scope.get().start(), column.getBooleanBit().clone())); + value.set(buffer.readBit(scope.start(), column.booleanBit())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse( + @Nonnull final RowBuffer buffer, + @Nonnull final RowCursor edit, + @Nonnull final Out value) { + + checkNotNull(buffer, "expected non-null buffer"); + checkNotNull(edit, "expected non-null edit"); + checkNotNull(value, "expected non-null value"); + + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); if (result != Result.SUCCESS) { - value.setAndGet(false); + value.set(false); return result; } - value.setAndGet(b.get().ReadSparseBool(edit)); + value.set(buffer.readSparseBoolean(edit)); return Result.SUCCESS; } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - boolean value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed( + @Nonnull final RowBuffer buffer, + @Nonnull final RowCursor scope, + @Nonnull final LayoutColumn column, + @Nonnull final Boolean value) { + + checkNotNull(buffer, "expected non-null buffer"); + checkNotNull(scope, "expected non-null scope"); + checkNotNull(column, "expected non-null column"); + checkNotNull(value, "expected non-null value"); + + checkArgument(scope.scopeType() instanceof LayoutUDT, + "expected scope of %s, not %s", LayoutUDT.class, scope.scopeType().getClass()); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } if (value) { - b.get().setBit(scope.get().start(), col.getBooleanBit().clone()); + buffer.setBit(scope.start(), column.booleanBit()); } else { - b.get().unsetBit(scope.get().start(), col.getBooleanBit().clone()); + buffer.unsetBit(scope.start(), column.booleanBit()); } - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, bool value, - // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, boolean value, - UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse( + @Nonnull final RowBuffer buffer, + @Nonnull final RowCursor edit, + @Nonnull final Boolean value, + @Nonnull final UpdateOptions options) { + + checkNotNull(buffer, "expected non-null buffer"); + checkNotNull(edit, "expected non-null edit"); + checkNotNull(value, "expected non-null value"); + checkNotNull(options, "expected non-null options"); + + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().writeSparseBoolean(edit, value, options); + buffer.writeSparseBoolean(edit, value, options); return Result.SUCCESS; } @Override - public Result WriteSparse(Reference b, Reference edit, boolean value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(RowBuffer buffer, RowCursor edit, Boolean value) { + return this.writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java index 63bc038..a738c60 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java @@ -3,9 +3,10 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; -// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: -///#pragma warning disable CA1028 // Enum Storage should be Int32 - +import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; +import it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.util.HashMap; import java.util.Map; @@ -13,13 +14,12 @@ import java.util.Map; /** * Type coded used in the binary encoding to indicate the formatting of succeeding bytes. */ -//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: -//ORIGINAL LINE: public enum LayoutCode : byte public enum LayoutCode { INVALID((byte)0), NULL((byte)1), + BOOLEAN_FALSE((byte)2), BOOLEAN((byte)3), @@ -28,14 +28,8 @@ public enum LayoutCode { INT_32((byte)7), INT_64((byte)8), UINT_8((byte)9), - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: UInt16 = 10, UINT_16((byte)10), - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: UInt32 = 11, UINT_32((byte)11), - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: UInt64 = 12, UINT_64((byte)12), VAR_INT((byte)13), VAR_UINT((byte)14), @@ -56,26 +50,37 @@ public enum LayoutCode { OBJECT_SCOPE((byte)30), IMMUTABLE_OBJECT_SCOPE((byte)31), + ARRAY_SCOPE((byte)32), IMMUTABLE_ARRAY_SCOPE((byte)33), + TYPED_ARRAY_SCOPE((byte)34), IMMUTABLE_TYPED_ARRAY_SCOPE((byte)35), + TUPLE_SCOPE((byte)36), IMMUTABLE_TUPLE_SCOPE((byte)37), + TYPED_TUPLE_SCOPE((byte)38), IMMUTABLE_TYPED_TUPLE_SCOPE((byte)39), + MAP_SCOPE((byte)40), IMMUTABLE_MAP_SCOPE((byte)41), + TYPED_MAP_SCOPE((byte)42), IMMUTABLE_TYPED_MAP_SCOPE((byte)43), + SET_SCOPE((byte)44), IMMUTABLE_SET_SCOPE((byte)45), + TYPED_SET_SCOPE((byte)46), IMMUTABLE_TYPED_SET_SCOPE((byte)47), + NULLABLE_SCOPE((byte)48), IMMUTABLE_NULLABLE_SCOPE((byte)49), + TAGGED_SCOPE((byte)50), IMMUTABLE_TAGGED_SCOPE((byte)51), + TAGGED2_SCOPE((byte)52), IMMUTABLE_TAGGED2_SCOPE((byte)53), @@ -89,7 +94,7 @@ public enum LayoutCode { public static final int BYTES = Byte.BYTES; - private static Map mappings; + private static Byte2ObjectMap mappings; private byte value; LayoutCode(byte value) { @@ -98,10 +103,10 @@ public enum LayoutCode { } public byte value() { - return value; + return this.value; } - public static LayoutCode forValue(byte value) { + public static LayoutCode from(byte value) { return mappings().get(value); } @@ -109,7 +114,7 @@ public enum LayoutCode { if (mappings == null) { synchronized (LayoutCode.class) { if (mappings == null) { - mappings = new HashMap(); + mappings = new Byte2ObjectOpenHashMap<>(); } } } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java index d684519..b950d54 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java @@ -5,37 +5,34 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; public final class LayoutCodeTraits { /** - * Returns true if the type code indicates that, even within a typed scope, this element type - * always requires a type code (because the value itself is in the type code). + * {@code true} if the specified layout code indicates that an element type always requires a type code + *

+ * When this method returns {@code true} it indicates that the element value is in the type code. * * @param code The element type code. */ - public static boolean AlwaysRequiresTypeCode(LayoutCode code) { + public static boolean alwaysRequiresTypeCode(LayoutCode code) { return (code == LayoutCode.BOOLEAN) || (code == LayoutCode.BOOLEAN_FALSE) || (code == LayoutCode.NULL); } /** - * Returns a canonicalized version of the layout code. + * Returns a canonicalized version of the specified layout code *

- * Some codes (e.g. {@link LayoutCode.Boolean} use multiple type codes to also encode - * values. This function converts actual value based code into the canonicalized type code for schema - * comparisons. + * Some codes (e.g. {@link LayoutCode#BOOLEAN} use multiple type codes to also encode values. This function converts + * actual value based code into the canonicalized type code for schema comparisons. * - * @param code The code to canonicalize. + * @param code The code to canonicalize */ - public static LayoutCode Canonicalize(LayoutCode code) { + public static LayoutCode canonicalize(LayoutCode code) { return (code == LayoutCode.BOOLEAN_FALSE) ? LayoutCode.BOOLEAN : code; } /** * Returns the same scope code without the immutable bit set. * - * @param code The scope type code. + * @param code The scope type code */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] public static LayoutCode ClearImmutableBit - // (LayoutCode code) - public static LayoutCode ClearImmutableBit(LayoutCode code) { - return code.value() & LayoutCode.forValue((byte)0xFE).value(); + public static LayoutCode clearImmutableBit(LayoutCode code) { + return LayoutCode.from((byte) (code.value() & 0xFE)); } } \ No newline at end of file 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 6046f88..77da86e 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 @@ -193,7 +193,7 @@ public final class LayoutColumn { private static @Nonnull String fullPath(final LayoutColumn parent, @Nonnull final String path) { if (parent != null) { - switch (LayoutCodeTraits.ClearImmutableBit(parent.type().layoutCode())) { + switch (LayoutCodeTraits.clearImmutableBit(parent.type().layoutCode())) { case OBJECT_SCOPE: case SCHEMA: return parent.fullPath().toString() + "." + path; diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompilationException.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompilationException.java index 748607f..af0c639 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompilationException.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompilationException.java @@ -5,9 +5,8 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import java.io.Serializable; -// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: -//ORIGINAL LINE: [Serializable][ExcludeFromCodeCoverage] public sealed class LayoutCompilationException : Exception public final class LayoutCompilationException extends RuntimeException implements Serializable { + public LayoutCompilationException() { } @@ -15,11 +14,7 @@ public final class LayoutCompilationException extends RuntimeException implement super(message); } - public LayoutCompilationException(String message, RuntimeException innerException) { - super(message, innerException); - } - - private LayoutCompilationException(SerializationInfo info, StreamingContext context) { - super(info, context); + public LayoutCompilationException(String message, RuntimeException cause) { + super(message, cause); } } \ No newline at end of file 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 33742b6..467033a 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 @@ -19,8 +19,9 @@ import com.azure.data.cosmos.serialization.hybridrow.schemas.TaggedPropertyType; import com.azure.data.cosmos.serialization.hybridrow.schemas.TuplePropertyType; import com.azure.data.cosmos.serialization.hybridrow.schemas.TypeKind; import com.azure.data.cosmos.serialization.hybridrow.schemas.UdtPropertyType; +import tangible.ListHelper; -import java.util.ArrayList; +import java.util.List; import static com.google.common.base.Preconditions.checkArgument; @@ -42,21 +43,22 @@ public final class LayoutCompiler { checkArgument(!tangible.StringHelper.isNullOrWhiteSpace(schema.name())); checkArgument(ns.schemas().contains(schema)); - LayoutBuilder builder = new LayoutBuilder(schema.name(), schema.schemaId().clone()); - LayoutCompiler.AddProperties(builder, ns, LayoutCode.SCHEMA, schema.properties()); + LayoutBuilder builder = new LayoutBuilder(schema.name(), schema.schemaId()); + LayoutCompiler.addProperties(builder, ns, LayoutCode.SCHEMA, schema.properties()); return builder.build(); } - private static void AddProperties(LayoutBuilder builder, Namespace ns, LayoutCode scope, - ArrayList properties) { + private static void addProperties(LayoutBuilder builder, Namespace ns, LayoutCode scope, List properties) { + + final Out typeArgs = new Out<>(); + for (Property p : properties) { - TypeArgumentList typeArgs = new TypeArgumentList(); - Out tempOut_typeArgs = - new Out(); - LayoutType type = LayoutCompiler.LogicalToPhysicalType(ns, p.propertyType(), tempOut_typeArgs); - typeArgs = tempOut_typeArgs.get(); - switch (LayoutCodeTraits.ClearImmutableBit(type.LayoutCode)) { + + LayoutType type = LayoutCompiler.logicalToPhysicalType(ns, p.propertyType(), typeArgs); + + switch (LayoutCodeTraits.clearImmutableBit(type.layoutCode())) { + case OBJECT_SCOPE: { if (!p.propertyType().nullable()) { throw new LayoutCompilationException("Non-nullable sparse column are not supported."); @@ -64,7 +66,7 @@ public final class LayoutCompiler { ObjectPropertyType op = (ObjectPropertyType)p.propertyType(); builder.addObjectScope(p.path(), type); - LayoutCompiler.AddProperties(builder, ns, type.LayoutCode, op.properties()); + LayoutCompiler.addProperties(builder, ns, type.layoutCode(), op.properties()); builder.EndObjectScope(); break; } @@ -83,8 +85,7 @@ public final class LayoutCompiler { if (!p.propertyType().nullable()) { throw new LayoutCompilationException("Non-nullable sparse column are not supported."); } - - builder.addTypedScope(p.path(), type, typeArgs.clone()); + builder.addTypedScope(p.path(), type, typeArgs.get()); break; } @@ -99,12 +100,12 @@ public final class LayoutCompiler { if (pp != null) { switch (pp.storage()) { case FIXED: - if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) { + if (LayoutCodeTraits.clearImmutableBit(scope) != LayoutCode.SCHEMA) { throw new LayoutCompilationException("Cannot have fixed storage within a sparse " + "scope."); } - if (type.getIsNull() && !pp.nullable()) { + if (type.isNull() && !pp.nullable()) { throw new LayoutCompilationException("Non-nullable null columns are not supported" + "."); } @@ -112,7 +113,7 @@ public final class LayoutCompiler { builder.addFixedColumn(p.path(), type, pp.nullable(), pp.length()); break; case VARIABLE: - if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) { + if (LayoutCodeTraits.clearImmutableBit(scope) != LayoutCode.SCHEMA) { throw new LayoutCompilationException("Cannot have variable storage within a " + "sparse scope."); } @@ -138,7 +139,7 @@ public final class LayoutCompiler { } } else { throw new LayoutCompilationException(String.format("Unknown property type: %1$s", - type.getName())); + type.name())); } break; @@ -147,7 +148,7 @@ public final class LayoutCompiler { } } - private static LayoutType LogicalToPhysicalType(Namespace ns, PropertyType logicalType, + private static LayoutType logicalToPhysicalType(Namespace ns, PropertyType logicalType, Out typeArgs) { typeArgs.setAndGet(TypeArgumentList.EMPTY); boolean tempVar = @@ -158,124 +159,125 @@ public final class LayoutCompiler { switch (logicalType.type()) { case Null: - return LayoutType.Null; + return LayoutTypes.NULL; case Boolean: - return LayoutType.Boolean; + return LayoutTypes.BOOLEAN; case Int8: - return LayoutType.Int8; + return LayoutTypes.INT_8; case Int16: - return LayoutType.Int16; + return LayoutTypes.INT_16; case Int32: - return LayoutType.Int32; + return LayoutTypes.INT_32; case Int64: - return LayoutType.Int64; + return LayoutTypes.INT_64; case UInt8: - return LayoutType.UInt8; + return LayoutTypes.UINT_8; case UInt16: - return LayoutType.UInt16; + return LayoutTypes.UINT_16; case UInt32: - return LayoutType.UInt32; + return LayoutTypes.UINT_32; case UInt64: - return LayoutType.UInt64; + return LayoutTypes.UINT_64; case Float32: - return LayoutType.Float32; + return LayoutTypes.FLOAT_32; case Float64: - return LayoutType.Float64; + return LayoutTypes.FLOAT_64; case Float128: - return LayoutType.Float128; + return LayoutTypes.FLOAT_128; case Decimal: - return LayoutType.Decimal; + return LayoutTypes.DECIMAL; case DateTime: - return LayoutType.DateTime; + return LayoutTypes.DATE_TIME; case UnixDateTime: - return LayoutType.UnixDateTime; + return LayoutTypes.UNIX_DATE_TIME; case Guid: - return LayoutType.Guid; + return LayoutTypes.GUID; case MongoDbObjectId: - return LayoutType.MongoDbObjectId; + throw new UnsupportedOperationException(); + // return LayoutTypes.MONGO_DB_OBJECT_ID; case Utf8: - return LayoutType.Utf8; + return LayoutTypes.UTF_8; case Binary: - return LayoutType.Binary; + return LayoutTypes.BINARY; case VarInt: - return LayoutType.VarInt; + return LayoutTypes.VAR_INT; case VarUInt: - return LayoutType.VarUInt; + return LayoutTypes.VAR_UINT; case Object: - return immutable ? LayoutType.ImmutableObject : LayoutType.Object; + return immutable ? LayoutTypes.IMMUTABLE_OBJECT : LayoutTypes.OBJECT; case Array: ArrayPropertyType ap = (ArrayPropertyType)logicalType; if ((ap.items() != null) && (ap.items().type() != TypeKind.Any)) { TypeArgumentList itemTypeArgs = new TypeArgumentList(); Out tempOut_itemTypeArgs = new Out(); - LayoutType itemType = LayoutCompiler.LogicalToPhysicalType(ns, ap.items(), tempOut_itemTypeArgs); + LayoutType itemType = LayoutCompiler.logicalToPhysicalType(ns, ap.items(), tempOut_itemTypeArgs); itemTypeArgs = tempOut_itemTypeArgs.get(); if (ap.items().nullable()) { itemTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, - itemTypeArgs.clone()) }); - itemType = itemType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable; + itemTypeArgs) }); + itemType = itemType.isImmutable() ? LayoutTypes.IMMUTABLE_NULLABLE : LayoutTypes.NULLABLE; } typeArgs.setAndGet(new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, - itemTypeArgs.clone()) })); - return immutable ? LayoutType.ImmutableTypedArray : LayoutType.TypedArray; + itemTypeArgs) })); + return immutable ? LayoutTypes.IMMUTABLE_TYPED_ARRAY : LayoutTypes.TYPED_ARRAY; } - return immutable ? LayoutType.ImmutableArray : LayoutType.Array; - case Set: + return immutable ? LayoutTypes.IMMUTABLE_ARRAY : LayoutTypes.ARRAY; + case SET: SetPropertyType sp = (SetPropertyType)logicalType; if ((sp.items() != null) && (sp.items().type() != TypeKind.Any)) { TypeArgumentList itemTypeArgs = new TypeArgumentList(); Out tempOut_itemTypeArgs2 = new Out(); - LayoutType itemType = LayoutCompiler.LogicalToPhysicalType(ns, sp.items(), + LayoutType itemType = LayoutCompiler.logicalToPhysicalType(ns, sp.items(), tempOut_itemTypeArgs2); itemTypeArgs = tempOut_itemTypeArgs2.get(); if (sp.items().nullable()) { itemTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, - itemTypeArgs.clone()) }); - itemType = itemType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable; + itemTypeArgs) }); + itemType = itemType.isImmutable() ? LayoutTypes.IMMUTABLE_NULLABLE : LayoutTypes.NULLABLE; } typeArgs.setAndGet(new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, - itemTypeArgs.clone()) })); - return immutable ? LayoutType.ImmutableTypedSet : LayoutType.TypedSet; + itemTypeArgs) })); + return immutable ? LayoutTypes.IMMUTABLE_TYPED_SET : LayoutTypes.TYPED_SET; } // TODO(283638): implement sparse set. throw new LayoutCompilationException(String.format("Unknown property type: %1$s", logicalType.type())); - case Map: + case MAP: MapPropertyType mp = (MapPropertyType)logicalType; if ((mp.keys() != null) && (mp.keys().type() != TypeKind.Any) && (mp.values() != null) && (mp.values().type() != TypeKind.Any)) { TypeArgumentList keyTypeArgs = new TypeArgumentList(); Out tempOut_keyTypeArgs = new Out(); - LayoutType keyType = LayoutCompiler.LogicalToPhysicalType(ns, mp.keys(), tempOut_keyTypeArgs); + LayoutType keyType = LayoutCompiler.logicalToPhysicalType(ns, mp.keys(), tempOut_keyTypeArgs); keyTypeArgs = tempOut_keyTypeArgs.get(); if (mp.keys().nullable()) { keyTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(keyType, - keyTypeArgs.clone()) }); - keyType = keyType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable; + keyTypeArgs) }); + keyType = keyType.isImmutable() ? LayoutTypes.IMMUTABLE_NULLABLE : LayoutTypes.NULLABLE; } TypeArgumentList valueTypeArgs = new TypeArgumentList(); Out tempOut_valueTypeArgs = new Out(); - LayoutType valueType = LayoutCompiler.LogicalToPhysicalType(ns, mp.values(), + LayoutType valueType = LayoutCompiler.logicalToPhysicalType(ns, mp.values(), tempOut_valueTypeArgs); valueTypeArgs = tempOut_valueTypeArgs.get(); if (mp.values().nullable()) { valueTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(valueType, - valueTypeArgs.clone()) }); - valueType = valueType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable; + valueTypeArgs) }); + valueType = valueType.isImmutable() ? LayoutTypes.IMMUTABLE_NULLABLE : LayoutTypes.NULLABLE; } typeArgs.setAndGet(new TypeArgumentList(new TypeArgument[] { - new TypeArgument(keyType, keyTypeArgs.clone()), - new TypeArgument(valueType, valueTypeArgs.clone()) + new TypeArgument(keyType, keyTypeArgs), + new TypeArgument(valueType, valueTypeArgs) })); - return immutable ? LayoutType.ImmutableTypedMap : LayoutType.TypedMap; + return immutable ? LayoutTypes.IMMUTABLE_TYPED_MAP : LayoutTypes.TYPED_MAP; } // TODO(283638): implement sparse map. @@ -288,22 +290,22 @@ public final class LayoutCompiler { for (int i = 0; i < tp.items().size(); i++) { TypeArgumentList itemTypeArgs = new TypeArgumentList(); Out tempOut_itemTypeArgs3 = new Out(); - LayoutType itemType = LayoutCompiler.LogicalToPhysicalType(ns, tp.items().get(i), + LayoutType itemType = LayoutCompiler.logicalToPhysicalType(ns, tp.items().get(i), tempOut_itemTypeArgs3); itemTypeArgs = tempOut_itemTypeArgs3.get(); if (tp.items().get(i).nullable()) { itemTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, - itemTypeArgs.clone()) }); - itemType = itemType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable; + itemTypeArgs) }); + itemType = itemType.isImmutable() ? LayoutTypes.IMMUTABLE_NULLABLE : LayoutTypes.NULLABLE; } - args[i] = new TypeArgument(itemType, itemTypeArgs.clone()); + args[i] = new TypeArgument(itemType, itemTypeArgs); } typeArgs.setAndGet(new TypeArgumentList(args)); - return immutable ? LayoutType.ImmutableTypedTuple : LayoutType.TypedTuple; + return immutable ? LayoutTypes.IMMUTABLE_TYPED_TUPLE : LayoutTypes.TYPED_TUPLE; - case Tagged: + case TAGGED: TaggedPropertyType tg = (TaggedPropertyType)logicalType; if ((tg.items().size() < TaggedPropertyType.MinTaggedArguments) || (tg.items().size() > TaggedPropertyType.MaxTaggedArguments)) { throw new LayoutCompilationException(String.format("Invalid number of arguments in Tagged: %1$s " + @@ -312,28 +314,28 @@ public final class LayoutCompiler { } TypeArgument[] tgArgs = new TypeArgument[tg.items().size() + 1]; - tgArgs[0] = new TypeArgument(LayoutType.UInt8, TypeArgumentList.EMPTY); + tgArgs[0] = new TypeArgument(LayoutTypes.UINT_8, TypeArgumentList.EMPTY); for (int i = 0; i < tg.items().size(); i++) { TypeArgumentList itemTypeArgs = new TypeArgumentList(); Out tempOut_itemTypeArgs4 = new Out(); - LayoutType itemType = LayoutCompiler.LogicalToPhysicalType(ns, tg.items().get(i), + LayoutType itemType = LayoutCompiler.logicalToPhysicalType(ns, tg.items().get(i), tempOut_itemTypeArgs4); itemTypeArgs = tempOut_itemTypeArgs4.get(); if (tg.items().get(i).nullable()) { itemTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, - itemTypeArgs.clone()) }); - itemType = itemType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable; + itemTypeArgs) }); + itemType = itemType.isImmutable() ? LayoutTypes.IMMUTABLE_NULLABLE : LayoutTypes.NULLABLE; } - tgArgs[i + 1] = new TypeArgument(itemType, itemTypeArgs.clone()); + tgArgs[i + 1] = new TypeArgument(itemType, itemTypeArgs); } typeArgs.setAndGet(new TypeArgumentList(tgArgs)); switch (tg.items().size()) { case 1: - return immutable ? LayoutType.ImmutableTagged : LayoutType.Tagged; + return immutable ? LayoutTypes.IMMUTABLE_TAGGED : LayoutTypes.TAGGED; case 2: - return immutable ? LayoutType.ImmutableTagged2 : LayoutType.Tagged2; + return immutable ? LayoutTypes.IMMUTABLE_TAGGED_2 : LayoutTypes.TAGGED_2; default: throw new LayoutCompilationException("Unexpected tagged arity"); } @@ -341,24 +343,24 @@ public final class LayoutCompiler { case Schema: UdtPropertyType up = (UdtPropertyType)logicalType; Schema udtSchema; - if (SchemaId.opEquals(up.schemaId().clone(), SchemaId.INVALID)) { - udtSchema = tangible.ListHelper.find(ns.schemas(), s = up.name().equals( > s.Name)) + if (SchemaId.opEquals(up.schemaId(), SchemaId.INVALID)) { + udtSchema = ListHelper.find(ns.schemas(), s = up.name().equals( > s.Name)) } else { - udtSchema = tangible.ListHelper.find(ns.schemas(), s = - SchemaId.opEquals( > s.SchemaId, up.schemaId().clone())) + udtSchema = ListHelper.find(ns.schemas(), s = + SchemaId.opEquals( > s.SchemaId, up.schemaId())) if (!udtSchema.name().equals(up.name())) { throw new LayoutCompilationException(String.format("Ambiguous schema reference: '%1$s:%2$s'", - up.name(), up.schemaId().clone())); + up.name(), up.schemaId())); } } if (udtSchema == null) { throw new LayoutCompilationException(String.format("Cannot resolve schema reference '%1$s:%2$s'", - up.name(), up.schemaId().clone())); + up.name(), up.schemaId())); } - typeArgs.setAndGet(new TypeArgumentList(udtSchema.schemaId().clone())); - return immutable ? LayoutType.ImmutableUDT : LayoutType.UDT; + typeArgs.setAndGet(new TypeArgumentList(udtSchema.schemaId())); + return immutable ? LayoutTypes.IMMUTABLE_UDT : LayoutTypes.UDT; default: throw new LayoutCompilationException(String.format("Unknown property type: %1$s", diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java index 0acee9f..b1bd1e2 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java @@ -8,14 +8,18 @@ import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import com.azure.data.cosmos.serialization.hybridrow.codecs.DateTimeCodec; +import javax.annotation.Nonnull; import java.time.LocalDateTime; +import java.time.OffsetDateTime; import static com.google.common.base.Preconditions.checkArgument; -public final class LayoutDateTime extends LayoutType { +public final class LayoutDateTime extends LayoutType { + public LayoutDateTime() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.DATE_TIME, 8); + super(LayoutCode.DATE_TIME, DateTimeCodec.BYTES); } public boolean isFixed() { @@ -27,60 +31,66 @@ public final class LayoutDateTime extends LayoutType { } @Override - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), col.getNullBit().clone())) { - value.setAndGet(LocalDateTime.MIN); + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set(OffsetDateTime.MIN); return Result.NOT_FOUND; } - value.setAndGet(b.get().readDateTime(scope.get().start() + col.getOffset())); + value.set(buffer.readDateTime(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result ReadSparse(Reference b, Reference edit, - Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { - value.setAndGet(LocalDateTime.MIN); + value.set(OffsetDateTime.MIN); return result; } - value.setAndGet(b.get().readSparseDateTime(edit)); + value.set(buffer.readSparseDateTime(edit)); return Result.SUCCESS; } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - LocalDateTime value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, OffsetDateTime value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().writeDateTime(scope.get().start() + col.getOffset(), value); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); - return Result.SUCCESS; - } - - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, DateTime value, - // UpdateOptions options = UpdateOptions.Upsert) - public Result writeSparse(Reference b, Reference edit, - LocalDateTime value, UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); - if (result != Result.SUCCESS) { - return result; - } - - b.get().writeSparseDateTime(edit, value, options); + buffer.writeDateTime(scope.start() + column.offset(), value); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } @Override - public Result writeSparse(RowBuffer b, RowCursor edit, DateTime value) { - return writeSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer b, RowCursor edit, OffsetDateTime value, UpdateOptions options) { + + Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg(), options); + + if (result != Result.SUCCESS) { + return result; + } + + b.writeSparseDateTime(edit, value, options); + return Result.SUCCESS; + } + + @Override + public Result writeSparse(RowBuffer buffer, RowCursor edit, OffsetDateTime value) { + return this.writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java index 21fa640..4caafb5 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java @@ -7,15 +7,17 @@ import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import com.azure.data.cosmos.serialization.hybridrow.codecs.DecimalCodec; +import javax.annotation.Nonnull; import java.math.BigDecimal; import static com.google.common.base.Preconditions.checkArgument; public final class LayoutDecimal extends LayoutType { + public LayoutDecimal() { - // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.DECIMAL, sizeof(BigDecimal)); + super(LayoutCode.DECIMAL, DecimalCodec.BYTES); } public boolean isFixed() { @@ -27,62 +29,63 @@ public final class LayoutDecimal extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { value.setAndGet(new BigDecimal(0)); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadDecimal(scope.get().start() + column.getOffset())); + value.setAndGet(buffer.readDecimal(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); if (result != Result.SUCCESS) { value.setAndGet(new BigDecimal(0)); return result; } - value.setAndGet(b.get().ReadSparseDecimal(edit)); + value.setAndGet(buffer.readSparseDecimal(edit)); return Result.SUCCESS; } @Override - public Result writeFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, BigDecimal value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + checkArgument(scope.scopeType() instanceof LayoutUDT); + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().WriteDecimal(scope.get().start() + column.getOffset(), value); - b.get().SetBit(scope.get().start(), column.getNullBit().clone()); + buffer.writeDecimal(scope.start() + column.offset(), value); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, decimal value, - // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeSparse(RowBuffer b, RowCursor edit, BigDecimal value, - UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, BigDecimal value, UpdateOptions options) { + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg(), options); if (result != Result.SUCCESS) { return result; } - b.get().WriteSparseDecimal(edit, value, options); + buffer.writeSparseDecimal(edit, value, options); return Result.SUCCESS; } @Override - public Result writeSparse(RowBuffer b, RowCursor edit, - BigDecimal value) { - return writeSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, BigDecimal value) { + return this.writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java index ecec16d..00f2a1c 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java @@ -8,35 +8,29 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + public final class LayoutEndScope extends LayoutScope { + public LayoutEndScope() { - // TODO: C# TO JAVA CONVERTER: C# to Java Converter could not resolve the named parameters in the - // following line: - //ORIGINAL LINE: base(LayoutCode.EndScope, false, isSizedScope: false, isIndexedScope: false, isFixedArity: - // false, isUniqueScope: false, isTypedScope: false); - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.END_SCOPE, false, isSizedScope():false, isIndexedScope():false, isFixedArity():false, isUniqueScope(): - false, isTypedScope():false) + super(LayoutCode.END_SCOPE, false, false, false, false, false, false); } public String name() { return "end"; } - @Override - public Result writeScope(RowBuffer b, RowCursor scope, - TypeArgumentList typeArgs, Out value) { - return writeScope(b, scope, typeArgs, UpdateOptions.Upsert, value); + @Nonnull + public Result writeScope(RowBuffer buffer, RowCursor scope, TypeArgumentList typeArgs, Out value) { + return this.writeScope(buffer, scope, typeArgs, UpdateOptions.Upsert, value); } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor scope, TypeArgumentList - // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor scope, - TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Contract.Fail("Cannot write an EndScope directly"); - value.setAndGet(null); + @Nonnull + public Result writeScope(RowBuffer buffer, RowCursor scope, TypeArgumentList typeArgs, UpdateOptions options, Out value) { + assert false : "cannot write an EndScope directly"; + value.set(null); return Result.FAILURE; } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java index d5b1d24..4f9aa78 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java @@ -9,11 +9,14 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.google.common.base.Preconditions.checkArgument; -public final class LayoutFloat128 extends LayoutType { +public final class LayoutFloat128 extends LayoutType { + public LayoutFloat128() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.FLOAT_128, HybridRow.Float128.Size); + super(LayoutCode.FLOAT_128, Float128.BYTES); } public boolean isFixed() { @@ -25,61 +28,67 @@ public final class LayoutFloat128 extends LayoutType value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { value.setAndGet(null); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadFloat128(scope.get().start() + column.getOffset()).clone()); + value.setAndGet(buffer.readFloat128(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - value.setAndGet(b.get().ReadSparseFloat128(edit).clone()); + value.setAndGet(buffer.readSparseFloat128(edit)); return Result.SUCCESS; } @Override - public Result writeFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Float128 value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Float128 value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().writeFloat128(scope.get().start() + column.getOffset(), value); - b.get().SetBit(scope.get().start(), column.getNullBit().clone()); + buffer.writeFloat128(scope.start() + column.offset(), value); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, Float128 value, - // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeSparse(RowBuffer b, RowCursor edit, Float128 value, - UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Float128 value, UpdateOptions options) { + + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().WriteSparseFloat128(edit, value.clone(), options); + buffer.writeSparseFloat128(edit, value, options); return Result.SUCCESS; } @Override - public Result writeSparse(RowBuffer b, RowCursor edit, Float128 value) { - return writeSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Float128 value) { + return this.writeSparse(buffer, edit, value, UpdateOptions.Upsert); } -} \ No newline at end of file +} diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java index 4042906..55b6fca 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java @@ -9,11 +9,14 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.google.common.base.Preconditions.checkArgument; public final class LayoutFloat32 extends LayoutType { + public LayoutFloat32() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.FLOAT_32, (Float.SIZE / Byte.SIZE)); + super(LayoutCode.FLOAT_32, Float.BYTES); } public boolean isFixed() { @@ -25,61 +28,67 @@ public final class LayoutFloat32 extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { - value.setAndGet(0); + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set(0F); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadFloat32(scope.get().start() + column.getOffset())); + value.set(buffer.readFloat32(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + + Result result = prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { - value.setAndGet(0); + value.set(0F); return result; } - value.setAndGet(b.get().ReadSparseFloat32(edit)); + value.set(buffer.readSparseFloat32(edit)); return Result.SUCCESS; } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - float value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Float value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().writeFloat32(scope.get().start() + col.getOffset(), value); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.writeFloat32(scope.start() + column.offset(), value); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, float value, - // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, float value, - UpdateOptions options) { - Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Float value, UpdateOptions options) { + + Result result = prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().writeSparseFloat32(edit, value, options); + buffer.writeSparseFloat32(edit, value, options); return Result.SUCCESS; } @Override - public Result WriteSparse(Reference b, Reference edit, float value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Float value) { + return this.writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java index 05cae52..d29e552 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java @@ -4,16 +4,18 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.google.common.base.Preconditions.checkArgument; public final class LayoutFloat64 extends LayoutType { + public LayoutFloat64() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.FLOAT_64, (Double.SIZE / Byte.SIZE)); + super(LayoutCode.FLOAT_64, Double.BYTES / Byte.SIZE); } public boolean isFixed() { @@ -25,41 +27,47 @@ public final class LayoutFloat64 extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { - value.setAndGet(0); + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set(0D); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadFloat64(scope.get().start() + column.getOffset())); + value.set(buffer.readFloat64(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { - value.setAndGet(0); + value.set(0D); return result; } - value.setAndGet(b.get().ReadSparseFloat64(edit)); + value.set(buffer.readSparseFloat64(edit)); return Result.SUCCESS; } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - double value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn col, Double value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().writeFloat64(scope.get().start() + col.getOffset(), value); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.writeFloat64(scope.start() + col.offset(), value); + buffer.setBit(scope.start(), col.nullBit()); return Result.SUCCESS; } @@ -67,19 +75,22 @@ public final class LayoutFloat64 extends LayoutType { //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, double value, // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, double value, - UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Double value, UpdateOptions options) { + + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().writeSparseFloat64(edit, value, options); + buffer.writeSparseFloat64(edit, value, options); return Result.SUCCESS; } @Override - public Result WriteSparse(Reference b, Reference edit, double value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Double value) { + return this.writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java index d1a38b5..d65341f 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java @@ -7,14 +7,17 @@ import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import com.azure.data.cosmos.serialization.hybridrow.codecs.GuidCodec; +import javax.annotation.Nonnull; import java.util.UUID; import static com.google.common.base.Preconditions.checkArgument; public final class LayoutGuid extends LayoutType { + public LayoutGuid() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.GUID, 16); + super(LayoutCode.GUID, GuidCodec.BYTES); } public boolean isFixed() { @@ -26,62 +29,67 @@ public final class LayoutGuid extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { - value.setAndGet(null); + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set(null); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadGuid(scope.get().start() + column.getOffset())); + value.set(buffer.readGuid(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + + Result result = prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { - value.setAndGet(null); + value.set(null); return result; } - value.setAndGet(b.get().ReadSparseGuid(edit)); + value.set(buffer.readSparseGuid(edit)); return Result.SUCCESS; } @Override - public Result writeFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - UUID value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, UUID value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().WriteGuid(scope.get().start() + column.getOffset(), value); - b.get().SetBit(scope.get().start(), column.getNullBit().clone()); + buffer.writeGuid(scope.start() + column.offset(), value); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, GuidCodec value, - // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeSparse(RowBuffer b, RowCursor edit, UUID value, - UpdateOptions options) { - Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, UUID value, UpdateOptions options) { + + Result result = prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().WriteSparseGuid(edit, value, options); + buffer.writeSparseGuid(edit, value, options); return Result.SUCCESS; } @Override - public Result writeSparse(RowBuffer b, RowCursor edit, - UUID value) { - return writeSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, UUID value) { + return this.writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java index 8cb9ee2..8ee0dab 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java @@ -4,16 +4,18 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.google.common.base.Preconditions.checkArgument; public final class LayoutInt16 extends LayoutType { + public LayoutInt16() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_16, (Short.SIZE / Byte.SIZE)); + super(LayoutCode.INT_16, Short.BYTES); } public boolean isFixed() { @@ -25,61 +27,67 @@ public final class LayoutInt16 extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { - value.setAndGet(0); + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set((short) 0); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadInt16(scope.get().start() + column.getOffset())); + value.set(buffer.readInt16(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + + Result result = prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { - value.setAndGet(0); + value.set((short) 0); return result; } - value.setAndGet(b.get().ReadSparseInt16(edit)); + value.set(buffer.readSparseInt16(edit)); return Result.SUCCESS; } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - short value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Short value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().writeInt16(scope.get().start() + col.getOffset(), value); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.writeInt16(scope.start() + column.offset(), value); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, short value, - // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, short value, - UpdateOptions options) { - Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Short value, UpdateOptions options) { + + Result result = prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().writeSparseInt16(edit, value, options); + buffer.writeSparseInt16(edit, value, options); return Result.SUCCESS; } @Override - public Result WriteSparse(Reference b, Reference edit, short value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Short value) { + return this.writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java index 80833f3..33f0ea5 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java @@ -4,16 +4,18 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.google.common.base.Preconditions.checkArgument; public final class LayoutInt32 extends LayoutType { + public LayoutInt32() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_32, (Integer.SIZE / Byte.SIZE)); + super(LayoutCode.INT_32, Integer.BYTES); } public boolean isFixed() { @@ -25,61 +27,67 @@ public final class LayoutInt32 extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { - value.setAndGet(0); + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set(0); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadInt32(scope.get().start() + column.getOffset())); + value.set(buffer.readInt32(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { - value.setAndGet(0); + value.set(0); return result; } - value.setAndGet(b.get().ReadSparseInt32(edit)); + value.set(buffer.readSparseInt32(edit)); return Result.SUCCESS; } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - int value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Integer value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().writeInt32(scope.get().start() + col.getOffset(), value); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.writeInt32(scope.start() + column.offset(), value); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, int value, UpdateOptions - // options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, int value, - UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Integer value, UpdateOptions options) { + + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().writeSparseInt32(edit, value, options); + buffer.writeSparseInt32(edit, value, options); return Result.SUCCESS; } @Override - public Result WriteSparse(Reference b, Reference edit, int value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer b, RowCursor edit, Integer value) { + return this.writeSparse(b, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java index 9e61cd0..d15edf5 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java @@ -4,16 +4,18 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.google.common.base.Preconditions.checkArgument; public final class LayoutInt64 extends LayoutType { + public LayoutInt64() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_64, (Long.SIZE / Byte.SIZE)); + super(LayoutCode.INT_64, Long.BYTES / Byte.SIZE); } public boolean isFixed() { @@ -25,61 +27,66 @@ public final class LayoutInt64 extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { - value.setAndGet(0); + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set(0L); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadInt64(scope.get().start() + column.getOffset())); + value.set(buffer.readInt64(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { - value.setAndGet(0); + value.set(0L); return result; } - value.setAndGet(b.get().ReadSparseInt64(edit)); + value.set(buffer.readSparseInt64(edit)); return Result.SUCCESS; } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - long value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Long value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().writeInt64(scope.get().start() + col.getOffset(), value); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.writeInt64(scope.start() + column.offset(), value); + buffer.setBit(scope.start(), column.nullBit()); + return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, long value, - // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, long value, - UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Long value, UpdateOptions options) { + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg(), options); if (result != Result.SUCCESS) { return result; } - b.get().writeSparseInt64(edit, value, options); + buffer.writeSparseInt64(edit, value, options); return Result.SUCCESS; } @Override - public Result WriteSparse(Reference b, Reference edit, long value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer b, RowCursor edit, Long value) { + return this.writeSparse(b, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java index 76b92ea..52be45b 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java @@ -4,16 +4,18 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.google.common.base.Preconditions.checkArgument; public final class LayoutInt8 extends LayoutType { + public LayoutInt8() { - super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_8, (Byte.SIZE / Byte.SIZE)); + super(LayoutCode.INT_8, Byte.BYTES); } public boolean isFixed() { @@ -25,61 +27,67 @@ public final class LayoutInt8 extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { - value.setAndGet(0); + @Nonnull + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (!buffer.readBit(scope.start(), column.nullBit())) { + value.set((byte) 0); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadInt8(scope.get().start() + column.getOffset())); + value.set(buffer.readInt8(scope.start() + column.offset())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, - Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + @Nonnull + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); + if (result != Result.SUCCESS) { - value.setAndGet(0); + value.set((byte) 0); return result; } - value.setAndGet(b.get().ReadSparseInt8(edit)); + value.set(buffer.readSparseInt8(edit)); return Result.SUCCESS; } @Override - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - byte value) { - checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (scope.get().immutable()) { + @Nonnull + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Byte value) { + + checkArgument(scope.scopeType() instanceof LayoutUDT); + + if (scope.immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().writeInt8(scope.get().start() + col.getOffset(), value); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.writeInt8(scope.start() + column.offset(), value); + buffer.setBit(scope.start(), column.nullBit()); return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, sbyte value, - // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteSparse(Reference b, Reference edit, byte value, - UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Byte value, UpdateOptions options) { + + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg(), options); + if (result != Result.SUCCESS) { return result; } - b.get().writeSparseInt8(edit, value, options); + buffer.writeSparseInt8(edit, value, options); return Result.SUCCESS; } @Override - public Result WriteSparse(Reference b, Reference edit, byte value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + @Nonnull + public Result writeSparse(RowBuffer buffer, RowCursor edit, Byte value) { + return this.writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java index ccca46b..129190b 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java @@ -25,41 +25,41 @@ public final class LayoutMongoDbObjectId extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + if (!buffer.get().readBit(scope.get().start(), column.getNullBit().clone())) { value.setAndGet(null); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadMongoDbObjectId(scope.get().start() + column.getOffset()).clone()); + value.setAndGet(buffer.get().ReadMongoDbObjectId(scope.get().start() + column.getOffset()).clone()); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + Result result = LayoutType.prepareSparseRead(buffer, edit, this.LayoutCode); if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - value.setAndGet(b.get().ReadSparseMongoDbObjectId(edit).clone()); + value.setAndGet(buffer.get().ReadSparseMongoDbObjectId(edit).clone()); return Result.SUCCESS; } @Override - public Result writeFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, MongoDbObjectId value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); if (scope.get().immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().WriteMongoDbObjectId(scope.get().start() + column.getOffset(), value.clone()); - b.get().SetBit(scope.get().start(), column.getNullBit().clone()); + buffer.get().WriteMongoDbObjectId(scope.get().start() + column.getOffset(), value.clone()); + buffer.get().SetBit(scope.get().start(), column.getNullBit().clone()); return Result.SUCCESS; } @@ -67,20 +67,20 @@ public final class LayoutMongoDbObjectId extends LayoutType { //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, MongoDbObjectId value, // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeSparse(RowBuffer b, RowCursor edit, + public Result writeSparse(RowBuffer buffer, RowCursor edit, MongoDbObjectId value, UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg().clone(), options); if (result != Result.SUCCESS) { return result; } - b.get().WriteSparseMongoDbObjectId(edit, value.clone(), options); + buffer.get().WriteSparseMongoDbObjectId(edit, value.clone(), options); return Result.SUCCESS; } @Override - public Result writeSparse(RowBuffer b, RowCursor edit, + public Result writeSparse(RowBuffer buffer, RowCursor edit, MongoDbObjectId value) { - return writeSparse(b, edit, value, UpdateOptions.Upsert); + return writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java index 29c656d..e9585a9 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java @@ -29,11 +29,11 @@ public final class LayoutNull extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); value.setAndGet(NullValue.Default); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + if (!buffer.get().readBit(scope.get().start(), column.getNullBit().clone())) { return Result.NOT_FOUND; } @@ -41,27 +41,27 @@ public final class LayoutNull extends LayoutType { } @Override - public Result readSparse(RowBuffer b, RowCursor edit, + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(buffer, edit, this.LayoutCode); if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - value.setAndGet(b.get().readSparseNull(edit).clone()); + value.setAndGet(buffer.get().readSparseNull(edit).clone()); return Result.SUCCESS; } @Override - public Result writeFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, NullValue value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); if (scope.get().immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().SetBit(scope.get().start(), column.getNullBit().clone()); + buffer.get().SetBit(scope.get().start(), column.getNullBit().clone()); return Result.SUCCESS; } @@ -69,19 +69,19 @@ public final class LayoutNull extends LayoutType { //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, NullValue value, // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeSparse(RowBuffer b, RowCursor edit, NullValue value, + public Result writeSparse(RowBuffer buffer, RowCursor edit, NullValue value, UpdateOptions options) { - Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); + Result result = prepareSparseWrite(buffer, edit, this.typeArg().clone(), options); if (result != Result.SUCCESS) { return result; } - b.get().WriteSparseNull(edit, value.clone(), options); + buffer.get().WriteSparseNull(edit, value.clone(), options); return Result.SUCCESS; } @Override - public Result writeSparse(RowBuffer b, RowCursor edit, NullValue value) { - return writeSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(RowBuffer buffer, RowCursor edit, NullValue value) { + return writeSparse(buffer, edit, value, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java index bf0c37b..7919f00 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java @@ -37,7 +37,7 @@ public final class LayoutNullable extends LayoutIndexedScope { checkArgument(edit.index() >= 0); checkArgument(edit.scopeTypeArgs().count() == 1); checkArgument(edit.index() == 1); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.scopeTypeArgs().get(0).type().layoutCode()); + return !LayoutCodeTraits.alwaysRequiresTypeCode(edit.scopeTypeArgs().get(0).type().layoutCode()); } public static Result hasValue(@Nonnull final RowBuffer b, @Nonnull final RowCursor scope) { @@ -85,18 +85,18 @@ public final class LayoutNullable extends LayoutIndexedScope { } @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + return writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { - return this.WriteScope(b, edit, typeArgs.clone(), true, value, options); + return this.WriteScope(buffer, edit, typeArgs.clone(), true, value, options); } @Override diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java index 4e9b2e4..8528e21 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java @@ -27,24 +27,24 @@ public final class LayoutObject extends LayoutPropertyScope { @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + return writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg().clone(), options); if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - b.get().WriteSparseObject(edit, this, options, value.clone()); + buffer.get().WriteSparseObject(edit, this, options, value.clone()); return Result.SUCCESS; } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutPropertyScope.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutPropertyScope.java index 543e95a..497429e 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutPropertyScope.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutPropertyScope.java @@ -5,9 +5,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; public abstract class LayoutPropertyScope extends LayoutScope { protected LayoutPropertyScope(LayoutCode code, boolean immutable) { - // TODO: C# TO JAVA CONVERTER: C# to Java Converter could not resolve the named parameters in the - // following line: - // base(code, immutable, isSizedScope: false, isIndexedScope: false, isFixedArity: false, isUniqueScope: false, isTypedScope: false); super(code, immutable, false, false, false, false, false); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java index 7825d67..3a4adcc 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java @@ -11,12 +11,10 @@ import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Strings.lenientFormat; /** - * An implementation of {@link LayoutResolver} which dynamically compiles schema from - * a {@link Namespace}. + * An implementation of {@link LayoutResolver} which dynamically compiles schema from a {@link Namespace}. *

- *

- * This resolver assumes that {@link Schema} within the {@link Namespace} have - * their {@link Schema.SchemaId} properly populated. The resolver caches compiled schema. + * This resolver assumes that {@link Schema} within the {@link Namespace} have their {@link Schema#schemaId()} properly + * populated. The resolver caches compiled schema. *

* All members of this class are multi-thread safe. */ @@ -30,8 +28,6 @@ public final class LayoutResolverNamespace extends LayoutResolver { this(schemaNamespace, null); } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public LayoutResolverNamespace(Namespace schemaNamespace, LayoutResolver parent = default) public LayoutResolverNamespace(Namespace schemaNamespace, LayoutResolver parent) { this.schemaNamespace = schemaNamespace; this.parent = parent; diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverSimple.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverSimple.java index d91cb7c..cd44bf3 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverSimple.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverSimple.java @@ -6,6 +6,7 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.serialization.hybridrow.SchemaId; public final class LayoutResolverSimple extends LayoutResolver { + private tangible.Func1Param resolver; public LayoutResolverSimple(tangible.Func1Param resolver) { @@ -14,6 +15,6 @@ public final class LayoutResolverSimple extends LayoutResolver { @Override public Layout resolve(SchemaId schemaId) { - return this.resolver.invoke(schemaId.clone()); + return this.resolver.invoke(schemaId); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java index 357f551..9766c98 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java @@ -10,6 +10,7 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursor; import com.azure.data.cosmos.serialization.hybridrow.RowCursors; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; @@ -22,8 +23,13 @@ public abstract class LayoutScope extends LayoutType { private final boolean isUniqueScope; protected LayoutScope( - @Nonnull final LayoutCode code, final boolean immutable, final boolean isSizedScope, - final boolean isIndexedScope, final boolean isFixedArity, final boolean isUniqueScope, boolean isTypedScope) { + @Nonnull final LayoutCode code, + final boolean immutable, + final boolean isSizedScope, + final boolean isIndexedScope, + final boolean isFixedArity, + final boolean isUniqueScope, + final boolean isTypedScope) { super(code, immutable, 0); this.isSizedScope = isSizedScope; @@ -33,6 +39,16 @@ public abstract class LayoutScope extends LayoutType { this.isTypedScope = isTypedScope; } + /** + * Returns {@code false} to indicate that a {@link LayoutScope} is a variable length, not fixed length layout type + * + * @return {@code false} + */ + @Override + public boolean isFixed() { + return false; + } + /** * Returns true if this is a fixed arity scope. */ @@ -68,18 +84,19 @@ public abstract class LayoutScope extends LayoutType { return this.isUniqueScope; } - public final Result deleteScope(@Nonnull final RowBuffer b, @Nonnull final RowCursor edit) { + @Nonnull + public final Result deleteScope(@Nonnull final RowBuffer buffer, @Nonnull final RowCursor edit) { - checkNotNull(b); - checkNotNull(edit); + checkNotNull(buffer, "expected non-null buffer"); + checkNotNull(edit, "expected non-null edit"); - Result result = LayoutType.prepareSparseDelete(b, edit, this.layoutCode()); + Result result = LayoutType.prepareSparseDelete(buffer, edit, this.layoutCode()); if (result != Result.SUCCESS) { return result; } - b.deleteSparse(edit); + buffer.deleteSparse(edit); return Result.SUCCESS; } @@ -97,21 +114,21 @@ public abstract class LayoutScope extends LayoutType { @Nonnull public final Result readScope( - @Nonnull final RowBuffer b, @Nonnull final RowCursor edit, @Nonnull final Out value) { + @Nonnull final RowBuffer buffer, @Nonnull final RowCursor edit, @Nonnull final Out value) { - checkNotNull(b); - checkNotNull(edit); - checkNotNull(value); + checkNotNull(buffer, "expected non-null buffer"); + checkNotNull(edit, "expected non-null edit"); + checkNotNull(value, "expected non-null value"); - Result result = LayoutType.prepareSparseRead(b, edit, this.layoutCode()); + Result result = LayoutType.prepareSparseRead(buffer, edit, this.layoutCode()); if (result != Result.SUCCESS) { - value.setAndGet(null); + value.set(null); return result; } boolean immutable = this.isImmutable() || edit.immutable() || edit.scopeType().isUniqueScope(); - value.set(b.sparseIteratorReadScope(edit, immutable)); + value.set(buffer.sparseIteratorReadScope(edit, immutable)); return Result.SUCCESS; } @@ -127,37 +144,39 @@ public abstract class LayoutScope extends LayoutType { throw new UnsupportedOperationException(); } + @Nonnull public abstract Result writeScope( - RowBuffer b, + RowBuffer buffer, RowCursor scope, TypeArgumentList typeArgs, Out value); + @Nonnull public abstract Result writeScope( - RowBuffer b, + RowBuffer buffer, RowCursor scope, TypeArgumentList typeArgs, UpdateOptions options, Out value); + @Nonnull public Result writeScope( - RowBuffer b, + RowBuffer buffer, RowCursor scope, TypeArgumentList typeArgs, TContext context, WriterFunc func) { - return this.writeScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert); + return this.writeScope(buffer, scope, typeArgs, context, func, UpdateOptions.Upsert); } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public virtual Result WriteScope(ref RowBuffer b, ref RowCursor scope, - // TypeArgumentList typeArgs, TContext context, WriterFunc func, UpdateOptions options = UpdateOptions - // .Upsert) + @Nonnull public Result writeScope( - RowBuffer b, - RowCursor scope, - TypeArgumentList typeArgs, - TContext context, WriterFunc func, UpdateOptions options) { + @Nonnull final RowBuffer buffer, + @Nonnull final RowCursor scope, + @Nonnull final TypeArgumentList typeArgs, + @Nullable TContext context, + @Nullable WriterFunc func, + @Nonnull UpdateOptions options) { final Out out = new Out<>(); - Result result = this.writeScope(b, scope, typeArgs, options, out); + Result result = this.writeScope(buffer, scope, typeArgs, options, out); if (result != Result.SUCCESS) { return result; @@ -166,28 +185,33 @@ public abstract class LayoutScope extends LayoutType { final RowCursor childScope = out.get(); if (func != null) { - result = func.invoke(b, childScope, context); + result = func.invoke(buffer, childScope, context); if (result != Result.SUCCESS) { - this.deleteScope(b, scope); + this.deleteScope(buffer, scope); return result; } } - RowCursors.skip(scope, b, childScope); + RowCursors.skip(scope, buffer, childScope); return Result.SUCCESS; } /** - * A function to write content into a {@link RowBuffer}. - * The type of the context value passed by the caller. + * A functional interfaced that can be used to write content to a {@link RowBuffer} * - * @param b The row to write to. - * @param scope The type of the scope to write into. - * @param context A context value provided by the caller. - * @return The result. + * @param The type of the context value passed by the caller */ @FunctionalInterface public interface WriterFunc { - @Nonnull Result invoke(RowBuffer b, RowCursor scope, TContext context); + /** + * Writes content to a {@link RowBuffer} + * + * @param buffer The row to write to + * @param scope The type of the scope to write into + * @param context A context value provided by the caller + * @return The result + */ + @Nonnull + Result invoke(@Nonnull final RowBuffer buffer, @Nonnull final RowCursor scope, @Nullable TContext context); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java index e8a3d33..31315dd 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java @@ -9,8 +9,11 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TAGGED_SCOPE; import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TAGGED_SCOPE; +import static com.google.common.base.Preconditions.checkArgument; public final class LayoutTagged extends LayoutIndexedScope { public LayoutTagged(boolean immutable) { @@ -18,65 +21,63 @@ public final class LayoutTagged extends LayoutIndexedScope { } public String name() { - return this.Immutable ? "im_tagged_t" : "tagged_t"; + return this.isImmutable() ? "im_tagged_t" : "tagged_t"; } public int countTypeArgument(TypeArgumentList value) { - checkState(value.count() == 2); - return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(1).type().CountTypeArgument(value.get(1).typeArgs().clone()); + checkArgument(value.count() == 2); + return LayoutCode.BYTES + value.get(1).type().countTypeArgument(value.get(1).typeArgs()); } @Override - public boolean HasImplicitTypeCode(Reference edit) { - checkArgument(edit.get().index() >= 0); - checkArgument(edit.get().scopeTypeArgs().count() > edit.get().index()); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode); + public boolean hasImplicitTypeCode(RowCursor edit) { + checkArgument(edit.index() >= 0); + checkArgument(edit.scopeTypeArgs().count() > edit.index()); + return !LayoutCodeTraits.alwaysRequiresTypeCode(edit.scopeTypeArgs().get(edit.index()).type().layoutCode()); } @Override - public TypeArgumentList readTypeArgumentList(Reference row, int offset, - Out lenInBytes) { - TypeArgument[] retval = new TypeArgument[2]; - retval[0] = new TypeArgument(UInt8, TypeArgumentList.EMPTY); - retval[1] = readTypeArgument(row, offset, lenInBytes); - return new TypeArgumentList(retval); + public TypeArgumentList readTypeArgumentList(RowBuffer buffer, int offset, Out lenInBytes) { + TypeArgument[] typeArgs = new TypeArgument[2]; + typeArgs[0] = new TypeArgument(LayoutTypes.UINT_8, TypeArgumentList.EMPTY); + typeArgs[1] = readTypeArgument(buffer, offset, lenInBytes); + return new TypeArgumentList(typeArgs); } @Override public void setImplicitTypeCode(RowCursor edit) { - edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type(); - edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone(); + edit.cellType(edit.scopeTypeArgs().get(edit.index()).type()); + edit.cellTypeArgs(edit.scopeTypeArgs().get(edit.index()).typeArgs()); } @Override - public Result writeScope(RowBuffer b, RowCursor edit, - TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + @Nonnull + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { + return this.writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList - // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, - TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + @Nonnull + public Result writeScope( + RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { + + Result result = prepareSparseWrite(buffer, edit, new TypeArgument(this, typeArgs), options); + if (result != Result.SUCCESS) { - value.setAndGet(null); + value.set(null); return result; } - b.get().WriteTypedTuple(edit, this, typeArgs.clone(), options, value.clone()); + value.set(buffer.writeTypedTuple(edit, this, typeArgs, options)); return Result.SUCCESS; } @Override - public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { + public int writeTypeArgument(RowBuffer row, int offset, TypeArgumentList value) { checkArgument(value.count() == 2); - row.get().writeSparseTypeCode(offset, this.LayoutCode); - int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); - lenInBytes += value.get(1).type().writeTypeArgument(row, offset + lenInBytes, - value.get(1).typeArgs().clone()); + row.writeSparseTypeCode(offset, this.layoutCode()); + int lenInBytes = LayoutCode.BYTES; + lenInBytes += value.get(1).type().writeTypeArgument(row, offset + lenInBytes, value.get(1).typeArgs()); return lenInBytes; } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java index 9dc898d..5e1cfb3 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java @@ -4,52 +4,57 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; -public final class LayoutTagged2 extends LayoutIndexedScope { - public LayoutTagged2(boolean immutable) { - super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TAGGED2_SCOPE : - com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TAGGED2_SCOPE, immutable, isSizedScope(): - true, isFixedArity():true, isUniqueScope():false, isTypedScope():true) - } +import javax.annotation.Nonnull; - public String name() { - return this.Immutable ? "im_tagged2_t" : "tagged2_t"; +import static com.google.common.base.Preconditions.checkState; + +public final class LayoutTagged2 extends LayoutIndexedScope { + + public LayoutTagged2(boolean immutable) { + super( + immutable ? LayoutCode.IMMUTABLE_TAGGED2_SCOPE : LayoutCode.TAGGED2_SCOPE, + immutable, true, true, false, true + ); } public int countTypeArgument(TypeArgumentList value) { checkState(value.count() == 3); - int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); + int lenInBytes = LayoutCode.BYTES; for (int i = 1; i < value.count(); i++) { - TypeArgument arg = value.get(i).clone(); - lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone()); + TypeArgument arg = value.get(i); + lenInBytes += arg.type().countTypeArgument(arg.typeArgs()); } return lenInBytes; } @Override - public boolean HasImplicitTypeCode(Reference edit) { - checkState(edit.get().index() >= 0); - checkState(edit.get().scopeTypeArgs().count() > edit.get().index()); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode); + public boolean hasImplicitTypeCode(RowCursor edit) { + checkState(edit.index() >= 0); + checkState(edit.scopeTypeArgs().count() > edit.index()); + return !LayoutCodeTraits.alwaysRequiresTypeCode(edit.scopeTypeArgs().get(edit.index()).type().layoutCode()); + } + + public String name() { + return this.isImmutable() ? "im_tagged2_t" : "tagged2_t"; } @Override - public TypeArgumentList readTypeArgumentList(Reference row, int offset, - Out lenInBytes) { - lenInBytes.setAndGet(0); + @Nonnull + public TypeArgumentList readTypeArgumentList(RowBuffer buffer, int offset, Out lenInBytes) { + lenInBytes.set(0); TypeArgument[] retval = new TypeArgument[3]; - retval[0] = new TypeArgument(UInt8, TypeArgumentList.EMPTY); + retval[0] = new TypeArgument(LayoutTypes.UINT_8, TypeArgumentList.EMPTY); for (int i = 1; i < 3; i++) { int itemLenInBytes; Out tempOut_itemLenInBytes = new Out(); - retval[i] = readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); + retval[i] = readTypeArgument(buffer, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); - lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); + lenInBytes.set(lenInBytes.get() + itemLenInBytes); } return new TypeArgumentList(retval); @@ -57,40 +62,44 @@ public final class LayoutTagged2 extends LayoutIndexedScope { @Override public void setImplicitTypeCode(RowCursor edit) { - edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type(); - edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone(); + edit.cellType(edit.scopeTypeArgs().get(edit.index()).type()); + edit.cellTypeArgs(edit.scopeTypeArgs().get(edit.index()).typeArgs()); } @Override - public Result writeScope(RowBuffer b, RowCursor edit, - TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + @Nonnull + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { + return this.writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList - // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, - TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + @Nonnull + @Nonnull + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, + Out value) { + + Result result = prepareSparseWrite(buffer, edit, new TypeArgument(this, typeArgs), options); + if (result != Result.SUCCESS) { - value.setAndGet(null); + value.set(null); return result; } - b.get().WriteTypedTuple(edit, this, typeArgs.clone(), options, value.clone()); + value.set(buffer.writeTypedTuple(edit, this, typeArgs, options)); return Result.SUCCESS; } @Override - public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { + public int writeTypeArgument(RowBuffer row, int offset, TypeArgumentList value) { + checkState(value.count() == 3); - row.get().writeSparseTypeCode(offset, this.LayoutCode); - int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); + + row.writeSparseTypeCode(offset, this.layoutCode()); + int lenInBytes = LayoutCode.BYTES; + for (int i = 1; i < value.count(); i++) { - TypeArgument arg = value.get(i).clone(); - lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone()); + TypeArgument arg = value.get(i); + lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs()); } return lenInBytes; diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java index a5ecf64..d26f2c0 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java @@ -13,73 +13,76 @@ import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.I import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TUPLE_SCOPE; public final class LayoutTuple extends LayoutIndexedScope { + public LayoutTuple(boolean immutable) { - super(immutable ? IMMUTABLE_TUPLE_SCOPE : TUPLE_SCOPE, immutable, false, true, false, false); + super( + immutable ? IMMUTABLE_TUPLE_SCOPE : TUPLE_SCOPE, + immutable, false, true, false, false + ); } public String name() { - return this.Immutable ? "im_tuple" : "tuple"; + return this.isImmutable() ? "im_tuple" : "tuple"; } public int countTypeArgument(TypeArgumentList value) { - int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); + int lenInBytes = LayoutCode.BYTES; //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count); lenInBytes += RowBuffer.count7BitEncodedUInt(value.count()); for (TypeArgument arg : value) { - lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone()); + lenInBytes += arg.type().countTypeArgument(arg.typeArgs()); } return lenInBytes; } @Override - public TypeArgumentList readTypeArgumentList(Reference row, int offset, - Out lenInBytes) { - int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes); + public TypeArgumentList readTypeArgumentList(RowBuffer buffer, int offset, Out lenInBytes) { + int numTypeArgs = buffer.intValue().Read7BitEncodedUInt(offset, lenInBytes); TypeArgument[] retval = new TypeArgument[numTypeArgs]; for (int i = 0; i < numTypeArgs; i++) { int itemLenInBytes; Out tempOut_itemLenInBytes = new Out(); - retval[i] = readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); + retval[i] = readTypeArgument(buffer, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); - lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); + lenInBytes.set(lenInBytes.get() + itemLenInBytes); } return new TypeArgumentList(retval); } @Override - public Result writeScope(RowBuffer b, RowCursor edit, - TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { + return writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, - TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { + + Result result = prepareSparseWrite(buffer, edit, new TypeArgument(this, typeArgs), options); + if (result != Result.SUCCESS) { - value.setAndGet(null); + value.set(null); return result; } - b.get().WriteSparseTuple(edit, this, typeArgs.clone(), options, value.clone()); + value.set(buffer.writeSparseTuple(edit, this, typeArgs, options)); return Result.SUCCESS; } @Override - public int writeTypeArgument(Reference row, int offset, TypeArgumentList value) { - row.get().writeSparseTypeCode(offset, this.LayoutCode); - int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); + public int writeTypeArgument(RowBuffer buffer, int offset, TypeArgumentList value) { + buffer.writeSparseTypeCode(offset, this.layoutCode()); + int lenInBytes = LayoutCode.BYTES; //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: lenInBytes += row.Write7BitEncodedUInt(offset + lenInBytes, (ulong)value.Count); - lenInBytes += row.get().write7BitEncodedUInt(offset + lenInBytes, value.count()); + //ORIGINAL LINE: lenInBytes += buffer.Write7BitEncodedUInt(offset + lenInBytes, (ulong)value.Count); + lenInBytes += buffer.write7BitEncodedUInt(offset + lenInBytes, (long) value.count()); for (TypeArgument arg : value) { - lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone()); + lenInBytes += arg.type().writeTypeArgument(buffer, offset + lenInBytes, arg.typeArgs()); } return lenInBytes; diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java index 0f8d735..55bb2d4 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java @@ -4,7 +4,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; @@ -199,7 +198,7 @@ public abstract class LayoutType implements ILayoutType { return Result.INSUFFICIENT_PERMISSIONS; } - if (edit.exists() && LayoutCodeTraits.Canonicalize(edit.cellType().layoutCode()) != code) { + if (edit.exists() && LayoutCodeTraits.canonicalize(edit.cellType().layoutCode()) != code) { return Result.TYPE_MISMATCH; } @@ -209,7 +208,7 @@ public abstract class LayoutType implements ILayoutType { /** * Helper for preparing the move of a sparse field into an existing restricted edit. * - * @param b The row to read from. + * @param buffer The row to read from. * @param destinationScope The parent set edit into which the field should be moved. * @param destinationCode The expected type of the edit moving within. * @param elementType The expected type of the elements within the edit. @@ -219,8 +218,9 @@ public abstract class LayoutType implements ILayoutType { * @return Success if the move is permitted, the error code otherwise. * The source field is delete if the move prepare fails with a destination error. */ + @Nonnull public static Result prepareSparseMove( - RowBuffer b, + RowBuffer buffer, RowCursor destinationScope, LayoutScope destinationCode, TypeArgument elementType, @@ -232,7 +232,7 @@ public abstract class LayoutType implements ILayoutType { checkArgument(destinationScope.index() == 0, "Can only insert into a edit at the root"); // Prepare the delete of the source - Result result = LayoutType.prepareSparseDelete(b, srcEdit, elementType.type().layoutCode()); + Result result = LayoutType.prepareSparseDelete(buffer, srcEdit, elementType.type().layoutCode()); if (result != Result.SUCCESS) { dstEdit.setAndGet(null); @@ -245,33 +245,33 @@ public abstract class LayoutType implements ILayoutType { } if (destinationScope.immutable()) { - b.deleteSparse(srcEdit); + buffer.deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.INSUFFICIENT_PERMISSIONS; } if (!srcEdit.cellTypeArgs().equals(elementType.typeArgs())) { - b.deleteSparse(srcEdit); + buffer.deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.TYPE_CONSTRAINT; } if (options == UpdateOptions.InsertAt) { - b.deleteSparse(srcEdit); + buffer.deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.TYPE_CONSTRAINT; } // Prepare the insertion at the destination. - dstEdit.setAndGet(b.prepareSparseMove(destinationScope, srcEdit)); + dstEdit.setAndGet(buffer.prepareSparseMove(destinationScope, srcEdit)); if ((options == UpdateOptions.Update) && (!dstEdit.get().exists())) { - b.deleteSparse(srcEdit); + buffer.deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.NOT_FOUND; } if ((options == UpdateOptions.Insert) && dstEdit.get().exists()) { - b.deleteSparse(srcEdit); + buffer.deleteSparse(srcEdit); dstEdit.setAndGet(null); return Result.EXISTS; } @@ -282,19 +282,20 @@ public abstract class LayoutType implements ILayoutType { /** * Helper for preparing the read of a sparse field. * - * @param b The row to read from. + * @param buffer The row to read from. * @param edit The parent edit containing the field to read. * @param code The expected type of the field. * @return Success if the read is permitted, the error code otherwise. */ + @Nonnull public static Result prepareSparseRead( - @Nonnull final RowBuffer b, @Nonnull final RowCursor edit, @Nonnull LayoutCode code) { + @Nonnull final RowBuffer buffer, @Nonnull final RowCursor edit, @Nonnull LayoutCode code) { if (!edit.exists()) { return Result.NOT_FOUND; } - if (LayoutCodeTraits.Canonicalize(edit.cellType().layoutCode()) != code) { + if (LayoutCodeTraits.canonicalize(edit.cellType().layoutCode()) != code) { return Result.TYPE_MISMATCH; } @@ -304,14 +305,15 @@ public abstract class LayoutType implements ILayoutType { /** * Helper for preparing the write of a sparse field. * - * @param b The row to write to. + * @param buffer The row to write to. * @param edit The cursor for the field to write. * @param typeArg The (optional) type constraints. * @param options The write options. * @return Success if the write is permitted, the error code otherwise. */ + @Nonnull public static Result prepareSparseWrite( - @Nonnull final RowBuffer b, + @Nonnull final RowBuffer buffer, @Nonnull final RowCursor edit, @Nonnull final TypeArgument typeArg, @Nonnull final UpdateOptions options) { @@ -351,9 +353,11 @@ public abstract class LayoutType implements ILayoutType { return Result.SUCCESS; } - public abstract Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, Out value); + @Nonnull + public abstract Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value); - public abstract Result readSparse(RowBuffer b, RowCursor edit, Out value); + @Nonnull + public abstract Result readSparse(RowBuffer buffer, RowCursor edit, Out value); public static TypeArgument readTypeArgument(RowBuffer row, int offset, Out lenInBytes) { LayoutType itemCode = row.readSparseTypeCode(offset); @@ -370,8 +374,9 @@ public abstract class LayoutType implements ILayoutType { return TypeArgumentList.EMPTY; } - public Result readVariable(RowBuffer b, RowCursor scope, LayoutColumn column, Out value) { - value.setAndGet(null); + @Nonnull + public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { + value.set(null); return Result.FAILURE; } @@ -390,18 +395,22 @@ public abstract class LayoutType implements ILayoutType { return (Value)this; } - public abstract Result writeFixed(RowBuffer b, RowCursor scope, LayoutColumn column, T value); + @Nonnull + public abstract Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, T value); - public abstract Result writeSparse(RowBuffer b, RowCursor edit, T value); + @Nonnull + public abstract Result writeSparse(RowBuffer buffer, RowCursor edit, T value); - public abstract Result writeSparse(RowBuffer b, RowCursor edit, T value, UpdateOptions options); + @Nonnull + public abstract Result writeSparse(RowBuffer buffer, RowCursor edit, T value, UpdateOptions options); public int writeTypeArgument(RowBuffer row, int offset, TypeArgumentList value) { row.writeSparseTypeCode(offset, this.layoutCode()); return LayoutCode.BYTES; } - public Result writeVariable(Reference b, Reference scope, LayoutColumn col, T value) { + @Nonnull + public Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, T value) { return Result.FAILURE; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java index 8d7a8f8..e26b773 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java @@ -28,7 +28,7 @@ public final class LayoutTypedArray extends LayoutIndexedScope { public boolean HasImplicitTypeCode(Reference edit) { checkState(edit.get().index() >= 0); checkState(edit.get().scopeTypeArgs().count() == 1); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode); + return !LayoutCodeTraits.alwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode); } @Override @@ -44,24 +44,24 @@ public final class LayoutTypedArray extends LayoutIndexedScope { } @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + return writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = LayoutType.prepareSparseWrite(buffer, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - b.get().WriteTypedArray(edit, this, typeArgs.clone(), options, value.clone()); + buffer.get().WriteTypedArray(edit, this, typeArgs.clone(), options, value.clone()); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java index 776a59d..74826fd 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java @@ -31,7 +31,7 @@ public final class LayoutTypedMap extends LayoutUniqueScope { } @Override - public TypeArgument FieldType(Reference scope) { + public TypeArgument fieldType(RowCursor scope) { return new TypeArgument(scope.get().scopeType().Immutable ? ImmutableTypedTuple : TypedTuple, scope.get().scopeTypeArgs().clone()); } @@ -65,24 +65,24 @@ public final class LayoutTypedMap extends LayoutUniqueScope { } @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + return writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = prepareSparseWrite(buffer, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - b.get().WriteTypedMap(edit, this, typeArgs.clone(), options, value.clone()); + buffer.get().WriteTypedMap(edit, this, typeArgs.clone(), options, value.clone()); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java index 94c036b..bdb67ca 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java @@ -27,7 +27,7 @@ public final class LayoutTypedSet extends LayoutUniqueScope { } @Override - public TypeArgument FieldType(Reference scope) { + public TypeArgument fieldType(RowCursor scope) { return scope.get().scopeTypeArgs().get(0).clone(); } @@ -35,7 +35,7 @@ public final class LayoutTypedSet extends LayoutUniqueScope { public boolean HasImplicitTypeCode(Reference edit) { checkState(edit.get().index() >= 0); checkState(edit.get().scopeTypeArgs().count() == 1); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode); + return !LayoutCodeTraits.alwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode); } @Override @@ -51,24 +51,24 @@ public final class LayoutTypedSet extends LayoutUniqueScope { } @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + return writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = prepareSparseWrite(buffer, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - b.get().WriteTypedSet(edit, this, typeArgs.clone(), options, value.clone()); + buffer.get().WriteTypedSet(edit, this, typeArgs.clone(), options, value.clone()); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java index 0bf72ab..5b66f18 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java @@ -37,7 +37,7 @@ public final class LayoutTypedTuple extends LayoutIndexedScope { public boolean HasImplicitTypeCode(Reference edit) { checkArgument(edit.get().index() >= 0); checkArgument(edit.get().scopeTypeArgs().count() > edit.get().index()); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode); + return !LayoutCodeTraits.alwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode); } @Override @@ -63,24 +63,24 @@ public final class LayoutTypedTuple extends LayoutIndexedScope { } @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + return writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Result result = LayoutType.prepareSparseWrite(buffer, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - b.get().WriteTypedTuple(edit, this, typeArgs.clone(), options, value.clone()); + buffer.get().WriteTypedTuple(edit, this, typeArgs.clone(), options, value.clone()); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java index 5388706..2a9dd32 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java @@ -18,17 +18,17 @@ public abstract class LayoutTypes { public static final LayoutFloat32 FLOAT_32 = new LayoutFloat32(); public static final LayoutFloat64 FLOAT_64 = new LayoutFloat64(); public static final LayoutGuid GUID = new LayoutGuid(); - public static final LayoutArray ImmutableArray = new LayoutArray(true); - public static final LayoutNullable ImmutableNullable = new LayoutNullable(true); - public static final LayoutObject ImmutableObject = new LayoutObject(true); - public static final LayoutTagged ImmutableTagged = new LayoutTagged(true); - public static final LayoutTagged2 ImmutableTagged2 = new LayoutTagged2(true); + public static final LayoutArray IMMUTABLE_ARRAY = new LayoutArray(true); + public static final LayoutNullable IMMUTABLE_NULLABLE = new LayoutNullable(true); + public static final LayoutObject IMMUTABLE_OBJECT = new LayoutObject(true); + public static final LayoutTagged IMMUTABLE_TAGGED = new LayoutTagged(true); + public static final LayoutTagged2 IMMUTABLE_TAGGED_2 = new LayoutTagged2(true); public static final LayoutTuple ImmutableTuple = new LayoutTuple(true); - public static final LayoutTypedArray ImmutableTypedArray = new LayoutTypedArray(true); - public static final LayoutTypedMap ImmutableTypedMap = new LayoutTypedMap(true); - public static final LayoutTypedSet ImmutableTypedSet = new LayoutTypedSet(true); - public static final LayoutTypedTuple ImmutableTypedTuple = new LayoutTypedTuple(true); - public static final LayoutUDT ImmutableUDT = new LayoutUDT(true); + public static final LayoutTypedArray IMMUTABLE_TYPED_ARRAY = new LayoutTypedArray(true); + public static final LayoutTypedMap IMMUTABLE_TYPED_MAP = new LayoutTypedMap(true); + public static final LayoutTypedSet IMMUTABLE_TYPED_SET = new LayoutTypedSet(true); + public static final LayoutTypedTuple IMMUTABLE_TYPED_TUPLE = new LayoutTypedTuple(true); + public static final LayoutUDT IMMUTABLE_UDT = new LayoutUDT(true); public static final LayoutInt16 INT_16 = new LayoutInt16(); public static final LayoutInt32 INT_32 = new LayoutInt32(); public static final LayoutInt64 INT_64 = new LayoutInt64(); @@ -41,8 +41,8 @@ public abstract class LayoutTypes { public static final LayoutTagged2 TAGGED_2 = new LayoutTagged2(false); public static final LayoutTuple TUPLE = new LayoutTuple(false); public static final LayoutTypedArray TYPED_ARRAY = new LayoutTypedArray(false); - public static final LayoutTypedMap TypedMap = new LayoutTypedMap(false); - public static final LayoutTypedSet TypedSet = new LayoutTypedSet(false); + public static final LayoutTypedMap TYPED_MAP = new LayoutTypedMap(false); + public static final LayoutTypedSet TYPED_SET = new LayoutTypedSet(false); public static final LayoutTypedTuple TYPED_TUPLE = new LayoutTypedTuple(false); public static final LayoutUDT UDT = new LayoutUDT(false); public static final LayoutUInt16 UINT_16 = new LayoutUInt16(); diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java index 5d7fea3..1cd2e6b 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java @@ -33,25 +33,25 @@ public final class LayoutUDT extends LayoutPropertyScope { } @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); + return writeScope(buffer, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor edit, + public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out value) { - Layout udt = b.get().resolver().resolve(typeArgs.schemaId().clone()); - Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); + Layout udt = buffer.get().resolver().resolve(typeArgs.schemaId().clone()); + Result result = prepareSparseWrite(buffer, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - b.get().WriteSparseUDT(edit, this, udt, options, value.clone()); + buffer.get().WriteSparseUDT(edit, this, udt, options, value.clone()); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java index f19a14f..b403400 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java @@ -30,30 +30,30 @@ public final class LayoutUInt16 extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // ushort value) @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + if (!buffer.get().readBit(scope.get().start(), column.getNullBit().clone())) { value.setAndGet(0); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadUInt16(scope.get().start() + column.getOffset())); + value.setAndGet(buffer.get().ReadUInt16(scope.get().start() + column.getOffset())); return Result.SUCCESS; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ushort value) @Override - public Result readSparse(RowBuffer b, RowCursor edit, + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(buffer, edit, this.LayoutCode); if (result != Result.SUCCESS) { value.setAndGet(0); return result; } - value.setAndGet(b.get().ReadSparseUInt16(edit)); + value.setAndGet(buffer.get().ReadSparseUInt16(edit)); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java index 27ce07c..e84e7c0 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java @@ -30,30 +30,30 @@ public final class LayoutUInt32 extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // uint value) @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + if (!buffer.get().readBit(scope.get().start(), column.getNullBit().clone())) { value.setAndGet(0); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadUInt32(scope.get().start() + column.getOffset())); + value.setAndGet(buffer.get().ReadUInt32(scope.get().start() + column.getOffset())); return Result.SUCCESS; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out uint value) @Override - public Result readSparse(RowBuffer b, RowCursor edit, + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(buffer, edit, this.LayoutCode); if (result != Result.SUCCESS) { value.setAndGet(0); return result; } - value.setAndGet(b.get().ReadSparseUInt32(edit)); + value.setAndGet(buffer.get().ReadSparseUInt32(edit)); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java index 4040f80..8ec7e29 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java @@ -30,30 +30,30 @@ public final class LayoutUInt64 extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // ulong value) @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + if (!buffer.get().readBit(scope.get().start(), column.getNullBit().clone())) { value.setAndGet(0); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadUInt64(scope.get().start() + column.getOffset())); + value.setAndGet(buffer.get().ReadUInt64(scope.get().start() + column.getOffset())); return Result.SUCCESS; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ulong value) @Override - public Result readSparse(RowBuffer b, RowCursor edit, + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(buffer, edit, this.LayoutCode); if (result != Result.SUCCESS) { value.setAndGet(0); return result; } - value.setAndGet(b.get().ReadSparseUInt64(edit)); + value.setAndGet(buffer.get().ReadSparseUInt64(edit)); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java index accfbbb..2c670ed 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java @@ -30,30 +30,30 @@ public final class LayoutUInt8 extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // byte value) @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + if (!buffer.get().readBit(scope.get().start(), column.getNullBit().clone())) { value.setAndGet(0); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadUInt8(scope.get().start() + column.getOffset())); + value.setAndGet(buffer.get().ReadUInt8(scope.get().start() + column.getOffset())); return Result.SUCCESS; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out byte value) @Override - public Result readSparse(RowBuffer b, RowCursor edit, + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(buffer, edit, this.LayoutCode); if (result != Result.SUCCESS) { value.setAndGet(0); return result; } - value.setAndGet(b.get().ReadSparseUInt8(edit)); + value.setAndGet(buffer.get().ReadSparseUInt8(edit)); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java index 45f8ea1..a206505 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java @@ -4,85 +4,89 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; -import com.azure.data.cosmos.serialization.hybridrow.RowOptions; import com.azure.data.cosmos.serialization.hybridrow.RowCursors; +import com.azure.data.cosmos.serialization.hybridrow.RowOptions; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; public abstract class LayoutUniqueScope extends LayoutIndexedScope { + protected LayoutUniqueScope(LayoutCode code, boolean immutable, boolean isSizedScope, boolean isTypedScope) { - // TODO: C# TO JAVA CONVERTER: C# to Java Converter could not resolve the named parameters in the - // following line: - //ORIGINAL LINE: base(code, immutable, isSizedScope, isFixedArity: false, isUniqueScope: true, isTypedScope: - // isTypedScope); super(code, immutable, isSizedScope, false, true, isTypedScope); } - public abstract TypeArgument FieldType(Reference scope); + public abstract TypeArgument fieldType(RowCursor scope); /** * Search for a matching field within a unique index. + *

+ * The pattern field is deleted whether the find succeeds or fails. * - * @param b The row to search. + * @param buffer The row to search. * @param scope The parent unique index edit to search. * @param patternScope The parent edit from which the match pattern is read. * @param value If successful, the updated edit. - * @return Success a matching field exists in the unique index, NotFound if no match is found, the - * error code otherwise. - *

- * The pattern field is delete whether the find succeeds or fails. + * @return Success a matching field exists in the unique index, NotFound if no match is found, the error code + * otherwise. */ - public final Result Find(Reference b, Reference scope, - Reference patternScope, Out value) { - Result result = LayoutType.prepareSparseMove(b, scope, this, this.FieldType(scope).clone(), patternScope, UpdateOptions.Update, value.clone()); + public final Result find(RowBuffer buffer, RowCursor scope, RowCursor patternScope, Out value) { + + Result result = LayoutType.prepareSparseMove(buffer, scope, this, this.fieldType(scope), patternScope, + UpdateOptions.Update, value); if (result != Result.SUCCESS) { return result; } - // Check if the search found the result. - b.get().deleteSparse(patternScope); - + buffer.deleteSparse(patternScope); return Result.SUCCESS; } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public Result MoveField(ref RowBuffer b, ref RowCursor destinationScope, ref RowCursor - // sourceEdit, UpdateOptions options = UpdateOptions.Upsert) - public final Result MoveField(Reference b, Reference destinationScope, - Reference sourceEdit, UpdateOptions options) { - RowCursor dstEdit; - Out tempOut_dstEdit = - new Out(); - Result result = LayoutType.prepareSparseMove(b, destinationScope, this, - this.FieldType(destinationScope).clone(), sourceEdit, options, tempOut_dstEdit); - dstEdit = tempOut_dstEdit.get(); + /** + * Moves an existing sparse field into the unique index. + *

+ * The source field MUST be a field whose type arguments match the element type of the destination unique index. + * The source field is deleted whether the move succeeds or fails. + * + * @param buffer The row to move within. + * @param destinationScope The parent unique indexed edit into which the field should be moved. + * @param sourceEdit The field to be moved. + * @param options The move options. + * @return Success if the field is permitted within the unique index, the error code otherwise. + */ + public final Result moveField( + RowBuffer buffer, RowCursor destinationScope, RowCursor sourceEdit, UpdateOptions options) { + + Out dstEdit = new Out<>(); + + Result result = LayoutType.prepareSparseMove( + buffer, destinationScope, this, this.fieldType(destinationScope), sourceEdit, options, dstEdit); if (result != Result.SUCCESS) { return result; } - // Perform the move. - Reference tempReference_dstEdit = - new Reference(dstEdit); - b.get().typedCollectionMoveField(tempReference_dstEdit, sourceEdit, RowOptions.from(options)); - dstEdit = tempReference_dstEdit.get(); + buffer.typedCollectionMoveField(dstEdit.get(), sourceEdit, RowOptions.from(options.value())); - // TODO: it would be "better" if the destinationScope were updated to point to the - // highest item seen. Then we would avoid the maximum reparse. - destinationScope.get().count(dstEdit.count()); + // TODO: it would be "better" if the destinationScope were updated to point to the highest item seen. Then we + // would avoid the maximum reparse + + destinationScope.count(dstEdit.get().count()); return Result.SUCCESS; } /** * Moves an existing sparse field into the unique index. * - * @param b The row to move within. + * @param buffer The row to move within. * @param destinationScope The parent unique indexed edit into which the field should be moved. * @param sourceEdit The field to be moved. - * @param options The move options. * @return Success if the field is permitted within the unique index, the error code otherwise. *

* The source field MUST be a field whose type arguments match the element type of the @@ -90,64 +94,58 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope { * * The source field is delete whether the move succeeds or fails. */ - - public final Result MoveField(Reference b, Reference destinationScope, - Reference sourceEdit) { - return MoveField(b, destinationScope, sourceEdit, UpdateOptions.Upsert); + public final Result moveField(RowBuffer buffer, RowCursor destinationScope, RowCursor sourceEdit) { + return this.moveField(buffer, destinationScope, sourceEdit, UpdateOptions.Upsert); } - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor scope, - // TypeArgumentList typeArgs, TContext context, WriterFunc func, UpdateOptions options = UpdateOptions - // .Upsert) @Override - public Result writeScope(RowBuffer b, RowCursor scope, - TypeArgumentList typeArgs, TContext context, WriterFunc func, - UpdateOptions options) { - RowCursor uniqueScope; - // 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.WriteScope(b, scope, typeArgs.clone(), out uniqueScope, options); - if (r != Result.SUCCESS) { - return r; + @Nonnull + public Result writeScope( + @Nonnull final RowBuffer buffer, + @Nonnull final RowCursor scope, + @Nonnull final TypeArgumentList typeArgs, + @Nullable final TContext context, + @Nullable final WriterFunc func, + @Nonnull final UpdateOptions options) { + + checkNotNull(buffer, "expected non-null buffer"); + checkNotNull(scope, "expected non-null scope"); + checkNotNull(typeArgs, "expected non-null typeArgs"); + checkNotNull(options, "expected non-null options"); + + final Out uniqueScope = new Out<>(); + Result result; + + result = this.writeScope(buffer, scope, typeArgs, options, uniqueScope); + + if (result != Result.SUCCESS) { + return result; } - RowCursor childScope; - // 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: - uniqueScope.Clone(out childScope); - childScope.deferUniqueIndex = true; - Reference tempReference_childScope = - new Reference(childScope); - // TODO: C# TO JAVA CONVERTER: The following line could not be converted: - r = func == null ? null : func.Invoke(ref b, ref childScope, context) ??Result.SUCCESS; - childScope = tempReference_childScope.get(); - if (r != Result.SUCCESS) { - this.deleteScope(b, scope); - return r; + RowCursor childScope = uniqueScope.get().deferUniqueIndex(true); + result = func == null ? null : func.invoke(buffer, childScope, context); + + if (result != null && result != Result.SUCCESS) { + this.deleteScope(buffer, scope); + return result; } - uniqueScope.count(childScope.count()); - Reference tempReference_uniqueScope = - new Reference(uniqueScope); - r = b.get().TypedCollectionUniqueIndexRebuild(tempReference_uniqueScope); - uniqueScope = tempReference_uniqueScope.get(); - if (r != Result.SUCCESS) { - this.deleteScope(b, scope); - return r; + uniqueScope.get().count(childScope.count()); + result = buffer.typedCollectionUniqueIndexRebuild(uniqueScope.get()); + + if (result != Result.SUCCESS) { + this.deleteScope(buffer, scope); + return result; } - Reference tempReference_childScope2 = - new Reference(childScope); - RowCursors.skip(scope.get().clone(), b, - tempReference_childScope2); - childScope = tempReference_childScope2.get(); + RowCursors.skip(scope, buffer, childScope); return Result.SUCCESS; } @Override - public Result writeScope(RowBuffer b, RowCursor scope, - TypeArgumentList typeArgs, TContext context, WriterFunc func) { - return writeScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert); + @Nonnull + public Result writeScope( + RowBuffer buffer, RowCursor scope, TypeArgumentList typeArgs, TContext context, WriterFunc func) { + return this.writeScope(buffer, scope, typeArgs, context, func, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java index 7fe2bd3..cdd4d88 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java @@ -26,41 +26,41 @@ public final class LayoutUnixDateTime extends LayoutType value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + if (!buffer.get().readBit(scope.get().start(), column.getNullBit().clone())) { value.setAndGet(null); return Result.NOT_FOUND; } - value.setAndGet(b.get().ReadUnixDateTime(scope.get().start() + column.getOffset()).clone()); + value.setAndGet(buffer.get().ReadUnixDateTime(scope.get().start() + column.getOffset()).clone()); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + Result result = prepareSparseRead(buffer, edit, this.LayoutCode); if (result != Result.SUCCESS) { value.setAndGet(null); return result; } - value.setAndGet(b.get().ReadSparseUnixDateTime(edit).clone()); + value.setAndGet(buffer.get().ReadSparseUnixDateTime(edit).clone()); return Result.SUCCESS; } @Override - public Result writeFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, UnixDateTime value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); if (scope.get().immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().WriteUnixDateTime(scope.get().start() + column.getOffset(), value.clone()); - b.get().SetBit(scope.get().start(), column.getNullBit().clone()); + buffer.get().WriteUnixDateTime(scope.get().start() + column.getOffset(), value.clone()); + buffer.get().SetBit(scope.get().start(), column.getNullBit().clone()); return Result.SUCCESS; } @@ -68,19 +68,19 @@ public final class LayoutUnixDateTime extends LayoutType implements ILayoutUtf8S } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, - Out value) { + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, 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.ReadFixed(b, scope, column, out span); + Result r = this.ReadFixed(buffer, scope, column, out span); value.setAndGet((r == Result.SUCCESS) ? span.toString() :) default return r; } - public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, + public Result ReadFixed(Reference b, Reference scope, LayoutColumn column, Out value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - checkArgument(col.getSize() >= 0); - if (!b.get().readBit(scope.get().start(), col.getNullBit().clone())) { + checkArgument(column.getSize() >= 0); + if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { value.setAndGet(null); return Result.NOT_FOUND; } - value.setAndGet(b.get().readFixedString(scope.get().start() + col.getOffset(), col.getSize())); + value.setAndGet(b.get().readFixedString(scope.get().start() + column.getOffset(), column.getSize())); return Result.SUCCESS; } @Override - public Result readSparse(RowBuffer b, RowCursor edit, + public Result readSparse(RowBuffer buffer, RowCursor edit, 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.ReadSparse(b, edit, out span); + Result r = this.ReadSparse(buffer, edit, out span); value.setAndGet((r == Result.SUCCESS) ? span.toString() :) default return r; @@ -73,12 +73,12 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S } @Override - public Result readVariable(RowBuffer b, RowCursor scope, LayoutColumn column + public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column , 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.ReadVariable(b, scope, column, out span); + Result r = this.ReadVariable(buffer, scope, column, out span); value.setAndGet((r == Result.SUCCESS) ? span.toString() :) default return r; @@ -99,87 +99,87 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S } @Override - public Result writeFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, String value) { checkArgument(value != null); - return this.WriteFixed(b, scope, column, Utf8Span.TranscodeUtf16(value)); + return this.writeFixed(buffer, scope, column, Utf8Span.TranscodeUtf16(value)); } - public Result WriteFixed(Reference b, Reference scope, LayoutColumn col, - Utf8Span value) { + public Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, + Utf8String value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - checkArgument(col.getSize() >= 0); - checkArgument(value.Length == col.getSize()); + checkArgument(column.getSize() >= 0); + checkArgument(value.Length == column.getSize()); if (scope.get().immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } - b.get().writeFixedString(scope.get().start() + col.getOffset(), value); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.get().writeFixedString(scope.get().start() + column.getOffset(), value); + buffer.get().setBit(scope.get().start(), column.getNullBit().clone()); return Result.SUCCESS; } @Override - public Result writeSparse(RowBuffer b, RowCursor edit, String value) { - return writeSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(RowBuffer buffer, RowCursor edit, String value) { + return writeSparse(buffer, edit, value, UpdateOptions.Upsert); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, string value, // UpdateOptions options = UpdateOptions.Upsert) @Override - public Result writeSparse(RowBuffer b, RowCursor edit, String value, + public Result writeSparse(RowBuffer buffer, RowCursor edit, String value, UpdateOptions options) { checkArgument(value != null); - return this.WriteSparse(b, edit, Utf8Span.TranscodeUtf16(value), options); + return this.writeSparse(buffer, edit, Utf8Span.TranscodeUtf16(value), options); } - public Result WriteSparse(Reference b, Reference edit, Utf8Span value) { - return WriteSparse(b, edit, value, UpdateOptions.Upsert); + public Result writeSparse(RowBuffer buffer, RowCursor edit, Utf8String value) { + return writeSparse(buffer, edit, value, UpdateOptions.Upsert); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public Result WriteSparse(ref RowBuffer b, ref RowCursor edit, Utf8Span value, UpdateOptions // options = UpdateOptions.Upsert) - public Result WriteSparse(Reference b, Reference edit, Utf8Span value, + public Result writeSparse(RowBuffer buffer, RowCursor edit, Utf8String value, UpdateOptions options) { - Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); + Result result = LayoutType.prepareSparseWrite(buffer, edit, this.typeArg().clone(), options); if (result != Result.SUCCESS) { return result; } - b.get().writeSparseString(edit, value, options); + buffer.get().writeSparseString(edit, value, options); return Result.SUCCESS; } @Override - public Result writeVariable(Reference b, Reference scope, - LayoutColumn col, String value) { + public Result writeVariable(RowBuffer buffer, RowCursor scope, + LayoutColumn column, String value) { checkArgument(value != null); - return this.WriteVariable(b, scope, col, Utf8Span.TranscodeUtf16(value)); + return this.writeVariable(buffer, scope, column, Utf8Span.TranscodeUtf16(value)); } - public Result WriteVariable(Reference b, Reference scope, - LayoutColumn col, Utf8Span value) { + public Result writeVariable(RowBuffer buffer, RowCursor scope, + LayoutColumn column, Utf8String value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); if (scope.get().immutable()) { return Result.INSUFFICIENT_PERMISSIONS; } int length = value.Length; - if ((col.getSize() > 0) && (length > col.getSize())) { + if ((column.getSize() > 0) && (length > column.getSize())) { return Result.TOO_BIG; } - boolean exists = b.get().readBit(scope.get().start(), col.getNullBit().clone()); - int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), - col.getOffset()); + boolean exists = buffer.get().readBit(scope.get().start(), column.getNullBit().clone()); + int varOffset = buffer.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), + column.getOffset()); int shift; Out tempOut_shift = new Out(); - b.get().writeVariableString(varOffset, value, exists, tempOut_shift); + buffer.get().writeVariableString(varOffset, value, exists, tempOut_shift); shift = tempOut_shift.get(); - b.get().setBit(scope.get().start(), col.getNullBit().clone()); + buffer.get().setBit(scope.get().start(), column.getNullBit().clone()); scope.get().metaOffset(scope.get().metaOffset() + shift); scope.get().valueOffset(scope.get().valueOffset() + shift); return Result.SUCCESS; diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java index 97cb5ae..b1495ee 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java @@ -29,7 +29,7 @@ public final class LayoutVarInt extends LayoutType { } @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { Contract.Fail("Not Implemented"); value.setAndGet(0); @@ -37,28 +37,28 @@ public final class LayoutVarInt extends LayoutType { } @Override - public Result readSparse(RowBuffer b, RowCursor edit, Out value) { - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + Result result = LayoutType.prepareSparseRead(buffer, edit, this.LayoutCode); if (result != Result.SUCCESS) { value.setAndGet(0); return result; } - value.setAndGet(b.get().ReadSparseVarInt(edit)); + value.setAndGet(buffer.get().ReadSparseVarInt(edit)); return Result.SUCCESS; } @Override - public Result readVariable(RowBuffer b, RowCursor scope, LayoutColumn column, Out value) { + public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + if (!buffer.get().readBit(scope.get().start(), column.getNullBit().clone())) { value.setAndGet(0); return Result.NOT_FOUND; } - int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), + int varOffset = buffer.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), column.getOffset()); - value.setAndGet(b.get().ReadVariableInt(varOffset)); + value.setAndGet(buffer.get().ReadVariableInt(varOffset)); return Result.SUCCESS; } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java index de8eb4c..f94e90b 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java @@ -34,7 +34,7 @@ public final class LayoutVarUInt extends LayoutType { //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // ulong value) @Override - public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, + public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { Contract.Fail("Not Implemented"); value.setAndGet(0); @@ -44,14 +44,14 @@ public final class LayoutVarUInt extends LayoutType { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ulong value) @Override - public Result readSparse(RowBuffer b, RowCursor edit, Out value) { - Result result = prepareSparseRead(b, edit, this.LayoutCode); + public Result readSparse(RowBuffer buffer, RowCursor edit, Out value) { + Result result = prepareSparseRead(buffer, edit, this.LayoutCode); if (result != Result.SUCCESS) { value.setAndGet(0); return result; } - value.setAndGet(b.get().readSparseVarUInt(edit)); + value.setAndGet(buffer.get().readSparseVarUInt(edit)); return Result.SUCCESS; } @@ -59,16 +59,16 @@ public final class LayoutVarUInt extends LayoutType { //ORIGINAL LINE: public override Result ReadVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out // ulong value) @Override - public Result readVariable(RowBuffer b, RowCursor scope, LayoutColumn column, Out value) { + public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out value) { checkArgument(scope.get().scopeType() instanceof LayoutUDT); - if (!b.get().readBit(scope.get().start(), column.getNullBit().clone())) { + if (!buffer.get().readBit(scope.get().start(), column.getNullBit().clone())) { value.setAndGet(0); return Result.NOT_FOUND; } - int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), + int varOffset = buffer.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(), column.getOffset()); - value.setAndGet(b.get().ReadVariableUInt(varOffset)); + value.setAndGet(buffer.get().ReadVariableUInt(varOffset)); return Result.SUCCESS; } 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 c78eaef..51d494b 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 @@ -50,7 +50,7 @@ public final class SegmentSerializer { break; case "comment": Out tempOut_Comment = new Out(); - r = reader.get().ReadString(tempOut_Comment); + r = reader.get().readString(tempOut_Comment); obj.get().argValue.Comment = tempOut_Comment.get(); if (r != Result.SUCCESS) { return r; @@ -59,7 +59,7 @@ public final class SegmentSerializer { break; case "sdl": Out tempOut_SDL = new Out(); - r = reader.get().ReadString(tempOut_SDL); + r = reader.get().readString(tempOut_SDL); obj.get().argValue.SDL = tempOut_SDL.get(); if (r != Result.SUCCESS) { return r; diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertySchemaConverter.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertySchemaConverter.java index 2ca82ee..4d92ef9 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertySchemaConverter.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertySchemaConverter.java @@ -49,10 +49,10 @@ public class PropertySchemaConverter extends JsonConverter { case Array: p = new ArrayPropertyType(); break; - case Set: + case SET: p = new SetPropertyType(); break; - case Map: + case MAP: p = new MapPropertyType(); break; case Object: @@ -61,7 +61,7 @@ public class PropertySchemaConverter extends JsonConverter { case Tuple: p = new TuplePropertyType(); break; - case Tagged: + case TAGGED: p = new TaggedPropertyType(); break; case Schema: diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java index 7c8eec8..580ccb4 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java @@ -167,12 +167,12 @@ public enum TypeKind { /** * A set property, either typed or untyped. */ - Set(25), + SET(25), /** * A map property, either typed or untyped. */ - Map(26), + MAP(26), /** * A tuple property. Tuples are typed, finite, ordered, sets. @@ -182,7 +182,7 @@ public enum TypeKind { /** * A tagged property. Tagged properties pair one or more typed values with an API-specific uint8 type code. */ - Tagged(28), + TAGGED(28), /** * A row with schema. 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 66f387d..0f791ba 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 @@ -245,7 +245,7 @@ public final class RowReaderUnitTests { assert rowReader.read(); Reference tempReference_nestedScope2 = new Reference(nestedScope); - Result result = rowReader.SkipScope(tempReference_nestedScope2); + Result result = rowReader.skipScope(tempReference_nestedScope2); nestedScope = tempReference_nestedScope2.get(); assert Result.SUCCESS != result; } @@ -254,12 +254,12 @@ public final class RowReaderUnitTests { while (reader.get().read()) { switch (reader.get().type().LayoutCode) { case TupleScope: { - ResultAssert.IsSuccess(reader.get().ReadScope(0, RowReaderUnitTests.ReadTuplePartial)); + ResultAssert.IsSuccess(reader.get().readScope(0, RowReaderUnitTests.ReadTuplePartial)); break; } case ObjectScope: { - ResultAssert.IsSuccess(reader.get().ReadScope(0, RowReaderUnitTests.ReadNestedDocumentDelegate)); + ResultAssert.IsSuccess(reader.get().readScope(0, RowReaderUnitTests.ReadNestedDocumentDelegate)); break; } } @@ -286,7 +286,7 @@ public final class RowReaderUnitTests { new Reference(nested); ResultAssert.IsSuccess(RowReaderUnitTests.ReadNestedDocumentNonDelegate(tempReference_nested2, 0)); nested = tempReference_nested2.get(); - ResultAssert.IsSuccess(reader.get().ReadScope(0, RowReaderUnitTests.ReadNestedDocumentDelegate)); + ResultAssert.IsSuccess(reader.get().readScope(0, RowReaderUnitTests.ReadNestedDocumentDelegate)); break; } } @@ -307,7 +307,7 @@ public final class RowReaderUnitTests { nested = tempReference_nested.get(); Reference tempReference_nested2 = new Reference(nested); - ResultAssert.IsSuccess(reader.get().SkipScope(tempReference_nested2)); + ResultAssert.IsSuccess(reader.get().skipScope(tempReference_nested2)); nested = tempReference_nested2.get(); break; } @@ -318,9 +318,9 @@ public final class RowReaderUnitTests { new Reference(nested); ResultAssert.IsSuccess(RowReaderUnitTests.ReadNestedDocumentNonDelegate(tempReference_nested3, 0)); nested = tempReference_nested3.get(); - ResultAssert.IsSuccess(reader.get().ReadScope(0, RowReaderUnitTests.ReadNestedDocumentDelegate)); + ResultAssert.IsSuccess(reader.get().readScope(0, RowReaderUnitTests.ReadNestedDocumentDelegate)); Reference tempReference_nested4 = new Reference(nested); - ResultAssert.IsSuccess(reader.get().SkipScope(tempReference_nested4)); + ResultAssert.IsSuccess(reader.get().skipScope(tempReference_nested4)); nested = tempReference_nested4.get(); break; } 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 393af36..e409d0d 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 @@ -155,8 +155,8 @@ public final class SerializerUnitTest { Out tempOut_Headers = new Out(); // TODO: C# TO JAVA CONVERTER: The following lambda contained an unresolved 'ref' keyword // - these are not converted by C# to Java Converter: - r = reader.get().ReadScope(retval, - (ref RowReader child, BatchOperation parent) -> BatchRequestHeadersSerializer.Read(tempReference_child, tempOut_Headers)); + r = reader.get().readScope(retval, + (RowReader RowReader child, BatchOperation parent) -> BatchRequestHeadersSerializer.Read(tempReference_child, tempOut_Headers)); parent.Headers = tempOut_Headers.get(); child = tempReference_child.get(); if (r != Result.SUCCESS) { @@ -175,7 +175,7 @@ public final class SerializerUnitTest { break; case "resourcePath": Out tempOut_ResourcePath = new Out(); - r = reader.get().ReadString(tempOut_ResourcePath); + r = reader.get().readString(tempOut_ResourcePath); retval.ResourcePath = tempOut_ResourcePath.get(); if (r != Result.SUCCESS) { return r; 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 ab6689d..df3da49 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 @@ -17,7 +17,7 @@ public final class AddressSerializer { switch (reader.get().path()) { case "street": Out tempOut_Street = new Out(); - r = reader.get().ReadString(tempOut_Street); + r = reader.get().readString(tempOut_Street); obj.get().argValue.Street = tempOut_Street.get(); if (r != Result.SUCCESS) { return r; @@ -26,7 +26,7 @@ public final class AddressSerializer { break; case "city": Out tempOut_City = new Out(); - r = reader.get().ReadString(tempOut_City); + r = reader.get().readString(tempOut_City); obj.get().argValue.City = tempOut_City.get(); if (r != Result.SUCCESS) { return r; @@ -35,7 +35,7 @@ public final class AddressSerializer { break; case "state": Out tempOut_State = new Out(); - r = reader.get().ReadString(tempOut_State); + r = reader.get().readString(tempOut_State); obj.get().argValue.State = tempOut_State.get(); if (r != Result.SUCCESS) { return r; @@ -47,7 +47,7 @@ public final class AddressSerializer { new Reference(child); Out tempOut_PostalCode = new Out(); // TODO: C# TO JAVA CONVERTER: The following lambda contained an unresolved 'ref' keyword - these are not converted by C# to Java Converter: - r = reader.get().ReadScope(obj.get(), (ref RowReader child, Address parent) -> PostalCodeSerializer.Read(tempReference_child, tempOut_PostalCode)); + r = reader.get().readScope(obj.get(), (RowReader RowReader child, Address parent) -> PostalCodeSerializer.Read(tempReference_child, tempOut_PostalCode)); parent.PostalCode = tempOut_PostalCode.get(); child = tempReference_child.get();