mirror of
https://github.com/microsoft/HybridRow.git
synced 2026-01-21 02:13:18 +00:00
Progressed on port from dotnet to java
This commit is contained in:
36
jre/pom.xml
36
jre/pom.xml
@@ -37,18 +37,48 @@ Licensed under the MIT License.
|
||||
<test.groups>unit</test.groups>
|
||||
<javadoc.opts/>
|
||||
<guava.version>27.0.1-jre</guava.version>
|
||||
<jackson.version>2.9.9</jackson.version>
|
||||
<mockito.version>1.10.19</mockito.version>
|
||||
<mongodb.version>3.11.0</mongodb.version>
|
||||
<netty.version>4.1.39.Final</netty.version>
|
||||
<protobuf.version>3.9.1</protobuf.version>
|
||||
<slf4j.version>1.7.28</slf4j.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>${protobuf.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
<version>${protobuf.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-buffer</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
@@ -63,6 +93,12 @@ Licensed under the MIT License.
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.internal;
|
||||
|
||||
import Newtonsoft.Json.*;
|
||||
|
||||
/**
|
||||
* Helper class for parsing <see cref="Utf8String" /> from JSON.
|
||||
*/
|
||||
public class Utf8StringJsonConverter extends JsonConverter {
|
||||
@Override
|
||||
public boolean getCanWrite() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanConvert(java.lang.Class objectType) {
|
||||
return objectType.isAssignableFrom(Utf8String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue,
|
||||
JsonSerializer serializer) {
|
||||
Contract.Requires(reader.TokenType == JsonToken.String);
|
||||
return Utf8String.TranscodeUtf16((String)reader.Value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) {
|
||||
writer.WriteValue(((Utf8String)value).toString());
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
/**
|
||||
* An optional interface that indicates a <see cref="LayoutType{T}" /> can also read using a
|
||||
* <see cref="ReadOnlySpan{T}" />.
|
||||
*
|
||||
* <typeparam name="TElement">The sub-element type to be written.</typeparam>
|
||||
*/
|
||||
public interface ILayoutSpanReadable<TElement> extends ILayoutType {
|
||||
Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<ReadOnlySpan<TElement>> value);
|
||||
|
||||
Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
tangible.OutObject<ReadOnlySpan<TElement>> value);
|
||||
|
||||
Result ReadVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<ReadOnlySpan<TElement>> value);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
/**
|
||||
* An optional interface that indicates a <see cref="LayoutType{T}" /> can also read using a
|
||||
* <see cref="Utf8Span" />.
|
||||
*/
|
||||
public interface ILayoutUtf8SpanReadable extends ILayoutType {
|
||||
Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Utf8Span> value);
|
||||
|
||||
Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, tangible.OutObject<Utf8Span> value);
|
||||
|
||||
Result ReadVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Utf8Span> value);
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutDateTime extends LayoutType<DateTime> {
|
||||
public LayoutDateTime() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.DateTime, 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "datetime";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<LocalDateTime> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = LocalDateTime.MIN;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadDateTime(scope.argValue.start + col.getOffset());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<LocalDateTime> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = LocalDateTime.MIN;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseDateTime(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
LocalDateTime value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteDateTime(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, DateTime value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
LocalDateTime value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseDateTime(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, DateTime value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
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(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Decimal, sizeof(BigDecimal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "decimal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<BigDecimal> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = new BigDecimal(0);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadDecimal(scope.argValue.start + col.getOffset());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<BigDecimal> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = new BigDecimal(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseDecimal(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
BigDecimal value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteDecimal(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.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, decimal value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, BigDecimal value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseDecimal(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
java.math.BigDecimal value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Float128;
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutFloat128 extends LayoutType<Float128> {
|
||||
public LayoutFloat128() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Float128, HybridRow.Float128.Size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "float128";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Float128> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = null;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadFloat128(scope.argValue.start + col.getOffset()).clone();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<Float128> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseFloat128(edit).clone();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Float128 value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteFloat128(scope.argValue.start + col.getOffset(), value.clone());
|
||||
b.argValue.SetBit(scope.argValue.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, Float128 value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, Float128 value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseFloat128(edit, value.clone(), options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, Float128 value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutFloat32 extends LayoutType<Float> {
|
||||
public LayoutFloat32() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Float32, (Float.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "float32";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Float> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = 0;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadFloat32(scope.argValue.start + col.getOffset());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<Float> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseFloat32(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
float value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteFloat32(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.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, float value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, float value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseFloat32(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, float value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutFloat64 extends LayoutType<Double> {
|
||||
public LayoutFloat64() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Float64, (Double.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "float64";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Double> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = 0;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadFloat64(scope.argValue.start + col.getOffset());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<Double> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseFloat64(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
double value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteFloat64(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.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, double value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, double value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseFloat64(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, double value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutGuid extends LayoutType<UUID> {
|
||||
public LayoutGuid() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Guid, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "guid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<UUID> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = null;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadGuid(scope.argValue.start + col.getOffset());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<UUID> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseGuid(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
UUID value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteGuid(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.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, Guid value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, UUID value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseGuid(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
java.util.UUID value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
public abstract class LayoutIndexedScope extends LayoutScope {
|
||||
protected LayoutIndexedScope(LayoutCode code, boolean immutable, boolean isSizedScope, boolean isFixedArity,
|
||||
boolean isUniqueScope, 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, isIndexedScope: true, isFixedArity: isFixedArity,
|
||||
// isUniqueScope: isUniqueScope, isTypedScope: isTypedScope);
|
||||
super(code, immutable, isSizedScope, isIndexedScope:true, isFixedArity:isFixedArity, isUniqueScope:
|
||||
isUniqueScope, isTypedScope:isTypedScope)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ReadSparsePath(tangible.RefObject<RowBuffer> row, tangible.RefObject<RowCursor> edit) {
|
||||
edit.argValue.pathToken = 0;
|
||||
edit.argValue.pathOffset = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutInt16 extends LayoutType<Short> {
|
||||
public LayoutInt16() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int16, (Short.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "int16";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Short> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = 0;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadInt16(scope.argValue.start + col.getOffset());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<Short> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseInt16(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
short value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteInt16(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.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, short value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, short value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseInt16(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, short value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutInt32 extends LayoutType<Integer> {
|
||||
public LayoutInt32() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int32, (Integer.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "int32";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Integer> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = 0;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadInt32(scope.argValue.start + col.getOffset());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<Integer> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseInt32(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
int value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteInt32(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.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, int value, UpdateOptions
|
||||
// options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, int value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseInt32(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, int value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutInt64 extends LayoutType<Long> {
|
||||
public LayoutInt64() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int64, (Long.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "int64";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Long> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = 0;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadInt64(scope.argValue.start + col.getOffset());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<Long> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseInt64(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
long value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteInt64(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.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, long value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, long value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseInt64(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, long value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutInt8 extends LayoutType<Byte> {
|
||||
public LayoutInt8() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int8, (Byte.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "int8";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Byte> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = 0;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadInt8(scope.argValue.start + col.getOffset());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<Byte> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseInt8(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
byte value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteInt8(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.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, sbyte value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, byte value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseInt8(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, byte value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> {
|
||||
public LayoutMongoDbObjectId() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.MongoDbObjectId, Microsoft.Azure.Cosmos.Serialization.HybridRow.MongoDbObjectId.Size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
@Override
|
||||
public String getName() {
|
||||
return "mongodbobjectid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<MongoDbObjectId> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = null;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadMongoDbObjectId(scope.argValue.start + col.getOffset()).clone();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<MongoDbObjectId> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseMongoDbObjectId(edit).clone();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
MongoDbObjectId value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteMongoDbObjectId(scope.argValue.start + col.getOffset(), value.clone());
|
||||
b.argValue.SetBit(scope.argValue.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, MongoDbObjectId value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
MongoDbObjectId value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseMongoDbObjectId(edit, value.clone(), options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
MongoDbObjectId value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.NullValue;
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutNull extends LayoutType<NullValue> {
|
||||
public LayoutNull() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Null, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsNull() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<NullValue> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
value.argValue = NullValue.Default;
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<NullValue> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseNull(edit).clone();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
NullValue value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.SetBit(scope.argValue.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, NullValue value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, NullValue value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseNull(edit, value.clone(), options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, NullValue value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableNullableScope;
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.NullableScope;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
public final class LayoutNullable extends LayoutIndexedScope {
|
||||
public LayoutNullable(boolean immutable) {
|
||||
super(immutable ? ImmutableNullableScope : NullableScope, immutable, true, true, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_nullable" : "nullable";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 1);
|
||||
return (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
checkState(edit.argValue.index >= 0);
|
||||
checkState(edit.argValue.scopeTypeArgs.getCount() == 1);
|
||||
checkState(edit.argValue.index == 1);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.argValue.scopeTypeArgs.get(0).getType().LayoutCode);
|
||||
}
|
||||
|
||||
public static Result HasValue(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutNullable);
|
||||
checkState(scope.argValue.index == 1 || scope.argValue.index == 2, "Nullable scopes always point at the value");
|
||||
checkState(scope.argValue.scopeTypeArgs.getCount() == 1);
|
||||
boolean hasValue = b.argValue.ReadInt8(scope.argValue.start) != 0;
|
||||
return hasValue ? Result.Success : Result.NotFound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset,
|
||||
tangible.OutObject<Integer> lenInBytes) {
|
||||
return new TypeArgumentList(new azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
checkState(edit.argValue.index == 1);
|
||||
edit.argValue.cellType = edit.argValue.scopeTypeArgs.get(0).getType();
|
||||
edit.argValue.cellTypeArgs = edit.argValue.scopeTypeArgs.get(0).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, boolean hasValue, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, hasValue, value, UpdateOptions.Upsert);
|
||||
}
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: public Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList typeArgs, bool
|
||||
// hasValue, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, boolean hasValue, tangible.OutObject<RowCursor> value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteNullable(edit, this, typeArgs.clone(), options, hasValue, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
return this.WriteScope(b, edit, typeArgs.clone(), true, value, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
checkState(value.getCount() == 1);
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes,
|
||||
value.get(0).getTypeArgs().clone());
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTaggedScope;
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TaggedScope;
|
||||
|
||||
public final class LayoutTagged extends LayoutIndexedScope {
|
||||
public LayoutTagged(boolean immutable) {
|
||||
super(immutable ? ImmutableTaggedScope : TaggedScope, immutable, true, true, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_tagged_t" : "tagged_t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 2);
|
||||
return (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(1).getType().CountTypeArgument(value.get(1).getTypeArgs().clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
Contract.Assert(edit.argValue.index >= 0);
|
||||
Contract.Assert(edit.argValue.scopeTypeArgs.getCount() > edit.argValue.index);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.argValue.scopeTypeArgs.get(edit.argValue.index).getType().LayoutCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset,
|
||||
tangible.OutObject<Integer> lenInBytes) {
|
||||
TypeArgument[] retval = new TypeArgument[2];
|
||||
retval[0] = new TypeArgument(LayoutType.UInt8, TypeArgumentList.Empty);
|
||||
retval[1] = LayoutType.ReadTypeArgument(row, offset, lenInBytes);
|
||||
return new TypeArgumentList(retval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
edit.argValue.cellType = edit.argValue.scopeTypeArgs.get(edit.argValue.index).getType();
|
||||
edit.argValue.cellTypeArgs = edit.argValue.scopeTypeArgs.get(edit.argValue.index).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteTypedTuple(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
Contract.Assert(value.getCount() == 2);
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
lenInBytes += value.get(1).getType().WriteTypeArgument(row, offset + lenInBytes,
|
||||
value.get(1).getTypeArgs().clone());
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
public final class LayoutTagged2 extends LayoutIndexedScope {
|
||||
public LayoutTagged2(boolean immutable) {
|
||||
super(immutable ? azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTagged2Scope : azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Tagged2Scope, immutable, isSizedScope:
|
||||
true, isFixedArity:true, isUniqueScope:false, isTypedScope:true)
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_tagged2_t" : "tagged2_t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 3);
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
for (int i = 1; i < value.getCount(); i++) {
|
||||
TypeArgument arg = value.get(i).clone();
|
||||
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
checkState(edit.argValue.index >= 0);
|
||||
checkState(edit.argValue.scopeTypeArgs.getCount() > edit.argValue.index);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.argValue.scopeTypeArgs.get(edit.argValue.index).getType().LayoutCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset,
|
||||
tangible.OutObject<Integer> lenInBytes) {
|
||||
lenInBytes.argValue = 0;
|
||||
TypeArgument[] retval = new TypeArgument[3];
|
||||
retval[0] = new TypeArgument(LayoutType.UInt8, TypeArgumentList.Empty);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
int itemLenInBytes;
|
||||
tangible.OutObject<Integer> tempOut_itemLenInBytes = new tangible.OutObject<Integer>();
|
||||
retval[i] = LayoutType.ReadTypeArgument(row, offset + lenInBytes.argValue, tempOut_itemLenInBytes);
|
||||
itemLenInBytes = tempOut_itemLenInBytes.argValue;
|
||||
lenInBytes.argValue += itemLenInBytes;
|
||||
}
|
||||
|
||||
return new TypeArgumentList(retval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
edit.argValue.cellType = edit.argValue.scopeTypeArgs.get(edit.argValue.index).getType();
|
||||
edit.argValue.cellTypeArgs = edit.argValue.scopeTypeArgs.get(edit.argValue.index).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteTypedTuple(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
checkState(value.getCount() == 3);
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
for (int i = 1; i < value.getCount(); i++) {
|
||||
TypeArgument arg = value.get(i).clone();
|
||||
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
public final class LayoutTuple extends LayoutIndexedScope {
|
||||
public LayoutTuple(boolean immutable) {
|
||||
super(immutable ? azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTupleScope : azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TupleScope, immutable, isSizedScope:
|
||||
false, isFixedArity:true, isUniqueScope:false, isTypedScope:false)
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_tuple" : "tuple";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count);
|
||||
lenInBytes += RowBuffer.Count7BitEncodedUInt(value.getCount());
|
||||
for (TypeArgument arg : value) {
|
||||
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset,
|
||||
tangible.OutObject<Integer> lenInBytes) {
|
||||
int numTypeArgs = row.argValue.intValue().Read7BitEncodedUInt(offset, lenInBytes);
|
||||
TypeArgument[] retval = new TypeArgument[numTypeArgs];
|
||||
for (int i = 0; i < numTypeArgs; i++) {
|
||||
int itemLenInBytes;
|
||||
tangible.OutObject<Integer> tempOut_itemLenInBytes = new tangible.OutObject<Integer>();
|
||||
retval[i] = LayoutType.ReadTypeArgument(row, offset + lenInBytes.argValue, tempOut_itemLenInBytes);
|
||||
itemLenInBytes = tempOut_itemLenInBytes.argValue;
|
||||
lenInBytes.argValue += itemLenInBytes;
|
||||
}
|
||||
|
||||
return new TypeArgumentList(retval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseTuple(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: lenInBytes += row.Write7BitEncodedUInt(offset + lenInBytes, (ulong)value.Count);
|
||||
lenInBytes += row.argValue.Write7BitEncodedUInt(offset + lenInBytes, value.getCount());
|
||||
for (TypeArgument arg : value) {
|
||||
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedArrayScope;
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE;
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedArrayScope;
|
||||
|
||||
public final class LayoutTypedArray extends LayoutIndexedScope {
|
||||
public LayoutTypedArray(boolean immutable) {
|
||||
super(immutable ? ImmutableTypedArrayScope : TypedArrayScope, immutable, true, false, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_array_t" : "array_t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 1);
|
||||
return (SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
checkState(edit.argValue.index >= 0);
|
||||
checkState(edit.argValue.scopeTypeArgs.getCount() == 1);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.argValue.scopeTypeArgs.get(0).getType().LayoutCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset,
|
||||
tangible.OutObject<Integer> lenInBytes) {
|
||||
return new TypeArgumentList(new azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
edit.argValue.cellType = edit.argValue.scopeTypeArgs.get(0).getType();
|
||||
edit.argValue.cellTypeArgs = edit.argValue.scopeTypeArgs.get(0).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteTypedArray(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
checkState(value.getCount() == 1);
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (SIZE / Byte.SIZE);
|
||||
lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes,
|
||||
value.get(0).getTypeArgs().clone());
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
public final class LayoutTypedMap extends LayoutUniqueScope {
|
||||
public LayoutTypedMap(boolean immutable) {
|
||||
super(immutable ? azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedMapScope : azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedMapScope, immutable, isSizedScope:
|
||||
true, isTypedScope:true)
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_map_t" : "map_t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 2);
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
for (TypeArgument arg : value) {
|
||||
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgument FieldType(tangible.RefObject<RowCursor> scope) {
|
||||
return new TypeArgument(scope.argValue.scopeType.Immutable ? LayoutType.ImmutableTypedTuple :
|
||||
LayoutType.TypedTuple, scope.argValue.scopeTypeArgs.clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset,
|
||||
tangible.OutObject<Integer> lenInBytes) {
|
||||
lenInBytes.argValue = 0;
|
||||
TypeArgument[] retval = new TypeArgument[2];
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int itemLenInBytes;
|
||||
tangible.OutObject<Integer> tempOut_itemLenInBytes = new tangible.OutObject<Integer>();
|
||||
retval[i] = LayoutType.ReadTypeArgument(row, offset + lenInBytes.argValue, tempOut_itemLenInBytes);
|
||||
itemLenInBytes = tempOut_itemLenInBytes.argValue;
|
||||
lenInBytes.argValue += itemLenInBytes;
|
||||
}
|
||||
|
||||
return new TypeArgumentList(retval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
edit.argValue.cellType = edit.argValue.scopeType.Immutable ? LayoutType.ImmutableTypedTuple :
|
||||
LayoutType.TypedTuple;
|
||||
edit.argValue.cellTypeArgs = edit.argValue.scopeTypeArgs.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteTypedMap(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
checkState(value.getCount() == 2);
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
for (TypeArgument arg : value) {
|
||||
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedSetScope;
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedSetScope;
|
||||
|
||||
public final class LayoutTypedSet extends LayoutUniqueScope {
|
||||
public LayoutTypedSet(boolean immutable) {
|
||||
super(immutable ? ImmutableTypedSetScope : TypedSetScope, immutable, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_set_t" : "set_t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 1);
|
||||
return (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgument FieldType(tangible.RefObject<RowCursor> scope) {
|
||||
return scope.argValue.scopeTypeArgs.get(0).clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
checkState(edit.argValue.index >= 0);
|
||||
checkState(edit.argValue.scopeTypeArgs.getCount() == 1);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.argValue.scopeTypeArgs.get(0).getType().LayoutCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset,
|
||||
tangible.OutObject<Integer> lenInBytes) {
|
||||
return new TypeArgumentList(new azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
edit.argValue.cellType = edit.argValue.scopeTypeArgs.get(0).getType();
|
||||
edit.argValue.cellTypeArgs = edit.argValue.scopeTypeArgs.get(0).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteTypedSet(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
Contract.Assert(value.getCount() == 1);
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes,
|
||||
value.get(0).getTypeArgs().clone());
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
public final class LayoutTypedTuple extends LayoutIndexedScope {
|
||||
public LayoutTypedTuple(boolean immutable) {
|
||||
super(immutable ? azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedTupleScope : azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedTupleScope, immutable, isSizedScope:
|
||||
true, isFixedArity:true, isUniqueScope:false, isTypedScope:true)
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_tuple_t" : "tuple_t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count);
|
||||
lenInBytes += RowBuffer.Count7BitEncodedUInt(value.getCount());
|
||||
for (TypeArgument arg : value) {
|
||||
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
Contract.Assert(edit.argValue.index >= 0);
|
||||
Contract.Assert(edit.argValue.scopeTypeArgs.getCount() > edit.argValue.index);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.argValue.scopeTypeArgs.get(edit.argValue.index).getType().LayoutCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset,
|
||||
tangible.OutObject<Integer> lenInBytes) {
|
||||
int numTypeArgs = row.argValue.intValue().Read7BitEncodedUInt(offset, lenInBytes);
|
||||
TypeArgument[] retval = new TypeArgument[numTypeArgs];
|
||||
for (int i = 0; i < numTypeArgs; i++) {
|
||||
int itemLenInBytes;
|
||||
tangible.OutObject<Integer> tempOut_itemLenInBytes = new tangible.OutObject<Integer>();
|
||||
retval[i] = LayoutType.ReadTypeArgument(row, offset + lenInBytes.argValue, tempOut_itemLenInBytes);
|
||||
itemLenInBytes = tempOut_itemLenInBytes.argValue;
|
||||
lenInBytes.argValue += itemLenInBytes;
|
||||
}
|
||||
|
||||
return new TypeArgumentList(retval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
edit.argValue.cellType = edit.argValue.scopeTypeArgs.get(edit.argValue.index).getType();
|
||||
edit.argValue.cellTypeArgs = edit.argValue.scopeTypeArgs.get(edit.argValue.index).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteTypedTuple(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: lenInBytes += row.Write7BitEncodedUInt(offset + lenInBytes, (ulong)value.Count);
|
||||
lenInBytes += row.argValue.Write7BitEncodedUInt(offset + lenInBytes, value.getCount());
|
||||
for (TypeArgument arg : value) {
|
||||
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
|
||||
public final class LayoutUDT extends LayoutPropertyScope {
|
||||
public LayoutUDT(boolean immutable) {
|
||||
super(immutable ? azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableSchema : azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Schema, immutable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_udt" : "udt";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
return (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.Size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset,
|
||||
tangible.OutObject<Integer> lenInBytes) {
|
||||
SchemaId schemaId = row.argValue.ReadSchemaId(offset).clone();
|
||||
lenInBytes.argValue = SchemaId.Size;
|
||||
return new TypeArgumentList(schemaId.clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Layout udt = b.argValue.getResolver().Resolve(typeArgs.getSchemaId().clone());
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseUDT(edit, this, udt, options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
row.argValue.WriteSchemaId(offset + (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), value.getSchemaId().clone());
|
||||
return (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.Size;
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import azure.data.cosmos.serialization.hybridrow.UnixDateTime;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutUnixDateTime extends LayoutType<UnixDateTime> {
|
||||
public LayoutUnixDateTime() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UnixDateTime, Microsoft.Azure.Cosmos.Serialization.HybridRow.UnixDateTime.Size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "unixdatetime";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<UnixDateTime> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = null;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadUnixDateTime(scope.argValue.start + col.getOffset()).clone();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<UnixDateTime> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseUnixDateTime(edit).clone();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
UnixDateTime value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteUnixDateTime(scope.argValue.start + col.getOffset(), value.clone());
|
||||
b.argValue.SetBit(scope.argValue.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, UnixDateTime value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, UnixDateTime value
|
||||
, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseUnixDateTime(edit, value.clone(), options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, UnixDateTime value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8SpanWritable, ILayoutUtf8SpanReadable {
|
||||
public LayoutUtf8() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Utf8, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "utf8";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<String> value) {
|
||||
Utf8Span span;
|
||||
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
|
||||
// cannot be converted using the 'OutObject' helper class unless the method is within the code being modified:
|
||||
Result r = this.ReadFixed(b, scope, col, out span);
|
||||
value.argValue = (r == Result.Success) ? span.toString() :
|
||||
default
|
||||
return r;
|
||||
}
|
||||
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Utf8Span> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
checkArgument(col.getSize() >= 0);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = null;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadFixedString(scope.argValue.start + col.getOffset(), col.getSize());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<String> value) {
|
||||
Utf8Span span;
|
||||
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
|
||||
// cannot be converted using the 'OutObject' helper class unless the method is within the code being modified:
|
||||
Result r = this.ReadSparse(b, edit, out span);
|
||||
value.argValue = (r == Result.Success) ? span.toString() :
|
||||
default
|
||||
return r;
|
||||
}
|
||||
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, tangible.OutObject<Utf8Span> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseString(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col
|
||||
, tangible.OutObject<String> value) {
|
||||
Utf8Span span;
|
||||
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
|
||||
// cannot be converted using the 'OutObject' helper class unless the method is within the code being modified:
|
||||
Result r = this.ReadVariable(b, scope, col, out span);
|
||||
value.argValue = (r == Result.Success) ? span.toString() :
|
||||
default
|
||||
return r;
|
||||
}
|
||||
|
||||
public Result ReadVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col
|
||||
, tangible.OutObject<Utf8Span> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = null;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
int varOffset = b.argValue.ComputeVariableValueOffset(scope.argValue.layout, scope.argValue.start,
|
||||
col.getOffset());
|
||||
value.argValue = b.argValue.ReadVariableString(varOffset);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
String value) {
|
||||
checkArgument(value != null);
|
||||
return this.WriteFixed(b, scope, col, Utf8Span.TranscodeUtf16(value));
|
||||
}
|
||||
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Utf8Span value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
checkArgument(col.getSize() >= 0);
|
||||
checkArgument(value.Length == col.getSize());
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteFixedString(scope.argValue.start + col.getOffset(), value);
|
||||
b.argValue.SetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, String value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, string value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, String value,
|
||||
UpdateOptions options) {
|
||||
checkArgument(value != null);
|
||||
return this.WriteSparse(b, edit, Utf8Span.TranscodeUtf16(value), options);
|
||||
}
|
||||
|
||||
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, Utf8Span 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, Utf8Span value, UpdateOptions
|
||||
// options = UpdateOptions.Upsert)
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, Utf8Span value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseString(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
LayoutColumn col, String value) {
|
||||
checkArgument(value != null);
|
||||
return this.WriteVariable(b, scope, col, Utf8Span.TranscodeUtf16(value));
|
||||
}
|
||||
|
||||
public Result WriteVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
LayoutColumn col, Utf8Span value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
int length = value.Length;
|
||||
if ((col.getSize() > 0) && (length > col.getSize())) {
|
||||
return Result.TooBig;
|
||||
}
|
||||
|
||||
boolean exists = b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone());
|
||||
int varOffset = b.argValue.ComputeVariableValueOffset(scope.argValue.layout, scope.argValue.start,
|
||||
col.getOffset());
|
||||
int shift;
|
||||
tangible.OutObject<Integer> tempOut_shift = new tangible.OutObject<Integer>();
|
||||
b.argValue.WriteVariableString(varOffset, value, exists, tempOut_shift);
|
||||
shift = tempOut_shift.argValue;
|
||||
b.argValue.SetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
scope.argValue.metaOffset += shift;
|
||||
scope.argValue.valueOffset += shift;
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutVarInt extends LayoutType<Long> {
|
||||
public LayoutVarInt() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.VarInt, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsVarint() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "varint";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Long> value) {
|
||||
Contract.Fail("Not Implemented");
|
||||
value.argValue = 0;
|
||||
return Result.Failure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, tangible.OutObject<Long> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseVarInt(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col, tangible.OutObject<Long> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = 0;
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
int varOffset = b.argValue.ComputeVariableValueOffset(scope.argValue.layout, scope.argValue.start,
|
||||
col.getOffset());
|
||||
value.argValue = b.argValue.ReadVariableInt(varOffset);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
long value) {
|
||||
Contract.Fail("Not Implemented");
|
||||
return Result.Failure;
|
||||
}
|
||||
|
||||
//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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, long value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseVarInt(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, long value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
LayoutColumn col, long value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
boolean exists = b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone());
|
||||
int varOffset = b.argValue.ComputeVariableValueOffset(scope.argValue.layout, scope.argValue.start,
|
||||
col.getOffset());
|
||||
int shift;
|
||||
tangible.OutObject<Integer> tempOut_shift = new tangible.OutObject<Integer>();
|
||||
b.argValue.WriteVariableInt(varOffset, value, exists, tempOut_shift);
|
||||
shift = tempOut_shift.argValue;
|
||||
b.argValue.SetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
scope.argValue.metaOffset += shift;
|
||||
scope.argValue.valueOffset += shift;
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.recordio;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
|
||||
public final class RecordSerializer {
|
||||
public static Result Read(tangible.RefObject<RowReader> reader, tangible.OutObject<Record> obj) {
|
||||
obj.argValue = null;
|
||||
while (reader.argValue.Read()) {
|
||||
Result r;
|
||||
|
||||
// TODO: use Path tokens here.
|
||||
switch (reader.argValue.getPath().toString()) {
|
||||
case "length":
|
||||
tangible.OutObject<Integer> tempOut_Length = new tangible.OutObject<Integer>();
|
||||
r = reader.argValue.ReadInt32(tempOut_Length);
|
||||
obj.argValue.argValue.Length = tempOut_Length.argValue;
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
|
||||
break;
|
||||
case "crc32":
|
||||
tangible.OutObject<Integer> tempOut_Crc32 = new tangible.OutObject<Integer>();
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: r = reader.ReadUInt32(out obj.Crc32);
|
||||
r = reader.argValue.ReadUInt32(tempOut_Crc32);
|
||||
obj.argValue.argValue.Crc32 = tempOut_Crc32.argValue;
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public static Result Write(tangible.RefObject<RowWriter> writer, TypeArgument typeArg, Record obj) {
|
||||
Result r;
|
||||
r = writer.argValue.WriteInt32("length", obj.Length);
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = writer.argValue.WriteUInt32("crc32", obj.Crc32);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.recordio;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
|
||||
public final class SegmentSerializer {
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: public static Result Read(Span<byte> span, LayoutResolver resolver, out Segment obj)
|
||||
public static Result Read(Span<Byte> span, LayoutResolver resolver, tangible.OutObject<Segment> obj) {
|
||||
RowBuffer row = new RowBuffer(span, HybridRowVersion.V1, resolver);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(row);
|
||||
RowReader reader = new RowReader(tempRef_row);
|
||||
row = tempRef_row.argValue;
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowReader> tempRef_reader =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowReader>(reader);
|
||||
Result tempVar = SegmentSerializer.Read(tempRef_reader, obj.clone());
|
||||
reader = tempRef_reader.argValue;
|
||||
return tempVar;
|
||||
}
|
||||
|
||||
public static Result Read(tangible.RefObject<RowReader> reader, tangible.OutObject<Segment> obj) {
|
||||
obj.argValue = null;
|
||||
while (reader.argValue.Read()) {
|
||||
Result r;
|
||||
|
||||
// TODO: use Path tokens here.
|
||||
switch (reader.argValue.getPath().toString()) {
|
||||
case "length":
|
||||
tangible.OutObject<Integer> tempOut_Length = new tangible.OutObject<Integer>();
|
||||
r = reader.argValue.ReadInt32(tempOut_Length);
|
||||
obj.argValue.argValue.Length = tempOut_Length.argValue;
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
|
||||
// If the RowBuffer isn't big enough to contain the rest of the header, then just
|
||||
// return the length.
|
||||
if (reader.argValue.getLength() < obj.argValue.Length) {
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
break;
|
||||
case "comment":
|
||||
tangible.OutObject<String> tempOut_Comment = new tangible.OutObject<String>();
|
||||
r = reader.argValue.ReadString(tempOut_Comment);
|
||||
obj.argValue.argValue.Comment = tempOut_Comment.argValue;
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
|
||||
break;
|
||||
case "sdl":
|
||||
tangible.OutObject<String> tempOut_SDL = new tangible.OutObject<String>();
|
||||
r = reader.argValue.ReadString(tempOut_SDL);
|
||||
obj.argValue.argValue.SDL = tempOut_SDL.argValue;
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public static Result Write(tangible.RefObject<RowWriter> writer, TypeArgument typeArg, Segment obj) {
|
||||
Result r;
|
||||
if (obj.Comment != null) {
|
||||
r = writer.argValue.WriteString("comment", obj.Comment);
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.SDL != null) {
|
||||
r = writer.argValue.WriteString("sdl", obj.SDL);
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
// Defer writing the length until all other fields of the segment header are written.
|
||||
// The length is then computed based on the current size of the underlying RowBuffer.
|
||||
// Because the length field is itself fixed, writing the length can never change the length.
|
||||
int length = writer.argValue.getLength();
|
||||
r = writer.argValue.WriteInt32("length", length);
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
|
||||
Contract.Assert(length == writer.argValue.getLength());
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
18
jre/src/main/java/com/azure/data/cosmos/core/OutObject.java
Normal file
18
jre/src/main/java/com/azure/data/cosmos/core/OutObject.java
Normal file
@@ -0,0 +1,18 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.core;
|
||||
|
||||
public final class OutObject<T> {
|
||||
|
||||
private T value;
|
||||
|
||||
public T get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void set(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
22
jre/src/main/java/com/azure/data/cosmos/core/RefObject.java
Normal file
22
jre/src/main/java/com/azure/data/cosmos/core/RefObject.java
Normal file
@@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.core;
|
||||
|
||||
public final class RefObject<T> {
|
||||
|
||||
private T value;
|
||||
|
||||
public RefObject(T value) {
|
||||
this.set(value);
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void set(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
459
jre/src/main/java/com/azure/data/cosmos/core/Utf8String.java
Normal file
459
jre/src/main/java/com/azure/data/cosmos/core/Utf8String.java
Normal file
@@ -0,0 +1,459 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.core;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeType;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import com.google.common.base.Utf8;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.base.Strings.lenientFormat;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
@JsonSerialize(using = Utf8String.JsonSerializer.class)
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public final class Utf8String implements CharSequence, Comparable<Utf8String> {
|
||||
|
||||
public static final Utf8String EMPTY = new Utf8String(Unpooled.EMPTY_BUFFER, 0);
|
||||
|
||||
private static final PooledByteBufAllocator allocator = PooledByteBufAllocator.DEFAULT;
|
||||
private final ByteBuf buffer;
|
||||
private final int length;
|
||||
|
||||
private Utf8String(final ByteBuf buffer) {
|
||||
this(buffer, decodedLength(buffer));
|
||||
}
|
||||
|
||||
private Utf8String(final ByteBuf buffer, final int decodedLength) {
|
||||
this.buffer = buffer.asReadOnly();
|
||||
this.length = decodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code true} if the length of this instance is zero
|
||||
*/
|
||||
public final boolean isEmpty() {
|
||||
return this.length == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char charAt(final int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-allocating enumeration of each character in the UTF-8 stream
|
||||
*/
|
||||
@Override
|
||||
public IntStream chars() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-allocating enumeration of each code point in the UTF-8 stream
|
||||
*/
|
||||
public final IntStream codePoints() {
|
||||
if (this.length == 0) {
|
||||
return IntStream.empty();
|
||||
}
|
||||
return StreamSupport.intStream(new CodePointIterable(this.buffer, this.length), false);
|
||||
}
|
||||
|
||||
public final int compareTo(@Nonnull final Utf8String other) {
|
||||
checkNotNull(other);
|
||||
return this.buffer.compareTo(other.buffer);
|
||||
}
|
||||
|
||||
public final int compareTo(@Nonnull final String other) {
|
||||
|
||||
checkNotNull(other);
|
||||
|
||||
final int length = this.length();
|
||||
final int otherLength = other.length();
|
||||
final int limit = Math.min(length, otherLength);
|
||||
|
||||
if (limit > 0) {
|
||||
|
||||
final CodePointIterable iterable = new CodePointIterable(this.buffer, this.length);
|
||||
int index = 0;
|
||||
|
||||
for (int codePoint : iterable) {
|
||||
|
||||
final int otherCodePoint = other.codePointAt(index++);
|
||||
|
||||
if (codePoint != otherCodePoint) {
|
||||
return codePoint - otherCodePoint;
|
||||
}
|
||||
|
||||
if (index >= limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return length - otherLength;
|
||||
}
|
||||
|
||||
public final boolean equals(ByteBuf other) {
|
||||
return this.buffer.equals(other);
|
||||
}
|
||||
|
||||
public final boolean equals(String other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
return this.compareTo(other) == 0;
|
||||
}
|
||||
|
||||
public final boolean equals(Utf8String other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
return this.buffer.equals(other.buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
if (other instanceof ByteBuf) {
|
||||
return this.equals((ByteBuf)other);
|
||||
}
|
||||
if (other instanceof String) {
|
||||
return this.equals((String)other);
|
||||
}
|
||||
if (other instanceof Utf8String) {
|
||||
return this.equals((Utf8String)other);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.buffer.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of this character sequence
|
||||
* <p>
|
||||
* The length is the number of Unicode characters in the sequence.
|
||||
*/
|
||||
public final int length() {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public static boolean opEquals(Utf8String left, Utf8String right) {
|
||||
if (null == left) {
|
||||
return null == right;
|
||||
}
|
||||
return left.equals(right);
|
||||
}
|
||||
|
||||
public static boolean opGreaterThan(Utf8String left, Utf8String right) {
|
||||
return left != null && left.compareTo(right) > 0;
|
||||
}
|
||||
|
||||
public static boolean opGreaterThan(Utf8String left, String right) {
|
||||
return left != null && left.compareTo(right) > 0;
|
||||
}
|
||||
|
||||
public static boolean opGreaterThan(String left, Utf8String right) {
|
||||
return right == null || right.compareTo(left) <= 0;
|
||||
}
|
||||
|
||||
public static boolean opGreaterThanOrEquals(Utf8String left, Utf8String right) {
|
||||
return left == null ? right == null : left.compareTo(right) >= 0;
|
||||
}
|
||||
|
||||
public static boolean opGreaterThanOrEquals(Utf8String left, String right) {
|
||||
return left == null ? right == null : left.compareTo(right) >= 0;
|
||||
}
|
||||
|
||||
public static boolean opGreaterThanOrEquals(String left, Utf8String right) {
|
||||
return right == null ? left != null : right.compareTo(left) < 0;
|
||||
}
|
||||
|
||||
public static boolean opLessThan(Utf8String left, Utf8String right) {
|
||||
return left == null ? right != null : left.compareTo(right) < 0;
|
||||
}
|
||||
|
||||
public static boolean opLessThan(Utf8String left, String right) {
|
||||
return left == null ? right != null : left.compareTo(right) < 0;
|
||||
}
|
||||
|
||||
public static boolean opLessThan(String left, Utf8String right) {
|
||||
return right == null ? left == null : right.compareTo(left) >= 0;
|
||||
}
|
||||
|
||||
public static boolean opLessThanOrEquals(Utf8String left, Utf8String right) {
|
||||
return left == null || left.compareTo(right) <= 0;
|
||||
}
|
||||
|
||||
public static boolean opLessThanOrEquals(Utf8String left, String right) {
|
||||
return left == null || left.compareTo(right) <= 0;
|
||||
}
|
||||
|
||||
public static boolean opLessThanOrEquals(String left, Utf8String right) {
|
||||
return right != null && right.compareTo(left) > 0;
|
||||
}
|
||||
|
||||
public static boolean opNotEquals(Utf8String left, Utf8String right) {
|
||||
if (null == left) {
|
||||
return null != right;
|
||||
}
|
||||
return !left.equals(right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
checkArgument(start < 0 || end < 0 || start > end || end > this.length, "start: %s, end: %s", start, end);
|
||||
// TODO: DANOBLE: compute buffer index for start and end character positions and use them in the slice
|
||||
return new Utf8String(this.buffer.slice(), end - start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.buffer.getCharSequence(0, this.buffer.capacity(), UTF_8).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <see cref="Utf8String" /> from a UTF16 encoding string.
|
||||
*
|
||||
* @param string The UTF16 encoding string.
|
||||
* @return A new <see cref="Utf8String" />.
|
||||
* <p>
|
||||
* This method must transcode the UTF-16 into UTF-8 which both requires allocation and is a size of data operation.
|
||||
*/
|
||||
public static Utf8String transcodeUtf16(final String string) {
|
||||
|
||||
if (string == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (string.isEmpty()) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
final int length = Utf8.encodedLength(string);
|
||||
final ByteBuf buffer = allocator.buffer(length, length);
|
||||
final int count = buffer.writeCharSequence(string, UTF_8);
|
||||
|
||||
checkState(count == length, "count: %s, length: %s", count, length);
|
||||
|
||||
return new Utf8String(buffer, string.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the contents of a byte buffer to prove it contains a valid UTF-8 character sequence
|
||||
*
|
||||
* @param buffer The byte buffer to validate
|
||||
* @return A {@link Utf8String} instance, if the @{code buffer} validates or a value of @{link Optional#empty}
|
||||
* otherwise.
|
||||
*/
|
||||
public static Optional<Utf8String> tryParseUtf8Bytes(@Nonnull final ByteBuf buffer) {
|
||||
checkNotNull(buffer);
|
||||
return Utf8.isWellFormed(buffer.array()) ? Optional.of(new Utf8String(buffer)) : Optional.empty();
|
||||
}
|
||||
|
||||
private static int decodedLength(final ByteBuf buffer) {
|
||||
|
||||
final CodePointIterable iterable = new CodePointIterable(buffer, -1);
|
||||
int decodedLength = 0;
|
||||
|
||||
for (int ignored : iterable) {
|
||||
decodedLength++;
|
||||
}
|
||||
|
||||
return decodedLength;
|
||||
}
|
||||
|
||||
private static final class CodePointIterable implements Iterable<Integer>, Iterator<Integer>, Spliterator.OfInt {
|
||||
|
||||
private static final int CHARACTERISTICS = Spliterator.IMMUTABLE | Spliterator.NONNULL | Spliterator.ORDERED;
|
||||
|
||||
private final ByteBuf buffer;
|
||||
private final int length;
|
||||
private int index;
|
||||
|
||||
public CodePointIterable(final ByteBuf buffer, final int length) {
|
||||
this.buffer = buffer;
|
||||
this.length = length;
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int characteristics() {
|
||||
return this.length == -1 ? CHARACTERISTICS : CHARACTERISTICS | Spliterator.SIZED | Spliterator.SUBSIZED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long estimateSize() {
|
||||
return this.length < 0 ? Long.MAX_VALUE : this.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachRemaining(final Consumer<? super Integer> action) {
|
||||
OfInt.super.forEachRemaining(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return this.index < this.buffer.capacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Iterator<Integer> iterator() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer next() {
|
||||
|
||||
if (!this.hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
final int leadingByte = this.buffer.getByte(this.index++) & 0xFF;
|
||||
|
||||
// A 1-byte UTF-8 code point is a special case that covers the 7-bit ASCII character set
|
||||
|
||||
if (leadingByte < 0x80) {
|
||||
return leadingByte;
|
||||
}
|
||||
|
||||
// The initial byte of 2-, 3- and 4-byte UTF-8 code points start with 2, 3, or 4 one bits followed by a 0
|
||||
// bit
|
||||
|
||||
final int codePoint;
|
||||
|
||||
if ((leadingByte & 0b1110_0000) == 0b1100_0000) {
|
||||
|
||||
// 110xxxxx 10xxxxxx => 0x00000080 - 0x000007FF
|
||||
|
||||
codePoint = ((leadingByte & 0b0001_1111) << 6) |
|
||||
(buffer.getByte(this.index++) & 0b0011_1111);
|
||||
|
||||
} else if ((leadingByte & 0b1111_0000) == 0b1110_0000) {
|
||||
|
||||
// 1110xxxx 10xxxxxx 10xxxxxx => 0x00000800 - 0x0000FFFF
|
||||
|
||||
codePoint = ((leadingByte & 0b0000_1111) << 12) |
|
||||
((buffer.getByte(this.index++) & 0b0011_1111) << 6) |
|
||||
((buffer.getByte(this.index++) & 0b0011_1111));
|
||||
|
||||
} else if ((leadingByte & 0b1111_1000) == 0b1111_0000) {
|
||||
|
||||
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx => 0x00010000 - 0x001FFFFF
|
||||
|
||||
codePoint = ((leadingByte & 0b0000_0111) << 18) |
|
||||
((buffer.getByte(this.index++) & 0b0011_1111) << 12) |
|
||||
((buffer.getByte(this.index++) & 0b0011_1111) << 6) |
|
||||
((buffer.getByte(this.index++) & 0b0011_1111));
|
||||
|
||||
} else {
|
||||
// leading byte is improperly encoded and we'll detect that before returning
|
||||
codePoint = leadingByte;
|
||||
}
|
||||
|
||||
checkState(Character.isDefined(codePoint), "invalid character: %s", codePoint);
|
||||
return codePoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<Integer> spliterator() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryAdvance(@Nonnull final IntConsumer action) {
|
||||
|
||||
checkNotNull(action);
|
||||
|
||||
if (this.hasNext()) {
|
||||
action.accept(this.next());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfInt trySplit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final class Deserializer extends StdDeserializer<Utf8String> {
|
||||
|
||||
private Deserializer() {
|
||||
super(Utf8String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Utf8String deserialize(JsonParser parser, DeserializationContext context) throws IOException,
|
||||
JsonProcessingException {
|
||||
|
||||
final JsonNode node = parser.getCodec().readTree(parser);
|
||||
final JsonNodeType type = node.getNodeType();
|
||||
|
||||
switch (type) {
|
||||
case STRING:
|
||||
return Utf8String.transcodeUtf16(node.textValue());
|
||||
case NULL:
|
||||
return null;
|
||||
default: {
|
||||
String message = lenientFormat("expected string value or null, not %s", type.name().toLowerCase());
|
||||
throw new JsonParseException(parser, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final class JsonSerializer extends StdSerializer<Utf8String> {
|
||||
|
||||
private JsonSerializer() {
|
||||
super(Utf8String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Utf8String value, JsonGenerator generator, SerializerProvider provider) throws IOException {
|
||||
generator.writeString(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
public class DefaultSpanResizer<T> implements ISpanResizer<T> {
|
||||
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
|
||||
///#pragma warning disable CA1051 // Do not declare visible instance fields
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
/**
|
||||
* Describes the header the precedes all valid Hybrid Rows.
|
||||
@@ -17,7 +17,7 @@ public final class HybridRowHeader {
|
||||
/**
|
||||
* Size (in bytes) of a serialized header.
|
||||
*/
|
||||
public static final int Size = (HybridRowVersion.SIZE / Byte.SIZE) + azure.data.cosmos.serialization.hybridrow.SchemaId.Size;
|
||||
public static final int Size = (HybridRowVersion.SIZE / Byte.SIZE) + com.azure.data.cosmos.serialization.hybridrow.SchemaId.Size;
|
||||
/**
|
||||
* The unique identifier of the schema whose layout was used to write this row.
|
||||
*/
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
|
||||
///#pragma warning disable CA1028 // Enum Storage should be Int32
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
public interface ISpanResizer<T> {
|
||||
/**
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
/**
|
||||
* The literal null value.
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
public enum Result {
|
||||
Success(0),
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,20 +2,21 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
|
||||
///#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.Layout;
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope;
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.LayoutScope;
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.LayoutType;
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.StringToken;
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument;
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutScope;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.StringToken;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList;
|
||||
|
||||
// ReSharper disable UseNameofExpression
|
||||
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
|
||||
@@ -101,10 +102,10 @@ public final class RowCursor {
|
||||
*/
|
||||
public StringToken writePathToken = new StringToken();
|
||||
|
||||
public static RowCursor Create(tangible.RefObject<RowBuffer> row) {
|
||||
SchemaId schemaId = row.argValue.ReadSchemaId(1).clone();
|
||||
Layout layout = row.argValue.getResolver().Resolve(schemaId.clone());
|
||||
int sparseSegmentOffset = row.argValue.ComputeVariableValueOffset(layout, HybridRowHeader.Size,
|
||||
public static RowCursor Create(RefObject<RowBuffer> row) {
|
||||
SchemaId schemaId = row.get().ReadSchemaId(1).clone();
|
||||
Layout layout = row.get().getResolver().Resolve(schemaId.clone());
|
||||
int sparseSegmentOffset = row.get().ComputeVariableValueOffset(layout, HybridRowHeader.Size,
|
||||
layout.getNumVariable());
|
||||
RowCursor tempVar = new RowCursor();
|
||||
tempVar.layout = layout;
|
||||
@@ -2,10 +2,11 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode;
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@@ -77,27 +78,27 @@ public final class RowCursorExtensions {
|
||||
// edit.writePathToken = pathToken;
|
||||
// return ref edit;
|
||||
// }
|
||||
public static boolean MoveNext(tangible.RefObject<RowCursor> edit, tangible.RefObject<RowBuffer> row) {
|
||||
edit.argValue.writePath = null;
|
||||
edit.argValue.writePathToken = null;
|
||||
return row.argValue.SparseIteratorMoveNext(edit);
|
||||
public static boolean MoveNext(RefObject<RowCursor> edit, RefObject<RowBuffer> row) {
|
||||
edit.get().writePath = null;
|
||||
edit.get().writePathToken = null;
|
||||
return row.get().SparseIteratorMoveNext(edit);
|
||||
}
|
||||
|
||||
public static boolean MoveNext(tangible.RefObject<RowCursor> edit, tangible.RefObject<RowBuffer> row,
|
||||
tangible.RefObject<RowCursor> childScope) {
|
||||
if (childScope.argValue.scopeType != null) {
|
||||
azure.data.cosmos.serialization.hybridrow.RowCursorExtensions.Skip(edit.argValue.clone(), row, childScope);
|
||||
public static boolean MoveNext(RefObject<RowCursor> edit, RefObject<RowBuffer> row,
|
||||
RefObject<RowCursor> childScope) {
|
||||
if (childScope.get().scopeType != null) {
|
||||
RowCursorExtensions.Skip(edit.get().clone(), row, childScope);
|
||||
}
|
||||
|
||||
return azure.data.cosmos.serialization.hybridrow.RowCursorExtensions.MoveNext(edit.argValue.clone(), row);
|
||||
return RowCursorExtensions.MoveNext(edit.get().clone(), row);
|
||||
}
|
||||
|
||||
public static boolean MoveTo(tangible.RefObject<RowCursor> edit, tangible.RefObject<RowBuffer> row, int index) {
|
||||
checkState(edit.argValue.index <= index);
|
||||
edit.argValue.writePath = null;
|
||||
edit.argValue.writePathToken = null;
|
||||
while (edit.argValue.index < index) {
|
||||
if (!row.argValue.SparseIteratorMoveNext(edit)) {
|
||||
public static boolean MoveTo(RefObject<RowCursor> edit, RefObject<RowBuffer> row, int index) {
|
||||
checkState(edit.get().index <= index);
|
||||
edit.get().writePath = null;
|
||||
edit.get().writePathToken = null;
|
||||
while (edit.get().index < index) {
|
||||
if (!row.get().SparseIteratorMoveNext(edit)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -105,23 +106,23 @@ public final class RowCursorExtensions {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Skip(tangible.RefObject<RowCursor> edit, tangible.RefObject<RowBuffer> row,
|
||||
tangible.RefObject<RowCursor> childScope) {
|
||||
checkArgument(childScope.argValue.start == edit.argValue.valueOffset);
|
||||
if (!(childScope.argValue.cellType instanceof LayoutEndScope)) {
|
||||
while (row.argValue.SparseIteratorMoveNext(childScope)) {
|
||||
public static void Skip(RefObject<RowCursor> edit, RefObject<RowBuffer> row,
|
||||
RefObject<RowCursor> childScope) {
|
||||
checkArgument(childScope.get().start == edit.get().valueOffset);
|
||||
if (!(childScope.get().cellType instanceof LayoutEndScope)) {
|
||||
while (row.get().SparseIteratorMoveNext(childScope)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (childScope.argValue.scopeType.IsSizedScope) {
|
||||
edit.argValue.endOffset = childScope.argValue.metaOffset;
|
||||
if (childScope.get().scopeType.IsSizedScope) {
|
||||
edit.get().endOffset = childScope.get().metaOffset;
|
||||
} else {
|
||||
edit.argValue.endOffset = childScope.argValue.metaOffset + (LayoutCode.SIZE / Byte.SIZE); // Move past the end of scope marker.
|
||||
edit.get().endOffset = childScope.get().metaOffset + (LayoutCode.SIZE / Byte.SIZE); // Move past the end of scope marker.
|
||||
}
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
|
||||
//#if DEBUG
|
||||
childScope.argValue = null;
|
||||
childScope.set(null);
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
/**
|
||||
* Describes the desired behavior when mutating a hybrid row.
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
import Newtonsoft.Json.*;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow;
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
/**
|
||||
* A wall clock time expressed in milliseconds since the Unix Epoch.
|
||||
@@ -2,7 +2,9 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.internal;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
/**
|
||||
* MurmurHash3 for x64 (Little Endian).
|
||||
@@ -19,14 +21,13 @@ public final class MurmurHash3 {
|
||||
@return The 128-bit hash represented as two 64-bit words.
|
||||
*/
|
||||
// TODO: C# TO JAVA CONVERTER: Methods returning tuples are not converted by C# to Java Converter:
|
||||
// public static(ulong low, ulong high) Hash128(string value, (ulong high, ulong low) seed)
|
||||
// {
|
||||
// Contract.Requires(value != null);
|
||||
// int size = Encoding.UTF8.GetMaxByteCount(value.Length);
|
||||
// Span<byte> span = size <= 256 ? stackalloc byte[size] : new byte[size];
|
||||
// int len = Encoding.UTF8.GetBytes(value.AsSpan(), span);
|
||||
// return MurmurHash3.Hash128(span.Slice(0, len), seed);
|
||||
// }
|
||||
public static Value Hash128(String value, Value seed) {
|
||||
checkArgument(value != null);
|
||||
int size = Encoding.UTF8.GetMaxByteCount(value.length());
|
||||
Span<byte> span = size <= 256 ? stackalloc byte[size] :new byte[size];
|
||||
int len = Encoding.UTF8.GetBytes(value.AsSpan(), span);
|
||||
return MurmurHash3.Hash128(span.Slice(0, len), seed);
|
||||
}
|
||||
|
||||
/** MurmurHash3 128-bit implementation.
|
||||
@param value The data to hash.
|
||||
@@ -34,11 +35,10 @@ public final class MurmurHash3 {
|
||||
@return The 128-bit hash represented as two 64-bit words.
|
||||
*/
|
||||
// TODO: C# TO JAVA CONVERTER: Methods returning tuples are not converted by C# to Java Converter:
|
||||
// public static(ulong low, ulong high) Hash128(bool value, (ulong high, ulong low) seed)
|
||||
// {
|
||||
// // Ensure that a bool is ALWAYS a single byte encoding with 1 for true and 0 for false.
|
||||
// return MurmurHash3.Hash128((byte)(value ? 1 : 0), seed);
|
||||
// }
|
||||
public static Value Hash128(boolean value, Value seed) {
|
||||
// Ensure that a bool is ALWAYS a single byte encoding with 1 for true and 0 for false.
|
||||
return MurmurHash3.Hash128((byte)(value ? 1 : 0), seed);
|
||||
}
|
||||
|
||||
/** MurmurHash3 128-bit implementation.
|
||||
@param value The data to hash.
|
||||
@@ -47,7 +47,7 @@ public final class MurmurHash3 {
|
||||
*/
|
||||
// TODO: C# TO JAVA CONVERTER: Methods returning tuples are not converted by C# to Java Converter:
|
||||
// public static unsafe(ulong low, ulong high) Hash128<T>(T value, (ulong high, ulong low) seed) where T :
|
||||
// unmanaged
|
||||
// unmanaged
|
||||
// {
|
||||
// ReadOnlySpan<T> span = new ReadOnlySpan<T>(&value, 1);
|
||||
// return MurmurHash3.Hash128(MemoryMarshal.AsBytes(span), seed);
|
||||
@@ -214,32 +214,42 @@ public final class MurmurHash3 {
|
||||
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ulong Mix(ulong h)
|
||||
private static long Mix(long h) {
|
||||
// TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java:
|
||||
unchecked
|
||||
{
|
||||
//C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift
|
||||
// operator since the left operand was originally of an unsigned type, but you should confirm this
|
||||
// replacement:
|
||||
h ^= h >>> 33;
|
||||
h *= 0xff51afd7ed558ccdL;
|
||||
//C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift
|
||||
// operator since the left operand was originally of an unsigned type, but you should confirm this
|
||||
// replacement:
|
||||
h ^= h >>> 33;
|
||||
h *= 0xc4ceb9fe1a85ec53L;
|
||||
//C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift
|
||||
// operator since the left operand was originally of an unsigned type, but you should confirm this replacement:
|
||||
h ^= h >>> 33;
|
||||
return h;
|
||||
}
|
||||
//C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift
|
||||
// operator since the left operand was originally of an unsigned type, but you should confirm this
|
||||
// replacement:
|
||||
h ^= h >>> 33;
|
||||
h *= 0xff51afd7ed558ccdL;
|
||||
//C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift
|
||||
// operator since the left operand was originally of an unsigned type, but you should confirm this
|
||||
// replacement:
|
||||
h ^= h >>> 33;
|
||||
h *= 0xc4ceb9fe1a85ec53L;
|
||||
//C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift
|
||||
// operator since the left operand was originally of an unsigned type, but you should confirm this replacement:
|
||||
h ^= h >>> 33;
|
||||
return h;
|
||||
}
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
|
||||
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ulong RotateLeft64(ulong n, int numBits)
|
||||
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ulong RotateLeft64(ulong n,
|
||||
// int numBits)
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ulong RotateLeft64(ulong n, int numBits)
|
||||
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ulong RotateLeft64(ulong n,
|
||||
// int numBits)
|
||||
private static long RotateLeft64(long n, int numBits) {
|
||||
Contract.Assert(numBits < 64, "numBits < 64");
|
||||
//C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift operator since the left operand was originally of an unsigned type, but you should confirm this replacement:
|
||||
checkArgument(numBits < 64, "numBits < 64");
|
||||
//C# TO JAVA CONVERTER WARNING: The right shift operator was replaced by Java's logical right shift operator
|
||||
// since the left operand was originally of an unsigned type, but you should confirm this replacement:
|
||||
return (n << numBits) | (n >>> (64 - numBits));
|
||||
}
|
||||
|
||||
public static final class Value {
|
||||
|
||||
public final long low, high;
|
||||
|
||||
public Value(long low, long high) {
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.internal;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
/**
|
||||
* Helper class for parsing <see cref="Utf8String" /> from JSON.
|
||||
*/
|
||||
public class Utf8StringJsonConverter extends StdSerializer<ByteBuf> {
|
||||
|
||||
public Utf8StringJsonConverter() {
|
||||
this(ByteBuf.class);
|
||||
}
|
||||
|
||||
public Utf8StringJsonConverter(Class<ByteBuf> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrite() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanConvert(Class<?> type) {
|
||||
return type.isAssignableFrom(ByteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object ReadJson(
|
||||
JsonReader reader, java.lang.Class objectType, Object existingValue, JsonSerializer serializer) {
|
||||
checkArgument(reader.TokenType == JsonToken.String);
|
||||
return Utf8String.TranscodeUtf16((String)reader.Value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) {
|
||||
writer.WriteValue(((Utf8String)value).toString());
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,11 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.io;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.io;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument;
|
||||
|
||||
/**
|
||||
* A type may implement this interface to support serialization into a HybridRow.
|
||||
@@ -18,5 +19,5 @@ public interface IRowSerializable {
|
||||
* @param typeArg The schematized layout type, if a schema is available.
|
||||
* @return Success if the write is successful, the error code otherwise.
|
||||
*/
|
||||
Result Write(tangible.RefObject<RowWriter> writer, TypeArgument typeArg);
|
||||
Result write(RefObject<RowWriter> writer, TypeArgument typeArg);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,11 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.io;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.io;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -19,28 +21,28 @@ public final class RowReaderExtensions {
|
||||
* @param list On success, the collection of materialized items.
|
||||
* @return The result.
|
||||
*/
|
||||
public static <TItem> Result ReadList(tangible.RefObject<RowReader> reader, DeserializerFunc<TItem> deserializer,
|
||||
tangible.OutObject<ArrayList<TItem>> list) {
|
||||
public static <TItem> Result ReadList(RefObject<RowReader> reader, DeserializerFunc<TItem> deserializer,
|
||||
OutObject<ArrayList<TItem>> list) {
|
||||
// Pass the context as a struct by value to avoid allocations.
|
||||
ListContext<TItem> ctx = new ListContext<TItem>();
|
||||
ctx.List = new ArrayList<TItem>();
|
||||
ctx.List = new ArrayList<>();
|
||||
ctx.Deserializer =
|
||||
(tangible.RefObject<RowReader> reader.argValue, tangible.OutObject<TItem> item) -> deserializer.invoke(reader.argValue.clone(), item);
|
||||
(RefObject<RowReader> reader.argValue, OutObject<TItem> item) -> deserializer.invoke(reader.get().clone(), item);
|
||||
|
||||
// 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.argValue.ReadScope(ctx.clone(), (ref RowReader arrayReader, ListContext<TItem> ctx1) ->
|
||||
Result r = reader.get().ReadScope(ctx.clone(), (ref RowReader arrayReader, ListContext<TItem> ctx1) ->
|
||||
{
|
||||
while (arrayReader.Read()) {
|
||||
Result r2 = arrayReader.ReadScope(ctx1.clone(), (ref RowReader itemReader, ListContext<TItem> ctx2) ->
|
||||
{
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowReader> tempRef_itemReader = new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowReader>(itemReader);
|
||||
RefObject<com.azure.data.cosmos.serialization.hybridrow.io.RowReader> tempRef_itemReader = new RefObject<com.azure.data.cosmos.serialization.hybridrow.io.RowReader>(itemReader);
|
||||
TItem op;
|
||||
tangible.OutObject<TItem> tempOut_op = new tangible.OutObject<TItem>();
|
||||
OutObject<TItem> tempOut_op = new OutObject<TItem>();
|
||||
Result r3 = ctx2.Deserializer.invoke(tempRef_itemReader, tempOut_op);
|
||||
op = tempOut_op.argValue;
|
||||
itemReader = tempRef_itemReader.argValue;
|
||||
op = tempOut_op.get();
|
||||
itemReader = tempRef_itemReader.get();
|
||||
if (r3 != Result.Success) {
|
||||
return r3;
|
||||
}
|
||||
@@ -58,11 +60,11 @@ public final class RowReaderExtensions {
|
||||
});
|
||||
|
||||
if (r != Result.Success) {
|
||||
list.argValue = null;
|
||||
list.set(null);
|
||||
return r;
|
||||
}
|
||||
|
||||
list.argValue = ctx.List;
|
||||
list.set(ctx.List);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -76,7 +78,7 @@ public final class RowReaderExtensions {
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface DeserializerFunc<TItem> {
|
||||
Result invoke(tangible.RefObject<RowReader> reader, tangible.OutObject<TItem> item);
|
||||
Result invoke(RefObject<RowReader> reader, OutObject<TItem> item);
|
||||
}
|
||||
|
||||
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may
|
||||
@@ -2,14 +2,23 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.io;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.io;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Float128;
|
||||
import azure.data.cosmos.serialization.hybridrow.NullValue;
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import azure.data.cosmos.serialization.hybridrow.UnixDateTime;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Float128;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.NullValue;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.UnixDateTime;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.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.TypeArgument;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.UpdateOptions;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -36,9 +45,9 @@ public final class RowWriter {
|
||||
public RowWriter() {
|
||||
}
|
||||
|
||||
private RowWriter(tangible.RefObject<RowBuffer> row, tangible.RefObject<RowCursor> scope) {
|
||||
this.row = row.argValue.clone();
|
||||
this.cursor = scope.argValue.clone();
|
||||
private RowWriter(RefObject<RowBuffer> row, RefObject<RowCursor> scope) {
|
||||
this.row = row.get().clone();
|
||||
this.cursor = scope.get().clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,21 +160,21 @@ public final class RowWriter {
|
||||
* @param func A function to write the entire row.
|
||||
* @return Success if the write is successful, an error code otherwise.
|
||||
*/
|
||||
public static <TContext> Result WriteBuffer(tangible.RefObject<RowBuffer> row, TContext context,
|
||||
public static <TContext> Result WriteBuffer(RefObject<RowBuffer> row, TContext context,
|
||||
WriterFunc<TContext> func) {
|
||||
RowCursor scope = RowCursor.Create(row);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_scope =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(scope);
|
||||
RefObject<RowCursor> tempRef_scope =
|
||||
new RefObject<RowCursor>(scope);
|
||||
RowWriter writer = new RowWriter(row, tempRef_scope);
|
||||
scope = tempRef_scope.argValue;
|
||||
scope = tempRef_scope.get();
|
||||
TypeArgument typeArg = new TypeArgument(LayoutType.UDT,
|
||||
new TypeArgumentList(scope.layout.getSchemaId().clone()));
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter> tempRef_writer =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter>(writer);
|
||||
RefObject<RowWriter> tempRef_writer =
|
||||
new RefObject<RowWriter>(writer);
|
||||
// TODO: C# TO JAVA CONVERTER: The following line could not be converted:
|
||||
Result result = func(ref writer, typeArg, context);
|
||||
writer = tempRef_writer.argValue;
|
||||
row.argValue = writer.row.clone();
|
||||
writer = tempRef_writer.get();
|
||||
row.set(writer.row.clone());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -374,37 +383,37 @@ public final class RowWriter {
|
||||
//ORIGINAL LINE: case LayoutObject scopeType:
|
||||
case LayoutObject
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteSparseObject(tempRef_cursor, scopeType, UpdateOptions.Upsert, tempOut_nestedScope);
|
||||
nestedScope = tempOut_nestedScope.argValue;
|
||||
nestedScope = tempOut_nestedScope.get();
|
||||
this.cursor = tempRef_cursor.argValue;
|
||||
break;
|
||||
// TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements:
|
||||
//ORIGINAL LINE: case LayoutArray scopeType:
|
||||
case LayoutArray
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor2 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope2 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor2 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope2 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteSparseArray(tempRef_cursor2, scopeType, UpdateOptions.Upsert, tempOut_nestedScope2);
|
||||
nestedScope = tempOut_nestedScope2.argValue;
|
||||
nestedScope = tempOut_nestedScope2.get();
|
||||
this.cursor = tempRef_cursor2.argValue;
|
||||
break;
|
||||
// TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements:
|
||||
//ORIGINAL LINE: case LayoutTypedArray scopeType:
|
||||
case LayoutTypedArray
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor3 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope3 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor3 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope3 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteTypedArray(tempRef_cursor3, scopeType, typeArg.getTypeArgs().clone(),
|
||||
UpdateOptions.Upsert, tempOut_nestedScope3);
|
||||
nestedScope = tempOut_nestedScope3.argValue;
|
||||
nestedScope = tempOut_nestedScope3.get();
|
||||
this.cursor = tempRef_cursor3.argValue;
|
||||
|
||||
break;
|
||||
@@ -412,13 +421,13 @@ public final class RowWriter {
|
||||
//ORIGINAL LINE: case LayoutTuple scopeType:
|
||||
case LayoutTuple
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor4 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope4 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor4 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope4 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteSparseTuple(tempRef_cursor4, scopeType, typeArg.getTypeArgs().clone(),
|
||||
UpdateOptions.Upsert, tempOut_nestedScope4);
|
||||
nestedScope = tempOut_nestedScope4.argValue;
|
||||
nestedScope = tempOut_nestedScope4.get();
|
||||
this.cursor = tempRef_cursor4.argValue;
|
||||
|
||||
break;
|
||||
@@ -426,13 +435,13 @@ public final class RowWriter {
|
||||
//ORIGINAL LINE: case LayoutTypedTuple scopeType:
|
||||
case LayoutTypedTuple
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor5 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope5 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor5 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope5 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteTypedTuple(tempRef_cursor5, scopeType, typeArg.getTypeArgs().clone(),
|
||||
UpdateOptions.Upsert, tempOut_nestedScope5);
|
||||
nestedScope = tempOut_nestedScope5.argValue;
|
||||
nestedScope = tempOut_nestedScope5.get();
|
||||
this.cursor = tempRef_cursor5.argValue;
|
||||
|
||||
break;
|
||||
@@ -440,13 +449,13 @@ public final class RowWriter {
|
||||
//ORIGINAL LINE: case LayoutTagged scopeType:
|
||||
case LayoutTagged
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor6 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope6 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor6 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope6 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteTypedTuple(tempRef_cursor6, scopeType, typeArg.getTypeArgs().clone(),
|
||||
UpdateOptions.Upsert, tempOut_nestedScope6);
|
||||
nestedScope = tempOut_nestedScope6.argValue;
|
||||
nestedScope = tempOut_nestedScope6.get();
|
||||
this.cursor = tempRef_cursor6.argValue;
|
||||
|
||||
break;
|
||||
@@ -454,13 +463,13 @@ public final class RowWriter {
|
||||
//ORIGINAL LINE: case LayoutTagged2 scopeType:
|
||||
case LayoutTagged2
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor7 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope7 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor7 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope7 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteTypedTuple(tempRef_cursor7, scopeType, typeArg.getTypeArgs().clone(),
|
||||
UpdateOptions.Upsert, tempOut_nestedScope7);
|
||||
nestedScope = tempOut_nestedScope7.argValue;
|
||||
nestedScope = tempOut_nestedScope7.get();
|
||||
this.cursor = tempRef_cursor7.argValue;
|
||||
|
||||
break;
|
||||
@@ -468,13 +477,13 @@ public final class RowWriter {
|
||||
//ORIGINAL LINE: case LayoutNullable scopeType:
|
||||
case LayoutNullable
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor8 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope8 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor8 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope8 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteNullable(tempRef_cursor8, scopeType, typeArg.getTypeArgs().clone(),
|
||||
UpdateOptions.Upsert, func != null, tempOut_nestedScope8);
|
||||
nestedScope = tempOut_nestedScope8.argValue;
|
||||
nestedScope = tempOut_nestedScope8.get();
|
||||
this.cursor = tempRef_cursor8.argValue;
|
||||
|
||||
break;
|
||||
@@ -483,26 +492,26 @@ public final class RowWriter {
|
||||
case LayoutUDT
|
||||
scopeType:
|
||||
Layout udt = this.row.getResolver().Resolve(typeArg.getTypeArgs().getSchemaId().clone());
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor9 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope9 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor9 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope9 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteSparseUDT(tempRef_cursor9, scopeType, udt, UpdateOptions.Upsert, tempOut_nestedScope9);
|
||||
nestedScope = tempOut_nestedScope9.argValue;
|
||||
this.cursor = tempRef_cursor9.argValue;
|
||||
nestedScope = tempOut_nestedScope9.get();
|
||||
this.cursor = tempRef_cursor9.get();
|
||||
break;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements:
|
||||
//ORIGINAL LINE: case LayoutTypedSet scopeType:
|
||||
case LayoutTypedSet
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor10 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope10 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor10 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope10 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteTypedSet(tempRef_cursor10, scopeType, typeArg.getTypeArgs().clone(),
|
||||
UpdateOptions.Upsert, tempOut_nestedScope10);
|
||||
nestedScope = tempOut_nestedScope10.argValue;
|
||||
nestedScope = tempOut_nestedScope10.get();
|
||||
this.cursor = tempRef_cursor10.argValue;
|
||||
|
||||
break;
|
||||
@@ -510,13 +519,13 @@ public final class RowWriter {
|
||||
//ORIGINAL LINE: case LayoutTypedMap scopeType:
|
||||
case LayoutTypedMap
|
||||
scopeType:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor11 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempOut_nestedScope11 =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.RowCursor>();
|
||||
RefObject<RowCursor> tempRef_cursor11 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
OutObject<RowCursor> tempOut_nestedScope11 =
|
||||
new OutObject<RowCursor>();
|
||||
this.row.WriteTypedMap(tempRef_cursor11, scopeType, typeArg.getTypeArgs().clone(),
|
||||
UpdateOptions.Upsert, tempOut_nestedScope11);
|
||||
nestedScope = tempOut_nestedScope11.argValue;
|
||||
nestedScope = tempOut_nestedScope11.get();
|
||||
this.cursor = tempRef_cursor11.argValue;
|
||||
|
||||
break;
|
||||
@@ -525,18 +534,18 @@ public final class RowWriter {
|
||||
return Result.Failure;
|
||||
}
|
||||
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_nestedScope =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(nestedScope);
|
||||
RefObject<RowBuffer> tempRef_row =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
RefObject<RowCursor> tempRef_nestedScope =
|
||||
new RefObject<RowCursor>(nestedScope);
|
||||
RowWriter nestedWriter = new RowWriter(tempRef_row, tempRef_nestedScope);
|
||||
nestedScope = tempRef_nestedScope.argValue;
|
||||
this.row = tempRef_row.argValue;
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter> tempRef_nestedWriter =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter>(nestedWriter);
|
||||
nestedScope = tempRef_nestedScope.get();
|
||||
this.row = tempRef_row.get();
|
||||
RefObject<RowWriter> tempRef_nestedWriter =
|
||||
new RefObject<RowWriter>(nestedWriter);
|
||||
// TODO: C# TO JAVA CONVERTER: The following line could not be converted:
|
||||
result = func == null ? null : func.Invoke(ref nestedWriter, typeArg, context) ??Result.Success;
|
||||
nestedWriter = tempRef_nestedWriter.argValue;
|
||||
nestedWriter = tempRef_nestedWriter.get();
|
||||
this.row = nestedWriter.row.clone();
|
||||
nestedScope.count = nestedWriter.cursor.count;
|
||||
|
||||
@@ -546,24 +555,24 @@ public final class RowWriter {
|
||||
}
|
||||
|
||||
if (type instanceof LayoutUniqueScope) {
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_nestedScope2 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(nestedScope);
|
||||
RefObject<RowCursor> tempRef_nestedScope2 =
|
||||
new RefObject<RowCursor>(nestedScope);
|
||||
result = this.row.TypedCollectionUniqueIndexRebuild(tempRef_nestedScope2);
|
||||
nestedScope = tempRef_nestedScope2.argValue;
|
||||
nestedScope = tempRef_nestedScope2.get();
|
||||
if (result != Result.Success) {
|
||||
// TODO: If the index rebuild fails then the row is corrupted. Should we automatically clean up here?
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row2 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor12 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(nestedWriter.cursor);
|
||||
Microsoft.Azure.Cosmos.Serialization.HybridRow.RowCursorExtensions.MoveNext(this.cursor.clone(), tempRef_row2
|
||||
RefObject<RowBuffer> tempRef_row2 =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
RefObject<RowCursor> tempRef_cursor12 =
|
||||
new RefObject<RowCursor>(nestedWriter.cursor);
|
||||
RowCursorExtensions.MoveNext(this.cursor.clone(), tempRef_row2
|
||||
, tempRef_cursor12);
|
||||
nestedWriter.cursor = tempRef_cursor12.argValue;
|
||||
this.row = tempRef_row2.argValue;
|
||||
nestedWriter.cursor = tempRef_cursor12.get();
|
||||
this.row = tempRef_row2.get();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -760,13 +769,13 @@ public final class RowWriter {
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
} else if (this.cursor.scopeType instanceof LayoutTypedMap) {
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
RefObject<RowCursor> tempRef_cursor =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
if (!typeArg.equals(this.cursor.scopeType.<LayoutUniqueScope>TypeAs().FieldType(tempRef_cursor).clone())) {
|
||||
this.cursor = tempRef_cursor.argValue;
|
||||
this.cursor = tempRef_cursor.get();
|
||||
return Result.TypeConstraint;
|
||||
} else {
|
||||
this.cursor = tempRef_cursor.argValue;
|
||||
this.cursor = tempRef_cursor.get();
|
||||
}
|
||||
} else if (this.cursor.scopeType.IsTypedScope && !typeArg.equals(this.cursor.scopeTypeArgs.get(0).clone())) {
|
||||
return Result.TypeConstraint;
|
||||
@@ -799,16 +808,16 @@ public final class RowWriter {
|
||||
return result;
|
||||
}
|
||||
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter> tempRef_this =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter>(this);
|
||||
RefObject<RowWriter> tempRef_this =
|
||||
new RefObject<RowWriter>(this);
|
||||
// TODO: C# TO JAVA CONVERTER: The following line could not be converted:
|
||||
sparse(ref this, value)
|
||||
this = tempRef_this.argValue;
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
Microsoft.Azure.Cosmos.Serialization.HybridRow.RowCursorExtensions.MoveNext(this.cursor.clone(),
|
||||
this = tempRef_this.get();
|
||||
RefObject<RowBuffer> tempRef_row =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
RowCursorExtensions.MoveNext(this.cursor.clone(),
|
||||
tempRef_row);
|
||||
this.row = tempRef_row.argValue;
|
||||
this.row = tempRef_row.get();
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -838,16 +847,16 @@ public final class RowWriter {
|
||||
return result;
|
||||
}
|
||||
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter> tempRef_this =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter>(this);
|
||||
RefObject<RowWriter> tempRef_this =
|
||||
new RefObject<RowWriter>(this);
|
||||
// TODO: C# TO JAVA CONVERTER: The following line could not be converted:
|
||||
sparse(ref this, value)
|
||||
this = tempRef_this.argValue;
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
Microsoft.Azure.Cosmos.Serialization.HybridRow.RowCursorExtensions.MoveNext(this.cursor.clone(),
|
||||
this = tempRef_this.get();
|
||||
RefObject<RowBuffer> tempRef_row =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
RowCursorExtensions.MoveNext(this.cursor.clone(),
|
||||
tempRef_row);
|
||||
this.row = tempRef_row.argValue;
|
||||
this.row = tempRef_row.get();
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -877,16 +886,16 @@ public final class RowWriter {
|
||||
return result;
|
||||
}
|
||||
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter> tempRef_this =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter>(this);
|
||||
RefObject<RowWriter> tempRef_this =
|
||||
new RefObject<RowWriter>(this);
|
||||
// TODO: C# TO JAVA CONVERTER: The following line could not be converted:
|
||||
sparse(ref this, value)
|
||||
this = tempRef_this.argValue;
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
Microsoft.Azure.Cosmos.Serialization.HybridRow.RowCursorExtensions.MoveNext(this.cursor.clone(),
|
||||
this = tempRef_this.get();
|
||||
RefObject<RowBuffer> tempRef_row =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
RowCursorExtensions.MoveNext(this.cursor.clone(),
|
||||
tempRef_row);
|
||||
this.row = tempRef_row.argValue;
|
||||
this.row = tempRef_row.get();
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -917,16 +926,16 @@ public final class RowWriter {
|
||||
return result;
|
||||
}
|
||||
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter> tempRef_this =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.io.RowWriter>(this);
|
||||
RefObject<RowWriter> tempRef_this =
|
||||
new RefObject<RowWriter>(this);
|
||||
// TODO: C# TO JAVA CONVERTER: The following line could not be converted:
|
||||
sparse(ref this, value)
|
||||
this = tempRef_this.argValue;
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
Microsoft.Azure.Cosmos.Serialization.HybridRow.RowCursorExtensions.MoveNext(this.cursor.clone(),
|
||||
this = tempRef_this.get();
|
||||
RefObject<RowBuffer> tempRef_row =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
RowCursorExtensions.MoveNext(this.cursor.clone(),
|
||||
tempRef_row);
|
||||
this.row = tempRef_row.argValue;
|
||||
this.row = tempRef_row.get();
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -956,17 +965,17 @@ public final class RowWriter {
|
||||
|
||||
switch (col.Storage) {
|
||||
case StorageKind.Fixed:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
RefObject<RowBuffer> tempRef_row =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
Result tempVar2 = t.WriteFixed(ref this.row, ref this.cursor, col, value)
|
||||
this.row = tempRef_row.argValue;
|
||||
this.row = tempRef_row.get();
|
||||
return tempVar2;
|
||||
|
||||
case StorageKind.Variable:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row2 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
RefObject<RowBuffer> tempRef_row2 =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
Result tempVar3 = t.WriteVariable(ref this.row, ref this.cursor, col, value)
|
||||
this.row = tempRef_row2.argValue;
|
||||
this.row = tempRef_row2.get();
|
||||
return tempVar3;
|
||||
|
||||
default:
|
||||
@@ -998,24 +1007,24 @@ public final class RowWriter {
|
||||
|
||||
switch (col.Storage) {
|
||||
case StorageKind.Fixed:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
RefObject<RowBuffer> tempRef_row =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
RefObject<RowCursor> tempRef_cursor =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
Result tempVar = t.<ILayoutUtf8SpanWritable>TypeAs().WriteFixed(tempRef_row, tempRef_cursor, col,
|
||||
value);
|
||||
this.cursor = tempRef_cursor.argValue;
|
||||
this.row = tempRef_row.argValue;
|
||||
this.cursor = tempRef_cursor.get();
|
||||
this.row = tempRef_row.get();
|
||||
return tempVar;
|
||||
case StorageKind.Variable:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row2 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor2 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
RefObject<RowBuffer> tempRef_row2 =
|
||||
new RefObject<RowBuffer>(this.row);
|
||||
RefObject<RowCursor> tempRef_cursor2 =
|
||||
new RefObject<RowCursor>(this.cursor);
|
||||
Result tempVar2 = t.<ILayoutUtf8SpanWritable>TypeAs().WriteVariable(tempRef_row2, tempRef_cursor2,
|
||||
col, value);
|
||||
this.cursor = tempRef_cursor2.argValue;
|
||||
this.row = tempRef_row2.argValue;
|
||||
this.cursor = tempRef_cursor2.get();
|
||||
this.row = tempRef_row2.get();
|
||||
return tempVar2;
|
||||
default:
|
||||
return Result.NotFound;
|
||||
@@ -1044,18 +1053,18 @@ public final class RowWriter {
|
||||
|
||||
switch (col.Storage) {
|
||||
case StorageKind.Fixed:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row = new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor = new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
RefObject<RowBuffer> tempRef_row = new RefObject<RowBuffer>(this.row);
|
||||
RefObject<RowCursor> tempRef_cursor = new RefObject<RowCursor>(this.cursor);
|
||||
Result tempVar = t.<ILayoutSpanWritable<TElement>>TypeAs().WriteFixed(tempRef_row, tempRef_cursor, col, value);
|
||||
this.cursor = tempRef_cursor.argValue;
|
||||
this.row = tempRef_row.argValue;
|
||||
this.cursor = tempRef_cursor.get();
|
||||
this.row = tempRef_row.get();
|
||||
return tempVar;
|
||||
case StorageKind.Variable:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row2 = new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor2 = new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
RefObject<RowBuffer> tempRef_row2 = new RefObject<RowBuffer>(this.row);
|
||||
RefObject<RowCursor> tempRef_cursor2 = new RefObject<RowCursor>(this.cursor);
|
||||
Result tempVar2 = t.<ILayoutSpanWritable<TElement>>TypeAs().WriteVariable(tempRef_row2, tempRef_cursor2, col, value);
|
||||
this.cursor = tempRef_cursor2.argValue;
|
||||
this.row = tempRef_row2.argValue;
|
||||
this.cursor = tempRef_cursor2.get();
|
||||
this.row = tempRef_row2.get();
|
||||
return tempVar2;
|
||||
default:
|
||||
return Result.NotFound;
|
||||
@@ -1084,18 +1093,18 @@ public final class RowWriter {
|
||||
|
||||
switch (col.Storage) {
|
||||
case StorageKind.Fixed:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row = new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor = new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
RefObject<RowBuffer> tempRef_row = new RefObject<RowBuffer>(this.row);
|
||||
RefObject<RowCursor> tempRef_cursor = new RefObject<RowCursor>(this.cursor);
|
||||
Result tempVar = t.<ILayoutSequenceWritable<TElement>>TypeAs().WriteFixed(tempRef_row, tempRef_cursor, col, value);
|
||||
this.cursor = tempRef_cursor.argValue;
|
||||
this.row = tempRef_row.argValue;
|
||||
this.cursor = tempRef_cursor.get();
|
||||
this.row = tempRef_row.get();
|
||||
return tempVar;
|
||||
case StorageKind.Variable:
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer> tempRef_row2 = new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowBuffer>(this.row);
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_cursor2 = new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(this.cursor);
|
||||
RefObject<RowBuffer> tempRef_row2 = new RefObject<RowBuffer>(this.row);
|
||||
RefObject<RowCursor> tempRef_cursor2 = new RefObject<RowCursor>(this.cursor);
|
||||
Result tempVar2 = t.<ILayoutSequenceWritable<TElement>>TypeAs().WriteVariable(tempRef_row2, tempRef_cursor2, col, value);
|
||||
this.cursor = tempRef_cursor2.argValue;
|
||||
this.row = tempRef_row2.argValue;
|
||||
this.cursor = tempRef_cursor2.get();
|
||||
this.row = tempRef_row2.get();
|
||||
return tempVar2;
|
||||
default:
|
||||
return Result.NotFound;
|
||||
@@ -1104,17 +1113,17 @@ public final class RowWriter {
|
||||
|
||||
@FunctionalInterface
|
||||
private interface AccessMethod<TValue> {
|
||||
void invoke(tangible.RefObject<RowWriter> writer, TValue value);
|
||||
void invoke(RefObject<RowWriter> writer, TValue value);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface AccessReadOnlySpanMethod<T> {
|
||||
void invoke(tangible.RefObject<RowWriter> writer, ReadOnlySpan value);
|
||||
void invoke(RefObject<RowWriter> writer, ReadOnlySpan value);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface AccessUtf8SpanMethod {
|
||||
void invoke(tangible.RefObject<RowWriter> writer, Utf8Span value);
|
||||
void invoke(RefObject<RowWriter> writer, Utf8Span value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1128,6 +1137,6 @@ public final class RowWriter {
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface WriterFunc<TContext> {
|
||||
Result invoke(tangible.RefObject<RowWriter> writer, TypeArgument typeArg, TContext context);
|
||||
Result invoke(RefObject<RowWriter> writer, TypeArgument typeArg, TContext context);
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,17 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.json;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.json;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Float128;
|
||||
import azure.data.cosmos.serialization.hybridrow.NullValue;
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.UnixDateTime;
|
||||
import azure.data.cosmos.serialization.hybridrow.io.RowReader;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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.UnixDateTime;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.io.RowReader;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class RowReaderJsonExtensions {
|
||||
/**
|
||||
@@ -18,8 +22,8 @@ public final class RowReaderJsonExtensions {
|
||||
* @param str If successful, the JSON document that corresponds to the <paramref name="reader"/>.
|
||||
* @return The result.
|
||||
*/
|
||||
public static Result ToJson(tangible.RefObject<RowReader> reader, tangible.OutObject<String> str) {
|
||||
return azure.data.cosmos.serialization.hybridrow.json.RowReaderJsonExtensions.ToJson(reader.argValue.clone(), new RowReaderJsonSettings(" "), str);
|
||||
public static Result ToJson(RefObject<RowReader> reader, OutObject<String> str) {
|
||||
return RowReaderJsonExtensions.ToJson(reader.get().clone(), new RowReaderJsonSettings(" "), str);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,29 +34,29 @@ public final class RowReaderJsonExtensions {
|
||||
* @param str If successful, the JSON document that corresponds to the <paramref name="reader"/>.
|
||||
* @return The result.
|
||||
*/
|
||||
public static Result ToJson(tangible.RefObject<RowReader> reader, RowReaderJsonSettings settings,
|
||||
tangible.OutObject<String> str) {
|
||||
public static Result ToJson(RefObject<RowReader> reader, RowReaderJsonSettings settings,
|
||||
OutObject<String> str) {
|
||||
ReaderStringContext ctx = new ReaderStringContext(new StringBuilder(),
|
||||
new RowReaderJsonSettings(settings.IndentChars, settings.QuoteChar == '\'' ? '\'' : '"'), 1);
|
||||
|
||||
ctx.Builder.append("{");
|
||||
Result result = RowReaderJsonExtensions.ToJson(reader, ctx.clone());
|
||||
if (result != Result.Success) {
|
||||
str.argValue = null;
|
||||
str.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
ctx.Builder.append(ctx.NewLine);
|
||||
ctx.Builder.append("}");
|
||||
str.argValue = ctx.Builder.toString();
|
||||
str.set(ctx.Builder.toString());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
private static Result ToJson(tangible.RefObject<RowReader> reader, ReaderStringContext ctx) {
|
||||
private static Result ToJson(RefObject<RowReader> reader, ReaderStringContext ctx) {
|
||||
int index = 0;
|
||||
while (reader.argValue.Read()) {
|
||||
String path = !reader.argValue.getPath().IsNull ? String.format("%1$s%2$s%3$s:", ctx.Settings.QuoteChar,
|
||||
reader.argValue.getPath(), ctx.Settings.QuoteChar) : null;
|
||||
while (reader.get().Read()) {
|
||||
String path = !reader.get().getPath().IsNull ? String.format("%1$s%2$s%3$s:", ctx.Settings.QuoteChar,
|
||||
reader.get().getPath(), ctx.Settings.QuoteChar) : null;
|
||||
if (index != 0) {
|
||||
ctx.Builder.append(',');
|
||||
}
|
||||
@@ -68,13 +72,13 @@ public final class RowReaderJsonExtensions {
|
||||
Result r;
|
||||
char scopeBracket = '\0';
|
||||
char scopeCloseBracket = '\0';
|
||||
switch (reader.argValue.getType().LayoutCode) {
|
||||
switch (reader.get().getType().LayoutCode) {
|
||||
case Null: {
|
||||
NullValue _;
|
||||
tangible.OutObject<Microsoft.Azure.Cosmos.Serialization.HybridRow.NullValue> tempOut__ =
|
||||
new tangible.OutObject<Microsoft.Azure.Cosmos.Serialization.HybridRow.NullValue>();
|
||||
r = reader.argValue.ReadNull(tempOut__);
|
||||
_ = tempOut__.argValue;
|
||||
OutObject<NullValue> tempOut__ =
|
||||
new OutObject<NullValue>();
|
||||
r = reader.get().ReadNull(tempOut__);
|
||||
_ = tempOut__.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -85,9 +89,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case Boolean: {
|
||||
boolean value;
|
||||
tangible.OutObject<Boolean> tempOut_value = new tangible.OutObject<Boolean>();
|
||||
r = reader.argValue.ReadBool(tempOut_value);
|
||||
value = tempOut_value.argValue;
|
||||
OutObject<Boolean> tempOut_value = new OutObject<Boolean>();
|
||||
r = reader.get().ReadBool(tempOut_value);
|
||||
value = tempOut_value.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -98,9 +102,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case Int8: {
|
||||
byte value;
|
||||
tangible.OutObject<Byte> tempOut_value2 = new tangible.OutObject<Byte>();
|
||||
r = reader.argValue.ReadInt8(tempOut_value2);
|
||||
value = tempOut_value2.argValue;
|
||||
OutObject<Byte> tempOut_value2 = new OutObject<Byte>();
|
||||
r = reader.get().ReadInt8(tempOut_value2);
|
||||
value = tempOut_value2.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -111,9 +115,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case Int16: {
|
||||
short value;
|
||||
tangible.OutObject<Short> tempOut_value3 = new tangible.OutObject<Short>();
|
||||
r = reader.argValue.ReadInt16(tempOut_value3);
|
||||
value = tempOut_value3.argValue;
|
||||
OutObject<Short> tempOut_value3 = new OutObject<Short>();
|
||||
r = reader.get().ReadInt16(tempOut_value3);
|
||||
value = tempOut_value3.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -124,9 +128,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case Int32: {
|
||||
int value;
|
||||
tangible.OutObject<Integer> tempOut_value4 = new tangible.OutObject<Integer>();
|
||||
r = reader.argValue.ReadInt32(tempOut_value4);
|
||||
value = tempOut_value4.argValue;
|
||||
OutObject<Integer> tempOut_value4 = new OutObject<Integer>();
|
||||
r = reader.get().ReadInt32(tempOut_value4);
|
||||
value = tempOut_value4.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -137,9 +141,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case Int64: {
|
||||
long value;
|
||||
tangible.OutObject<Long> tempOut_value5 = new tangible.OutObject<Long>();
|
||||
r = reader.argValue.ReadInt64(tempOut_value5);
|
||||
value = tempOut_value5.argValue;
|
||||
OutObject<Long> tempOut_value5 = new OutObject<Long>();
|
||||
r = reader.get().ReadInt64(tempOut_value5);
|
||||
value = tempOut_value5.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -150,11 +154,11 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case UInt8: {
|
||||
byte value;
|
||||
tangible.OutObject<Byte> tempOut_value6 = new tangible.OutObject<Byte>();
|
||||
OutObject<Byte> tempOut_value6 = new OutObject<Byte>();
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: r = reader.ReadUInt8(out byte value);
|
||||
r = reader.argValue.ReadUInt8(tempOut_value6);
|
||||
value = tempOut_value6.argValue;
|
||||
r = reader.get().ReadUInt8(tempOut_value6);
|
||||
value = tempOut_value6.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -165,11 +169,11 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case UInt16: {
|
||||
short value;
|
||||
tangible.OutObject<Short> tempOut_value7 = new tangible.OutObject<Short>();
|
||||
OutObject<Short> tempOut_value7 = new OutObject<Short>();
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: r = reader.ReadUInt16(out ushort value);
|
||||
r = reader.argValue.ReadUInt16(tempOut_value7);
|
||||
value = tempOut_value7.argValue;
|
||||
r = reader.get().ReadUInt16(tempOut_value7);
|
||||
value = tempOut_value7.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -180,11 +184,11 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case UInt32: {
|
||||
int value;
|
||||
tangible.OutObject<Integer> tempOut_value8 = new tangible.OutObject<Integer>();
|
||||
OutObject<Integer> tempOut_value8 = new OutObject<Integer>();
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: r = reader.ReadUInt32(out uint value);
|
||||
r = reader.argValue.ReadUInt32(tempOut_value8);
|
||||
value = tempOut_value8.argValue;
|
||||
r = reader.get().ReadUInt32(tempOut_value8);
|
||||
value = tempOut_value8.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -195,11 +199,11 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case UInt64: {
|
||||
long value;
|
||||
tangible.OutObject<Long> tempOut_value9 = new tangible.OutObject<Long>();
|
||||
OutObject<Long> tempOut_value9 = new OutObject<Long>();
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: r = reader.ReadUInt64(out ulong value);
|
||||
r = reader.argValue.ReadUInt64(tempOut_value9);
|
||||
value = tempOut_value9.argValue;
|
||||
r = reader.get().ReadUInt64(tempOut_value9);
|
||||
value = tempOut_value9.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -210,9 +214,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case VarInt: {
|
||||
long value;
|
||||
tangible.OutObject<Long> tempOut_value10 = new tangible.OutObject<Long>();
|
||||
r = reader.argValue.ReadVarInt(tempOut_value10);
|
||||
value = tempOut_value10.argValue;
|
||||
OutObject<Long> tempOut_value10 = new OutObject<Long>();
|
||||
r = reader.get().ReadVarInt(tempOut_value10);
|
||||
value = tempOut_value10.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -223,11 +227,11 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case VarUInt: {
|
||||
long value;
|
||||
tangible.OutObject<Long> tempOut_value11 = new tangible.OutObject<Long>();
|
||||
OutObject<Long> tempOut_value11 = new OutObject<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.argValue.ReadVarUInt(tempOut_value11);
|
||||
value = tempOut_value11.argValue;
|
||||
r = reader.get().ReadVarUInt(tempOut_value11);
|
||||
value = tempOut_value11.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -238,9 +242,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case Float32: {
|
||||
float value;
|
||||
tangible.OutObject<Float> tempOut_value12 = new tangible.OutObject<Float>();
|
||||
r = reader.argValue.ReadFloat32(tempOut_value12);
|
||||
value = tempOut_value12.argValue;
|
||||
OutObject<Float> tempOut_value12 = new OutObject<Float>();
|
||||
r = reader.get().ReadFloat32(tempOut_value12);
|
||||
value = tempOut_value12.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -251,9 +255,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case Float64: {
|
||||
double value;
|
||||
tangible.OutObject<Double> tempOut_value13 = new tangible.OutObject<Double>();
|
||||
r = reader.argValue.ReadFloat64(tempOut_value13);
|
||||
value = tempOut_value13.argValue;
|
||||
OutObject<Double> tempOut_value13 = new OutObject<Double>();
|
||||
r = reader.get().ReadFloat64(tempOut_value13);
|
||||
value = tempOut_value13.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -264,24 +268,24 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case Float128: {
|
||||
Float128 _;
|
||||
tangible.OutObject<Microsoft.Azure.Cosmos.Serialization.HybridRow.Float128> tempOut__2 =
|
||||
new tangible.OutObject<Microsoft.Azure.Cosmos.Serialization.HybridRow.Float128>();
|
||||
r = reader.argValue.ReadFloat128(tempOut__2);
|
||||
_ = tempOut__2.argValue;
|
||||
OutObject<Float128> tempOut__2 =
|
||||
new OutObject<Float128>();
|
||||
r = reader.get().ReadFloat128(tempOut__2);
|
||||
_ = tempOut__2.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
|
||||
// ctx.Builder.AppendFormat("High: {0}, Low: {1}\n", value.High, value.Low);
|
||||
Contract.Assert(false, "Float128 are not supported.");
|
||||
checkState(false, "Float128 are not supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
case Decimal: {
|
||||
java.math.BigDecimal value;
|
||||
tangible.OutObject<BigDecimal> tempOut_value14 = new tangible.OutObject<BigDecimal>();
|
||||
r = reader.argValue.ReadDecimal(tempOut_value14);
|
||||
value = tempOut_value14.argValue;
|
||||
OutObject<BigDecimal> tempOut_value14 = new OutObject<BigDecimal>();
|
||||
r = reader.get().ReadDecimal(tempOut_value14);
|
||||
value = tempOut_value14.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -292,9 +296,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case DateTime: {
|
||||
java.time.LocalDateTime value;
|
||||
tangible.OutObject<LocalDateTime> tempOut_value15 = new tangible.OutObject<LocalDateTime>();
|
||||
r = reader.argValue.ReadDateTime(tempOut_value15);
|
||||
value = tempOut_value15.argValue;
|
||||
OutObject<LocalDateTime> tempOut_value15 = new OutObject<LocalDateTime>();
|
||||
r = reader.get().ReadDateTime(tempOut_value15);
|
||||
value = tempOut_value15.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -307,10 +311,10 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case UnixDateTime: {
|
||||
UnixDateTime value;
|
||||
tangible.OutObject<Microsoft.Azure.Cosmos.Serialization.HybridRow.UnixDateTime> tempOut_value16 =
|
||||
new tangible.OutObject<Microsoft.Azure.Cosmos.Serialization.HybridRow.UnixDateTime>();
|
||||
r = reader.argValue.ReadUnixDateTime(tempOut_value16);
|
||||
value = tempOut_value16.argValue;
|
||||
OutObject<UnixDateTime> tempOut_value16 =
|
||||
new OutObject<UnixDateTime>();
|
||||
r = reader.get().ReadUnixDateTime(tempOut_value16);
|
||||
value = tempOut_value16.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -321,9 +325,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case Guid: {
|
||||
java.util.UUID value;
|
||||
tangible.OutObject<UUID> tempOut_value17 = new tangible.OutObject<UUID>();
|
||||
r = reader.argValue.ReadGuid(tempOut_value17);
|
||||
value = tempOut_value17.argValue;
|
||||
OutObject<UUID> tempOut_value17 = new OutObject<UUID>();
|
||||
r = reader.get().ReadGuid(tempOut_value17);
|
||||
value = tempOut_value17.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -336,9 +340,9 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case MongoDbObjectId: {
|
||||
MongoDbObjectId value;
|
||||
tangible.OutObject<Microsoft.Azure.Cosmos.Serialization.HybridRow.MongoDbObjectId> tempOut_value18 = new tangible.OutObject<Microsoft.Azure.Cosmos.Serialization.HybridRow.MongoDbObjectId>();
|
||||
r = reader.argValue.ReadMongoDbObjectId(tempOut_value18);
|
||||
value = tempOut_value18.argValue;
|
||||
OutObject<azure.data.cosmos.serialization.hybridrow.MongoDbObjectId> tempOut_value18 = new OutObject<azure.data.cosmos.serialization.hybridrow.MongoDbObjectId>();
|
||||
r = reader.get().ReadMongoDbObjectId(tempOut_value18);
|
||||
value = tempOut_value18.get();
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -357,7 +361,7 @@ public final class RowReaderJsonExtensions {
|
||||
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword
|
||||
// - these cannot be converted using the 'OutObject' helper class unless the method is within the
|
||||
// code being modified:
|
||||
r = reader.argValue.ReadString(out value);
|
||||
r = reader.get().ReadString(out value);
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -373,7 +377,7 @@ public final class RowReaderJsonExtensions {
|
||||
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'OutObject' 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: r = reader.ReadBinary(out ReadOnlySpan<byte> value);
|
||||
r = reader.argValue.ReadBinary(out value);
|
||||
r = reader.get().ReadBinary(out value);
|
||||
if (r != Result.Success) {
|
||||
return r;
|
||||
}
|
||||
@@ -386,13 +390,13 @@ public final class RowReaderJsonExtensions {
|
||||
|
||||
case NullableScope:
|
||||
case ImmutableNullableScope: {
|
||||
if (!reader.argValue.getHasValue()) {
|
||||
if (!reader.get().getHasValue()) {
|
||||
ctx.Builder.append("null");
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java:
|
||||
goto case LayoutCode.TypedTupleScope
|
||||
// goto case LayoutCode.TypedTupleScope;
|
||||
}
|
||||
|
||||
case ArrayScope:
|
||||
@@ -414,7 +418,7 @@ public final class RowReaderJsonExtensions {
|
||||
scopeBracket = '[';
|
||||
scopeCloseBracket = ']';
|
||||
// TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java:
|
||||
goto case LayoutCode.EndScope
|
||||
// goto case LayoutCode.EndScope;
|
||||
case ObjectScope:
|
||||
case ImmutableObjectScope:
|
||||
case Schema:
|
||||
@@ -425,7 +429,7 @@ public final class RowReaderJsonExtensions {
|
||||
case EndScope: {
|
||||
ctx.Builder.append(scopeBracket);
|
||||
int snapshot = ctx.Builder.length();
|
||||
r = reader.argValue.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;
|
||||
}
|
||||
@@ -440,7 +444,7 @@ public final class RowReaderJsonExtensions {
|
||||
}
|
||||
|
||||
default: {
|
||||
Contract.Assert(false, String.format("Unknown type will be ignored: %1$s", reader.argValue.getType().LayoutCode));
|
||||
throw new IllegalStateException(lenientFormat("Unknown type will be ignored: %s", reader.get().getType().LayoutCode));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.json;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.json;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
|
||||
///#pragma warning disable CA1051 // Do not declare visible instance fields
|
||||
@@ -33,9 +33,6 @@ public final class RowReaderJsonSettings {
|
||||
this(" ", '"');
|
||||
}
|
||||
|
||||
public RowReaderJsonSettings() {
|
||||
}
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: public RowReaderJsonSettings(string indentChars = " ", char quoteChar = '"')
|
||||
public RowReaderJsonSettings(String indentChars, char quoteChar) {
|
||||
@@ -2,11 +2,12 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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 <see cref="LayoutType{T}" /> can also write using a
|
||||
@@ -15,18 +16,18 @@ import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
* <typeparam name="TElement">The sub-element type to be written.</typeparam>
|
||||
*/
|
||||
public interface ILayoutSequenceWritable<TElement> extends ILayoutType {
|
||||
Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
ReadOnlySequence<TElement> value);
|
||||
|
||||
Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
ReadOnlySequence<TElement> value);
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: Result WriteSparse(ref RowBuffer b, ref RowCursor edit, ReadOnlySequence<TElement> value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert);
|
||||
Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
ReadOnlySequence<TElement> value, UpdateOptions options);
|
||||
|
||||
Result WriteVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Result WriteVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
ReadOnlySequence<TElement> value);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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 <see cref="LayoutType{T}" /> can also read using a
|
||||
* <see cref="ReadOnlySpan{T}" />.
|
||||
*
|
||||
* <typeparam name="TElement">The sub-element type to be written.</typeparam>
|
||||
*/
|
||||
public interface ILayoutSpanReadable<TElement> extends ILayoutType {
|
||||
Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<ReadOnlySpan<TElement>> value);
|
||||
|
||||
Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
OutObject<ReadOnlySpan<TElement>> value);
|
||||
|
||||
Result ReadVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<ReadOnlySpan<TElement>> value);
|
||||
}
|
||||
@@ -2,11 +2,12 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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 <see cref="LayoutType{T}" /> can also write using a
|
||||
@@ -15,18 +16,18 @@ import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
* <typeparam name="TElement">The sub-element type to be written.</typeparam>
|
||||
*/
|
||||
public interface ILayoutSpanWritable<TElement> extends ILayoutType {
|
||||
Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
ReadOnlySpan<TElement> value);
|
||||
|
||||
Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
ReadOnlySpan<TElement> value);
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: Result WriteSparse(ref RowBuffer b, ref RowCursor edit, ReadOnlySpan<TElement> value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert);
|
||||
Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
ReadOnlySpan<TElement> value, UpdateOptions options);
|
||||
|
||||
Result WriteVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Result WriteVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
ReadOnlySpan<TElement> value);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
/**
|
||||
* Marker interface for layout types.
|
||||
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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 <see cref="LayoutType{T}" /> can also read using a
|
||||
* <see cref="Utf8Span" />.
|
||||
*/
|
||||
public interface ILayoutUtf8SpanReadable extends ILayoutType {
|
||||
Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Utf8Span> value);
|
||||
|
||||
Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> scope, OutObject<Utf8Span> value);
|
||||
|
||||
Result ReadVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Utf8Span> value);
|
||||
}
|
||||
@@ -2,27 +2,28 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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 <see cref="LayoutType{T}" /> can also write using a
|
||||
* <see cref="Utf8Span" />.
|
||||
*/
|
||||
public interface ILayoutUtf8SpanWritable extends ILayoutType {
|
||||
Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Utf8Span value);
|
||||
|
||||
Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, Utf8Span value);
|
||||
Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, Utf8Span value);
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: Result WriteSparse(ref RowBuffer b, ref RowCursor edit, Utf8Span value, UpdateOptions options =
|
||||
// UpdateOptions.Upsert);
|
||||
Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, Utf8Span value, UpdateOptions options);
|
||||
Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, Utf8Span value, UpdateOptions options);
|
||||
|
||||
Result WriteVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Result WriteVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Utf8Span value);
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.StorageKind;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -53,7 +55,7 @@ public final class Layout {
|
||||
/**
|
||||
* Unique identifier of the schema from which this <see cref="Layout" /> was generated.
|
||||
*/
|
||||
private SchemaId SchemaId = new SchemaId();
|
||||
private com.azure.data.cosmos.serialization.hybridrow.SchemaId SchemaId = new SchemaId();
|
||||
/**
|
||||
* Minimum required size of a row of this layout.
|
||||
* <p>
|
||||
@@ -134,18 +136,17 @@ public final class Layout {
|
||||
* @param column If found, the column specification, otherwise null.
|
||||
* @return True if a column with the path is found, otherwise false.
|
||||
*/
|
||||
public boolean TryFind(UtfAnyString path, tangible.OutObject<LayoutColumn> column) {
|
||||
public boolean TryFind(UtfAnyString path, OutObject<LayoutColumn> column) {
|
||||
if (path.IsNull) {
|
||||
column.argValue = null;
|
||||
column.set(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (path.IsUtf8) {
|
||||
return (this.pathMap.containsKey(path.ToUtf8String()) && (column.argValue =
|
||||
this.pathMap.get(path.ToUtf8String())) == column.argValue);
|
||||
return (this.pathMap.containsKey(path.ToUtf8String()) && (column.set(this.pathMap.get(path.ToUtf8String()))) == column.get());
|
||||
}
|
||||
|
||||
return (this.pathStringMap.containsKey(path) && (column.argValue = this.pathStringMap.get(path)) == column.argValue);
|
||||
return (this.pathStringMap.containsKey(path) && (column.set(this.pathStringMap.get(path))) == column.get());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,8 +156,8 @@ public final class Layout {
|
||||
* @param column If found, the column specification, otherwise null.
|
||||
* @return True if a column with the path is found, otherwise false.
|
||||
*/
|
||||
public boolean TryFind(String path, tangible.OutObject<LayoutColumn> column) {
|
||||
return (this.pathStringMap.containsKey(path) && (column.argValue = this.pathStringMap.get(path)) == column.argValue);
|
||||
public boolean TryFind(String path, OutObject<LayoutColumn> column) {
|
||||
return (this.pathStringMap.containsKey(path) && (column.set(this.pathStringMap.get(path))) == column.get());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2,14 +2,16 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ArrayScope;
|
||||
import static azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableArrayScope;
|
||||
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ArrayScope;
|
||||
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableArrayScope;
|
||||
|
||||
public final class LayoutArray extends LayoutIndexedScope {
|
||||
private TypeArgument TypeArg = new TypeArgument();
|
||||
@@ -28,10 +30,13 @@ public final class LayoutArray extends LayoutIndexedScope {
|
||||
return TypeArg;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
public Result WriteScope(
|
||||
RefObject<RowBuffer> b,
|
||||
RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs,
|
||||
OutObject<RowCursor> value
|
||||
) {
|
||||
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
|
||||
}
|
||||
|
||||
@@ -39,15 +44,15 @@ public final class LayoutArray extends LayoutIndexedScope {
|
||||
//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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseArray(edit, this, options, value.clone());
|
||||
b.get().WriteSparseArray(edit, this, options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,13 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@@ -16,7 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpanWritable<Byte>,
|
||||
ILayoutSpanReadable<Byte>, ILayoutSequenceWritable<Byte> {
|
||||
public LayoutBinary() {
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Binary, 0);
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Binary, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,15 +35,15 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
//ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
|
||||
// byte[] value)
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<byte[]> value) {
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<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 'OutObject' 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, col, out span);
|
||||
value.argValue = (r == Result.Success) ? span.ToArray() :
|
||||
value.set((r == Result.Success) ? span.ToArray() :)
|
||||
default
|
||||
return r;
|
||||
}
|
||||
@@ -49,44 +51,44 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
//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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<ReadOnlySpan<Byte>> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<ReadOnlySpan<Byte>> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
checkArgument(col.getSize() >= 0);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = null;
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(null);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadFixedBinary(scope.argValue.start + col.getOffset(), col.getSize());
|
||||
value.set(b.get().ReadFixedBinary(scope.get().start + col.getOffset(), col.getSize()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out byte[] value)
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<byte[]> value) {
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<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 'OutObject' 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.argValue = (r == Result.Success) ? span.ToArray() :
|
||||
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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, tangible.OutObject<ReadOnlySpan<Byte>> value) {
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, OutObject<ReadOnlySpan<Byte>> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseBinary(edit);
|
||||
value.set(b.get().ReadSparseBinary(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -94,15 +96,15 @@ 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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col
|
||||
, tangible.OutObject<byte[]> value) {
|
||||
public Result ReadVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col
|
||||
, OutObject<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 'OutObject' 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, col, out span);
|
||||
value.argValue = (r == Result.Success) ? span.ToArray() :
|
||||
value.set((r == Result.Success) ? span.ToArray() :)
|
||||
default
|
||||
return r;
|
||||
}
|
||||
@@ -110,17 +112,17 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
//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
|
||||
// ReadOnlySpan<byte> value)
|
||||
public Result ReadVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col
|
||||
, tangible.OutObject<ReadOnlySpan<Byte>> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = null;
|
||||
public Result ReadVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col
|
||||
, OutObject<ReadOnlySpan<Byte>> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(null);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
int varOffset = b.argValue.ComputeVariableValueOffset(scope.argValue.layout, scope.argValue.start,
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start,
|
||||
col.getOffset());
|
||||
value.argValue = b.argValue.ReadVariableBinary(varOffset);
|
||||
value.set(b.get().ReadVariableBinary(varOffset));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -128,7 +130,7 @@ 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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
byte[] value) {
|
||||
checkArgument(value != null);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
@@ -139,39 +141,39 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
//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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
ReadOnlySpan<Byte> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
checkArgument(col.getSize() >= 0);
|
||||
checkArgument(value.Length == col.getSize());
|
||||
if (scope.argValue.immutable) {
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteFixedBinary(scope.argValue.start + col.getOffset(), value, col.getSize());
|
||||
b.argValue.SetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
b.get().WriteFixedBinary(scope.get().start + col.getOffset(), value, col.getSize());
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
//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,
|
||||
// ReadOnlySequence<byte> value)
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
ReadOnlySequence<Byte> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
checkArgument(col.getSize() >= 0);
|
||||
checkArgument(value.Length == col.getSize());
|
||||
if (scope.argValue.immutable) {
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.argValue.WriteFixedBinary(scope.argValue.start + col.getOffset(), value, col.getSize());
|
||||
b.argValue.SetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
b.get().WriteFixedBinary(scope.get().start + col.getOffset(), value, col.getSize());
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, byte[] value) {
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, byte[] value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
|
||||
@@ -180,7 +182,7 @@ 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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, byte[] value,
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, byte[] value,
|
||||
UpdateOptions options) {
|
||||
checkArgument(value != null);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
@@ -188,7 +190,7 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
return this.WriteSparse(b, edit, new ReadOnlySpan<Byte>(value), options);
|
||||
}
|
||||
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
ReadOnlySpan<Byte> value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
@@ -197,18 +199,18 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
//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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
ReadOnlySpan<Byte> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseBinary(edit, value, options);
|
||||
b.get().WriteSparseBinary(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
ReadOnlySequence<Byte> value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
@@ -217,14 +219,14 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
//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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
ReadOnlySequence<Byte> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseBinary(edit, value, options);
|
||||
b.get().WriteSparseBinary(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -232,7 +234,7 @@ 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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public Result WriteVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
LayoutColumn col, byte[] value) {
|
||||
checkArgument(value != null);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
@@ -243,10 +245,10 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
//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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public Result WriteVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
LayoutColumn col, ReadOnlySpan<Byte> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
@@ -255,26 +257,26 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
return Result.TooBig;
|
||||
}
|
||||
|
||||
boolean exists = b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone());
|
||||
int varOffset = b.argValue.ComputeVariableValueOffset(scope.argValue.layout, scope.argValue.start,
|
||||
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone());
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start,
|
||||
col.getOffset());
|
||||
int shift;
|
||||
tangible.OutObject<Integer> tempOut_shift = new tangible.OutObject<Integer>();
|
||||
b.argValue.WriteVariableBinary(varOffset, value, exists, tempOut_shift);
|
||||
shift = tempOut_shift.argValue;
|
||||
b.argValue.SetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
scope.argValue.metaOffset += shift;
|
||||
scope.argValue.valueOffset += shift;
|
||||
OutObject<Integer> tempOut_shift = new OutObject<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 += shift;
|
||||
scope.get().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,
|
||||
// ReadOnlySequence<byte> value)
|
||||
public Result WriteVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public Result WriteVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
LayoutColumn col, ReadOnlySequence<Byte> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
@@ -283,16 +285,16 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
return Result.TooBig;
|
||||
}
|
||||
|
||||
boolean exists = b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone());
|
||||
int varOffset = b.argValue.ComputeVariableValueOffset(scope.argValue.layout, scope.argValue.start,
|
||||
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone());
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start,
|
||||
col.getOffset());
|
||||
int shift;
|
||||
tangible.OutObject<Integer> tempOut_shift = new tangible.OutObject<Integer>();
|
||||
b.argValue.WriteVariableBinary(varOffset, value, exists, tempOut_shift);
|
||||
shift = tempOut_shift.argValue;
|
||||
b.argValue.SetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
scope.argValue.metaOffset += shift;
|
||||
scope.argValue.valueOffset += shift;
|
||||
OutObject<Integer> tempOut_shift = new OutObject<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 += shift;
|
||||
scope.get().valueOffset += shift;
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@@ -107,7 +107,7 @@ public final class LayoutBit implements IEquatable<LayoutBit> {
|
||||
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(LayoutBit
|
||||
// left, LayoutBit right)
|
||||
public static boolean opNotEquals(LayoutBit left, LayoutBit right) {
|
||||
return !azure.data.cosmos.serialization.hybridrow.layouts.LayoutBit.opEquals(left.clone(), right.clone());
|
||||
return !LayoutBit.opEquals(left.clone(), right.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2,11 +2,13 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@@ -31,46 +33,46 @@ public final class LayoutBoolean extends LayoutType<Boolean> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
tangible.OutObject<Boolean> value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
value.argValue = false;
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Boolean> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(false);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadBit(scope.argValue.start, col.getBoolBit().clone());
|
||||
value.set(b.get().ReadBit(scope.get().start, col.getBoolBit().clone()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<Boolean> value) {
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<Boolean> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = false;
|
||||
value.set(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.ReadSparseBool(edit);
|
||||
value.set(b.get().ReadSparseBool(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col,
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
boolean value) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
b.argValue.SetBit(scope.argValue.start, col.getBoolBit().clone());
|
||||
b.get().SetBit(scope.get().start, col.getBoolBit().clone());
|
||||
} else {
|
||||
b.argValue.UnsetBit(scope.argValue.start, col.getBoolBit().clone());
|
||||
b.get().UnsetBit(scope.get().start, col.getBoolBit().clone());
|
||||
}
|
||||
|
||||
b.argValue.SetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -78,19 +80,19 @@ public final class LayoutBoolean extends LayoutType<Boolean> {
|
||||
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, bool value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, boolean value,
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, boolean value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseBool(edit, value, options);
|
||||
b.get().WriteSparseBool(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, boolean value) {
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, boolean value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.StorageKind;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.StorageKind;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Stack;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
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
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
public final class LayoutCodeTraits {
|
||||
/**
|
||||
@@ -2,9 +2,11 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.StorageKind;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.StorageKind;
|
||||
|
||||
import static com.google.common.base.Strings.lenientFormat;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
|
||||
//ORIGINAL LINE: [DebuggerDisplay("{FullPath + \": \" + Type.Name + TypeArgs.ToString()}")] public sealed class
|
||||
@@ -236,7 +238,7 @@ public final class LayoutColumn {
|
||||
case TypedMapScope:
|
||||
return parent.getFullPath().toString() + "[]" + path;
|
||||
default:
|
||||
Contract.Fail(String.format("Parent scope type not supported: %1$s", parent.type.LayoutCode));
|
||||
throw new IllegalStateException(lenientFormat("Parent scope type not supported: %s", parent.type.LayoutCode));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -2,23 +2,24 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.ArrayPropertyType;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.MapPropertyType;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.Namespace;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.ObjectPropertyType;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.PrimitivePropertyType;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.Property;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.PropertyType;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.Schema;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.ScopePropertyType;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.SetPropertyType;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.TaggedPropertyType;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.TuplePropertyType;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.TypeKind;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.UdtPropertyType;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.ArrayPropertyType;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.MapPropertyType;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.Namespace;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.ObjectPropertyType;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.PrimitivePropertyType;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.Property;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.PropertyType;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.Schema;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.ScopePropertyType;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.SetPropertyType;
|
||||
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 java.util.ArrayList;
|
||||
|
||||
@@ -52,10 +53,10 @@ public final class LayoutCompiler {
|
||||
ArrayList<Property> properties) {
|
||||
for (Property p : properties) {
|
||||
TypeArgumentList typeArgs = new TypeArgumentList();
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList> tempOut_typeArgs =
|
||||
new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList>();
|
||||
OutObject<TypeArgumentList> tempOut_typeArgs =
|
||||
new OutObject<TypeArgumentList>();
|
||||
LayoutType type = LayoutCompiler.LogicalToPhysicalType(ns, p.getPropertyType(), tempOut_typeArgs);
|
||||
typeArgs = tempOut_typeArgs.argValue;
|
||||
typeArgs = tempOut_typeArgs.get();
|
||||
switch (LayoutCodeTraits.ClearImmutableBit(type.LayoutCode)) {
|
||||
case ObjectScope: {
|
||||
if (!p.getPropertyType().getNullable()) {
|
||||
@@ -148,8 +149,8 @@ public final class LayoutCompiler {
|
||||
}
|
||||
|
||||
private static LayoutType LogicalToPhysicalType(Namespace ns, PropertyType logicalType,
|
||||
tangible.OutObject<TypeArgumentList> typeArgs) {
|
||||
typeArgs.argValue = TypeArgumentList.Empty;
|
||||
OutObject<TypeArgumentList> typeArgs) {
|
||||
typeArgs.set(TypeArgumentList.Empty);
|
||||
boolean tempVar =
|
||||
(logicalType instanceof ScopePropertyType ? (ScopePropertyType)logicalType : null).getImmutable();
|
||||
boolean immutable =
|
||||
@@ -208,17 +209,17 @@ public final class LayoutCompiler {
|
||||
ArrayPropertyType ap = (ArrayPropertyType)logicalType;
|
||||
if ((ap.getItems() != null) && (ap.getItems().getType() != TypeKind.Any)) {
|
||||
TypeArgumentList itemTypeArgs = new TypeArgumentList();
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList> tempOut_itemTypeArgs = new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList>();
|
||||
OutObject<TypeArgumentList> tempOut_itemTypeArgs = new OutObject<TypeArgumentList>();
|
||||
LayoutType itemType = LayoutCompiler.LogicalToPhysicalType(ns, ap.getItems(), tempOut_itemTypeArgs);
|
||||
itemTypeArgs = tempOut_itemTypeArgs.argValue;
|
||||
itemTypeArgs = tempOut_itemTypeArgs.get();
|
||||
if (ap.getItems().getNullable()) {
|
||||
itemTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType,
|
||||
itemTypeArgs.clone()) });
|
||||
itemType = itemType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable;
|
||||
}
|
||||
|
||||
typeArgs.argValue = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType,
|
||||
itemTypeArgs.clone()) });
|
||||
typeArgs.set(new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType,
|
||||
itemTypeArgs.clone()) }));
|
||||
return immutable ? LayoutType.ImmutableTypedArray : LayoutType.TypedArray;
|
||||
}
|
||||
|
||||
@@ -227,18 +228,18 @@ public final class LayoutCompiler {
|
||||
SetPropertyType sp = (SetPropertyType)logicalType;
|
||||
if ((sp.getItems() != null) && (sp.getItems().getType() != TypeKind.Any)) {
|
||||
TypeArgumentList itemTypeArgs = new TypeArgumentList();
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList> tempOut_itemTypeArgs2 = new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList>();
|
||||
OutObject<TypeArgumentList> tempOut_itemTypeArgs2 = new OutObject<TypeArgumentList>();
|
||||
LayoutType itemType = LayoutCompiler.LogicalToPhysicalType(ns, sp.getItems(),
|
||||
tempOut_itemTypeArgs2);
|
||||
itemTypeArgs = tempOut_itemTypeArgs2.argValue;
|
||||
itemTypeArgs = tempOut_itemTypeArgs2.get();
|
||||
if (sp.getItems().getNullable()) {
|
||||
itemTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType,
|
||||
itemTypeArgs.clone()) });
|
||||
itemType = itemType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable;
|
||||
}
|
||||
|
||||
typeArgs.argValue = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType,
|
||||
itemTypeArgs.clone()) });
|
||||
typeArgs.set(new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType,
|
||||
itemTypeArgs.clone()) }));
|
||||
return immutable ? LayoutType.ImmutableTypedSet : LayoutType.TypedSet;
|
||||
}
|
||||
|
||||
@@ -250,9 +251,9 @@ public final class LayoutCompiler {
|
||||
MapPropertyType mp = (MapPropertyType)logicalType;
|
||||
if ((mp.getKeys() != null) && (mp.getKeys().getType() != TypeKind.Any) && (mp.getValues() != null) && (mp.getValues().getType() != TypeKind.Any)) {
|
||||
TypeArgumentList keyTypeArgs = new TypeArgumentList();
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList> tempOut_keyTypeArgs = new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList>();
|
||||
OutObject<TypeArgumentList> tempOut_keyTypeArgs = new OutObject<TypeArgumentList>();
|
||||
LayoutType keyType = LayoutCompiler.LogicalToPhysicalType(ns, mp.getKeys(), tempOut_keyTypeArgs);
|
||||
keyTypeArgs = tempOut_keyTypeArgs.argValue;
|
||||
keyTypeArgs = tempOut_keyTypeArgs.get();
|
||||
if (mp.getKeys().getNullable()) {
|
||||
keyTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(keyType,
|
||||
keyTypeArgs.clone()) });
|
||||
@@ -260,21 +261,21 @@ public final class LayoutCompiler {
|
||||
}
|
||||
|
||||
TypeArgumentList valueTypeArgs = new TypeArgumentList();
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList> tempOut_valueTypeArgs = new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList>();
|
||||
OutObject<TypeArgumentList> tempOut_valueTypeArgs = new OutObject<TypeArgumentList>();
|
||||
LayoutType valueType = LayoutCompiler.LogicalToPhysicalType(ns, mp.getValues(),
|
||||
tempOut_valueTypeArgs);
|
||||
valueTypeArgs = tempOut_valueTypeArgs.argValue;
|
||||
valueTypeArgs = tempOut_valueTypeArgs.get();
|
||||
if (mp.getValues().getNullable()) {
|
||||
valueTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(valueType,
|
||||
valueTypeArgs.clone()) });
|
||||
valueType = valueType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable;
|
||||
}
|
||||
|
||||
typeArgs.argValue = new TypeArgumentList(new TypeArgument[]
|
||||
typeArgs.set(new TypeArgumentList(new TypeArgument[]
|
||||
{
|
||||
new TypeArgument(keyType, keyTypeArgs.clone()),
|
||||
new TypeArgument(valueType, valueTypeArgs.clone())
|
||||
});
|
||||
}));
|
||||
return immutable ? LayoutType.ImmutableTypedMap : LayoutType.TypedMap;
|
||||
}
|
||||
|
||||
@@ -287,10 +288,10 @@ public final class LayoutCompiler {
|
||||
TypeArgument[] args = new TypeArgument[tp.getItems().size()];
|
||||
for (int i = 0; i < tp.getItems().size(); i++) {
|
||||
TypeArgumentList itemTypeArgs = new TypeArgumentList();
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList> tempOut_itemTypeArgs3 = new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList>();
|
||||
OutObject<TypeArgumentList> tempOut_itemTypeArgs3 = new OutObject<TypeArgumentList>();
|
||||
LayoutType itemType = LayoutCompiler.LogicalToPhysicalType(ns, tp.getItems().get(i),
|
||||
tempOut_itemTypeArgs3);
|
||||
itemTypeArgs = tempOut_itemTypeArgs3.argValue;
|
||||
itemTypeArgs = tempOut_itemTypeArgs3.get();
|
||||
if (tp.getItems().get(i).getNullable()) {
|
||||
itemTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType,
|
||||
itemTypeArgs.clone()) });
|
||||
@@ -300,7 +301,7 @@ public final class LayoutCompiler {
|
||||
args[i] = new TypeArgument(itemType, itemTypeArgs.clone());
|
||||
}
|
||||
|
||||
typeArgs.argValue = new TypeArgumentList(args);
|
||||
typeArgs.set(new TypeArgumentList(args));
|
||||
return immutable ? LayoutType.ImmutableTypedTuple : LayoutType.TypedTuple;
|
||||
|
||||
case Tagged:
|
||||
@@ -315,10 +316,10 @@ public final class LayoutCompiler {
|
||||
tgArgs[0] = new TypeArgument(LayoutType.UInt8, TypeArgumentList.Empty);
|
||||
for (int i = 0; i < tg.getItems().size(); i++) {
|
||||
TypeArgumentList itemTypeArgs = new TypeArgumentList();
|
||||
tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList> tempOut_itemTypeArgs4 = new tangible.OutObject<azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList>();
|
||||
OutObject<TypeArgumentList> tempOut_itemTypeArgs4 = new OutObject<TypeArgumentList>();
|
||||
LayoutType itemType = LayoutCompiler.LogicalToPhysicalType(ns, tg.getItems().get(i),
|
||||
tempOut_itemTypeArgs4);
|
||||
itemTypeArgs = tempOut_itemTypeArgs4.argValue;
|
||||
itemTypeArgs = tempOut_itemTypeArgs4.get();
|
||||
if (tg.getItems().get(i).getNullable()) {
|
||||
itemTypeArgs = new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType,
|
||||
itemTypeArgs.clone()) });
|
||||
@@ -328,7 +329,7 @@ public final class LayoutCompiler {
|
||||
tgArgs[i + 1] = new TypeArgument(itemType, itemTypeArgs.clone());
|
||||
}
|
||||
|
||||
typeArgs.argValue = new TypeArgumentList(tgArgs);
|
||||
typeArgs.set(new TypeArgumentList(tgArgs));
|
||||
switch (tg.getItems().size()) {
|
||||
case 1:
|
||||
return immutable ? LayoutType.ImmutableTagged : LayoutType.Tagged;
|
||||
@@ -341,13 +342,11 @@ public final class LayoutCompiler {
|
||||
case Schema:
|
||||
UdtPropertyType up = (UdtPropertyType)logicalType;
|
||||
Schema udtSchema;
|
||||
if (azure.data.cosmos.serialization.hybridrow.SchemaId.opEquals(up.getSchemaId().clone(),
|
||||
SchemaId.Invalid)) {
|
||||
if (SchemaId.opEquals(up.getSchemaId().clone(), SchemaId.Invalid)) {
|
||||
udtSchema = tangible.ListHelper.find(ns.getSchemas(), s = up.getName().equals( > s.Name))
|
||||
} else {
|
||||
udtSchema = tangible.ListHelper.find(ns.getSchemas(), s =
|
||||
azure.data.cosmos.serialization.hybridrow.SchemaId.opEquals( > s.SchemaId,
|
||||
up.getSchemaId().clone()))
|
||||
SchemaId.opEquals( > s.SchemaId, up.getSchemaId().clone()))
|
||||
if (!udtSchema.getName().equals(up.getName())) {
|
||||
throw new LayoutCompilationException(String.format("Ambiguous schema reference: '%1$s:%2$s'",
|
||||
up.getName(), up.getSchemaId().clone()));
|
||||
@@ -359,7 +358,7 @@ public final class LayoutCompiler {
|
||||
up.getName(), up.getSchemaId().clone()));
|
||||
}
|
||||
|
||||
typeArgs.argValue = new TypeArgumentList(udtSchema.getSchemaId().clone());
|
||||
typeArgs.set(new TypeArgumentList(udtSchema.getSchemaId().clone()));
|
||||
return immutable ? LayoutType.ImmutableUDT : LayoutType.UDT;
|
||||
|
||||
default:
|
||||
@@ -0,0 +1,90 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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.time.LocalDateTime;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutDateTime extends LayoutType<DateTime> {
|
||||
public LayoutDateTime() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.DateTime, 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "datetime";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<LocalDateTime> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(LocalDateTime.MIN);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadDateTime(scope.get().start + col.getOffset()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<LocalDateTime> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(LocalDateTime.MIN);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseDateTime(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
LocalDateTime value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteDateTime(scope.get().start + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, DateTime value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
LocalDateTime value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseDateTime(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, DateTime value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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.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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "decimal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<BigDecimal> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(new BigDecimal(0));
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadDecimal(scope.get().start + col.getOffset()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<BigDecimal> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(new BigDecimal(0));
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseDecimal(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
BigDecimal value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteDecimal(scope.get().start + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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(RefObject<RowBuffer> b, RefObject<RowCursor> edit, BigDecimal value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseDecimal(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
java.math.BigDecimal value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,13 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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 LayoutEndScope extends LayoutScope {
|
||||
public LayoutEndScope() {
|
||||
@@ -14,7 +16,7 @@ public final class LayoutEndScope extends LayoutScope {
|
||||
// following line:
|
||||
//ORIGINAL LINE: base(LayoutCode.EndScope, false, isSizedScope: false, isIndexedScope: false, isFixedArity:
|
||||
// false, isUniqueScope: false, isTypedScope: false);
|
||||
super(azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.EndScope, false, isSizedScope:false, isIndexedScope:false, isFixedArity:false, isUniqueScope:
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.EndScope, false, isSizedScope:false, isIndexedScope:false, isFixedArity:false, isUniqueScope:
|
||||
false, isTypedScope:false)
|
||||
}
|
||||
|
||||
@@ -25,8 +27,8 @@ public final class LayoutEndScope extends LayoutScope {
|
||||
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value) {
|
||||
return WriteScope(b, scope, typeArgs, value, UpdateOptions.Upsert);
|
||||
}
|
||||
|
||||
@@ -34,10 +36,10 @@ public final class LayoutEndScope extends LayoutScope {
|
||||
//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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Contract.Fail("Cannot write an EndScope directly");
|
||||
value.argValue = null;
|
||||
value.set(null);
|
||||
return Result.Failure;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Float128;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutFloat128 extends LayoutType<com.azure.data.cosmos.serialization.hybridrow.Float128> {
|
||||
public LayoutFloat128() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Float128, HybridRow.Float128.Size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "float128";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Float128> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(null);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadFloat128(scope.get().start + col.getOffset()).clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<Float128> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseFloat128(edit).clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
Float128 value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteFloat128(scope.get().start + col.getOffset(), value.clone());
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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(RefObject<RowBuffer> b, RefObject<RowCursor> edit, Float128 value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseFloat128(edit, value.clone(), options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, Float128 value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutFloat32 extends LayoutType<Float> {
|
||||
public LayoutFloat32() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Float32, (Float.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "float32";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Float> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(0);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadFloat32(scope.get().start + col.getOffset()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<Float> value) {
|
||||
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseFloat32(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
float value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteFloat32(scope.get().start + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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(RefObject<RowBuffer> b, RefObject<RowCursor> edit, float value,
|
||||
UpdateOptions options) {
|
||||
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseFloat32(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, float value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutFloat64 extends LayoutType<Double> {
|
||||
public LayoutFloat64() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Float64, (Double.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "float64";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Double> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(0);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadFloat64(scope.get().start + col.getOffset()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<Double> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseFloat64(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
double value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteFloat64(scope.get().start + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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, double value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, double value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseFloat64(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, double value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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.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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "guid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<UUID> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(null);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadGuid(scope.get().start + col.getOffset()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<UUID> value) {
|
||||
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseGuid(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
UUID value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteGuid(scope.get().start + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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, Guid value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, UUID value,
|
||||
UpdateOptions options) {
|
||||
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseGuid(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
java.util.UUID value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
public abstract class LayoutIndexedScope extends LayoutScope {
|
||||
|
||||
protected LayoutIndexedScope(
|
||||
LayoutCode code, boolean immutable, boolean isSizedScope, boolean isFixedArity, boolean isUniqueScope,
|
||||
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, isIndexedScope: true, isFixedArity: isFixedArity,
|
||||
// isUniqueScope: isUniqueScope, isTypedScope: isTypedScope);
|
||||
super(code, immutable, isSizedScope, true, isFixedArity, isUniqueScope, isTypedScope);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ReadSparsePath(RefObject<RowBuffer> row, RefObject<RowCursor> edit) {
|
||||
edit.get().pathToken = 0;
|
||||
edit.get().pathOffset = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutInt16 extends LayoutType<Short> {
|
||||
public LayoutInt16() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int16, (Short.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "int16";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Short> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(0);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadInt16(scope.get().start + col.getOffset()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<Short> value) {
|
||||
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseInt16(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
short value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteInt16(scope.get().start + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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(RefObject<RowBuffer> b, RefObject<RowCursor> edit, short value,
|
||||
UpdateOptions options) {
|
||||
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseInt16(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, short value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutInt32 extends LayoutType<Integer> {
|
||||
public LayoutInt32() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int32, (Integer.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "int32";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Integer> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(0);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadInt32(scope.get().start + col.getOffset()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<Integer> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseInt32(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
int value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteInt32(scope.get().start + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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(RefObject<RowBuffer> b, RefObject<RowCursor> edit, int value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseInt32(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, int value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutInt64 extends LayoutType<Long> {
|
||||
public LayoutInt64() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int64, (Long.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "int64";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Long> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(0);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadInt64(scope.get().start + col.getOffset()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<Long> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseInt64(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
long value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteInt64(scope.get().start + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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(RefObject<RowBuffer> b, RefObject<RowCursor> edit, long value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseInt64(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, long value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutInt8 extends LayoutType<Byte> {
|
||||
public LayoutInt8() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Int8, (Byte.SIZE / Byte.SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "int8";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<Byte> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(0);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadInt8(scope.get().start + col.getOffset()));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<Byte> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseInt8(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
byte value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteInt8(scope.get().start + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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(RefObject<RowBuffer> b, RefObject<RowCursor> edit, byte value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseInt8(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, byte value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> {
|
||||
public LayoutMongoDbObjectId() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.MongoDbObjectId, azure.data.cosmos.serialization.hybridrow.MongoDbObjectId.Size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
@Override
|
||||
public String getName() {
|
||||
return "mongodbobjectid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<MongoDbObjectId> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
value.set(null);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadMongoDbObjectId(scope.get().start + col.getOffset()).clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<MongoDbObjectId> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseMongoDbObjectId(edit).clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
MongoDbObjectId value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteMongoDbObjectId(scope.get().start + col.getOffset(), value.clone());
|
||||
b.get().SetBit(scope.get().start, col.getNullBit().clone());
|
||||
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, MongoDbObjectId value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
MongoDbObjectId value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseMongoDbObjectId(edit, value.clone(), options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
MongoDbObjectId value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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 static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
public final class LayoutNull extends LayoutType<NullValue> {
|
||||
public LayoutNull() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Null, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsFixed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsNull() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
OutObject<NullValue> value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
value.set(NullValue.Default);
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<NullValue> value) {
|
||||
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.set(b.get().ReadSparseNull(edit).clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col,
|
||||
NullValue value) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
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, NullValue value,
|
||||
// UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, NullValue value,
|
||||
UpdateOptions options) {
|
||||
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseNull(edit, value.clone(), options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, NullValue value) {
|
||||
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
public final class LayoutNullable extends LayoutIndexedScope {
|
||||
public LayoutNullable(boolean immutable) {
|
||||
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableNullableScope :
|
||||
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.NullableScope, immutable, true, true, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_nullable" : "nullable";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 1);
|
||||
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
checkState(edit.get().index >= 0);
|
||||
checkState(edit.get().scopeTypeArgs.getCount() == 1);
|
||||
checkState(edit.get().index == 1);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(0).getType().LayoutCode);
|
||||
}
|
||||
|
||||
public static Result HasValue(RefObject<RowBuffer> b, RefObject<RowCursor> scope) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutNullable);
|
||||
checkState(scope.get().index == 1 || scope.get().index == 2, "Nullable scopes always point at the value");
|
||||
checkState(scope.get().scopeTypeArgs.getCount() == 1);
|
||||
boolean hasValue = b.get().ReadInt8(scope.get().start) != 0;
|
||||
return hasValue ? Result.Success : Result.NotFound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(RefObject<RowBuffer> row, int offset,
|
||||
OutObject<Integer> lenInBytes) {
|
||||
return new TypeArgumentList(new TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
checkState(edit.get().index == 1);
|
||||
edit.get().cellType = edit.get().scopeTypeArgs.get(0).getType();
|
||||
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, boolean hasValue, OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, hasValue, value, UpdateOptions.Upsert);
|
||||
}
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: public Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList typeArgs, bool
|
||||
// hasValue, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, boolean hasValue, OutObject<RowCursor> value,
|
||||
UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteNullable(edit, this, typeArgs.clone(), options, hasValue, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value, UpdateOptions options) {
|
||||
return this.WriteScope(b, edit, typeArgs.clone(), true, value, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
checkState(value.getCount() == 1);
|
||||
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes,
|
||||
value.get(0).getTypeArgs().clone());
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,20 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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 LayoutObject extends LayoutPropertyScope {
|
||||
private TypeArgument TypeArg = new TypeArgument();
|
||||
|
||||
public LayoutObject(boolean immutable) {
|
||||
super(immutable ? azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableObjectScope : azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ObjectScope, immutable);
|
||||
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableObjectScope :
|
||||
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ObjectScope, immutable);
|
||||
this.TypeArg = new TypeArgument(this);
|
||||
}
|
||||
|
||||
@@ -27,8 +30,8 @@ public final class LayoutObject extends LayoutPropertyScope {
|
||||
|
||||
|
||||
@Override
|
||||
public Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value) {
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
|
||||
}
|
||||
|
||||
@@ -36,15 +39,15 @@ public final class LayoutObject extends LayoutPropertyScope {
|
||||
//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(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value, UpdateOptions options) {
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.WriteSparseObject(edit, this, options, value.clone());
|
||||
b.get().WriteSparseObject(edit, this, options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
public abstract class LayoutPropertyScope extends LayoutScope {
|
||||
protected LayoutPropertyScope(LayoutCode code, boolean immutable) {
|
||||
@@ -2,9 +2,9 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
|
||||
public abstract class LayoutResolver {
|
||||
public abstract Layout Resolve(SchemaId schemaId);
|
||||
@@ -2,11 +2,14 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.Namespace;
|
||||
import azure.data.cosmos.serialization.hybridrow.schemas.Schema;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.Namespace;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.Schema;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.base.Strings.lenientFormat;
|
||||
|
||||
/**
|
||||
* An implementation of <see cref="LayoutResolver" /> which dynamically compiles schema from
|
||||
@@ -52,7 +55,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
|
||||
}
|
||||
|
||||
for (Schema s : this.schemaNamespace.getSchemas()) {
|
||||
if (azure.data.cosmos.serialization.hybridrow.SchemaId.opEquals(s.getSchemaId().clone(),
|
||||
if (SchemaId.opEquals(s.getSchemaId().clone(),
|
||||
schemaId.clone())) {
|
||||
layout = s.Compile(this.schemaNamespace);
|
||||
layout = this.layoutCache.putIfAbsent(schemaId.getId(), layout);
|
||||
@@ -69,7 +72,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
|
||||
return layout;
|
||||
}
|
||||
|
||||
Contract.Fail(String.format("Failed to resolve schema %1$s", schemaId.clone()));
|
||||
throw new IllegalStateException(lenientFormat("Failed to resolve schema %s", schemaId.clone()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
|
||||
public final class LayoutResolverSimple extends LayoutResolver {
|
||||
private tangible.Func1Param<SchemaId, Layout> resolver;
|
||||
@@ -2,11 +2,15 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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.RowCursorExtensions;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
public abstract class LayoutScope extends LayoutType {
|
||||
/**
|
||||
@@ -30,8 +34,10 @@ public abstract class LayoutScope extends LayoutType {
|
||||
*/
|
||||
public boolean IsUniqueScope;
|
||||
|
||||
protected LayoutScope(LayoutCode code, boolean immutable, boolean isSizedScope, boolean isIndexedScope,
|
||||
boolean isFixedArity, boolean isUniqueScope, boolean isTypedScope) {
|
||||
protected LayoutScope(
|
||||
LayoutCode code, boolean immutable, boolean isSizedScope, boolean isIndexedScope, boolean isFixedArity,
|
||||
boolean isUniqueScope, boolean isTypedScope
|
||||
) {
|
||||
super(code, immutable, 0);
|
||||
this.IsSizedScope = isSizedScope;
|
||||
this.IsIndexedScope = isIndexedScope;
|
||||
@@ -45,13 +51,13 @@ public abstract class LayoutScope extends LayoutType {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final Result DeleteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit) {
|
||||
public final Result DeleteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit) {
|
||||
Result result = LayoutType.PrepareSparseDelete(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.DeleteSparse(edit);
|
||||
b.get().DeleteSparse(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -62,48 +68,49 @@ public abstract class LayoutScope extends LayoutType {
|
||||
* @param edit
|
||||
* @return True if the type code is implied (not written), false otherwise.
|
||||
*/
|
||||
public boolean HasImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
public boolean HasImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final Result ReadScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
tangible.OutObject<RowCursor> value) {
|
||||
public final Result ReadScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
OutObject<RowCursor> value) {
|
||||
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
value.argValue = null;
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
value.argValue = b.argValue.SparseIteratorReadScope(edit,
|
||||
this.Immutable || edit.argValue.immutable || edit.argValue.scopeType.IsUniqueScope).clone();
|
||||
value.set(b.get().SparseIteratorReadScope(edit,
|
||||
this.Immutable || edit.get().immutable || edit.get().scopeType.IsUniqueScope).clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public void ReadSparsePath(tangible.RefObject<RowBuffer> row, tangible.RefObject<RowCursor> edit) {
|
||||
public void ReadSparsePath(RefObject<RowBuffer> row, RefObject<RowCursor> edit) {
|
||||
int pathLenInBytes;
|
||||
tangible.OutObject<Integer> tempOut_pathLenInBytes = new tangible.OutObject<Integer>();
|
||||
tangible.OutObject<Integer> tempOut_pathOffset = new tangible.OutObject<Integer>();
|
||||
edit.argValue.pathToken = row.argValue.ReadSparsePathLen(edit.argValue.layout, edit.argValue.valueOffset, tempOut_pathLenInBytes, tempOut_pathOffset);
|
||||
edit.argValue.argValue.pathOffset = tempOut_pathOffset.argValue;
|
||||
pathLenInBytes = tempOut_pathLenInBytes.argValue;
|
||||
edit.argValue.valueOffset += pathLenInBytes;
|
||||
OutObject<Integer> tempOut_pathLenInBytes = new OutObject<Integer>();
|
||||
OutObject<Integer> tempOut_pathOffset = new OutObject<Integer>();
|
||||
edit.get().pathToken = row.get().ReadSparsePathLen(edit.get().layout, edit.get().valueOffset, tempOut_pathLenInBytes, tempOut_pathOffset);
|
||||
edit.get().argValue.pathOffset = tempOut_pathOffset.get();
|
||||
pathLenInBytes = tempOut_pathLenInBytes.get();
|
||||
edit.get().valueOffset += pathLenInBytes;
|
||||
}
|
||||
|
||||
public void SetImplicitTypeCode(tangible.RefObject<RowCursor> edit) {
|
||||
Contract.Fail("No implicit type codes.");
|
||||
public void SetImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public final abstract Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value);
|
||||
public abstract Result WriteScope(
|
||||
RefObject<RowBuffer> b, RefObject<RowCursor> scope, TypeArgumentList typeArgs,
|
||||
OutObject<RowCursor> value);
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: public abstract Result WriteScope(ref RowBuffer b, ref RowCursor scope, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert);
|
||||
public abstract Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
TypeArgumentList typeArgs, tangible.OutObject<RowCursor> value,
|
||||
public abstract Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value,
|
||||
UpdateOptions options);
|
||||
|
||||
public <TContext> Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public <TContext> Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func) {
|
||||
return WriteScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert);
|
||||
}
|
||||
@@ -112,7 +119,7 @@ public abstract class LayoutScope extends LayoutType {
|
||||
//ORIGINAL LINE: public virtual Result WriteScope<TContext>(ref RowBuffer b, ref RowCursor scope,
|
||||
// TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func, UpdateOptions options = UpdateOptions
|
||||
// .Upsert)
|
||||
public <TContext> Result WriteScope(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public <TContext> Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func,
|
||||
UpdateOptions options) {
|
||||
RowCursor childScope;
|
||||
@@ -123,21 +130,21 @@ public abstract class LayoutScope extends LayoutType {
|
||||
return r;
|
||||
}
|
||||
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_childScope =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(childScope);
|
||||
RefObject<RowCursor> tempRef_childScope =
|
||||
new RefObject<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 = tempRef_childScope.argValue;
|
||||
childScope = tempRef_childScope.get();
|
||||
if (r != Result.Success) {
|
||||
this.DeleteScope(b, scope);
|
||||
return r;
|
||||
}
|
||||
|
||||
tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor> tempRef_childScope2 =
|
||||
new tangible.RefObject<azure.data.cosmos.serialization.hybridrow.RowCursor>(childScope);
|
||||
Microsoft.Azure.Cosmos.Serialization.HybridRow.RowCursorExtensions.Skip(scope.argValue.clone(), b,
|
||||
RefObject<RowCursor> tempRef_childScope2 =
|
||||
new RefObject<RowCursor>(childScope);
|
||||
RowCursorExtensions.Skip(scope.get().clone(), b,
|
||||
tempRef_childScope2);
|
||||
childScope = tempRef_childScope2.argValue;
|
||||
childScope = tempRef_childScope2.get();
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -152,6 +159,6 @@ public abstract class LayoutScope extends LayoutType {
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface WriterFunc<TContext> {
|
||||
Result invoke(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, TContext context);
|
||||
Result invoke(RefObject<RowBuffer> b, RefObject<RowCursor> scope, TContext context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTaggedScope;
|
||||
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TaggedScope;
|
||||
|
||||
public final class LayoutTagged extends LayoutIndexedScope {
|
||||
public LayoutTagged(boolean immutable) {
|
||||
super(immutable ? ImmutableTaggedScope : TaggedScope, immutable, true, true, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_tagged_t" : "tagged_t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 2);
|
||||
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(1).getType().CountTypeArgument(value.get(1).getTypeArgs().clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
checkArgument(edit.get().index >= 0);
|
||||
checkArgument(edit.get().scopeTypeArgs.getCount() > edit.get().index);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(edit.get().index).getType().LayoutCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(RefObject<RowBuffer> row, int offset,
|
||||
OutObject<Integer> lenInBytes) {
|
||||
TypeArgument[] retval = new TypeArgument[2];
|
||||
retval[0] = new TypeArgument(UInt8, TypeArgumentList.Empty);
|
||||
retval[1] = ReadTypeArgument(row, offset, lenInBytes);
|
||||
return new TypeArgumentList(retval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
edit.get().cellType = edit.get().scopeTypeArgs.get(edit.get().index).getType();
|
||||
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(edit.get().index).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteTypedTuple(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
checkArgument(value.getCount() == 2);
|
||||
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
lenInBytes += value.get(1).getType().WriteTypeArgument(row, offset + lenInBytes,
|
||||
value.get(1).getTypeArgs().clone());
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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.ImmutableTagged2Scope :
|
||||
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Tagged2Scope, immutable, isSizedScope:
|
||||
true, isFixedArity:true, isUniqueScope:false, isTypedScope:true)
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_tagged2_t" : "tagged2_t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 3);
|
||||
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
for (int i = 1; i < value.getCount(); i++) {
|
||||
TypeArgument arg = value.get(i).clone();
|
||||
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
checkState(edit.get().index >= 0);
|
||||
checkState(edit.get().scopeTypeArgs.getCount() > edit.get().index);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(edit.get().index).getType().LayoutCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(RefObject<RowBuffer> row, int offset,
|
||||
OutObject<Integer> lenInBytes) {
|
||||
lenInBytes.set(0);
|
||||
TypeArgument[] retval = new TypeArgument[3];
|
||||
retval[0] = new TypeArgument(UInt8, TypeArgumentList.Empty);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
int itemLenInBytes;
|
||||
OutObject<Integer> tempOut_itemLenInBytes = new OutObject<Integer>();
|
||||
retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
|
||||
itemLenInBytes = tempOut_itemLenInBytes.get();
|
||||
lenInBytes.set(lenInBytes.get() + itemLenInBytes);
|
||||
}
|
||||
|
||||
return new TypeArgumentList(retval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
edit.get().cellType = edit.get().scopeTypeArgs.get(edit.get().index).getType();
|
||||
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(edit.get().index).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteTypedTuple(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
checkState(value.getCount() == 3);
|
||||
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
for (int i = 1; i < value.getCount(); i++) {
|
||||
TypeArgument arg = value.get(i).clone();
|
||||
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTupleScope;
|
||||
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TupleScope;
|
||||
|
||||
public final class LayoutTuple extends LayoutIndexedScope {
|
||||
public LayoutTuple(boolean immutable) {
|
||||
super(immutable ? ImmutableTupleScope : TupleScope, immutable, false, true, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_tuple" : "tuple";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count);
|
||||
lenInBytes += RowBuffer.Count7BitEncodedUInt(value.getCount());
|
||||
for (TypeArgument arg : value) {
|
||||
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(RefObject<RowBuffer> row, int offset,
|
||||
OutObject<Integer> lenInBytes) {
|
||||
int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes);
|
||||
TypeArgument[] retval = new TypeArgument[numTypeArgs];
|
||||
for (int i = 0; i < numTypeArgs; i++) {
|
||||
int itemLenInBytes;
|
||||
OutObject<Integer> tempOut_itemLenInBytes = new OutObject<Integer>();
|
||||
retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
|
||||
itemLenInBytes = tempOut_itemLenInBytes.get();
|
||||
lenInBytes.set(lenInBytes.get() + itemLenInBytes);
|
||||
}
|
||||
|
||||
return new TypeArgumentList(retval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteSparseTuple(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(RefObject<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);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: lenInBytes += row.Write7BitEncodedUInt(offset + lenInBytes, (ulong)value.Count);
|
||||
lenInBytes += row.get().Write7BitEncodedUInt(offset + lenInBytes, value.getCount());
|
||||
for (TypeArgument arg : value) {
|
||||
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
|
||||
}
|
||||
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,16 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Strings.lenientFormat;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
|
||||
///#pragma warning disable SA1402 // FileMayOnlyContainASingleType
|
||||
@@ -250,7 +253,7 @@ public abstract class LayoutType implements ILayoutType {
|
||||
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
|
||||
// Justification = "Type is immutable.")] public static readonly LayoutVarUInt VarUInt = new LayoutVarUInt();
|
||||
public static final LayoutVarUInt VarUInt = new LayoutVarUInt();
|
||||
private static final LayoutType[] CodeIndex = new LayoutType[azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.EndScope.getValue() + 1];
|
||||
private static final LayoutType[] CodeIndex = new LayoutType[com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.EndScope.getValue() + 1];
|
||||
/**
|
||||
* If true, this edit's nested fields cannot be updated individually.
|
||||
* The entire edit can still be replaced.
|
||||
@@ -259,7 +262,7 @@ public abstract class LayoutType implements ILayoutType {
|
||||
/**
|
||||
* The physical layout code used to represent the type within the serialization.
|
||||
*/
|
||||
public LayoutCode LayoutCode = azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.values()[0];
|
||||
public LayoutCode LayoutCode = com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.values()[0];
|
||||
/**
|
||||
* If fixed, the fixed size of the type's serialization in bytes, otherwise undefined.
|
||||
*/
|
||||
@@ -314,7 +317,7 @@ public abstract class LayoutType implements ILayoutType {
|
||||
public abstract String getName();
|
||||
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
return (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
}
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
|
||||
@@ -325,7 +328,7 @@ public abstract class LayoutType implements ILayoutType {
|
||||
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
|
||||
//#if DEBUG
|
||||
if (type == null) {
|
||||
Contract.Fail(String.format("Not Implemented: %1$s", code));
|
||||
throw new IllegalStateException(lenientFormat("Not Implemented: %s", code));
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -340,17 +343,17 @@ public abstract class LayoutType implements ILayoutType {
|
||||
* @param code The expected type of the field.
|
||||
* @return Success if the delete is permitted, the error code otherwise.
|
||||
*/
|
||||
public static Result PrepareSparseDelete(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
public static Result PrepareSparseDelete(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
LayoutCode code) {
|
||||
if (edit.argValue.scopeType.IsFixedArity) {
|
||||
if (edit.get().scopeType.IsFixedArity) {
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
|
||||
if (edit.argValue.immutable) {
|
||||
if (edit.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
if (edit.argValue.exists && LayoutCodeTraits.Canonicalize(edit.argValue.cellType.LayoutCode) != code) {
|
||||
if (edit.get().exists && LayoutCodeTraits.Canonicalize(edit.get().cellType.LayoutCode) != code) {
|
||||
return Result.TypeMismatch;
|
||||
}
|
||||
|
||||
@@ -370,55 +373,55 @@ public abstract class LayoutType implements ILayoutType {
|
||||
* @return Success if the move is permitted, the error code otherwise.
|
||||
* The source field is delete if the move prepare fails with a destination error.
|
||||
*/
|
||||
public static Result PrepareSparseMove(tangible.RefObject<RowBuffer> b,
|
||||
tangible.RefObject<RowCursor> destinationScope,
|
||||
public static Result PrepareSparseMove(RefObject<RowBuffer> b,
|
||||
RefObject<RowCursor> destinationScope,
|
||||
LayoutScope destinationCode, TypeArgument elementType,
|
||||
tangible.RefObject<RowCursor> srcEdit, UpdateOptions options,
|
||||
tangible.OutObject<RowCursor> dstEdit) {
|
||||
checkArgument(destinationScope.argValue.scopeType == destinationCode);
|
||||
checkArgument(destinationScope.argValue.index == 0, "Can only insert into a edit at the root");
|
||||
RefObject<RowCursor> srcEdit, UpdateOptions options,
|
||||
OutObject<RowCursor> dstEdit) {
|
||||
checkArgument(destinationScope.get().scopeType == destinationCode);
|
||||
checkArgument(destinationScope.get().index == 0, "Can only insert into a edit at the root");
|
||||
|
||||
// Prepare the delete of the source.
|
||||
Result result = LayoutType.PrepareSparseDelete(b, srcEdit, elementType.getType().LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
dstEdit.argValue = null;
|
||||
dstEdit.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!srcEdit.argValue.exists) {
|
||||
dstEdit.argValue = null;
|
||||
if (!srcEdit.get().exists) {
|
||||
dstEdit.set(null);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
if (destinationScope.argValue.immutable) {
|
||||
b.argValue.DeleteSparse(srcEdit);
|
||||
dstEdit.argValue = null;
|
||||
if (destinationScope.get().immutable) {
|
||||
b.get().DeleteSparse(srcEdit);
|
||||
dstEdit.set(null);
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
if (!srcEdit.argValue.cellTypeArgs.equals(elementType.getTypeArgs().clone())) {
|
||||
b.argValue.DeleteSparse(srcEdit);
|
||||
dstEdit.argValue = null;
|
||||
if (!srcEdit.get().cellTypeArgs.equals(elementType.getTypeArgs().clone())) {
|
||||
b.get().DeleteSparse(srcEdit);
|
||||
dstEdit.set(null);
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
|
||||
if (options == UpdateOptions.InsertAt) {
|
||||
b.argValue.DeleteSparse(srcEdit);
|
||||
dstEdit.argValue = null;
|
||||
b.get().DeleteSparse(srcEdit);
|
||||
dstEdit.set(null);
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
|
||||
// Prepare the insertion at the destination.
|
||||
dstEdit.argValue = b.argValue.PrepareSparseMove(destinationScope, srcEdit).clone();
|
||||
if ((options == UpdateOptions.Update) && (!dstEdit.argValue.exists)) {
|
||||
b.argValue.DeleteSparse(srcEdit);
|
||||
dstEdit.argValue = null;
|
||||
dstEdit.set(b.get().PrepareSparseMove(destinationScope, srcEdit).clone());
|
||||
if ((options == UpdateOptions.Update) && (!dstEdit.get().exists)) {
|
||||
b.get().DeleteSparse(srcEdit);
|
||||
dstEdit.set(null);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
if ((options == UpdateOptions.Insert) && dstEdit.argValue.exists) {
|
||||
b.argValue.DeleteSparse(srcEdit);
|
||||
dstEdit.argValue = null;
|
||||
if ((options == UpdateOptions.Insert) && dstEdit.get().exists) {
|
||||
b.get().DeleteSparse(srcEdit);
|
||||
dstEdit.set(null);
|
||||
return Result.Exists;
|
||||
}
|
||||
|
||||
@@ -433,13 +436,13 @@ public abstract class LayoutType implements ILayoutType {
|
||||
* @param code The expected type of the field.
|
||||
* @return Success if the read is permitted, the error code otherwise.
|
||||
*/
|
||||
public static Result PrepareSparseRead(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
public static Result PrepareSparseRead(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
LayoutCode code) {
|
||||
if (!edit.argValue.exists) {
|
||||
if (!edit.get().exists) {
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
if (LayoutCodeTraits.Canonicalize(edit.argValue.cellType.LayoutCode) != code) {
|
||||
if (LayoutCodeTraits.Canonicalize(edit.get().cellType.LayoutCode) != code) {
|
||||
return Result.TypeMismatch;
|
||||
}
|
||||
|
||||
@@ -455,37 +458,37 @@ public abstract class LayoutType implements ILayoutType {
|
||||
* @param options The write options.
|
||||
* @return Success if the write is permitted, the error code otherwise.
|
||||
*/
|
||||
public static Result PrepareSparseWrite(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit,
|
||||
public static Result PrepareSparseWrite(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgument typeArg, UpdateOptions options) {
|
||||
if (edit.argValue.immutable || (edit.argValue.scopeType.IsUniqueScope && !edit.argValue.deferUniqueIndex)) {
|
||||
if (edit.get().immutable || (edit.get().scopeType.IsUniqueScope && !edit.get().deferUniqueIndex)) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
if (edit.argValue.scopeType.IsFixedArity && !(edit.argValue.scopeType instanceof LayoutNullable)) {
|
||||
if ((edit.argValue.index < edit.argValue.scopeTypeArgs.getCount()) && !typeArg.equals(edit.argValue.scopeTypeArgs.get(edit.argValue.index).clone())) {
|
||||
if (edit.get().scopeType.IsFixedArity && !(edit.get().scopeType instanceof LayoutNullable)) {
|
||||
if ((edit.get().index < edit.get().scopeTypeArgs.getCount()) && !typeArg.equals(edit.get().scopeTypeArgs.get(edit.get().index).clone())) {
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
} else if (edit.argValue.scopeType instanceof LayoutTypedMap) {
|
||||
if (!((typeArg.getType() instanceof LayoutTypedTuple) && typeArg.getTypeArgs().equals(edit.argValue.scopeTypeArgs.clone()))) {
|
||||
} else if (edit.get().scopeType instanceof LayoutTypedMap) {
|
||||
if (!((typeArg.getType() instanceof LayoutTypedTuple) && typeArg.getTypeArgs().equals(edit.get().scopeTypeArgs.clone()))) {
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
} else if (edit.argValue.scopeType.IsTypedScope && !typeArg.equals(edit.argValue.scopeTypeArgs.get(0).clone())) {
|
||||
} else if (edit.get().scopeType.IsTypedScope && !typeArg.equals(edit.get().scopeTypeArgs.get(0).clone())) {
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
|
||||
if ((options == UpdateOptions.InsertAt) && edit.argValue.scopeType.IsFixedArity) {
|
||||
if ((options == UpdateOptions.InsertAt) && edit.get().scopeType.IsFixedArity) {
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
|
||||
if ((options == UpdateOptions.InsertAt) && !edit.argValue.scopeType.IsFixedArity) {
|
||||
edit.argValue.exists = false; // InsertAt never overwrites an existing item.
|
||||
if ((options == UpdateOptions.InsertAt) && !edit.get().scopeType.IsFixedArity) {
|
||||
edit.get().exists = false; // InsertAt never overwrites an existing item.
|
||||
}
|
||||
|
||||
if ((options == UpdateOptions.Update) && (!edit.argValue.exists)) {
|
||||
if ((options == UpdateOptions.Update) && (!edit.get().exists)) {
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
if ((options == UpdateOptions.Insert) && edit.argValue.exists) {
|
||||
if ((options == UpdateOptions.Insert) && edit.get().exists) {
|
||||
return Result.Exists;
|
||||
}
|
||||
|
||||
@@ -494,18 +497,18 @@ public abstract class LayoutType implements ILayoutType {
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
|
||||
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static TypeArgument ReadTypeArgument(ref RowBuffer row, int offset, out int lenInBytes)
|
||||
public static TypeArgument ReadTypeArgument(tangible.RefObject<RowBuffer> row, int offset, tangible.OutObject<Integer> lenInBytes) {
|
||||
LayoutType itemCode = row.argValue.ReadSparseTypeCode(offset);
|
||||
public static TypeArgument ReadTypeArgument(RefObject<RowBuffer> row, int offset, OutObject<Integer> lenInBytes) {
|
||||
LayoutType itemCode = row.get().ReadSparseTypeCode(offset);
|
||||
int argsLenInBytes;
|
||||
tangible.OutObject<Integer> tempOut_argsLenInBytes = new tangible.OutObject<Integer>();
|
||||
TypeArgumentList itemTypeArgs = itemCode.ReadTypeArgumentList(row, offset + (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), tempOut_argsLenInBytes).clone();
|
||||
argsLenInBytes = tempOut_argsLenInBytes.argValue;
|
||||
lenInBytes.argValue = (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + argsLenInBytes;
|
||||
OutObject<Integer> tempOut_argsLenInBytes = new OutObject<Integer>();
|
||||
TypeArgumentList itemTypeArgs = itemCode.ReadTypeArgumentList(row, offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), tempOut_argsLenInBytes).clone();
|
||||
argsLenInBytes = tempOut_argsLenInBytes.get();
|
||||
lenInBytes.set((com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + argsLenInBytes);
|
||||
return new TypeArgument(itemCode, itemTypeArgs.clone());
|
||||
}
|
||||
|
||||
public TypeArgumentList ReadTypeArgumentList(tangible.RefObject<RowBuffer> row, int offset, tangible.OutObject<Integer> lenInBytes) {
|
||||
lenInBytes.argValue = 0;
|
||||
public TypeArgumentList ReadTypeArgumentList(RefObject<RowBuffer> row, int offset, OutObject<Integer> lenInBytes) {
|
||||
lenInBytes.set(0);
|
||||
return TypeArgumentList.Empty;
|
||||
}
|
||||
|
||||
@@ -518,8 +521,8 @@ public abstract class LayoutType implements ILayoutType {
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
public int WriteTypeArgument(tangible.RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
row.argValue.WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
return (azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
public int WriteTypeArgument(RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,13 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@@ -29,10 +31,10 @@ public abstract class LayoutType<T> extends LayoutType {
|
||||
this.typeArg = new TypeArgument(this);
|
||||
}
|
||||
|
||||
public final Result DeleteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public final Result DeleteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
LayoutColumn col) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
@@ -41,7 +43,7 @@ public abstract class LayoutType<T> extends LayoutType {
|
||||
return Result.TypeMismatch;
|
||||
}
|
||||
|
||||
b.argValue.UnsetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
b.get().UnsetBit(scope.get().start, col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -51,13 +53,13 @@ public abstract class LayoutType<T> extends LayoutType {
|
||||
* If a value exists, then it is removed. The remainder of the row is resized to accomodate
|
||||
* a decrease in required space. If no value exists this operation is a no-op.
|
||||
*/
|
||||
public final Result DeleteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit) {
|
||||
public final Result DeleteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit) {
|
||||
Result result = LayoutType.PrepareSparseDelete(b, edit, this.LayoutCode);
|
||||
if (result != Result.Success) {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.argValue.DeleteSparse(edit);
|
||||
b.get().DeleteSparse(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -67,55 +69,55 @@ public abstract class LayoutType<T> extends LayoutType {
|
||||
* If a value exists, then it is removed. The remainder of the row is resized to accomodate
|
||||
* a decrease in required space. If no value exists this operation is a no-op.
|
||||
*/
|
||||
public final Result DeleteVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public final Result DeleteVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
LayoutColumn col) {
|
||||
checkArgument(scope.argValue.scopeType instanceof LayoutUDT);
|
||||
if (scope.argValue.immutable) {
|
||||
checkArgument(scope.get().scopeType instanceof LayoutUDT);
|
||||
if (scope.get().immutable) {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
boolean exists = b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone());
|
||||
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone());
|
||||
if (exists) {
|
||||
int varOffset = b.argValue.ComputeVariableValueOffset(scope.argValue.layout, scope.argValue.start,
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start,
|
||||
col.getOffset());
|
||||
b.argValue.DeleteVariable(varOffset, this.getIsVarint());
|
||||
b.argValue.UnsetBit(scope.argValue.start, col.getNullBit().clone());
|
||||
b.get().DeleteVariable(varOffset, this.getIsVarint());
|
||||
b.get().UnsetBit(scope.get().start, col.getNullBit().clone());
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public final Result HasValue(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public final Result HasValue(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
LayoutColumn col) {
|
||||
if (!b.argValue.ReadBit(scope.argValue.start, col.getNullBit().clone())) {
|
||||
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public abstract Result ReadFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
LayoutColumn col, tangible.OutObject<T> value);
|
||||
public abstract Result ReadFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
LayoutColumn col, OutObject<T> value);
|
||||
|
||||
public abstract Result ReadSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, tangible.OutObject<T> value);
|
||||
public abstract Result ReadSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, OutObject<T> value);
|
||||
|
||||
public Result ReadVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope, LayoutColumn col
|
||||
, tangible.OutObject<T> value) {
|
||||
value.argValue = null;
|
||||
public Result ReadVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope, LayoutColumn col
|
||||
, OutObject<T> value) {
|
||||
value.set(null);
|
||||
return Result.Failure;
|
||||
}
|
||||
|
||||
public abstract Result WriteFixed(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public abstract Result WriteFixed(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
LayoutColumn col, T value);
|
||||
|
||||
public abstract Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, T value);
|
||||
public abstract Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, T value);
|
||||
|
||||
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
|
||||
//ORIGINAL LINE: public abstract Result WriteSparse(ref RowBuffer b, ref RowCursor edit, T value, UpdateOptions
|
||||
// options = UpdateOptions.Upsert);
|
||||
public abstract Result WriteSparse(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> edit, T value, UpdateOptions options);
|
||||
public abstract Result WriteSparse(RefObject<RowBuffer> b, RefObject<RowCursor> edit, T value, UpdateOptions options);
|
||||
|
||||
public Result WriteVariable(tangible.RefObject<RowBuffer> b, tangible.RefObject<RowCursor> scope,
|
||||
public Result WriteVariable(RefObject<RowBuffer> b, RefObject<RowCursor> scope,
|
||||
LayoutColumn col, T value) {
|
||||
return Result.Failure;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.OutObject;
|
||||
import com.azure.data.cosmos.core.RefObject;
|
||||
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 LayoutTypedArray extends LayoutIndexedScope {
|
||||
public LayoutTypedArray(boolean immutable) {
|
||||
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedArrayScope :
|
||||
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedArrayScope, immutable, true, false, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.Immutable ? "im_array_t" : "array_t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int CountTypeArgument(TypeArgumentList value) {
|
||||
checkState(value.getCount() == 1);
|
||||
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
checkState(edit.get().index >= 0);
|
||||
checkState(edit.get().scopeTypeArgs.getCount() == 1);
|
||||
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(0).getType().LayoutCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeArgumentList ReadTypeArgumentList(RefObject<RowBuffer> row, int offset,
|
||||
OutObject<Integer> lenInBytes) {
|
||||
return new TypeArgumentList(new TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetImplicitTypeCode(RefObject<RowCursor> edit) {
|
||||
edit.get().cellType = edit.get().scopeTypeArgs.get(0).getType();
|
||||
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value) {
|
||||
return WriteScope(b, edit, typeArgs, 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 WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
|
||||
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
|
||||
@Override
|
||||
public Result WriteScope(RefObject<RowBuffer> b, RefObject<RowCursor> edit,
|
||||
TypeArgumentList typeArgs, OutObject<RowCursor> value, UpdateOptions options) {
|
||||
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
|
||||
if (result != Result.Success) {
|
||||
value.set(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().WriteTypedArray(edit, this, typeArgs.clone(), options, value.clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int WriteTypeArgument(RefObject<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
checkState(value.getCount() == 1);
|
||||
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
|
||||
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
|
||||
lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes,
|
||||
value.get(0).getTypeArgs().clone());
|
||||
return lenInBytes;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user