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 final class Utf8String implements CharSequence, Comparable<Utf8String> {
public static final Utf8String EMPTY = new Utf8String(Unpooled.EMPTY_BUFFER, 0); 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 static final PooledByteBufAllocator allocator = PooledByteBufAllocator.DEFAULT;
private final ByteBuf buffer; private final ByteBuf buffer;
private final int length; 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)); 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.buffer = buffer.asReadOnly();
this.length = decodedLength; this.length = decodedLength;
} }
@@ -63,6 +70,13 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
return this.length == 0; return this.length == 0;
} }
/**
* {@code true} if this instance is null
*/
public final boolean isNull() {
return this.buffer == null;
}
@Override @Override
public char charAt(final int index) { public char charAt(final int index) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@@ -87,13 +101,29 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
} }
public final int compareTo(@Nonnull final Utf8String other) { public final int compareTo(@Nonnull final Utf8String other) {
checkNotNull(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); 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 length = this.length();
final int otherLength = other.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(); 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. * 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. * 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. * 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 * 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. * 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 public final class NullValue {
// 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> {
/** /**
* The default null literal. * The default null literal.
* This is the same value as default({@link NullValue}). * 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(); 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. * @param other The value to compare against.
* @return True if the two values are the same. * @return True if the two values are the same.
@@ -31,37 +27,16 @@ public final class NullValue implements IEquatable<NullValue> {
return true; return true;
} }
/**
* {@link object.Equals(object)} overload.
*/
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object other) {
if (null == obj) { if (null == other) {
return false; return false;
} }
return other instanceof NullValue && this.equals((NullValue)other);
return obj instanceof NullValue && this.equals((NullValue)obj);
} }
/**
* {@link object.GetHashCode} overload.
*/
@Override @Override
public int hashCode() { public int hashCode() {
return 42; 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; 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.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.Layout;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope; 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.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.LayoutType;
import com.azure.data.cosmos.serialization.hybridrow.layouts.StringToken; 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.TypeArgument;
import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList; import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList;
// ReSharper disable UseNameofExpression import static com.google.common.base.Strings.lenientFormat;
// 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
public final class RowCursor { public final class RowCursor {
/** /**
* If existing, the layout code of the existing field, otherwise undefined. * 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. * For types with generic parameters (e.g. {@link LayoutTuple}, the type parameters.
*/ */
public TypeArgumentList cellTypeArgs = new TypeArgumentList(); 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. * 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. * True if an existing field matching the search criteria was found.
*/ */
public boolean exists; 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. * 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. * If existing, the layout string token of scope relative path for reading.
*/ */
public int pathToken; public int pathToken;
/** private int count;
* The kind of scope within which this edit was prepared. private boolean immutable;
*/ private int index;
public LayoutScope scopeType; private Layout layout;
/** private int metaOffset;
* The type parameters of the scope within which this edit was prepared. private LayoutScope scopeType;
*/ private TypeArgumentList scopeTypeArgs = new TypeArgumentList();
public TypeArgumentList scopeTypeArgs = new TypeArgumentList(); private int start;
/** private int valueOffset;
* The 0-based byte offset from the beginning of the row where the first sparse field within private UtfAnyString writePath;
* the scope begins. private StringToken writePathToken = new StringToken();
*/
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();
public static RowCursor Create(Reference<RowBuffer> row) { public static RowCursor Create(Reference<RowBuffer> row) {
SchemaId schemaId = row.get().ReadSchemaId(1).clone();
Layout layout = row.get().getResolver().Resolve(schemaId.clone()); final SchemaId schemaId = row.get().ReadSchemaId(1);
int sparseSegmentOffset = row.get().ComputeVariableValueOffset(layout, HybridRowHeader.Size, final Layout layout = row.get().resolver().Resolve(schemaId);
final int sparseSegmentOffset = row.get().computeVariableValueOffset(layout, HybridRowHeader.SIZE,
layout.numVariable()); layout.numVariable());
RowCursor tempVar = new RowCursor();
tempVar.layout = layout; final RowCursor cursor = new RowCursor()
tempVar.scopeType = LayoutType.UDT; .layout(layout)
tempVar.scopeTypeArgs = new TypeArgumentList(schemaId.clone()); .scopeType(LayoutType.UDT)
tempVar.start = HybridRowHeader.Size; .scopeTypeArgs(new TypeArgumentList(schemaId))
tempVar.metaOffset = sparseSegmentOffset; .start(HybridRowHeader.SIZE)
tempVar.valueOffset = sparseSegmentOffset; .metaOffset(sparseSegmentOffset)
return tempVar.clone(); .valueOffset(sparseSegmentOffset);
return cursor;
} }
// TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter: public static RowCursor Create(RowBuffer row) {
// public static ref RowCursor Create(ref RowBuffer row, out RowCursor cursor)
// { final SchemaId schemaId = row.ReadSchemaId(1);
// SchemaId schemaId = row.ReadSchemaId(1); final Layout layout = row.Resolver.Resolve(schemaId);
// Layout layout = row.Resolver.Resolve(schemaId); final int sparseSegmentOffset = row.computeVariableValueOffset(layout, HybridRowHeader.Size,
// int sparseSegmentOffset = row.ComputeVariableValueOffset(layout, HybridRowHeader.Size, layout layout.NumVariable);
// .NumVariable);
// cursor = new RowCursor { layout = layout, scopeType = LayoutType.UDT, scopeTypeArgs = new return new RowCursor()
// TypeArgumentList(schemaId), start = HybridRowHeader.Size, metaOffset = sparseSegmentOffset, .layout(layout)
// valueOffset = sparseSegmentOffset}; .scopeType(LayoutType.UDT)
// .scopeTypeArgs(new TypeArgumentList(schemaId, HybridRowHeader.SIZE, sparseSegmentOffset, sparseSegmentOffset);
// return ref cursor; }
// }
/**
* 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: // 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) // public static ref RowCursor CreateForAppend(ref RowBuffer row, out RowCursor cursor)
@@ -143,94 +115,157 @@ public final class RowCursor {
// return ref cursor; // 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; public RowCursor immutable(boolean immutable) {
varCopy.scopeType = this.scopeType; this.immutable = immutable;
varCopy.scopeTypeArgs = this.scopeTypeArgs.clone(); return this;
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();
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 @Override
public String toString() { public String toString() {
try { try {
if (this.scopeType == null) {
if (this.scopeType() == null) {
return "<Invalid>"; return "<Invalid>";
} }
TypeArgument scopeTypeArg = (this.scopeType == null) || (this.scopeType instanceof LayoutEndScope) ? TypeArgument scopeTypeArg = (this.scopeType() instanceof LayoutEndScope)
default: ? new TypeArgument()
new TypeArgument(this.scopeType, this.scopeTypeArgs.clone()); : new TypeArgument(this.scopeType(), this.scopeTypeArgs().clone());
TypeArgument typeArg = (this.cellType == null) || (this.cellType instanceof LayoutEndScope) ? TypeArgument typeArg = (this.cellType == null) || (this.cellType instanceof LayoutEndScope)
default: ? new TypeArgument()
new TypeArgument(this.cellType, this.cellTypeArgs.clone()); : new TypeArgument(this.cellType, this.cellTypeArgs.clone());
String pathOrIndex = !this.writePath.IsNull ? this.writePath.toString() : String.valueOf(this.index); String pathOrIndex = this.writePath().isNull() ? String.valueOf(this.index()) : this.writePath().toString();
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" : ""); return lenientFormat("%s[%s] : %s@%s/%s%s",
} catch (java.lang.Exception e) { scopeTypeArg.clone(),
pathOrIndex,
typeArg.clone(),
this.metaOffset(),
this.valueOffset(),
this.immutable() ? " immutable" : "");
} catch (Exception ignored) {
return "<???>"; return "<???>";
} }
} }
/** /**
* If true, this scope's nested fields cannot be updated individually. * If existing, the offset to the value of the existing field, otherwise undefined.
* The entire scope can still be replaced.
*/ */
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: public int valueOffset() {
//ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public bool Immutable return valueOffset;
boolean getImmutable() }
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: public UtfAnyString writePath() {
//ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public int Index return writePath;
int getIndex() }
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: public StringToken writePathToken() {
//ORIGINAL LINE: [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Layout Layout return writePathToken;
Layout getLayout() }
/** public void writePathToken(StringToken writePathToken) {
* The kind of scope. this.writePathToken = writePathToken;
*/ }
// 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()
} }

View File

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

View File

@@ -4,124 +4,114 @@
package com.azure.data.cosmos.serialization.hybridrow; 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. * 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: @JsonDeserialize(using = SchemaId.JsonDeserializer.class)
//ORIGINAL LINE: [JsonConverter(typeof(SchemaIdConverter))][DebuggerDisplay("{" + nameof(SchemaId.Id) + "}") @JsonSerialize(using = SchemaId.JsonSerializer.class)
// ][StructLayout(LayoutKind.Sequential, Pack = 1)] public readonly struct SchemaId : IEquatable<SchemaId> public final class SchemaId {
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ
// from the original: public static final SchemaId INVALID = null;
//ORIGINAL LINE: [JsonConverter(typeof(SchemaIdConverter))][DebuggerDisplay("{" + nameof(SchemaId.Id) + "}") public static final SchemaId NONE = new SchemaId();
// ][StructLayout(LayoutKind.Sequential, Pack = 1)] public readonly struct SchemaId : IEquatable<SchemaId> public static final int SIZE = (Integer.SIZE / Byte.SIZE);
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct: private static long MAX_VALUE = 0x00000000FFFFFFFFL;
public final class SchemaId implements IEquatable<SchemaId> { private final int id;
public static final SchemaId Invalid = null;
public static final int Size = (Integer.SIZE / Byte.SIZE);
/**
* The underlying identifier.
*/
private int Id;
/** /**
* Initializes a new instance of the {@link SchemaId} struct. * Initializes a new instance of the {@link SchemaId} struct.
* *
* @param id The underlying globally unique identifier of the schema. * @param id The underlying globally unique identifier of the schema.
*/ */
public SchemaId() {
}
public SchemaId(int id) { public SchemaId(int id) {
this.Id = id; this.id = id;
} }
public int getId() { private SchemaId() {
return Id; this.id = -1;
} }
/**
* {@link object.Equals(object)} overload.
*/
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object other) {
if (null == obj) { return other instanceof SchemaId && this.equals((SchemaId) other);
return false;
}
return obj instanceof SchemaId && this.equals((SchemaId)obj);
} }
/** /**
* 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. * @param other The value to compare against.
* @return True if the two values are the same. * @return True if the two values are the same.
*/ */
public boolean equals(SchemaId other) { 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 @Override
public int hashCode() { 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) { public int id() {
return left.equals(right.clone()); return id;
} }
/**
* Operator != overload.
*/
public static boolean opNotEquals(SchemaId left, SchemaId right) {
return !left.equals(right.clone());
}
/**
* {@link object.ToString} overload.
*/
@Override @Override
public String toString() { public String toString() {
return String.valueOf(this.getId()); return String.valueOf(this.id());
} }
/** static final class JsonDeserializer extends StdDeserializer<SchemaId> {
* Helper class for parsing {@link SchemaId} from JSON.
*/ private JsonDeserializer() {
public static class SchemaIdConverter extends JsonConverter { super(SchemaId.class);
@Override
public boolean getCanWrite() {
return true;
} }
@Override @Override
public boolean CanConvert(java.lang.Class objectType) { public SchemaId deserialize(final JsonParser parser, final DeserializationContext context) throws IOException, JsonProcessingException {
return objectType.isAssignableFrom(SchemaId.class);
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 @Override
public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue, public void serialize(final SchemaId value, final JsonGenerator generator, final SerializerProvider provider) throws IOException {
JsonSerializer serializer) { generator.writeNumber((long) value.id() & MAX_VALUE);
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());
} }
} }
} }

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.Out;
import com.azure.data.cosmos.core.Reference; 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.Float128;
import com.azure.data.cosmos.serialization.hybridrow.NullValue; import com.azure.data.cosmos.serialization.hybridrow.NullValue;
import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor; 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.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.ILayoutSpanReadable;
import com.azure.data.cosmos.serialization.hybridrow.layouts.ILayoutUtf8SpanReadable; import com.azure.data.cosmos.serialization.hybridrow.layouts.ILayoutUtf8SpanReadable;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutBinary; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutBinary;
@@ -76,53 +77,56 @@ public final class RowReader {
private RowCursor cursor = new RowCursor(); private RowCursor cursor = new RowCursor();
private RowBuffer row = new RowBuffer(); private RowBuffer row = new RowBuffer();
private int schematizedCount; private int schematizedCount;
// State that can be checkpointed. // State that can be checkpointed.
private States state = States.values()[0]; 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() { public RowReader() {
} }
/** /**
* Initializes a new instance of the {@link RowReader} struct. * Initializes a new instance of the {@link RowReader} struct.
* *
* @param row The row to be read. * @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(Reference<RowBuffer> row) { public RowReader(Reference<RowBuffer> row) {
this(row, RowCursor.Create(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) { public RowReader(Reference<RowBuffer> row, final Checkpoint checkpoint) {
this.row = row.get().clone(); this.row = row.get().clone();
this.columns = checkpoint.Cursor.layout.columns(); this.columns = checkpoint.Cursor.layout().columns();
this.schematizedCount = checkpoint.Cursor.layout.numFixed() + checkpoint.Cursor.layout.numVariable(); this.schematizedCount = checkpoint.Cursor.layout().numFixed() + checkpoint.Cursor.layout().numVariable();
this.state = checkpoint.State; this.state = checkpoint.State;
this.cursor = checkpoint.Cursor.clone(); this.cursor = checkpoint.Cursor.clone();
this.columnIndex = checkpoint.ColumnIndex; 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) { private RowReader(Reference<RowBuffer> row, final RowCursor scope) {
this.cursor = scope.clone(); this.cursor = scope.clone();
this.row = row.get().clone(); this.row = row.get().clone();
this.columns = this.cursor.layout.columns(); this.columns = this.cursor.layout().columns();
this.schematizedCount = this.cursor.layout.numFixed() + this.cursor.layout.numVariable(); this.schematizedCount = this.cursor.layout().numFixed() + this.cursor.layout().numVariable();
this.state = States.None; this.state = States.None;
this.columnIndex = -1; this.columnIndex = -1;
@@ -136,25 +140,26 @@ public final class RowReader {
* is set (even though its values is set to null). * is set (even though its values is set to null).
*/ */
public boolean getHasValue() { public boolean getHasValue() {
switch (this.state) { switch (this.state) {
case Schematized: case Schematized:
return true; return true;
case Sparse: case Sparse:
if (this.cursor.cellType instanceof LayoutNullable) { if (this.cursor.cellType instanceof LayoutNullable) {
Reference<RowCursor> tempReference_cursor = Reference<RowCursor> cursor = new Reference<>(this.cursor);
new Reference<RowCursor>(this.cursor); RowCursor nullableScope = this.row.SparseIteratorReadScope(cursor, true).clone();
RowCursor nullableScope = this.row.SparseIteratorReadScope(tempReference_cursor, true).clone(); this.cursor = cursor.get();
this.cursor = tempReference_cursor.get(); Reference<RowBuffer> row = new Reference<>(this.row);
Reference<RowBuffer> tempReference_row = Reference<RowCursor> tempReference_nullableScope = new Reference<>(nullableScope);
new Reference<RowBuffer>(this.row); boolean tempVar = LayoutNullable.HasValue(row, tempReference_nullableScope) == Result.Success;
Reference<RowCursor> tempReference_nullableScope = new Reference<RowCursor>(nullableScope);
boolean tempVar = LayoutNullable.HasValue(tempReference_row, tempReference_nullableScope) == Result.Success;
nullableScope = tempReference_nullableScope.get(); nullableScope = tempReference_nullableScope.get();
this.row = tempReference_row.get(); this.row = row.get();
return tempVar; return tempVar;
} }
return true; return true;
default: default:
return false; return false;
} }
@@ -171,7 +176,7 @@ public final class RowReader {
case Schematized: case Schematized:
return 0; return 0;
case Sparse: case Sparse:
return this.cursor.index; return this.cursor.index();
default: default:
return 0; return 0;
} }
@@ -181,7 +186,7 @@ public final class RowReader {
* The length of row in bytes. * The length of row in bytes.
*/ */
public int getLength() { 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 * The path, relative to the scope, of the field (if positioned on a field, undefined otherwise)
* otherwise).
* <p> * <p>
* When enumerating an indexed scope, this value is always null (see {@link Index}). * When enumerating an indexed scope, this value is always null (see {@link Index}).
*/ */
@@ -268,7 +272,7 @@ public final class RowReader {
case Sparse: case Sparse:
return this.cursor.cellTypeArgs.clone(); return this.cursor.cellTypeArgs.clone();
default: default:
return TypeArgumentList.Empty; return TypeArgumentList.EMPTY;
} }
} }
@@ -281,7 +285,7 @@ public final class RowReader {
switch (this.state) { switch (this.state) {
case None: { case None: {
if (this.cursor.scopeType instanceof LayoutUDT) { if (this.cursor.scopeType() instanceof LayoutUDT) {
this.state = States.Schematized; this.state = States.Schematized;
// TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java:
// goto case States.Schematized; // goto case States.Schematized;
@@ -301,10 +305,10 @@ public final class RowReader {
// goto case States.Sparse; // goto case States.Sparse;
} }
checkState(this.cursor.scopeType instanceof LayoutUDT); checkState(this.cursor.scopeType() instanceof LayoutUDT);
LayoutColumn col = this.columns[this.columnIndex]; 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. // Skip schematized values if they aren't present.
// TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java: // TODO: C# TO JAVA CONVERTER: There is no 'goto' in Java:
// goto case States.Schematized; // 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. * {@link ReaderFunc{TContext}} is not an option, such as when TContext is a ref struct.
*/ */
public Result SkipScope(Reference<RowReader> nestedReader) { 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; return Result.Failure;
} }
@@ -1116,14 +1120,14 @@ public final class RowReader {
new Reference<RowBuffer>(this.row); new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.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.cursor = tempReference_cursor.get();
this.row = tempReference_row.get(); this.row = tempReference_row.get();
return tempVar; return tempVar;
case Variable: case Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row); Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor); 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.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get(); this.row = tempReference_row2.get();
return tempVar2; return tempVar2;
@@ -1152,14 +1156,14 @@ public final class RowReader {
case Fixed: case Fixed:
Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row); Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = new Reference<RowCursor>(this.cursor); 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.cursor = tempReference_cursor.get();
this.row = tempReference_row.get(); this.row = tempReference_row.get();
return tempVar; return tempVar;
case Variable: case Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row); Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor); 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); tempReference_cursor2, col, value);
this.cursor = tempReference_cursor2.get(); this.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get(); this.row = tempReference_row2.get();
@@ -1190,14 +1194,14 @@ public final class RowReader {
case Fixed: case Fixed:
Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row); Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = new Reference<RowCursor>(this.cursor); 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.cursor = tempReference_cursor.get();
this.row = tempReference_row.get(); this.row = tempReference_row.get();
return tempVar; return tempVar;
case Variable: case Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row); Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor); 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.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get(); this.row = tempReference_row2.get();
return tempVar2; return tempVar2;

