Progressed on port from dotnet to java

This commit is contained in:
David Noble
2019-09-08 01:43:33 -07:00
parent 93380aee9e
commit 7e30bf7456
65 changed files with 1551 additions and 1468 deletions

View File

@@ -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;

View File

@@ -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.

View File

@@ -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());

View File

@@ -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<RowWriter> writer, TypeArgument typeArg);
}

View File

@@ -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<TItem> ctx1) ->
Result r = reader.get().readScope(ctx.clone(), (RowReader RowReader arrayReader, ListContext<TItem> ctx1) ->
{
while (arrayReader.Read()) {
Result r2 = arrayReader.ReadScope(ctx1.clone(), (ref RowReader itemReader, ListContext<TItem> ctx2) ->

View File

@@ -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.
* <p>
* 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<RowBuffer> row, Reference<RowCursor> 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));
}

View File

@@ -214,7 +214,7 @@ public final class RowReaderJsonExtensions {
case VarInt: {
long value;
Out<Long> tempOut_value10 = new Out<Long>();
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<Long> tempOut_value11 = new Out<Long>();
//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;
}

View File

@@ -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}}.
*
* <typeparam name="TElement">The sub-element type to be written.</typeparam>
* @param <TElement> The sub-element type to be written
*/
public interface ILayoutSequenceWritable<TElement> extends ILayoutType {
Result WriteFixed(
Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, ReadOnlySequence<TElement> value);
Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn col, List<TElement> value);
Result WriteSparse(
Reference<RowBuffer> b, Reference<RowCursor> edit, ReadOnlySequence<TElement> value);
Result writeSparse(RowBuffer buffer, RowCursor edit, List<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, ReadOnlySequence<TElement> value, UpdateOptions
// options = UpdateOptions.Upsert);
Result writeSparse(RowBuffer buffer, RowCursor edit, List<TElement> value, UpdateOptions options);
Result WriteSparse(
Reference<RowBuffer> b, Reference<RowCursor> edit, ReadOnlySequence<TElement> value, UpdateOptions options);
Result WriteVariable(
Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, ReadOnlySequence<TElement> value);
Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, List<TElement> value);
}

View File

@@ -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}}
*
* <typeparam name="TElement">The sub-element type to be written.</typeparam>
* @param <TElement> The sub-element type to be written
*/
public interface ILayoutSpanReadable<TElement> extends ILayoutType {
Result ReadFixed(
Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<ReadOnlySpan<TElement>> value);
Result ReadSparse(
Reference<RowBuffer> b, Reference<RowCursor> scope, Out<ReadOnlySpan<TElement>> value);
Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<List<TElement>> value);
Result ReadVariable(
Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<ReadOnlySpan<TElement>> value);
Result readSparse(RowBuffer buffer, RowCursor scope, Out<List<TElement>> value);
Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<List<TElement>> value);
}

View File

@@ -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}}
*
* <typeparam name="TElement">The sub-element type to be written.</typeparam>
* @param <TElement> The sub-element type to be written
*/
public interface ILayoutSpanWritable<TElement> extends ILayoutType {
Result WriteFixed(
Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, ReadOnlySpan<TElement> value);
Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, List<TElement> value);
Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, ReadOnlySpan<TElement> 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<TElement> value, UpdateOptions options = UpdateOptions.Upsert);
Result writeSparse(RowBuffer buffer, RowCursor edit, List<TElement> value, UpdateOptions options);
Result WriteSparse(
Reference<RowBuffer> b, Reference<RowCursor> edit, ReadOnlySpan<TElement> value, UpdateOptions options);
Result WriteVariable(
Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, ReadOnlySpan<TElement> value);
Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, List<TElement> value);
}

View File

@@ -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<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Utf8Span> value);
Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<Utf8String> value);
Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> scope, Out<Utf8Span> value);
Result readSparse(RowBuffer buffer, RowCursor scope, Out<Utf8String> value);
Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Utf8Span> value);
Result ReadVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<Utf8String> value);
}

View File

@@ -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<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Utf8Span value);
Result writeFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Utf8String value);
Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> edit, Utf8Span value, UpdateOptions options);
Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Utf8Span value);
Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Utf8String value);
}

View File

@@ -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<RowCursor> value
) {
return this.writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
@Nonnull Out<RowCursor> 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<RowCursor> value) {
Result result = prepareSparseWrite(b, edit, this.typeArg(), options);
@Nonnull
public Result writeScope(
RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> 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;
}
}

