Progressed on port from dotnet to java

This commit is contained in:
David Noble
2019-08-27 22:13:39 -07:00
parent 5f8e221e08
commit 28c8eadd01
78 changed files with 2910 additions and 3340 deletions

View File

@@ -42,16 +42,23 @@ import static java.nio.charset.StandardCharsets.UTF_8;
public final class Utf8String implements CharSequence, Comparable<Utf8String> {
public static final Utf8String EMPTY = new Utf8String(Unpooled.EMPTY_BUFFER, 0);
public static final Utf8String NULL = new Utf8String();
private static final PooledByteBufAllocator allocator = PooledByteBufAllocator.DEFAULT;
private final ByteBuf buffer;
private final int length;
private Utf8String(final ByteBuf buffer) {
private Utf8String() {
this.buffer = null;
this.length = -1;
}
private Utf8String(@Nonnull final ByteBuf buffer) {
this(buffer, decodedLength(buffer));
}
private Utf8String(final ByteBuf buffer, final int decodedLength) {
private Utf8String(@Nonnull final ByteBuf buffer, final int decodedLength) {
checkNotNull(buffer);
this.buffer = buffer.asReadOnly();
this.length = decodedLength;
}
@@ -63,6 +70,13 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
return this.length == 0;
}
/**
* {@code true} if this instance is null
*/
public final boolean isNull() {
return this.buffer == null;
}
@Override
public char charAt(final int index) {
throw new UnsupportedOperationException();
@@ -87,13 +101,29 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
}
public final int compareTo(@Nonnull final Utf8String other) {
checkNotNull(other);
if (other.buffer == this.buffer) {
return 0;
}
if (other.buffer == null) {
return 1;
}
if (this.buffer == null) {
return -1;
}
return this.buffer.compareTo(other.buffer);
}
public final int compareTo(@Nonnull final String other) {
public final int compareTo(final String other) {
checkNotNull(other);
if (this.buffer == null) {
return other == null ? 0 : -1;
}
final int length = this.length();
final int otherLength = other.length();
@@ -250,6 +280,10 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
return this.buffer.getCharSequence(0, this.buffer.capacity(), UTF_8).toString();
}
public String toUtf16() {
return this.buffer.getCharSequence(0, this.buffer.capacity(), UTF_8).toString();
}
/**
* Creates a {@link Utf8String} from a UTF16 encoding string.
*

View File

@@ -17,7 +17,7 @@ public final class HybridRowHeader {
/**
* Size (in bytes) of a serialized header.
*/
public static final int Size = (HybridRowVersion.SIZE / Byte.SIZE) + com.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.
*/

View File

@@ -10,11 +10,7 @@ package com.azure.data.cosmos.serialization.hybridrow;
* May be stored hybrid row to indicate the literal null value. Typically this value should
* not be used and the corresponding column should be absent from the row.
*/
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ
// from the original:
//ORIGINAL LINE: public readonly struct NullValue : IEquatable<NullValue>
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct:
public final class NullValue implements IEquatable<NullValue> {
public final class NullValue {
/**
* The default null literal.
* This is the same value as default({@link NullValue}).
@@ -22,7 +18,7 @@ public final class NullValue implements IEquatable<NullValue> {
public static final NullValue Default = new NullValue();
/**
* Returns true if this is the same value as {@link other}.
* Returns true if this is the same value as {@code other}.
*
* @param other The value to compare against.
* @return True if the two values are the same.
@@ -31,37 +27,16 @@ public final class NullValue implements IEquatable<NullValue> {
return true;
}
/**
* {@link object.Equals(object)} overload.
*/
@Override
public boolean equals(Object obj) {
if (null == obj) {
public boolean equals(Object other) {
if (null == other) {
return false;
}
return obj instanceof NullValue && this.equals((NullValue)obj);
return other instanceof NullValue && this.equals((NullValue)other);
}
/**
* {@link object.GetHashCode} overload.
*/
@Override
public int hashCode() {
return 42;
}
/**
* Operator == overload.
*/
public static boolean opEquals(NullValue left, NullValue right) {
return left.equals(right.clone());
}
/**
* Operator != overload.
*/
public static boolean opNotEquals(NullValue left, NullValue right) {
return !left.equals(right.clone());
}
}

View File

@@ -4,27 +4,21 @@
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 com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.UtfAnyString;
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.LayoutTuple;
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:
//ORIGINAL LINE: [DebuggerDisplay("{ToString()}")] public struct RowCursor
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ
// from the original:
//ORIGINAL LINE: [DebuggerDisplay("{ToString()}")] public struct RowCursor
import static com.google.common.base.Strings.lenientFormat;
public final class RowCursor {
/**
* If existing, the layout code of the existing field, otherwise undefined.
*/
@@ -33,10 +27,6 @@ public final class RowCursor {
* For types with generic parameters (e.g. {@link LayoutTuple}, the type parameters.
*/
public TypeArgumentList cellTypeArgs = new TypeArgumentList();
/**
* For sized scopes (e.g. Typed Array), the number of elements.
*/
public int count;
/**
* If true, this scope is an unique index scope whose index will be built after its items are written.
*/
@@ -50,24 +40,6 @@ public final class RowCursor {
* True if an existing field matching the search criteria was found.
*/
public boolean exists;
/**
* If true, this scope's nested fields cannot be updated individually.
* The entire scope can still be replaced.
*/
public boolean immutable;
/**
* For indexed scopes (e.g. Array), the 0-based index into the scope of the sparse field.
*/
public int index;
/**
* The layout describing the contents of the scope, or null if the scope is unschematized.
*/
public Layout layout;
/**
* If existing, the offset to the metadata of the existing field, otherwise the location to
* insert a new field.
*/
public int metaOffset;
/**
* If existing, the offset scope relative path for reading.
*/
@@ -76,60 +48,60 @@ public final class RowCursor {
* If existing, the layout string token of scope relative path for reading.
*/
public int pathToken;
/**
* The kind of scope within which this edit was prepared.
*/
public LayoutScope scopeType;
/**
* The type parameters of the scope within which this edit was prepared.
*/
public TypeArgumentList scopeTypeArgs = new TypeArgumentList();
/**
* The 0-based byte offset from the beginning of the row where the first sparse field within
* the scope begins.
*/
public int start;
/**
* If existing, the offset to the value of the existing field, otherwise undefined.
*/
public int valueOffset;
/**
* If existing, the scope relative path for writing.
*/
public UtfAnyString writePath;
/**
* If WritePath is tokenized, then its token.
*/
public StringToken writePathToken = new StringToken();
private int count;
private boolean immutable;
private int index;
private Layout layout;
private int metaOffset;
private LayoutScope scopeType;
private TypeArgumentList scopeTypeArgs = new TypeArgumentList();
private int start;
private int valueOffset;
private UtfAnyString writePath;
private StringToken writePathToken = new StringToken();
public static RowCursor Create(Reference<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,
final SchemaId schemaId = row.get().ReadSchemaId(1);
final Layout layout = row.get().resolver().Resolve(schemaId);
final int sparseSegmentOffset = row.get().computeVariableValueOffset(layout, HybridRowHeader.SIZE,
layout.numVariable());
RowCursor tempVar = new RowCursor();
tempVar.layout = layout;
tempVar.scopeType = LayoutType.UDT;
tempVar.scopeTypeArgs = new TypeArgumentList(schemaId.clone());
tempVar.start = HybridRowHeader.Size;
tempVar.metaOffset = sparseSegmentOffset;
tempVar.valueOffset = sparseSegmentOffset;
return tempVar.clone();
final RowCursor cursor = new RowCursor()
.layout(layout)
.scopeType(LayoutType.UDT)
.scopeTypeArgs(new TypeArgumentList(schemaId))
.start(HybridRowHeader.SIZE)
.metaOffset(sparseSegmentOffset)
.valueOffset(sparseSegmentOffset);
return cursor;
}
// TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter:
// public static ref RowCursor Create(ref RowBuffer row, out RowCursor cursor)
// {
// SchemaId schemaId = row.ReadSchemaId(1);
// Layout layout = row.Resolver.Resolve(schemaId);
// int sparseSegmentOffset = row.ComputeVariableValueOffset(layout, HybridRowHeader.Size, layout
// .NumVariable);
// cursor = new RowCursor { layout = layout, scopeType = LayoutType.UDT, scopeTypeArgs = new
// TypeArgumentList(schemaId), start = HybridRowHeader.Size, metaOffset = sparseSegmentOffset,
// valueOffset = sparseSegmentOffset};
//
// return ref cursor;
// }
public static RowCursor Create(RowBuffer row) {
final SchemaId schemaId = row.ReadSchemaId(1);
final Layout layout = row.Resolver.Resolve(schemaId);
final int sparseSegmentOffset = row.computeVariableValueOffset(layout, HybridRowHeader.Size,
layout.NumVariable);
return new RowCursor()
.layout(layout)
.scopeType(LayoutType.UDT)
.scopeTypeArgs(new TypeArgumentList(schemaId, HybridRowHeader.SIZE, sparseSegmentOffset, sparseSegmentOffset);
}
/**
* For sized scopes (e.g. Typed Array), the number of elements.
*/
public int count() {
return count;
}
public RowCursor count(int count) {
this.count = count;
return this;
}
// TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter:
// public static ref RowCursor CreateForAppend(ref RowBuffer row, out RowCursor cursor)
@@ -143,94 +115,157 @@ public final class RowCursor {
// return ref cursor;
// }
public RowCursor clone() {
RowCursor varCopy = new RowCursor();
/**
* If {@code true}, this scope's nested fields cannot be updated individually
* <p>
* The entire scope can still be replaced.
*/
public boolean immutable() {
return immutable;
}
varCopy.layout = this.layout;
varCopy.scopeType = this.scopeType;
varCopy.scopeTypeArgs = this.scopeTypeArgs.clone();
varCopy.immutable = this.immutable;
varCopy.deferUniqueIndex = this.deferUniqueIndex;
varCopy.start = this.start;
varCopy.exists = this.exists;
varCopy.writePath = this.writePath;
varCopy.writePathToken = this.writePathToken.clone();
varCopy.pathOffset = this.pathOffset;
varCopy.pathToken = this.pathToken;
varCopy.metaOffset = this.metaOffset;
varCopy.cellType = this.cellType;
varCopy.valueOffset = this.valueOffset;
varCopy.endOffset = this.endOffset;
varCopy.count = this.count;
varCopy.index = this.index;
varCopy.cellTypeArgs = this.cellTypeArgs.clone();
public RowCursor immutable(boolean immutable) {
this.immutable = immutable;
return this;
}
return varCopy;
/**
* For indexed scopes (e.g. an Array scope), the zero-based index into the scope of the sparse field
*/
public int index() {
return index;
}
public RowCursor index(int index) {
this.index = index;
return this;
}
/**
* The layout describing the contents of the scope, or {@code null} if the scope is unschematized.
*/
public Layout layout() {
return layout;
}
public RowCursor layout(Layout layout) {
this.layout = layout;
return this;
}
/**
* If existing, the offset to the metadata of the existing field, otherwise the location to
* insert a new field.
*/
public int metaOffset() {
return metaOffset;
}
public RowCursor metaOffset(int metaOffset) {
this.metaOffset = metaOffset;
return this;
}
/**
* The kind of scope within which this edit was prepared
*/
public LayoutScope scopeType() {
return scopeType;
}
public RowCursor scopeType(LayoutScope scopeType) {
this.scopeType = scopeType;
return this;
}
/**
* The type parameters of the scope within which this edit was prepared
*/
public TypeArgumentList scopeTypeArgs() {
return scopeTypeArgs;
}
public RowCursor scopeTypeArgs(TypeArgumentList scopeTypeArgs) {
this.scopeTypeArgs = scopeTypeArgs;
return this;
}
/**
* The 0-based byte offset from the beginning of the row where the first sparse field within
* the scope begins.
*/
public int start() {
return start;
}
public RowCursor start(int start) {
this.start = start;
return this;
}
@Override
public String toString() {
try {
if (this.scopeType == null) {
if (this.scopeType() == null) {
return "<Invalid>";
}
TypeArgument scopeTypeArg = (this.scopeType == null) || (this.scopeType instanceof LayoutEndScope) ?
default:
new TypeArgument(this.scopeType, this.scopeTypeArgs.clone());
TypeArgument scopeTypeArg = (this.scopeType() instanceof LayoutEndScope)
? new TypeArgument()
: new TypeArgument(this.scopeType(), this.scopeTypeArgs().clone());
TypeArgument typeArg = (this.cellType == null) || (this.cellType instanceof LayoutEndScope) ?
default:
new TypeArgument(this.cellType, this.cellTypeArgs.clone());
TypeArgument typeArg = (this.cellType == null) || (this.cellType instanceof LayoutEndScope)
? new TypeArgument()
: new TypeArgument(this.cellType, this.cellTypeArgs.clone());
String pathOrIndex = !this.writePath.IsNull ? this.writePath.toString() : String.valueOf(this.index);
return String.format("%1$s[%2$s] : %3$s@%4$s/%5$s", scopeTypeArg.clone(), pathOrIndex,
typeArg.clone(), this.metaOffset, this.valueOffset) + (this.immutable ? " immutable" : "");
} catch (java.lang.Exception e) {
String pathOrIndex = this.writePath().isNull() ? String.valueOf(this.index()) : this.writePath().toString();
return lenientFormat("%s[%s] : %s@%s/%s%s",
scopeTypeArg.clone(),
pathOrIndex,
typeArg.clone(),
this.metaOffset(),
this.valueOffset(),
this.immutable() ? " immutable" : "");
} catch (Exception ignored) {
return "<???>";
}
}
/**
* If true, this scope's nested fields cannot be updated individually.
* The entire scope can still be replaced.
* If existing, the offset to the value of the existing field, otherwise undefined.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public bool Immutable
boolean getImmutable()
public int valueOffset() {
return valueOffset;
}
public RowCursor valueOffset(int valueOffset) {
this.valueOffset = valueOffset;
return this;
}
/**
* For indexed scopes (e.g. Array), the 0-based index into the scope of the next insertion.
* If existing, the scope relative path for writing.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public int Index
int getIndex()
public UtfAnyString writePath() {
return writePath;
}
public void writePath(UtfAnyString writePath) {
this.writePath = writePath;
}
/**
* The layout describing the contents of the scope, or null if the scope is unschematized.
* If WritePath is tokenized, then its token.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Layout Layout
Layout getLayout()
public StringToken writePathToken() {
return writePathToken;
}
/**
* The kind of scope.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public LayoutType ScopeType
LayoutType getScopeType()
/**
* For types with generic parameters (e.g. {@link LayoutTuple}, the type parameters.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public TypeArgumentList ScopeTypeArgs
TypeArgumentList getScopeTypeArgs()
/**
* The full logical type.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public TypeArgument TypeArg
TypeArgument getTypeArg()
public void writePathToken(StringToken writePathToken) {
this.writePathToken = writePathToken;
}
}

View File

@@ -79,14 +79,14 @@ public final class RowCursorExtensions {
// return ref edit;
// }
public static boolean MoveNext(Reference<RowCursor> edit, Reference<RowBuffer> row) {
edit.get().writePath = null;
edit.get().writePathToken = null;
edit.get().writePath(null);
edit.get().writePathToken(null);
return row.get().SparseIteratorMoveNext(edit);
}
public static boolean MoveNext(Reference<RowCursor> edit, Reference<RowBuffer> row,
Reference<RowCursor> childScope) {
if (childScope.get().scopeType != null) {
if (childScope.get().scopeType() != null) {
RowCursorExtensions.Skip(edit.get().clone(), row, childScope);
}
@@ -94,10 +94,10 @@ public final class RowCursorExtensions {
}
public static boolean MoveTo(Reference<RowCursor> edit, Reference<RowBuffer> row, int index) {
checkState(edit.get().index <= index);
edit.get().writePath = null;
edit.get().writePathToken = null;
while (edit.get().index < 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;
}
@@ -108,16 +108,16 @@ public final class RowCursorExtensions {
public static void Skip(Reference<RowCursor> edit, Reference<RowBuffer> row,
Reference<RowCursor> childScope) {
checkArgument(childScope.get().start == edit.get().valueOffset);
checkArgument(childScope.get().start() == edit.get().valueOffset());
if (!(childScope.get().cellType instanceof LayoutEndScope)) {
while (row.get().SparseIteratorMoveNext(childScope)) {
}
}
if (childScope.get().scopeType.IsSizedScope) {
edit.get().endOffset = childScope.get().metaOffset;
if (childScope.get().scopeType().isSizedScope()) {
edit.get().endOffset = childScope.get().metaOffset();
} else {
edit.get().endOffset = childScope.get().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:

View File

@@ -4,124 +4,114 @@
package com.azure.data.cosmos.serialization.hybridrow;
import Newtonsoft.Json.*;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import static com.google.common.base.Preconditions.checkArgument;
import java.io.IOException;
import static com.google.common.base.Strings.lenientFormat;
/**
* The unique identifier for a schema.
* The unique identifier for a schema
* Identifiers must be unique within the scope of the database in which they are used.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [JsonConverter(typeof(SchemaIdConverter))][DebuggerDisplay("{" + nameof(SchemaId.Id) + "}")
// ][StructLayout(LayoutKind.Sequential, Pack = 1)] public readonly struct SchemaId : IEquatable<SchemaId>
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ
// from the original:
//ORIGINAL LINE: [JsonConverter(typeof(SchemaIdConverter))][DebuggerDisplay("{" + nameof(SchemaId.Id) + "}")
// ][StructLayout(LayoutKind.Sequential, Pack = 1)] public readonly struct SchemaId : IEquatable<SchemaId>
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct:
public final class SchemaId implements IEquatable<SchemaId> {
public static final SchemaId Invalid = null;
public static final int Size = (Integer.SIZE / Byte.SIZE);
/**
* The underlying identifier.
*/
private int Id;
@JsonDeserialize(using = SchemaId.JsonDeserializer.class)
@JsonSerialize(using = SchemaId.JsonSerializer.class)
public final class SchemaId {
public static final SchemaId INVALID = null;
public static final SchemaId NONE = new SchemaId();
public static final int SIZE = (Integer.SIZE / Byte.SIZE);
private static long MAX_VALUE = 0x00000000FFFFFFFFL;
private final int id;
/**
* Initializes a new instance of the {@link SchemaId} struct.
*
* @param id The underlying globally unique identifier of the schema.
*/
public SchemaId() {
}
public SchemaId(int id) {
this.Id = id;
this.id = id;
}
public int getId() {
return Id;
private SchemaId() {
this.id = -1;
}
/**
* {@link object.Equals(object)} overload.
*/
@Override
public boolean equals(Object obj) {
if (null == obj) {
return false;
}
return obj instanceof SchemaId && this.equals((SchemaId)obj);
public boolean equals(Object other) {
return other instanceof SchemaId && this.equals((SchemaId) other);
}
/**
* Returns true if this is the same {@link SchemaId} as {@link other}.
* {@code true} if this is the same {@link SchemaId} as {@code other}
*
* @param other The value to compare against.
* @return True if the two values are the same.
*/
public boolean equals(SchemaId other) {
return this.getId() == other.getId();
if (null == other) {
return false;
}
return this.id() == other.id();
}
/**
* {@link object.GetHashCode} overload.
*/
@Override
public int hashCode() {
return (new Integer(this.getId())).hashCode();
return Integer.valueOf(this.id()).hashCode();
}
/**
* Operator == overload.
* The underlying integer value of this {@link SchemaId}
*
* @return The integer value of this {@link SchemaId}
*/
public static boolean opEquals(SchemaId left, SchemaId right) {
return left.equals(right.clone());
public int id() {
return id;
}
/**
* Operator != overload.
*/
public static boolean opNotEquals(SchemaId left, SchemaId right) {
return !left.equals(right.clone());
}
/**
* {@link object.ToString} overload.
*/
@Override
public String toString() {
return String.valueOf(this.getId());
return String.valueOf(this.id());
}
/**
* Helper class for parsing {@link SchemaId} from JSON.
*/
public static class SchemaIdConverter extends JsonConverter {
@Override
public boolean getCanWrite() {
return true;
static final class JsonDeserializer extends StdDeserializer<SchemaId> {
private JsonDeserializer() {
super(SchemaId.class);
}
@Override
public boolean CanConvert(java.lang.Class objectType) {
return objectType.isAssignableFrom(SchemaId.class);
public SchemaId deserialize(final JsonParser parser, final DeserializationContext context) throws IOException, JsonProcessingException {
final long value = parser.getLongValue();
if (value < 0 || value > MAX_VALUE) {
String message = lenientFormat("expected integer value in [0, 4294967295], not %s", value);
throw MismatchedInputException.from(parser, SchemaId.class, message);
}
return new SchemaId((int) value);
}
}
static final class JsonSerializer extends StdSerializer<SchemaId> {
private JsonSerializer() {
super(SchemaId.class);
}
@Override
public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue,
JsonSerializer serializer) {
checkArgument(reader.TokenType == JsonToken.Integer);
// TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'checked' in this context:
//ORIGINAL LINE: return new SchemaId(checked((int)(long)reader.Value));
return new SchemaId((int)(long)reader.Value);
}
@Override
public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) {
writer.WriteValue((long)((SchemaId)value).getId());
public void serialize(final SchemaId value, final JsonGenerator generator, final SerializerProvider provider) throws IOException {
generator.writeNumber((long) value.id() & MAX_VALUE);
}
}
}

View File

@@ -6,13 +6,14 @@ package com.azure.data.cosmos.serialization.hybridrow.io;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.UtfAnyString;
import com.azure.data.cosmos.serialization.hybridrow.Float128;
import com.azure.data.cosmos.serialization.hybridrow.NullValue;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.UnixDateTime;
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import com.azure.data.cosmos.serialization.hybridrow.UnixDateTime;
import com.azure.data.cosmos.serialization.hybridrow.layouts.ILayoutSpanReadable;
import com.azure.data.cosmos.serialization.hybridrow.layouts.ILayoutUtf8SpanReadable;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutBinary;
@@ -76,53 +77,56 @@ public final class RowReader {
private RowCursor cursor = new RowCursor();
private RowBuffer row = new RowBuffer();
private int schematizedCount;
// State that can be checkpointed.
private States state = States.values()[0];
/**
* Initializes a new instance of the {@link RowReader} struct.
*
* @param row The row to be read.
* @param scope The scope whose fields should be enumerated.
* <p>
* A {@link RowReader} instance traverses all of the top-level fields of a given
* scope. If the root scope is provided then all top-level fields in the row are enumerated. Nested
* child {@link RowReader} instances can be access through the {@link ReadScope} method
* to process nested content.
*/
public RowReader() {
}
/**
* Initializes a new instance of the {@link RowReader} struct.
*
* @param row The row to be read.
* @param scope The scope whose fields should be enumerated.
* <p>
* A {@link RowReader} instance traverses all of the top-level fields of a given
* scope. If the root scope is provided then all top-level fields in the row are enumerated. Nested
* child {@link RowReader} instances can be access through the {@link ReadScope} method
* to process nested content.
* @param row The row to be read
*/
public RowReader(Reference<RowBuffer> row) {
this(row, RowCursor.Create(row));
}
/**
* Initializes a new instance of the {@link RowReader} struct.
*
* @param row The row to be read
* @param checkpoint Initial state of the reader
*/
public RowReader(Reference<RowBuffer> row, final Checkpoint checkpoint) {
this.row = row.get().clone();
this.columns = checkpoint.Cursor.layout.columns();
this.schematizedCount = checkpoint.Cursor.layout.numFixed() + checkpoint.Cursor.layout.numVariable();
this.columns = checkpoint.Cursor.layout().columns();
this.schematizedCount = checkpoint.Cursor.layout().numFixed() + checkpoint.Cursor.layout().numVariable();
this.state = checkpoint.State;
this.cursor = checkpoint.Cursor.clone();
this.columnIndex = checkpoint.ColumnIndex;
}
/**
* Initializes a new instance of the {@link RowReader} struct.
*
* @param row The row to be read
* @param scope The scope whose fields should be enumerated
* <p>
* A {@link RowReader} instance traverses all of the top-level fields of a given scope. If the
* root scope is provided then all top-level fields in the row are enumerated. Nested child
* {@link RowReader} instances can be access through the {@link RowReader#ReadScope} method to
* process nested content.
*/
private RowReader(Reference<RowBuffer> row, final RowCursor scope) {
this.cursor = scope.clone();
this.row = row.get().clone();
this.columns = this.cursor.layout.columns();
this.schematizedCount = this.cursor.layout.numFixed() + this.cursor.layout.numVariable();
this.columns = this.cursor.layout().columns();
this.schematizedCount = this.cursor.layout().numFixed() + this.cursor.layout().numVariable();
this.state = States.None;
this.columnIndex = -1;
@@ -136,25 +140,26 @@ public final class RowReader {
* is set (even though its values is set to null).
*/
public boolean getHasValue() {
switch (this.state) {
case Schematized:
return true;
case Sparse:
if (this.cursor.cellType instanceof LayoutNullable) {
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
RowCursor nullableScope = this.row.SparseIteratorReadScope(tempReference_cursor, true).clone();
this.cursor = tempReference_cursor.get();
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_nullableScope = new Reference<RowCursor>(nullableScope);
boolean tempVar = LayoutNullable.HasValue(tempReference_row, tempReference_nullableScope) == Result.Success;
Reference<RowCursor> cursor = new Reference<>(this.cursor);
RowCursor nullableScope = this.row.SparseIteratorReadScope(cursor, true).clone();
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;
nullableScope = tempReference_nullableScope.get();
this.row = tempReference_row.get();
this.row = row.get();
return tempVar;
}
return true;
default:
return false;
}
@@ -171,7 +176,7 @@ public final class RowReader {
case Schematized:
return 0;
case Sparse:
return this.cursor.index;
return this.cursor.index();
default:
return 0;
}
@@ -181,7 +186,7 @@ public final class RowReader {
* The length of row in bytes.
*/
public int getLength() {
return this.row.getLength();
return this.row.length();
}
/**
@@ -210,8 +215,7 @@ public final class RowReader {
}
/**
* The path, relative to the scope, of the field (if positioned on a field, undefined
* otherwise).
* The path, relative to the scope, of the field (if positioned on a field, undefined otherwise)
* <p>
* When enumerating an indexed scope, this value is always null (see {@link Index}).
*/
@@ -268,7 +272,7 @@ public final class RowReader {
case Sparse:
return this.cursor.cellTypeArgs.clone();
default:
return TypeArgumentList.Empty;
return TypeArgumentList.EMPTY;
}
}
@@ -281,7 +285,7 @@ public final class RowReader {
switch (this.state) {
case None: {
if (this.cursor.scopeType instanceof LayoutUDT) {
if (this.cursor.scopeType() instanceof LayoutUDT) {
this.state = States.Schematized;
// TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java:
// goto case States.Schematized;
@@ -301,10 +305,10 @@ public final class RowReader {
// goto case States.Sparse;
}
checkState(this.cursor.scopeType instanceof LayoutUDT);
checkState(this.cursor.scopeType() instanceof LayoutUDT);
LayoutColumn col = this.columns[this.columnIndex];
if (!this.row.ReadBit(this.cursor.start, col.getNullBit().clone())) {
if (!this.row.ReadBit(this.cursor.start(), col.getNullBit().clone())) {
// Skip schematized values if they aren't present.
// TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java:
// goto case States.Schematized;
@@ -1067,7 +1071,7 @@ public final class RowReader {
* {@link ReaderFunc{TContext}} is not an option, such as when TContext is a ref struct.
*/
public Result SkipScope(Reference<RowReader> nestedReader) {
if (nestedReader.get().cursor.start != this.cursor.valueOffset) {
if (nestedReader.get().cursor.start() != this.cursor.valueOffset()) {
return Result.Failure;
}
@@ -1116,14 +1120,14 @@ public final class RowReader {
new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
Result tempVar = t.<LayoutType<TValue>>TypeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value);
Result tempVar = t.<LayoutType<TValue>>typeAs().readFixed(tempReference_row, tempReference_cursor, col, value);
this.cursor = tempReference_cursor.get();
this.row = tempReference_row.get();
return tempVar;
case Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor);
Result tempVar2 = t.<LayoutType<TValue>>TypeAs().ReadVariable(tempReference_row2, tempReference_cursor2, col, value);
Result tempVar2 = t.<LayoutType<TValue>>typeAs().readVariable(tempReference_row2, tempReference_cursor2, col, value);
this.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get();
return tempVar2;
@@ -1152,14 +1156,14 @@ public final class RowReader {
case Fixed:
Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = new Reference<RowCursor>(this.cursor);
Result tempVar = t.<ILayoutUtf8SpanReadable>TypeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value);
Result tempVar = t.<ILayoutUtf8SpanReadable>typeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value);
this.cursor = tempReference_cursor.get();
this.row = tempReference_row.get();
return tempVar;
case Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor);
Result tempVar2 = t.<ILayoutUtf8SpanReadable>TypeAs().ReadVariable(tempReference_row2,
Result tempVar2 = t.<ILayoutUtf8SpanReadable>typeAs().ReadVariable(tempReference_row2,
tempReference_cursor2, col, value);
this.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get();
@@ -1190,14 +1194,14 @@ public final class RowReader {
case Fixed:
Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = new Reference<RowCursor>(this.cursor);
Result tempVar = t.<ILayoutSpanReadable<TElement>>TypeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value);
Result tempVar = t.<ILayoutSpanReadable<TElement>>typeAs().ReadFixed(tempReference_row, tempReference_cursor, col, value);
this.cursor = tempReference_cursor.get();
this.row = tempReference_row.get();
return tempVar;
case Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor);
Result tempVar2 = t.<ILayoutSpanReadable<TElement>>TypeAs().ReadVariable(tempReference_row2, tempReference_cursor2, col, value);
Result tempVar2 = t.<ILayoutSpanReadable<TElement>>typeAs().ReadVariable(tempReference_row2, tempReference_cursor2, col, value);
this.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get();
return tempVar2;

View File

@@ -54,21 +54,21 @@ public final class RowWriter {
* The active layout of the current writer scope.
*/
public Layout getLayout() {
return this.cursor.layout;
return this.cursor.layout();
}
/**
* The length of row in bytes.
*/
public int getLength() {
return this.row.getLength();
return this.row.length();
}
/**
* The resolver for UDTs.
*/
public LayoutResolver getResolver() {
return this.row.getResolver();
return this.row.resolver();
}
/**
@@ -168,7 +168,7 @@ public final class RowWriter {
RowWriter writer = new RowWriter(row, tempReference_scope);
scope = tempReference_scope.get();
TypeArgument typeArg = new TypeArgument(LayoutType.UDT,
new TypeArgumentList(scope.layout.schemaId().clone()));
new TypeArgumentList(scope.layout().schemaId().clone()));
Reference<RowWriter> tempReference_writer =
new Reference<RowWriter>(writer);
// TODO: C# TO JAVA CONVERTER: The following line could not be converted:
@@ -371,7 +371,7 @@ public final class RowWriter {
public <TContext> Result WriteScope(UtfAnyString path, TypeArgument typeArg, TContext context,
WriterFunc<TContext> func) {
LayoutType type = typeArg.getType();
LayoutType type = typeArg.type();
Result result = this.PrepareSparseWrite(path, typeArg.clone());
if (result != Result.Success) {
return result;
@@ -411,7 +411,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope3 =
new Out<RowCursor>();
this.row.WriteTypedArray(tempRef_cursor3, scopeType, typeArg.getTypeArgs().clone(),
this.row.WriteTypedArray(tempRef_cursor3, scopeType, typeArg.typeArgs().clone(),
UpdateOptions.Upsert, tempOut_nestedScope3);
nestedScope = tempOut_nestedScope3.get();
this.cursor = tempRef_cursor3.argValue;
@@ -425,7 +425,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope4 =
new Out<RowCursor>();
this.row.WriteSparseTuple(tempRef_cursor4, scopeType, typeArg.getTypeArgs().clone(),
this.row.WriteSparseTuple(tempRef_cursor4, scopeType, typeArg.typeArgs().clone(),
UpdateOptions.Upsert, tempOut_nestedScope4);
nestedScope = tempOut_nestedScope4.get();
this.cursor = tempRef_cursor4.argValue;
@@ -439,7 +439,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope5 =
new Out<RowCursor>();
this.row.WriteTypedTuple(tempRef_cursor5, scopeType, typeArg.getTypeArgs().clone(),
this.row.WriteTypedTuple(tempRef_cursor5, scopeType, typeArg.typeArgs().clone(),
UpdateOptions.Upsert, tempOut_nestedScope5);
nestedScope = tempOut_nestedScope5.get();
this.cursor = tempRef_cursor5.argValue;
@@ -453,7 +453,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope6 =
new Out<RowCursor>();
this.row.WriteTypedTuple(tempRef_cursor6, scopeType, typeArg.getTypeArgs().clone(),
this.row.WriteTypedTuple(tempRef_cursor6, scopeType, typeArg.typeArgs().clone(),
UpdateOptions.Upsert, tempOut_nestedScope6);
nestedScope = tempOut_nestedScope6.get();
this.cursor = tempRef_cursor6.argValue;
@@ -467,7 +467,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope7 =
new Out<RowCursor>();
this.row.WriteTypedTuple(tempRef_cursor7, scopeType, typeArg.getTypeArgs().clone(),
this.row.WriteTypedTuple(tempRef_cursor7, scopeType, typeArg.typeArgs().clone(),
UpdateOptions.Upsert, tempOut_nestedScope7);
nestedScope = tempOut_nestedScope7.get();
this.cursor = tempRef_cursor7.argValue;
@@ -481,7 +481,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope8 =
new Out<RowCursor>();
this.row.WriteNullable(tempRef_cursor8, scopeType, typeArg.getTypeArgs().clone(),
this.row.WriteNullable(tempRef_cursor8, scopeType, typeArg.typeArgs().clone(),
UpdateOptions.Upsert, func != null, tempOut_nestedScope8);
nestedScope = tempOut_nestedScope8.get();
this.cursor = tempRef_cursor8.argValue;
@@ -491,7 +491,7 @@ public final class RowWriter {
//ORIGINAL LINE: case LayoutUDT scopeType:
case LayoutUDT
scopeType:
Layout udt = this.row.getResolver().Resolve(typeArg.getTypeArgs().getSchemaId().clone());
Layout udt = this.row.resolver().Resolve(typeArg.typeArgs().schemaId().clone());
Reference<RowCursor> tempReference_cursor9 =
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope9 =
@@ -509,7 +509,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope10 =
new Out<RowCursor>();
this.row.WriteTypedSet(tempRef_cursor10, scopeType, typeArg.getTypeArgs().clone(),
this.row.WriteTypedSet(tempRef_cursor10, scopeType, typeArg.typeArgs().clone(),
UpdateOptions.Upsert, tempOut_nestedScope10);
nestedScope = tempOut_nestedScope10.get();
this.cursor = tempRef_cursor10.argValue;
@@ -523,7 +523,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope11 =
new Out<RowCursor>();
this.row.WriteTypedMap(tempRef_cursor11, scopeType, typeArg.getTypeArgs().clone(),
this.row.WriteTypedMap(tempRef_cursor11, scopeType, typeArg.typeArgs().clone(),
UpdateOptions.Upsert, tempOut_nestedScope11);
nestedScope = tempOut_nestedScope11.get();
this.cursor = tempRef_cursor11.argValue;
@@ -547,7 +547,7 @@ public final class RowWriter {
result = func == null ? null : func.Invoke(ref nestedWriter, typeArg, context) ??Result.Success;
nestedWriter = tempReference_nestedWriter.get();
this.row = nestedWriter.row.clone();
nestedScope.count = nestedWriter.cursor.count;
nestedScope.count(nestedWriter.cursor.count());
if (result != Result.Success) {
// TODO: what about unique violations here?
@@ -764,24 +764,24 @@ public final class RowWriter {
* @return Success if the write is permitted, the error code otherwise.
*/
private Result PrepareSparseWrite(UtfAnyString path, TypeArgument typeArg) {
if (this.cursor.scopeType.IsFixedArity && !(this.cursor.scopeType instanceof LayoutNullable)) {
if ((this.cursor.index < this.cursor.scopeTypeArgs.getCount()) && !typeArg.equals(this.cursor.scopeTypeArgs.get(this.cursor.index).clone())) {
if (this.cursor.scopeType().isFixedArity() && !(this.cursor.scopeType() instanceof LayoutNullable)) {
if ((this.cursor.index() < this.cursor.scopeTypeArgs().count()) && !typeArg.equals(this.cursor.scopeTypeArgs().get(this.cursor.index()).clone())) {
return Result.TypeConstraint;
}
} else if (this.cursor.scopeType instanceof LayoutTypedMap) {
} else if (this.cursor.scopeType() instanceof LayoutTypedMap) {
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
if (!typeArg.equals(this.cursor.scopeType.<LayoutUniqueScope>TypeAs().FieldType(tempReference_cursor).clone())) {
if (!typeArg.equals(this.cursor.scopeType().<LayoutUniqueScope>typeAs().FieldType(tempReference_cursor).clone())) {
this.cursor = tempReference_cursor.get();
return Result.TypeConstraint;
} else {
this.cursor = tempReference_cursor.get();
}
} else if (this.cursor.scopeType.IsTypedScope && !typeArg.equals(this.cursor.scopeTypeArgs.get(0).clone())) {
} else if (this.cursor.scopeType().isTypedScope() && !typeArg.equals(this.cursor.scopeTypeArgs().get(0).clone())) {
return Result.TypeConstraint;
}
this.cursor.writePath = path;
this.cursor.writePath(path);
return Result.Success;
}
@@ -797,7 +797,7 @@ public final class RowWriter {
*/
private <TLayoutType extends LayoutType<String> & ILayoutUtf8SpanWritable> Result WritePrimitive(UtfAnyString path, Utf8Span value, TLayoutType type, AccessUtf8SpanMethod sparse) {
Result result = Result.NotFound;
if (this.cursor.scopeType instanceof LayoutUDT) {
if (this.cursor.scopeType() instanceof LayoutUDT) {
result = this.WriteSchematizedValue(path, value);
}
@@ -836,7 +836,7 @@ public final class RowWriter {
*/
private <TLayoutType extends LayoutType<TElement[]> & ILayoutSpanWritable<TElement>, TElement> Result WritePrimitive(UtfAnyString path, ReadOnlySpan<TElement> value, TLayoutType type, AccessReadOnlySpanMethod<TElement> sparse) {
Result result = Result.NotFound;
if (this.cursor.scopeType instanceof LayoutUDT) {
if (this.cursor.scopeType() instanceof LayoutUDT) {
result = this.WriteSchematizedValue(path, value);
}
@@ -875,7 +875,7 @@ public final class RowWriter {
*/
private <TLayoutType extends LayoutType<TElement[]> & ILayoutSequenceWritable<TElement>, TElement> Result WritePrimitive(UtfAnyString path, ReadOnlySequence<TElement> value, TLayoutType type, AccessMethod<ReadOnlySequence<TElement>> sparse) {
Result result = Result.NotFound;
if (this.cursor.scopeType instanceof LayoutUDT) {
if (this.cursor.scopeType() instanceof LayoutUDT) {
result = this.WriteSchematizedValue(path, value);
}
@@ -914,7 +914,7 @@ public final class RowWriter {
private <TValue> Result WritePrimitive(UtfAnyString path, TValue value, LayoutType<TValue> type,
AccessMethod<TValue> sparse) {
Result result = Result.NotFound;
if (this.cursor.scopeType instanceof LayoutUDT) {
if (this.cursor.scopeType() instanceof LayoutUDT) {
result = this.WriteSchematizedValue(path, value);
}
@@ -953,7 +953,7 @@ public final class RowWriter {
LayoutColumn col;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
if (!this.cursor.layout.TryFind(path, out col)) {
if (!this.cursor.layout().TryFind(path, out col)) {
return Result.NotFound;
}
@@ -967,14 +967,14 @@ public final class RowWriter {
case StorageKind.Fixed:
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(this.row);
Result tempVar2 = t.WriteFixed(ref this.row, ref this.cursor, col, value)
Result tempVar2 = t.writeFixed(ref this.row, ref this.cursor, col, value)
this.row = tempReference_row.get();
return tempVar2;
case StorageKind.Variable:
Reference<RowBuffer> tempReference_row2 =
new Reference<RowBuffer>(this.row);
Result tempVar3 = t.WriteVariable(ref this.row, ref this.cursor, col, value)
Result tempVar3 = t.writeVariable(ref this.row, ref this.cursor, col, value)
this.row = tempReference_row2.get();
return tempVar3;
@@ -996,7 +996,7 @@ public final class RowWriter {
LayoutColumn col;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
if (!this.cursor.layout.TryFind(path, out col)) {
if (!this.cursor.layout().TryFind(path, out col)) {
return Result.NotFound;
}
@@ -1011,7 +1011,7 @@ public final class RowWriter {
new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
Result tempVar = t.<ILayoutUtf8SpanWritable>TypeAs().WriteFixed(tempReference_row, tempReference_cursor, col,
Result tempVar = t.<ILayoutUtf8SpanWritable>typeAs().WriteFixed(tempReference_row, tempReference_cursor, col,
value);
this.cursor = tempReference_cursor.get();
this.row = tempReference_row.get();
@@ -1021,7 +1021,7 @@ public final class RowWriter {
new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 =
new Reference<RowCursor>(this.cursor);
Result tempVar2 = t.<ILayoutUtf8SpanWritable>TypeAs().WriteVariable(tempReference_row2,
Result tempVar2 = t.<ILayoutUtf8SpanWritable>typeAs().WriteVariable(tempReference_row2,
tempReference_cursor2,
col, value);
this.cursor = tempReference_cursor2.get();
@@ -1043,7 +1043,7 @@ public final class RowWriter {
private <TElement> Result WriteSchematizedValue(UtfAnyString path, ReadOnlySpan<TElement> value) {
LayoutColumn col;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
if (!this.cursor.layout.TryFind(path, out col)) {
if (!this.cursor.layout().TryFind(path, out col)) {
return Result.NotFound;
}
@@ -1056,14 +1056,14 @@ public final class RowWriter {
case StorageKind.Fixed:
Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = new Reference<RowCursor>(this.cursor);
Result tempVar = t.<ILayoutSpanWritable<TElement>>TypeAs().WriteFixed(tempReference_row, tempReference_cursor, col, value);
Result tempVar = t.<ILayoutSpanWritable<TElement>>typeAs().WriteFixed(tempReference_row, tempReference_cursor, col, value);
this.cursor = tempReference_cursor.get();
this.row = tempReference_row.get();
return tempVar;
case StorageKind.Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor);
Result tempVar2 = t.<ILayoutSpanWritable<TElement>>TypeAs().WriteVariable(tempReference_row2, tempReference_cursor2, col, value);
Result tempVar2 = t.<ILayoutSpanWritable<TElement>>typeAs().WriteVariable(tempReference_row2, tempReference_cursor2, col, value);
this.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get();
return tempVar2;
@@ -1083,7 +1083,7 @@ public final class RowWriter {
private <TElement> Result WriteSchematizedValue(UtfAnyString path, ReadOnlySequence<TElement> value) {
LayoutColumn col;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
if (!this.cursor.layout.TryFind(path, out col)) {
if (!this.cursor.layout().TryFind(path, out col)) {
return Result.NotFound;
}
@@ -1096,14 +1096,14 @@ public final class RowWriter {
case StorageKind.Fixed:
Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = new Reference<RowCursor>(this.cursor);
Result tempVar = t.<ILayoutSequenceWritable<TElement>>TypeAs().WriteFixed(tempReference_row, tempReference_cursor, col, value);
Result tempVar = t.<ILayoutSequenceWritable<TElement>>typeAs().WriteFixed(tempReference_row, tempReference_cursor, col, value);
this.cursor = tempReference_cursor.get();
this.row = tempReference_row.get();
return tempVar;
case StorageKind.Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor);
Result tempVar2 = t.<ILayoutSequenceWritable<TElement>>TypeAs().WriteVariable(tempReference_row2, tempReference_cursor2, col, value);
Result tempVar2 = t.<ILayoutSequenceWritable<TElement>>typeAs().WriteVariable(tempReference_row2, tempReference_cursor2, col, value);
this.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get();
return tempVar2;

View File

@@ -10,23 +10,22 @@ 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.ArrayScope;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableArrayScope;
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) {
super(immutable ? ImmutableArrayScope : ArrayScope, immutable, false, false, false, false);
super(immutable ? IMMUTABLE_ARRAY_SCOPE : ARRAY_SCOPE, immutable, false, false, false, false);
this.TypeArg = new TypeArgument(this);
}
@Override
public String getName() {
public String name() {
return this.Immutable ? "im_array" : "array";
}
public TypeArgument getTypeArg() {
public TypeArgument typeArg() {
return TypeArg;
}
@@ -46,7 +45,7 @@ public final class LayoutArray extends LayoutIndexedScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;

View File

@@ -18,16 +18,14 @@ 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(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Binary, 0);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.BINARY, 0);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return false;
}
@Override
public String getName() {
public String name() {
return "binary";
}
@@ -35,7 +33,7 @@ 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(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<byte[]> value) {
ReadOnlySpan<Byte> span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
@@ -53,21 +51,21 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
// ReadOnlySpan<byte> value)
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<ReadOnlySpan<Byte>> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null);
return Result.NotFound;
}
value.setAndGet(b.get().ReadFixedBinary(scope.get().start + col.getOffset(), col.getSize()));
value.setAndGet(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(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<byte[]> value) {
ReadOnlySpan<Byte> span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
@@ -82,7 +80,7 @@ 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 ReadSparse(ref RowBuffer b, ref RowCursor edit, out ReadOnlySpan<byte> value)
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<ReadOnlySpan<Byte>> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -96,7 +94,7 @@ 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(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
public Result readVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
, Out<byte[]> value) {
ReadOnlySpan<Byte> span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
@@ -114,13 +112,13 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
// ReadOnlySpan<byte> value)
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
, Out<ReadOnlySpan<Byte>> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null);
return Result.NotFound;
}
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start,
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset());
value.setAndGet(b.get().ReadVariableBinary(varOffset));
return Result.Success;
@@ -130,7 +128,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(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
byte[] value) {
checkArgument(value != null);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
@@ -143,15 +141,15 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
// ReadOnlySpan<byte> value)
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
ReadOnlySpan<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0);
checkArgument(value.Length == col.getSize());
if (scope.get().immutable) {
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
b.get().WriteFixedBinary(scope.get().start + col.getOffset(), value, col.getSize());
b.get().SetBit(scope.get().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;
}
@@ -160,21 +158,21 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
// ReadOnlySequence<byte> value)
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
ReadOnlySequence<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0);
checkArgument(value.Length == col.getSize());
if (scope.get().immutable) {
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
b.get().WriteFixedBinary(scope.get().start + col.getOffset(), value, col.getSize());
b.get().SetBit(scope.get().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(Reference<RowBuffer> b, Reference<RowCursor> edit, byte[] value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, byte[] value) {
return writeSparse(b, edit, value, UpdateOptions.Upsert);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
@@ -182,7 +180,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(Reference<RowBuffer> b, Reference<RowCursor> edit, byte[] value,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, byte[] value,
UpdateOptions options) {
checkArgument(value != null);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
@@ -201,7 +199,7 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
ReadOnlySpan<Byte> value, UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -221,7 +219,7 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
ReadOnlySequence<Byte> value, UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -234,7 +232,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(Reference<RowBuffer> b, Reference<RowCursor> scope,
public Result writeVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, byte[] value) {
checkArgument(value != null);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
@@ -247,8 +245,8 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
// ReadOnlySpan<byte> value)
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, ReadOnlySpan<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
@@ -257,16 +255,16 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
return Result.TooBig;
}
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().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;
Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift);
shift = tempOut_shift.get();
b.get().SetBit(scope.get().start, col.getNullBit().clone());
scope.get().metaOffset += shift;
scope.get().valueOffset += shift;
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success;
}
@@ -275,8 +273,8 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
// ReadOnlySequence<byte> value)
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, ReadOnlySequence<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
@@ -285,16 +283,16 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
return Result.TooBig;
}
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().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;
Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift);
shift = tempOut_shift.get();
b.get().SetBit(scope.get().start, col.getNullBit().clone());
scope.get().metaOffset += shift;
scope.get().valueOffset += shift;
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success;
}
}

View File

@@ -17,38 +17,35 @@ public final class LayoutBoolean extends LayoutType<Boolean> {
super(, 0);
}
@Override
public boolean getIsBool() {
public boolean isBoolean() {
return true;
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "bool";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Boolean> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(false);
return Result.NotFound;
}
value.setAndGet(b.get().ReadBit(scope.get().start, col.getBoolBit().clone()));
value.setAndGet(b.get().ReadBit(scope.get().start(), col.getBoolBit().clone()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Boolean> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(false);
return result;
@@ -61,18 +58,18 @@ public final class LayoutBoolean extends LayoutType<Boolean> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
boolean value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
if (value) {
b.get().SetBit(scope.get().start, col.getBoolBit().clone());
b.get().SetBit(scope.get().start(), col.getBoolBit().clone());
} else {
b.get().UnsetBit(scope.get().start, col.getBoolBit().clone());
b.get().UnsetBit(scope.get().start(), col.getBoolBit().clone());
}
b.get().SetBit(scope.get().start, col.getNullBit().clone());
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -82,7 +79,7 @@ public final class LayoutBoolean extends LayoutType<Boolean> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, boolean value,
UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -51,16 +51,16 @@ public final class LayoutBuilder {
if (type.getIsNull()) {
checkArgument(nullable);
LayoutBit nullbit = this.bitallocator.Allocate().clone();
col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Fixed, this.getParent(),
col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Fixed, this.getParent(),
this.fixedCount, 0, nullbit.clone(), LayoutBit.Invalid, 0);
} else if (type.getIsBool()) {
LayoutBit nullbit = nullable ? this.bitallocator.Allocate() : LayoutBit.Invalid;
LayoutBit boolbit = this.bitallocator.Allocate().clone();
col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Fixed, this.getParent(),
col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Fixed, this.getParent(),
this.fixedCount, 0, nullbit.clone(), boolbit.clone(), 0);
} else {
LayoutBit nullBit = nullable ? this.bitallocator.Allocate() : LayoutBit.Invalid;
col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Fixed, this.getParent(),
col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Fixed, this.getParent(),
this.fixedCount, this.fixedSize, nullBit.clone(), LayoutBit.Invalid, length);
this.fixedSize += type.getIsFixed() ? type.Size : length;
@@ -71,7 +71,7 @@ public final class LayoutBuilder {
}
public void AddObjectScope(String path, LayoutType type) {
LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Sparse, this.getParent(),
LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Sparse, this.getParent(),
this.sparseCount, -1, LayoutBit.Invalid, LayoutBit.Invalid, 0);
this.sparseCount++;
@@ -80,7 +80,7 @@ public final class LayoutBuilder {
}
public void AddSparseColumn(String path, LayoutType type) {
LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Sparse, this.getParent(),
LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Sparse, this.getParent(),
this.sparseCount, -1, LayoutBit.Invalid, LayoutBit.Invalid, 0);
this.sparseCount++;
@@ -102,7 +102,7 @@ public final class LayoutBuilder {
checkArgument(length >= 0);
checkArgument(type.getAllowVariable());
LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.Empty, StorageKind.Variable,
LayoutColumn col = new LayoutColumn(path, type, TypeArgumentList.EMPTY, StorageKind.Variable,
this.getParent(), this.varCount, this.varCount, this.bitallocator.Allocate().clone(), LayoutBit.Invalid,
length);

View File

@@ -8,104 +8,109 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts;
///#pragma warning disable CA1028 // Enum Storage should be Int32
import java.util.HashMap;
import java.util.Map;
/**
* Type coded used in the binary encoding to indicate the formatting of succeeding bytes.
*/
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public enum LayoutCode : byte
public enum LayoutCode {
Invalid((byte)0),
Null((byte)1),
BooleanFalse((byte)2),
Boolean((byte)3),
INVALID((byte)0),
Int8((byte)5),
Int16((byte)6),
Int32((byte)7),
Int64((byte)8),
UInt8((byte)9),
NULL((byte)1),
BOOLEAN_FALSE((byte)2),
BOOLEAN((byte)3),
INT_8((byte)5),
INT_16((byte)6),
INT_32((byte)7),
INT_64((byte)8),
UINT_8((byte)9),
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: UInt16 = 10,
UInt16((byte)10),
UINT_16((byte)10),
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: UInt32 = 11,
UInt32((byte)11),
UINT_32((byte)11),
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: UInt64 = 12,
UInt64((byte)12),
VarInt((byte)13),
VarUInt((byte)14),
UINT_64((byte)12),
VAR_INT((byte)13),
VAR_UINT((byte)14),
Float32((byte)15),
Float64((byte)16),
Decimal((byte)17),
FLOAT_32((byte)15),
FLOAT_64((byte)16),
DECIMAL((byte)17),
DateTime((byte)18),
Guid((byte)19),
DATE_TIME((byte)18),
GUID((byte)19),
Utf8((byte)20),
Binary((byte)21),
UTF_8((byte)20),
BINARY((byte)21),
Float128((byte)22),
UnixDateTime((byte)23),
MongoDbObjectId((byte)24),
FLOAT_128((byte)22),
UNIX_DATE_TIME((byte)23),
MONGODB_OBJECT_ID((byte)24),
ObjectScope((byte)30),
ImmutableObjectScope((byte)31),
ArrayScope((byte)32),
ImmutableArrayScope((byte)33),
TypedArrayScope((byte)34),
ImmutableTypedArrayScope((byte)35),
TupleScope((byte)36),
ImmutableTupleScope((byte)37),
TypedTupleScope((byte)38),
ImmutableTypedTupleScope((byte)39),
MapScope((byte)40),
ImmutableMapScope((byte)41),
TypedMapScope((byte)42),
ImmutableTypedMapScope((byte)43),
SetScope((byte)44),
ImmutableSetScope((byte)45),
TypedSetScope((byte)46),
ImmutableTypedSetScope((byte)47),
NullableScope((byte)48),
ImmutableNullableScope((byte)49),
TaggedScope((byte)50),
ImmutableTaggedScope((byte)51),
Tagged2Scope((byte)52),
ImmutableTagged2Scope((byte)53),
OBJECT_SCOPE((byte)30),
IMMUTABLE_OBJECT_SCOPE((byte)31),
ARRAY_SCOPE((byte)32),
IMMUTABLE_ARRAY_SCOPE((byte)33),
TYPED_ARRAY_SCOPE((byte)34),
IMMUTABLE_TYPED_ARRAY_SCOPE((byte)35),
TUPLE_SCOPE((byte)36),
IMMUTABLE_TUPLE_SCOPE((byte)37),
TYPED_TUPLE_SCOPE((byte)38),
IMMUTABLE_TYPED_TUPLE_SCOPE((byte)39),
MAP_SCOPE((byte)40),
IMMUTABLE_MAP_SCOPE((byte)41),
TYPED_MAP_SCOPE((byte)42),
IMMUTABLE_TYPED_MAP_SCOPE((byte)43),
SET_SCOPE((byte)44),
IMMUTABLE_SET_SCOPE((byte)45),
TYPED_SET_SCOPE((byte)46),
IMMUTABLE_TYPED_SET_SCOPE((byte)47),
NULLABLE_SCOPE((byte)48),
IMMUTABLE_NULLABLE_SCOPE((byte)49),
TAGGED_SCOPE((byte)50),
IMMUTABLE_TAGGED_SCOPE((byte)51),
TAGGED2_SCOPE((byte)52),
IMMUTABLE_TAGGED2_SCOPE((byte)53),
/**
* Nested row.
*/
Schema((byte)68),
ImmutableSchema((byte)69),
SCHEMA((byte)68),
IMMUTABLE_SCHEMA((byte)69),
EndScope((byte)70);
END_SCOPE((byte)70);
public static final int SIZE = java.lang.Byte.SIZE;
private static java.util.HashMap<Byte, LayoutCode> mappings;
private byte byteValue;
public static final int SIZE = Byte.SIZE;
private static Map<Byte, LayoutCode> mappings;
private byte value;
LayoutCode(byte value) {
byteValue = value;
getMappings().put(value, this);
this.value = value;
mappings().put(value, this);
}
public byte getValue() {
return byteValue;
public byte value() {
return value;
}
public static LayoutCode forValue(byte value) {
return getMappings().get(value);
return mappings().get(value);
}
private static java.util.HashMap<Byte, LayoutCode> getMappings() {
private static Map<Byte, LayoutCode> mappings() {
if (mappings == null) {
synchronized (LayoutCode.class) {
if (mappings == null) {
mappings = new java.util.HashMap<Byte, LayoutCode>();
mappings = new HashMap<Byte, LayoutCode>();
}
}
}

View File

@@ -12,7 +12,7 @@ public final class LayoutCodeTraits {
* @param code The element type code.
*/
public static boolean AlwaysRequiresTypeCode(LayoutCode code) {
return (code == LayoutCode.Boolean) || (code == LayoutCode.BooleanFalse) || (code == LayoutCode.Null);
return (code == LayoutCode.BOOLEAN) || (code == LayoutCode.BOOLEAN_FALSE) || (code == LayoutCode.NULL);
}
/**
@@ -25,7 +25,7 @@ public final class LayoutCodeTraits {
* @param code The code to canonicalize.
*/
public static LayoutCode Canonicalize(LayoutCode code) {
return (code == LayoutCode.BooleanFalse) ? LayoutCode.Boolean : code;
return (code == LayoutCode.BOOLEAN_FALSE) ? LayoutCode.BOOLEAN : code;
}
/**
@@ -37,6 +37,6 @@ public final class LayoutCodeTraits {
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] public static LayoutCode ClearImmutableBit
// (LayoutCode code)
public static LayoutCode ClearImmutableBit(LayoutCode code) {
return code.getValue() & LayoutCode.forValue((byte)0xFE).getValue();
return code.value() & LayoutCode.forValue((byte)0xFE).value();
}
}

View File

@@ -7,8 +7,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.core.Utf8String;
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
// LayoutColumn
@@ -107,7 +105,7 @@ public final class LayoutColumn {
this.offset = offset;
this.nullBit = nullBit.clone();
this.boolBit = boolBit.clone();
this.size = this.typeArg.getType().getIsFixed() ? type.Size : length;
this.size = this.typeArg.type().getIsFixed() ? type.Size : length;
}
/**
@@ -187,7 +185,7 @@ public final class LayoutColumn {
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerHidden] public T TypeAs<T>() where T : ILayoutType
public <T extends ILayoutType> T TypeAs() {
return this.type.TypeAs();
return this.type.typeAs();
}
/**
@@ -230,13 +228,13 @@ public final class LayoutColumn {
private static String GetFullPath(LayoutColumn parent, String path) {
if (parent != null) {
switch (LayoutCodeTraits.ClearImmutableBit(parent.type.LayoutCode)) {
case ObjectScope:
case Schema:
case OBJECT_SCOPE:
case SCHEMA:
return parent.getFullPath().toString() + "." + path;
case ArrayScope:
case TypedArrayScope:
case TypedSetScope:
case TypedMapScope:
case ARRAY_SCOPE:
case TYPED_ARRAY_SCOPE:
case TYPED_SET_SCOPE:
case TYPED_MAP_SCOPE:
return parent.getFullPath().toString() + "[]" + path;
default:
throw new IllegalStateException(lenientFormat("Parent scope type not supported: %s", parent.type.LayoutCode));

View File

@@ -44,7 +44,7 @@ public final class LayoutCompiler {
checkArgument(ns.getSchemas().contains(schema));
LayoutBuilder builder = new LayoutBuilder(schema.getName(), schema.getSchemaId().clone());
LayoutCompiler.AddProperties(builder, ns, LayoutCode.Schema, schema.getProperties());
LayoutCompiler.AddProperties(builder, ns, LayoutCode.SCHEMA, schema.getProperties());
return builder.Build();
}
@@ -58,7 +58,7 @@ public final class LayoutCompiler {
LayoutType type = LayoutCompiler.LogicalToPhysicalType(ns, p.getPropertyType(), tempOut_typeArgs);
typeArgs = tempOut_typeArgs.get();
switch (LayoutCodeTraits.ClearImmutableBit(type.LayoutCode)) {
case ObjectScope: {
case OBJECT_SCOPE: {
if (!p.getPropertyType().getNullable()) {
throw new LayoutCompilationException("Non-nullable sparse column are not supported.");
}
@@ -70,17 +70,17 @@ public final class LayoutCompiler {
break;
}
case ArrayScope:
case TypedArrayScope:
case SetScope:
case TypedSetScope:
case MapScope:
case TypedMapScope:
case TupleScope:
case TypedTupleScope:
case TaggedScope:
case Tagged2Scope:
case Schema: {
case ARRAY_SCOPE:
case TYPED_ARRAY_SCOPE:
case SET_SCOPE:
case TYPED_SET_SCOPE:
case MAP_SCOPE:
case TYPED_MAP_SCOPE:
case TUPLE_SCOPE:
case TYPED_TUPLE_SCOPE:
case TAGGED_SCOPE:
case TAGGED2_SCOPE:
case SCHEMA: {
if (!p.getPropertyType().getNullable()) {
throw new LayoutCompilationException("Non-nullable sparse column are not supported.");
}
@@ -89,7 +89,7 @@ public final class LayoutCompiler {
break;
}
case NullableScope: {
case NULLABLE_SCOPE: {
throw new LayoutCompilationException("Nullables cannot be explicitly declared as columns.");
}
@@ -100,7 +100,7 @@ public final class LayoutCompiler {
if (pp != null) {
switch (pp.getStorage()) {
case Fixed:
if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.Schema) {
if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) {
throw new LayoutCompilationException("Cannot have fixed storage within a sparse " +
"scope.");
}
@@ -113,7 +113,7 @@ public final class LayoutCompiler {
builder.AddFixedColumn(p.getPath(), type, pp.getNullable(), pp.getLength());
break;
case Variable:
if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.Schema) {
if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) {
throw new LayoutCompilationException("Cannot have variable storage within a " +
"sparse scope.");
}
@@ -150,7 +150,7 @@ public final class LayoutCompiler {
private static LayoutType LogicalToPhysicalType(Namespace ns, PropertyType logicalType,
Out<TypeArgumentList> typeArgs) {
typeArgs.setAndGet(TypeArgumentList.Empty);
typeArgs.setAndGet(TypeArgumentList.EMPTY);
boolean tempVar =
(logicalType instanceof ScopePropertyType ? (ScopePropertyType)logicalType : null).getImmutable();
boolean immutable =
@@ -313,7 +313,7 @@ public final class LayoutCompiler {
}
TypeArgument[] tgArgs = new TypeArgument[tg.getItems().size() + 1];
tgArgs[0] = new TypeArgument(LayoutType.UInt8, TypeArgumentList.Empty);
tgArgs[0] = new TypeArgument(LayoutType.UInt8, TypeArgumentList.EMPTY);
for (int i = 0; i < tg.getItems().size(); i++) {
TypeArgumentList itemTypeArgs = new TypeArgumentList();
Out<TypeArgumentList> tempOut_itemTypeArgs4 = new Out<TypeArgumentList>();
@@ -342,7 +342,7 @@ public final class LayoutCompiler {
case Schema:
UdtPropertyType up = (UdtPropertyType)logicalType;
Schema udtSchema;
if (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 =

View File

@@ -16,36 +16,34 @@ 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);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.DATE_TIME, 8);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "datetime";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<LocalDateTime> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(LocalDateTime.MIN);
return Result.NotFound;
}
value.setAndGet(b.get().ReadDateTime(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadDateTime(scope.get().start() + col.getOffset()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<LocalDateTime> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(LocalDateTime.MIN);
return result;
@@ -58,23 +56,22 @@ public final class LayoutDateTime extends LayoutType<DateTime> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
LocalDateTime value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
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(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
LocalDateTime value, UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -84,7 +81,7 @@ public final class LayoutDateTime extends LayoutType<DateTime> {
}
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, DateTime value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, DateTime value) {
return writeSparse(b, edit, value, UpdateOptions.Upsert);
}
}

View File

@@ -17,36 +17,34 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutDecimal extends LayoutType<BigDecimal> {
public LayoutDecimal() {
// TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof':
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Decimal, sizeof(BigDecimal));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.DECIMAL, sizeof(BigDecimal));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "decimal";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<BigDecimal> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(new BigDecimal(0));
return Result.NotFound;
}
value.setAndGet(b.get().ReadDecimal(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadDecimal(scope.get().start() + col.getOffset()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<BigDecimal> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(new BigDecimal(0));
return result;
@@ -57,15 +55,15 @@ public final class LayoutDecimal extends LayoutType<BigDecimal> {
}
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
BigDecimal value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteDecimal(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -73,9 +71,9 @@ public final class LayoutDecimal extends LayoutType<BigDecimal> {
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, decimal value,
// UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, BigDecimal value,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, BigDecimal value,
UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -85,8 +83,8 @@ public final class LayoutDecimal extends LayoutType<BigDecimal> {
}
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
java.math.BigDecimal value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
return writeSparse(b, edit, value, UpdateOptions.Upsert);
}
}

View File

@@ -16,12 +16,11 @@ 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(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.EndScope, false, isSizedScope:false, isIndexedScope:false, isFixedArity:false, isUniqueScope:
false, isTypedScope:false)
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.END_SCOPE, false, isSizedScope():false, isIndexedScope():false, isFixedArity():false, isUniqueScope():
false, isTypedScope():false)
}
@Override
public String getName() {
public String name() {
return "end";
}

View File

@@ -15,36 +15,34 @@ 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);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.FLOAT_128, HybridRow.Float128.Size);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "float128";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Float128> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null);
return Result.NotFound;
}
value.setAndGet(b.get().ReadFloat128(scope.get().start + col.getOffset()).clone());
value.setAndGet(b.get().ReadFloat128(scope.get().start() + col.getOffset()).clone());
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Float128> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -55,15 +53,15 @@ public final class LayoutFloat128 extends LayoutType<com.azure.data.cosmos.seria
}
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Float128 value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteFloat128(scope.get().start() + col.getOffset(), value.clone());
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -71,9 +69,9 @@ public final class LayoutFloat128 extends LayoutType<com.azure.data.cosmos.seria
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, Float128 value,
// UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Float128 value,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Float128 value,
UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -83,7 +81,7 @@ public final class LayoutFloat128 extends LayoutType<com.azure.data.cosmos.seria
}
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Float128 value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Float128 value) {
return writeSparse(b, edit, value, UpdateOptions.Upsert);
}
}

View File

@@ -14,36 +14,34 @@ 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));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.FLOAT_32, (Float.SIZE / Byte.SIZE));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "float32";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Float> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadFloat32(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadFloat32(scope.get().start() + col.getOffset()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Float> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -56,13 +54,13 @@ public final class LayoutFloat32 extends LayoutType<Float> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
float value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteFloat32(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -72,7 +70,7 @@ public final class LayoutFloat32 extends LayoutType<Float> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, float value,
UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -14,36 +14,34 @@ 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));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.FLOAT_64, (Double.SIZE / Byte.SIZE));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "float64";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Double> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadFloat64(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadFloat64(scope.get().start() + col.getOffset()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Double> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -56,13 +54,13 @@ public final class LayoutFloat64 extends LayoutType<Double> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
double value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteFloat64(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -72,7 +70,7 @@ public final class LayoutFloat64 extends LayoutType<Double> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, double value,
UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -16,36 +16,34 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutGuid extends LayoutType<UUID> {
public LayoutGuid() {
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Guid, 16);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.GUID, 16);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "guid";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<UUID> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null);
return Result.NotFound;
}
value.setAndGet(b.get().ReadGuid(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadGuid(scope.get().start() + col.getOffset()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<UUID> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -56,15 +54,15 @@ public final class LayoutGuid extends LayoutType<UUID> {
}
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
UUID value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteGuid(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -72,9 +70,9 @@ public final class LayoutGuid extends LayoutType<UUID> {
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, Guid value,
// UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, UUID value,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, UUID value,
UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -84,8 +82,8 @@ public final class LayoutGuid extends LayoutType<UUID> {
}
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
java.util.UUID value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
return writeSparse(b, edit, value, UpdateOptions.Upsert);
}
}

View File

@@ -14,36 +14,34 @@ 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));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_16, (Short.SIZE / Byte.SIZE));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "int16";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Short> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadInt16(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadInt16(scope.get().start() + col.getOffset()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Short> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -56,13 +54,13 @@ public final class LayoutInt16 extends LayoutType<Short> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
short value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteInt16(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -72,7 +70,7 @@ public final class LayoutInt16 extends LayoutType<Short> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, short value,
UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -14,36 +14,34 @@ 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));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_32, (Integer.SIZE / Byte.SIZE));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "int32";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Integer> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadInt32(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadInt32(scope.get().start() + col.getOffset()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Integer> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -56,13 +54,13 @@ public final class LayoutInt32 extends LayoutType<Integer> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
int value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteInt32(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -72,7 +70,7 @@ public final class LayoutInt32 extends LayoutType<Integer> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, int value,
UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -14,36 +14,34 @@ 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));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_64, (Long.SIZE / Byte.SIZE));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "int64";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Long> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadInt64(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadInt64(scope.get().start() + col.getOffset()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Long> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -56,13 +54,13 @@ public final class LayoutInt64 extends LayoutType<Long> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
long value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteInt64(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -72,7 +70,7 @@ public final class LayoutInt64 extends LayoutType<Long> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value,
UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -14,36 +14,34 @@ 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));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.INT_8, (Byte.SIZE / Byte.SIZE));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "int8";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadInt8(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadInt8(scope.get().start() + col.getOffset()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Byte> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -56,13 +54,13 @@ public final class LayoutInt8 extends LayoutType<Byte> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
byte value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteInt8(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -72,7 +70,7 @@ public final class LayoutInt8 extends LayoutType<Byte> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, byte value,
UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -14,37 +14,35 @@ 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);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.MONGODB_OBJECT_ID, azure.data.cosmos.serialization.hybridrow.MongoDbObjectId.Size);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
// ReSharper disable once StringLiteralTypo
@Override
public String getName() {
public String name() {
return "mongodbobjectid";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<MongoDbObjectId> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null);
return Result.NotFound;
}
value.setAndGet(b.get().ReadMongoDbObjectId(scope.get().start + col.getOffset()).clone());
value.setAndGet(b.get().ReadMongoDbObjectId(scope.get().start() + col.getOffset()).clone());
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<MongoDbObjectId> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -55,15 +53,15 @@ public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> {
}
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
MongoDbObjectId value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
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());
b.get().WriteMongoDbObjectId(scope.get().start() + col.getOffset(), value.clone());
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -71,9 +69,9 @@ public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> {
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, MongoDbObjectId value,
// UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
MongoDbObjectId value, UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -83,8 +81,8 @@ public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> {
}
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
MongoDbObjectId value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
return writeSparse(b, edit, value, UpdateOptions.Upsert);
}
}

View File

@@ -15,30 +15,27 @@ 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);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.NULL, 0);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public boolean getIsNull() {
public boolean isNull() {
return true;
}
@Override
public String getName() {
public String name() {
return "null";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<NullValue> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
value.setAndGet(NullValue.Default);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
return Result.NotFound;
}
@@ -46,9 +43,9 @@ public final class LayoutNull extends LayoutType<NullValue> {
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<NullValue> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -59,14 +56,14 @@ public final class LayoutNull extends LayoutType<NullValue> {
}
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
NullValue value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
b.get().SetBit(scope.get().start, col.getNullBit().clone());
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -74,9 +71,9 @@ public final class LayoutNull extends LayoutType<NullValue> {
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, NullValue value,
// UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, NullValue value,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, NullValue value,
UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -86,7 +83,7 @@ public final class LayoutNull extends LayoutType<NullValue> {
}
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, NullValue value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, NullValue value) {
return writeSparse(b, edit, value, UpdateOptions.Upsert);
}
}

View File

@@ -15,48 +15,46 @@ 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);
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_NULLABLE_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.NULLABLE_SCOPE, immutable, true, true, false, true);
}
@Override
public String getName() {
public String name() {
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());
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());
}
@Override
public boolean HasImplicitTypeCode(Reference<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);
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 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.getCount() == 1);
boolean hasValue = b.get().ReadInt8(scope.get().start) != 0;
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;
return hasValue ? Result.Success : Result.NotFound;
}
@Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset,
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
return new TypeArgumentList(new TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) });
return new TypeArgumentList(new TypeArgument[] { 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).getType();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone();
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 Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
@@ -70,7 +68,7 @@ public final class LayoutNullable extends LayoutIndexedScope {
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);
Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -96,12 +94,12 @@ public final class LayoutNullable extends LayoutIndexedScope {
}
@Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.getCount() == 1);
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.count() == 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());
lenInBytes += value.get(0).type().writeTypeArgument(row, offset + lenInBytes,
value.get(0).typeArgs().clone());
return lenInBytes;
}
}

View File

@@ -14,17 +14,16 @@ public final class LayoutObject extends LayoutPropertyScope {
private TypeArgument TypeArg = new TypeArgument();
public LayoutObject(boolean immutable) {
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableObjectScope :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ObjectScope, immutable);
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_OBJECT_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.OBJECT_SCOPE, immutable);
this.TypeArg = new TypeArgument(this);
}
@Override
public String getName() {
public String name() {
return this.Immutable ? "im_object" : "object";
}
public TypeArgument getTypeArg() {
public TypeArgument typeArg() {
return TypeArg;
}
@@ -41,7 +40,7 @@ public final class LayoutObject extends LayoutPropertyScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;

View File

@@ -50,7 +50,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
// ConcurrentDictionary method:
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
if (this.layoutCache.TryGetValue(schemaId.getId(), out layout)) {
if (this.layoutCache.TryGetValue(schemaId.id(), out layout)) {
return layout;
}
@@ -58,7 +58,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
if (SchemaId.opEquals(s.getSchemaId().clone(),
schemaId.clone())) {
layout = s.Compile(this.schemaNamespace);
layout = this.layoutCache.putIfAbsent(schemaId.getId(), layout);
layout = this.layoutCache.putIfAbsent(schemaId.id(), layout);
return layout;
}
}
@@ -67,7 +67,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
if (layout != null) {
// TODO: C# TO JAVA CONVERTER: There is no Java ConcurrentHashMap equivalent to this .NET
// ConcurrentDictionary method:
boolean succeeded = this.layoutCache.TryAdd(schemaId.getId(), layout);
boolean succeeded = this.layoutCache.TryAdd(schemaId.id(), layout);
checkState(succeeded);
return layout;
}

View File

@@ -13,51 +13,70 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public abstract class LayoutScope extends LayoutType {
/**
* Returns true if this is a fixed arity scope.
*/
public boolean IsFixedArity;
/**
* Returns true if this is an indexed scope.
*/
public boolean IsIndexedScope;
/**
* Returns true if this is a sized scope.
*/
public boolean IsSizedScope;
/**
* Returns true if this is a typed scope.
*/
public boolean IsTypedScope;
/**
* Returns true if the scope's elements cannot be updated directly.
*/
public boolean IsUniqueScope;
private boolean isFixedArity;
private boolean isIndexedScope;
private boolean isSizedScope;
private boolean isTypedScope;
private boolean isUniqueScope;
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;
this.IsFixedArity = isFixedArity;
this.IsUniqueScope = isUniqueScope;
this.IsTypedScope = isTypedScope;
this.isSizedScope = isSizedScope;
this.isIndexedScope = isIndexedScope;
this.isFixedArity = isFixedArity;
this.isUniqueScope = isUniqueScope;
this.isTypedScope = isTypedScope;
}
@Override
public final boolean getIsFixed() {
return false;
/**
* 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(Reference<RowBuffer> b, Reference<RowCursor> edit) {
Result result = LayoutType.PrepareSparseDelete(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseDelete(b, edit, this.LayoutCode);
if (result != Result.Success) {
return result;
}
b.get().DeleteSparse(edit);
b.get().deleteSparse(edit);
return Result.Success;
}
@@ -72,16 +91,18 @@ public abstract class LayoutScope extends LayoutType {
return false;
}
public final Result ReadScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<RowCursor> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
public final Result ReadScope(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<RowCursor> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(null);
return result;
}
value.setAndGet(b.get().SparseIteratorReadScope(edit,
this.Immutable || edit.get().immutable || edit.get().scopeType.IsUniqueScope).clone());
this.Immutable || edit.get().immutable() || edit.get().scopeType().isUniqueScope()).clone());
return Result.Success;
}
@@ -89,10 +110,10 @@ public abstract class LayoutScope extends LayoutType {
int pathLenInBytes;
Out<Integer> tempOut_pathLenInBytes = new Out<Integer>();
Out<Integer> tempOut_pathOffset = new Out<Integer>();
edit.get().pathToken = row.get().ReadSparsePathLen(edit.get().layout, edit.get().valueOffset, tempOut_pathLenInBytes, tempOut_pathOffset);
edit.get().argValue.pathOffset = tempOut_pathOffset.get();
edit.get().pathToken = row.get().ReadSparsePathLen(edit.get().layout(), edit.get().valueOffset(), tempOut_pathLenInBytes, tempOut_pathOffset);
edit.get().pathOffset = tempOut_pathOffset.get();
pathLenInBytes = tempOut_pathLenInBytes.get();
edit.get().valueOffset += pathLenInBytes;
edit.get().valueOffset(edit.get().valueOffset() + pathLenInBytes);
}
public void SetImplicitTypeCode(Reference<RowCursor> edit) {

View File

@@ -10,45 +10,43 @@ 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;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TAGGED_SCOPE;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TAGGED_SCOPE;
public final class LayoutTagged extends LayoutIndexedScope {
public LayoutTagged(boolean immutable) {
super(immutable ? ImmutableTaggedScope : TaggedScope, immutable, true, true, false, true);
super(immutable ? IMMUTABLE_TAGGED_SCOPE : TAGGED_SCOPE, immutable, true, true, false, true);
}
@Override
public String getName() {
public String name() {
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());
public int countTypeArgument(TypeArgumentList value) {
checkState(value.count() == 2);
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(1).type().CountTypeArgument(value.get(1).typeArgs().clone());
}
@Override
public boolean HasImplicitTypeCode(Reference<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);
checkArgument(edit.get().index() >= 0);
checkArgument(edit.get().scopeTypeArgs().count() > edit.get().index());
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode);
}
@Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset,
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
TypeArgument[] retval = new TypeArgument[2];
retval[0] = new TypeArgument(UInt8, TypeArgumentList.Empty);
retval[1] = ReadTypeArgument(row, offset, lenInBytes);
retval[0] = new TypeArgument(UInt8, TypeArgumentList.EMPTY);
retval[1] = readTypeArgument(row, offset, lenInBytes);
return new TypeArgumentList(retval);
}
@Override
public void SetImplicitTypeCode(Reference<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();
edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone();
}
@Override
@@ -63,7 +61,7 @@ public final class LayoutTagged extends LayoutIndexedScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -74,12 +72,12 @@ public final class LayoutTagged extends LayoutIndexedScope {
}
@Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkArgument(value.getCount() == 2);
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkArgument(value.count() == 2);
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
lenInBytes += value.get(1).getType().WriteTypeArgument(row, offset + lenInBytes,
value.get(1).getTypeArgs().clone());
lenInBytes += value.get(1).type().writeTypeArgument(row, offset + lenInBytes,
value.get(1).typeArgs().clone());
return lenInBytes;
}
}

View File

@@ -12,23 +12,21 @@ 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)
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TAGGED2_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TAGGED2_SCOPE, immutable, isSizedScope():
true, isFixedArity():true, isUniqueScope():false, isTypedScope():true)
}
@Override
public String getName() {
public String name() {
return this.Immutable ? "im_tagged2_t" : "tagged2_t";
}
@Override
public int CountTypeArgument(TypeArgumentList value) {
checkState(value.getCount() == 3);
public int countTypeArgument(TypeArgumentList value) {
checkState(value.count() == 3);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
for (int i = 1; i < value.getCount(); i++) {
for (int i = 1; i < value.count(); i++) {
TypeArgument arg = value.get(i).clone();
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone());
}
return lenInBytes;
@@ -36,21 +34,21 @@ public final class LayoutTagged2 extends LayoutIndexedScope {
@Override
public boolean HasImplicitTypeCode(Reference<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);
checkState(edit.get().index() >= 0);
checkState(edit.get().scopeTypeArgs().count() > edit.get().index());
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode);
}
@Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset,
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
lenInBytes.setAndGet(0);
TypeArgument[] retval = new TypeArgument[3];
retval[0] = new TypeArgument(UInt8, TypeArgumentList.Empty);
retval[0] = new TypeArgument(UInt8, TypeArgumentList.EMPTY);
for (int i = 1; i < 3; i++) {
int itemLenInBytes;
Out<Integer> tempOut_itemLenInBytes = new Out<Integer>();
retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
retval[i] = readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
itemLenInBytes = tempOut_itemLenInBytes.get();
lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes);
}
@@ -60,8 +58,8 @@ public final class LayoutTagged2 extends LayoutIndexedScope {
@Override
public void SetImplicitTypeCode(Reference<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();
edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone();
}
@Override
@@ -76,7 +74,7 @@ public final class LayoutTagged2 extends LayoutIndexedScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -87,13 +85,13 @@ public final class LayoutTagged2 extends LayoutIndexedScope {
}
@Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.getCount() == 3);
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.count() == 3);
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
for (int i = 1; i < value.getCount(); i++) {
for (int i = 1; i < value.count(); i++) {
TypeArgument arg = value.get(i).clone();
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone());
}
return lenInBytes;

View File

@@ -10,41 +10,39 @@ 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;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TUPLE_SCOPE;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TUPLE_SCOPE;
public final class LayoutTuple extends LayoutIndexedScope {
public LayoutTuple(boolean immutable) {
super(immutable ? ImmutableTupleScope : TupleScope, immutable, false, true, false, false);
super(immutable ? IMMUTABLE_TUPLE_SCOPE : TUPLE_SCOPE, immutable, false, true, false, false);
}
@Override
public String getName() {
public String name() {
return this.Immutable ? "im_tuple" : "tuple";
}
@Override
public int CountTypeArgument(TypeArgumentList value) {
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());
lenInBytes += RowBuffer.Count7BitEncodedUInt(value.count());
for (TypeArgument arg : value) {
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone());
}
return lenInBytes;
}
@Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset,
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes);
TypeArgument[] retval = new TypeArgument[numTypeArgs];
for (int i = 0; i < numTypeArgs; i++) {
int itemLenInBytes;
Out<Integer> tempOut_itemLenInBytes = new Out<Integer>();
retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
retval[i] = readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
itemLenInBytes = tempOut_itemLenInBytes.get();
lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes);
}
@@ -64,7 +62,7 @@ public final class LayoutTuple extends LayoutIndexedScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -75,14 +73,14 @@ public final class LayoutTuple extends LayoutIndexedScope {
}
@Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
//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());
lenInBytes += row.get().Write7BitEncodedUInt(offset + lenInBytes, value.count());
for (TypeArgument arg : value) {
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone());
}
return lenInBytes;

View File

@@ -13,327 +13,171 @@ 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
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
///#pragma warning disable SA1201 // Elements should appear in the correct order
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
///#pragma warning disable SA1401 // Fields should be private
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
///#pragma warning disable CA1040 // Avoid empty interfaces
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
///#pragma warning disable CA1051 // Do not declare visible instance fields
/**
* The abstract base class for typed hybrid row field descriptors.
* {@link LayoutType} is immutable.
* Describes the physical byte layout of a hybrid row field of a specific physical type {@code T}
*
* {@link LayoutType<T>} is an immutable, stateless, helper class. It provides methods for manipulating hybrid row
* fields of a particular type, and properties that describe the layout of fields of that type.
* <p>
* {@param <T>} The specific physical type whose byte layout is represented by this class.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerDisplay("{" + nameof(LayoutType.Name) + "}")] public abstract class LayoutType : ILayoutType
public abstract class LayoutType implements ILayoutType {
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutArray Array = new LayoutArray(immutable:
// false);
public static final LayoutArray Array = new LayoutArray(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutBinary Binary = new LayoutBinary();
public static final LayoutBinary Binary = new LayoutBinary();
/**
* The number of bits in a single byte on the current architecture.
*/
public static final int BitsPerByte = 8;
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutBoolean Boolean = new LayoutBoolean(true);
public static final LayoutBoolean Boolean = new LayoutBoolean(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutBoolean BooleanFalse = new LayoutBoolean
// (false);
public static final LayoutBoolean BooleanFalse = new LayoutBoolean(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutDateTime DateTime = new LayoutDateTime();
public static final LayoutDateTime DateTime = new LayoutDateTime();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutDecimal Decimal = new LayoutDecimal();
public static final LayoutDecimal Decimal = new LayoutDecimal();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] internal static readonly LayoutEndScope EndScope = new LayoutEndScope();
public static final LayoutEndScope EndScope = new LayoutEndScope();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutFloat128 Float128 = new LayoutFloat128();
public static final LayoutFloat128 Float128 = new LayoutFloat128();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutFloat32 Float32 = new LayoutFloat32();
public static final LayoutFloat32 Float32 = new LayoutFloat32();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutFloat64 Float64 = new LayoutFloat64();
public static final LayoutFloat64 Float64 = new LayoutFloat64();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutArray ImmutableArray = new LayoutArray
// (immutable: true);
public static final LayoutArray ImmutableArray = new LayoutArray(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutNullable ImmutableNullable = new
// LayoutNullable(immutable: true);
public static final LayoutNullable ImmutableNullable = new LayoutNullable(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutObject ImmutableObject = new LayoutObject
// (immutable: true);
public static final LayoutObject ImmutableObject = new LayoutObject(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTagged ImmutableTagged = new LayoutTagged
// (immutable: true);
public static final LayoutTagged ImmutableTagged = new LayoutTagged(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTagged2 ImmutableTagged2 = new
// LayoutTagged2(immutable: true);
public static final LayoutTagged2 ImmutableTagged2 = new LayoutTagged2(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTuple ImmutableTuple = new LayoutTuple
// (immutable: true);
public static final LayoutTuple ImmutableTuple = new LayoutTuple(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTypedArray ImmutableTypedArray = new
// LayoutTypedArray(immutable: true);
public static final LayoutTypedArray ImmutableTypedArray = new LayoutTypedArray(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTypedMap ImmutableTypedMap = new
// LayoutTypedMap(immutable: true);
public static final LayoutTypedMap ImmutableTypedMap = new LayoutTypedMap(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTypedSet ImmutableTypedSet = new
// LayoutTypedSet(immutable: true);
public static final LayoutTypedSet ImmutableTypedSet = new LayoutTypedSet(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTypedTuple ImmutableTypedTuple = new
// LayoutTypedTuple(immutable: true);
public static final LayoutTypedTuple ImmutableTypedTuple = new LayoutTypedTuple(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUDT ImmutableUDT = new LayoutUDT
// (immutable: true);
public static final LayoutUDT ImmutableUDT = new LayoutUDT(true);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutInt16 Int16 = new LayoutInt16();
public static final LayoutInt16 Int16 = new LayoutInt16();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutInt32 Int32 = new LayoutInt32();
public static final LayoutInt32 Int32 = new LayoutInt32();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutInt64 Int64 = new LayoutInt64();
public static final LayoutInt64 Int64 = new LayoutInt64();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutInt8 Int8 = new LayoutInt8();
public static final LayoutInt8 Int8 = new LayoutInt8();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutMongoDbObjectId MongoDbObjectId = new
// LayoutMongoDbObjectId();
public static final LayoutMongoDbObjectId MongoDbObjectId = new LayoutMongoDbObjectId();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutNull Null = new LayoutNull();
public static final LayoutNull Null = new LayoutNull();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutNullable Nullable = new LayoutNullable
// (immutable: false);
public static final LayoutNullable Nullable = new LayoutNullable(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutObject Object = new LayoutObject
// (immutable: false);
public static final LayoutObject Object = new LayoutObject(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTagged Tagged = new LayoutTagged
// (immutable: false);
public static final LayoutTagged Tagged = new LayoutTagged(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTagged2 Tagged2 = new LayoutTagged2
// (immutable: false);
public static final LayoutTagged2 Tagged2 = new LayoutTagged2(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTuple Tuple = new LayoutTuple(immutable:
// false);
public static final LayoutTuple Tuple = new LayoutTuple(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTypedArray TypedArray = new
// LayoutTypedArray(immutable: false);
public static final LayoutTypedArray TypedArray = new LayoutTypedArray(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTypedMap TypedMap = new LayoutTypedMap
// (immutable: false);
public static final LayoutTypedMap TypedMap = new LayoutTypedMap(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTypedSet TypedSet = new LayoutTypedSet
// (immutable: false);
public static final LayoutTypedSet TypedSet = new LayoutTypedSet(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutTypedTuple TypedTuple = new
// LayoutTypedTuple(immutable: false);
public static final LayoutTypedTuple TypedTuple = new LayoutTypedTuple(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUDT UDT = new LayoutUDT(immutable: false);
public static final LayoutUDT UDT = new LayoutUDT(false);
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUInt16 UInt16 = new LayoutUInt16();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUInt16 UInt16 = new LayoutUInt16();
public static final LayoutUInt16 UInt16 = new LayoutUInt16();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUInt32 UInt32 = new LayoutUInt32();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUInt32 UInt32 = new LayoutUInt32();
public static final LayoutUInt32 UInt32 = new LayoutUInt32();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUInt64 UInt64 = new LayoutUInt64();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUInt64 UInt64 = new LayoutUInt64();
public static final LayoutUInt64 UInt64 = new LayoutUInt64();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUInt8 UInt8 = new LayoutUInt8();
public static final LayoutUInt8 UInt8 = new LayoutUInt8();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutGuid Guid = new LayoutGuid();
public static final LayoutGuid Guid = new LayoutGuid();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUnixDateTime UnixDateTime = new
// LayoutUnixDateTime();
public static final LayoutUnixDateTime UnixDateTime = new LayoutUnixDateTime();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutUtf8 Utf8 = new LayoutUtf8();
public static final LayoutUtf8 Utf8 = new LayoutUtf8();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
// Justification = "Type is immutable.")] public static readonly LayoutVarInt VarInt = new LayoutVarInt();
public static final LayoutVarInt VarInt = new LayoutVarInt();
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//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[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.
*/
public boolean Immutable;
/**
* The physical layout code used to represent the type within the serialization.
*/
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.
*/
public int Size;
public abstract class LayoutType<T> implements ILayoutType {
private static final LayoutType[] CodeIndex = new LayoutType[LayoutCode.END_SCOPE.value() + 1];
private final boolean immutable;
private final LayoutCode layoutCode;
private final int size;
private final TypeArgument typeArg;
/**
* Initializes a new instance of the {@link LayoutType} class.
* Initializes a new instance of the {@link LayoutType<T>} class.
*/
public LayoutType(LayoutCode code, boolean immutable, int size) {
this.LayoutCode = code;
this.Immutable = immutable;
this.Size = size;
LayoutType.CodeIndex[code.getValue()] = this;
protected LayoutType(LayoutCode code, boolean immutable, int size) {
this.layoutCode = code;
this.immutable = immutable;
this.size = size;
this.typeArg = new TypeArgument(this);
CodeIndex[code.value()] = this;
}
/**
* True if this type can be used in the variable-length segment.
* Initializes a new instance of the {@link LayoutType<T>} class.
*/
public final boolean getAllowVariable() {
return !this.getIsFixed();
protected LayoutType(LayoutCode code, int size) {
this(code, false, size);
}
/**
* True if this type is a boolean.
*/
public boolean getIsBool() {
public boolean isBoolean() {
return false;
}
/**
* True if this type is always fixed length.
*/
public abstract boolean getIsFixed();
public abstract boolean isFixed();
/**
* If true, this edit's nested fields cannot be updated individually.
* The entire edit can still be replaced.
*/
public boolean isImmutable() {
return immutable;
}
/**
* True if this type is a literal null.
*/
public boolean getIsNull() {
public boolean isNull() {
return false;
}
/**
* True if this type is a variable-length encoded integer type (either signed or unsigned).
*/
public boolean getIsVarint() {
public boolean isVarint() {
return false;
}
/**
* True if this type can be used in the variable-length segment.
*/
public final boolean allowVariable() {
return !this.isFixed();
}
public int countTypeArgument(TypeArgumentList value) {
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
}
public final Result deleteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
if (col.getNullBit().getIsInvalid()) {
// Cannot delete a non-nullable fixed column.
return Result.TypeMismatch;
}
b.get().UnsetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
/**
* Delete an existing value.
* <p>
* 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(Reference<RowBuffer> b, Reference<RowCursor> edit) {
Result result = LayoutType.prepareSparseDelete(b, edit, this.layoutCode());
if (result != Result.Success) {
return result;
}
b.get().deleteSparse(edit);
return Result.Success;
}
/**
* Delete an existing value.
* <p>
* If a value exists, then it is removed. The remainder of the row is resized to accommodate a decrease in
* required space. If no value exists this operation is a no-op.
*/
public final Result deleteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit());
if (exists) {
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset());
b.get().DeleteVariable(varOffset, this.isVarint());
b.get().UnsetBit(scope.get().start(), col.getNullBit().clone());
}
return Result.Success;
}
public static LayoutType fromCode(LayoutCode code) {
LayoutType type = LayoutType.CodeIndex[code.value()];
assert type != null : lenientFormat("Not Implemented: %s", code);
return type;
}
public final Result hasValue(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col) {
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
return Result.NotFound;
}
return Result.Success;
}
/**
* The physical layout code used to represent the type within the serialization.
*/
public LayoutCode layoutCode() {
return this.layoutCode;
}
/**
* Human readable name of the type.
*/
public abstract String getName();
public int CountTypeArgument(TypeArgumentList value) {
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:
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static LayoutType FromCode
// (LayoutCode code)
public static LayoutType FromCode(LayoutCode code) {
LayoutType type = LayoutType.CodeIndex[code.getValue()];
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
//#if DEBUG
if (type == null) {
throw new IllegalStateException(lenientFormat("Not Implemented: %s", code));
}
//#endif
return type;
}
public abstract String name();
/**
* Helper for preparing the delete of a sparse field.
@@ -343,17 +187,16 @@ 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(Reference<RowBuffer> b, Reference<RowCursor> edit,
LayoutCode code) {
if (edit.get().scopeType.IsFixedArity) {
public static Result prepareSparseDelete(Reference<RowBuffer> b, Reference<RowCursor> edit, LayoutCode code) {
if (edit.get().scopeType().isFixedArity()) {
return Result.TypeConstraint;
}
if (edit.get().immutable) {
if (edit.get().immutable()) {
return Result.InsufficientPermissions;
}
if (edit.get().exists && LayoutCodeTraits.Canonicalize(edit.get().cellType.LayoutCode) != code) {
if (edit.get().exists && LayoutCodeTraits.Canonicalize(edit.get().cellType.layoutCode()) != code) {
return Result.TypeMismatch;
}
@@ -373,16 +216,21 @@ 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(Reference<RowBuffer> b,
Reference<RowCursor> destinationScope,
LayoutScope destinationCode, TypeArgument elementType,
Reference<RowCursor> srcEdit, UpdateOptions options,
Out<RowCursor> dstEdit) {
checkArgument(destinationScope.get().scopeType == destinationCode);
checkArgument(destinationScope.get().index == 0, "Can only insert into a edit at the root");
public static Result prepareSparseMove(
Reference<RowBuffer> b,
Reference<RowCursor> destinationScope,
LayoutScope destinationCode,
TypeArgument elementType,
Reference<RowCursor> srcEdit,
UpdateOptions options,
Out<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.type().layoutCode());
// Prepare the delete of the source.
Result result = LayoutType.PrepareSparseDelete(b, srcEdit, elementType.getType().LayoutCode);
if (result != Result.Success) {
dstEdit.setAndGet(null);
return result;
@@ -393,34 +241,34 @@ public abstract class LayoutType implements ILayoutType {
return Result.NotFound;
}
if (destinationScope.get().immutable) {
b.get().DeleteSparse(srcEdit);
if (destinationScope.get().immutable()) {
b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null);
return Result.InsufficientPermissions;
}
if (!srcEdit.get().cellTypeArgs.equals(elementType.getTypeArgs().clone())) {
b.get().DeleteSparse(srcEdit);
if (!srcEdit.get().cellTypeArgs.equals(elementType.typeArgs())) {
b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null);
return Result.TypeConstraint;
}
if (options == UpdateOptions.InsertAt) {
b.get().DeleteSparse(srcEdit);
b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null);
return Result.TypeConstraint;
}
// Prepare the insertion at the destination.
dstEdit.setAndGet(b.get().PrepareSparseMove(destinationScope, srcEdit).clone());
dstEdit.setAndGet(b.get().PrepareSparseMove(destinationScope, srcEdit));
if ((options == UpdateOptions.Update) && (!dstEdit.get().exists)) {
b.get().DeleteSparse(srcEdit);
b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null);
return Result.NotFound;
}
if ((options == UpdateOptions.Insert) && dstEdit.get().exists) {
b.get().DeleteSparse(srcEdit);
b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null);
return Result.Exists;
}
@@ -436,13 +284,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(Reference<RowBuffer> b, Reference<RowCursor> edit,
LayoutCode code) {
public static Result prepareSparseRead(Reference<RowBuffer> b, Reference<RowCursor> edit, LayoutCode code) {
if (!edit.get().exists) {
return Result.NotFound;
}
if (LayoutCodeTraits.Canonicalize(edit.get().cellType.LayoutCode) != code) {
if (LayoutCodeTraits.Canonicalize(edit.get().cellType.layoutCode()) != code) {
return Result.TypeMismatch;
}
@@ -458,29 +306,29 @@ 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(Reference<RowBuffer> b, Reference<RowCursor> edit,
public static Result prepareSparseWrite(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgument typeArg, UpdateOptions options) {
if (edit.get().immutable || (edit.get().scopeType.IsUniqueScope && !edit.get().deferUniqueIndex)) {
if (edit.get().immutable() || (edit.get().scopeType().isUniqueScope() && !edit.get().deferUniqueIndex)) {
return Result.InsufficientPermissions;
}
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())) {
if (edit.get().scopeType().isFixedArity() && !(edit.get().scopeType() instanceof LayoutNullable)) {
if ((edit.get().index() < edit.get().scopeTypeArgs().count()) && !typeArg.equals(edit.get().scopeTypeArgs().get(edit.get().index()))) {
return Result.TypeConstraint;
}
} else if (edit.get().scopeType instanceof LayoutTypedMap) {
if (!((typeArg.getType() instanceof LayoutTypedTuple) && typeArg.getTypeArgs().equals(edit.get().scopeTypeArgs.clone()))) {
} else if (edit.get().scopeType() instanceof LayoutTypedMap) {
if (!((typeArg.type() instanceof LayoutTypedTuple) && typeArg.typeArgs().equals(edit.get().scopeTypeArgs()))) {
return Result.TypeConstraint;
}
} else if (edit.get().scopeType.IsTypedScope && !typeArg.equals(edit.get().scopeTypeArgs.get(0).clone())) {
} else if (edit.get().scopeType().isTypedScope() && !typeArg.equals(edit.get().scopeTypeArgs().get(0))) {
return Result.TypeConstraint;
}
if ((options == UpdateOptions.InsertAt) && edit.get().scopeType.IsFixedArity) {
if ((options == UpdateOptions.InsertAt) && edit.get().scopeType().isFixedArity()) {
return Result.TypeConstraint;
}
if ((options == UpdateOptions.InsertAt) && !edit.get().scopeType.IsFixedArity) {
if ((options == UpdateOptions.InsertAt) && !edit.get().scopeType().isFixedArity()) {
edit.get().exists = false; // InsertAt never overwrites an existing item.
}
@@ -495,34 +343,61 @@ public abstract class LayoutType implements ILayoutType {
return Result.Success;
}
// 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(Reference<RowBuffer> row, int offset, Out<Integer> lenInBytes) {
public abstract Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<T> value);
public abstract Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<T> value);
public static TypeArgument readTypeArgument(Reference<RowBuffer> row, int offset, Out<Integer> lenInBytes) {
LayoutType itemCode = row.get().ReadSparseTypeCode(offset);
int argsLenInBytes;
Out<Integer> tempOut_argsLenInBytes = new Out<Integer>();
TypeArgumentList itemTypeArgs = itemCode.ReadTypeArgumentList(row, offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), tempOut_argsLenInBytes).clone();
TypeArgumentList itemTypeArgs = itemCode.readTypeArgumentList(row, offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), tempOut_argsLenInBytes);
argsLenInBytes = tempOut_argsLenInBytes.get();
lenInBytes.setAndGet((com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + argsLenInBytes);
return new TypeArgument(itemCode, itemTypeArgs.clone());
return new TypeArgument(itemCode, itemTypeArgs);
}
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset, Out<Integer> lenInBytes) {
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset, Out<Integer> lenInBytes) {
lenInBytes.setAndGet(0);
return TypeArgumentList.Empty;
return TypeArgumentList.EMPTY;
}
public Result readVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<T> value) {
value.setAndGet(null);
return Result.Failure;
}
/**
* If fixed, the fixed size of the type's serialization in bytes, otherwise undefined.
*/
public int size() {
return size;
}
/**
* The physical layout type of the field cast to the specified type.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerHidden] public T TypeAs<T>() where T : ILayoutType
public final <T extends ILayoutType> T TypeAs() {
return (T)this;
@SuppressWarnings("unchecked")
public final <Value extends ILayoutType> Value typeAs() {
return (Value)this;
}
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
public abstract Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, T value);
public abstract Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, T value);
public abstract Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, T value, UpdateOptions options);
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
row.get().WriteSparseTypeCode(offset, this.layoutCode());
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
}
}
public Result writeVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, T value) {
return Result.Failure;
}
TypeArgument typeArg() {
return this.typeArg;
}
}

View File

@@ -1,126 +0,0 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
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 static com.google.common.base.Preconditions.checkArgument;
/**
* Describes the physical byte layout of a hybrid row field of a specific physical type
* <typeparamref name="T" />.
*
*
* {@link LayoutType{T}} is an immutable, stateless, helper class. It provides
* methods for manipulating hybrid row fields of a particular type, and properties that describe the
* layout of fields of that type.
* <para />
* {@link LayoutType{T}} is immutable.
*/
public abstract class LayoutType<T> extends LayoutType {
private TypeArgument typeArg = new TypeArgument();
public LayoutType(LayoutCode code, int size) {
super(code, false, size);
this.typeArg = new TypeArgument(this);
}
public final Result DeleteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
return Result.InsufficientPermissions;
}
if (col.getNullBit().getIsInvalid()) {
// Cannot delete a non-nullable fixed column.
return Result.TypeMismatch;
}
b.get().UnsetBit(scope.get().start, col.getNullBit().clone());
return Result.Success;
}
/**
* Delete an existing value.
* <p>
* 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(Reference<RowBuffer> b, Reference<RowCursor> edit) {
Result result = LayoutType.PrepareSparseDelete(b, edit, this.LayoutCode);
if (result != Result.Success) {
return result;
}
b.get().DeleteSparse(edit);
return Result.Success;
}
/**
* Delete an existing value.
* <p>
* 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(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
return Result.InsufficientPermissions;
}
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone());
if (exists) {
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start,
col.getOffset());
b.get().DeleteVariable(varOffset, this.getIsVarint());
b.get().UnsetBit(scope.get().start, col.getNullBit().clone());
}
return Result.Success;
}
public final Result HasValue(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col) {
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
return Result.NotFound;
}
return Result.Success;
}
public abstract Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, Out<T> value);
public abstract Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<T> value);
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
, Out<T> value) {
value.setAndGet(null);
return Result.Failure;
}
public abstract Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, T value);
public abstract Result WriteSparse(Reference<RowBuffer> b, Reference<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(Reference<RowBuffer> b, Reference<RowCursor> edit, T value, UpdateOptions options);
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, T value) {
return Result.Failure;
}
abstract TypeArgument getTypeArg();
}

View File

@@ -12,38 +12,36 @@ 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);
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_ARRAY_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_ARRAY_SCOPE, immutable, true, false, false, true);
}
@Override
public String getName() {
public String name() {
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());
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());
}
@Override
public boolean HasImplicitTypeCode(Reference<RowCursor> edit) {
checkState(edit.get().index >= 0);
checkState(edit.get().scopeTypeArgs.getCount() == 1);
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(0).getType().LayoutCode);
checkState(edit.get().index() >= 0);
checkState(edit.get().scopeTypeArgs().count() == 1);
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode);
}
@Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset,
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
return new TypeArgumentList(new TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) });
return new TypeArgumentList(new TypeArgument[] { LayoutType.readTypeArgument(row, offset, lenInBytes) });
}
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
edit.get().cellType = edit.get().scopeTypeArgs.get(0).getType();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone();
edit.get().cellType = edit.get().scopeTypeArgs().get(0).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone();
}
@Override
@@ -58,7 +56,7 @@ public final class LayoutTypedArray extends LayoutIndexedScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -69,12 +67,12 @@ public final class LayoutTypedArray extends LayoutIndexedScope {
}
@Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.getCount() == 1);
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.count() == 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());
lenInBytes += value.get(0).type().writeTypeArgument(row, offset + lenInBytes,
value.get(0).typeArgs().clone());
return lenInBytes;
}
}

View File

@@ -12,22 +12,20 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
public final class LayoutTypedMap extends LayoutUniqueScope {
public LayoutTypedMap(boolean immutable) {
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedMapScope :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedMapScope, immutable, isSizedScope:
true, isTypedScope:true)
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_MAP_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_MAP_SCOPE, immutable, isSizedScope():
true, isTypedScope():true)
}
@Override
public String getName() {
public String name() {
return this.Immutable ? "im_map_t" : "map_t";
}
@Override
public int CountTypeArgument(TypeArgumentList value) {
checkState(value.getCount() == 2);
public int countTypeArgument(TypeArgumentList value) {
checkState(value.count() == 2);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
for (TypeArgument arg : value) {
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone());
}
return lenInBytes;
@@ -35,8 +33,8 @@ public final class LayoutTypedMap extends LayoutUniqueScope {
@Override
public TypeArgument FieldType(Reference<RowCursor> scope) {
return new TypeArgument(scope.get().scopeType.Immutable ? ImmutableTypedTuple :
TypedTuple, scope.get().scopeTypeArgs.clone());
return new TypeArgument(scope.get().scopeType().Immutable ? ImmutableTypedTuple :
TypedTuple, scope.get().scopeTypeArgs().clone());
}
@Override
@@ -45,14 +43,14 @@ public final class LayoutTypedMap extends LayoutUniqueScope {
}
@Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset,
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
lenInBytes.setAndGet(0);
TypeArgument[] retval = new TypeArgument[2];
for (int i = 0; i < 2; i++) {
int itemLenInBytes;
Out<Integer> tempOut_itemLenInBytes = new Out<Integer>();
retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
retval[i] = readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
itemLenInBytes = tempOut_itemLenInBytes.get();
lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes);
}
@@ -62,9 +60,9 @@ public final class LayoutTypedMap extends LayoutUniqueScope {
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
edit.get().cellType = edit.get().scopeType.Immutable ? ImmutableTypedTuple :
edit.get().cellType = edit.get().scopeType().Immutable ? ImmutableTypedTuple :
TypedTuple;
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.clone();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().clone();
}
@Override
@@ -79,7 +77,7 @@ public final class LayoutTypedMap extends LayoutUniqueScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -90,12 +88,12 @@ public final class LayoutTypedMap extends LayoutUniqueScope {
}
@Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.getCount() == 2);
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.count() == 2);
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
for (TypeArgument arg : value) {
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone());
}
return lenInBytes;

View File

@@ -10,47 +10,45 @@ 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.ImmutableTypedSetScope;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedSetScope;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_SET_SCOPE;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_SET_SCOPE;
public final class LayoutTypedSet extends LayoutUniqueScope {
public LayoutTypedSet(boolean immutable) {
super(immutable ? ImmutableTypedSetScope : TypedSetScope, immutable, true, true);
super(immutable ? IMMUTABLE_TYPED_SET_SCOPE : TYPED_SET_SCOPE, immutable, true, true);
}
@Override
public String getName() {
public String name() {
return this.Immutable ? "im_set_t" : "set_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());
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());
}
@Override
public TypeArgument FieldType(Reference<RowCursor> scope) {
return scope.get().scopeTypeArgs.get(0).clone();
return scope.get().scopeTypeArgs().get(0).clone();
}
@Override
public boolean HasImplicitTypeCode(Reference<RowCursor> edit) {
checkState(edit.get().index >= 0);
checkState(edit.get().scopeTypeArgs.getCount() == 1);
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(0).getType().LayoutCode);
checkState(edit.get().index() >= 0);
checkState(edit.get().scopeTypeArgs().count() == 1);
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode);
}
@Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset,
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
return new TypeArgumentList(new TypeArgument[] { ReadTypeArgument(row, offset, lenInBytes) });
return new TypeArgumentList(new TypeArgument[] { readTypeArgument(row, offset, lenInBytes) });
}
@Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) {
edit.get().cellType = edit.get().scopeTypeArgs.get(0).getType();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone();
edit.get().cellType = edit.get().scopeTypeArgs().get(0).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone();
}
@Override
@@ -65,7 +63,7 @@ public final class LayoutTypedSet extends LayoutUniqueScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -76,12 +74,12 @@ public final class LayoutTypedSet extends LayoutUniqueScope {
}
@Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkArgument(value.getCount() == 1);
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkArgument(value.count() == 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());
lenInBytes += value.get(0).type().writeTypeArgument(row, offset + lenInBytes,
value.get(0).typeArgs().clone());
return lenInBytes;
}
}

View File

@@ -14,23 +14,21 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutTypedTuple extends LayoutIndexedScope {
public LayoutTypedTuple(boolean immutable) {
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedTupleScope :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedTupleScope, immutable, true, true, false, true);
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_TUPLE_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_TUPLE_SCOPE, immutable, true, true, false, true);
}
@Override
public String getName() {
public String name() {
return this.Immutable ? "im_tuple_t" : "tuple_t";
}
@Override
public int CountTypeArgument(TypeArgumentList value) {
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());
lenInBytes += RowBuffer.Count7BitEncodedUInt(value.count());
for (TypeArgument arg : value) {
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone());
lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone());
}
return lenInBytes;
@@ -38,20 +36,20 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
@Override
public boolean HasImplicitTypeCode(Reference<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);
checkArgument(edit.get().index() >= 0);
checkArgument(edit.get().scopeTypeArgs().count() > edit.get().index());
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode);
}
@Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset,
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes);
TypeArgument[] retval = new TypeArgument[numTypeArgs];
for (int i = 0; i < numTypeArgs; i++) {
int itemLenInBytes;
Out<Integer> tempOut_itemLenInBytes = new Out<Integer>();
retval[i] = LayoutType.ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
retval[i] = LayoutType.readTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes);
itemLenInBytes = tempOut_itemLenInBytes.get();
lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes);
}
@@ -61,8 +59,8 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
@Override
public void SetImplicitTypeCode(Reference<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();
edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone();
}
@Override
@@ -77,7 +75,7 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -88,14 +86,14 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
}
@Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
//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());
lenInBytes += row.get().Write7BitEncodedUInt(offset + lenInBytes, value.count());
for (TypeArgument arg : value) {
lenInBytes += arg.getType().WriteTypeArgument(row, offset + lenInBytes, arg.getTypeArgs().clone());
lenInBytes += arg.type().writeTypeArgument(row, offset + lenInBytes, arg.typeArgs().clone());
}
return lenInBytes;

View File

@@ -0,0 +1,58 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
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 int BitsPerByte = 8;
public static final LayoutBoolean Boolean = new LayoutBoolean(true);
public static final LayoutBoolean BooleanFalse = new LayoutBoolean(false);
public static final LayoutDateTime DateTime = new LayoutDateTime();
public static final LayoutDecimal Decimal = new LayoutDecimal();
public static final LayoutEndScope EndScope = new LayoutEndScope();
public static final LayoutFloat128 Float128 = new LayoutFloat128();
public static final LayoutFloat32 Float32 = new LayoutFloat32();
public static final LayoutFloat64 Float64 = new LayoutFloat64();
public static final LayoutGuid Guid = new LayoutGuid();
public static final LayoutArray ImmutableArray = new LayoutArray(true);
public static final LayoutNullable ImmutableNullable = new LayoutNullable(true);
public static final LayoutObject ImmutableObject = new LayoutObject(true);
public static final LayoutTagged ImmutableTagged = new LayoutTagged(true);
public static final LayoutTagged2 ImmutableTagged2 = new LayoutTagged2(true);
public static final LayoutTuple ImmutableTuple = new LayoutTuple(true);
public static final LayoutTypedArray ImmutableTypedArray = new LayoutTypedArray(true);
public static final LayoutTypedMap ImmutableTypedMap = new LayoutTypedMap(true);
public static final LayoutTypedSet ImmutableTypedSet = new LayoutTypedSet(true);
public static final LayoutTypedTuple ImmutableTypedTuple = new LayoutTypedTuple(true);
public static final LayoutUDT ImmutableUDT = new LayoutUDT(true);
public static final LayoutInt16 Int16 = new LayoutInt16();
public static final LayoutInt32 Int32 = new LayoutInt32();
public static final LayoutInt64 Int64 = new LayoutInt64();
public static final LayoutInt8 Int8 = 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 LayoutTypedMap TypedMap = new LayoutTypedMap(false);
public static final LayoutTypedSet TypedSet = new LayoutTypedSet(false);
public static final LayoutTypedTuple TypedTuple = new LayoutTypedTuple(false);
public static final LayoutUDT UDT = new LayoutUDT(false);
public static final LayoutUInt16 UInt16 = new LayoutUInt16();
public static final LayoutUInt32 UInt32 = new LayoutUInt32();
public static final LayoutUInt64 UInt64 = new LayoutUInt64();
public static final LayoutUInt8 UInt8 = new LayoutUInt8();
public static final LayoutUnixDateTime UnixDateTime = new LayoutUnixDateTime();
public static final LayoutUtf8 Utf8 = new LayoutUtf8();
public static final LayoutVarInt VarInt = new LayoutVarInt();
public static final LayoutVarUInt VarUInt = new LayoutVarUInt();
}

View File

@@ -13,25 +13,23 @@ import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
public final class LayoutUDT extends LayoutPropertyScope {
public LayoutUDT(boolean immutable) {
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableSchema :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Schema, immutable);
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_SCHEMA :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SCHEMA, immutable);
}
@Override
public String getName() {
public String name() {
return this.Immutable ? "im_udt" : "udt";
}
@Override
public int CountTypeArgument(TypeArgumentList value) {
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.Size;
public int countTypeArgument(TypeArgumentList value) {
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.SIZE;
}
@Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset,
public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) {
SchemaId schemaId = row.get().ReadSchemaId(offset).clone();
lenInBytes.setAndGet(SchemaId.Size);
lenInBytes.setAndGet(SchemaId.SIZE);
return new TypeArgumentList(schemaId.clone());
}
@@ -47,8 +45,8 @@ public final class LayoutUDT extends LayoutPropertyScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Layout udt = b.get().getResolver().Resolve(typeArgs.getSchemaId().clone());
Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
Layout udt = b.get().resolver().Resolve(typeArgs.schemaId().clone());
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -59,9 +57,9 @@ public final class LayoutUDT extends LayoutPropertyScope {
}
@Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
row.get().WriteSchemaId(offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), value.getSchemaId().clone());
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.Size;
row.get().WriteSchemaId(offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), value.schemaId().clone());
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.SIZE;
}
}

View File

@@ -16,16 +16,14 @@ import static com.google.common.base.Preconditions.checkArgument;
//ORIGINAL LINE: public sealed class LayoutUInt16 : LayoutType<ushort>
public final class LayoutUInt16 extends LayoutType<Short> {
public LayoutUInt16() {
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UInt16, (Short.SIZE / Byte.SIZE));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UINT_16, (Short.SIZE / Byte.SIZE));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "uint16";
}
@@ -33,24 +31,24 @@ public final class LayoutUInt16 extends LayoutType<Short> {
//ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// ushort value)
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Short> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadUInt16(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadUInt16(scope.get().start() + col.getOffset()));
return Result.Success;
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ushort value)
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Short> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -66,13 +64,13 @@ public final class LayoutUInt16 extends LayoutType<Short> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
short value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
b.get().WriteUInt16(scope.get().start + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone());
b.get().WriteUInt16(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -83,7 +81,7 @@ public final class LayoutUInt16 extends LayoutType<Short> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, short value,
UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -16,16 +16,14 @@ import static com.google.common.base.Preconditions.checkArgument;
//ORIGINAL LINE: public sealed class LayoutUInt32 : LayoutType<uint>
public final class LayoutUInt32 extends LayoutType<Integer> {
public LayoutUInt32() {
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UInt32, (Integer.SIZE / Byte.SIZE));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UINT_32, (Integer.SIZE / Byte.SIZE));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "uint32";
}
@@ -33,24 +31,24 @@ public final class LayoutUInt32 extends LayoutType<Integer> {
//ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// uint value)
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Integer> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadUInt32(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadUInt32(scope.get().start() + col.getOffset()));
return Result.Success;
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out uint value)
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Integer> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -66,13 +64,13 @@ public final class LayoutUInt32 extends LayoutType<Integer> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
int value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
b.get().WriteUInt32(scope.get().start + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone());
b.get().WriteUInt32(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -83,7 +81,7 @@ public final class LayoutUInt32 extends LayoutType<Integer> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, int value,
UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -16,16 +16,14 @@ import static com.google.common.base.Preconditions.checkArgument;
//ORIGINAL LINE: public sealed class LayoutUInt64 : LayoutType<ulong>
public final class LayoutUInt64 extends LayoutType<Long> {
public LayoutUInt64() {
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UInt64, (Long.SIZE / Byte.SIZE));
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UINT_64, (Long.SIZE / Byte.SIZE));
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "uint64";
}
@@ -33,24 +31,24 @@ public final class LayoutUInt64 extends LayoutType<Long> {
//ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// ulong value)
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Long> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadUInt64(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadUInt64(scope.get().start() + col.getOffset()));
return Result.Success;
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ulong value)
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Long> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -66,13 +64,13 @@ public final class LayoutUInt64 extends LayoutType<Long> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
long value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
b.get().WriteUInt64(scope.get().start + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone());
b.get().WriteUInt64(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -83,7 +81,7 @@ public final class LayoutUInt64 extends LayoutType<Long> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value,
UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -16,16 +16,14 @@ import static com.google.common.base.Preconditions.checkArgument;
//ORIGINAL LINE: public sealed class LayoutUInt8 : LayoutType<byte>
public final class LayoutUInt8 extends LayoutType<Byte> {
public LayoutUInt8() {
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UInt8, 1);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UINT_8, 1);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "uint8";
}
@@ -33,24 +31,24 @@ public final class LayoutUInt8 extends LayoutType<Byte> {
//ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// byte value)
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
value.setAndGet(b.get().ReadUInt8(scope.get().start + col.getOffset()));
value.setAndGet(b.get().ReadUInt8(scope.get().start() + col.getOffset()));
return Result.Success;
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out byte value)
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Byte> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -66,13 +64,13 @@ public final class LayoutUInt8 extends LayoutType<Byte> {
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
byte value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
b.get().WriteUInt8(scope.get().start + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone());
b.get().WriteUInt8(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -83,7 +81,7 @@ public final class LayoutUInt8 extends LayoutType<Byte> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, byte value,
UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}

View File

@@ -6,7 +6,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.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;
@@ -38,14 +37,14 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
*/
public final Result Find(Reference<RowBuffer> b, Reference<RowCursor> scope,
Reference<RowCursor> patternScope, Out<RowCursor> value) {
Result result = LayoutType.PrepareSparseMove(b, scope, this, this.FieldType(scope).clone(), patternScope, UpdateOptions.Update, value.clone());
Result result = LayoutType.prepareSparseMove(b, scope, this, this.FieldType(scope).clone(), patternScope, UpdateOptions.Update, value.clone());
if (result != Result.Success) {
return result;
}
// Check if the search found the result.
b.get().DeleteSparse(patternScope);
b.get().deleteSparse(patternScope);
return Result.Success;
}
@@ -58,7 +57,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
RowCursor dstEdit;
Out<RowCursor> tempOut_dstEdit =
new Out<RowCursor>();
Result result = LayoutType.PrepareSparseMove(b, destinationScope, this,
Result result = LayoutType.prepareSparseMove(b, destinationScope, this,
this.FieldType(destinationScope).clone(), sourceEdit, options, tempOut_dstEdit);
dstEdit = tempOut_dstEdit.get();
@@ -74,7 +73,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
// TODO: it would be "better" if the destinationScope were updated to point to the
// highest item seen. Then we would avoid the maximum reparse.
destinationScope.get().count = dstEdit.count;
destinationScope.get().count(dstEdit.count());
return Result.Success;
}
@@ -129,7 +128,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
return r;
}
uniqueScope.count = childScope.count;
uniqueScope.count(childScope.count());
Reference<RowCursor> tempReference_uniqueScope =
new Reference<RowCursor>(uniqueScope);
r = b.get().TypedCollectionUniqueIndexRebuild(tempReference_uniqueScope);

View File

@@ -15,37 +15,35 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutUnixDateTime extends LayoutType<com.azure.data.cosmos.serialization.hybridrow.UnixDateTime> {
public LayoutUnixDateTime() {
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UnixDateTime,
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UNIX_DATE_TIME,
com.azure.data.cosmos.serialization.hybridrow.UnixDateTime.Size);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return true;
}
@Override
public String getName() {
public String name() {
return "unixdatetime";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<UnixDateTime> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null);
return Result.NotFound;
}
value.setAndGet(b.get().ReadUnixDateTime(scope.get().start + col.getOffset()).clone());
value.setAndGet(b.get().ReadUnixDateTime(scope.get().start() + col.getOffset()).clone());
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<UnixDateTime> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -56,15 +54,15 @@ public final class LayoutUnixDateTime extends LayoutType<com.azure.data.cosmos.s
}
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
UnixDateTime value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
b.get().WriteUnixDateTime(scope.get().start + col.getOffset(), value.clone());
b.get().SetBit(scope.get().start, col.getNullBit().clone());
b.get().WriteUnixDateTime(scope.get().start() + col.getOffset(), value.clone());
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@@ -72,9 +70,9 @@ public final class LayoutUnixDateTime extends LayoutType<com.azure.data.cosmos.s
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, UnixDateTime value,
// UpdateOptions options = UpdateOptions.Upsert)
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, UnixDateTime value
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, UnixDateTime value
, UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -84,7 +82,7 @@ public final class LayoutUnixDateTime extends LayoutType<com.azure.data.cosmos.s
}
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, UnixDateTime value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, UnixDateTime value) {
return writeSparse(b, edit, value, UpdateOptions.Upsert);
}
}

View File

@@ -14,21 +14,19 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8SpanWritable, ILayoutUtf8SpanReadable {
public LayoutUtf8() {
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Utf8, 0);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UTF_8, 0);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return false;
}
@Override
public String getName() {
public String name() {
return "utf8";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<String> value) {
Utf8Span span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
@@ -41,19 +39,19 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Utf8Span> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null);
return Result.NotFound;
}
value.setAndGet(b.get().ReadFixedString(scope.get().start + col.getOffset(), col.getSize()));
value.setAndGet(b.get().ReadFixedString(scope.get().start() + col.getOffset(), col.getSize()));
return Result.Success;
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<String> value) {
Utf8Span span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
@@ -65,7 +63,7 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
}
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<Utf8Span> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(null);
return result;
@@ -76,7 +74,7 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
}
@Override
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
public Result readVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
, Out<String> value) {
Utf8Span span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
@@ -89,20 +87,20 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
, Out<Utf8Span> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null);
return Result.NotFound;
}
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start,
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset());
value.setAndGet(b.get().ReadVariableString(varOffset));
return Result.Success;
}
@Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
String value) {
checkArgument(value != null);
return this.WriteFixed(b, scope, col, Utf8Span.TranscodeUtf16(value));
@@ -110,28 +108,28 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Utf8Span value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0);
checkArgument(value.Length == col.getSize());
if (scope.get().immutable) {
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
b.get().WriteFixedString(scope.get().start + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone());
b.get().WriteFixedString(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success;
}
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, String value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert);
public Result writeSparse(Reference<RowBuffer> b, Reference<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(Reference<RowBuffer> b, Reference<RowCursor> edit, String value,
public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, String value,
UpdateOptions options) {
checkArgument(value != null);
return this.WriteSparse(b, edit, Utf8Span.TranscodeUtf16(value), options);
@@ -147,7 +145,7 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
// options = UpdateOptions.Upsert)
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Utf8Span value,
UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -157,7 +155,7 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
}
@Override
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
public Result writeVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, String value) {
checkArgument(value != null);
return this.WriteVariable(b, scope, col, Utf8Span.TranscodeUtf16(value));
@@ -165,8 +163,8 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, Utf8Span value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
@@ -175,16 +173,16 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
return Result.TooBig;
}
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().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;
Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableString(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;
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success;
}
}

View File

@@ -14,26 +14,23 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutVarInt extends LayoutType<Long> {
public LayoutVarInt() {
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.VarInt, 0);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.VAR_INT, 0);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return false;
}
@Override
public boolean getIsVarint() {
public boolean isVarint() {
return true;
}
@Override
public String getName() {
public String name() {
return "varint";
}
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Long> value) {
Contract.Fail("Not Implemented");
value.setAndGet(0);
@@ -41,8 +38,8 @@ public final class LayoutVarInt extends LayoutType<Long> {
}
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<Long> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode);
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<Long> value) {
Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -53,14 +50,14 @@ public final class LayoutVarInt extends LayoutType<Long> {
}
@Override
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Long> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
public Result readVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Long> value) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start,
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset());
value.setAndGet(b.get().ReadVariableInt(varOffset));
return Result.Success;
@@ -79,7 +76,7 @@ public final class LayoutVarInt extends LayoutType<Long> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value,
UpdateOptions options) {
Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -96,21 +93,21 @@ public final class LayoutVarInt extends LayoutType<Long> {
@Override
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, long value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().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;
Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableInt(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;
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success;
}
}

View File

@@ -16,21 +16,18 @@ import static com.google.common.base.Preconditions.checkArgument;
//ORIGINAL LINE: public sealed class LayoutVarUInt : LayoutType<ulong>
public final class LayoutVarUInt extends LayoutType<Long> {
public LayoutVarUInt() {
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.VarUInt, 0);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.VAR_UINT, 0);
}
@Override
public boolean getIsFixed() {
public boolean isFixed() {
return false;
}
@Override
public boolean getIsVarint() {
public boolean isVarint() {
return true;
}
@Override
public String getName() {
public String name() {
return "varuint";
}
@@ -38,7 +35,7 @@ public final class LayoutVarUInt extends LayoutType<Long> {
//ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// ulong value)
@Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
public Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Long> value) {
Contract.Fail("Not Implemented");
value.setAndGet(0);
@@ -48,8 +45,8 @@ public final class LayoutVarUInt extends LayoutType<Long> {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ulong value)
@Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<Long> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode);
public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<Long> value) {
Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) {
value.setAndGet(0);
return result;
@@ -63,14 +60,14 @@ public final class LayoutVarUInt extends LayoutType<Long> {
//ORIGINAL LINE: public override Result ReadVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// ulong value)
@Override
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Long> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) {
public Result readVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Long> value) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0);
return Result.NotFound;
}
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start,
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset());
value.setAndGet(b.get().ReadVariableUInt(varOffset));
return Result.Success;
@@ -93,7 +90,7 @@ public final class LayoutVarUInt extends LayoutType<Long> {
@Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value,
UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options);
Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) {
return result;
}
@@ -113,21 +110,21 @@ public final class LayoutVarUInt extends LayoutType<Long> {
@Override
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, long value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT);
if (scope.get().immutable) {
checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable()) {
return Result.InsufficientPermissions;
}
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().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;
Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableUInt(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;
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success;
}
}

View File

@@ -6,87 +6,65 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.core.Utf8String;
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ
// from the original:
//ORIGINAL LINE: public readonly struct StringToken
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct:
public final class StringToken {
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
///#pragma warning disable CA1051 // Do not declare visible instance fields
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public readonly ulong Id;
public long Id;
public Utf8String Path;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public readonly byte[] Varint;
public byte[] Varint;
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
///#pragma warning restore CA1051 // Do not declare visible instance fields
public final class StringToken implements Cloneable {
public long id;
public Utf8String path;
public byte[] varint;
public StringToken() {
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public StringToken(ulong id, Utf8String path)
public StringToken(long id, Utf8String path) {
this.Id = id;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: this.Varint = new byte[StringToken.Count7BitEncodedUInt(id)];
this.Varint = new byte[StringToken.Count7BitEncodedUInt(id)];
StringToken.Write7BitEncodedUInt(this.Varint.AsSpan(), id);
this.Path = path;
this.varint = new byte[StringToken.Count7BitEncodedUInt(id)];
StringToken.Write7BitEncodedUInt(this.varint, id);
this.path = path;
this.id = id;
}
@Override
public StringToken clone() {
StringToken varCopy = new StringToken();
varCopy.Id = this.Id;
varCopy.Varint = this.Varint;
varCopy.Path = this.Path;
return varCopy;
try {
final StringToken token = (StringToken)super.clone();
token.id = this.id;
token.path = this.path;
token.varint = this.varint;
return token;
} catch (CloneNotSupportedException error) {
assert false : error;
throw new IllegalStateException(error);
}
}
boolean getIsNull()
public boolean isNull() {
return this.varint == null;
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: private static int Count7BitEncodedUInt(ulong value)
private static int Count7BitEncodedUInt(long value) {
// Count the number of bytes needed to write out an int 7 bits at a time.
int i = 0;
while (value >= 0x80L) {
i++;
//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:
value >>>= 7;
}
i++;
return i;
return ++i;
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: private static int Write7BitEncodedUInt(Span<byte> buffer, ulong value)
private static int Write7BitEncodedUInt(Span<Byte> buffer, long value) {
// Write out an unsigned long 7 bits at a time. The high bit of the byte,
// when set, indicates there are more bytes.
private static int Write7BitEncodedUInt(byte[] buffer, long value) {
// Write an unsigned long 7 bits at a time. The high bit of the byte, when set, indicates there are more bytes.
int i = 0;
while (value >= 0x80L) {
// TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context:
//ORIGINAL LINE: buffer[i] = unchecked((byte)(value | 0x80));
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
buffer[i] = (byte)(value | 0x80);
i++;
//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:
buffer[i++] = (byte) (value | 0x80);
value >>>= 7;
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: buffer[i] = (byte)value;
buffer[i] = (byte)value;
i++;
buffer[i++] = (byte) value;
return i;
}
}

View File

@@ -9,9 +9,8 @@ import com.azure.data.cosmos.core.Utf8String;
import com.azure.data.cosmos.core.UtfAnyString;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
@@ -29,13 +28,15 @@ public final class StringTokenizer {
*/
public StringTokenizer() {
this.tokens = new HashMap<Utf8String, StringToken>(
Map.ofEntries(Map.entry(Utf8String.EMPTY, new StringToken(0, Utf8String.EMPTY))));
this.tokens = new HashMap<>();
this.tokens.put(Utf8String.EMPTY, new StringToken(0, Utf8String.EMPTY));
this.stringTokens = new HashMap<String, StringToken>(
Map.ofEntries(Map.entry("", new StringToken(0, Utf8String.EMPTY))));
this.stringTokens = new HashMap<>();
this.stringTokens.put("", new StringToken(0, Utf8String.EMPTY));
this.strings = new ArrayList<>();
this.strings.add(Utf8String.EMPTY);
this.strings = new ArrayList<Utf8String>(Collections.singletonList(Utf8String.EMPTY));
this.count = 1;
}
@@ -61,41 +62,33 @@ public final class StringTokenizer {
* Looks up a string's corresponding token.
*
* @param path The string to look up.
* @param token If successful, the string's assigned token.
* @return True if successful, false otherwise.
* @return {@code true} if successful, {@code false} otherwise.
*/
public boolean tryFindToken(UtfAnyString path, Out<StringToken> token) {
public Optional<StringToken> findToken(UtfAnyString path) {
if (path.isNull()) {
token.setAndGet(null);
return false;
return Optional.empty();
}
if (path.isUtf8()) {
return (this.tokens.containsKey(path.toUtf8()) && (token.setAndGet(this.tokens.get(path.toUtf8()))) == token.get());
return Optional.ofNullable(this.tokens.get(path.toUtf8()));
}
return (this.stringTokens.containsKey(path.toUtf16()) && (token.setAndGet(this.stringTokens.get(path.toUtf16()))) == token.get());
return Optional.ofNullable(this.stringTokens.get(path.toUtf16()));
}
/**
* Assign a token to the string.
* Assign a token to a string
* <p>
* If the string already has a token, that token is returned instead.
*
* @param path The string to assign a new token.
* @return The token assigned to the string.
*/
public StringToken add(Utf8String path) {
checkArgument(path != null);
StringToken token;
if (this.tokens.containsKey(path) && (token = this.tokens.get(path)) == token) {
return token;
}
token = this.allocateToken(path).clone();
return token;
final StringToken token = this.tokens.get(path);
return token == null ? this.allocateToken(path) : token;
}
/**
@@ -113,14 +106,13 @@ public final class StringTokenizer {
*/
private StringToken allocateToken(Utf8String path) {
final long id = this.count++;
final StringToken token = new StringToken(id, path);
final StringToken token = new StringToken(this.count++, path);
this.tokens.put(path, token.clone());
this.stringTokens.put(path.toString(), token.clone());
this.stringTokens.put(path.toUtf16(), token);
this.tokens.put(path, token);
this.strings.add(path);
checkState((long)this.strings.size() - 1 == id);
return token.clone();
checkState((long)this.strings.size() - 1 == token.id);
return token;
}
}

View File

@@ -4,33 +4,22 @@
package com.azure.data.cosmos.serialization.hybridrow.layouts;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerDisplay("{this.type == null ? null : ToString()}")] public readonly struct TypeArgument :
// IEquatable<TypeArgument>
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ
// from the original:
//ORIGINAL LINE: [DebuggerDisplay("{this.type == null ? null : ToString()}")] public readonly struct TypeArgument :
// IEquatable<TypeArgument>
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct:
public final class TypeArgument implements IEquatable<TypeArgument> {
private LayoutType type;
private TypeArgumentList typeArgs = new TypeArgumentList();
public final class TypeArgument {
private final LayoutType type;
private final TypeArgumentList typeArgs;
/**
* Initializes a new instance of the {@link TypeArgument} struct.
*
* @param type The type of the constraint.
*/
public TypeArgument() {
}
public TypeArgument(LayoutType type) {
checkArgument(type != null);
checkNotNull(type);
this.type = type;
this.typeArgs = TypeArgumentList.Empty;
this.typeArgs = TypeArgumentList.EMPTY;
}
/**
@@ -40,78 +29,28 @@ public final class TypeArgument implements IEquatable<TypeArgument> {
* @param typeArgs For generic types the type parameters.
*/
public TypeArgument(LayoutType type, TypeArgumentList typeArgs) {
checkArgument(type != null);
checkNotNull(type);
this.type = type;
this.typeArgs = typeArgs.clone();
}
/**
* The physical layout type.
*/
public LayoutType getType() {
return this.type;
}
/**
* If the type argument is itself generic, then its type arguments.
*/
public TypeArgumentList getTypeArgs() {
return this.typeArgs.clone();
}
/**
* The physical layout type of the field cast to the specified type.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerHidden] public T TypeAs<T>() where T : ILayoutType
public <T extends ILayoutType> T TypeAs() {
return this.type.TypeAs();
}
public TypeArgument clone() {
TypeArgument varCopy = new TypeArgument();
varCopy.type = this.type;
varCopy.typeArgs = this.typeArgs.clone();
return varCopy;
}
public boolean equals(TypeArgument other) {
return this.type.equals(other.type) && this.typeArgs.equals(other.typeArgs.clone());
this.typeArgs = typeArgs;
}
@Override
public boolean equals(Object obj) {
if (null == obj) {
public boolean equals(Object other) {
if (null == other) {
return false;
}
boolean tempVar = obj instanceof TypeArgument;
TypeArgument ota = tempVar ? (TypeArgument)obj : null;
if (tempVar) {
return this.equals(ota);
}
return false;
return other instanceof TypeArgument && this.equals((TypeArgument) other);
}
@Override
public int hashCode() {
// TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java:
unchecked
{
return (this.type.hashCode() * 397) ^ this.typeArgs.hashCode();
}
return (this.type.hashCode() * 397) ^ this.typeArgs.hashCode();
}
public static boolean opEquals(TypeArgument left, TypeArgument right) {
return left.equals(right.clone());
}
public static boolean opNotEquals(TypeArgument left, TypeArgument right) {
return !left.equals(right.clone());
public boolean equals(TypeArgument other) {
return this.type.equals(other.type) && this.typeArgs.equals(other.typeArgs);
}
@Override
@@ -119,7 +58,20 @@ public final class TypeArgument implements IEquatable<TypeArgument> {
if (this.type == null) {
return "";
}
return this.type.name() + this.typeArgs.toString();
}
return this.type.getName() + this.typeArgs.toString();
/**
* The physical layout type.
*/
public LayoutType type() {
return this.type;
}
/**
* If the type argument is itself generic, then its type arguments.
*/
public TypeArgumentList typeArgs() {
return this.typeArgs;
}
}

View File

@@ -6,38 +6,26 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
import java.util.Arrays;
import static com.google.common.base.Preconditions.checkArgument;
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
///#pragma warning disable CA1034 // Nested types should not be visible
public final class TypeArgumentList
{
public static final TypeArgumentList EMPTY = new TypeArgumentList();
private final TypeArgument[] args;
private final SchemaId schemaId;
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerDisplay("{this.args == null ? null : ToString()}")] public readonly struct TypeArgumentList
// : IEquatable<TypeArgumentList>
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ
// from the original:
//ORIGINAL LINE: [DebuggerDisplay("{this.args == null ? null : ToString()}")] public readonly struct TypeArgumentList
// : IEquatable<TypeArgumentList>
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct:
public final class TypeArgumentList implements IEquatable<TypeArgumentList> {
public static final TypeArgumentList Empty = new TypeArgumentList(Array.<TypeArgument>Empty());
private TypeArgument[] args;
/**
* For UDT fields, the schema id of the nested layout.
*/
private SchemaId schemaId = new SchemaId();
public TypeArgumentList() {
private TypeArgumentList() {
this.args = new TypeArgument[] {};
this.schemaId = SchemaId.NONE;
}
public TypeArgumentList(TypeArgument[] args) {
checkArgument(args != null);
this.args = args;
this.schemaId = getSchemaId().Invalid;
this.schemaId = SchemaId.INVALID;
}
/**
@@ -45,20 +33,20 @@ public final class TypeArgumentList implements IEquatable<TypeArgumentList> {
*
* @param schemaId For UDT fields, the schema id of the nested layout.
*/
public TypeArgumentList(SchemaId schemaId) {
this.args = Array.<TypeArgument>Empty();
this.schemaId = schemaId.clone();
public TypeArgumentList(SchemaId schemaId, TypeArgument...args) {
this.args = args.length == 0 ? EMPTY.args : args;
this.schemaId = schemaId;
}
public int getCount() {
public int count() {
return this.args.length;
}
/**
* For UDT fields, the schema id of the nested layout.
*/
public SchemaId getSchemaId() {
return this.schemaId.clone();
public SchemaId schemaId() {
return this.schemaId;
}
/**
@@ -68,35 +56,19 @@ public final class TypeArgumentList implements IEquatable<TypeArgumentList> {
return new Enumerator(this.args);
}
public TypeArgumentList clone() {
TypeArgumentList varCopy = new TypeArgumentList();
varCopy.args = this.args.clone();
varCopy.schemaId = this.schemaId.clone();
return varCopy;
}
public boolean equals(TypeArgumentList other) {
//C# TO JAVA CONVERTER WARNING: Java Arrays.equals is not always identical to LINQ 'SequenceEqual':
//ORIGINAL LINE: return (this.schemaId == other.schemaId) && this.args.SequenceEqual(other.args);
return (SchemaId.opEquals(this.schemaId.clone(),
other.schemaId.clone())) && Arrays.equals(this.args, other.args);
if (null == other) {
return false;
}
if (this == other) {
return true;
}
return this.schemaId().equals(other.schemaId()) && Arrays.equals(this.args, other.args);
}
@Override
public boolean equals(Object obj) {
if (null == obj) {
return false;
}
boolean tempVar = obj instanceof TypeArgumentList;
TypeArgumentList ota = tempVar ? (TypeArgumentList)obj : null;
if (tempVar) {
return this.equals(ota);
}
return false;
public boolean equals(Object other) {
return other instanceof TypeArgumentList && this.equals((TypeArgumentList) other);
}
public TypeArgument get(int i) {
@@ -105,32 +77,30 @@ public final class TypeArgumentList implements IEquatable<TypeArgumentList> {
@Override
public int hashCode() {
// TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java:
unchecked
{
int hash = 19;
hash = (hash * 397) ^ this.schemaId.hashCode();
for (TypeArgument a : this.args) {
hash = (hash * 397) ^ a.hashCode();
}
return hash;
int hash = 19;
hash = (hash * 397) ^ this.schemaId().hashCode();
for (TypeArgument a : this.args) {
hash = (hash * 397) ^ a.hashCode();
}
return hash;
}
public static boolean opEquals(TypeArgumentList left, TypeArgumentList right) {
return left.equals(right.clone());
return left.equals(right);
}
public static boolean opNotEquals(TypeArgumentList left, TypeArgumentList right) {
return !left.equals(right.clone());
return !left.equals(right);
}
@Override
public String toString() {
if (SchemaId.opNotEquals(this.schemaId.clone(),
getSchemaId().Invalid)) {
return String.format("<%1$s>", this.schemaId.toString());
if (this.schemaId.equals(SchemaId.INVALID)) {
return String.format("<%1$s>", this.schemaId().toString());
}
if (this.args == null || this.args == null ? null : this.args.length == 0) {

View File

@@ -28,7 +28,7 @@ public final class RecordIOFormatter {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: resizer = resizer != null ? resizer : DefaultSpanResizer<byte>.Default;
resizer = resizer != null ? resizer : DefaultSpanResizer < Byte >.Default;
int estimatedSize = HybridRowHeader.Size + RecordIOFormatter.RecordLayout.getSize() + body.Length;
int estimatedSize = HybridRowHeader.SIZE + RecordIOFormatter.RecordLayout.getSize() + body.Length;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint crc32 = Crc32.Update(0, body.Span);
int crc32 = Crc32.Update(0, body.Span);
@@ -50,7 +50,7 @@ public final class RecordIOFormatter {
//ORIGINAL LINE: resizer = resizer != null ? resizer : DefaultSpanResizer<byte>.Default;
resizer = resizer != null ? resizer : DefaultSpanResizer < Byte >.Default;
int estimatedSize =
HybridRowHeader.Size + RecordIOFormatter.SegmentLayout.getSize() + segment.Comment == null ? null :
HybridRowHeader.SIZE + RecordIOFormatter.SegmentLayout.getSize() + segment.Comment == null ? null :
segment.Comment.length() != null ? segment.Comment.length() : 0 + segment.SDL == null ? null :
segment.SDL.length() != null ? segment.SDL.length() : 0 + 20;

View File

@@ -71,7 +71,7 @@ public final class RecordIOParser {
this.state = State.NeedSegmentLength;
// TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java:
case NeedSegmentLength: {
int minimalSegmentRowSize = HybridRowHeader.Size + RecordIOFormatter.SegmentLayout.getSize();
int minimalSegmentRowSize = HybridRowHeader.SIZE + RecordIOFormatter.SegmentLayout.getSize();
if (b.Length < minimalSegmentRowSize) {
need.setAndGet(minimalSegmentRowSize);
consumed.setAndGet(buffer.Length - b.Length);
@@ -138,8 +138,8 @@ public final class RecordIOParser {
}
case NeedHeader: {
if (b.Length < HybridRowHeader.Size) {
need.setAndGet(HybridRowHeader.Size);
if (b.Length < HybridRowHeader.SIZE) {
need.setAndGet(HybridRowHeader.SIZE);
consumed.setAndGet(buffer.Length - b.Length);
return Result.InsufficientBuffer;
}
@@ -171,7 +171,7 @@ public final class RecordIOParser {
}
case NeedRecord: {
int minimalRecordRowSize = HybridRowHeader.Size + RecordIOFormatter.RecordLayout.getSize();
int minimalRecordRowSize = HybridRowHeader.SIZE + RecordIOFormatter.RecordLayout.getSize();
if (b.Length < minimalRecordRowSize) {
need.setAndGet(minimalRecordRowSize);
consumed.setAndGet(buffer.Length - b.Length);

View File

@@ -120,7 +120,7 @@ HashMap<SchemaId, Schema> ids
up:
ValidateAssert.Exists((up.Name, up.SchemaId), schemas, "Schema reference", "Namespace")
if (SchemaId.opNotEquals(up.SchemaId,
SchemaId.Invalid)) {
SchemaId.INVALID)) {
Schema s = ValidateAssert.Exists(up.SchemaId, ids, "Schema id", "Namespace");
ValidateAssert.AreEqual(up.Name, s.getName(), String.format("Schema name '%1$s' does not match " +
"the name of schema with id '%2$s': %3$s", up.Name, up.SchemaId, s.getName()));
@@ -154,7 +154,7 @@ HashMap<SchemaId, Schema> ids
// Enable id-less Schema references for all types with a unique version in the namespace.
for (Schema s : ns.getSchemas()) {
if (nameVersioningCheck.get(s.getName()).equals(1)) {
ValidateAssert.DuplicateCheck((s.getName(), SchemaId.Invalid), s, nameDupCheck, "Schema reference",
ValidateAssert.DuplicateCheck((s.getName(), SchemaId.INVALID), s, nameDupCheck, "Schema reference",
"Namespace")
}
}
@@ -269,7 +269,7 @@ private static void Visit(PropertyType p, PropertyType parent, HashMap<(String,
* @param label Diagnostic label describing <paramref name="id" />.
*/
public static void IsValidSchemaId(SchemaId id, String label) {
if (SchemaId.opEquals(id.clone(), SchemaId.Invalid)) {
if (SchemaId.opEquals(id.clone(), SchemaId.INVALID)) {
throw new SchemaException(String.format("%1$s cannot be 0", label));
}
}

View File

@@ -38,7 +38,7 @@ public class UdtPropertyType extends ScopePropertyType {
private com.azure.data.cosmos.serialization.hybridrow.SchemaId SchemaId = new SchemaId();
public UdtPropertyType() {
this.setSchemaId(com.azure.data.cosmos.serialization.hybridrow.SchemaId.Invalid);
this.setSchemaId(com.azure.data.cosmos.serialization.hybridrow.SchemaId.INVALID);
}
public final String getName() {

View File

@@ -74,18 +74,18 @@ public final class BsonRowGenerator implements Closeable {
private void DispatchArray(TypeArgument typeArg, Object value) {
checkArgument(typeArg.getTypeArgs().getCount() == 1);
checkArgument(typeArg.typeArgs().count() == 1);
this.writer.writeStartArray();
for (Object item : (ArrayList<Object>)value) {
this.LayoutCodeSwitch(null, typeArg.getTypeArgs().get(0).clone(), item);
this.LayoutCodeSwitch(null, typeArg.typeArgs().get(0).clone(), item);
}
this.writer.writeEndArray();
}
private void DispatchMap(TypeArgument typeArg, Object value) {
checkArgument(typeArg.getTypeArgs().getCount() == 2);
checkArgument(typeArg.typeArgs().count() == 2);
this.writer.writeStartArray();
for (Object item : (ArrayList<Object>)value) {
@@ -96,10 +96,10 @@ public final class BsonRowGenerator implements Closeable {
}
private void DispatchNullable(TypeArgument typeArg, Object value) {
checkArgument(typeArg.getTypeArgs().getCount() == 1);
checkArgument(typeArg.typeArgs().count() == 1);
if (value != null) {
this.LayoutCodeSwitch(null, typeArg.getTypeArgs().get(0).clone(), value);
this.LayoutCodeSwitch(null, typeArg.typeArgs().get(0).clone(), value);
} else {
this.writer.writeNull();
}
@@ -112,25 +112,25 @@ public final class BsonRowGenerator implements Closeable {
}
private void DispatchSet(TypeArgument typeArg, Object value) {
checkArgument(typeArg.getTypeArgs().getCount() == 1);
checkArgument(typeArg.typeArgs().count() == 1);
this.writer.WriteStartArray();
for (Object item : (ArrayList<Object>)value) {
this.LayoutCodeSwitch(null, typeArg.getTypeArgs().get(0).clone(), item);
this.LayoutCodeSwitch(null, typeArg.typeArgs().get(0).clone(), item);
}
this.writer.WriteEndArray();
}
private void DispatchTuple(TypeArgument typeArg, Object value) {
checkArgument(typeArg.getTypeArgs().getCount() >= 2);
checkArgument(typeArg.typeArgs().count() >= 2);
ArrayList<Object> items = (ArrayList<Object>)value;
checkArgument(items.size() == typeArg.getTypeArgs().getCount());
checkArgument(items.size() == typeArg.typeArgs().count());
this.writer.WriteStartArray();
for (int i = 0; i < items.size(); i++) {
Object item = items.get(i);
this.LayoutCodeSwitch(null, typeArg.getTypeArgs().get(i).clone(), item);
this.LayoutCodeSwitch(null, typeArg.typeArgs().get(i).clone(), item);
}
this.writer.WriteEndArray();
@@ -140,7 +140,7 @@ public final class BsonRowGenerator implements Closeable {
this.writer.WriteStartDocument();
HashMap<Utf8String, Object> dict = (HashMap<Utf8String, Object>)value;
Layout udt = this.resolver.Resolve(typeArg.getTypeArgs().getSchemaId().clone());
Layout udt = this.resolver.Resolve(typeArg.typeArgs().schemaId().clone());
for (LayoutColumn c : udt.columns()) {
this.LayoutCodeSwitch(c.getPath(), c.getTypeArg().clone(), dict.get(c.getPath()));
}
@@ -153,7 +153,7 @@ public final class BsonRowGenerator implements Closeable {
this.writer.WriteName(path);
}
switch (typeArg.getType().LayoutCode) {
switch (typeArg.type().LayoutCode) {
case Null:
this.writer.WriteNull();
return;

View File

@@ -73,13 +73,13 @@ public final class CodeGenRowGenerator {
}
public int getLength() {
return this.row.getLength();
return this.row.length();
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public Result ReadBuffer(byte[] buffer)
public Result ReadBuffer(byte[] buffer) {
this.row = new RowBuffer(buffer.AsSpan(), HybridRowVersion.V1, this.row.getResolver());
this.row = new RowBuffer(buffer.AsSpan(), HybridRowVersion.V1, this.row.resolver());
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(this.row);
RowCursor root = RowCursor.Create(tempReference_row);
@@ -95,8 +95,8 @@ public final class CodeGenRowGenerator {
}
public void Reset() {
Layout layout = this.row.getResolver().Resolve(this.row.getHeader().getSchemaId().clone());
this.row.InitLayout(HybridRowVersion.V1, layout, this.row.getResolver());
Layout layout = this.row.resolver().Resolve(this.row.header().getSchemaId().clone());
this.row.InitLayout(HybridRowVersion.V1, layout, this.row.resolver());
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
@@ -157,7 +157,7 @@ public final class CodeGenRowGenerator {
Out<StringToken> tempOut_postalCodeToken = new Out<StringToken>();
layout.getTokenizer().TryFindToken(this.postalCode.getPath(), tempOut_postalCodeToken);
this.postalCodeToken = tempOut_postalCodeToken.get();
this.postalCodeSerializer = new PostalCodeHybridRowSerializer(resolver.Resolve(this.postalCode.getTypeArgs().getSchemaId().clone()), resolver);
this.postalCodeSerializer = new PostalCodeHybridRowSerializer(resolver.Resolve(this.postalCode.getTypeArgs().schemaId().clone()), resolver);
}
@Override
@@ -353,7 +353,7 @@ public final class CodeGenRowGenerator {
this.addresses.getTypeArgs().clone()) });
this.addressSerializer =
new AddressHybridRowSerializer(resolver.Resolve(this.addresses.getTypeArgs().get(1).getTypeArgs().getSchemaId().clone()), resolver);
new AddressHybridRowSerializer(resolver.Resolve(this.addresses.getTypeArgs().get(1).typeArgs().schemaId().clone()), resolver);
this.addressSerializerWriter = (Reference<RowBuffer> b, Reference<RowCursor> scope,
HashMap<Utf8String, Object> context) -> addressSerializer.WriteBuffer(b,
scope, context);
@@ -363,7 +363,7 @@ public final class CodeGenRowGenerator {
public Result ReadBuffer(Reference<RowBuffer> row, Reference<RowCursor> root) {
java.util.UUID _;
Out<UUID> tempOut__ = new Out<UUID>();
Result r = LayoutType.Guid.ReadFixed(row, root, this.guestId, tempOut__);
Result r = LayoutType.Guid.readFixed(row, root, this.guestId, tempOut__);
_ = tempOut__.get();
if (r != Result.Success) {
return r;
@@ -550,7 +550,7 @@ public final class CodeGenRowGenerator {
//ORIGINAL LINE: case 0 when key.Equals(GuestsHybridRowSerializer.GuestIdName):
case 0
if (value != null) {
r = LayoutType.Guid.WriteFixed(row, root, this.guestId, (UUID)value);
r = LayoutType.Guid.writeFixed(row, root, this.guestId, (UUID)value);
if (r != Result.Success) {
return r;
}
@@ -796,7 +796,7 @@ public final class CodeGenRowGenerator {
layout.getTokenizer().TryFindToken(this.address.getPath(), tempOut_addressToken);
this.addressToken = tempOut_addressToken.get();
this.addressSerializer =
new AddressHybridRowSerializer(resolver.Resolve(this.address.getTypeArgs().getSchemaId().clone()),
new AddressHybridRowSerializer(resolver.Resolve(this.address.getTypeArgs().schemaId().clone()),
resolver);
}
@@ -974,7 +974,7 @@ public final class CodeGenRowGenerator {
public Result ReadBuffer(Reference<RowBuffer> row, Reference<RowCursor> root) {
int _;
Out<Integer> tempOut__ = new Out<Integer>();
Result r = LayoutType.Int32.ReadFixed(row, root, this.zip, tempOut__);
Result r = LayoutType.Int32.readFixed(row, root, this.zip, tempOut__);
_ = tempOut__.get();
if (r != Result.Success) {
return r;
@@ -983,7 +983,7 @@ public final class CodeGenRowGenerator {
root.get().Find(row, this.plus4Token.clone());
short _;
Out<Short> tempOut__2 = new Out<Short>();
Result tempVar = LayoutType.Int16.ReadSparse(row, root, tempOut__2);
Result tempVar = LayoutType.Int16.readSparse(row, root, tempOut__2);
_ = tempOut__2.get();
return tempVar;
}
@@ -1083,7 +1083,7 @@ public final class CodeGenRowGenerator {
Out<Byte> tempOut__2 = new Out<Byte>();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: r = LayoutType.UInt8.ReadFixed(ref row, ref root, this.roomNumber, out byte _);
r = LayoutType.UInt8.ReadFixed(row, root, this.roomNumber, tempOut__2);
r = LayoutType.UInt8.readFixed(row, root, this.roomNumber, tempOut__2);
_ = tempOut__2.get();
if (r != Result.Success) {
return r;
@@ -1091,7 +1091,7 @@ public final class CodeGenRowGenerator {
boolean _;
Out<Boolean> tempOut__3 = new Out<Boolean>();
Result tempVar = LayoutType.Boolean.ReadFixed(row, root, this.isAvailable, tempOut__3);
Result tempVar = LayoutType.Boolean.readFixed(row, root, this.isAvailable, tempOut__3);
_ = tempOut__3.get();
return tempVar;
}

View File

@@ -4,7 +4,6 @@
package com.azure.data.cosmos.serialization.hybridrow.perf;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.ISpanResizer;
@@ -49,7 +48,7 @@ public final class JsonModelRowGenerator {
}
public int getLength() {
return this.row.getLength();
return this.row.length();
}
public RowReader GetReader() {
@@ -63,12 +62,12 @@ public final class JsonModelRowGenerator {
// TODO: C# TO JAVA CONVERTER: C# to Java Converter cannot determine whether this System.IO.Stream is input or
// output:
public boolean ReadFrom(InputStream stream, int length) {
return this.row.ReadFrom(stream, length, HybridRowVersion.V1, this.row.getResolver());
return this.row.ReadFrom(stream, length, HybridRowVersion.V1, this.row.resolver());
}
public void Reset() {
Layout layout = this.row.getResolver().Resolve(this.row.getHeader().getSchemaId().clone());
this.row.InitLayout(HybridRowVersion.V1, layout, this.row.getResolver());
Layout layout = this.row.resolver().Resolve(this.row.header().getSchemaId().clone());
this.row.InitLayout(HybridRowVersion.V1, layout, this.row.resolver());
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:

View File

@@ -4,11 +4,10 @@
package com.azure.data.cosmos.serialization.hybridrow.perf;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTagged2Scope;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TAGGED2_SCOPE;
public final class RowReaderExtensions {
public static Result VisitReader(Reference<RowReader> reader) {
@@ -68,7 +67,7 @@ public final class RowReaderExtensions {
case TaggedScope:
case ImmutableTaggedScope:
case Tagged2Scope:
case ImmutableTagged2Scope: {
case IMMUTABLE_TAGGED2_SCOPE: {
// TODO: C# TO JAVA CONVERTER: The following lambda contained an unresolved 'ref' keyword - these are not converted by C# to Java Converter:
Result r = reader.get().ReadScope(null, (ref RowReader child, Object _) -> child.VisitReader());
if (r != Result.Success) {

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
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 com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutIndexedScope;
@@ -31,21 +30,21 @@ public final class DeleteRowDispatcher implements IDispatcher {
public <TLayout extends LayoutType<TValue>, TValue> void Dispatch(Reference<RowOperationDispatcher> dispatcher, Reference<RowCursor> root, LayoutColumn col, LayoutType t, TValue value) {
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<TLayout>TypeAs().DeleteSparse(tempReference_Row, root));
ResultAssert.IsSuccess(t.<TLayout>typeAs().deleteSparse(tempReference_Row, root));
dispatcher.get().argValue.Row = tempReference_Row.get();
}
public void DispatchArray(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 1);
checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor arrayScope;
Out<RowCursor> tempOut_arrayScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutTypedArray>TypeAs().ReadScope(tempReference_Row, scope, tempOut_arrayScope));
ResultAssert.IsSuccess(t.<LayoutTypedArray>typeAs().ReadScope(tempReference_Row, scope, tempOut_arrayScope));
arrayScope = tempOut_arrayScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
@@ -59,28 +58,28 @@ public final class DeleteRowDispatcher implements IDispatcher {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword -
// these cannot be converted using the 'Ref' helper class unless the method is within the code
// being modified:
dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).getType(),
typeArgs.get(0).getTypeArgs().clone(), item);
dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).type(),
typeArgs.get(0).typeArgs().clone(), item);
}
}
Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<LayoutTypedArray>TypeAs().DeleteScope(tempReference_Row3, scope));
ResultAssert.IsSuccess(t.<LayoutTypedArray>typeAs().DeleteScope(tempReference_Row3, scope));
dispatcher.get().argValue.Row = tempReference_Row3.get();
}
public void DispatchMap(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 2);
checkArgument(typeArgs.count() == 2);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor mapScope;
Out<RowCursor> tempOut_mapScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutTypedMap>TypeAs().ReadScope(tempReference_Row, scope, tempOut_mapScope));
ResultAssert.IsSuccess(t.<LayoutTypedMap>typeAs().ReadScope(tempReference_Row, scope, tempOut_mapScope));
mapScope = tempOut_mapScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
if (!mapScope.Immutable) {
@@ -99,17 +98,17 @@ public final class DeleteRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<LayoutTypedMap>TypeAs().DeleteScope(tempReference_Row3, scope));
ResultAssert.IsSuccess(t.<LayoutTypedMap>typeAs().DeleteScope(tempReference_Row3, scope));
dispatcher.get().argValue.Row = tempReference_Row3.get();
}
public void DispatchNullable(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 1);
checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<LayoutNullable>TypeAs().DeleteScope(tempReference_Row, scope));
ResultAssert.IsSuccess(t.<LayoutNullable>typeAs().DeleteScope(tempReference_Row, scope));
dispatcher.get().argValue.Row = tempReference_Row.get();
}
@@ -120,14 +119,14 @@ public final class DeleteRowDispatcher implements IDispatcher {
public void DispatchSet(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 1);
checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor setScope;
Out<RowCursor> tempOut_setScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutTypedSet>TypeAs().ReadScope(tempReference_Row, scope, tempOut_setScope));
ResultAssert.IsSuccess(t.<LayoutTypedSet>typeAs().ReadScope(tempReference_Row, scope, tempOut_setScope));
setScope = tempOut_setScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
if (!setScope.Immutable) {
@@ -140,30 +139,30 @@ public final class DeleteRowDispatcher implements IDispatcher {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword -
// these cannot be converted using the 'Ref' helper class unless the method is within the code
// being modified:
dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).getType(),
typeArgs.get(0).getTypeArgs().clone(), item);
dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).type(),
typeArgs.get(0).typeArgs().clone(), item);
}
}
Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<LayoutTypedSet>TypeAs().DeleteScope(tempReference_Row3, scope));
ResultAssert.IsSuccess(t.<LayoutTypedSet>typeAs().DeleteScope(tempReference_Row3, scope));
dispatcher.get().argValue.Row = tempReference_Row3.get();
}
public void DispatchTuple(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() >= 2);
checkArgument(typeArgs.count() >= 2);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<LayoutIndexedScope>TypeAs().DeleteScope(tempReference_Row, scope));
ResultAssert.IsSuccess(t.<LayoutIndexedScope>typeAs().DeleteScope(tempReference_Row, scope));
dispatcher.get().argValue.Row = tempReference_Row.get();
}
public void DispatchUDT(Reference<RowOperationDispatcher> dispatcher, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Object value) {
Reference<RowBuffer> tempReference_Row = new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<LayoutUDT>TypeAs().DeleteScope(tempReference_Row, scope));
ResultAssert.IsSuccess(t.<LayoutUDT>typeAs().DeleteScope(tempReference_Row, scope));
dispatcher.get().argValue.Row = tempReference_Row.get();
}
}

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Float128;
import com.azure.data.cosmos.serialization.hybridrow.NullValue;
import com.azure.data.cosmos.serialization.hybridrow.Result;
@@ -1779,7 +1778,7 @@ private final static class RoundTripSparseArray extends TestActionDispatcher<Rou
field = tempReference_field2.get();
ResultAssert.IsSuccess(r, tag);
Assert.AreEqual(scope.ScopeType, scope2.ScopeType, tag);
Assert.AreEqual(scope.start, scope2.start, tag);
Assert.AreEqual(scope.start(), scope2.start(), tag);
Assert.AreEqual(scope.Immutable, scope2.Immutable, tag);
// Read the nested fields
@@ -1860,7 +1859,7 @@ private final static class RoundTripSparseArray extends TestActionDispatcher<Rou
// Overwrite the whole scope.
Reference<RowCursor> tempReference_field3 =
new Reference<RowCursor>(field);
r = LayoutType.Null.WriteSparse(row, tempReference_field3, NullValue.Default);
r = LayoutType.Null.writeSparse(row, tempReference_field3, NullValue.Default);
field = tempReference_field3.get();
ResultAssert.IsSuccess(r, tag);
Reference<RowCursor> tempReference_field4 =
@@ -2010,7 +2009,7 @@ private final static class RoundTripSparseObject extends TestActionDispatcher<Ro
field = tempReference_field3.get();
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
Assert.AreEqual(scope.ScopeType, scope2.ScopeType, "Json: {0}", expected.Json);
Assert.AreEqual(scope.start, scope2.start, "Json: {0}", expected.Json);
Assert.AreEqual(scope.start(), scope2.start(), "Json: {0}", expected.Json);
Assert.AreEqual(scope.Immutable, scope2.Immutable, "Json: {0}", expected.Json);
// Read the nested field
@@ -2051,7 +2050,7 @@ private final static class RoundTripSparseObject extends TestActionDispatcher<Ro
// Overwrite the whole scope.
Reference<RowCursor> tempReference_field4 =
new Reference<RowCursor>(field);
r = LayoutType.Null.WriteSparse(row, tempReference_field4, NullValue.Default);
r = LayoutType.Null.writeSparse(row, tempReference_field4, NullValue.Default);
field = tempReference_field4.get();
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
Reference<RowCursor> tempReference_field5 =
@@ -2189,7 +2188,7 @@ private final static class RoundTripSparseObjectMulti extends TestActionDispatch
} else {
Reference<RowCursor> tempReference_nestedField2 =
new Reference<RowCursor>(nestedField);
r = LayoutType.Null.WriteSparse(row, tempReference_nestedField2, NullValue.Default);
r = LayoutType.Null.writeSparse(row, tempReference_nestedField2, NullValue.Default);
nestedField = tempReference_nestedField2.get();
ResultAssert.IsSuccess(r, tag);
}
@@ -2257,12 +2256,12 @@ private final static class RoundTripSparseObjectMulti extends TestActionDispatch
RowCursor _;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
Assert.AreEqual(scope2.AsReadOnly(out _).start, scope3.start, tag);
Assert.AreEqual(scope2.AsReadOnly(out _).start, scope3.start(), tag);
// Overwrite the nested field.
Reference<RowCursor> tempReference_nestedField4 =
new Reference<RowCursor>(nestedField);
r = LayoutType.Null.WriteSparse(row, tempReference_nestedField4, NullValue.Default);
r = LayoutType.Null.writeSparse(row, tempReference_nestedField4, NullValue.Default);
nestedField = tempReference_nestedField4.get();
ResultAssert.IsSuccess(r, tag);
@@ -2383,7 +2382,7 @@ private final static class RoundTripSparseObjectNested extends TestActionDispatc
} else {
Reference<RowCursor> tempReference_field2 =
new Reference<RowCursor>(field);
r = LayoutType.Null.WriteSparse(row, tempReference_field2, NullValue.Default);
r = LayoutType.Null.writeSparse(row, tempReference_field2, NullValue.Default);
field = tempReference_field2.get();
ResultAssert.IsSuccess(r, tag);
}
@@ -2519,7 +2518,7 @@ private final static class RoundTripSparseOrdering extends TestActionDispatcher<
} else {
Reference<RowCursor> tempReference_field2 =
new Reference<RowCursor>(field);
r = LayoutType.Null.WriteSparse(row, tempReference_field2, NullValue.Default);
r = LayoutType.Null.writeSparse(row, tempReference_field2, NullValue.Default);
field = tempReference_field2.get();
ResultAssert.IsSuccess(r, "Json: {0}", json);
Out<TValue> tempOut_value3 = new Out<TValue>();
@@ -2681,7 +2680,7 @@ private final static class RoundTripSparseSet extends TestActionDispatcher<Round
field = tempReference_field2.get();
ResultAssert.IsSuccess(r, tag);
Assert.AreEqual(scope.ScopeType, scope2.ScopeType, tag);
Assert.AreEqual(scope.start, scope2.start, tag);
Assert.AreEqual(scope.start(), scope2.start(), tag);
Assert.AreEqual(scope.Immutable, scope2.Immutable, tag);
// Read the nested fields
@@ -2837,7 +2836,7 @@ private final static class RoundTripSparseSet extends TestActionDispatcher<Round
// Overwrite the whole scope.
Reference<RowCursor> tempReference_field9 = new Reference<RowCursor>(field);
r = LayoutType.Null.WriteSparse(row, tempReference_field9, NullValue.Default);
r = LayoutType.Null.writeSparse(row, tempReference_field9, NullValue.Default);
field = tempReference_field9.get();
ResultAssert.IsSuccess(r, tag);
Reference<RowCursor> tempReference_field10 = new Reference<RowCursor>(field);
@@ -2984,7 +2983,7 @@ private final static class RoundTripSparseSimple extends TestActionDispatcher<Ro
} else {
Reference<RowCursor> tempReference_field2 =
new Reference<RowCursor>(field);
r = LayoutType.Null.WriteSparse(row, tempReference_field2, NullValue.Default);
r = LayoutType.Null.writeSparse(row, tempReference_field2, NullValue.Default);
field = tempReference_field2.get();
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
@@ -3071,7 +3070,7 @@ private static class RoundTripVariable extends TestActionDispatcher<RoundTripVar
TLayout t = (TLayout)col.getType();
TValue value;
Out<TValue> tempOut_value = new Out<TValue>();
Result r = t.ReadVariable(row, root, col, tempOut_value);
Result r = t.readVariable(row, root, col, tempOut_value);
value = tempOut_value.get();
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
boolean tempVar = exValue instanceof Array;
@@ -3086,7 +3085,7 @@ private static class RoundTripVariable extends TestActionDispatcher<RoundTripVar
protected final <TLayout extends LayoutType<TValue>, TValue> void RoundTrip(Reference<RowBuffer> row,
Reference<RowCursor> root, LayoutColumn col, Object exValue, Expected expected) {
TLayout t = (TLayout)col.getType();
Result r = t.WriteVariable(row, root, col, (TValue)exValue);
Result r = t.writeVariable(row, root, col, (TValue)exValue);
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
this.<TLayout, TValue>Compare(row, root, col, exValue, expected.clone());
@@ -3096,7 +3095,7 @@ private static class RoundTripVariable extends TestActionDispatcher<RoundTripVar
root.get().AsReadOnly(out roRoot);
Reference<RowCursor> tempReference_roRoot =
new Reference<RowCursor>(roRoot);
ResultAssert.InsufficientPermissions(t.WriteVariable(row, tempReference_roRoot, col, (TValue)expected.Value));
ResultAssert.InsufficientPermissions(t.writeVariable(row, tempReference_roRoot, col, (TValue)expected.Value));
roRoot = tempReference_roRoot.get();
}
@@ -3169,16 +3168,16 @@ private final static class VariableInterleaving extends RoundTripVariable {
this.<TLayout, TValue>RoundTrip(row, root, c, expected.Value, expected.clone());
// Make the var column shorter.
int rowSizeBeforeShrink = row.get().getLength();
int rowSizeBeforeShrink = row.get().length();
this.<TLayout, TValue>RoundTrip(row, root, a, expected.Short, expected.clone());
this.<TLayout, TValue>Compare(row, root, c, expected.Value, expected.clone());
int rowSizeAfterShrink = row.get().getLength();
int rowSizeAfterShrink = row.get().length();
Assert.IsTrue(rowSizeAfterShrink < rowSizeBeforeShrink, "Json: {0}", expected.Json);
// Make the var column longer.
this.<TLayout, TValue>RoundTrip(row, root, a, expected.Long, expected.clone());
this.<TLayout, TValue>Compare(row, root, c, expected.Value, expected.clone());
int rowSizeAfterGrow = row.get().getLength();
int rowSizeAfterGrow = row.get().length();
Assert.IsTrue(rowSizeAfterGrow > rowSizeAfterShrink, "Json: {0}", expected.Json);
Assert.IsTrue(rowSizeAfterGrow > rowSizeBeforeShrink, "Json: {0}", expected.Json);
@@ -3202,13 +3201,13 @@ private final static class VariableInterleaving extends RoundTripVariable {
root.get().AsReadOnly(out roRoot);
Reference<RowCursor> tempReference_roRoot =
new Reference<RowCursor>(roRoot);
ResultAssert.InsufficientPermissions(t.DeleteVariable(row, tempReference_roRoot, col));
ResultAssert.InsufficientPermissions(t.deleteVariable(row, tempReference_roRoot, col));
roRoot = tempReference_roRoot.get();
Result r = t.DeleteVariable(row, root, col);
Result r = t.deleteVariable(row, root, col);
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
TValue _;
Out<TValue> tempOut__ = new Out<TValue>();
r = t.ReadVariable(row, root, col, tempOut__);
r = t.readVariable(row, root, col, tempOut__);
_ = tempOut__.get();
ResultAssert.NotFound(r, "Json: {0}", expected.Json);
}
@@ -3216,7 +3215,7 @@ private final static class VariableInterleaving extends RoundTripVariable {
private <TLayout extends LayoutType<TValue>, TValue> void TooBig(Reference<RowBuffer> row,
Reference<RowCursor> root, LayoutColumn col, Expected expected) {
TLayout t = (TLayout)col.getType();
Result r = t.WriteVariable(row, root, col, (TValue)expected.TooBig);
Result r = t.writeVariable(row, root, col, (TValue)expected.TooBig);
Assert.AreEqual(Result.TooBig, r, "Json: {0}", expected.Json);
}
@@ -3231,7 +3230,7 @@ private final static class VariableInterleaving extends RoundTripVariable {
TLayout t = (TLayout)col.Type;
TValue _;
Out<TValue> tempOut__ = new Out<TValue>();
Result r = t.ReadVariable(row, root, col, tempOut__);
Result r = t.readVariable(row, root, col, tempOut__);
_ = tempOut__.get();
ResultAssert.NotFound(r, "Json: {0}", expected.Json);
return col;

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
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 com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType;
@@ -35,7 +34,7 @@ public final class ReadRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
Out<TValue> tempOut_value = new Out<TValue>();
ResultAssert.IsSuccess(t.<TLayout>TypeAs().ReadFixed(tempReference_Row, root, col, tempOut_value));
ResultAssert.IsSuccess(t.<TLayout>typeAs().readFixed(tempReference_Row, root, col, tempOut_value));
value = tempOut_value.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
break;
@@ -43,7 +42,7 @@ public final class ReadRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row);
Out<TValue> tempOut_value2 = new Out<TValue>();
ResultAssert.IsSuccess(t.<TLayout>TypeAs().ReadVariable(tempReference_Row2, root, col, tempOut_value2));
ResultAssert.IsSuccess(t.<TLayout>typeAs().readVariable(tempReference_Row2, root, col, tempOut_value2));
value = tempOut_value2.get();
dispatcher.get().argValue.Row = tempReference_Row2.get();
break;
@@ -51,7 +50,7 @@ public final class ReadRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row);
Out<TValue> tempOut_value3 = new Out<TValue>();
ResultAssert.IsSuccess(t.<TLayout>TypeAs().ReadSparse(tempReference_Row3, root, tempOut_value3));
ResultAssert.IsSuccess(t.<TLayout>typeAs().readSparse(tempReference_Row3, root, tempOut_value3));
value = tempOut_value3.get();
dispatcher.get().argValue.Row = tempReference_Row3.get();
break;
@@ -67,14 +66,14 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchArray(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 1);
checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor arrayScope;
Out<RowCursor> tempOut_arrayScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutTypedArray>TypeAs().ReadScope(tempReference_Row, scope, tempOut_arrayScope));
ResultAssert.IsSuccess(t.<LayoutTypedArray>typeAs().ReadScope(tempReference_Row, scope, tempOut_arrayScope));
arrayScope = tempOut_arrayScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
@@ -87,8 +86,8 @@ public final class ReadRowDispatcher implements IDispatcher {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these
// cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified:
dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).getType(),
typeArgs.get(0).getTypeArgs().clone(), items.get(i++));
dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).type(),
typeArgs.get(0).typeArgs().clone(), items.get(i++));
}
dispatcher.get().argValue.Row = tempReference_Row2.get();
}
@@ -96,14 +95,14 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchMap(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 2);
checkArgument(typeArgs.count() == 2);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor mapScope;
Out<RowCursor> tempOut_mapScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutTypedMap>TypeAs().ReadScope(tempReference_Row, scope, tempOut_mapScope));
ResultAssert.IsSuccess(t.<LayoutTypedMap>typeAs().ReadScope(tempReference_Row, scope, tempOut_mapScope));
mapScope = tempOut_mapScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
int i = 0;
@@ -124,14 +123,14 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchNullable(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 1);
checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor nullableScope;
Out<RowCursor> tempOut_nullableScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutNullable>TypeAs().ReadScope(tempReference_Row, scope, tempOut_nullableScope));
ResultAssert.IsSuccess(t.<LayoutNullable>typeAs().ReadScope(tempReference_Row, scope, tempOut_nullableScope));
nullableScope = tempOut_nullableScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
@@ -150,8 +149,8 @@ public final class ReadRowDispatcher implements IDispatcher {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these
// cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified:
dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).getType(),
typeArgs.get(0).getTypeArgs().clone(), value);
dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).type(),
typeArgs.get(0).typeArgs().clone(), value);
} else {
Reference<RowBuffer> tempReference_Row4 =
new Reference<RowBuffer>(dispatcher.get().Row);
@@ -170,14 +169,14 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchSet(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 1);
checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor setScope;
Out<RowCursor> tempOut_setScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutTypedSet>TypeAs().ReadScope(tempReference_Row, scope, tempOut_setScope));
ResultAssert.IsSuccess(t.<LayoutTypedSet>typeAs().ReadScope(tempReference_Row, scope, tempOut_setScope));
setScope = tempOut_setScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
int i = 0;
@@ -189,8 +188,8 @@ public final class ReadRowDispatcher implements IDispatcher {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these
// cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified:
dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).getType(),
typeArgs.get(0).getTypeArgs().clone(), items.get(i++));
dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).type(),
typeArgs.get(0).typeArgs().clone(), items.get(i++));
}
dispatcher.get().argValue.Row = tempReference_Row2.get();
}
@@ -198,18 +197,18 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchTuple(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() >= 2);
checkArgument(typeArgs.count() >= 2);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor tupleScope;
Out<RowCursor> tempOut_tupleScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutIndexedScope>TypeAs().ReadScope(tempReference_Row, scope, tempOut_tupleScope));
ResultAssert.IsSuccess(t.<LayoutIndexedScope>typeAs().ReadScope(tempReference_Row, scope, tempOut_tupleScope));
tupleScope = tempOut_tupleScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
for (int i = 0; i < typeArgs.getCount(); i++) {
for (int i = 0; i < typeArgs.count(); i++) {
Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row);
tupleScope.MoveNext(tempReference_Row2);
@@ -218,8 +217,8 @@ public final class ReadRowDispatcher implements IDispatcher {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these
// cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified:
dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).getType(),
typeArgs.get(i).getTypeArgs().clone(), valueAccessor.GetValue(value));
dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).type(),
typeArgs.get(i).typeArgs().clone(), valueAccessor.GetValue(value));
}
}
@@ -229,7 +228,7 @@ public final class ReadRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row = new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor udtScope;
Out<RowCursor> tempOut_udtScope = new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutUDT>TypeAs().ReadScope(tempReference_Row, scope, tempOut_udtScope));
ResultAssert.IsSuccess(t.<LayoutUDT>typeAs().ReadScope(tempReference_Row, scope, tempOut_udtScope));
udtScope = tempOut_udtScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
IDispatchable valueDispatcher = value instanceof IDispatchable ? (IDispatchable)value : null;

View File

@@ -237,7 +237,7 @@ public class RecordIOUnitTests {
return r;
}
buffer.setAndGet(resizer.getMemory().Slice(0, row.getLength()));
buffer.setAndGet(resizer.getMemory().Slice(0, row.length()));
return Result.Success;
}
}

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Float128;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.MemorySpanResizer;
@@ -182,7 +181,7 @@ public final class RowReaderUnitTests {
Tuple.Create(3.0, new Point(5, 6)) })
RowReader reader = d.GetReader().clone();
assert reader.getLength() == d.Row.getLength();
assert reader.getLength() == d.Row.length();
Reference<RowReader> tempReference_reader =
new Reference<RowReader>(reader);
RowReaderUnitTests.PrintReader(tempReference_reader, 0);

View File

@@ -17,10 +17,10 @@ public class SchemaIdUnitTests {
SchemaId b = new SchemaId(2);
SchemaId c = new SchemaId();
assert 1 == a.getId();
assert 2 == b.getId();
assert SchemaId.Invalid == c.clone();
assert 2 != a.getId();
assert 1 == a.id();
assert 2 == b.id();
assert SchemaId.INVALID == c.clone();
assert 2 != a.id();
assert a.clone() != b.clone();
assert SchemaId.opEquals(a.clone(), a.clone());
assert SchemaId.opNotEquals(a.clone(), b.clone());

View File

@@ -72,7 +72,7 @@ public final class SerializerUnitTest {
Result r = RowWriter.WriteBuffer(tempReference_row, request, BatchRequestSerializer.Write);
row = tempReference_row.get();
assert Result.Success == r;
System.out.printf("Length of serialized row: %1$s" + "\r\n", row.getLength());
System.out.printf("Length of serialized row: %1$s" + "\r\n", row.length());
// Read the row back again.
Reference<RowBuffer> tempReference_row2 =

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
@@ -344,7 +343,7 @@ public final class TupleUnitTests {
RowCursor _;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
assert valueScope.AsReadOnly(out _).start == valueScope2.start;
assert valueScope.AsReadOnly(out _).start == valueScope2.start();
RowCursor _;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
@@ -878,7 +877,7 @@ public final class TupleUnitTests {
}
private static void WriteCoord(Reference<RowBuffer> row, Reference<RowCursor> coordScope, TypeArgumentList typeArgs, Coord cd) {
Layout coordLayout = row.get().getResolver().Resolve(typeArgs.getSchemaId().clone());
Layout coordLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone());
LayoutColumn c;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
assert coordLayout.TryFind("lat", out c);

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
@@ -333,7 +332,7 @@ public final class TypedArrayUnitTests {
private static void WriteSimilarMatch(Reference<RowBuffer> row, Reference<RowCursor> matchScope
, TypeArgumentList typeArgs, SimilarMatch m) {
Layout matchLayout = row.get().getResolver().Resolve(typeArgs.getSchemaId().clone());
Layout matchLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone());
LayoutColumn c;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:

View File

@@ -1179,7 +1179,7 @@ public final class TypedMapUnitTests {
}
private static void WriteEarnings(Reference<RowBuffer> row, Reference<RowCursor> udtScope, TypeArgumentList typeArgs, Earnings m) {
Layout udt = row.get().getResolver().Resolve(typeArgs.getSchemaId().clone());
Layout udt = row.get().resolver().Resolve(typeArgs.getSchemaId().clone());
LayoutColumn c;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
assert udt.TryFind("domestic", out c);
@@ -1338,7 +1338,7 @@ public final class TypedMapUnitTests {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword -
// these cannot be converted using the 'Ref' helper class unless the method is within the code
// being modified:
ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().<LayoutUtf8>TypeAs().WriteSparse(row,
ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().<LayoutUtf8>typeAs().WriteSparse(row,
ref tupleScope, item.Key));
assert tupleScope.MoveNext(row);
TypeArgument valueType = c.getTypeArgs().get(1).clone();
@@ -1421,7 +1421,7 @@ public final class TypedMapUnitTests {
out tupleScope));
Reference<RowCursor> tempReference_tupleScope =
new Reference<RowCursor>(tupleScope);
ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().<LayoutDateTime>TypeAs().WriteSparse(row,
ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().<LayoutDateTime>typeAs().WriteSparse(row,
tempReference_tupleScope, item.Key));
tupleScope = tempReference_tupleScope.get();
assert tupleScope.MoveNext(row);

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
@@ -1467,7 +1466,7 @@ public final class TypedSetUnitTests {
}
private static void WriteShoppingItem(Reference<RowBuffer> row, Reference<RowCursor> matchScope, TypeArgumentList typeArgs, ShoppingItem m) {
Layout matchLayout = row.get().getResolver().Resolve(typeArgs.getSchemaId().clone());
Layout matchLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone());
LayoutColumn c;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
assert matchLayout.TryFind("label", out c);
@@ -1507,7 +1506,7 @@ public final class TypedSetUnitTests {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword -
// these cannot be converted using the 'Ref' helper class unless the method is within the code
// being modified:
ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().<LayoutUtf8>TypeAs().WriteSparse(row,
ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().<LayoutUtf8>typeAs().WriteSparse(row,
ref tempCursor, item));
Reference<RowCursor> tempReference_attendScope =
new Reference<RowCursor>(attendScope);
@@ -1546,7 +1545,7 @@ public final class TypedSetUnitTests {
root.get().Clone(out tempCursor).Find(row, Utf8String.Empty);
Reference<RowCursor> tempReference_tempCursor2 =
new Reference<RowCursor>(tempCursor);
ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().<LayoutGuid>TypeAs().WriteSparse(row,
ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().<LayoutGuid>typeAs().WriteSparse(row,
tempReference_tempCursor2, item));
tempCursor = tempReference_tempCursor2.get();
Reference<RowCursor> tempReference_projScope =
@@ -1586,7 +1585,7 @@ public final class TypedSetUnitTests {
root.get().Clone(out tempCursor).Find(row, Utf8String.Empty);
Reference<RowCursor> tempReference_tempCursor4 =
new Reference<RowCursor>(tempCursor);
ResultAssert.IsSuccess(c.getTypeArgs().get(0).getType().<LayoutBoolean>TypeAs().WriteSparse(row,
ResultAssert.IsSuccess(c.getTypeArgs().get(0).type().<LayoutBoolean>typeAs().WriteSparse(row,
tempReference_tempCursor4, item));
tempCursor = tempReference_tempCursor4.get();
Reference<RowCursor> tempReference_checkboxScope =

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
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 com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType;
@@ -33,19 +32,19 @@ public final class WriteRowDispatcher implements IDispatcher {
case Fixed:
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<TLayout>TypeAs().WriteFixed(tempReference_Row, field, col, value));
ResultAssert.IsSuccess(t.<TLayout>typeAs().writeFixed(tempReference_Row, field, col, value));
dispatcher.get().argValue.Row = tempReference_Row.get();
break;
case Variable:
Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<TLayout>TypeAs().WriteVariable(tempReference_Row2, field, col, value));
ResultAssert.IsSuccess(t.<TLayout>typeAs().writeVariable(tempReference_Row2, field, col, value));
dispatcher.get().argValue.Row = tempReference_Row2.get();
break;
default:
Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row);
ResultAssert.IsSuccess(t.<TLayout>TypeAs().WriteSparse(tempReference_Row3, field, value));
ResultAssert.IsSuccess(t.<TLayout>typeAs().writeSparse(tempReference_Row3, field, value));
dispatcher.get().argValue.Row = tempReference_Row3.get();
break;
}
@@ -54,14 +53,14 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchArray(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 1);
checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor arrayScope;
Out<RowCursor> tempOut_arrayScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutTypedArray>TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
ResultAssert.IsSuccess(t.<LayoutTypedArray>typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
tempOut_arrayScope));
arrayScope = tempOut_arrayScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
@@ -71,8 +70,8 @@ public final class WriteRowDispatcher implements IDispatcher {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these
// cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified:
dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).getType(),
typeArgs.get(0).getTypeArgs().clone(), item);
dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).type(),
typeArgs.get(0).typeArgs().clone(), item);
Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row);
arrayScope.MoveNext(tempReference_Row2);
@@ -83,20 +82,20 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchMap(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 2);
checkArgument(typeArgs.count() == 2);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor mapScope;
Out<RowCursor> tempOut_mapScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutTypedMap>TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
ResultAssert.IsSuccess(t.<LayoutTypedMap>typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
tempOut_mapScope));
mapScope = tempOut_mapScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
Reference<RowCursor> tempReference_mapScope =
new Reference<RowCursor>(mapScope);
TypeArgument fieldType = t.<LayoutUniqueScope>TypeAs().FieldType(tempReference_mapScope).clone();
TypeArgument fieldType = t.<LayoutUniqueScope>typeAs().FieldType(tempReference_mapScope).clone();
mapScope = tempReference_mapScope.get();
List pairs = (List)value;
for (Object pair : pairs) {
@@ -122,7 +121,7 @@ public final class WriteRowDispatcher implements IDispatcher {
new Reference<RowCursor>(mapScope);
Reference<RowCursor> tempReference_tempCursor =
new Reference<RowCursor>(tempCursor);
ResultAssert.IsSuccess(t.<LayoutTypedMap>TypeAs().MoveField(tempReference_Row3, tempReference_mapScope2,
ResultAssert.IsSuccess(t.<LayoutTypedMap>typeAs().MoveField(tempReference_Row3, tempReference_mapScope2,
tempReference_tempCursor));
tempCursor = tempReference_tempCursor.get();
mapScope = tempReference_mapScope2.get();
@@ -133,14 +132,14 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchNullable(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 1);
checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor nullableScope;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
ResultAssert.IsSuccess(t.<LayoutNullable>TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
ResultAssert.IsSuccess(t.<LayoutNullable>typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
value != null, out nullableScope));
dispatcher.get().argValue.Row = tempReference_Row.get();
@@ -148,8 +147,8 @@ public final class WriteRowDispatcher implements IDispatcher {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these
// cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified:
dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).getType(),
typeArgs.get(0).getTypeArgs().clone(), value);
dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).type(),
typeArgs.get(0).typeArgs().clone(), value);
}
}
@@ -160,14 +159,14 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchSet(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() == 1);
checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor setScope;
Out<RowCursor> tempOut_setScope =
new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutTypedSet>TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
ResultAssert.IsSuccess(t.<LayoutTypedSet>typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
tempOut_setScope));
setScope = tempOut_setScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
@@ -185,8 +184,8 @@ public final class WriteRowDispatcher implements IDispatcher {
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these
// cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified:
dispatcher.get().LayoutCodeSwitch(ref tempCursor, elmPath, typeArgs.get(0).getType(),
typeArgs.get(0).getTypeArgs().clone(), item);
dispatcher.get().LayoutCodeSwitch(ref tempCursor, elmPath, typeArgs.get(0).type(),
typeArgs.get(0).typeArgs().clone(), item);
// Move item into the set.
Reference<RowBuffer> tempReference_Row3 =
@@ -195,7 +194,7 @@ public final class WriteRowDispatcher implements IDispatcher {
new Reference<RowCursor>(setScope);
Reference<RowCursor> tempReference_tempCursor =
new Reference<RowCursor>(tempCursor);
ResultAssert.IsSuccess(t.<LayoutTypedSet>TypeAs().MoveField(tempReference_Row3, tempReference_setScope,
ResultAssert.IsSuccess(t.<LayoutTypedSet>typeAs().MoveField(tempReference_Row3, tempReference_setScope,
tempReference_tempCursor));
tempCursor = tempReference_tempCursor.get();
setScope = tempReference_setScope.get();
@@ -206,24 +205,24 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchTuple(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) {
checkArgument(typeArgs.getCount() >= 2);
checkArgument(typeArgs.count() >= 2);
Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor tupleScope;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
ResultAssert.IsSuccess(t.<LayoutIndexedScope>TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
ResultAssert.IsSuccess(t.<LayoutIndexedScope>typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(),
out tupleScope));
dispatcher.get().argValue.Row = tempReference_Row.get();
for (int i = 0; i < typeArgs.getCount(); i++) {
for (int i = 0; i < typeArgs.count(); i++) {
PropertyInfo valueAccessor = value.getClass().GetProperty(String.format("Item%1$s", i + 1));
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these
// cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified:
dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).getType(),
typeArgs.get(i).getTypeArgs().clone(), valueAccessor.GetValue(value));
dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).type(),
typeArgs.get(i).typeArgs().clone(), valueAccessor.GetValue(value));
Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row);
tupleScope.MoveNext(tempReference_Row2);
@@ -237,7 +236,7 @@ public final class WriteRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row = new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor udtScope;
Out<RowCursor> tempOut_udtScope = new Out<RowCursor>();
ResultAssert.IsSuccess(t.<LayoutUDT>TypeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), tempOut_udtScope));
ResultAssert.IsSuccess(t.<LayoutUDT>typeAs().WriteScope(tempReference_Row, scope, typeArgs.clone(), tempOut_udtScope));
udtScope = tempOut_udtScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get();
IDispatchable valueDispatcher = value instanceof IDispatchable ? (IDispatchable)value : null;