View File

@@ -54,21 +54,21 @@ public final class RowWriter {
* The active layout of the current writer scope. * The active layout of the current writer scope.
*/ */
public Layout getLayout() { public Layout getLayout() {
return this.cursor.layout; return this.cursor.layout();
} }
/** /**
* The length of row in bytes. * The length of row in bytes.
*/ */
public int getLength() { public int getLength() {
return this.row.getLength(); return this.row.length();
} }
/** /**
* The resolver for UDTs. * The resolver for UDTs.
*/ */
public LayoutResolver getResolver() { 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); RowWriter writer = new RowWriter(row, tempReference_scope);
scope = tempReference_scope.get(); scope = tempReference_scope.get();
TypeArgument typeArg = new TypeArgument(LayoutType.UDT, TypeArgument typeArg = new TypeArgument(LayoutType.UDT,
new TypeArgumentList(scope.layout.schemaId().clone())); new TypeArgumentList(scope.layout().schemaId().clone()));
Reference<RowWriter> tempReference_writer = Reference<RowWriter> tempReference_writer =
new Reference<RowWriter>(writer); new Reference<RowWriter>(writer);
// TODO: C# TO JAVA CONVERTER: The following line could not be converted: // 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, public <TContext> Result WriteScope(UtfAnyString path, TypeArgument typeArg, TContext context,
WriterFunc<TContext> func) { WriterFunc<TContext> func) {
LayoutType type = typeArg.getType(); LayoutType type = typeArg.type();
Result result = this.PrepareSparseWrite(path, typeArg.clone()); Result result = this.PrepareSparseWrite(path, typeArg.clone());
if (result != Result.Success) { if (result != Result.Success) {
return result; return result;
@@ -411,7 +411,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope3 = Out<RowCursor> tempOut_nestedScope3 =
new Out<RowCursor>(); 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); UpdateOptions.Upsert, tempOut_nestedScope3);
nestedScope = tempOut_nestedScope3.get(); nestedScope = tempOut_nestedScope3.get();
this.cursor = tempRef_cursor3.argValue; this.cursor = tempRef_cursor3.argValue;
@@ -425,7 +425,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope4 = Out<RowCursor> tempOut_nestedScope4 =
new Out<RowCursor>(); 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); UpdateOptions.Upsert, tempOut_nestedScope4);
nestedScope = tempOut_nestedScope4.get(); nestedScope = tempOut_nestedScope4.get();
this.cursor = tempRef_cursor4.argValue; this.cursor = tempRef_cursor4.argValue;
@@ -439,7 +439,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope5 = Out<RowCursor> tempOut_nestedScope5 =
new Out<RowCursor>(); 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); UpdateOptions.Upsert, tempOut_nestedScope5);
nestedScope = tempOut_nestedScope5.get(); nestedScope = tempOut_nestedScope5.get();
this.cursor = tempRef_cursor5.argValue; this.cursor = tempRef_cursor5.argValue;
@@ -453,7 +453,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope6 = Out<RowCursor> tempOut_nestedScope6 =
new Out<RowCursor>(); 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); UpdateOptions.Upsert, tempOut_nestedScope6);
nestedScope = tempOut_nestedScope6.get(); nestedScope = tempOut_nestedScope6.get();
this.cursor = tempRef_cursor6.argValue; this.cursor = tempRef_cursor6.argValue;
@@ -467,7 +467,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope7 = Out<RowCursor> tempOut_nestedScope7 =
new Out<RowCursor>(); 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); UpdateOptions.Upsert, tempOut_nestedScope7);
nestedScope = tempOut_nestedScope7.get(); nestedScope = tempOut_nestedScope7.get();
this.cursor = tempRef_cursor7.argValue; this.cursor = tempRef_cursor7.argValue;
@@ -481,7 +481,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope8 = Out<RowCursor> tempOut_nestedScope8 =
new Out<RowCursor>(); 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); UpdateOptions.Upsert, func != null, tempOut_nestedScope8);
nestedScope = tempOut_nestedScope8.get(); nestedScope = tempOut_nestedScope8.get();
this.cursor = tempRef_cursor8.argValue; this.cursor = tempRef_cursor8.argValue;
@@ -491,7 +491,7 @@ public final class RowWriter {
//ORIGINAL LINE: case LayoutUDT scopeType: //ORIGINAL LINE: case LayoutUDT scopeType:
case LayoutUDT case LayoutUDT
scopeType: 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 = Reference<RowCursor> tempReference_cursor9 =
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope9 = Out<RowCursor> tempOut_nestedScope9 =
@@ -509,7 +509,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope10 = Out<RowCursor> tempOut_nestedScope10 =
new Out<RowCursor>(); 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); UpdateOptions.Upsert, tempOut_nestedScope10);
nestedScope = tempOut_nestedScope10.get(); nestedScope = tempOut_nestedScope10.get();
this.cursor = tempRef_cursor10.argValue; this.cursor = tempRef_cursor10.argValue;
@@ -523,7 +523,7 @@ public final class RowWriter {
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope11 = Out<RowCursor> tempOut_nestedScope11 =
new Out<RowCursor>(); 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); UpdateOptions.Upsert, tempOut_nestedScope11);
nestedScope = tempOut_nestedScope11.get(); nestedScope = tempOut_nestedScope11.get();
this.cursor = tempRef_cursor11.argValue; 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; result = func == null ? null : func.Invoke(ref nestedWriter, typeArg, context) ??Result.Success;
nestedWriter = tempReference_nestedWriter.get(); nestedWriter = tempReference_nestedWriter.get();
this.row = nestedWriter.row.clone(); this.row = nestedWriter.row.clone();
nestedScope.count = nestedWriter.cursor.count; nestedScope.count(nestedWriter.cursor.count());
if (result != Result.Success) { if (result != Result.Success) {
// TODO: what about unique violations here? // 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. * @return Success if the write is permitted, the error code otherwise.
*/ */
private Result PrepareSparseWrite(UtfAnyString path, TypeArgument typeArg) { private Result PrepareSparseWrite(UtfAnyString path, TypeArgument typeArg) {
if (this.cursor.scopeType.IsFixedArity && !(this.cursor.scopeType instanceof LayoutNullable)) { 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.index() < this.cursor.scopeTypeArgs().count()) && !typeArg.equals(this.cursor.scopeTypeArgs().get(this.cursor.index()).clone())) {
return Result.TypeConstraint; return Result.TypeConstraint;
} }
} else if (this.cursor.scopeType instanceof LayoutTypedMap) { } else if (this.cursor.scopeType() instanceof LayoutTypedMap) {
Reference<RowCursor> tempReference_cursor = Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.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(); this.cursor = tempReference_cursor.get();
return Result.TypeConstraint; return Result.TypeConstraint;
} else { } else {
this.cursor = tempReference_cursor.get(); 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; return Result.TypeConstraint;
} }
this.cursor.writePath = path; this.cursor.writePath(path);
return Result.Success; 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) { private <TLayoutType extends LayoutType<String> & ILayoutUtf8SpanWritable> Result WritePrimitive(UtfAnyString path, Utf8Span value, TLayoutType type, AccessUtf8SpanMethod sparse) {
Result result = Result.NotFound; Result result = Result.NotFound;
if (this.cursor.scopeType instanceof LayoutUDT) { if (this.cursor.scopeType() instanceof LayoutUDT) {
result = this.WriteSchematizedValue(path, value); 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) { private <TLayoutType extends LayoutType<TElement[]> & ILayoutSpanWritable<TElement>, TElement> Result WritePrimitive(UtfAnyString path, ReadOnlySpan<TElement> value, TLayoutType type, AccessReadOnlySpanMethod<TElement> sparse) {
Result result = Result.NotFound; Result result = Result.NotFound;
if (this.cursor.scopeType instanceof LayoutUDT) { if (this.cursor.scopeType() instanceof LayoutUDT) {
result = this.WriteSchematizedValue(path, value); 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) { 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; Result result = Result.NotFound;
if (this.cursor.scopeType instanceof LayoutUDT) { if (this.cursor.scopeType() instanceof LayoutUDT) {
result = this.WriteSchematizedValue(path, value); result = this.WriteSchematizedValue(path, value);
} }
@@ -914,7 +914,7 @@ public final class RowWriter {
private <TValue> Result WritePrimitive(UtfAnyString path, TValue value, LayoutType<TValue> type, private <TValue> Result WritePrimitive(UtfAnyString path, TValue value, LayoutType<TValue> type,
AccessMethod<TValue> sparse) { AccessMethod<TValue> sparse) {
Result result = Result.NotFound; Result result = Result.NotFound;
if (this.cursor.scopeType instanceof LayoutUDT) { if (this.cursor.scopeType() instanceof LayoutUDT) {
result = this.WriteSchematizedValue(path, value); result = this.WriteSchematizedValue(path, value);
} }
@@ -953,7 +953,7 @@ public final class RowWriter {
LayoutColumn col; LayoutColumn col;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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: // 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; return Result.NotFound;
} }
@@ -967,14 +967,14 @@ public final class RowWriter {
case StorageKind.Fixed: case StorageKind.Fixed:
Reference<RowBuffer> tempReference_row = Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(this.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(); this.row = tempReference_row.get();
return tempVar2; return tempVar2;
case StorageKind.Variable: case StorageKind.Variable:
Reference<RowBuffer> tempReference_row2 = Reference<RowBuffer> tempReference_row2 =
new Reference<RowBuffer>(this.row); 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(); this.row = tempReference_row2.get();
return tempVar3; return tempVar3;
@@ -996,7 +996,7 @@ public final class RowWriter {
LayoutColumn col; LayoutColumn col;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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: // 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; return Result.NotFound;
} }
@@ -1011,7 +1011,7 @@ public final class RowWriter {
new Reference<RowBuffer>(this.row); new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.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); value);
this.cursor = tempReference_cursor.get(); this.cursor = tempReference_cursor.get();
this.row = tempReference_row.get(); this.row = tempReference_row.get();
@@ -1021,7 +1021,7 @@ public final class RowWriter {
new Reference<RowBuffer>(this.row); new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = Reference<RowCursor> tempReference_cursor2 =
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
Result tempVar2 = t.<ILayoutUtf8SpanWritable>TypeAs().WriteVariable(tempReference_row2, Result tempVar2 = t.<ILayoutUtf8SpanWritable>typeAs().WriteVariable(tempReference_row2,
tempReference_cursor2, tempReference_cursor2,
col, value); col, value);
this.cursor = tempReference_cursor2.get(); this.cursor = tempReference_cursor2.get();
@@ -1043,7 +1043,7 @@ public final class RowWriter {
private <TElement> Result WriteSchematizedValue(UtfAnyString path, ReadOnlySpan<TElement> value) { private <TElement> Result WriteSchematizedValue(UtfAnyString path, ReadOnlySpan<TElement> value) {
LayoutColumn col; 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: // 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; return Result.NotFound;
} }
@@ -1056,14 +1056,14 @@ public final class RowWriter {
case StorageKind.Fixed: case StorageKind.Fixed:
Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row); Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = new Reference<RowCursor>(this.cursor); 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.cursor = tempReference_cursor.get();
this.row = tempReference_row.get(); this.row = tempReference_row.get();
return tempVar; return tempVar;
case StorageKind.Variable: case StorageKind.Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row); Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor); 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.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get(); this.row = tempReference_row2.get();
return tempVar2; return tempVar2;
@@ -1083,7 +1083,7 @@ public final class RowWriter {
private <TElement> Result WriteSchematizedValue(UtfAnyString path, ReadOnlySequence<TElement> value) { private <TElement> Result WriteSchematizedValue(UtfAnyString path, ReadOnlySequence<TElement> value) {
LayoutColumn col; 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: // 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; return Result.NotFound;
} }
@@ -1096,14 +1096,14 @@ public final class RowWriter {
case StorageKind.Fixed: case StorageKind.Fixed:
Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row); Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor = new Reference<RowCursor>(this.cursor); 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.cursor = tempReference_cursor.get();
this.row = tempReference_row.get(); this.row = tempReference_row.get();
return tempVar; return tempVar;
case StorageKind.Variable: case StorageKind.Variable:
Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row); Reference<RowBuffer> tempReference_row2 = new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 = new Reference<RowCursor>(this.cursor); 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.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get(); this.row = tempReference_row2.get();
return tempVar2; 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.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor; 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.ARRAY_SCOPE;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableArrayScope; import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_ARRAY_SCOPE;
public final class LayoutArray extends LayoutIndexedScope { public final class LayoutArray extends LayoutIndexedScope {
private TypeArgument TypeArg = new TypeArgument(); private TypeArgument TypeArg = new TypeArgument();
public LayoutArray(boolean immutable) { 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); this.TypeArg = new TypeArgument(this);
} }
@Override public String name() {
public String getName() {
return this.Immutable ? "im_array" : "array"; return this.Immutable ? "im_array" : "array";
} }
public TypeArgument getTypeArg() { public TypeArgument typeArg() {
return TypeArg; return TypeArg;
} }
@@ -46,7 +45,7 @@ public final class LayoutArray extends LayoutIndexedScope {
@Override @Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) { 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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; 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>, public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpanWritable<Byte>,
ILayoutSpanReadable<Byte>, ILayoutSequenceWritable<Byte> { ILayoutSpanReadable<Byte>, ILayoutSequenceWritable<Byte> {
public LayoutBinary() { 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 isFixed() {
public boolean getIsFixed() {
return false; return false;
} }
@Override public String name() {
public String getName() {
return "binary"; 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 //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// byte[] value) // byte[] value)
@Override @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) { Out<byte[]> value) {
ReadOnlySpan<Byte> span; ReadOnlySpan<Byte> span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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) // ReadOnlySpan<byte> value)
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<ReadOnlySpan<Byte>> value) { Out<ReadOnlySpan<Byte>> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0); 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); value.setAndGet(null);
return Result.NotFound; 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; return Result.Success;
} }
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //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) //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out byte[] value)
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<byte[]> value) { Out<byte[]> value) {
ReadOnlySpan<Byte> span; 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: // 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: //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) //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) { 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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; 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 //ORIGINAL LINE: public override Result ReadVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// byte[] value) // byte[] value)
@Override @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) { , Out<byte[]> value) {
ReadOnlySpan<Byte> span; ReadOnlySpan<Byte> span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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) // ReadOnlySpan<byte> value)
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
, Out<ReadOnlySpan<Byte>> value) { , Out<ReadOnlySpan<Byte>> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null); value.setAndGet(null);
return Result.NotFound; 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()); col.getOffset());
value.setAndGet(b.get().ReadVariableBinary(varOffset)); value.setAndGet(b.get().ReadVariableBinary(varOffset));
return Result.Success; 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[] //ORIGINAL LINE: public override Result WriteFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, byte[]
// value) // value)
@Override @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) { byte[] value) {
checkArgument(value != null); checkArgument(value != null);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //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) // ReadOnlySpan<byte> value)
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
ReadOnlySpan<Byte> value) { ReadOnlySpan<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0); checkArgument(col.getSize() >= 0);
checkArgument(value.Length == col.getSize()); checkArgument(value.Length == col.getSize());
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteFixedBinary(scope.get().start + col.getOffset(), value, col.getSize()); b.get().WriteFixedBinary(scope.get().start() + col.getOffset(), value, col.getSize());
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@@ -160,21 +158,21 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
// ReadOnlySequence<byte> value) // ReadOnlySequence<byte> value)
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
ReadOnlySequence<Byte> value) { ReadOnlySequence<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0); checkArgument(col.getSize() >= 0);
checkArgument(value.Length == col.getSize()); checkArgument(value.Length == col.getSize());
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteFixedBinary(scope.get().start + col.getOffset(), value, col.getSize()); b.get().WriteFixedBinary(scope.get().start() + col.getOffset(), value, col.getSize());
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, byte[] value) { public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, byte[] value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert); return writeSparse(b, edit, value, UpdateOptions.Upsert);
} }
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //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) // UpdateOptions options = UpdateOptions.Upsert)
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
@Override @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) { UpdateOptions options) {
checkArgument(value != null); checkArgument(value != null);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
ReadOnlySpan<Byte> value, UpdateOptions options) { 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) { if (result != Result.Success) {
return result; 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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
ReadOnlySequence<Byte> value, UpdateOptions options) { 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) { if (result != Result.Success) {
return result; 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, //ORIGINAL LINE: public override Result WriteVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col,
// byte[] value) // byte[] value)
@Override @Override
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, public Result writeVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, byte[] value) { LayoutColumn col, byte[] value) {
checkArgument(value != null); checkArgument(value != null);
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //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) // ReadOnlySpan<byte> value)
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, ReadOnlySpan<Byte> value) { LayoutColumn col, ReadOnlySpan<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
@@ -257,16 +255,16 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
return Result.TooBig; return Result.TooBig;
} }
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset()); col.getOffset());
int shift; int shift;
Out<Integer> tempOut_shift = new Out<Integer>(); Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift); b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift);
shift = tempOut_shift.get(); shift = tempOut_shift.get();
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset += shift; scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset += shift; scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success; return Result.Success;
} }
@@ -275,8 +273,8 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
// ReadOnlySequence<byte> value) // ReadOnlySequence<byte> value)
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, ReadOnlySequence<Byte> value) { LayoutColumn col, ReadOnlySequence<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
@@ -285,16 +283,16 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
return Result.TooBig; return Result.TooBig;
} }
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset()); col.getOffset());
int shift; int shift;
Out<Integer> tempOut_shift = new Out<Integer>(); Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift); b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift);
shift = tempOut_shift.get(); shift = tempOut_shift.get();
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset += shift; scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset += shift; scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success; return Result.Success;
} }
} }