View File

@@ -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<byte[]>, ILayoutSpanWritable<byte>,
// ILayoutSpanReadable<byte>, ILayoutSequenceWritable<byte>
public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpanWritable<Byte>,
ILayoutSpanReadable<Byte>, ILayoutSequenceWritable<Byte> {
public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpanWritable<Byte>, ILayoutSpanReadable<Byte>, ILayoutSequenceWritable<Byte> {
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<byte[]> 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<byte[]> value) {
public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<byte[]> value) {
ReadOnlySpan<Byte> 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<byte> 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<byte> 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<byte> value)
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<ReadOnlySpan<Byte>> 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<ReadOnlySpan<Byte>> 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<byte[]> value) {
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<byte[]> value) {
ReadOnlySpan<Byte> 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<byte> 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<byte> value)
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<ReadOnlySpan<Byte>> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
public Result ReadSparse(RowBuffer buffer, RowCursor edit, Out<ReadOnlySpan<Byte>> 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<byte[]> 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<byte[]> value) {
public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<byte[]> value) {
ReadOnlySpan<Byte> 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<byte> 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<byte> value)
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
, Out<ReadOnlySpan<Byte>> 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<ReadOnlySpan<Byte>> 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<byte[]> 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<byte>(value));
return this.WriteFixed(b, scope, column, new ReadOnlySpan<Byte>(value));
return this.writeFixed(buffer, scope, column, new ReadOnlySpan<Byte>(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<byte> value)
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
ReadOnlySpan<Byte> 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<Byte> 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<byte> value)
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
ReadOnlySequence<Byte> 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<Byte> 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<byte[]> 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<byte>(value), options);
return this.WriteSparse(b, edit, new ReadOnlySpan<Byte>(value), options);
return this.WriteSparse(buffer, edit, new ReadOnlySpan<Byte>(value), options);
}
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
ReadOnlySpan<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:
//ORIGINAL LINE: public Result WriteSparse(ref RowBuffer b, ref RowCursor edit, ReadOnlySpan<byte> value,
// UpdateOptions options = UpdateOptions.Upsert)
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
ReadOnlySpan<Byte> value, UpdateOptions options) {
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
public Result writeSparse(RowBuffer buffer, RowCursor edit, List<Byte> 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<RowBuffer> b, Reference<RowCursor> edit,
ReadOnlySequence<Byte> value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
public Result WriteSparse(RowBuffer b, RowCursor edit, ReadOnlySequence<Byte> value) {
return writeSparse(b, edit, value, UpdateOptions.Upsert);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public Result WriteSparse(ref RowBuffer b, ref RowCursor edit, ReadOnlySequence<byte> value,
// UpdateOptions options = UpdateOptions.Upsert)
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
ReadOnlySequence<Byte> value, UpdateOptions options) {
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
public Result WriteSparse(RowBuffer b, RowCursor edit, ReadOnlySequence<Byte> 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<byte[]> implements ILayoutSpa
//ORIGINAL LINE: public override Result WriteVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col,
// byte[] value)
@Override
public Result writeVariable(Reference<RowBuffer> b, Reference<RowCursor> 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<byte>(value));
return this.WriteVariable(b, scope, col, new ReadOnlySpan<Byte>(value));
return this.writeVariable(buffer, scope, column, new ReadOnlySpan<Byte>(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<byte> value)
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, ReadOnlySpan<Byte> value) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
public Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, List<Byte> 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<Integer> tempOut_shift = new Out<Integer>();
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<byte> value)
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, ReadOnlySequence<Byte> value) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
public Result WriteVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, ReadOnlySequence<Byte> 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<Integer> tempOut_shift = new Out<Integer>();
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;
}
}

View File

@@ -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<Boolean> {
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<Boolean> 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<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);
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<Boolean> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(
@Nonnull final RowBuffer buffer,
@Nonnull final RowCursor edit,
@Nonnull final Out<Boolean> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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);
}
}

View File

@@ -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<Byte, LayoutCode> mappings;
private static Byte2ObjectMap<LayoutCode> 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<Byte, LayoutCode>();
mappings = new Byte2ObjectOpenHashMap<>();
}
}
}

View File

