Renamed jre as java because Java is used to can refer to two things: the platform and the language. In this case we are referring to the Java Platform, not the Java Runtime Environment.

This commit is contained in:
David Noble
2019-09-01 14:26:40 -07:00
parent ab82943fe0
commit 7ae43bf830
193 changed files with 3840 additions and 2117 deletions

View File

@@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.core;
public class Codecs {
}

View File

@@ -3,6 +3,9 @@
package com.azure.data.cosmos.serialization.hybridrow;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public enum Result {
Success(0),
Failure(1),
@@ -40,31 +43,32 @@ public enum Result {
*/
Canceled(10);
public static final int SIZE = java.lang.Integer.SIZE;
private static java.util.HashMap<Integer, Result> mappings;
private int intValue;
public static final int SIZE = Integer.SIZE;
private static Int2ObjectMap<Result> mappings;
private final int value;
Result(int value) {
intValue = value;
getMappings().put(value, this);
this.value = value;
mappings().put(value, this);
}
public int getValue() {
return intValue;
public static Result from(int value) {
return mappings().get(value);
}
public static Result forValue(int value) {
return getMappings().get(value);
public int value() {
return this.value;
}
private static java.util.HashMap<Integer, Result> getMappings() {
private static Int2ObjectMap<Result> mappings() {
if (mappings == null) {
synchronized (Result.class) {
if (mappings == null) {
mappings = new java.util.HashMap<Integer, Result>();
mappings = new Int2ObjectOpenHashMap<>();
}
}
}
return mappings;
}
}
}

View File

@@ -128,8 +128,8 @@ public final class RowCursor implements Cloneable {
return this.endOffset;
}
public RowCursor endOffset(int endOffset) {
this.endOffset = endOffset;
public RowCursor endOffset(int value) {
this.endOffset = value;
return this;
}
@@ -140,8 +140,8 @@ public final class RowCursor implements Cloneable {
return this.exists;
}
public RowCursor exists(boolean exists) {
this.exists = exists;
public RowCursor exists(boolean value) {
this.exists = value;
return this;
}
@@ -154,8 +154,8 @@ public final class RowCursor implements Cloneable {
return this.immutable;
}
public RowCursor immutable(boolean immutable) {
this.immutable = immutable;
public RowCursor immutable(boolean value) {
this.immutable = value;
return this;
}
@@ -166,8 +166,8 @@ public final class RowCursor implements Cloneable {
return this.index;
}
public RowCursor index(int index) {
this.index = index;
public RowCursor index(int value) {
this.index = value;
return this;
}
@@ -178,8 +178,8 @@ public final class RowCursor implements Cloneable {
return this.layout;
}
public RowCursor layout(Layout layout) {
this.layout = layout;
public RowCursor layout(Layout value) {
this.layout = value;
return this;
}
@@ -191,8 +191,8 @@ public final class RowCursor implements Cloneable {
return this.metaOffset;
}
public RowCursor metaOffset(int metaOffset) {
this.metaOffset = metaOffset;
public RowCursor metaOffset(final int value) {
this.metaOffset = value;
return this;
}
@@ -203,6 +203,11 @@ public final class RowCursor implements Cloneable {
return this.pathOffset;
}
public RowCursor pathOffset(final int value) {
this.pathOffset = value;
return this;
}
/**
* If existing, the layout string token of scope relative path for reading.
*/
@@ -210,6 +215,11 @@ public final class RowCursor implements Cloneable {
return this.pathToken;
}
public RowCursor pathToken(int value) {
this.pathToken = value;
return this;
}
/**
* The kind of scope within which this edit was prepared
*/

View File

@@ -107,7 +107,7 @@ public final class RowCursors {
return true;
}
public static void skip(RowCursor edit, RowBuffer row, RowCursor childScope) {
public static void skip(@Nonnull final RowCursor edit, @Nonnull final RowBuffer row, @Nonnull final RowCursor childScope) {
checkArgument(childScope.start() == edit.valueOffset());

View File

@@ -143,7 +143,7 @@ public final class RowReader {
this.cursor = cursor.get();
Reference<RowBuffer> row = new Reference<>(this.row);
Reference<RowCursor> tempReference_nullableScope = new Reference<>(nullableScope);
boolean tempVar = LayoutNullable.HasValue(row, tempReference_nullableScope) == Result.Success;
boolean tempVar = LayoutNullable.hasValue(row, tempReference_nullableScope) == Result.Success;
nullableScope = tempReference_nullableScope.get();
this.row = row.get();
return tempVar;
@@ -534,7 +534,7 @@ public final class RowReader {
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseFloat64(tempReference_cursor));
value.setAndGet(this.row.readSparseFloat64(tempReference_cursor));
this.cursor = tempReference_cursor.get();
return Result.Success;
default:
@@ -561,7 +561,7 @@ public final class RowReader {
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseGuid(tempReference_cursor));
value.setAndGet(this.row.readSparseGuid(tempReference_cursor));
this.cursor = tempReference_cursor.get();
return Result.Success;
default:
@@ -588,7 +588,7 @@ public final class RowReader {
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseInt16(tempReference_cursor));
value.setAndGet(this.row.readSparseInt16(tempReference_cursor));
this.cursor = tempReference_cursor.get();
return Result.Success;
default:
@@ -615,7 +615,7 @@ public final class RowReader {
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseInt32(tempReference_cursor));
value.setAndGet(this.row.readSparseInt32(tempReference_cursor));
this.cursor = tempReference_cursor.get();
return Result.Success;
default:
@@ -642,7 +642,7 @@ public final class RowReader {
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseInt64(tempReference_cursor));
value.setAndGet(this.row.readSparseInt64(tempReference_cursor));
this.cursor = tempReference_cursor.get();
return Result.Success;
default:
@@ -669,7 +669,7 @@ public final class RowReader {
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseInt8(tempReference_cursor));
value.setAndGet(this.row.readSparseInt8(tempReference_cursor));
this.cursor = tempReference_cursor.get();
return Result.Success;
default:

View File

@@ -398,7 +398,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope2 =
new Out<RowCursor>();
this.row.WriteSparseArray(tempRef_cursor2, scopeType, UpdateOptions.Upsert, tempOut_nestedScope2);
this.row.writeSparseArray(tempRef_cursor2, scopeType, UpdateOptions.Upsert, tempOut_nestedScope2);
nestedScope = tempOut_nestedScope2.get();
this.cursor = tempRef_cursor2.argValue;
break;

View File

@@ -4,53 +4,48 @@
package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import javax.annotation.Nonnull;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ARRAY_SCOPE;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_ARRAY_SCOPE;
public final class LayoutArray extends LayoutIndexedScope {
private TypeArgument TypeArg = new TypeArgument();
public LayoutArray(boolean immutable) {
public LayoutArray(final boolean immutable) {
super(immutable ? IMMUTABLE_ARRAY_SCOPE : ARRAY_SCOPE, immutable, false, false, false, false);
this.TypeArg = new TypeArgument(this);
}
public String name() {
return this.Immutable ? "im_array" : "array";
}
public TypeArgument typeArg() {
return TypeArg;
return this.isImmutable() ? "im_array" : "array";
}
@Override
public Result WriteScope(
Reference<RowBuffer> b,
Reference<RowCursor> edit,
TypeArgumentList typeArgs,
Out<RowCursor> value
public Result writeScope(
@Nonnull final RowBuffer b,
@Nonnull final RowCursor edit,
@Nonnull final TypeArgumentList typeArgs,
@Nonnull Out<RowCursor> value
) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return this.writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Result result = prepareSparseWrite(b, edit, this.typeArg(), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
}
b.get().WriteSparseArray(edit, this, options, value.clone());
b.writeSparseArray(edit, this, options, value);
return Result.Success;
}
}

View File

@@ -11,12 +11,12 @@ public final class LayoutBit {
*/
public static final LayoutBit INVALID = new LayoutBit(-1);
private int index;
private final int index;
/**
* Initializes a new instance of the {@link LayoutBit} struct.
*
* @param index The 0-based offset into the layout bitmask.
* @param index The zero-based offset into the layout bitmask.
*/
public LayoutBit(int index) {
checkArgument(index >= -1);
@@ -52,6 +52,10 @@ public final class LayoutBit {
return this.index;
}
public boolean isInvalid() {
return this.index == INVALID.index;
}
/**
* Returns the zero-based byte offset from the beginning of the row or scope that contains the bit from the bitmask
* <p>

View File

@@ -4,7 +4,6 @@
package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
@@ -25,17 +24,17 @@ public final class LayoutEndScope extends LayoutScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> scope,
public Result writeScope(RowBuffer b, RowCursor scope,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, scope, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, scope, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor scope, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> scope,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor scope,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Contract.Fail("Cannot write an EndScope directly");
value.setAndGet(null);
return Result.Failure;

View File

@@ -3,23 +3,23 @@
package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import javax.annotation.Nonnull;
public abstract class LayoutIndexedScope extends LayoutScope {
protected LayoutIndexedScope(
LayoutCode code, boolean immutable, boolean isSizedScope, boolean isFixedArity, boolean isUniqueScope,
boolean isTypedScope
) {
@Nonnull final LayoutCode code, final boolean immutable, final boolean isSizedScope, final boolean isFixedArity,
final boolean isUniqueScope, final boolean isTypedScope) {
super(code, immutable, isSizedScope, true, isFixedArity, isUniqueScope, isTypedScope);
}
@Override
public void ReadSparsePath(Reference<RowBuffer> row, Reference<RowCursor> edit) {
edit.get().pathToken = 0;
edit.get().pathOffset = 0;
public void readSparsePath(@Nonnull final RowBuffer row, @Nonnull final RowCursor edit) {
edit.pathToken(0);
edit.pathOffset(0);
}
}

View File

@@ -9,7 +9,10 @@ import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import javax.annotation.Nonnull;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
public final class LayoutNullable extends LayoutIndexedScope {
@@ -22,49 +25,53 @@ public final class LayoutNullable extends LayoutIndexedScope {
return this.Immutable ? "im_nullable" : "nullable";
}
public int countTypeArgument(TypeArgumentList value) {
checkState(value.count() == 1);
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).type().CountTypeArgument(value.get(0).typeArgs().clone());
public int countTypeArgument(@Nonnull final TypeArgumentList value) {
checkNotNull(value, "expected non-null value");
checkArgument(value.count() == 1);
return (LayoutCode.SIZE / Byte.SIZE) + value.get(0).type().countTypeArgument(value.get(0).typeArgs());
}
@Override
public boolean HasImplicitTypeCode(Reference<RowCursor> edit) {
checkState(edit.get().index() >= 0);
checkState(edit.get().scopeTypeArgs().count() == 1);
checkState(edit.get().index() == 1);
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode);
public boolean hasImplicitTypeCode(@Nonnull final RowCursor edit) {
checkNotNull(edit, "expected non-null edit");
checkArgument(edit.index() >= 0);
checkArgument(edit.scopeTypeArgs().count() == 1);
checkArgument(edit.index() == 1);
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.scopeTypeArgs().get(0).type().layoutCode());
}
public static Result HasValue(Reference<RowBuffer> b, Reference<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().count() == 1);
boolean hasValue = b.get().ReadInt8(scope.get().start()) != 0;
public static Result hasValue(@Nonnull final RowBuffer b, @Nonnull final RowCursor scope) {
checkNotNull(b);
checkNotNull(scope);
checkArgument(scope.scopeType() instanceof LayoutNullable);
checkArgument(scope.index() == 1 || scope.index() == 2);
checkArgument(scope.scopeTypeArgs().count() == 1);
boolean hasValue = b.readInt8(scope.start()) != 0;
return hasValue ? Result.Success : Result.NotFound;
}
@Override
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
return new TypeArgumentList(new TypeArgument[] { LayoutType.readTypeArgument(row, offset, lenInBytes) });
public TypeArgumentList readTypeArgumentList(
@Nonnull final RowBuffer row, int offset, @Nonnull final Out<Integer> lenInBytes) {
return new TypeArgumentList(LayoutType.readTypeArgument(row, offset, lenInBytes));
}
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
checkState(edit.get().index() == 1);
edit.get().cellType = edit.get().scopeTypeArgs().get(0).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone();
public void setImplicitTypeCode(RowCursor edit) {
checkState(edit.index() == 1);
edit.get().cellType(edit.get().scopeTypeArgs().get(0).type());
edit.get().cellTypeArgs(edit.get().scopeTypeArgs().get(0).typeArgs());
}
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, boolean hasValue, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, hasValue, value, UpdateOptions.Upsert);
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(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, boolean hasValue, Out<RowCursor> value,
UpdateOptions options) {
Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
@@ -78,17 +85,17 @@ public final class LayoutNullable extends LayoutIndexedScope {
}
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
return this.WriteScope(b, edit, typeArgs.clone(), true, value, options);
}

View File

@@ -4,7 +4,6 @@
package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
@@ -28,17 +27,17 @@ public final class LayoutObject extends LayoutPropertyScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
value.setAndGet(null);

View File

@@ -0,0 +1,194 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.RowCursors;
import javax.annotation.Nonnull;
import static com.google.common.base.Preconditions.checkNotNull;
public abstract class LayoutScope extends LayoutType {
private final boolean isFixedArity;
private final boolean isIndexedScope;
private final boolean isSizedScope;
private final boolean isTypedScope;
private final boolean isUniqueScope;
protected LayoutScope(
@Nonnull final LayoutCode code, final boolean immutable, final boolean isSizedScope,
final boolean isIndexedScope, final boolean isFixedArity, final boolean isUniqueScope, boolean isTypedScope) {
super(code, immutable, 0);
this.isSizedScope = isSizedScope;
this.isIndexedScope = isIndexedScope;
this.isFixedArity = isFixedArity;
this.isUniqueScope = isUniqueScope;
this.isTypedScope = isTypedScope;
}
/**
* Returns true if this is a fixed arity scope.
*/
public boolean isFixedArity() {
return this.isFixedArity;
}
/**
* Returns true if this is an indexed scope.
*/
public boolean isIndexedScope() {
return this.isIndexedScope;
}
/**
* Returns true if this is a sized scope.
*/
public boolean isSizedScope() {
return this.isSizedScope;
}
/**
* Returns true if this is a typed scope.
*/
public boolean isTypedScope() {
return this.isTypedScope;
}
/**
* Returns true if the scope's elements cannot be updated directly.
*/
public boolean isUniqueScope() {
return this.isUniqueScope;
}
public final Result deleteScope(@Nonnull final RowBuffer b, @Nonnull final RowCursor edit) {
checkNotNull(b);
checkNotNull(edit);
Result result = LayoutType.prepareSparseDelete(b, edit, this.layoutCode());
if (result != Result.Success) {
return result;
}
b.deleteSparse(edit);
return Result.Success;
}
/**
* {@code true} if writing an item in the specified typed scope would elide the type code because it is implied by
* the type arguments
*
* @param edit a non-null {@link RowCursor} specifying a typed scope
* @return {@code true} if the type code is implied (not written); {@code false} otherwise.
*/
public boolean hasImplicitTypeCode(@Nonnull final RowCursor edit) {
checkNotNull(edit, "expected non-null edit");
return false;
}
@Nonnull
public final Result readScope(
@Nonnull final RowBuffer b, @Nonnull final RowCursor edit, @Nonnull final Out<RowCursor> value) {
checkNotNull(b);
checkNotNull(edit);
checkNotNull(value);
Result result = LayoutType.prepareSparseRead(b, edit, this.layoutCode());
if (result != Result.Success) {
value.setAndGet(null);
return result;
}
boolean immutable = this.isImmutable() || edit.immutable() || edit.scopeType().isUniqueScope();
value.set(b.sparseIteratorReadScope(edit, immutable));
return Result.Success;
}
public void readSparsePath(@Nonnull final RowBuffer row, @Nonnull final RowCursor edit) {
Out<Integer> pathLenInBytes = new Out<>();
Out<Integer> pathOffset = new Out<>();
edit.pathToken(row.readSparsePathLen(edit.layout(), edit.valueOffset(), pathLenInBytes, pathOffset));
edit.pathOffset(pathOffset.get());
edit.valueOffset(edit.valueOffset() + pathLenInBytes.get());
}
public void setImplicitTypeCode(final RowCursor edit) {
throw new UnsupportedOperationException();
}
public abstract Result writeScope(
RowBuffer b,
RowCursor scope,
TypeArgumentList typeArgs, Out<RowCursor> value);
public abstract Result writeScope(
RowBuffer b,
RowCursor scope,
TypeArgumentList typeArgs,
UpdateOptions options, Out<RowCursor> value);
public <TContext> Result writeScope(
RowBuffer b,
RowCursor scope,
TypeArgumentList typeArgs,
TContext context, WriterFunc<TContext> func) {
return this.writeScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public virtual Result WriteScope<TContext>(ref RowBuffer b, ref RowCursor scope,
// TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func, UpdateOptions options = UpdateOptions
// .Upsert)
public <TContext> Result writeScope(
RowBuffer b,
RowCursor scope,
TypeArgumentList typeArgs,
TContext context, WriterFunc<TContext> func, UpdateOptions options) {
final Out<RowCursor> out = new Out<>();
Result result = this.writeScope(b, scope, typeArgs, options, out);
if (result != Result.Success) {
return result;
}
final RowCursor childScope = out.get();
if (func != null) {
result = func.invoke(b, childScope, context);
if (result != Result.Success) {
this.deleteScope(b, scope);
return result;
}
}
RowCursors.skip(scope, b, childScope);
return Result.Success;
}
/**
* A function to write content into a {@link RowBuffer}.
* <typeparam name="TContext">The type of the context value passed by the caller.</typeparam>
*
* @param b The row to write to.
* @param scope The type of the scope to write into.
* @param context A context value provided by the caller.
* @return The result.
*/
@FunctionalInterface
public interface WriterFunc<TContext> {
@Nonnull Result invoke(RowBuffer b, RowCursor scope, TContext context);
}
}

View File

@@ -43,23 +43,23 @@ public final class LayoutTagged extends LayoutIndexedScope {
}
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
public void setImplicitTypeCode(RowCursor edit) {
edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone();
}
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);

View File

@@ -56,23 +56,23 @@ public final class LayoutTagged2 extends LayoutIndexedScope {
}
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
public void setImplicitTypeCode(RowCursor edit) {
edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone();
}
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);

View File

@@ -50,17 +50,17 @@ public final class LayoutTuple extends LayoutIndexedScope {
}
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);

View File

@@ -287,13 +287,14 @@ public abstract class LayoutType<T> 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(Reference<RowBuffer> b, Reference<RowCursor> edit, LayoutCode code) {
public static Result prepareSparseRead(
@Nonnull final RowBuffer b, @Nonnull final RowCursor edit, @Nonnull LayoutCode code) {
if (!edit.get().exists()) {
if (!edit.exists()) {
return Result.NotFound;
}
if (LayoutCodeTraits.Canonicalize(edit.get().cellType().layoutCode()) != code) {
if (LayoutCodeTraits.Canonicalize(edit.cellType().layoutCode()) != code) {
return Result.TypeMismatch;
}

View File

@@ -38,23 +38,23 @@ public final class LayoutTypedArray extends LayoutIndexedScope {
}
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
public void setImplicitTypeCode(RowCursor edit) {
edit.get().cellType = edit.get().scopeTypeArgs().get(0).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone();
}
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);

View File

@@ -58,24 +58,24 @@ public final class LayoutTypedMap extends LayoutUniqueScope {
}
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
public void setImplicitTypeCode(RowCursor edit) {
edit.get().cellType = edit.get().scopeType().Immutable ? ImmutableTypedTuple :
TypedTuple;
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().clone();
}
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);

View File

@@ -45,23 +45,23 @@ public final class LayoutTypedSet extends LayoutUniqueScope {
}
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
public void setImplicitTypeCode(RowCursor edit) {
edit.get().cellType = edit.get().scopeTypeArgs().get(0).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone();
}
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);

View File

@@ -57,23 +57,23 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
}
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
public void setImplicitTypeCode(RowCursor edit) {
edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone();
}
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);

View File

@@ -7,14 +7,14 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts;
* Layout type definitions
*/
public abstract class LayoutTypes {
public static final LayoutArray Array = new LayoutArray(false);
public static final LayoutBinary Binary = new LayoutBinary();
public static final LayoutArray ARRAY = new LayoutArray(false);
public static final LayoutBinary BINARY = new LayoutBinary();
public static final int BitsPerByte = 8;
public static final LayoutBoolean Boolean = new LayoutBoolean(true);
public static final LayoutBoolean BOOLEAN = new LayoutBoolean(true);
public static final LayoutBoolean BooleanFalse = new LayoutBoolean(false);
public static final LayoutDateTime DATE_TIME = new LayoutDateTime();
public static final LayoutDecimal DECIMAL = new LayoutDecimal();
public static final LayoutEndScope EndScope = new LayoutEndScope();
public static final LayoutEndScope END_SCOPE = new LayoutEndScope();
public static final LayoutFloat128 FLOAT_128 = new LayoutFloat128();
public static final LayoutFloat32 FLOAT_32 = new LayoutFloat32();
public static final LayoutFloat64 FLOAT_64 = new LayoutFloat64();
@@ -34,24 +34,24 @@ public abstract class LayoutTypes {
public static final LayoutInt32 INT_32 = new LayoutInt32();
public static final LayoutInt64 INT_64 = new LayoutInt64();
public static final LayoutInt8 INT_8 = new LayoutInt8();
public static final LayoutMongoDbObjectId MongoDbObjectId = new LayoutMongoDbObjectId();
public static final LayoutNull Null = new LayoutNull();
public static final LayoutNullable Nullable = new LayoutNullable(false);
public static final LayoutObject Object = new LayoutObject(false);
public static final LayoutTagged Tagged = new LayoutTagged(false);
public static final LayoutTagged2 Tagged2 = new LayoutTagged2(false);
public static final LayoutTuple Tuple = new LayoutTuple(false);
public static final LayoutTypedArray TypedArray = new LayoutTypedArray(false);
public static final LayoutMongoDbObjectId MONGODB_OBJECT_ID = new LayoutMongoDbObjectId();
public static final LayoutNull NULL = new LayoutNull();
public static final LayoutNullable NULLABLE = new LayoutNullable(false);
public static final LayoutObject OBJECT = new LayoutObject(false);
public static final LayoutTagged TAGGED = new LayoutTagged(false);
public static final LayoutTagged2 TAGGED_2 = new LayoutTagged2(false);
public static final LayoutTuple TUPLE = new LayoutTuple(false);
public static final LayoutTypedArray TYPED_ARRAY = new LayoutTypedArray(false);
public static final LayoutTypedMap TypedMap = new LayoutTypedMap(false);
public static final LayoutTypedSet TypedSet = new LayoutTypedSet(false);
public static final LayoutTypedTuple TypedTuple = new LayoutTypedTuple(false);
public static final LayoutTypedTuple TYPED_TUPLE = new LayoutTypedTuple(false);
public static final LayoutUDT UDT = new LayoutUDT(false);
public static final LayoutUInt16 UINT_16 = new LayoutUInt16();
public static final LayoutUInt32 UINT_32 = new LayoutUInt32();
public static final LayoutUInt64 UINT_64 = new LayoutUInt64();
public static final LayoutUInt8 UINT_8 = new LayoutUInt8();
public static final LayoutUnixDateTime UNIX_DATE_TIME = new LayoutUnixDateTime();
public static final LayoutUtf8 Utf8 = new LayoutUtf8();
public static final LayoutVarInt VarInt = new LayoutVarInt();
public static final LayoutVarUInt VarUInt = new LayoutVarUInt();
public static final LayoutUtf8 UTF_8 = new LayoutUtf8();
public static final LayoutVarInt VAR_INT = new LayoutVarInt();
public static final LayoutVarUInt VAR_UINT = new LayoutVarUInt();
}

View File

@@ -33,17 +33,17 @@ public final class LayoutUDT extends LayoutPropertyScope {
}
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, Out<RowCursor> value) {
return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert);
return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList
// typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
public Result writeScope(RowBuffer b, RowCursor edit,
TypeArgumentList typeArgs, UpdateOptions options, Out<RowCursor> value) {
Layout udt = b.get().resolver().resolve(typeArgs.schemaId().clone());
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {

View File

@@ -101,7 +101,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
// TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func, UpdateOptions options = UpdateOptions
// .Upsert)
@Override
public <TContext> Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> scope,
public <TContext> Result writeScope(RowBuffer b, RowCursor scope,
TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func,
UpdateOptions options) {
RowCursor uniqueScope;
@@ -146,8 +146,8 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
}
@Override
public <TContext> Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> scope,
public <TContext> Result writeScope(RowBuffer b, RowCursor scope,
TypeArgumentList typeArgs, TContext context, WriterFunc<TContext> func) {
return WriteScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert);
return writeScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert);
}
}

Some files were not shown because too many files have changed in this diff Show More