View File

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

View File

@@ -51,16 +51,16 @@ public final class LayoutBuilder {
if (type.getIsNull()) { if (type.getIsNull()) {
checkArgument(nullable); checkArgument(nullable);
LayoutBit nullbit = this.bitallocator.Allocate().clone(); 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); this.fixedCount, 0, nullbit.clone(), LayoutBit.Invalid, 0);
} else if (type.getIsBool()) { } else if (type.getIsBool()) {
LayoutBit nullbit = nullable ? this.bitallocator.Allocate() : LayoutBit.Invalid; LayoutBit nullbit = nullable ? this.bitallocator.Allocate() : LayoutBit.Invalid;
LayoutBit boolbit = this.bitallocator.Allocate().clone(); 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); this.fixedCount, 0, nullbit.clone(), boolbit.clone(), 0);
} else { } else {
LayoutBit nullBit = nullable ? this.bitallocator.Allocate() : LayoutBit.Invalid; 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.fixedCount, this.fixedSize, nullBit.clone(), LayoutBit.Invalid, length);
this.fixedSize += type.getIsFixed() ? type.Size : length; this.fixedSize += type.getIsFixed() ? type.Size : length;
@@ -71,7 +71,7 @@ public final class LayoutBuilder {
} }
public void AddObjectScope(String path, LayoutType type) { 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, -1, LayoutBit.Invalid, LayoutBit.Invalid, 0);
this.sparseCount++; this.sparseCount++;
@@ -80,7 +80,7 @@ public final class LayoutBuilder {
} }
public void AddSparseColumn(String path, LayoutType type) { 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, -1, LayoutBit.Invalid, LayoutBit.Invalid, 0);
this.sparseCount++; this.sparseCount++;
@@ -102,7 +102,7 @@ public final class LayoutBuilder {
checkArgument(length >= 0); checkArgument(length >= 0);
checkArgument(type.getAllowVariable()); 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, this.getParent(), this.varCount, this.varCount, this.bitallocator.Allocate().clone(), LayoutBit.Invalid,
length); length);

View File

@@ -8,104 +8,109 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts;
///#pragma warning disable CA1028 // Enum Storage should be Int32 ///#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. * 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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public enum LayoutCode : byte //ORIGINAL LINE: public enum LayoutCode : byte
public enum LayoutCode { public enum LayoutCode {
Invalid((byte)0),
Null((byte)1), INVALID((byte)0),
BooleanFalse((byte)2),
Boolean((byte)3),
Int8((byte)5), NULL((byte)1),
Int16((byte)6), BOOLEAN_FALSE((byte)2),
Int32((byte)7), BOOLEAN((byte)3),
Int64((byte)8),
UInt8((byte)9), 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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: UInt16 = 10, //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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: UInt32 = 11, //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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: UInt64 = 12, //ORIGINAL LINE: UInt64 = 12,
UInt64((byte)12), UINT_64((byte)12),
VarInt((byte)13), VAR_INT((byte)13),
VarUInt((byte)14), VAR_UINT((byte)14),
Float32((byte)15), FLOAT_32((byte)15),
Float64((byte)16), FLOAT_64((byte)16),
Decimal((byte)17), DECIMAL((byte)17),
DateTime((byte)18), DATE_TIME((byte)18),
Guid((byte)19), GUID((byte)19),
Utf8((byte)20), UTF_8((byte)20),
Binary((byte)21), BINARY((byte)21),
Float128((byte)22), FLOAT_128((byte)22),
UnixDateTime((byte)23), UNIX_DATE_TIME((byte)23),
MongoDbObjectId((byte)24), MONGODB_OBJECT_ID((byte)24),
ObjectScope((byte)30), OBJECT_SCOPE((byte)30),
ImmutableObjectScope((byte)31), IMMUTABLE_OBJECT_SCOPE((byte)31),
ArrayScope((byte)32), ARRAY_SCOPE((byte)32),
ImmutableArrayScope((byte)33), IMMUTABLE_ARRAY_SCOPE((byte)33),
TypedArrayScope((byte)34), TYPED_ARRAY_SCOPE((byte)34),
ImmutableTypedArrayScope((byte)35), IMMUTABLE_TYPED_ARRAY_SCOPE((byte)35),
TupleScope((byte)36), TUPLE_SCOPE((byte)36),
ImmutableTupleScope((byte)37), IMMUTABLE_TUPLE_SCOPE((byte)37),
TypedTupleScope((byte)38), TYPED_TUPLE_SCOPE((byte)38),
ImmutableTypedTupleScope((byte)39), IMMUTABLE_TYPED_TUPLE_SCOPE((byte)39),
MapScope((byte)40), MAP_SCOPE((byte)40),
ImmutableMapScope((byte)41), IMMUTABLE_MAP_SCOPE((byte)41),
TypedMapScope((byte)42), TYPED_MAP_SCOPE((byte)42),
ImmutableTypedMapScope((byte)43), IMMUTABLE_TYPED_MAP_SCOPE((byte)43),
SetScope((byte)44), SET_SCOPE((byte)44),
ImmutableSetScope((byte)45), IMMUTABLE_SET_SCOPE((byte)45),
TypedSetScope((byte)46), TYPED_SET_SCOPE((byte)46),
ImmutableTypedSetScope((byte)47), IMMUTABLE_TYPED_SET_SCOPE((byte)47),
NullableScope((byte)48), NULLABLE_SCOPE((byte)48),
ImmutableNullableScope((byte)49), IMMUTABLE_NULLABLE_SCOPE((byte)49),
TaggedScope((byte)50), TAGGED_SCOPE((byte)50),
ImmutableTaggedScope((byte)51), IMMUTABLE_TAGGED_SCOPE((byte)51),
Tagged2Scope((byte)52), TAGGED2_SCOPE((byte)52),
ImmutableTagged2Scope((byte)53), IMMUTABLE_TAGGED2_SCOPE((byte)53),
/** /**
* Nested row. * Nested row.
*/ */
Schema((byte)68), SCHEMA((byte)68),
ImmutableSchema((byte)69), IMMUTABLE_SCHEMA((byte)69),
EndScope((byte)70); END_SCOPE((byte)70);
public static final int SIZE = java.lang.Byte.SIZE; public static final int SIZE = Byte.SIZE;
private static java.util.HashMap<Byte, LayoutCode> mappings;
private byte byteValue; private static Map<Byte, LayoutCode> mappings;
private byte value;
LayoutCode(byte value) { LayoutCode(byte value) {
byteValue = value; this.value = value;
getMappings().put(value, this); mappings().put(value, this);
} }
public byte getValue() { public byte value() {
return byteValue; return value;
} }
public static LayoutCode forValue(byte 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) { if (mappings == null) {
synchronized (LayoutCode.class) { synchronized (LayoutCode.class) {
if (mappings == null) { 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. * @param code The element type code.
*/ */
public static boolean AlwaysRequiresTypeCode(LayoutCode 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. * @param code The code to canonicalize.
*/ */
public static LayoutCode Canonicalize(LayoutCode code) { 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 //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] public static LayoutCode ClearImmutableBit
// (LayoutCode code) // (LayoutCode code)
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.core.Utf8String;
import com.azure.data.cosmos.serialization.hybridrow.schemas.StorageKind; import com.azure.data.cosmos.serialization.hybridrow.schemas.StorageKind;
import static com.google.common.base.Strings.lenientFormat;
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerDisplay("{FullPath + \": \" + Type.Name + TypeArgs.ToString()}")] public sealed class //ORIGINAL LINE: [DebuggerDisplay("{FullPath + \": \" + Type.Name + TypeArgs.ToString()}")] public sealed class
// LayoutColumn // LayoutColumn
@@ -107,7 +105,7 @@ public final class LayoutColumn {
this.offset = offset; this.offset = offset;
this.nullBit = nullBit.clone(); this.nullBit = nullBit.clone();
this.boolBit = boolBit.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: // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerHidden] public T TypeAs<T>() where T : ILayoutType //ORIGINAL LINE: [DebuggerHidden] public T TypeAs<T>() where T : ILayoutType
public <T extends ILayoutType> T TypeAs() { 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) { private static String GetFullPath(LayoutColumn parent, String path) {
if (parent != null) { if (parent != null) {
switch (LayoutCodeTraits.ClearImmutableBit(parent.type.LayoutCode)) { switch (LayoutCodeTraits.ClearImmutableBit(parent.type.LayoutCode)) {
case ObjectScope: case OBJECT_SCOPE:
case Schema: case SCHEMA:
return parent.getFullPath().toString() + "." + path; return parent.getFullPath().toString() + "." + path;
case ArrayScope: case ARRAY_SCOPE:
case TypedArrayScope: case TYPED_ARRAY_SCOPE:
case TypedSetScope: case TYPED_SET_SCOPE:
case TypedMapScope: case TYPED_MAP_SCOPE:
return parent.getFullPath().toString() + "[]" + path; return parent.getFullPath().toString() + "[]" + path;
default: default:
throw new IllegalStateException(lenientFormat("Parent scope type not supported: %s", parent.type.LayoutCode)); 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)); checkArgument(ns.getSchemas().contains(schema));
LayoutBuilder builder = new LayoutBuilder(schema.getName(), schema.getSchemaId().clone()); 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(); return builder.Build();
} }
@@ -58,7 +58,7 @@ public final class LayoutCompiler {
LayoutType type = LayoutCompiler.LogicalToPhysicalType(ns, p.getPropertyType(), tempOut_typeArgs); LayoutType type = LayoutCompiler.LogicalToPhysicalType(ns, p.getPropertyType(), tempOut_typeArgs);
typeArgs = tempOut_typeArgs.get(); typeArgs = tempOut_typeArgs.get();
switch (LayoutCodeTraits.ClearImmutableBit(type.LayoutCode)) { switch (LayoutCodeTraits.ClearImmutableBit(type.LayoutCode)) {
case ObjectScope: { case OBJECT_SCOPE: {
if (!p.getPropertyType().getNullable()) { if (!p.getPropertyType().getNullable()) {
throw new LayoutCompilationException("Non-nullable sparse column are not supported."); throw new LayoutCompilationException("Non-nullable sparse column are not supported.");
} }
@@ -70,17 +70,17 @@ public final class LayoutCompiler {
break; break;
} }
case ArrayScope: case ARRAY_SCOPE:
case TypedArrayScope: case TYPED_ARRAY_SCOPE:
case SetScope: case SET_SCOPE:
case TypedSetScope: case TYPED_SET_SCOPE:
case MapScope: case MAP_SCOPE:
case TypedMapScope: case TYPED_MAP_SCOPE:
case TupleScope: case TUPLE_SCOPE:
case TypedTupleScope: case TYPED_TUPLE_SCOPE:
case TaggedScope: case TAGGED_SCOPE:
case Tagged2Scope: case TAGGED2_SCOPE:
case Schema: { case SCHEMA: {
if (!p.getPropertyType().getNullable()) { if (!p.getPropertyType().getNullable()) {
throw new LayoutCompilationException("Non-nullable sparse column are not supported."); throw new LayoutCompilationException("Non-nullable sparse column are not supported.");
} }
@@ -89,7 +89,7 @@ public final class LayoutCompiler {
break; break;
} }
case NullableScope: { case NULLABLE_SCOPE: {
throw new LayoutCompilationException("Nullables cannot be explicitly declared as columns."); throw new LayoutCompilationException("Nullables cannot be explicitly declared as columns.");
} }
@@ -100,7 +100,7 @@ public final class LayoutCompiler {
if (pp != null) { if (pp != null) {
switch (pp.getStorage()) { switch (pp.getStorage()) {
case Fixed: case Fixed:
if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.Schema) { if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) {
throw new LayoutCompilationException("Cannot have fixed storage within a sparse " + throw new LayoutCompilationException("Cannot have fixed storage within a sparse " +
"scope."); "scope.");
} }
@@ -113,7 +113,7 @@ public final class LayoutCompiler {
builder.AddFixedColumn(p.getPath(), type, pp.getNullable(), pp.getLength()); builder.AddFixedColumn(p.getPath(), type, pp.getNullable(), pp.getLength());
break; break;
case Variable: case Variable:
if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.Schema) { if (LayoutCodeTraits.ClearImmutableBit(scope) != LayoutCode.SCHEMA) {
throw new LayoutCompilationException("Cannot have variable storage within a " + throw new LayoutCompilationException("Cannot have variable storage within a " +
"sparse scope."); "sparse scope.");
} }
@@ -150,7 +150,7 @@ public final class LayoutCompiler {
private static LayoutType LogicalToPhysicalType(Namespace ns, PropertyType logicalType, private static LayoutType LogicalToPhysicalType(Namespace ns, PropertyType logicalType,
Out<TypeArgumentList> typeArgs) { Out<TypeArgumentList> typeArgs) {
typeArgs.setAndGet(TypeArgumentList.Empty); typeArgs.setAndGet(TypeArgumentList.EMPTY);
boolean tempVar = boolean tempVar =
(logicalType instanceof ScopePropertyType ? (ScopePropertyType)logicalType : null).getImmutable(); (logicalType instanceof ScopePropertyType ? (ScopePropertyType)logicalType : null).getImmutable();
boolean immutable = boolean immutable =
@@ -313,7 +313,7 @@ public final class LayoutCompiler {
} }
TypeArgument[] tgArgs = new TypeArgument[tg.getItems().size() + 1]; 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++) { for (int i = 0; i < tg.getItems().size(); i++) {
TypeArgumentList itemTypeArgs = new TypeArgumentList(); TypeArgumentList itemTypeArgs = new TypeArgumentList();
Out<TypeArgumentList> tempOut_itemTypeArgs4 = new Out<TypeArgumentList>(); Out<TypeArgumentList> tempOut_itemTypeArgs4 = new Out<TypeArgumentList>();
@@ -342,7 +342,7 @@ public final class LayoutCompiler {
case Schema: case Schema:
UdtPropertyType up = (UdtPropertyType)logicalType; UdtPropertyType up = (UdtPropertyType)logicalType;
Schema udtSchema; 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)) udtSchema = tangible.ListHelper.find(ns.getSchemas(), s = up.getName().equals( > s.Name))
} else { } else {
udtSchema = tangible.ListHelper.find(ns.getSchemas(), s = 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 final class LayoutDateTime extends LayoutType<DateTime> {
public LayoutDateTime() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "datetime"; return "datetime";
} }
@Override @Override
public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<LocalDateTime> value) { Out<LocalDateTime> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(LocalDateTime.MIN); value.setAndGet(LocalDateTime.MIN);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<LocalDateTime> value) { Out<LocalDateTime> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(LocalDateTime.MIN); value.setAndGet(LocalDateTime.MIN);
return result; return result;
@@ -58,23 +56,22 @@ public final class LayoutDateTime extends LayoutType<DateTime> {
@Override @Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
LocalDateTime value) { LocalDateTime value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteDateTime(scope.get().start + col.getOffset(), value); b.get().WriteDateTime(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //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, //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, DateTime value,
// UpdateOptions options = UpdateOptions.Upsert) // 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) { 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) { if (result != Result.Success) {
return result; return result;
} }
@@ -84,7 +81,7 @@ public final class LayoutDateTime extends LayoutType<DateTime> {
} }
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, DateTime value) { public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, DateTime value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert); 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 final class LayoutDecimal extends LayoutType<BigDecimal> {
public LayoutDecimal() { public LayoutDecimal() {
// TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': // 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "decimal"; return "decimal";
} }
@Override @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) { Out<BigDecimal> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(new BigDecimal(0)); value.setAndGet(new BigDecimal(0));
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<BigDecimal> value) { Out<BigDecimal> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(new BigDecimal(0)); value.setAndGet(new BigDecimal(0));
return result; return result;
@@ -57,15 +55,15 @@ public final class LayoutDecimal extends LayoutType<BigDecimal> {
} }
@Override @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) { BigDecimal value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteDecimal(scope.get().start + col.getOffset(), value); b.get().WriteDecimal(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; 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, //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, decimal value,
// UpdateOptions options = UpdateOptions.Upsert) // UpdateOptions options = UpdateOptions.Upsert)
@Override @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) { 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) { if (result != Result.Success) {
return result; return result;
} }
@@ -85,8 +83,8 @@ public final class LayoutDecimal extends LayoutType<BigDecimal> {
} }
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
java.math.BigDecimal value) { 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: // following line:
//ORIGINAL LINE: base(LayoutCode.EndScope, false, isSizedScope: false, isIndexedScope: false, isFixedArity: //ORIGINAL LINE: base(LayoutCode.EndScope, false, isSizedScope: false, isIndexedScope: false, isFixedArity:
// false, isUniqueScope: false, isTypedScope: false); // false, isUniqueScope: false, isTypedScope: false);
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.EndScope, false, isSizedScope:false, isIndexedScope:false, isFixedArity:false, isUniqueScope: super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.END_SCOPE, false, isSizedScope():false, isIndexedScope():false, isFixedArity():false, isUniqueScope():
false, isTypedScope:false) false, isTypedScope():false)
} }
@Override public String name() {
public String getName() {
return "end"; 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 final class LayoutFloat128 extends LayoutType<com.azure.data.cosmos.serialization.hybridrow.Float128> {
public LayoutFloat128() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "float128"; return "float128";
} }
@Override @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) { Out<Float128> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null); value.setAndGet(null);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Float128> value) { Out<Float128> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -55,15 +53,15 @@ public final class LayoutFloat128 extends LayoutType<com.azure.data.cosmos.seria
} }
@Override @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) { Float128 value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteFloat128(scope.get().start + col.getOffset(), value.clone()); b.get().WriteFloat128(scope.get().start() + col.getOffset(), value.clone());
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; 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, //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, Float128 value,
// UpdateOptions options = UpdateOptions.Upsert) // UpdateOptions options = UpdateOptions.Upsert)
@Override @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) { 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) { if (result != Result.Success) {
return result; return result;
} }
@@ -83,7 +81,7 @@ public final class LayoutFloat128 extends LayoutType<com.azure.data.cosmos.seria
} }
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Float128 value) { public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Float128 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 LayoutFloat32 extends LayoutType<Float> { public final class LayoutFloat32 extends LayoutType<Float> {
public LayoutFloat32() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "float32"; return "float32";
} }
@Override @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) { Out<Float> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0); value.setAndGet(0);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Float> value) { Out<Float> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode); Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(0); value.setAndGet(0);
return result; return result;
@@ -56,13 +54,13 @@ public final class LayoutFloat32 extends LayoutType<Float> {
@Override @Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
float value) { float value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteFloat32(scope.get().start + col.getOffset(), value); b.get().WriteFloat32(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@@ -72,7 +70,7 @@ public final class LayoutFloat32 extends LayoutType<Float> {
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, float value, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, float value,
UpdateOptions options) { UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) { if (result != Result.Success) {
return result; return result;
} }

View File

@@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutFloat64 extends LayoutType<Double> { public final class LayoutFloat64 extends LayoutType<Double> {
public LayoutFloat64() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "float64"; return "float64";
} }
@Override @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) { Out<Double> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0); value.setAndGet(0);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Double> value) { Out<Double> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(0); value.setAndGet(0);
return result; return result;
@@ -56,13 +54,13 @@ public final class LayoutFloat64 extends LayoutType<Double> {
@Override @Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
double value) { double value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteFloat64(scope.get().start + col.getOffset(), value); b.get().WriteFloat64(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@@ -72,7 +70,7 @@ public final class LayoutFloat64 extends LayoutType<Double> {
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, double value, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, double value,
UpdateOptions options) { 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) { if (result != Result.Success) {
return result; return result;
} }

View File

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

View File

@@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutInt32 extends LayoutType<Integer> { public final class LayoutInt32 extends LayoutType<Integer> {
public LayoutInt32() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "int32"; return "int32";
} }
@Override @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) { Out<Integer> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0); value.setAndGet(0);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Integer> value) { Out<Integer> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(0); value.setAndGet(0);
return result; return result;
@@ -56,13 +54,13 @@ public final class LayoutInt32 extends LayoutType<Integer> {
@Override @Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
int value) { int value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteInt32(scope.get().start + col.getOffset(), value); b.get().WriteInt32(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@@ -72,7 +70,7 @@ public final class LayoutInt32 extends LayoutType<Integer> {
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, int value, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, int value,
UpdateOptions options) { 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) { if (result != Result.Success) {
return result; return result;
} }

View File

@@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutInt64 extends LayoutType<Long> { public final class LayoutInt64 extends LayoutType<Long> {
public LayoutInt64() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "int64"; return "int64";
} }
@Override @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) { Out<Long> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0); value.setAndGet(0);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Long> value) { Out<Long> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(0); value.setAndGet(0);
return result; return result;
@@ -56,13 +54,13 @@ public final class LayoutInt64 extends LayoutType<Long> {
@Override @Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
long value) { long value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteInt64(scope.get().start + col.getOffset(), value); b.get().WriteInt64(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@@ -72,7 +70,7 @@ public final class LayoutInt64 extends LayoutType<Long> {
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value,
UpdateOptions options) { 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) { if (result != Result.Success) {
return result; return result;
} }

View File

@@ -14,36 +14,34 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutInt8 extends LayoutType<Byte> { public final class LayoutInt8 extends LayoutType<Byte> {
public LayoutInt8() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "int8"; return "int8";
} }
@Override @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) { Out<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0); value.setAndGet(0);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Byte> value) { Out<Byte> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(0); value.setAndGet(0);
return result; return result;
@@ -56,13 +54,13 @@ public final class LayoutInt8 extends LayoutType<Byte> {
@Override @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) { byte value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteInt8(scope.get().start + col.getOffset(), value); b.get().WriteInt8(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@@ -72,7 +70,7 @@ public final class LayoutInt8 extends LayoutType<Byte> {
@Override @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) { 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) { if (result != Result.Success) {
return result; return result;
} }

View File

@@ -14,37 +14,35 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> { public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> {
public LayoutMongoDbObjectId() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
// ReSharper disable once StringLiteralTypo // ReSharper disable once StringLiteralTypo
@Override public String name() {
public String getName() {
return "mongodbobjectid"; return "mongodbobjectid";
} }
@Override @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) { Out<MongoDbObjectId> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null); value.setAndGet(null);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<MongoDbObjectId> value) { Out<MongoDbObjectId> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -55,15 +53,15 @@ public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> {
} }
@Override @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) { MongoDbObjectId value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteMongoDbObjectId(scope.get().start + col.getOffset(), value.clone()); b.get().WriteMongoDbObjectId(scope.get().start() + col.getOffset(), value.clone());
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; 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, //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, MongoDbObjectId value,
// UpdateOptions options = UpdateOptions.Upsert) // UpdateOptions options = UpdateOptions.Upsert)
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
MongoDbObjectId value, UpdateOptions options) { 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) { if (result != Result.Success) {
return result; return result;
} }
@@ -83,8 +81,8 @@ public final class LayoutMongoDbObjectId extends LayoutType<MongoDbObjectId> {
} }
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
MongoDbObjectId value) { 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 final class LayoutNull extends LayoutType<NullValue> {
public LayoutNull() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public boolean isNull() {
public boolean getIsNull() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "null"; return "null";
} }
@Override @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) { Out<NullValue> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
value.setAndGet(NullValue.Default); 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; return Result.NotFound;
} }
@@ -46,9 +43,9 @@ public final class LayoutNull extends LayoutType<NullValue> {
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<NullValue> value) { Out<NullValue> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode); Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -59,14 +56,14 @@ public final class LayoutNull extends LayoutType<NullValue> {
} }
@Override @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) { NullValue value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; 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, //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, NullValue value,
// UpdateOptions options = UpdateOptions.Upsert) // UpdateOptions options = UpdateOptions.Upsert)
@Override @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) { UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) { if (result != Result.Success) {
return result; return result;
} }
@@ -86,7 +83,7 @@ public final class LayoutNull extends LayoutType<NullValue> {
} }
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, NullValue value) { public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, NullValue value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert); 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 final class LayoutNullable extends LayoutIndexedScope {
public LayoutNullable(boolean immutable) { public LayoutNullable(boolean immutable) {
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableNullableScope : super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_NULLABLE_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.NullableScope, immutable, true, true, false, true); com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.NULLABLE_SCOPE, immutable, true, true, false, true);
} }
@Override public String name() {
public String getName() {
return this.Immutable ? "im_nullable" : "nullable"; return this.Immutable ? "im_nullable" : "nullable";
} }
@Override public int countTypeArgument(TypeArgumentList value) {
public int CountTypeArgument(TypeArgumentList value) { checkState(value.count() == 1);
checkState(value.getCount() == 1); return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).type().CountTypeArgument(value.get(0).typeArgs().clone());
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone());
} }
@Override @Override
public boolean HasImplicitTypeCode(Reference<RowCursor> edit) { public boolean HasImplicitTypeCode(Reference<RowCursor> edit) {
checkState(edit.get().index >= 0); checkState(edit.get().index() >= 0);
checkState(edit.get().scopeTypeArgs.getCount() == 1); checkState(edit.get().scopeTypeArgs().count() == 1);
checkState(edit.get().index == 1); checkState(edit.get().index() == 1);
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(0).getType().LayoutCode); return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode);
} }
public static Result HasValue(Reference<RowBuffer> b, Reference<RowCursor> scope) { public static Result HasValue(Reference<RowBuffer> b, Reference<RowCursor> scope) {
checkArgument(scope.get().scopeType instanceof LayoutNullable); 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().index() == 1 || scope.get().index() == 2, "Nullable scopes always point at the value");
checkState(scope.get().scopeTypeArgs.getCount() == 1); checkState(scope.get().scopeTypeArgs().count() == 1);
boolean hasValue = b.get().ReadInt8(scope.get().start) != 0; boolean hasValue = b.get().ReadInt8(scope.get().start()) != 0;
return hasValue ? Result.Success : Result.NotFound; return hasValue ? Result.Success : Result.NotFound;
} }
@Override @Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset, public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) { Out<Integer> lenInBytes) {
return new TypeArgumentList(new TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) }); return new TypeArgumentList(new TypeArgument[] { LayoutType.readTypeArgument(row, offset, lenInBytes) });
} }
@Override @Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) { public void SetImplicitTypeCode(Reference<RowCursor> edit) {
checkState(edit.get().index == 1); checkState(edit.get().index() == 1);
edit.get().cellType = edit.get().scopeTypeArgs.get(0).getType(); edit.get().cellType = edit.get().scopeTypeArgs().get(0).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone();
} }
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit, 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, public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, boolean hasValue, Out<RowCursor> value, TypeArgumentList typeArgs, boolean hasValue, Out<RowCursor> value,
UpdateOptions options) { 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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -96,12 +94,12 @@ public final class LayoutNullable extends LayoutIndexedScope {
} }
@Override @Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) { public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.getCount() == 1); checkState(value.count() == 1);
row.get().WriteSparseTypeCode(offset, this.LayoutCode); row.get().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes, lenInBytes += value.get(0).type().writeTypeArgument(row, offset + lenInBytes,
value.get(0).getTypeArgs().clone()); value.get(0).typeArgs().clone());
return lenInBytes; return lenInBytes;
} }
} }