@@ -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
* <p>
* 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
* <p>
* 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));
}
}

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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<Property> properties) {
private static void addProperties(LayoutBuilder builder, Namespace ns, LayoutCode scope, List<Property> properties) {
final Out<TypeArgumentList> typeArgs = new Out<>();
for (Property p : properties) {
TypeArgumentList typeArgs = new TypeArgumentList();
Out<TypeArgumentList> tempOut_typeArgs =
new Out<TypeArgumentList>();
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<TypeArgumentList> 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<TypeArgumentList> tempOut_itemTypeArgs = new Out<TypeArgumentList>();
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<TypeArgumentList> tempOut_itemTypeArgs2 = new Out<TypeArgumentList>();
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<TypeArgumentList> tempOut_keyTypeArgs = new Out<TypeArgumentList>();
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<TypeArgumentList> tempOut_valueTypeArgs = new Out<TypeArgumentList>();
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<TypeArgumentList> tempOut_itemTypeArgs3 = new Out<TypeArgumentList>();
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<TypeArgumentList> tempOut_itemTypeArgs4 = new Out<TypeArgumentList>();
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",

View File

@@ -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<DateTime> {
public final class LayoutDateTime extends LayoutType<OffsetDateTime> {
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<DateTime> {
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<LocalDateTime> 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<OffsetDateTime> 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<RowBuffer> b, Reference<RowCursor> edit,
Out<LocalDateTime> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<OffsetDateTime> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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);
}
}

View File

@@ -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<BigDecimal> {
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<BigDecimal> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<BigDecimal> 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<BigDecimal> 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<BigDecimal> 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);
}
}

View File

@@ -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<RowCursor> value) {
return writeScope(b, scope, typeArgs, UpdateOptions.Upsert, value);
@Nonnull
public Result writeScope(RowBuffer buffer, RowCursor scope, TypeArgumentList typeArgs, Out<RowCursor> 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<RowCursor> value) {
Contract.Fail("Cannot write an EndScope directly");
value.setAndGet(null);
@Nonnull
public Result writeScope(RowBuffer buffer, RowCursor scope, TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
assert false : "cannot write an EndScope directly";
value.set(null);
return Result.FAILURE;
}
}

View File

@@ -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<com.azure.data.cosmos.serialization.hybridrow.Float128> {
public final class LayoutFloat128 extends LayoutType<Float128> {
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<com.azure.data.cosmos.seria
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<Float128> 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<Float128> 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<Float128> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<Float128> 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);
}
}
}

View File

@@ -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<Float> {
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<Float> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<Float> 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<Float> 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<Float> value) {
Result result = prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<Float> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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);
}
}

View File

@@ -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<Double> {
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<Double> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<Double> 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<Double> 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<Double> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<Double> 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<RowBuffer> b, Reference<RowCursor> 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<Double> {
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, double value,
// UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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);
}
}

View File

@@ -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<UUID> {
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<UUID> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<UUID> 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<UUID> 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<UUID> value) {
Result result = prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<UUID> 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);
}
}

View File

@@ -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<Short> {
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<Short> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<Short> 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<Short> 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<Short> value) {
Result result = prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<Short> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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);
}
}

View File

@@ -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<Integer> {
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<Integer> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<Integer> 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<Integer> 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<Integer> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<Integer> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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);
}
}

View File

@@ -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<Long> {
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<Long> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<Long> 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<Long> 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<Long> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<Long> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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);
}
}

View File

@@ -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<Byte> {
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<Byte> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<Byte> 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<Byte> 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<Byte> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
@Nonnull
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<Byte> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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);
}
}

View File

@@ -25,41 +25,41 @@ public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column,
Out<MongoDbObjectId> 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<MongoDbObjectId> 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<MongoDbObjectId> {
//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);
}
}

View File

@@ -29,11 +29,11 @@ public final class LayoutNull extends LayoutType<NullValue> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column,
Out<NullValue> 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<NullValue> {
}
@Override
public Result readSparse(RowBuffer b, RowCursor edit,
public Result readSparse(RowBuffer buffer, RowCursor edit,
Out<NullValue> 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<NullValue> {
//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);
}
}

View File

@@ -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<RowCursor> 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<RowCursor> value) {
return this.WriteScope(b, edit, typeArgs.clone(), true, value, options);
return this.WriteScope(buffer, edit, typeArgs.clone(), true, value, options);
}
@Override

