diff --git a/java/src/main/java/com/azure/data/cosmos/core/Utf8String.java b/java/src/main/java/com/azure/data/cosmos/core/Utf8String.java
index c5e397f..0e44916 100644
--- a/java/src/main/java/com/azure/data/cosmos/core/Utf8String.java
+++ b/java/src/main/java/com/azure/data/cosmos/core/Utf8String.java
@@ -56,7 +56,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
}
private Utf8String(@Nonnull final ByteBuf buffer, final int decodedLength) {
- checkNotNull(buffer);
+ checkNotNull(buffer, "expected non-null buffer");
this.buffer = buffer.asReadOnly();
this.length = decodedLength;
}
@@ -75,114 +75,6 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
return this.buffer == null;
}
- /**
- * Returns a reference to the read-only {@link ByteBuf} holding the content of this {@link Utf8String}
- *
- * A value of {@code null} is returns, if this {@link Utf8String} is null.
- * @return reference to the read-only {@link ByteBuf} holding the content of this {@link Utf8String}.
- */
- @Nullable
- public ByteBuf content() {
- return this.buffer;
- }
-
- /**
- * Creates a deep copy of this {@link Utf8String}
- */
- @Override
- public Utf8String copy() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Duplicates this {@link Utf8String}
- *
- * Be aware that this will not automatically call {@link #retain()}.
- */
- @Override
- public Utf8String duplicate() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Duplicates this {@link Utf8String}
- *
- * This method returns a retained duplicate unlike {@link #duplicate()}.
- *
- * @see ByteBuf#retainedDuplicate()
- */
- @Override
- public Utf8String retainedDuplicate() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns a new {@link Utf8String} which contains the specified {@code content}
- *
- * @param content text of the {@link Utf8String} to be created.
- */
- @Override
- public Utf8String replace(ByteBuf content) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns the reference count of this {@link Utf8String}
- *
- * If {@code 0}, it means this object has been deallocated.
- */
- @Override
- public int refCnt() {
- return this.buffer.refCnt();
- }
-
- @Override
- public Utf8String retain() {
- this.buffer.retain();
- return this;
- }
-
- @Override
- public Utf8String retain(int increment) {
- this.buffer.retain(increment);
- return this;
- }
-
- @Override
- public Utf8String touch() {
- this.buffer.touch();
- return this;
- }
-
- @Override
- public Utf8String touch(Object hint) {
- this.buffer.touch(hint);
- return this;
- }
-
- /**
- * Decreases the reference count by {@code 1} and deallocates this object if the reference count reaches at
- * {@code 0}.
- *
- * @return {@code true} if and only if the reference count became {@code 0} and this object has been deallocated
- */
- @Override
- public boolean release() {
- return this.buffer.release();
- }
-
- /**
- * Decreases the reference count by the specified {@code decrement} and deallocates this object if the reference
- * count reaches at {@code 0}.
- *
- * @param decrement
- * @return {@code true} if and only if the reference count became {@code 0} and this object has been deallocated
- */
- @Override
- public boolean release(int decrement) {
- return false;
- }
-
@Override
public char charAt(final int index) {
throw new UnsupportedOperationException();
@@ -208,7 +100,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
public final int compareTo(@Nonnull final Utf8String other) {
- checkNotNull(other);
+ checkNotNull(other, "expected non-null other");
if (other.buffer == this.buffer) {
return 0;
@@ -257,6 +149,35 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
return length - otherLength;
}
+ /**
+ * Returns a reference to the read-only {@link ByteBuf} holding the content of this {@link Utf8String}
+ *
+ * A value of {@code null} is returns, if this {@link Utf8String} is null.
+ * @return reference to the read-only {@link ByteBuf} holding the content of this {@link Utf8String}.
+ */
+ @Nullable
+ public ByteBuf content() {
+ return this.buffer;
+ }
+
+ /**
+ * Creates a deep copy of this {@link Utf8String}
+ */
+ @Override
+ public Utf8String copy() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Duplicates this {@link Utf8String}
+ *
+ * Be aware that this will not automatically call {@link #retain()}.
+ */
+ @Override
+ public Utf8String duplicate() {
+ throw new UnsupportedOperationException();
+ }
+
public final boolean equals(ByteBuf other) {
return this.buffer.equals(other);
}
@@ -298,6 +219,35 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
return false;
}
+ /**
+ * Creates a new {@link Utf8String} from a {@link ByteBuf} with UTF-8 character validation
+ *
+ * The {@link Utf8String} created retains the {@link ByteBuf}. (No data is transferred.)
+ *
+ * @param buffer The {@link ByteBuf} to validate and assign to the {@link Utf8String} created.
+ * @return A {@link Utf8String} instance, if the @{code buffer} validates or a value of @{link Optional#empty}
+ * otherwise.
+ */
+ @Nonnull
+ public static Optional from(@Nonnull final ByteBuf buffer) {
+ checkNotNull(buffer, "expected non-null buffer");
+ return Utf8.isWellFormed(buffer.array()) ? Optional.of(new Utf8String(buffer)) : Optional.empty();
+ }
+
+ /**
+ * Creates a new {@link Utf8String} from a {@link ByteBuf} without UTF-8 character validation
+ *
+ * The {@link Utf8String} created retains the {@link ByteBuf}. (No data is transferred.)
+ *
+ * @param buffer The {@link ByteBuf} to assign to the {@link Utf8String} created.
+ * @return a new {@link Utf8String}
+ */
+ @Nonnull
+ public static Utf8String fromUnsafe(@Nonnull ByteBuf buffer) {
+ checkNotNull(buffer, "expected non-null buffer");
+ return new Utf8String(buffer);
+ }
+
@Override
public int hashCode() {
return this.buffer.hashCode();
@@ -312,6 +262,73 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
return this.length;
}
+ /**
+ * Returns the reference count of this {@link Utf8String}
+ *
+ * If {@code 0}, it means this object has been deallocated.
+ */
+ @Override
+ public int refCnt() {
+ return this.buffer.refCnt();
+ }
+
+ /**
+ * Decreases the reference count by {@code 1} and deallocates this object if the reference count reaches at
+ * {@code 0}.
+ *
+ * @return {@code true} if and only if the reference count became {@code 0} and this object has been deallocated
+ */
+ @Override
+ public boolean release() {
+ return this.buffer.release();
+ }
+
+ /**
+ * Decreases the reference count by the specified {@code decrement} and deallocates this object if the reference
+ * count reaches at {@code 0}.
+ *
+ * @param decrement
+ * @return {@code true} if and only if the reference count became {@code 0} and this object has been deallocated
+ */
+ @Override
+ public boolean release(int decrement) {
+ return false;
+ }
+
+ /**
+ * Returns a new {@link Utf8String} which contains the specified {@code content}
+ *
+ * @param content text of the {@link Utf8String} to be created.
+ */
+ @Override
+ public Utf8String replace(ByteBuf content) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Utf8String retain() {
+ this.buffer.retain();
+ return this;
+ }
+
+ @Override
+ public Utf8String retain(int increment) {
+ this.buffer.retain(increment);
+ return this;
+ }
+
+ /**
+ * Duplicates this {@link Utf8String}
+ *
+ * This method returns a retained duplicate unlike {@link #duplicate()}.
+ *
+ * @see ByteBuf#retainedDuplicate()
+ */
+ @Override
+ public Utf8String retainedDuplicate() {
+ throw new UnsupportedOperationException();
+ }
+
@Override
public CharSequence subSequence(int start, int end) {
checkArgument(start < 0 || end < 0 || start > end || end > this.length, "start: %s, end: %s", start, end);
@@ -328,6 +345,18 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
return this.buffer.getCharSequence(0, this.buffer.capacity(), UTF_8).toString();
}
+ @Override
+ public Utf8String touch() {
+ this.buffer.touch();
+ return this;
+ }
+
+ @Override
+ public Utf8String touch(Object hint) {
+ this.buffer.touch(hint);
+ return this;
+ }
+
/**
* Creates a {@link Utf8String} from a UTF16 encoding string
*
@@ -356,35 +385,6 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
return new Utf8String(buffer, string.length());
}
- /**
- * Creates a new {@link Utf8String} from a {@link ByteBuf} with UTF-8 character validation
- *
- * The {@link Utf8String} created retains the {@link ByteBuf}. (No data is transferred.)
- *
- * @param buffer The {@link ByteBuf} to validate and assign to the {@link Utf8String} created.
- * @return A {@link Utf8String} instance, if the @{code buffer} validates or a value of @{link Optional#empty}
- * otherwise.
- */
- @Nonnull
- public static Optional from(@Nonnull final ByteBuf buffer) {
- checkNotNull(buffer);
- return Utf8.isWellFormed(buffer.array()) ? Optional.of(new Utf8String(buffer)) : Optional.empty();
- }
-
- /**
- * Creates a new {@link Utf8String} from a {@link ByteBuf} without UTF-8 character validation
- *
- * The {@link Utf8String} created retains the {@link ByteBuf}. (No data is transferred.)
- *
- * @param buffer The {@link ByteBuf} to assign to the {@link Utf8String} created.
- * @return a new {@link Utf8String}
- */
- @Nonnull
- public static Utf8String fromUnsafe(@Nonnull ByteBuf buffer) {
- checkNotNull(buffer);
- return new Utf8String(buffer);
- }
-
private static int decodedLength(final ByteBuf buffer) {
final CodePointIterable iterable = new CodePointIterable(buffer, -1);
@@ -498,7 +498,7 @@ public final class Utf8String implements ByteBufHolder, CharSequence, Comparable
@Override
public boolean tryAdvance(@Nonnull final IntConsumer action) {
- checkNotNull(action);
+ checkNotNull(action, "expected non-null action");
if (this.hasNext()) {
action.accept(this.next());
diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Float128.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Float128.java
index 50ba734..b0038f3 100644
--- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Float128.java
+++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Float128.java
@@ -26,7 +26,7 @@ public final class Float128 {
/**
* The size (in bytes) of a {@link Float128}.
*/
- public static final int SIZE = (Long.SIZE / Byte.SIZE) + (Long.SIZE / Byte.SIZE);
+ public static final int BYTES = 2 * Long.BYTES;
private final long high;
private final long low;
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 14188fe..70fe327 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
@@ -79,7 +79,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.lenientFormat;
-//import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType.MongoDbObjectId;
+//import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTypes.MongoDbObjectId;
/**
* Manages a sequence of bytes representing a Hybrid Row
@@ -153,6 +153,7 @@ public final class RowBuffer {
* located.
*/
public int ComputeVariableValueOffset(Layout layout, int scopeOffset, int varIndex) {
+
if (layout == null) {
return scopeOffset;
}
@@ -181,36 +182,10 @@ public final class RowBuffer {
return offset;
}
- /**
- * Delete the sparse field at the indicated path.
- *
- * @param edit The field to delete.
- */
- public void DeleteSparse(RowCursor edit) {
- // If the field doesn't exist, then nothing to do.
- if (!edit.exists()) {
- return;
- }
+ public void TypedCollectionMoveField(RowCursor dstEdit, RowCursor srcEdit, RowOptions options) {
- int numBytes = 0;
- int _;
- Out tempOut__ = new Out();
- int _;
- Out tempOut__2 = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, edit.get().cellType(), edit.get().cellTypeArgs().clone(), numBytes,
- RowOptions.DELETE, tempOut__, tempOut__2, tempOut_shift);
- shift = tempOut_shift.get();
- _ = tempOut__2.get();
- _ = tempOut__.get();
- this.length(this.length() + shift);
- }
-
- public void TypedCollectionMoveField(Reference dstEdit, Reference srcEdit
- , RowOptions options) {
int encodedSize = this.sparseComputeSize(srcEdit);
- int numBytes = encodedSize - (srcEdit.get().valueOffset() - srcEdit.get().metaOffset());
+ int numBytes = encodedSize - (srcEdit.valueOffset() - srcEdit.metaOffset());
// Insert the field metadata into its new location.
int metaBytes;
@@ -219,21 +194,21 @@ public final class RowBuffer {
Out tempOut_spaceNeeded = new Out();
int shiftInsert;
Out tempOut_shiftInsert = new Out();
- this.EnsureSparse(dstEdit, srcEdit.get().cellType(), srcEdit.get().cellTypeArgs().clone(), numBytes,
+ this.ensureSparse(numBytes, dstEdit, srcEdit.cellType(), srcEdit.cellTypeArgs(),
options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shiftInsert);
shiftInsert = tempOut_shiftInsert.get();
spaceNeeded = tempOut_spaceNeeded.get();
metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(dstEdit, srcEdit.get().cellType(), srcEdit.get().cellTypeArgs().clone(), metaBytes);
+ this.writeSparseMetadata(dstEdit, srcEdit.cellType(), srcEdit.cellTypeArgs(), metaBytes);
checkState(spaceNeeded == metaBytes + numBytes);
- if (srcEdit.get().metaOffset() >= dstEdit.get().metaOffset()) {
- srcEdit.get().metaOffset(srcEdit.get().metaOffset() + shiftInsert);
- srcEdit.get().valueOffset(srcEdit.get().valueOffset() + shiftInsert);
+ if (srcEdit.metaOffset() >= dstEdit.metaOffset()) {
+ srcEdit.metaOffset(srcEdit.metaOffset() + shiftInsert);
+ srcEdit.valueOffset(srcEdit.valueOffset() + shiftInsert);
}
// Copy the value bits from the old location.
- this.buffer.Slice(srcEdit.get().valueOffset(), numBytes).CopyTo(this.buffer.Slice(dstEdit.get().valueOffset()));
+ this.buffer.Slice(srcEdit.valueOffset(), numBytes).CopyTo(this.buffer.Slice(dstEdit.valueOffset()));
this.length(this.length() + shiftInsert);
// Delete the old location.
@@ -241,14 +216,14 @@ public final class RowBuffer {
Out tempOut_spaceNeeded2 = new Out();
int shiftDelete;
Out tempOut_shiftDelete = new Out();
- this.EnsureSparse(srcEdit, srcEdit.get().cellType(), srcEdit.get().cellTypeArgs().clone(), numBytes,
+ this.ensureSparse(numBytes, srcEdit, srcEdit.cellType(), srcEdit.cellTypeArgs(),
RowOptions.DELETE, tempOut_metaBytes2, tempOut_spaceNeeded2, tempOut_shiftDelete);
shiftDelete = tempOut_shiftDelete.get();
spaceNeeded = tempOut_spaceNeeded2.get();
metaBytes = tempOut_metaBytes2.get();
checkState(shiftDelete < 0);
- this.length(this.length() + shiftDelete);
+ this.buffer.writerIndex(this.length() + shiftDelete);
}
/**
@@ -280,9 +255,9 @@ public final class RowBuffer {
* operation is idempotent.
*
*/
- public Result TypedCollectionUniqueIndexRebuild(Reference scope) {
- checkArgument(scope.get().scopeType().isUniqueScope());
- checkArgument(scope.get().index() == 0);
+ public Result TypedCollectionUniqueIndexRebuild(RowCursor scope) {
+ checkArgument(scope.scopeType().isUniqueScope());
+ checkArgument(scope.index() == 0);
RowCursor dstEdit;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be
@@ -302,7 +277,7 @@ public final class RowBuffer {
Reference tempReference_dstEdit =
new Reference(dstEdit);
this.readSparseMetadata(tempReference_dstEdit);
- dstEdit = tempReference_dstEdit.get();
+ dstEdit = tempReference_dstEdit;
Contract.Assert(dstEdit.pathOffset() ==
default)
Reference tempReference_dstEdit2 =
@@ -327,7 +302,7 @@ public final class RowBuffer {
// that items are relatively large, using scratch space requires each item to be moved
// AT MOST once. Given that row buffer memory is likely reused, scratch space is
// relatively memory efficient.
- int shift = dstEdit.metaOffset() - scope.get().valueOffset();
+ int shift = dstEdit.metaOffset() - scope.valueOffset();
// Sort and check for duplicates.
// TODO: C# TO JAVA CONVERTER: C# 'unsafe' code is not converted by C# to Java Converter:
@@ -342,7 +317,7 @@ public final class RowBuffer {
// }
// Move elements.
- int metaOffset = scope.get().valueOffset();
+ int metaOffset = scope.valueOffset();
this.ensure(this.length() + shift);
this.buffer.Slice(metaOffset, this.length() - metaOffset).CopyTo(this.buffer.Slice(metaOffset + shift));
for (UniqueIndexItem x : uniqueIndex) {
@@ -364,438 +339,81 @@ public final class RowBuffer {
return Result.SUCCESS;
}
- public void WriteNullable(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs,
- UpdateOptions options, boolean hasValue, Out newScope) {
- int numBytes = this.countDefaultValue(scopeType, typeArgs);
+ public void WriteSparseArray(
+ @Nonnull final RowCursor edit, @Nonnull final LayoutScope scopeType, @Nonnull final UpdateOptions options,
+ @Nonnull final Out newScope) {
+
+ checkNotNull(edit, "expected non-null edit");
+ checkNotNull(scopeType, "expected non-null scopeType");
+ checkNotNull(options, "expected non-null options");
+ checkNotNull(newScope, "expected non-null newScope");
+
+ int numBytes = LayoutCode.BYTES; // end scope type code
+ TypeArgumentList typeArgs = TypeArgumentList.EMPTY;
int metaBytes;
- Out tempOut_metaBytes = new Out();
+ final Out metaBytes = new Out<>();
int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
+ final Out spaceNeeded = new Out<>();
int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, scopeType, typeArgs, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
+ final Out shift = new Out<>();
+
+ this.ensureSparse(numBytes, edit, scopeType, typeArgs, options, tempOut_metaBytes, tempOut_spaceNeeded,
+ tempOut_shift);
shift = tempOut_shift.get();
spaceNeeded = tempOut_spaceNeeded.get();
metaBytes = tempOut_metaBytes.get();
this.writeSparseMetadata(edit, scopeType, typeArgs, metaBytes);
- int numWritten = this.writeDefaultValue(edit.get().valueOffset(), scopeType, typeArgs);
- checkState(numBytes == numWritten);
+ this.writeSparseTypeCode(edit.valueOffset(), LayoutCode.END_SCOPE);
checkState(spaceNeeded == metaBytes + numBytes);
- if (hasValue) {
- this.writeInt8(edit.get().valueOffset(), (byte) 1);
- }
- int valueOffset = edit.get().valueOffset() + 1;
- newScope.setAndGet(new RowCursor());
- newScope.get().scopeType(scopeType);
- newScope.get().scopeTypeArgs(typeArgs);
- newScope.get().start(edit.get().valueOffset());
- newScope.get().valueOffset(valueOffset);
- newScope.get().metaOffset(valueOffset);
- newScope.get().layout(edit.get().layout());
- newScope.get().count(2);
- newScope.get().index(1);
-
- this.length(this.length() + shift);
- Reference tempReference_this =
- new Reference(this);
- RowCursors.moveNext(newScope.get().clone(), tempReference_this);
- this = tempReference_this.get();
+ newScope.setAndGet(new RowCursor())
+ .scopeType(scopeType)
+ .scopeTypeArgs(typeArgs)
+ .start(edit.valueOffset())
+ .valueOffset(edit.valueOffset())
+ .metaOffset(edit.valueOffset())
+ .layout(edit.layout());
}
- public void WriteSparseBinary(
- @Nonnull final RowCursor edit, @Nonnull final ByteBuf value, @Nonnull final UpdateOptions options) {
-
- checkNotNull(edit, "expected non-null edit");
- checkNotNull(value, "expected non-null value");
- checkNotNull(options, "expected non-null options");
-
- final LayoutType layoutType = LayoutTypes.BINARY;
- final int readableBytes = value.readableBytes();
- final int length = RowBuffer.count7BitEncodedUInt(readableBytes) + readableBytes;
-
- Out metaBytes = new Out<>();
- Out shift = new Out<>();
- Out spaceNeeded = new Out<>();
-
- this.EnsureSparse(edit, layoutType, TypeArgumentList.EMPTY, length, options, metaBytes, spaceNeeded, shift);
- this.writeSparseMetadata(edit, layoutType, TypeArgumentList.EMPTY, metaBytes.get());
- this.WriteBinary(edit.valueOffset(), value);
-
- checkState(spaceNeeded.get() == metaBytes.get() + length);
-
- edit.endOffset(edit.metaOffset() + spaceNeeded.get());
- }
-
- public void WriteSparseBinary(Reference edit, ReadOnlySequence value,
- UpdateOptions options) {
- int len = (int) value.Length;
- int numBytes = len + RowBuffer.count7BitEncodedUInt(len);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Binary, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Binary, TypeArgumentList.EMPTY, metaBytes);
- int sizeLenInBytes = this.WriteBinary(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + len + sizeLenInBytes);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseBool(Reference edit, boolean value, UpdateOptions options) {
- int numBytes = 0;
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.EMPTY,
- numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.EMPTY,
- metaBytes);
- checkState(spaceNeeded == metaBytes);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseDateTime(RowCursor edit, OffsetDateTime value, UpdateOptions options) {
- int numBytes = 8;
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.DateTime, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.DateTime, TypeArgumentList.EMPTY, metaBytes);
- this.writeDateTime(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + 8);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseDecimal(Reference edit, BigDecimal value, UpdateOptions options) {
- // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof':
- int numBytes = sizeof(BigDecimal);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Decimal, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Decimal, TypeArgumentList.EMPTY, metaBytes);
- this.writeDecimal(edit.get().valueOffset(), value);
- // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof':
- checkState(spaceNeeded == metaBytes + sizeof(BigDecimal));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseFloat128(Reference edit, Float128 value, UpdateOptions options) {
- int numBytes = Float128.SIZE;
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Float128, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Float128, TypeArgumentList.EMPTY, metaBytes);
- this.writeFloat128(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + Float128.SIZE);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseFloat32(@Nonnull RowCursor edit, float value, @Nonnull UpdateOptions options) {
-
- int numBytes = (Float.SIZE / Byte.SIZE);
- int metaBytes;
-
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutTypes.FLOAT_32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Float32, TypeArgumentList.EMPTY, metaBytes);
- this.writeFloat32(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + (Float.SIZE / Byte.SIZE));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseFloat64(Reference edit, double value, UpdateOptions options) {
- int numBytes = (Double.SIZE / Byte.SIZE);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Float64, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Float64, TypeArgumentList.EMPTY, metaBytes);
- this.writeFloat64(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + (Double.SIZE / Byte.SIZE));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseGuid(Reference edit, UUID value, UpdateOptions options) {
- int numBytes = 16;
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Guid, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Guid, TypeArgumentList.EMPTY, metaBytes);
- this.writeGuid(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + 16);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseInt16(Reference edit, short value, UpdateOptions options) {
- int numBytes = (Short.SIZE / Byte.SIZE);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Int16, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Int16, TypeArgumentList.EMPTY, metaBytes);
- this.writeInt16(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + (Short.SIZE / Byte.SIZE));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- // TODO: DANOBLE: resurrect MongoDbObjectId
- // public MongoDbObjectId ReadMongoDbObjectId(int offset) {
- // return MemoryMarshal.Read(this.buffer.Slice(offset));
- // }
-
- public void WriteSparseInt32(Reference edit, int value, UpdateOptions options) {
- int numBytes = (Integer.SIZE / Byte.SIZE);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Int32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Int32, TypeArgumentList.EMPTY, metaBytes);
- this.writeInt32(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + (Integer.SIZE / Byte.SIZE));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseInt64(Reference edit, long value, UpdateOptions options) {
- int numBytes = (Long.SIZE / Byte.SIZE);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Int64, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Int64, TypeArgumentList.EMPTY, metaBytes);
- this.writeInt64(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + (Long.SIZE / Byte.SIZE));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseInt8(Reference edit, byte value, UpdateOptions options) {
- int numBytes = (Byte.SIZE / Byte.SIZE);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Int8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
-
- this.writeSparseMetadata(edit, LayoutType.Int8, TypeArgumentList.EMPTY, metaBytes);
- this.writeInt8(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + (Byte.SIZE / Byte.SIZE));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseMongoDbObjectId(Reference edit, MongoDbObjectId value,
- UpdateOptions options) {
- int numBytes = MongoDbObjectId.Size;
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, MongoDbObjectId, TypeArgumentList.EMPTY, numBytes, options,
- tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
-
- this.writeSparseMetadata(edit, MongoDbObjectId, TypeArgumentList.EMPTY, metaBytes);
- this.WriteMongoDbObjectId(edit.get().valueOffset(), value.clone());
- checkState(spaceNeeded == metaBytes + MongoDbObjectId.Size);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseNull(Reference edit, NullValue value, UpdateOptions options) {
- int numBytes = 0;
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Null, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Null, TypeArgumentList.EMPTY, metaBytes);
- checkState(spaceNeeded == metaBytes);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseObject(Reference edit, LayoutScope scopeType, UpdateOptions options,
- Out newScope) {
- int numBytes = (LayoutCode.SIZE / Byte.SIZE); // end scope type code.
- TypeArgumentList typeArgs = TypeArgumentList.EMPTY;
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, scopeType, TypeArgumentList.EMPTY, metaBytes);
- this.writeSparseTypeCode(edit.get().valueOffset(), LayoutCode.END_SCOPE);
- checkState(spaceNeeded == metaBytes + numBytes);
- newScope.setAndGet(new RowCursor());
- newScope.get().scopeType(scopeType);
- newScope.get().scopeTypeArgs(TypeArgumentList.EMPTY);
- newScope.get().start(edit.get().valueOffset());
- newScope.get().valueOffset(edit.get().valueOffset());
- newScope.get().metaOffset(edit.get().valueOffset());
- newScope.get().layout(edit.get().layout());
-
- this.length(this.length() + shift);
- }
-
- // TODO: DANOBLE: resurrect MongoDbObjectId
- // public MongoDbObjectId ReadSparseMongoDbObjectId(Reference edit) {
- // this.readSparsePrimitiveTypeCode(edit, MongoDbObjectId);
- // edit.get().endOffset = edit.get().valueOffset() + MongoDbObjectId.Size;
- // return this.ReadMongoDbObjectId(edit.get().valueOffset()).clone();
- // }
-
- public void WriteSparseString(Reference edit, Utf8Span value, UpdateOptions options) {
+ public void WriteSparseString(@Nonnull final RowCursor edit, Utf8Span value, UpdateOptions options) {
int len = value.Length;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: int numBytes = len + RowBuffer.Count7BitEncodedUInt((ulong)len);
int numBytes = len + RowBuffer.count7BitEncodedUInt(len);
int metaBytes;
- Out tempOut_metaBytes = new Out();
+ final Out metaBytes = new Out<>();
int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
+ final Out spaceNeeded = new Out<>();
int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.Utf8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
+ final Out shift = new Out<>();
+ this.ensureSparse(numBytes, edit, LayoutTypes.UTF_8, TypeArgumentList.EMPTY, options, tempOut_metaBytes,
tempOut_spaceNeeded, tempOut_shift);
shift = tempOut_shift.get();
spaceNeeded = tempOut_spaceNeeded.get();
metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.Utf8, TypeArgumentList.EMPTY, metaBytes);
- int sizeLenInBytes = this.writeString(edit.get().valueOffset(), value);
+ this.writeSparseMetadata(edit, LayoutTypes.UTF_8, TypeArgumentList.EMPTY, metaBytes);
+ int sizeLenInBytes = this.writeString(edit.valueOffset(), value);
checkState(spaceNeeded == metaBytes + len + sizeLenInBytes);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
+ edit.endOffset(edit.metaOffset() + spaceNeeded.get());
+ this.buffer.writerIndex(this.length() + shift.get());
}
- public void WriteSparseTuple(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs
+ public void WriteSparseTuple(@Nonnull final RowCursor edit, LayoutScope scopeType, TypeArgumentList typeArgs
, UpdateOptions options, Out newScope) {
- int numBytes = (LayoutCode.SIZE / Byte.SIZE) * (1 + typeArgs.count()); // nulls for each element.
+ int numBytes = LayoutCode.BYTES * (1 + typeArgs.count()); // nulls for each element.
int metaBytes;
- Out tempOut_metaBytes = new Out();
+ final Out metaBytes = new Out<>();
int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
+ final Out spaceNeeded = new Out<>();
int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes,
+ final Out shift = new Out<>();
+ this.ensureSparse(numBytes, edit, scopeType, typeArgs, options, tempOut_metaBytes,
tempOut_spaceNeeded, tempOut_shift);
shift = tempOut_shift.get();
spaceNeeded = tempOut_spaceNeeded.get();
metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes);
- int valueOffset = edit.get().valueOffset();
+ this.writeSparseMetadata(edit, scopeType, typeArgs, metaBytes);
+ int valueOffset = edit.valueOffset();
for (int i = 0; i < typeArgs.count(); i++) {
this.writeSparseTypeCode(valueOffset, LayoutCode.NULL);
valueOffset += (LayoutCode.SIZE / Byte.SIZE);
@@ -805,393 +423,216 @@ public final class RowBuffer {
checkState(spaceNeeded == metaBytes + numBytes);
newScope.setAndGet(new RowCursor());
newScope.get().scopeType(scopeType);
- newScope.get().scopeTypeArgs(typeArgs.clone());
- newScope.get().start(edit.get().valueOffset());
- newScope.get().valueOffset(edit.get().valueOffset());
- newScope.get().metaOffset(edit.get().valueOffset());
- newScope.get().layout(edit.get().layout());
+ newScope.get().scopeTypeArgs(typeArgs);
+ newScope.get().start(edit.valueOffset());
+ newScope.get().valueOffset(edit.valueOffset());
+ newScope.get().metaOffset(edit.valueOffset());
+ newScope.get().layout(edit.layout());
newScope.get().count(typeArgs.count());
- this.length(this.length() + shift);
+ this.buffer.writerIndex(this.length() + shift.get());
}
- public void WriteSparseUDT(Reference edit, LayoutScope scopeType, Layout udt,
+ // TODO: DANOBLE: ressurrect this method
+ // public void WriteSparseMongoDbObjectId(@Nonnull final RowCursor edit, MongoDbObjectId value,
+ // UpdateOptions options) {
+ // int numBytes = MongoDbObjectId.Size;
+ // int metaBytes;
+ // final Out metaBytes = new Out<>();
+ // int spaceNeeded;
+ // final Out spaceNeeded = new Out<>();
+ // int shift;
+ // final Out shift = new Out<>();
+ // this.ensureSparse(numBytes, edit, MongoDbObjectId, TypeArgumentList.EMPTY, options,
+ // tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift);
+ // shift = tempOut_shift.get();
+ // spaceNeeded = tempOut_spaceNeeded.get();
+ // metaBytes = tempOut_metaBytes.get();
+ //
+ // this.writeSparseMetadata(edit, MongoDbObjectId, TypeArgumentList.EMPTY, metaBytes);
+ // this.WriteMongoDbObjectId(edit.valueOffset(), value.clone());
+ // checkState(spaceNeeded == metaBytes + MongoDbObjectId.Size);
+ // edit.endOffset(edit.metaOffset() + spaceNeeded.get());
+ // this.buffer.writerIndex(this.length() + shift);
+ // }
+
+ public void WriteSparseUDT(@Nonnull final RowCursor edit, LayoutScope scopeType, Layout udt,
UpdateOptions options, Out newScope) {
TypeArgumentList typeArgs = new TypeArgumentList(udt.schemaId().clone());
int numBytes = udt.size() + (LayoutCode.SIZE / Byte.SIZE);
int metaBytes;
- Out tempOut_metaBytes = new Out();
+ final Out metaBytes = new Out<>();
int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
+ final Out spaceNeeded = new Out<>();
int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes,
+ final Out shift = new Out<>();
+ this.ensureSparse(numBytes, edit, scopeType, typeArgs, options, tempOut_metaBytes,
tempOut_spaceNeeded, tempOut_shift);
shift = tempOut_shift.get();
spaceNeeded = tempOut_spaceNeeded.get();
metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes);
+ this.writeSparseMetadata(edit, scopeType, typeArgs, metaBytes);
// Clear all presence bits.
- this.buffer.Slice(edit.get().valueOffset(), udt.size()).Fill(0);
+ this.buffer.Slice(edit.valueOffset(), udt.size()).Fill(0);
// Write scope terminator.
- int valueOffset = edit.get().valueOffset() + udt.size();
+ int valueOffset = edit.valueOffset() + udt.size();
this.writeSparseTypeCode(valueOffset, LayoutCode.END_SCOPE);
checkState(spaceNeeded == metaBytes + numBytes);
newScope.setAndGet(new RowCursor());
newScope.get().scopeType(scopeType);
- newScope.get().scopeTypeArgs(typeArgs.clone());
- newScope.get().start(edit.get().valueOffset());
+ newScope.get().scopeTypeArgs(typeArgs);
+ newScope.get().start(edit.valueOffset());
newScope.get().valueOffset(valueOffset);
newScope.get().metaOffset(valueOffset);
newScope.get().layout(udt);
- this.length(this.length() + shift);
+ this.buffer.writerIndex(this.length() + shift.get());
}
- //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
- //ORIGINAL LINE: internal void WriteSparseUInt16(ref RowCursor edit, ushort value, UpdateOptions options)
- public void WriteSparseUInt16(Reference edit, short value, UpdateOptions options) {
- int numBytes = (Short.SIZE / Byte.SIZE);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.UInt16, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.UInt16, TypeArgumentList.EMPTY, metaBytes);
- this.writeUInt16(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + (Short.SIZE / Byte.SIZE));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
- //ORIGINAL LINE: internal void WriteSparseUInt32(ref RowCursor edit, uint value, UpdateOptions options)
- public void WriteSparseUInt32(Reference edit, int value, UpdateOptions options) {
- int numBytes = (Integer.SIZE / Byte.SIZE);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.UInt32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.UInt32, TypeArgumentList.EMPTY, metaBytes);
- this.writeUInt32(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + (Integer.SIZE / Byte.SIZE));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
- //ORIGINAL LINE: internal void WriteSparseUInt64(ref RowCursor edit, ulong value, UpdateOptions options)
- public void WriteSparseUInt64(Reference edit, long value, UpdateOptions options) {
- int numBytes = (Long.SIZE / Byte.SIZE);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.UInt64, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.UInt64, TypeArgumentList.EMPTY, metaBytes);
- this.writeUInt64(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + (Long.SIZE / Byte.SIZE));
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
- //ORIGINAL LINE: internal void WriteSparseUInt8(ref RowCursor edit, byte value, UpdateOptions options)
- public void WriteSparseUInt8(Reference edit, byte value, UpdateOptions options) {
- int numBytes = 1;
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.UInt8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.UInt8, TypeArgumentList.EMPTY, metaBytes);
- this.writeUInt8(edit.get().valueOffset(), value);
- checkState(spaceNeeded == metaBytes + 1);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseUnixDateTime(Reference edit, UnixDateTime value, UpdateOptions options) {
- int numBytes = 8;
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.UnixDateTime, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes
- , tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
-
- this.writeSparseMetadata(edit, LayoutType.UnixDateTime, TypeArgumentList.EMPTY, metaBytes);
- this.writeUnixDateTime(edit.get().valueOffset(), value.clone());
- checkState(spaceNeeded == metaBytes + 8);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteSparseVarInt(Reference edit, long value, UpdateOptions options) {
- int numBytes = RowBuffer.Count7BitEncodedInt(value);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.VarInt, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.VarInt, TypeArgumentList.EMPTY, metaBytes);
- int sizeLenInBytes = this.write7BitEncodedInt(edit.get().valueOffset(), value);
- checkState(sizeLenInBytes == numBytes);
- checkState(spaceNeeded == metaBytes + sizeLenInBytes);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
- //ORIGINAL LINE: internal void WriteSparseVarUInt(ref RowCursor edit, ulong value, UpdateOptions options)
- public void WriteSparseVarUInt(Reference edit, long value, UpdateOptions options) {
- int numBytes = RowBuffer.count7BitEncodedUInt(value);
- int metaBytes;
- Out tempOut_metaBytes = new Out();
- int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
- int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, LayoutType.VarUInt, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
- tempOut_spaceNeeded, tempOut_shift);
- shift = tempOut_shift.get();
- spaceNeeded = tempOut_spaceNeeded.get();
- metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, LayoutType.VarUInt, TypeArgumentList.EMPTY, metaBytes);
- int sizeLenInBytes = this.write7BitEncodedUInt(edit.get().valueOffset(), value);
- checkState(sizeLenInBytes == numBytes);
- checkState(spaceNeeded == metaBytes + sizeLenInBytes);
- edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
- this.length(this.length() + shift);
- }
-
- public void WriteTypedArray(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs,
+ public void WriteTypedArray(@Nonnull final RowCursor edit, LayoutScope scopeType, TypeArgumentList typeArgs,
UpdateOptions options, Out newScope) {
- int numBytes = (Integer.SIZE / Byte.SIZE);
+ int numBytes = Integer.BYTES;
int metaBytes;
- Out tempOut_metaBytes = new Out();
+ final Out metaBytes = new Out<>();
int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
+ final Out spaceNeeded = new Out<>();
int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes,
+ final Out shift = new Out<>();
+ this.ensureSparse(numBytes, edit, scopeType, typeArgs, options, tempOut_metaBytes,
tempOut_spaceNeeded, tempOut_shift);
shift = tempOut_shift.get();
spaceNeeded = tempOut_spaceNeeded.get();
metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes);
+ this.writeSparseMetadata(edit, scopeType, typeArgs, metaBytes);
checkState(spaceNeeded == metaBytes + numBytes);
- this.writeUInt32(edit.get().valueOffset(), 0);
- int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size
+ this.writeUInt32(edit.valueOffset(), 0);
+ int valueOffset = edit.valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size
newScope.setAndGet(new RowCursor());
newScope.get().scopeType(scopeType);
- newScope.get().scopeTypeArgs(typeArgs.clone());
- newScope.get().start(edit.get().valueOffset());
+ newScope.get().scopeTypeArgs(typeArgs);
+ newScope.get().start(edit.valueOffset());
newScope.get().valueOffset(valueOffset);
newScope.get().metaOffset(valueOffset);
- newScope.get().layout(edit.get().layout());
+ newScope.get().layout(edit.layout());
- this.length(this.length() + shift);
+ this.buffer.writerIndex(this.length() + shift.get());
}
- public void WriteTypedMap(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs,
+ public void WriteTypedMap(@Nonnull final RowCursor edit, LayoutScope scopeType, TypeArgumentList typeArgs,
UpdateOptions options, Out newScope) {
- int numBytes = (Integer.SIZE / Byte.SIZE); // Sized scope.
+ int numBytes = Integer.BYTES; // Sized scope.
int metaBytes;
- Out tempOut_metaBytes = new Out();
+ final Out metaBytes = new Out<>();
int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
+ final Out spaceNeeded = new Out<>();
int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes,
+ final Out shift = new Out<>();
+ this.ensureSparse(numBytes, edit, scopeType, typeArgs, options, tempOut_metaBytes,
tempOut_spaceNeeded, tempOut_shift);
shift = tempOut_shift.get();
spaceNeeded = tempOut_spaceNeeded.get();
metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes);
+ this.writeSparseMetadata(edit, scopeType, typeArgs, metaBytes);
checkState(spaceNeeded == metaBytes + numBytes);
- this.writeUInt32(edit.get().valueOffset(), 0);
- int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size
+ this.writeUInt32(edit.valueOffset(), 0);
+ int valueOffset = edit.valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size
newScope.setAndGet(new RowCursor());
newScope.get().scopeType(scopeType);
- newScope.get().scopeTypeArgs(typeArgs.clone());
- newScope.get().start(edit.get().valueOffset());
+ newScope.get().scopeTypeArgs(typeArgs);
+ newScope.get().start(edit.valueOffset());
newScope.get().valueOffset(valueOffset);
newScope.get().metaOffset(valueOffset);
- newScope.get().layout(edit.get().layout());
+ newScope.get().layout(edit.layout());
- this.length(this.length() + shift);
+ this.buffer.writerIndex(this.length() + shift.get());
}
- public void WriteTypedSet(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs,
+ public void WriteTypedSet(@Nonnull final RowCursor edit, LayoutScope scopeType, TypeArgumentList typeArgs,
UpdateOptions options, Out newScope) {
- int numBytes = (Integer.SIZE / Byte.SIZE);
+ int numBytes = Integer.BYTES;
int metaBytes;
- Out tempOut_metaBytes = new Out();
+ final Out metaBytes = new Out<>();
int spaceNeeded;
- Out tempOut_spaceNeeded = new Out();
+ final Out spaceNeeded = new Out<>();
int shift;
- Out tempOut_shift = new Out();
- this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes,
+ final Out shift = new Out<>();
+ this.ensureSparse(numBytes, edit, scopeType, typeArgs, options, tempOut_metaBytes,
tempOut_spaceNeeded, tempOut_shift);
shift = tempOut_shift.get();
spaceNeeded = tempOut_spaceNeeded.get();
metaBytes = tempOut_metaBytes.get();
- this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes);
+ this.writeSparseMetadata(edit, scopeType, typeArgs, metaBytes);
checkState(spaceNeeded == metaBytes + numBytes);
- this.writeUInt32(edit.get().valueOffset(), 0);
- int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size
+ this.writeUInt32(edit.valueOffset(), 0);
+ int valueOffset = edit.valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size
newScope.setAndGet(new RowCursor());
newScope.get().scopeType(scopeType);
- newScope.get().scopeTypeArgs(typeArgs.clone());
- newScope.get().start(edit.get().valueOffset());
+ newScope.get().scopeTypeArgs(typeArgs);
+ newScope.get().start(edit.valueOffset());
newScope.get().valueOffset(valueOffset);
newScope.get().metaOffset(valueOffset);
- newScope.get().layout(edit.get().layout());
+ newScope.get().layout(edit.layout());
- this.length(this.length() + shift);
+ this.buffer.writerIndex(this.length() + shift.get());
}
- public void WriteTypedTuple(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs,
+ public void WriteTypedTuple(@Nonnull final RowCursor edit, LayoutScope scopeType, TypeArgumentList typeArgs,
UpdateOptions options, Out newScope) {
- int numBytes = this.countDefaultValue(scopeType, typeArgs.clone());
+ int numBytes = this.countDefaultValue(scopeType, typeArgs);
int metaBytes;
- Out tempOut_metaBytes = new Out();
+ final Out