View File

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

View File

@@ -50,7 +50,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
// ConcurrentDictionary method: // ConcurrentDictionary method:
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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: // 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; return layout;
} }
@@ -58,7 +58,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
if (SchemaId.opEquals(s.getSchemaId().clone(), if (SchemaId.opEquals(s.getSchemaId().clone(),
schemaId.clone())) { schemaId.clone())) {
layout = s.Compile(this.schemaNamespace); layout = s.Compile(this.schemaNamespace);
layout = this.layoutCache.putIfAbsent(schemaId.getId(), layout); layout = this.layoutCache.putIfAbsent(schemaId.id(), layout);
return layout; return layout;
} }
} }
@@ -67,7 +67,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
if (layout != null) { if (layout != null) {
// TODO: C# TO JAVA CONVERTER: There is no Java ConcurrentHashMap equivalent to this .NET // TODO: C# TO JAVA CONVERTER: There is no Java ConcurrentHashMap equivalent to this .NET
// ConcurrentDictionary method: // ConcurrentDictionary method:
boolean succeeded = this.layoutCache.TryAdd(schemaId.getId(), layout); boolean succeeded = this.layoutCache.TryAdd(schemaId.id(), layout);
checkState(succeeded); checkState(succeeded);
return layout; return layout;
} }

View File

@@ -13,51 +13,70 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public abstract class LayoutScope extends LayoutType { public abstract class LayoutScope extends LayoutType {
/**
* Returns true if this is a fixed arity scope. private boolean isFixedArity;
*/ private boolean isIndexedScope;
public boolean IsFixedArity; private boolean isSizedScope;
/** private boolean isTypedScope;
* Returns true if this is an indexed scope. private boolean isUniqueScope;
*/
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;
protected LayoutScope( protected LayoutScope(
LayoutCode code, boolean immutable, boolean isSizedScope, boolean isIndexedScope, boolean isFixedArity, LayoutCode code, boolean immutable, boolean isSizedScope, boolean isIndexedScope, boolean isFixedArity,
boolean isUniqueScope, boolean isTypedScope boolean isUniqueScope, boolean isTypedScope
) { ) {
super(code, immutable, 0); super(code, immutable, 0);
this.IsSizedScope = isSizedScope;
this.IsIndexedScope = isIndexedScope; this.isSizedScope = isSizedScope;
this.IsFixedArity = isFixedArity; this.isIndexedScope = isIndexedScope;
this.IsUniqueScope = isUniqueScope; this.isFixedArity = isFixedArity;
this.IsTypedScope = isTypedScope; this.isUniqueScope = isUniqueScope;
this.isTypedScope = isTypedScope;
} }
@Override /**
public final boolean getIsFixed() { * Returns true if this is a fixed arity scope.
return false; */
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) { 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) { if (result != Result.Success) {
return result; return result;
} }
b.get().DeleteSparse(edit); b.get().deleteSparse(edit);
return Result.Success; return Result.Success;
} }
@@ -72,16 +91,18 @@ public abstract class LayoutScope extends LayoutType {
return false; return false;
} }
public final Result ReadScope(Reference<RowBuffer> b, Reference<RowCursor> edit, public final Result ReadScope(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<RowCursor> value) {
Out<RowCursor> value) {
Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
} }
value.setAndGet(b.get().SparseIteratorReadScope(edit, 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; return Result.Success;
} }
@@ -89,10 +110,10 @@ public abstract class LayoutScope extends LayoutType {
int pathLenInBytes; int pathLenInBytes;
Out<Integer> tempOut_pathLenInBytes = new Out<Integer>(); Out<Integer> tempOut_pathLenInBytes = new Out<Integer>();
Out<Integer> tempOut_pathOffset = 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().pathToken = row.get().ReadSparsePathLen(edit.get().layout(), edit.get().valueOffset(), tempOut_pathLenInBytes, tempOut_pathOffset);
edit.get().argValue.pathOffset = tempOut_pathOffset.get(); edit.get().pathOffset = tempOut_pathOffset.get();
pathLenInBytes = tempOut_pathLenInBytes.get(); pathLenInBytes = tempOut_pathLenInBytes.get();
edit.get().valueOffset += pathLenInBytes; edit.get().valueOffset(edit.get().valueOffset() + pathLenInBytes);
} }
public void SetImplicitTypeCode(Reference<RowCursor> edit) { 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.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor; 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.IMMUTABLE_TAGGED_SCOPE;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TaggedScope; import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TAGGED_SCOPE;
public final class LayoutTagged extends LayoutIndexedScope { public final class LayoutTagged extends LayoutIndexedScope {
public LayoutTagged(boolean immutable) { 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 name() {
public String getName() {
return this.Immutable ? "im_tagged_t" : "tagged_t"; return this.Immutable ? "im_tagged_t" : "tagged_t";
} }
@Override public int countTypeArgument(TypeArgumentList value) {
public int CountTypeArgument(TypeArgumentList value) { checkState(value.count() == 2);
checkState(value.getCount() == 2); return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(1).type().CountTypeArgument(value.get(1).typeArgs().clone());
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(1).getType().CountTypeArgument(value.get(1).getTypeArgs().clone());
} }
@Override @Override
public boolean HasImplicitTypeCode(Reference<RowCursor> edit) { public boolean HasImplicitTypeCode(Reference<RowCursor> edit) {
checkArgument(edit.get().index >= 0); checkArgument(edit.get().index() >= 0);
checkArgument(edit.get().scopeTypeArgs.getCount() > edit.get().index); checkArgument(edit.get().scopeTypeArgs().count() > edit.get().index());
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(edit.get().index).getType().LayoutCode); return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode);
} }
@Override @Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset, public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) { Out<Integer> lenInBytes) {
TypeArgument[] retval = new TypeArgument[2]; TypeArgument[] retval = new TypeArgument[2];
retval[0] = new TypeArgument(UInt8, TypeArgumentList.Empty); retval[0] = new TypeArgument(UInt8, TypeArgumentList.EMPTY);
retval[1] = ReadTypeArgument(row, offset, lenInBytes); retval[1] = readTypeArgument(row, offset, lenInBytes);
return new TypeArgumentList(retval); return new TypeArgumentList(retval);
} }
@Override @Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) { public void SetImplicitTypeCode(Reference<RowCursor> edit) {
edit.get().cellType = edit.get().scopeTypeArgs.get(edit.get().index).getType(); edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(edit.get().index).getTypeArgs().clone(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone();
} }
@Override @Override
@@ -63,7 +61,7 @@ public final class LayoutTagged extends LayoutIndexedScope {
@Override @Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) { 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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -74,12 +72,12 @@ public final class LayoutTagged extends LayoutIndexedScope {
} }
@Override @Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) { public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkArgument(value.getCount() == 2); checkArgument(value.count() == 2);
row.get().WriteSparseTypeCode(offset, this.LayoutCode); row.get().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
lenInBytes += value.get(1).getType().WriteTypeArgument(row, offset + lenInBytes, lenInBytes += value.get(1).type().writeTypeArgument(row, offset + lenInBytes,
value.get(1).getTypeArgs().clone()); value.get(1).typeArgs().clone());
return lenInBytes; return lenInBytes;
} }
} }

View File