View File

@@ -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<RowCursor> 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<RowCursor> 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;
}
}

View File

@@ -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);
}
}

View File

@@ -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}.
* <p>
* <p>
* 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.
* <p>
* 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;

View File

@@ -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<SchemaId, Layout> resolver;
public LayoutResolverSimple(tangible.Func1Param<SchemaId, Layout> 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);
}
}

View File

@@ -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<RowCursor> value) {
@Nonnull final RowBuffer buffer, @Nonnull final RowCursor edit, @Nonnull final Out<RowCursor> 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<RowCursor> value);
@Nonnull
public abstract Result writeScope(
RowBuffer b,
RowBuffer buffer,
RowCursor scope,
TypeArgumentList typeArgs,
UpdateOptions options, Out<RowCursor> value);
@Nonnull
public <TContext> Result writeScope(
RowBuffer b,
RowBuffer buffer,
RowCursor scope,
TypeArgumentList typeArgs,
TContext context, WriterFunc<TContext> 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<TContext>(ref RowBuffer b, ref RowCursor scope,
// TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func, UpdateOptions options = UpdateOptions
// .Upsert)
@Nonnull
public <TContext> Result writeScope(
RowBuffer b,
RowCursor scope,
TypeArgumentList typeArgs,
TContext context, WriterFunc<TContext> func, UpdateOptions options) {
@Nonnull final RowBuffer buffer,
@Nonnull final RowCursor scope,
@Nonnull final TypeArgumentList typeArgs,
@Nullable TContext context,
@Nullable WriterFunc<TContext> func,
@Nonnull UpdateOptions options) {
final Out<RowCursor> 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}.
* <typeparam name="TContext">The type of the context value passed by the caller.</typeparam>
* 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 <TContext> The type of the context value passed by the caller
*/
@FunctionalInterface
public interface WriterFunc<TContext> {
@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);
}
}

View File

@@ -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<RowCursor> 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<RowBuffer> row, int offset,
Out<Integer> 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<Integer> 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<RowCursor> value) {
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
@Nonnull
public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out<RowCursor> 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<RowCursor> 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<RowCursor> 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<RowBuffer> 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;
}
}

View File