@@ -12,23 +12,21 @@ import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
public final class LayoutTagged2 extends LayoutIndexedScope { public final class LayoutTagged2 extends LayoutIndexedScope {
public LayoutTagged2(boolean immutable) { public LayoutTagged2(boolean immutable) {
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTagged2Scope : super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TAGGED2_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Tagged2Scope, immutable, isSizedScope: com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TAGGED2_SCOPE, immutable, isSizedScope():
true, isFixedArity:true, isUniqueScope:false, isTypedScope:true) true, isFixedArity():true, isUniqueScope():false, isTypedScope():true)
} }
@Override public String name() {
public String getName() {
return this.Immutable ? "im_tagged2_t" : "tagged2_t"; return this.Immutable ? "im_tagged2_t" : "tagged2_t";
} }
@Override public int countTypeArgument(TypeArgumentList value) {
public int CountTypeArgument(TypeArgumentList value) { checkState(value.count() == 3);
checkState(value.getCount() == 3);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); 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(); TypeArgument arg = value.get(i).clone();
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone()); lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone());
} }
return lenInBytes; return lenInBytes;
@@ -36,21 +34,21 @@ public final class LayoutTagged2 extends LayoutIndexedScope {
@Override @Override
public boolean HasImplicitTypeCode(Reference<RowCursor> edit) { public boolean HasImplicitTypeCode(Reference<RowCursor> edit) {
checkState(edit.get().index >= 0); checkState(edit.get().index() >= 0);
checkState(edit.get().scopeTypeArgs.getCount() > edit.get().index); checkState(edit.get().scopeTypeArgs().count() > edit.get().index());
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(edit.get().index).getType().LayoutCode); return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode);
} }
@Override @Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset, public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) { Out<Integer> lenInBytes) {
lenInBytes.setAndGet(0); lenInBytes.setAndGet(0);
TypeArgument[] retval = new TypeArgument[3]; 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++) { for (int i = 1; i < 3; i++) {
int itemLenInBytes; int itemLenInBytes;
Out<Integer> tempOut_itemLenInBytes = new Out<Integer>(); 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(); itemLenInBytes = tempOut_itemLenInBytes.get();
lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes);
} }
@@ -60,8 +58,8 @@ public final class LayoutTagged2 extends LayoutIndexedScope {
@Override @Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) { public void SetImplicitTypeCode(Reference<RowCursor> edit) {
edit.get().cellType = edit.get().scopeTypeArgs.get(edit.get().index).getType(); edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(edit.get().index).getTypeArgs().clone(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone();
} }
@Override @Override
@@ -76,7 +74,7 @@ public final class LayoutTagged2 extends LayoutIndexedScope {
@Override @Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) { 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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -87,13 +85,13 @@ public final class LayoutTagged2 extends LayoutIndexedScope {
} }
@Override @Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) { public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.getCount() == 3); checkState(value.count() == 3);
row.get().WriteSparseTypeCode(offset, this.LayoutCode); row.get().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); 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(); 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; 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.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor; 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.IMMUTABLE_TUPLE_SCOPE;
import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TupleScope; import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TUPLE_SCOPE;
public final class LayoutTuple extends LayoutIndexedScope { public final class LayoutTuple extends LayoutIndexedScope {
public LayoutTuple(boolean immutable) { 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 name() {
public String getName() {
return this.Immutable ? "im_tuple" : "tuple"; 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); 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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count); //ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count);
lenInBytes += RowBuffer.Count7BitEncodedUInt(value.getCount()); lenInBytes += RowBuffer.Count7BitEncodedUInt(value.count());
for (TypeArgument arg : value) { for (TypeArgument arg : value) {
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone()); lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone());
} }
return lenInBytes; return lenInBytes;
} }
@Override @Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset, public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) { Out<Integer> lenInBytes) {
int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes); int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes);
TypeArgument[] retval = new TypeArgument[numTypeArgs]; TypeArgument[] retval = new TypeArgument[numTypeArgs];
for (int i = 0; i < numTypeArgs; i++) { for (int i = 0; i < numTypeArgs; i++) {
int itemLenInBytes; int itemLenInBytes;
Out<Integer> tempOut_itemLenInBytes = new Out<Integer>(); 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(); itemLenInBytes = tempOut_itemLenInBytes.get();
lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes);
} }
@@ -64,7 +62,7 @@ public final class LayoutTuple extends LayoutIndexedScope {
@Override @Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) { 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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -75,14 +73,14 @@ public final class LayoutTuple extends LayoutIndexedScope {
} }
@Override @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().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); 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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: lenInBytes += row.Write7BitEncodedUInt(offset + lenInBytes, (ulong)value.Count); //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) { 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; 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.Preconditions.checkArgument;
import static com.google.common.base.Strings.lenientFormat; 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. * Describes the physical byte layout of a hybrid row field of a specific physical type {@code T}
* {@link LayoutType} is immutable. *
* {@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: public abstract class LayoutType<T> implements ILayoutType {
//ORIGINAL LINE: [DebuggerDisplay("{" + nameof(LayoutType.Name) + "}")] public abstract class LayoutType : ILayoutType
public abstract class LayoutType implements ILayoutType { private static final LayoutType[] CodeIndex = new LayoutType[LayoutCode.END_SCOPE.value() + 1];
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", private final boolean immutable;
// Justification = "Type is immutable.")] public static readonly LayoutArray Array = new LayoutArray(immutable: private final LayoutCode layoutCode;
// false); private final int size;
public static final LayoutArray Array = new LayoutArray(false); private final TypeArgument typeArg;
// 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;
/** /**
* 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) { protected LayoutType(LayoutCode code, boolean immutable, int size) {
this.LayoutCode = code; this.layoutCode = code;
this.Immutable = immutable; this.immutable = immutable;
this.Size = size; this.size = size;
LayoutType.CodeIndex[code.getValue()] = this; 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() { protected LayoutType(LayoutCode code, int size) {
return !this.getIsFixed(); this(code, false, size);
} }
/** /**
* True if this type is a boolean. * True if this type is a boolean.
*/ */
public boolean getIsBool() { public boolean isBoolean() {
return false; return false;
} }
/** /**
* True if this type is always fixed length. * 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. * True if this type is a literal null.
*/ */
public boolean getIsNull() { public boolean isNull() {
return false; return false;
} }
/** /**
* True if this type is a variable-length encoded integer type (either signed or unsigned). * True if this type is a variable-length encoded integer type (either signed or unsigned).
*/ */
public boolean getIsVarint() { public boolean isVarint() {
return false; 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. * Human readable name of the type.
*/ */
public abstract String getName(); public abstract String name();
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;
}
/** /**
* Helper for preparing the delete of a sparse field. * 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. * @param code The expected type of the field.
* @return Success if the delete is permitted, the error code otherwise. * @return Success if the delete is permitted, the error code otherwise.
*/ */
public static Result PrepareSparseDelete(Reference<RowBuffer> b, Reference<RowCursor> edit, public static Result prepareSparseDelete(Reference<RowBuffer> b, Reference<RowCursor> edit, LayoutCode code) {
LayoutCode code) { if (edit.get().scopeType().isFixedArity()) {
if (edit.get().scopeType.IsFixedArity) {
return Result.TypeConstraint; return Result.TypeConstraint;
} }
if (edit.get().immutable) { if (edit.get().immutable()) {
return Result.InsufficientPermissions; 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; return Result.TypeMismatch;
} }
@@ -373,16 +216,21 @@ public abstract class LayoutType implements ILayoutType {
* @return Success if the move is permitted, the error code otherwise. * @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. * The source field is delete if the move prepare fails with a destination error.
*/ */
public static Result PrepareSparseMove(Reference<RowBuffer> b, public static Result prepareSparseMove(
Reference<RowCursor> destinationScope, Reference<RowBuffer> b,
LayoutScope destinationCode, TypeArgument elementType, Reference<RowCursor> destinationScope,
Reference<RowCursor> srcEdit, UpdateOptions options, LayoutScope destinationCode,
Out<RowCursor> dstEdit) { TypeArgument elementType,
checkArgument(destinationScope.get().scopeType == destinationCode); Reference<RowCursor> srcEdit,
checkArgument(destinationScope.get().index == 0, "Can only insert into a edit at the root"); 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) { if (result != Result.Success) {
dstEdit.setAndGet(null); dstEdit.setAndGet(null);
return result; return result;
@@ -393,34 +241,34 @@ public abstract class LayoutType implements ILayoutType {
return Result.NotFound; return Result.NotFound;
} }
if (destinationScope.get().immutable) { if (destinationScope.get().immutable()) {
b.get().DeleteSparse(srcEdit); b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null); dstEdit.setAndGet(null);
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
if (!srcEdit.get().cellTypeArgs.equals(elementType.getTypeArgs().clone())) { if (!srcEdit.get().cellTypeArgs.equals(elementType.typeArgs())) {
b.get().DeleteSparse(srcEdit); b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null); dstEdit.setAndGet(null);
return Result.TypeConstraint; return Result.TypeConstraint;
} }
if (options == UpdateOptions.InsertAt) { if (options == UpdateOptions.InsertAt) {
b.get().DeleteSparse(srcEdit); b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null); dstEdit.setAndGet(null);
return Result.TypeConstraint; return Result.TypeConstraint;
} }
// Prepare the insertion at the destination. // 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)) { if ((options == UpdateOptions.Update) && (!dstEdit.get().exists)) {
b.get().DeleteSparse(srcEdit); b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null); dstEdit.setAndGet(null);
return Result.NotFound; return Result.NotFound;
} }
if ((options == UpdateOptions.Insert) && dstEdit.get().exists) { if ((options == UpdateOptions.Insert) && dstEdit.get().exists) {
b.get().DeleteSparse(srcEdit); b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null); dstEdit.setAndGet(null);
return Result.Exists; return Result.Exists;
} }
@@ -436,13 +284,13 @@ public abstract class LayoutType implements ILayoutType {
* @param code The expected type of the field. * @param code The expected type of the field.
* @return Success if the read is permitted, the error code otherwise. * @return Success if the read is permitted, the error code otherwise.
*/ */
public static Result PrepareSparseRead(Reference<RowBuffer> b, Reference<RowCursor> edit, public static Result prepareSparseRead(Reference<RowBuffer> b, Reference<RowCursor> edit, LayoutCode code) {
LayoutCode code) {
if (!edit.get().exists) { if (!edit.get().exists) {
return Result.NotFound; return Result.NotFound;
} }
if (LayoutCodeTraits.Canonicalize(edit.get().cellType.LayoutCode) != code) { if (LayoutCodeTraits.Canonicalize(edit.get().cellType.layoutCode()) != code) {
return Result.TypeMismatch; return Result.TypeMismatch;
} }
@@ -458,29 +306,29 @@ public abstract class LayoutType implements ILayoutType {
* @param options The write options. * @param options The write options.
* @return Success if the write is permitted, the error code otherwise. * @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) { 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; return Result.InsufficientPermissions;
} }
if (edit.get().scopeType.IsFixedArity && !(edit.get().scopeType instanceof LayoutNullable)) { 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().index() < edit.get().scopeTypeArgs().count()) && !typeArg.equals(edit.get().scopeTypeArgs().get(edit.get().index()))) {
return Result.TypeConstraint; return Result.TypeConstraint;
} }
} else if (edit.get().scopeType instanceof LayoutTypedMap) { } else if (edit.get().scopeType() instanceof LayoutTypedMap) {
if (!((typeArg.getType() instanceof LayoutTypedTuple) && typeArg.getTypeArgs().equals(edit.get().scopeTypeArgs.clone()))) { if (!((typeArg.type() instanceof LayoutTypedTuple) && typeArg.typeArgs().equals(edit.get().scopeTypeArgs()))) {
return Result.TypeConstraint; 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; return Result.TypeConstraint;
} }
if ((options == UpdateOptions.InsertAt) && edit.get().scopeType.IsFixedArity) { if ((options == UpdateOptions.InsertAt) && edit.get().scopeType().isFixedArity()) {
return Result.TypeConstraint; 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. edit.get().exists = false; // InsertAt never overwrites an existing item.
} }
@@ -495,34 +343,61 @@ public abstract class LayoutType implements ILayoutType {
return Result.Success; return Result.Success;
} }
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: public abstract Result readFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<T> value);
//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 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); LayoutType itemCode = row.get().ReadSparseTypeCode(offset);
int argsLenInBytes; int argsLenInBytes;
Out<Integer> tempOut_argsLenInBytes = new Out<Integer>(); 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(); argsLenInBytes = tempOut_argsLenInBytes.get();
lenInBytes.setAndGet((com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + argsLenInBytes); 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); 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. * 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: @SuppressWarnings("unchecked")
//ORIGINAL LINE: [DebuggerHidden] public T TypeAs<T>() where T : ILayoutType public final <Value extends ILayoutType> Value typeAs() {
public final <T extends ILayoutType> T TypeAs() { return (Value)this;
return (T)this;
} }
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) { public abstract Result writeFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, T value);
row.get().WriteSparseTypeCode(offset, this.LayoutCode);
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); 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 final class LayoutTypedArray extends LayoutIndexedScope {
public LayoutTypedArray(boolean immutable) { public LayoutTypedArray(boolean immutable) {
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedArrayScope : super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_ARRAY_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedArrayScope, immutable, true, false, false, true); com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_ARRAY_SCOPE, immutable, true, false, false, true);
} }
@Override public String name() {
public String getName() {
return this.Immutable ? "im_array_t" : "array_t"; return this.Immutable ? "im_array_t" : "array_t";
} }
@Override public int countTypeArgument(TypeArgumentList value) {
public int CountTypeArgument(TypeArgumentList value) { checkState(value.count() == 1);
checkState(value.getCount() == 1); return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).type().CountTypeArgument(value.get(0).typeArgs().clone());
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).getType().CountTypeArgument(value.get(0).getTypeArgs().clone());
} }
@Override @Override
public boolean HasImplicitTypeCode(Reference<RowCursor> edit) { public boolean HasImplicitTypeCode(Reference<RowCursor> edit) {
checkState(edit.get().index >= 0); checkState(edit.get().index() >= 0);
checkState(edit.get().scopeTypeArgs.getCount() == 1); checkState(edit.get().scopeTypeArgs().count() == 1);
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(0).getType().LayoutCode); return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode);
} }
@Override @Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset, public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) { Out<Integer> lenInBytes) {
return new TypeArgumentList(new TypeArgument[] { LayoutType.ReadTypeArgument(row, offset, lenInBytes) }); return new TypeArgumentList(new TypeArgument[] { LayoutType.readTypeArgument(row, offset, lenInBytes) });
} }
@Override @Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) { public void SetImplicitTypeCode(Reference<RowCursor> edit) {
edit.get().cellType = edit.get().scopeTypeArgs.get(0).getType(); edit.get().cellType = edit.get().scopeTypeArgs().get(0).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(0).getTypeArgs().clone(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone();
} }
@Override @Override
@@ -58,7 +56,7 @@ public final class LayoutTypedArray extends LayoutIndexedScope {
@Override @Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) { 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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -69,12 +67,12 @@ public final class LayoutTypedArray extends LayoutIndexedScope {
} }
@Override @Override
public int WriteTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) { public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
checkState(value.getCount() == 1); checkState(value.count() == 1);
row.get().WriteSparseTypeCode(offset, this.LayoutCode); row.get().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE);
lenInBytes += value.get(0).getType().WriteTypeArgument(row, offset + lenInBytes, lenInBytes += value.get(0).type().writeTypeArgument(row, offset + lenInBytes,
value.get(0).getTypeArgs().clone()); value.get(0).typeArgs().clone());
return lenInBytes; return lenInBytes;
} }
} }

View File

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

View File

@@ -14,23 +14,21 @@ import static com.google.common.base.Preconditions.checkArgument;
public final class LayoutTypedTuple extends LayoutIndexedScope { public final class LayoutTypedTuple extends LayoutIndexedScope {
public LayoutTypedTuple(boolean immutable) { public LayoutTypedTuple(boolean immutable) {
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableTypedTupleScope : super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_TYPED_TUPLE_SCOPE :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TypedTupleScope, immutable, true, true, false, true); com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.TYPED_TUPLE_SCOPE, immutable, true, true, false, true);
} }
@Override public String name() {
public String getName() {
return this.Immutable ? "im_tuple_t" : "tuple_t"; 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); 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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count); //ORIGINAL LINE: lenInBytes += RowBuffer.Count7BitEncodedUInt((ulong)value.Count);
lenInBytes += RowBuffer.Count7BitEncodedUInt(value.getCount()); lenInBytes += RowBuffer.Count7BitEncodedUInt(value.count());
for (TypeArgument arg : value) { for (TypeArgument arg : value) {
lenInBytes += arg.getType().CountTypeArgument(arg.getTypeArgs().clone()); lenInBytes += arg.type().CountTypeArgument(arg.typeArgs().clone());
} }
return lenInBytes; return lenInBytes;
@@ -38,20 +36,20 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
@Override @Override
public boolean HasImplicitTypeCode(Reference<RowCursor> edit) { public boolean HasImplicitTypeCode(Reference<RowCursor> edit) {
checkArgument(edit.get().index >= 0); checkArgument(edit.get().index() >= 0);
checkArgument(edit.get().scopeTypeArgs.getCount() > edit.get().index); checkArgument(edit.get().scopeTypeArgs().count() > edit.get().index());
return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs.get(edit.get().index).getType().LayoutCode); return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(edit.get().index()).type().LayoutCode);
} }
@Override @Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset, public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) { Out<Integer> lenInBytes) {
int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes); int numTypeArgs = row.get().intValue().Read7BitEncodedUInt(offset, lenInBytes);
TypeArgument[] retval = new TypeArgument[numTypeArgs]; TypeArgument[] retval = new TypeArgument[numTypeArgs];
for (int i = 0; i < numTypeArgs; i++) { for (int i = 0; i < numTypeArgs; i++) {
int itemLenInBytes; int itemLenInBytes;
Out<Integer> tempOut_itemLenInBytes = new Out<Integer>(); 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(); itemLenInBytes = tempOut_itemLenInBytes.get();
lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes);
} }
@@ -61,8 +59,8 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
@Override @Override
public void SetImplicitTypeCode(Reference<RowCursor> edit) { public void SetImplicitTypeCode(Reference<RowCursor> edit) {
edit.get().cellType = edit.get().scopeTypeArgs.get(edit.get().index).getType(); edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type();
edit.get().cellTypeArgs = edit.get().scopeTypeArgs.get(edit.get().index).getTypeArgs().clone(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone();
} }
@Override @Override
@@ -77,7 +75,7 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
@Override @Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) { 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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -88,14 +86,14 @@ public final class LayoutTypedTuple extends LayoutIndexedScope {
} }
@Override @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().WriteSparseTypeCode(offset, this.LayoutCode);
int lenInBytes = (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE); 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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: lenInBytes += row.Write7BitEncodedUInt(offset + lenInBytes, (ulong)value.Count); //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) { 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; 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 final class LayoutUDT extends LayoutPropertyScope {
public LayoutUDT(boolean immutable) { public LayoutUDT(boolean immutable) {
super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ImmutableSchema : super(immutable ? com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_SCHEMA :
com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.Schema, immutable); com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SCHEMA, immutable);
} }
@Override public String name() {
public String getName() {
return this.Immutable ? "im_udt" : "udt"; return this.Immutable ? "im_udt" : "udt";
} }
@Override public int countTypeArgument(TypeArgumentList value) {
public int CountTypeArgument(TypeArgumentList value) { return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.SIZE;
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.Size;
} }
@Override @Override
public TypeArgumentList ReadTypeArgumentList(Reference<RowBuffer> row, int offset, public TypeArgumentList readTypeArgumentList(Reference<RowBuffer> row, int offset,
Out<Integer> lenInBytes) { Out<Integer> lenInBytes) {
SchemaId schemaId = row.get().ReadSchemaId(offset).clone(); SchemaId schemaId = row.get().ReadSchemaId(offset).clone();
lenInBytes.setAndGet(SchemaId.Size); lenInBytes.setAndGet(SchemaId.SIZE);
return new TypeArgumentList(schemaId.clone()); return new TypeArgumentList(schemaId.clone());
} }
@@ -47,8 +45,8 @@ public final class LayoutUDT extends LayoutPropertyScope {
@Override @Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) { TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Layout udt = b.get().getResolver().Resolve(typeArgs.getSchemaId().clone()); Layout udt = b.get().resolver().Resolve(typeArgs.schemaId().clone());
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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -59,9 +57,9 @@ public final class LayoutUDT extends LayoutPropertyScope {
} }
@Override @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().WriteSparseTypeCode(offset, this.LayoutCode);
row.get().WriteSchemaId(offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), value.getSchemaId().clone()); 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; 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> //ORIGINAL LINE: public sealed class LayoutUInt16 : LayoutType<ushort>
public final class LayoutUInt16 extends LayoutType<Short> { public final class LayoutUInt16 extends LayoutType<Short> {
public LayoutUInt16() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "uint16"; 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 //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// ushort value) // ushort value)
@Override @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) { Out<Short> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0); value.setAndGet(0);
return Result.NotFound; 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; return Result.Success;
} }
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //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) //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ushort value)
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Short> value) { Out<Short> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode); Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(0); value.setAndGet(0);
return result; return result;
@@ -66,13 +64,13 @@ public final class LayoutUInt16 extends LayoutType<Short> {
@Override @Override
public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
short value) { short value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteUInt16(scope.get().start + col.getOffset(), value); b.get().WriteUInt16(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@@ -83,7 +81,7 @@ public final class LayoutUInt16 extends LayoutType<Short> {
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, short value, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, short value,
UpdateOptions options) { UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) { if (result != Result.Success) {
return result; return result;
} }

View File

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

View File

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

View File

@@ -16,16 +16,14 @@ import static com.google.common.base.Preconditions.checkArgument;
//ORIGINAL LINE: public sealed class LayoutUInt8 : LayoutType<byte> //ORIGINAL LINE: public sealed class LayoutUInt8 : LayoutType<byte>
public final class LayoutUInt8 extends LayoutType<Byte> { public final class LayoutUInt8 extends LayoutType<Byte> {
public LayoutUInt8() { 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 isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "uint8"; 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 //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// byte value) // byte value)
@Override @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) { Out<Byte> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0); value.setAndGet(0);
return Result.NotFound; 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; return Result.Success;
} }
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //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) //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out byte value)
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<Byte> value) { Out<Byte> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode); Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(0); value.setAndGet(0);
return result; return result;
@@ -66,13 +64,13 @@ public final class LayoutUInt8 extends LayoutType<Byte> {
@Override @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) { byte value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteUInt8(scope.get().start + col.getOffset(), value); b.get().WriteUInt8(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@@ -83,7 +81,7 @@ public final class LayoutUInt8 extends LayoutType<Byte> {
@Override @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) { UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) { if (result != Result.Success) {
return result; 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.Out;
import com.azure.data.cosmos.core.Reference; 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.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor; 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, public final Result Find(Reference<RowBuffer> b, Reference<RowCursor> scope,
Reference<RowCursor> patternScope, Out<RowCursor> value) { 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) { if (result != Result.Success) {
return result; return result;
} }
// Check if the search found the result. // Check if the search found the result.
b.get().DeleteSparse(patternScope); b.get().deleteSparse(patternScope);
return Result.Success; return Result.Success;
} }
@@ -58,7 +57,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
RowCursor dstEdit; RowCursor dstEdit;
Out<RowCursor> tempOut_dstEdit = Out<RowCursor> tempOut_dstEdit =
new Out<RowCursor>(); 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); this.FieldType(destinationScope).clone(), sourceEdit, options, tempOut_dstEdit);
dstEdit = tempOut_dstEdit.get(); 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 // TODO: it would be "better" if the destinationScope were updated to point to the
// highest item seen. Then we would avoid the maximum reparse. // highest item seen. Then we would avoid the maximum reparse.
destinationScope.get().count = dstEdit.count; destinationScope.get().count(dstEdit.count());
return Result.Success; return Result.Success;
} }
@@ -129,7 +128,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
return r; return r;
} }
uniqueScope.count = childScope.count; uniqueScope.count(childScope.count());
Reference<RowCursor> tempReference_uniqueScope = Reference<RowCursor> tempReference_uniqueScope =
new Reference<RowCursor>(uniqueScope); new Reference<RowCursor>(uniqueScope);
r = b.get().TypedCollectionUniqueIndexRebuild(tempReference_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 final class LayoutUnixDateTime extends LayoutType<com.azure.data.cosmos.serialization.hybridrow.UnixDateTime> {
public LayoutUnixDateTime() { 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); com.azure.data.cosmos.serialization.hybridrow.UnixDateTime.Size);
} }
@Override public boolean isFixed() {
public boolean getIsFixed() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "unixdatetime"; return "unixdatetime";
} }
@Override @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) { Out<UnixDateTime> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null); value.setAndGet(null);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<UnixDateTime> value) { Out<UnixDateTime> value) {
Result result = PrepareSparseRead(b, edit, this.LayoutCode); Result result = prepareSparseRead(b, edit, this.LayoutCode);
if (result != Result.Success) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -56,15 +54,15 @@ public final class LayoutUnixDateTime extends LayoutType<com.azure.data.cosmos.s
} }
@Override @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) { UnixDateTime value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteUnixDateTime(scope.get().start + col.getOffset(), value.clone()); b.get().WriteUnixDateTime(scope.get().start() + col.getOffset(), value.clone());
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; 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, //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, UnixDateTime value,
// UpdateOptions options = UpdateOptions.Upsert) // UpdateOptions options = UpdateOptions.Upsert)
@Override @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) { , UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) { if (result != Result.Success) {
return result; return result;
} }
@@ -84,7 +82,7 @@ public final class LayoutUnixDateTime extends LayoutType<com.azure.data.cosmos.s
} }
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, UnixDateTime value) { public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, UnixDateTime value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert); 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 final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8SpanWritable, ILayoutUtf8SpanReadable {
public LayoutUtf8() { 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 isFixed() {
public boolean getIsFixed() {
return false; return false;
} }
@Override public String name() {
public String getName() {
return "utf8"; return "utf8";
} }
@Override @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) { Out<String> value) {
Utf8Span span; Utf8Span span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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, public Result ReadFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Out<Utf8Span> value) { Out<Utf8Span> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0); 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); value.setAndGet(null);
return Result.NotFound; 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; return Result.Success;
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, public Result readSparse(Reference<RowBuffer> b, Reference<RowCursor> edit,
Out<String> value) { Out<String> value) {
Utf8Span span; Utf8Span span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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) { 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) { if (result != Result.Success) {
value.setAndGet(null); value.setAndGet(null);
return result; return result;
@@ -76,7 +74,7 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
} }
@Override @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) { , Out<String> value) {
Utf8Span span; Utf8Span span;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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 public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col
, Out<Utf8Span> value) { , Out<Utf8Span> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(null); value.setAndGet(null);
return Result.NotFound; 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()); col.getOffset());
value.setAndGet(b.get().ReadVariableString(varOffset)); value.setAndGet(b.get().ReadVariableString(varOffset));
return Result.Success; return Result.Success;
} }
@Override @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) { String value) {
checkArgument(value != null); checkArgument(value != null);
return this.WriteFixed(b, scope, col, Utf8Span.TranscodeUtf16(value)); 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, public Result WriteFixed(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col,
Utf8Span value) { Utf8Span value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
checkArgument(col.getSize() >= 0); checkArgument(col.getSize() >= 0);
checkArgument(value.Length == col.getSize()); checkArgument(value.Length == col.getSize());
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
b.get().WriteFixedString(scope.get().start + col.getOffset(), value); b.get().WriteFixedString(scope.get().start() + col.getOffset(), value);
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
return Result.Success; return Result.Success;
} }
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, String value) { public Result writeSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, String value) {
return WriteSparse(b, edit, value, UpdateOptions.Upsert); return writeSparse(b, edit, value, UpdateOptions.Upsert);
} }
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //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, //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, string value,
// UpdateOptions options = UpdateOptions.Upsert) // UpdateOptions options = UpdateOptions.Upsert)
@Override @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) { UpdateOptions options) {
checkArgument(value != null); checkArgument(value != null);
return this.WriteSparse(b, edit, Utf8Span.TranscodeUtf16(value), options); 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) // options = UpdateOptions.Upsert)
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Utf8Span value, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Utf8Span value,
UpdateOptions options) { 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) { if (result != Result.Success) {
return result; return result;
} }
@@ -157,7 +155,7 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
} }
@Override @Override
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, public Result writeVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, String value) { LayoutColumn col, String value) {
checkArgument(value != null); checkArgument(value != null);
return this.WriteVariable(b, scope, col, Utf8Span.TranscodeUtf16(value)); 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, public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, Utf8Span value) { LayoutColumn col, Utf8Span value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
@@ -175,16 +173,16 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
return Result.TooBig; return Result.TooBig;
} }
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset()); col.getOffset());
int shift; int shift;
Out<Integer> tempOut_shift = new Out<Integer>(); Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableString(varOffset, value, exists, tempOut_shift); b.get().WriteVariableString(varOffset, value, exists, tempOut_shift);
shift = tempOut_shift.get(); shift = tempOut_shift.get();
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset += shift; scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset += shift; scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success; 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 final class LayoutVarInt extends LayoutType<Long> {
public LayoutVarInt() { 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 isFixed() {
public boolean getIsFixed() {
return false; return false;
} }
@Override public boolean isVarint() {
public boolean getIsVarint() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "varint"; return "varint";
} }
@Override @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) { Out<Long> value) {
Contract.Fail("Not Implemented"); Contract.Fail("Not Implemented");
value.setAndGet(0); value.setAndGet(0);
@@ -41,8 +38,8 @@ public final class LayoutVarInt extends LayoutType<Long> {
} }
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<Long> value) { 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) { if (result != Result.Success) {
value.setAndGet(0); value.setAndGet(0);
return result; return result;
@@ -53,14 +50,14 @@ public final class LayoutVarInt extends LayoutType<Long> {
} }
@Override @Override
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Long> value) { public Result readVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Long> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0); value.setAndGet(0);
return Result.NotFound; 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()); col.getOffset());
value.setAndGet(b.get().ReadVariableInt(varOffset)); value.setAndGet(b.get().ReadVariableInt(varOffset));
return Result.Success; return Result.Success;
@@ -79,7 +76,7 @@ public final class LayoutVarInt extends LayoutType<Long> {
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value,
UpdateOptions options) { 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) { if (result != Result.Success) {
return result; return result;
} }
@@ -96,21 +93,21 @@ public final class LayoutVarInt extends LayoutType<Long> {
@Override @Override
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, long value) { LayoutColumn col, long value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset()); col.getOffset());
int shift; int shift;
Out<Integer> tempOut_shift = new Out<Integer>(); Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableInt(varOffset, value, exists, tempOut_shift); b.get().WriteVariableInt(varOffset, value, exists, tempOut_shift);
shift = tempOut_shift.get(); shift = tempOut_shift.get();
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset += shift; scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset += shift; scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success; 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> //ORIGINAL LINE: public sealed class LayoutVarUInt : LayoutType<ulong>
public final class LayoutVarUInt extends LayoutType<Long> { public final class LayoutVarUInt extends LayoutType<Long> {
public LayoutVarUInt() { 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 isFixed() {
public boolean getIsFixed() {
return false; return false;
} }
@Override public boolean isVarint() {
public boolean getIsVarint() {
return true; return true;
} }
@Override public String name() {
public String getName() {
return "varuint"; 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 //ORIGINAL LINE: public override Result ReadFixed(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// ulong value) // ulong value)
@Override @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) { Out<Long> value) {
Contract.Fail("Not Implemented"); Contract.Fail("Not Implemented");
value.setAndGet(0); 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: //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) //ORIGINAL LINE: public override Result ReadSparse(ref RowBuffer b, ref RowCursor edit, out ulong value)
@Override @Override
public Result ReadSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, Out<Long> value) { 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) { if (result != Result.Success) {
value.setAndGet(0); value.setAndGet(0);
return result; 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 //ORIGINAL LINE: public override Result ReadVariable(ref RowBuffer b, ref RowCursor scope, LayoutColumn col, out
// ulong value) // ulong value)
@Override @Override
public Result ReadVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Long> value) { public Result readVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, LayoutColumn col, Out<Long> value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { if (!b.get().ReadBit(scope.get().start(), col.getNullBit().clone())) {
value.setAndGet(0); value.setAndGet(0);
return Result.NotFound; 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()); col.getOffset());
value.setAndGet(b.get().ReadVariableUInt(varOffset)); value.setAndGet(b.get().ReadVariableUInt(varOffset));
return Result.Success; return Result.Success;
@@ -93,7 +90,7 @@ public final class LayoutVarUInt extends LayoutType<Long> {
@Override @Override
public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value, public Result WriteSparse(Reference<RowBuffer> b, Reference<RowCursor> edit, long value,
UpdateOptions options) { UpdateOptions options) {
Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options);
if (result != Result.Success) { if (result != Result.Success) {
return result; return result;
} }
@@ -113,21 +110,21 @@ public final class LayoutVarUInt extends LayoutType<Long> {
@Override @Override
public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope, public Result WriteVariable(Reference<RowBuffer> b, Reference<RowCursor> scope,
LayoutColumn col, long value) { LayoutColumn col, long value) {
checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(scope.get().scopeType() instanceof LayoutUDT);
if (scope.get().immutable) { if (scope.get().immutable()) {
return Result.InsufficientPermissions; return Result.InsufficientPermissions;
} }
boolean exists = b.get().ReadBit(scope.get().start, col.getNullBit().clone()); boolean exists = b.get().ReadBit(scope.get().start(), col.getNullBit().clone());
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset()); col.getOffset());
int shift; int shift;
Out<Integer> tempOut_shift = new Out<Integer>(); Out<Integer> tempOut_shift = new Out<Integer>();
b.get().WriteVariableUInt(varOffset, value, exists, tempOut_shift); b.get().WriteVariableUInt(varOffset, value, exists, tempOut_shift);
shift = tempOut_shift.get(); shift = tempOut_shift.get();
b.get().SetBit(scope.get().start, col.getNullBit().clone()); b.get().SetBit(scope.get().start(), col.getNullBit().clone());
scope.get().metaOffset += shift; scope.get().metaOffset(scope.get().metaOffset() + shift);
scope.get().valueOffset += shift; scope.get().valueOffset(scope.get().valueOffset() + shift);
return Result.Success; return Result.Success;
} }
} }

View File

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

View File

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

View File

@@ -4,33 +4,22 @@
package com.azure.data.cosmos.serialization.hybridrow.layouts; 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: public final class TypeArgument {
//ORIGINAL LINE: [DebuggerDisplay("{this.type == null ? null : ToString()}")] public readonly struct TypeArgument :
// IEquatable<TypeArgument> private final LayoutType type;
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ private final TypeArgumentList typeArgs;
// 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();
/** /**
* Initializes a new instance of the {@link TypeArgument} struct. * Initializes a new instance of the {@link TypeArgument} struct.
* *
* @param type The type of the constraint. * @param type The type of the constraint.
*/ */
public TypeArgument() {
}
public TypeArgument(LayoutType type) { public TypeArgument(LayoutType type) {
checkArgument(type != null); checkNotNull(type);
this.type = 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. * @param typeArgs For generic types the type parameters.
*/ */
public TypeArgument(LayoutType type, TypeArgumentList typeArgs) { public TypeArgument(LayoutType type, TypeArgumentList typeArgs) {
checkArgument(type != null); checkNotNull(type);
this.type = type; this.type = type;
this.typeArgs = typeArgs.clone(); this.typeArgs = typeArgs;
}
/**
* 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());
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object other) {
if (null == obj) {
if (null == other) {
return false; return false;
} }
boolean tempVar = obj instanceof TypeArgument; return other instanceof TypeArgument && this.equals((TypeArgument) other);
TypeArgument ota = tempVar ? (TypeArgument)obj : null;
if (tempVar) {
return this.equals(ota);
}
return false;
} }
@Override @Override
public int hashCode() { public int hashCode() {
// TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java: return (this.type.hashCode() * 397) ^ this.typeArgs.hashCode();
unchecked
{
return (this.type.hashCode() * 397) ^ this.typeArgs.hashCode();
}
} }
public static boolean opEquals(TypeArgument left, TypeArgument right) { public boolean equals(TypeArgument other) {
return left.equals(right.clone()); return this.type.equals(other.type) && this.typeArgs.equals(other.typeArgs);
}
public static boolean opNotEquals(TypeArgument left, TypeArgument right) {
return !left.equals(right.clone());
} }
@Override @Override
@@ -119,7 +58,20 @@ public final class TypeArgument implements IEquatable<TypeArgument> {
if (this.type == null) { if (this.type == null) {
return ""; 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 com.azure.data.cosmos.serialization.hybridrow.SchemaId;
import java.util.Arrays;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: public final class TypeArgumentList
///#pragma warning disable CA1034 // Nested types should not be visible {
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: private TypeArgumentList() {
//ORIGINAL LINE: [DebuggerDisplay("{this.args == null ? null : ToString()}")] public readonly struct TypeArgumentList this.args = new TypeArgument[] {};
// : IEquatable<TypeArgumentList> this.schemaId = SchemaId.NONE;
//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() {
} }
public TypeArgumentList(TypeArgument[] args) { public TypeArgumentList(TypeArgument[] args) {
checkArgument(args != null); checkArgument(args != null);
this.args = args; 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. * @param schemaId For UDT fields, the schema id of the nested layout.
*/ */
public TypeArgumentList(SchemaId schemaId) { public TypeArgumentList(SchemaId schemaId, TypeArgument...args) {
this.args = Array.<TypeArgument>Empty(); this.args = args.length == 0 ? EMPTY.args : args;
this.schemaId = schemaId.clone(); this.schemaId = schemaId;
} }
public int getCount() { public int count() {
return this.args.length; return this.args.length;
} }
/** /**
* For UDT fields, the schema id of the nested layout. * For UDT fields, the schema id of the nested layout.
*/ */
public SchemaId getSchemaId() { public SchemaId schemaId() {
return this.schemaId.clone(); return this.schemaId;
} }
/** /**
@@ -68,35 +56,19 @@ public final class TypeArgumentList implements IEquatable<TypeArgumentList> {
return new Enumerator(this.args); 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) { public boolean equals(TypeArgumentList other) {
//C# TO JAVA CONVERTER WARNING: Java Arrays.equals is not always identical to LINQ 'SequenceEqual': if (null == other) {
//ORIGINAL LINE: return (this.schemaId == other.schemaId) && this.args.SequenceEqual(other.args); return false;
return (SchemaId.opEquals(this.schemaId.clone(), }
other.schemaId.clone())) && Arrays.equals(this.args, other.args); if (this == other) {
return true;
}
return this.schemaId().equals(other.schemaId()) && Arrays.equals(this.args, other.args);
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object other) {
if (null == obj) { return other instanceof TypeArgumentList && this.equals((TypeArgumentList) other);
return false;
}
boolean tempVar = obj instanceof TypeArgumentList;
TypeArgumentList ota = tempVar ? (TypeArgumentList)obj : null;
if (tempVar) {
return this.equals(ota);
}
return false;
} }
public TypeArgument get(int i) { public TypeArgument get(int i) {
@@ -105,32 +77,30 @@ public final class TypeArgumentList implements IEquatable<TypeArgumentList> {
@Override @Override
public int hashCode() { 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) { 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) { public static boolean opNotEquals(TypeArgumentList left, TypeArgumentList right) {
return !left.equals(right.clone()); return !left.equals(right);
} }
@Override @Override
public String toString() { public String toString() {
if (SchemaId.opNotEquals(this.schemaId.clone(),
getSchemaId().Invalid)) { if (this.schemaId.equals(SchemaId.INVALID)) {
return String.format("<%1$s>", this.schemaId.toString()); return String.format("<%1$s>", this.schemaId().toString());
} }
if (this.args == null || this.args == null ? null : this.args.length == 0) { 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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: resizer = resizer != null ? resizer : DefaultSpanResizer<byte>.Default; //ORIGINAL LINE: resizer = resizer != null ? resizer : DefaultSpanResizer<byte>.Default;
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: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint crc32 = Crc32.Update(0, body.Span); //ORIGINAL LINE: uint crc32 = Crc32.Update(0, body.Span);
int 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; //ORIGINAL LINE: resizer = resizer != null ? resizer : DefaultSpanResizer<byte>.Default;
resizer = resizer != null ? resizer : DefaultSpanResizer < Byte >.Default; resizer = resizer != null ? resizer : DefaultSpanResizer < Byte >.Default;
int estimatedSize = 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.Comment.length() != null ? segment.Comment.length() : 0 + segment.SDL == null ? null :
segment.SDL.length() != null ? segment.SDL.length() : 0 + 20; segment.SDL.length() != null ? segment.SDL.length() : 0 + 20;

View File

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

View File

@@ -120,7 +120,7 @@ HashMap<SchemaId, Schema> ids
up: up:
ValidateAssert.Exists((up.Name, up.SchemaId), schemas, "Schema reference", "Namespace") ValidateAssert.Exists((up.Name, up.SchemaId), schemas, "Schema reference", "Namespace")
if (SchemaId.opNotEquals(up.SchemaId, if (SchemaId.opNotEquals(up.SchemaId,
SchemaId.Invalid)) { SchemaId.INVALID)) {
Schema s = ValidateAssert.Exists(up.SchemaId, ids, "Schema id", "Namespace"); 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 " + 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())); "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. // Enable id-less Schema references for all types with a unique version in the namespace.
for (Schema s : ns.getSchemas()) { for (Schema s : ns.getSchemas()) {
if (nameVersioningCheck.get(s.getName()).equals(1)) { 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") "Namespace")
} }
} }
@@ -269,7 +269,7 @@ private static void Visit(PropertyType p, PropertyType parent, HashMap<(String,
* @param label Diagnostic label describing <paramref name="id" />. * @param label Diagnostic label describing <paramref name="id" />.
*/ */
public static void IsValidSchemaId(SchemaId id, String label) { 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)); 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(); private com.azure.data.cosmos.serialization.hybridrow.SchemaId SchemaId = new SchemaId();
public UdtPropertyType() { 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() { public final String getName() {

View File

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

View File

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

View File

@@ -4,7 +4,6 @@
package com.azure.data.cosmos.serialization.hybridrow.perf; 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.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.ISpanResizer; import com.azure.data.cosmos.serialization.hybridrow.ISpanResizer;
@@ -49,7 +48,7 @@ public final class JsonModelRowGenerator {
} }
public int getLength() { public int getLength() {
return this.row.getLength(); return this.row.length();
} }
public RowReader GetReader() { 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 // TODO: C# TO JAVA CONVERTER: C# to Java Converter cannot determine whether this System.IO.Stream is input or
// output: // output:
public boolean ReadFrom(InputStream stream, int length) { 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() { public void Reset() {
Layout layout = this.row.getResolver().Resolve(this.row.getHeader().getSchemaId().clone()); Layout layout = this.row.resolver().Resolve(this.row.header().getSchemaId().clone());
this.row.InitLayout(HybridRowVersion.V1, layout, this.row.getResolver()); this.row.InitLayout(HybridRowVersion.V1, layout, this.row.resolver());
} }
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //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; 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.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Result; 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 final class RowReaderExtensions {
public static Result VisitReader(Reference<RowReader> reader) { public static Result VisitReader(Reference<RowReader> reader) {
@@ -68,7 +67,7 @@ public final class RowReaderExtensions {
case TaggedScope: case TaggedScope:
case ImmutableTaggedScope: case ImmutableTaggedScope:
case Tagged2Scope: 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: // 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()); Result r = reader.get().ReadScope(null, (ref RowReader child, Object _) -> child.VisitReader());
if (r != Result.Success) { 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.Out;
import com.azure.data.cosmos.core.Reference; 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.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor; import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutIndexedScope; 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) { public <TLayout extends LayoutType<TValue>, TValue> void Dispatch(Reference<RowOperationDispatcher> dispatcher, Reference<RowCursor> root, LayoutColumn col, LayoutType t, TValue value) {
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().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(); dispatcher.get().argValue.Row = tempReference_Row.get();
} }
public void DispatchArray(Reference<RowOperationDispatcher> dispatcher, public void DispatchArray(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 1); checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor arrayScope; RowCursor arrayScope;
Out<RowCursor> tempOut_arrayScope = Out<RowCursor> tempOut_arrayScope =
new Out<RowCursor>(); 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(); arrayScope = tempOut_arrayScope.get();
dispatcher.get().argValue.Row = tempReference_Row.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 - // 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 // these cannot be converted using the 'Ref' helper class unless the method is within the code
// being modified: // being modified:
dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).getType(), dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).type(),
typeArgs.get(0).getTypeArgs().clone(), item); typeArgs.get(0).typeArgs().clone(), item);
} }
} }
Reference<RowBuffer> tempReference_Row3 = Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row); 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(); dispatcher.get().argValue.Row = tempReference_Row3.get();
} }
public void DispatchMap(Reference<RowOperationDispatcher> dispatcher, public void DispatchMap(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 2); checkArgument(typeArgs.count() == 2);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor mapScope; RowCursor mapScope;
Out<RowCursor> tempOut_mapScope = Out<RowCursor> tempOut_mapScope =
new Out<RowCursor>(); 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(); mapScope = tempOut_mapScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get(); dispatcher.get().argValue.Row = tempReference_Row.get();
if (!mapScope.Immutable) { if (!mapScope.Immutable) {
@@ -99,17 +98,17 @@ public final class DeleteRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row3 = Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row); 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(); dispatcher.get().argValue.Row = tempReference_Row3.get();
} }
public void DispatchNullable(Reference<RowOperationDispatcher> dispatcher, public void DispatchNullable(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 1); checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().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(); dispatcher.get().argValue.Row = tempReference_Row.get();
} }
@@ -120,14 +119,14 @@ public final class DeleteRowDispatcher implements IDispatcher {
public void DispatchSet(Reference<RowOperationDispatcher> dispatcher, public void DispatchSet(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 1); checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor setScope; RowCursor setScope;
Out<RowCursor> tempOut_setScope = Out<RowCursor> tempOut_setScope =
new Out<RowCursor>(); 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(); setScope = tempOut_setScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get(); dispatcher.get().argValue.Row = tempReference_Row.get();
if (!setScope.Immutable) { 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 - // 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 // these cannot be converted using the 'Ref' helper class unless the method is within the code
// being modified: // being modified:
dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).getType(), dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).type(),
typeArgs.get(0).getTypeArgs().clone(), item); typeArgs.get(0).typeArgs().clone(), item);
} }
} }
Reference<RowBuffer> tempReference_Row3 = Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row); 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(); dispatcher.get().argValue.Row = tempReference_Row3.get();
} }
public void DispatchTuple(Reference<RowOperationDispatcher> dispatcher, public void DispatchTuple(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() >= 2); checkArgument(typeArgs.count() >= 2);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().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(); dispatcher.get().argValue.Row = tempReference_Row.get();
} }
public void DispatchUDT(Reference<RowOperationDispatcher> dispatcher, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Object value) { 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); 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(); 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.Out;
import com.azure.data.cosmos.core.Reference; 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.Float128;
import com.azure.data.cosmos.serialization.hybridrow.NullValue; import com.azure.data.cosmos.serialization.hybridrow.NullValue;
import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.Result;
@@ -1779,7 +1778,7 @@ private final static class RoundTripSparseArray extends TestActionDispatcher<Rou
field = tempReference_field2.get(); field = tempReference_field2.get();
ResultAssert.IsSuccess(r, tag); ResultAssert.IsSuccess(r, tag);
Assert.AreEqual(scope.ScopeType, scope2.ScopeType, 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); Assert.AreEqual(scope.Immutable, scope2.Immutable, tag);
// Read the nested fields // Read the nested fields
@@ -1860,7 +1859,7 @@ private final static class RoundTripSparseArray extends TestActionDispatcher<Rou
// Overwrite the whole scope. // Overwrite the whole scope.
Reference<RowCursor> tempReference_field3 = Reference<RowCursor> tempReference_field3 =
new Reference<RowCursor>(field); 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(); field = tempReference_field3.get();
ResultAssert.IsSuccess(r, tag); ResultAssert.IsSuccess(r, tag);
Reference<RowCursor> tempReference_field4 = Reference<RowCursor> tempReference_field4 =
@@ -2010,7 +2009,7 @@ private final static class RoundTripSparseObject extends TestActionDispatcher<Ro
field = tempReference_field3.get(); field = tempReference_field3.get();
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
Assert.AreEqual(scope.ScopeType, scope2.ScopeType, "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); Assert.AreEqual(scope.Immutable, scope2.Immutable, "Json: {0}", expected.Json);
// Read the nested field // Read the nested field
@@ -2051,7 +2050,7 @@ private final static class RoundTripSparseObject extends TestActionDispatcher<Ro
// Overwrite the whole scope. // Overwrite the whole scope.
Reference<RowCursor> tempReference_field4 = Reference<RowCursor> tempReference_field4 =
new Reference<RowCursor>(field); 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(); field = tempReference_field4.get();
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
Reference<RowCursor> tempReference_field5 = Reference<RowCursor> tempReference_field5 =
@@ -2189,7 +2188,7 @@ private final static class RoundTripSparseObjectMulti extends TestActionDispatch
} else { } else {
Reference<RowCursor> tempReference_nestedField2 = Reference<RowCursor> tempReference_nestedField2 =
new Reference<RowCursor>(nestedField); 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(); nestedField = tempReference_nestedField2.get();
ResultAssert.IsSuccess(r, tag); ResultAssert.IsSuccess(r, tag);
} }
@@ -2257,12 +2256,12 @@ private final static class RoundTripSparseObjectMulti extends TestActionDispatch
RowCursor _; RowCursor _;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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: // 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. // Overwrite the nested field.
Reference<RowCursor> tempReference_nestedField4 = Reference<RowCursor> tempReference_nestedField4 =
new Reference<RowCursor>(nestedField); 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(); nestedField = tempReference_nestedField4.get();
ResultAssert.IsSuccess(r, tag); ResultAssert.IsSuccess(r, tag);
@@ -2383,7 +2382,7 @@ private final static class RoundTripSparseObjectNested extends TestActionDispatc
} else { } else {
Reference<RowCursor> tempReference_field2 = Reference<RowCursor> tempReference_field2 =
new Reference<RowCursor>(field); 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(); field = tempReference_field2.get();
ResultAssert.IsSuccess(r, tag); ResultAssert.IsSuccess(r, tag);
} }
@@ -2519,7 +2518,7 @@ private final static class RoundTripSparseOrdering extends TestActionDispatcher<
} else { } else {
Reference<RowCursor> tempReference_field2 = Reference<RowCursor> tempReference_field2 =
new Reference<RowCursor>(field); 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(); field = tempReference_field2.get();
ResultAssert.IsSuccess(r, "Json: {0}", json); ResultAssert.IsSuccess(r, "Json: {0}", json);
Out<TValue> tempOut_value3 = new Out<TValue>(); Out<TValue> tempOut_value3 = new Out<TValue>();
@@ -2681,7 +2680,7 @@ private final static class RoundTripSparseSet extends TestActionDispatcher<Round
field = tempReference_field2.get(); field = tempReference_field2.get();
ResultAssert.IsSuccess(r, tag); ResultAssert.IsSuccess(r, tag);
Assert.AreEqual(scope.ScopeType, scope2.ScopeType, 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); Assert.AreEqual(scope.Immutable, scope2.Immutable, tag);
// Read the nested fields // Read the nested fields
@@ -2837,7 +2836,7 @@ private final static class RoundTripSparseSet extends TestActionDispatcher<Round
// Overwrite the whole scope. // Overwrite the whole scope.
Reference<RowCursor> tempReference_field9 = new Reference<RowCursor>(field); 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(); field = tempReference_field9.get();
ResultAssert.IsSuccess(r, tag); ResultAssert.IsSuccess(r, tag);
Reference<RowCursor> tempReference_field10 = new Reference<RowCursor>(field); Reference<RowCursor> tempReference_field10 = new Reference<RowCursor>(field);
@@ -2984,7 +2983,7 @@ private final static class RoundTripSparseSimple extends TestActionDispatcher<Ro
} else { } else {
Reference<RowCursor> tempReference_field2 = Reference<RowCursor> tempReference_field2 =
new Reference<RowCursor>(field); 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(); field = tempReference_field2.get();
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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(); TLayout t = (TLayout)col.getType();
TValue value; TValue value;
Out<TValue> tempOut_value = new Out<TValue>(); 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(); value = tempOut_value.get();
ResultAssert.IsSuccess(r, "Json: {0}", expected.Json); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
boolean tempVar = exValue instanceof Array; 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, protected final <TLayout extends LayoutType<TValue>, TValue> void RoundTrip(Reference<RowBuffer> row,
Reference<RowCursor> root, LayoutColumn col, Object exValue, Expected expected) { Reference<RowCursor> root, LayoutColumn col, Object exValue, Expected expected) {
TLayout t = (TLayout)col.getType(); 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); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
this.<TLayout, TValue>Compare(row, root, col, exValue, expected.clone()); 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); root.get().AsReadOnly(out roRoot);
Reference<RowCursor> tempReference_roRoot = Reference<RowCursor> tempReference_roRoot =
new Reference<RowCursor>(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(); 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()); this.<TLayout, TValue>RoundTrip(row, root, c, expected.Value, expected.clone());
// Make the var column shorter. // 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>RoundTrip(row, root, a, expected.Short, expected.clone());
this.<TLayout, TValue>Compare(row, root, c, expected.Value, 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); Assert.IsTrue(rowSizeAfterShrink < rowSizeBeforeShrink, "Json: {0}", expected.Json);
// Make the var column longer. // Make the var column longer.
this.<TLayout, TValue>RoundTrip(row, root, a, expected.Long, expected.clone()); this.<TLayout, TValue>RoundTrip(row, root, a, expected.Long, expected.clone());
this.<TLayout, TValue>Compare(row, root, c, expected.Value, 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 > rowSizeAfterShrink, "Json: {0}", expected.Json);
Assert.IsTrue(rowSizeAfterGrow > rowSizeBeforeShrink, "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); root.get().AsReadOnly(out roRoot);
Reference<RowCursor> tempReference_roRoot = Reference<RowCursor> tempReference_roRoot =
new Reference<RowCursor>(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(); 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); ResultAssert.IsSuccess(r, "Json: {0}", expected.Json);
TValue _; TValue _;
Out<TValue> tempOut__ = new Out<TValue>(); Out<TValue> tempOut__ = new Out<TValue>();
r = t.ReadVariable(row, root, col, tempOut__); r = t.readVariable(row, root, col, tempOut__);
_ = tempOut__.get(); _ = tempOut__.get();
ResultAssert.NotFound(r, "Json: {0}", expected.Json); 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, private <TLayout extends LayoutType<TValue>, TValue> void TooBig(Reference<RowBuffer> row,
Reference<RowCursor> root, LayoutColumn col, Expected expected) { Reference<RowCursor> root, LayoutColumn col, Expected expected) {
TLayout t = (TLayout)col.getType(); 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); 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; TLayout t = (TLayout)col.Type;
TValue _; TValue _;
Out<TValue> tempOut__ = new Out<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(); _ = tempOut__.get();
ResultAssert.NotFound(r, "Json: {0}", expected.Json); ResultAssert.NotFound(r, "Json: {0}", expected.Json);
return col; 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.Out;
import com.azure.data.cosmos.core.Reference; 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.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor; import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType;
@@ -35,7 +34,7 @@ public final class ReadRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
Out<TValue> tempOut_value = new Out<TValue>(); 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(); value = tempOut_value.get();
dispatcher.get().argValue.Row = tempReference_Row.get(); dispatcher.get().argValue.Row = tempReference_Row.get();
break; break;
@@ -43,7 +42,7 @@ public final class ReadRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row2 = Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
Out<TValue> tempOut_value2 = new Out<TValue>(); 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(); value = tempOut_value2.get();
dispatcher.get().argValue.Row = tempReference_Row2.get(); dispatcher.get().argValue.Row = tempReference_Row2.get();
break; break;
@@ -51,7 +50,7 @@ public final class ReadRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row3 = Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
Out<TValue> tempOut_value3 = new Out<TValue>(); 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(); value = tempOut_value3.get();
dispatcher.get().argValue.Row = tempReference_Row3.get(); dispatcher.get().argValue.Row = tempReference_Row3.get();
break; break;
@@ -67,14 +66,14 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchArray(Reference<RowOperationDispatcher> dispatcher, public void DispatchArray(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 1); checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor arrayScope; RowCursor arrayScope;
Out<RowCursor> tempOut_arrayScope = Out<RowCursor> tempOut_arrayScope =
new Out<RowCursor>(); 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(); arrayScope = tempOut_arrayScope.get();
dispatcher.get().argValue.Row = tempReference_Row.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 // 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 // cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified: // modified:
dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).getType(), dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).type(),
typeArgs.get(0).getTypeArgs().clone(), items.get(i++)); typeArgs.get(0).typeArgs().clone(), items.get(i++));
} }
dispatcher.get().argValue.Row = tempReference_Row2.get(); dispatcher.get().argValue.Row = tempReference_Row2.get();
} }
@@ -96,14 +95,14 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchMap(Reference<RowOperationDispatcher> dispatcher, public void DispatchMap(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 2); checkArgument(typeArgs.count() == 2);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor mapScope; RowCursor mapScope;
Out<RowCursor> tempOut_mapScope = Out<RowCursor> tempOut_mapScope =
new Out<RowCursor>(); 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(); mapScope = tempOut_mapScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get(); dispatcher.get().argValue.Row = tempReference_Row.get();
int i = 0; int i = 0;
@@ -124,14 +123,14 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchNullable(Reference<RowOperationDispatcher> dispatcher, public void DispatchNullable(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 1); checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor nullableScope; RowCursor nullableScope;
Out<RowCursor> tempOut_nullableScope = Out<RowCursor> tempOut_nullableScope =
new Out<RowCursor>(); 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(); nullableScope = tempOut_nullableScope.get();
dispatcher.get().argValue.Row = tempReference_Row.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 // 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 // cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified: // modified:
dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).getType(), dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).type(),
typeArgs.get(0).getTypeArgs().clone(), value); typeArgs.get(0).typeArgs().clone(), value);
} else { } else {
Reference<RowBuffer> tempReference_Row4 = Reference<RowBuffer> tempReference_Row4 =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
@@ -170,14 +169,14 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchSet(Reference<RowOperationDispatcher> dispatcher, public void DispatchSet(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 1); checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor setScope; RowCursor setScope;
Out<RowCursor> tempOut_setScope = Out<RowCursor> tempOut_setScope =
new Out<RowCursor>(); 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(); setScope = tempOut_setScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get(); dispatcher.get().argValue.Row = tempReference_Row.get();
int i = 0; 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 // 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 // cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified: // modified:
dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).getType(), dispatcher.get().LayoutCodeSwitch(ref setScope, null, typeArgs.get(0).type(),
typeArgs.get(0).getTypeArgs().clone(), items.get(i++)); typeArgs.get(0).typeArgs().clone(), items.get(i++));
} }
dispatcher.get().argValue.Row = tempReference_Row2.get(); dispatcher.get().argValue.Row = tempReference_Row2.get();
} }
@@ -198,18 +197,18 @@ public final class ReadRowDispatcher implements IDispatcher {
public void DispatchTuple(Reference<RowOperationDispatcher> dispatcher, public void DispatchTuple(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() >= 2); checkArgument(typeArgs.count() >= 2);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor tupleScope; RowCursor tupleScope;
Out<RowCursor> tempOut_tupleScope = Out<RowCursor> tempOut_tupleScope =
new Out<RowCursor>(); 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(); tupleScope = tempOut_tupleScope.get();
dispatcher.get().argValue.Row = tempReference_Row.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 = Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
tupleScope.MoveNext(tempReference_Row2); 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 // 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 // cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified: // modified:
dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).getType(), dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).type(),
typeArgs.get(i).getTypeArgs().clone(), valueAccessor.GetValue(value)); 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); Reference<RowBuffer> tempReference_Row = new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor udtScope; RowCursor udtScope;
Out<RowCursor> tempOut_udtScope = new Out<RowCursor>(); 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(); udtScope = tempOut_udtScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get(); dispatcher.get().argValue.Row = tempReference_Row.get();
IDispatchable valueDispatcher = value instanceof IDispatchable ? (IDispatchable)value : null; IDispatchable valueDispatcher = value instanceof IDispatchable ? (IDispatchable)value : null;