@@ -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<RowCursor> 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<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
lenInBytes.setAndGet(0);
@Nonnull
public TypeArgumentList readTypeArgumentList(RowBuffer buffer, int offset, Out<Integer> 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<Integer> tempOut_itemLenInBytes = new Out<Integer>();
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<RowCursor> value) {
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
@Nonnull
public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out<RowCursor> 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<RowCursor> 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<RowCursor> 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<RowBuffer> 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;

View File

@@ -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<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes);
public TypeArgumentList readTypeArgumentList(RowBuffer buffer, int offset, Out<Integer> lenInBytes) {
int numTypeArgs = buffer.intValue().Read7BitEncodedUInt(offset, lenInBytes);
TypeArgument[] retval = new TypeArgument[numTypeArgs];
for (int i = 0; i < numTypeArgs; i++) {
int itemLenInBytes;
Out<Integer> tempOut_itemLenInBytes = new Out<Integer>();
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<RowCursor> value) {
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, Out<RowCursor> 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<RowCursor> value) {
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
public Result writeScope(RowBuffer buffer, RowCursor edit, TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> 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<RowBuffer> 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;

View File

@@ -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<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T> implements ILayoutType {
return Result.SUCCESS;
}
public abstract Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column, Out<T> value);
@Nonnull
public abstract Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<T> value);
public abstract Result readSparse(RowBuffer b, RowCursor edit, Out<T> value);
@Nonnull
public abstract Result readSparse(RowBuffer buffer, RowCursor edit, Out<T> value);
public static TypeArgument readTypeArgument(RowBuffer row, int offset, Out<Integer> lenInBytes) {
LayoutType itemCode = row.readSparseTypeCode(offset);
@@ -370,8 +374,9 @@ public abstract class LayoutType<T> implements ILayoutType {
return TypeArgumentList.EMPTY;
}
public Result readVariable(RowBuffer b, RowCursor scope, LayoutColumn column, Out<T> value) {
value.setAndGet(null);
@Nonnull
public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<T> value) {
value.set(null);
return Result.FAILURE;
}
@@ -390,18 +395,22 @@ public abstract class LayoutType<T> 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<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, T value) {
@Nonnull
public Result writeVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, T value) {
return Result.FAILURE;
}

View File

@@ -28,7 +28,7 @@ public final class LayoutTypedArray extends LayoutIndexedScope {
public boolean HasImplicitTypeCode(Reference<RowCursor> 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<RowCursor> 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<RowCursor> 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;
}

View File

@@ -31,7 +31,7 @@ public final class LayoutTypedMap extends LayoutUniqueScope {
}
@Override
public TypeArgument FieldType(Reference<RowCursor> 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<RowCursor> 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<RowCursor> 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;
}

View File

@@ -27,7 +27,7 @@ public final class LayoutTypedSet extends LayoutUniqueScope {
}
@Override
public TypeArgument FieldType(Reference<RowCursor> 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<RowCursor> 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<RowCursor> 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<RowCursor> 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;
}

View File

@@ -37,7 +37,7 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
public boolean HasImplicitTypeCode(Reference<RowCursor> 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<RowCursor> 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<RowCursor> 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;
}

View File

@@ -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();

View File

@@ -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<RowCursor> 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<RowCursor> 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;
}

View File

@@ -30,30 +30,30 @@ public final class LayoutUInt16 extends LayoutType<Short> {
//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<Short> 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<Short> 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;
}

View File

@@ -30,30 +30,30 @@ public final class LayoutUInt32 extends LayoutType<Integer> {
//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<Integer> 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<Integer> 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;
}

View File

@@ -30,30 +30,30 @@ public final class LayoutUInt64 extends LayoutType<Long> {
//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<Long> 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<Long> 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;
}

View File

@@ -30,30 +30,30 @@ public final class LayoutUInt8 extends LayoutType<Byte> {
//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<Byte> 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<Byte> 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;
}

View File

@@ -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<RowCursor> scope);
public abstract TypeArgument fieldType(RowCursor scope);
/**
* Search for a matching field within a unique index.
* <p>
* 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.
* <p>
* 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<RowBuffer> b, Reference<RowCursor> scope,
Reference<RowCursor> patternScope, Out<RowCursor> 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<RowCursor> 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<RowBuffer> b, Reference<RowCursor> destinationScope,
Reference<RowCursor> sourceEdit, UpdateOptions options) {
RowCursor dstEdit;
Out<RowCursor> tempOut_dstEdit =
new Out<RowCursor>();
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.
* <p>
* 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<RowCursor> 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<RowCursor> tempReference_dstEdit =
new Reference<RowCursor>(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.
* <p>
* 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 {
* <para />
* The source field is delete whether the move succeeds or fails.
*/
public final Result MoveField(Reference<RowBuffer> b, Reference<RowCursor> destinationScope,
Reference<RowCursor> 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<TContext>(ref RowBuffer b, ref RowCursor scope,
// TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func, UpdateOptions options = UpdateOptions
// .Upsert)
@Override
public <TContext> Result writeScope(RowBuffer b, RowCursor scope,
TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> 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 <TContext> Result writeScope(
@Nonnull final RowBuffer buffer,
@Nonnull final RowCursor scope,
@Nonnull final TypeArgumentList typeArgs,
@Nullable final TContext context,
@Nullable final WriterFunc<TContext> 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<RowCursor> 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<RowCursor> tempReference_childScope =
new Reference<RowCursor>(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<RowCursor> tempReference_uniqueScope =
new Reference<RowCursor>(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<RowCursor> tempReference_childScope2 =
new Reference<RowCursor>(childScope);
RowCursors.skip(scope.get().clone(), b,
tempReference_childScope2);
childScope = tempReference_childScope2.get();
RowCursors.skip(scope, buffer, childScope);
return Result.SUCCESS;
}
@Override
public <TContext> Result writeScope(RowBuffer b, RowCursor scope,
TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func) {
return writeScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert);
@Nonnull
public <TContext> Result writeScope(
RowBuffer buffer, RowCursor scope, TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func) {
return this.writeScope(buffer, scope, typeArgs, context, func, UpdateOptions.Upsert);
}
}

View File

@@ -26,41 +26,41 @@ public final class LayoutUnixDateTime extends LayoutType<com.azure.data.cosmos.s
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column,
Out<UnixDateTime> 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<UnixDateTime> 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<com.azure.data.cosmos.s
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, UnixDateTime value,
// UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result writeSparse(RowBuffer b, RowCursor edit, UnixDateTime value
public Result writeSparse(RowBuffer buffer, RowCursor edit, UnixDateTime 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().WriteSparseUnixDateTime(edit, value.clone(), options);
buffer.get().WriteSparseUnixDateTime(edit, value.clone(), options);
return Result.SUCCESS;
}
@Override
public Result writeSparse(RowBuffer b, RowCursor edit, UnixDateTime value) {
return writeSparse(b, edit, value, UpdateOptions.Upsert);
public Result writeSparse(RowBuffer buffer, RowCursor edit, UnixDateTime value) {
return writeSparse(buffer, edit, value, UpdateOptions.Upsert);
}
}

View File

@@ -5,6 +5,7 @@ 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;
@@ -25,37 +26,36 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
Out<String> value) {
public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<String> 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<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn column,
Out<Utf8Span> 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<String> 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<String> implements ILayoutUtf8S
}
@Override
public Result readVariable(RowBuffer b, RowCursor scope, LayoutColumn column
public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column
, Out<String> 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<String> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<RowBuffer> b, Reference<RowCursor> 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<Integer> tempOut_shift = new Out<Integer>();
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;

View File

@@ -29,7 +29,7 @@ public final class LayoutVarInt extends LayoutType<Long> {
}
@Override
public Result readFixed(RowBuffer b, RowCursor scope, LayoutColumn column,
public Result readFixed(RowBuffer buffer, RowCursor scope, LayoutColumn column,
Out<Long> value) {
Contract.Fail("Not Implemented");
value.setAndGet(0);
@@ -37,28 +37,28 @@ public final class LayoutVarInt extends LayoutType<Long> {
}
@Override
public Result readSparse(RowBuffer b, RowCursor edit, Out<Long> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<Long> 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<Long> value) {
public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<Long> 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;
}

View File

@@ -34,7 +34,7 @@ public final class LayoutVarUInt extends LayoutType<Long> {
//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<Long> value) {
Contract.Fail("Not Implemented");
value.setAndGet(0);
@@ -44,14 +44,14 @@ public final class LayoutVarUInt extends LayoutType<Long> {
//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<Long> value) {
Result result = prepareSparseRead(b, edit, this.LayoutCode);
public Result readSparse(RowBuffer buffer, RowCursor edit, Out<Long> 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<Long> {
//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<Long> value) {
public Result readVariable(RowBuffer buffer, RowCursor scope, LayoutColumn column, Out<Long> 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;
}

View File

@@ -50,7 +50,7 @@ public final class SegmentSerializer {
break;
case "comment":
Out<String> tempOut_Comment = new Out<String>();
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<String> tempOut_SDL = new Out<String>();
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;

View File

@@ -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:

View File

@@ -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.

View File

@@ -245,7 +245,7 @@ public final class RowReaderUnitTests {
assert rowReader.read();
Reference<RowReader> tempReference_nestedScope2 =
new Reference<RowReader>(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<RowReader>(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<RowReader> tempReference_nested2 =
new Reference<RowReader>(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<RowReader>(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<RowReader> tempReference_nested4 = new Reference<RowReader>(nested);
ResultAssert.IsSuccess(reader.get().SkipScope(tempReference_nested4));
ResultAssert.IsSuccess(reader.get().skipScope(tempReference_nested4));
nested = tempReference_nested4.get();
break;
}

View File

@@ -155,8 +155,8 @@ public final class SerializerUnitTest {
Out<BatchRequestHeaders> tempOut_Headers = new Out<BatchRequestHeaders>();
// 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<String> tempOut_ResourcePath = new Out<String>();
r = reader.get().ReadString(tempOut_ResourcePath);
r = reader.get().readString(tempOut_ResourcePath);
retval.ResourcePath = tempOut_ResourcePath.get();
if (r != Result.SUCCESS) {
return r;

View File

@@ -17,7 +17,7 @@ public final class AddressSerializer {
switch (reader.get().path()) {
case "street":
Out<String> tempOut_Street = new Out<String>();
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<String> tempOut_City = new Out<String>();
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<String> tempOut_State = new Out<String>();
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<RowReader>(child);
Out<PostalCode> tempOut_PostalCode = new Out<PostalCode>();
// 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();