View File

@@ -237,7 +237,7 @@ public class RecordIOUnitTests {
return r; return r;
} }
buffer.setAndGet(resizer.getMemory().Slice(0, row.getLength())); buffer.setAndGet(resizer.getMemory().Slice(0, row.length()));
return Result.Success; 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.Out;
import com.azure.data.cosmos.core.Reference; 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.Float128;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.MemorySpanResizer; import com.azure.data.cosmos.serialization.hybridrow.MemorySpanResizer;
@@ -182,7 +181,7 @@ public final class RowReaderUnitTests {
Tuple.Create(3.0, new Point(5, 6)) }) Tuple.Create(3.0, new Point(5, 6)) })
RowReader reader = d.GetReader().clone(); RowReader reader = d.GetReader().clone();
assert reader.getLength() == d.Row.getLength(); assert reader.getLength() == d.Row.length();
Reference<RowReader> tempReference_reader = Reference<RowReader> tempReference_reader =
new Reference<RowReader>(reader); new Reference<RowReader>(reader);
RowReaderUnitTests.PrintReader(tempReference_reader, 0); RowReaderUnitTests.PrintReader(tempReference_reader, 0);

View File

@@ -17,10 +17,10 @@ public class SchemaIdUnitTests {
SchemaId b = new SchemaId(2); SchemaId b = new SchemaId(2);
SchemaId c = new SchemaId(); SchemaId c = new SchemaId();
assert 1 == a.getId(); assert 1 == a.id();
assert 2 == b.getId(); assert 2 == b.id();
assert SchemaId.Invalid == c.clone(); assert SchemaId.INVALID == c.clone();
assert 2 != a.getId(); assert 2 != a.id();
assert a.clone() != b.clone(); assert a.clone() != b.clone();
assert SchemaId.opEquals(a.clone(), a.clone()); assert SchemaId.opEquals(a.clone(), a.clone());
assert SchemaId.opNotEquals(a.clone(), b.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); Result r = RowWriter.WriteBuffer(tempReference_row, request, BatchRequestSerializer.Write);
row = tempReference_row.get(); row = tempReference_row.get();
assert Result.Success == r; 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. // Read the row back again.
Reference<RowBuffer> tempReference_row2 = 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.Out;
import com.azure.data.cosmos.core.Reference; 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.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
@@ -344,7 +343,7 @@ public final class TupleUnitTests {
RowCursor _; RowCursor _;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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: // 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 _; RowCursor _;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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: // 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) { 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; 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: // 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); 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.Out;
import com.azure.data.cosmos.core.Reference; 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.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; 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 private static void WriteSimilarMatch(Reference<RowBuffer> row, Reference<RowCursor> matchScope
, TypeArgumentList typeArgs, SimilarMatch m) { , TypeArgumentList typeArgs, SimilarMatch m) {
Layout matchLayout = row.get().getResolver().Resolve(typeArgs.getSchemaId().clone()); Layout matchLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone());
LayoutColumn c; LayoutColumn c;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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: // 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) { 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; 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: // 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); 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 - // 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 // these cannot be converted using the 'Ref' helper class unless the method is within the code
// being modified: // 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)); ref tupleScope, item.Key));
assert tupleScope.MoveNext(row); assert tupleScope.MoveNext(row);
TypeArgument valueType = c.getTypeArgs().get(1).clone(); TypeArgument valueType = c.getTypeArgs().get(1).clone();
@@ -1421,7 +1421,7 @@ public final class TypedMapUnitTests {
out tupleScope)); out tupleScope));
Reference<RowCursor> tempReference_tupleScope = Reference<RowCursor> tempReference_tupleScope =
new Reference<RowCursor>(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)); tempReference_tupleScope, item.Key));
tupleScope = tempReference_tupleScope.get(); tupleScope = tempReference_tupleScope.get();
assert tupleScope.MoveNext(row); 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.Out;
import com.azure.data.cosmos.core.Reference; 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.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; 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) { 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; 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: // 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); 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 - // 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 // these cannot be converted using the 'Ref' helper class unless the method is within the code
// being modified: // 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)); ref tempCursor, item));
Reference<RowCursor> tempReference_attendScope = Reference<RowCursor> tempReference_attendScope =
new Reference<RowCursor>(attendScope); new Reference<RowCursor>(attendScope);
@@ -1546,7 +1545,7 @@ public final class TypedSetUnitTests {
root.get().Clone(out tempCursor).Find(row, Utf8String.Empty); root.get().Clone(out tempCursor).Find(row, Utf8String.Empty);
Reference<RowCursor> tempReference_tempCursor2 = Reference<RowCursor> tempReference_tempCursor2 =
new Reference<RowCursor>(tempCursor); 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)); tempReference_tempCursor2, item));
tempCursor = tempReference_tempCursor2.get(); tempCursor = tempReference_tempCursor2.get();
Reference<RowCursor> tempReference_projScope = Reference<RowCursor> tempReference_projScope =
@@ -1586,7 +1585,7 @@ public final class TypedSetUnitTests {
root.get().Clone(out tempCursor).Find(row, Utf8String.Empty); root.get().Clone(out tempCursor).Find(row, Utf8String.Empty);
Reference<RowCursor> tempReference_tempCursor4 = Reference<RowCursor> tempReference_tempCursor4 =
new Reference<RowCursor>(tempCursor); 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)); tempReference_tempCursor4, item));
tempCursor = tempReference_tempCursor4.get(); tempCursor = tempReference_tempCursor4.get();
Reference<RowCursor> tempReference_checkboxScope = 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.Out;
import com.azure.data.cosmos.core.Reference; 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.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor; import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType;
@@ -33,19 +32,19 @@ public final class WriteRowDispatcher implements IDispatcher {
case Fixed: case Fixed:
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().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(); dispatcher.get().argValue.Row = tempReference_Row.get();
break; break;
case Variable: case Variable:
Reference<RowBuffer> tempReference_Row2 = Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row); 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(); dispatcher.get().argValue.Row = tempReference_Row2.get();
break; break;
default: default:
Reference<RowBuffer> tempReference_Row3 = Reference<RowBuffer> tempReference_Row3 =
new Reference<RowBuffer>(dispatcher.get().Row); 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(); dispatcher.get().argValue.Row = tempReference_Row3.get();
break; break;
} }
@@ -54,14 +53,14 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchArray(Reference<RowOperationDispatcher> dispatcher, public void DispatchArray(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 1); checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor arrayScope; RowCursor arrayScope;
Out<RowCursor> tempOut_arrayScope = Out<RowCursor> tempOut_arrayScope =
new Out<RowCursor>(); 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)); tempOut_arrayScope));
arrayScope = tempOut_arrayScope.get(); arrayScope = tempOut_arrayScope.get();
dispatcher.get().argValue.Row = tempReference_Row.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 // 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 // cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified: // modified:
dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).getType(), dispatcher.get().LayoutCodeSwitch(ref arrayScope, null, typeArgs.get(0).type(),
typeArgs.get(0).getTypeArgs().clone(), item); typeArgs.get(0).typeArgs().clone(), item);
Reference<RowBuffer> tempReference_Row2 = Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
arrayScope.MoveNext(tempReference_Row2); arrayScope.MoveNext(tempReference_Row2);
@@ -83,20 +82,20 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchMap(Reference<RowOperationDispatcher> dispatcher, public void DispatchMap(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 2); checkArgument(typeArgs.count() == 2);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor mapScope; RowCursor mapScope;
Out<RowCursor> tempOut_mapScope = Out<RowCursor> tempOut_mapScope =
new Out<RowCursor>(); 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)); tempOut_mapScope));
mapScope = tempOut_mapScope.get(); mapScope = tempOut_mapScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get(); dispatcher.get().argValue.Row = tempReference_Row.get();
Reference<RowCursor> tempReference_mapScope = Reference<RowCursor> tempReference_mapScope =
new Reference<RowCursor>(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(); mapScope = tempReference_mapScope.get();
List pairs = (List)value; List pairs = (List)value;
for (Object pair : pairs) { for (Object pair : pairs) {
@@ -122,7 +121,7 @@ public final class WriteRowDispatcher implements IDispatcher {
new Reference<RowCursor>(mapScope); new Reference<RowCursor>(mapScope);
Reference<RowCursor> tempReference_tempCursor = Reference<RowCursor> tempReference_tempCursor =
new Reference<RowCursor>(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)); tempReference_tempCursor));
tempCursor = tempReference_tempCursor.get(); tempCursor = tempReference_tempCursor.get();
mapScope = tempReference_mapScope2.get(); mapScope = tempReference_mapScope2.get();
@@ -133,14 +132,14 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchNullable(Reference<RowOperationDispatcher> dispatcher, public void DispatchNullable(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 1); checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor nullableScope; RowCursor nullableScope;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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: // 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)); value != null, out nullableScope));
dispatcher.get().argValue.Row = tempReference_Row.get(); 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 // 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 // cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified: // modified:
dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).getType(), dispatcher.get().LayoutCodeSwitch(ref nullableScope, null, typeArgs.get(0).type(),
typeArgs.get(0).getTypeArgs().clone(), value); typeArgs.get(0).typeArgs().clone(), value);
} }
} }
@@ -160,14 +159,14 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchSet(Reference<RowOperationDispatcher> dispatcher, public void DispatchSet(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() == 1); checkArgument(typeArgs.count() == 1);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor setScope; RowCursor setScope;
Out<RowCursor> tempOut_setScope = Out<RowCursor> tempOut_setScope =
new Out<RowCursor>(); 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)); tempOut_setScope));
setScope = tempOut_setScope.get(); setScope = tempOut_setScope.get();
dispatcher.get().argValue.Row = tempReference_Row.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 // 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 // cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified: // modified:
dispatcher.get().LayoutCodeSwitch(ref tempCursor, elmPath, typeArgs.get(0).getType(), dispatcher.get().LayoutCodeSwitch(ref tempCursor, elmPath, typeArgs.get(0).type(),
typeArgs.get(0).getTypeArgs().clone(), item); typeArgs.get(0).typeArgs().clone(), item);
// Move item into the set. // Move item into the set.
Reference<RowBuffer> tempReference_Row3 = Reference<RowBuffer> tempReference_Row3 =
@@ -195,7 +194,7 @@ public final class WriteRowDispatcher implements IDispatcher {
new Reference<RowCursor>(setScope); new Reference<RowCursor>(setScope);
Reference<RowCursor> tempReference_tempCursor = Reference<RowCursor> tempReference_tempCursor =
new Reference<RowCursor>(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)); tempReference_tempCursor));
tempCursor = tempReference_tempCursor.get(); tempCursor = tempReference_tempCursor.get();
setScope = tempReference_setScope.get(); setScope = tempReference_setScope.get();
@@ -206,24 +205,24 @@ public final class WriteRowDispatcher implements IDispatcher {
public void DispatchTuple(Reference<RowOperationDispatcher> dispatcher, public void DispatchTuple(Reference<RowOperationDispatcher> dispatcher,
Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs, Reference<RowCursor> scope, LayoutType t, TypeArgumentList typeArgs,
Object value) { Object value) {
checkArgument(typeArgs.getCount() >= 2); checkArgument(typeArgs.count() >= 2);
Reference<RowBuffer> tempReference_Row = Reference<RowBuffer> tempReference_Row =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor tupleScope; RowCursor tupleScope;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // 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: // 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)); out tupleScope));
dispatcher.get().argValue.Row = tempReference_Row.get(); 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)); 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 // 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 // cannot be converted using the 'Ref' helper class unless the method is within the code being
// modified: // modified:
dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).getType(), dispatcher.get().LayoutCodeSwitch(ref tupleScope, null, typeArgs.get(i).type(),
typeArgs.get(i).getTypeArgs().clone(), valueAccessor.GetValue(value)); typeArgs.get(i).typeArgs().clone(), valueAccessor.GetValue(value));
Reference<RowBuffer> tempReference_Row2 = Reference<RowBuffer> tempReference_Row2 =
new Reference<RowBuffer>(dispatcher.get().Row); new Reference<RowBuffer>(dispatcher.get().Row);
tupleScope.MoveNext(tempReference_Row2); tupleScope.MoveNext(tempReference_Row2);
@@ -237,7 +236,7 @@ public final class WriteRowDispatcher implements IDispatcher {
Reference<RowBuffer> tempReference_Row = new Reference<RowBuffer>(dispatcher.get().Row); Reference<RowBuffer> tempReference_Row = new Reference<RowBuffer>(dispatcher.get().Row);
RowCursor udtScope; RowCursor udtScope;
Out<RowCursor> tempOut_udtScope = new Out<RowCursor>(); 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(); udtScope = tempOut_udtScope.get();
dispatcher.get().argValue.Row = tempReference_Row.get(); dispatcher.get().argValue.Row = tempReference_Row.get();
IDispatchable valueDispatcher = value instanceof IDispatchable ? (IDispatchable)value : null; IDispatchable valueDispatcher = value instanceof IDispatchable ? (IDispatchable)value : null;