Progressed on port from dotnet to java

This commit is contained in:
David Noble
2019-08-28 20:26:25 -07:00
parent 20ad953fcd
commit 1ac2c33a15
38 changed files with 1584 additions and 1553 deletions

View File

@@ -7,7 +7,6 @@ package com.azure.data.cosmos.core;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.SerializerProvider;
@@ -17,7 +16,6 @@ import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.google.common.base.Utf8;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.Unpooled;
import javax.annotation.Nonnull;
@@ -44,7 +42,6 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
public static final Utf8String EMPTY = new Utf8String(Unpooled.EMPTY_BUFFER, 0);
public static final Utf8String NULL = new Utf8String();
private static final PooledByteBufAllocator allocator = PooledByteBufAllocator.DEFAULT;
private final ByteBuf buffer;
private final int length;
@@ -303,7 +300,7 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
}
final int length = Utf8.encodedLength(string);
final ByteBuf buffer = allocator.buffer(length, length);
final ByteBuf buffer = Unpooled.wrappedBuffer(new byte[length]);
final int count = buffer.writeCharSequence(string, UTF_8);
checkState(count == length, "count: %s, length: %s", count, length);
@@ -400,24 +397,24 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
// 110xxxxx 10xxxxxx => 0x00000080 - 0x000007FF
codePoint = ((leadingByte & 0b0001_1111) << 6) |
(buffer.getByte(this.index++) & 0b0011_1111);
(this.buffer.getByte(this.index++) & 0b0011_1111);
} else if ((leadingByte & 0b1111_0000) == 0b1110_0000) {
// 1110xxxx 10xxxxxx 10xxxxxx => 0x00000800 - 0x0000FFFF
codePoint = ((leadingByte & 0b0000_1111) << 12) |
((buffer.getByte(this.index++) & 0b0011_1111) << 6) |
((buffer.getByte(this.index++) & 0b0011_1111));
((this.buffer.getByte(this.index++) & 0b0011_1111) << 6) |
((this.buffer.getByte(this.index++) & 0b0011_1111));
} else if ((leadingByte & 0b1111_1000) == 0b1111_0000) {
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx => 0x00010000 - 0x001FFFFF
codePoint = ((leadingByte & 0b0000_0111) << 18) |
((buffer.getByte(this.index++) & 0b0011_1111) << 12) |
((buffer.getByte(this.index++) & 0b0011_1111) << 6) |
((buffer.getByte(this.index++) & 0b0011_1111));
((this.buffer.getByte(this.index++) & 0b0011_1111) << 12) |
((this.buffer.getByte(this.index++) & 0b0011_1111) << 6) |
((this.buffer.getByte(this.index++) & 0b0011_1111));
} else {
// leading byte is improperly encoded and we'll detect that before returning
@@ -460,8 +457,7 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
}
@Override
public Utf8String deserialize(JsonParser parser, DeserializationContext context) throws IOException,
JsonProcessingException {
public Utf8String deserialize(JsonParser parser, DeserializationContext context) throws IOException {
final JsonNode node = parser.getCodec().readTree(parser);
final JsonNodeType type = node.getNodeType();

View File

@@ -5,47 +5,39 @@
package com.azure.data.cosmos.serialization.hybridrow;
/**
* Describes the header the precedes all valid Hybrid Rows.
* Describes the header that precedes all valid Hybrid Rows.
*/
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [StructLayout(LayoutKind.Sequential, Pack = 1)] public readonly struct HybridRowHeader
//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: [StructLayout(LayoutKind.Sequential, Pack = 1)] public readonly struct HybridRowHeader
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct:
public final class HybridRowHeader {
/**
* Size (in bytes) of a serialized header.
*/
public static final int SIZE = (HybridRowVersion.SIZE / Byte.SIZE) + com.azure.data.cosmos.serialization.hybridrow.SchemaId.SIZE;
/**
* The unique identifier of the schema whose layout was used to write this row.
*/
private SchemaId SchemaId = new SchemaId();
/**
* The version of the HybridRow library used to write this row.
*/
private HybridRowVersion Version = HybridRowVersion.values()[0];
public static final int SIZE = (HybridRowVersion.SIZE / Byte.SIZE) + SchemaId.SIZE;
private SchemaId schemaId;
private HybridRowVersion version = HybridRowVersion.values()[0];
/**
* Initializes a new instance of the {@link HybridRowHeader} struct.
* Initializes a new instance of a {@link HybridRowHeader}
*
* @param version The version of the HybridRow library used to write this row.
* @param schemaId The unique identifier of the schema whose layout was used to write this row.
*/
public HybridRowHeader() {
}
public HybridRowHeader(HybridRowVersion version, SchemaId schemaId) {
this.Version = version;
this.SchemaId = schemaId.clone();
this.version = version;
this.schemaId = new SchemaId(schemaId.id());
}
public SchemaId getSchemaId() {
return SchemaId;
/**
* The unique identifier of the schema whose layout was used to write this row.
*/
public SchemaId schemaId() {
return this.schemaId;
}
public HybridRowVersion getVersion() {
return Version;
/**
* The version of the HybridRow library used to write this row.
*/
public HybridRowVersion version() {
return this.version;
}
}

View File

@@ -4,16 +4,15 @@
package com.azure.data.cosmos.serialization.hybridrow;
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
///#pragma warning disable CA1028 // Enum Storage should be Int32
import java.util.HashMap;
/**
* Versions of HybridRow.
* Versions of HybridRow
* <p>
* A version from this list MUST be inserted in the version BOM at the beginning of all rows.
*/
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public enum HybridRowVersion : byte
public enum HybridRowVersion {
Invalid((byte)0),
/**
@@ -23,18 +22,18 @@ public enum HybridRowVersion {
public static final int SIZE = java.lang.Byte.SIZE;
private static java.util.HashMap<Byte, HybridRowVersion> mappings;
private byte byteValue;
private byte value;
HybridRowVersion(byte value) {
byteValue = value;
this.value = value;
getMappings().put(value, this);
}
public byte getValue() {
return byteValue;
public byte value() {
return this.value;
}
public static HybridRowVersion forValue(byte value) {
public static HybridRowVersion from(byte value) {
return getMappings().get(value);
}
@@ -42,7 +41,7 @@ public enum HybridRowVersion {
if (mappings == null) {
synchronized (HybridRowVersion.class) {
if (mappings == null) {
mappings = new java.util.HashMap<Byte, HybridRowVersion>();
mappings = new HashMap<>();
}
}
}

View File

@@ -4,7 +4,6 @@
package com.azure.data.cosmos.serialization.hybridrow;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.UtfAnyString;
import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope;
@@ -18,53 +17,42 @@ import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList;
import static com.google.common.base.Strings.lenientFormat;
public final class RowCursor {
public final class RowCursor implements Cloneable {
/**
* If existing, the layout code of the existing field, otherwise undefined.
*/
public LayoutType cellType;
/**
* For types with generic parameters (e.g. {@link LayoutTuple}, the type parameters.
*/
public TypeArgumentList cellTypeArgs;
/**
* If true, this scope is an unique index scope whose index will be built after its items are written.
*/
public boolean deferUniqueIndex;
/**
* If existing, the offset to the end of the existing field. Used as a hint when skipping
* forward.
*/
public int endOffset;
/**
* True if an existing field matching the search criteria was found.
*/
public boolean exists;
/**
* If existing, the offset scope relative path for reading.
*/
public int pathOffset;
/**
* If existing, the layout string token of scope relative path for reading.
*/
public int pathToken;
private LayoutType cellType;
private TypeArgumentList cellTypeArgs;
private int count;
private boolean deferUniqueIndex;
private int endOffset;
private boolean exists;
private boolean immutable;
private int index;
private Layout layout;
private int metaOffset;
private int pathOffset;
private int pathToken;
private LayoutScope scopeType;
private TypeArgumentList scopeTypeArgs;
private int start;
private int valueOffset;
private UtfAnyString writePath;
private StringToken writePathToken = new StringToken();
private StringToken writePathToken;
private RowCursor() {
}
protected RowCursor clone() {
try {
return (RowCursor) super.clone();
} catch (CloneNotSupportedException error) {
throw new IllegalStateException(error);
}
}
public static RowCursor Create(RowBuffer row) {
final SchemaId schemaId = row.ReadSchemaId(1);
final Layout layout = row.resolver().Resolve(schemaId);
final Layout layout = row.resolver().resolve(schemaId);
final int sparseSegmentOffset = row.computeVariableValueOffset(layout, HybridRowHeader.SIZE, layout.numVariable());
return new RowCursor()
@@ -79,7 +67,7 @@ public final class RowCursor {
public static RowCursor CreateForAppend(RowBuffer row) {
final SchemaId schemaId = row.ReadSchemaId(1);
final Layout layout = row.resolver().Resolve(schemaId);
final Layout layout = row.resolver().resolve(schemaId);
return new RowCursor()
.layout(layout)
@@ -90,11 +78,30 @@ public final class RowCursor {
.valueOffset(row.length());
}
/**
* If existing, the layout code of the existing field, otherwise undefined.
*/
public LayoutType cellType() {
return this.cellType;
}
public RowCursor cellType(LayoutType cellType) {
this.cellType = cellType;
return this;
}
/**
* For types with generic parameters (e.g. {@link LayoutTuple}, the type parameters.
*/
public TypeArgumentList cellTypeArgs() {
return this.cellTypeArgs;
}
/**
* For sized scopes (e.g. Typed Array), the number of elements.
*/
public int count() {
return count;
return this.count;
}
public RowCursor count(int count) {
@@ -102,13 +109,45 @@ public final class RowCursor {
return this;
}
/**
* If true, this scope is an unique index scope whose index will be built after its items are written.
*/
public boolean deferUniqueIndex() {
return this.deferUniqueIndex;
}
/**
* If existing, the offset to the end of the existing field. Used as a hint when skipping
* forward.
*/
public int endOffset() {
return this.endOffset;
}
public RowCursor endOffset(int endOffset) {
this.endOffset = endOffset;
return this;
}
/**
* True if an existing field matching the search criteria was found.
*/
public boolean exists() {
return this.exists;
}
public RowCursor exists(boolean exists) {
this.exists = exists;
return this;
}
/**
* 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;
return this.immutable;
}
public RowCursor immutable(boolean immutable) {
@@ -120,7 +159,7 @@ public final class RowCursor {
* For indexed scopes (e.g. an Array scope), the zero-based index into the scope of the sparse field
*/
public int index() {
return index;
return this.index;
}
public RowCursor index(int index) {
@@ -132,7 +171,7 @@ public final class RowCursor {
* The layout describing the contents of the scope, or {@code null} if the scope is unschematized.
*/
public Layout layout() {
return layout;
return this.layout;
}
public RowCursor layout(Layout layout) {
@@ -145,7 +184,7 @@ public final class RowCursor {
* insert a new field.
*/
public int metaOffset() {
return metaOffset;
return this.metaOffset;
}
public RowCursor metaOffset(int metaOffset) {
@@ -153,11 +192,25 @@ public final class RowCursor {
return this;
}
/**
* If existing, the offset scope relative path for reading.
*/
public int pathOffset() {
return this.pathOffset;
}
/**
* If existing, the layout string token of scope relative path for reading.
*/
public int pathToken() {
return this.pathToken;
}
/**
* The kind of scope within which this edit was prepared
*/
public LayoutScope scopeType() {
return scopeType;
return this.scopeType;
}
public RowCursor scopeType(LayoutScope scopeType) {
@@ -169,7 +222,7 @@ public final class RowCursor {
* The type parameters of the scope within which this edit was prepared
*/
public TypeArgumentList scopeTypeArgs() {
return scopeTypeArgs;
return this.scopeTypeArgs;
}
public RowCursor scopeTypeArgs(TypeArgumentList scopeTypeArgs) {
@@ -182,7 +235,7 @@ public final class RowCursor {
* the scope begins.
*/
public int start() {
return start;
return this.start;
}
public RowCursor start(int start) {
@@ -203,9 +256,9 @@ public final class RowCursor {
? TypeArgument.NONE
: new TypeArgument(this.scopeType(), this.scopeTypeArgs());
TypeArgument typeArg = (this.cellType == null) || (this.cellType instanceof LayoutEndScope)
TypeArgument typeArg = (this.cellType() == null) || (this.cellType() instanceof LayoutEndScope)
? TypeArgument.NONE
: new TypeArgument(this.cellType, this.cellTypeArgs);
: new TypeArgument(this.cellType(), this.cellTypeArgs());
String pathOrIndex = this.writePath().isNull() ? String.valueOf(this.index()) : this.writePath().toString();
@@ -226,7 +279,7 @@ public final class RowCursor {
* If existing, the offset to the value of the existing field, otherwise undefined.
*/
public int valueOffset() {
return valueOffset;
return this.valueOffset;
}
public RowCursor valueOffset(int valueOffset) {
@@ -238,7 +291,7 @@ public final class RowCursor {
* If existing, the scope relative path for writing.
*/
public UtfAnyString writePath() {
return writePath;
return this.writePath;
}
public void writePath(UtfAnyString writePath) {
@@ -249,7 +302,7 @@ public final class RowCursor {
* If WritePath is tokenized, then its token.
*/
public StringToken writePathToken() {
return writePathToken;
return this.writePathToken;
}
public void writePathToken(StringToken writePathToken) {

View File

@@ -1,128 +0,0 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
package com.azure.data.cosmos.serialization.hybridrow;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope;
import static com.google.common.base.Preconditions.checkArgument;
public final class RowCursorExtensions {
/** Makes a copy of the current cursor.
The two cursors will have independent and unconnected lifetimes after cloning. However,
mutations to a {@link RowBuffer} can invalidate any active cursors over the same row.
*/
// TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter:
// public static ref RowCursor Clone(this in RowCursor src, out RowCursor dest)
// {
// dest = src;
// return ref dest;
// }
/**
* Returns an equivalent scope that is read-only.
*/
// TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter:
// public static ref RowCursor AsReadOnly(this in RowCursor src, out RowCursor dest)
// {
// dest = src;
// dest.immutable = true;
// return ref dest;
// }
// TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter:
// public static ref RowCursor Find(this ref RowCursor edit, ref RowBuffer row, UtfAnyString path)
// {
// Contract.Requires(!edit.scopeType.IsIndexedScope);
//
// if (!(edit.cellType is LayoutEndScope))
// {
// while (row.SparseIteratorMoveNext(ref edit))
// {
// if (path.Equals(row.ReadSparsePath(ref edit)))
// {
// edit.exists = true;
// break;
// }
// }
// }
//
// edit.writePath = path;
// edit.writePathToken = default;
// return ref edit;
// }
// TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter:
// public static ref RowCursor Find(this ref RowCursor edit, ref RowBuffer row, in StringToken pathToken)
// {
// Contract.Requires(!edit.scopeType.IsIndexedScope);
//
// if (!(edit.cellType is LayoutEndScope))
// {
// while (row.SparseIteratorMoveNext(ref edit))
// {
// if (pathToken.Id == (ulong)edit.pathToken)
// {
// edit.exists = true;
// break;
// }
// }
// }
//
// edit.writePath = pathToken.Path;
// edit.writePathToken = pathToken;
// return ref edit;
// }
public static boolean MoveNext(Reference<RowCursor> edit, Reference<RowBuffer> row) {
edit.get().writePath(null);
edit.get().writePathToken(null);
return row.get().SparseIteratorMoveNext(edit);
}
public static boolean MoveNext(Reference<RowCursor> edit, Reference<RowBuffer> row,
Reference<RowCursor> childScope) {
if (childScope.get().scopeType() != null) {
RowCursorExtensions.Skip(edit.get().clone(), row, childScope);
}
return RowCursorExtensions.MoveNext(edit.get().clone(), row);
}
public static boolean MoveTo(Reference<RowCursor> edit, Reference<RowBuffer> row, int index) {
checkState(edit.get().index() <= index);
edit.get().writePath(null);
edit.get().writePathToken(null);
while (edit.get().index() < index) {
if (!row.get().SparseIteratorMoveNext(edit)) {
return false;
}
}
return true;
}
public static void Skip(Reference<RowCursor> edit, Reference<RowBuffer> row,
Reference<RowCursor> childScope) {
checkArgument(childScope.get().start() == edit.get().valueOffset());
if (!(childScope.get().cellType instanceof LayoutEndScope)) {
while (row.get().SparseIteratorMoveNext(childScope)) {
}
}
if (childScope.get().scopeType().isSizedScope()) {
edit.get().endOffset = childScope.get().metaOffset();
} else {
edit.get().endOffset = childScope.get().metaOffset() + (LayoutCode.SIZE / Byte.SIZE); // Move past the end of scope marker.
}
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
//#if DEBUG
childScope.setAndGet(null);
//#endif
}
}

View File

@@ -0,0 +1,127 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
package com.azure.data.cosmos.serialization.hybridrow;
import com.azure.data.cosmos.core.UtfAnyString;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope;
import com.azure.data.cosmos.serialization.hybridrow.layouts.StringToken;
import javax.annotation.Nonnull;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
public final class RowCursors {
private RowCursors() {
}
public static RowCursor Find(@Nonnull RowCursor edit, @Nonnull RowBuffer row, @Nonnull UtfAnyString path) {
checkArgument(!edit.scopeType().isIndexedScope());
if (!(edit.cellType() instanceof LayoutEndScope)) {
while (row.sparseIteratorMoveNext(edit)) {
if (path.equals(row.readSparsePath(edit))) {
edit.exists(true);
break;
}
}
}
edit.writePath(path);
edit.writePathToken(null);
return edit;
}
public static RowCursor Find(@Nonnull RowCursor edit, @Nonnull RowBuffer row, @Nonnull StringToken pathToken) {
checkNotNull(edit);
checkNotNull(row);
checkNotNull(pathToken);
checkArgument(!edit.scopeType().isIndexedScope());
if (!(edit.cellType() instanceof LayoutEndScope)) {
while (row.sparseIteratorMoveNext(edit)) {
if (pathToken.id() == (long) edit.pathToken()) {
edit.exists(true);
break;
}
}
}
edit.writePath(new UtfAnyString(pathToken.path()));
edit.writePathToken(pathToken);
return edit;
}
/**
* Returns an equivalent scope that is read-only.
*/
public static RowCursor asReadOnly(RowCursor src) {
return src.clone().immutable(true);
}
/**
* Makes a copy of the current cursor.
* <p>
* The two cursors will have independent and unconnected lifetimes after cloning. However, mutations to a
* {@link RowBuffer} can invalidate any active cursors over the same row.
*/
public static RowCursor copy(RowCursor source) {
return source.clone();
}
public static boolean moveNext(RowCursor edit, RowBuffer row) {
edit.writePath(null);
edit.writePathToken(null);
return row.sparseIteratorMoveNext(edit);
}
public static boolean moveNext(@Nonnull RowCursor edit, @Nonnull RowBuffer row, @Nonnull RowCursor childScope) {
if (childScope.scopeType() != null) {
RowCursors.skip(edit.clone(), row, childScope);
}
return RowCursors.moveNext(edit.clone(), row);
}
public static boolean moveTo(@Nonnull final RowCursor edit, @Nonnull final RowBuffer row, final int index) {
checkNotNull(row);
checkNotNull(edit);
checkArgument(edit.index() <= index);
edit.writePath(null);
edit.writePathToken(null);
while (edit.index() < index) {
if (!row.sparseIteratorMoveNext(edit)) {
return false;
}
}
return true;
}
public static void skip(RowCursor edit, RowBuffer row, RowCursor childScope) {
checkArgument(childScope.start() == edit.valueOffset());
if (!(childScope.cellType() instanceof LayoutEndScope)) {
//noinspection StatementWithEmptyBody
while (row.sparseIteratorMoveNext(childScope)) {
}
}
if (childScope.scopeType().isSizedScope()) {
edit.endOffset(childScope.metaOffset());
} else {
edit.endOffset(childScope.metaOffset() + (LayoutCode.SIZE / Byte.SIZE)); // move past end of scope marker
}
}
}

View File

@@ -27,9 +27,12 @@ import static com.google.common.base.Strings.lenientFormat;
@JsonSerialize(using = SchemaId.JsonSerializer.class)
public final class SchemaId {
// TODO: DANOBLE: Consider caching SchemaId instances to reduce memory footprint
public static final SchemaId INVALID = null;
public static final SchemaId NONE = new SchemaId();
public static final SchemaId NONE = new SchemaId(-1);
public static final int SIZE = (Integer.SIZE / Byte.SIZE);
private static long MAX_VALUE = 0x00000000FFFFFFFFL;
private final int id;
@@ -38,14 +41,10 @@ public final class SchemaId {
*
* @param id The underlying globally unique identifier of the schema.
*/
public SchemaId(int id) {
private SchemaId(int id) {
this.id = id;
}
private SchemaId() {
this.id = -1;
}
@Override
public boolean equals(Object other) {
return other instanceof SchemaId && this.equals((SchemaId) other);
@@ -75,7 +74,16 @@ public final class SchemaId {
* @return The integer value of this {@link SchemaId}
*/
public int id() {
return id;
return this.id;
}
/**
* Returns a {@link SchemaId} from a specified underlying integer value
*
* @return The integer value of this {@link SchemaId}
*/
public static SchemaId from(int id) {
return new SchemaId(id);
}
@Override

View File

@@ -13,7 +13,7 @@ import com.azure.data.cosmos.serialization.hybridrow.NullValue;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import com.azure.data.cosmos.serialization.hybridrow.RowCursors;
import com.azure.data.cosmos.serialization.hybridrow.UnixDateTime;
import com.azure.data.cosmos.serialization.hybridrow.layouts.ILayoutSpanReadable;
import com.azure.data.cosmos.serialization.hybridrow.layouts.ILayoutUtf8SpanReadable;
@@ -67,14 +67,12 @@ public final class RowReader {
private int columnIndex;
private ReadOnlySpan<LayoutColumn> columns;
private RowCursor cursor = new RowCursor();
private RowBuffer row = new RowBuffer();
private RowCursor cursor;
private RowBuffer row;
private int schematizedCount;
private States state; // checkpoint state
// State that can be checkpointed.
private States state = States.values()[0];
public RowReader() {
private RowReader() {
}
/**
@@ -140,7 +138,7 @@ public final class RowReader {
return true;
case Sparse:
if (this.cursor.cellType instanceof LayoutNullable) {
if (this.cursor.cellType() instanceof LayoutNullable) {
Reference<RowCursor> cursor = new Reference<>(this.cursor);
RowCursor nullableScope = this.row.SparseIteratorReadScope(cursor, true).clone();
this.cursor = cursor.get();
@@ -193,13 +191,13 @@ public final class RowReader {
case Schematized:
return this.columns[this.columnIndex].Path;
case Sparse:
if (this.cursor.pathOffset == 0) {
if (this.cursor.pathOffset() == 0) {
return null;
}
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
Utf8Span span = this.row.ReadSparsePath(tempReference_cursor);
Utf8Span span = this.row.readSparsePath(tempReference_cursor);
this.cursor = tempReference_cursor.get();
return Utf8String.CopyFrom(span);
default:
@@ -219,7 +217,7 @@ public final class RowReader {
case Sparse:
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
Utf8Span tempVar = this.row.ReadSparsePath(tempReference_cursor);
Utf8Span tempVar = this.row.readSparsePath(tempReference_cursor);
this.cursor = tempReference_cursor.get();
return tempVar;
default:
@@ -249,7 +247,7 @@ public final class RowReader {
case Schematized:
return this.columns[this.columnIndex].Type;
case Sparse:
return this.cursor.cellType;
return this.cursor.cellType();
default:
return null;
}
@@ -263,7 +261,7 @@ public final class RowReader {
case Schematized:
return this.columns[this.columnIndex].TypeArgs;
case Sparse:
return this.cursor.cellTypeArgs.clone();
return this.cursor.cellTypeArgs().clone();
default:
return TypeArgumentList.EMPTY;
}
@@ -314,7 +312,7 @@ public final class RowReader {
Reference<RowBuffer> tempReference_row = new Reference<RowBuffer>(this.row);
if (!RowCursorExtensions.MoveNext(this.cursor.clone(),
if (!RowCursors.moveNext(this.cursor.clone(),
tempReference_row)) {
this.row = tempReference_row.get();
this.state = States.Done;
@@ -368,7 +366,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutBinary)) {
if (!(this.cursor.cellType() instanceof LayoutBinary)) {
value.setAndGet(null);
return Result.TypeMismatch;
}
@@ -395,7 +393,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutBoolean)) {
if (!(this.cursor.cellType() instanceof LayoutBoolean)) {
value.setAndGet(false);
return Result.TypeMismatch;
}
@@ -422,7 +420,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutDateTime)) {
if (!(this.cursor.cellType() instanceof LayoutDateTime)) {
value.setAndGet(LocalDateTime.MIN);
return Result.TypeMismatch;
}
@@ -449,7 +447,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutDecimal)) {
if (!(this.cursor.cellType() instanceof LayoutDecimal)) {
value.setAndGet(new BigDecimal(0));
return Result.TypeMismatch;
}
@@ -476,7 +474,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value.clone());
case Sparse:
if (!(this.cursor.cellType instanceof LayoutFloat128)) {
if (!(this.cursor.cellType() instanceof LayoutFloat128)) {
value.setAndGet(null);
return Result.TypeMismatch;
}
@@ -503,7 +501,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutFloat32)) {
if (!(this.cursor.cellType() instanceof LayoutFloat32)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -530,7 +528,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutFloat64)) {
if (!(this.cursor.cellType() instanceof LayoutFloat64)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -557,7 +555,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutGuid)) {
if (!(this.cursor.cellType() instanceof LayoutGuid)) {
value.setAndGet(null);
return Result.TypeMismatch;
}
@@ -584,7 +582,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutInt16)) {
if (!(this.cursor.cellType() instanceof LayoutInt16)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -611,7 +609,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutInt32)) {
if (!(this.cursor.cellType() instanceof LayoutInt32)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -638,7 +636,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutInt64)) {
if (!(this.cursor.cellType() instanceof LayoutInt64)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -665,7 +663,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutInt8)) {
if (!(this.cursor.cellType() instanceof LayoutInt8)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -692,7 +690,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value.clone());
case Sparse:
if (!(this.cursor.cellType instanceof LayoutMongoDbObjectId)) {
if (!(this.cursor.cellType() instanceof LayoutMongoDbObjectId)) {
value.setAndGet(null);
return Result.TypeMismatch;
}
@@ -719,14 +717,14 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value.clone());
case Sparse:
if (!(this.cursor.cellType instanceof LayoutNull)) {
if (!(this.cursor.cellType() instanceof LayoutNull)) {
value.setAndGet(null);
return Result.TypeMismatch;
}
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseNull(tempReference_cursor).clone());
value.setAndGet(this.row.readSparseNull(tempReference_cursor).clone());
this.cursor = tempReference_cursor.get();
return Result.Success;
default:
@@ -785,7 +783,7 @@ public final class RowReader {
new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor2 =
new Reference<RowCursor>(nestedReader.cursor);
RowCursorExtensions.Skip(this.cursor.clone(), tempReference_row2,
RowCursors.skip(this.cursor.clone(), tempReference_row2,
tempReference_cursor2);
nestedReader.cursor = tempReference_cursor2.get();
this.row = tempReference_row2.get();
@@ -835,7 +833,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutUtf8)) {
if (!(this.cursor.cellType() instanceof LayoutUtf8)) {
value.setAndGet(null);
return Result.TypeMismatch;
}
@@ -864,7 +862,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutUInt16)) {
if (!(this.cursor.cellType() instanceof LayoutUInt16)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -893,7 +891,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutUInt32)) {
if (!(this.cursor.cellType() instanceof LayoutUInt32)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -922,7 +920,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutUInt64)) {
if (!(this.cursor.cellType() instanceof LayoutUInt64)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -951,7 +949,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutUInt8)) {
if (!(this.cursor.cellType() instanceof LayoutUInt8)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -978,7 +976,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value.clone());
case Sparse:
if (!(this.cursor.cellType instanceof LayoutUnixDateTime)) {
if (!(this.cursor.cellType() instanceof LayoutUnixDateTime)) {
value.setAndGet(null);
return Result.TypeMismatch;
}
@@ -1005,7 +1003,7 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutVarInt)) {
if (!(this.cursor.cellType() instanceof LayoutVarInt)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
@@ -1034,14 +1032,14 @@ public final class RowReader {
case Schematized:
return this.ReadPrimitiveValue(value);
case Sparse:
if (!(this.cursor.cellType instanceof LayoutVarUInt)) {
if (!(this.cursor.cellType() instanceof LayoutVarUInt)) {
value.setAndGet(0);
return Result.TypeMismatch;
}
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseVarUInt(tempReference_cursor));
value.setAndGet(this.row.readSparseVarUInt(tempReference_cursor));
this.cursor = tempReference_cursor.get();
return Result.Success;
default:
@@ -1072,7 +1070,7 @@ public final class RowReader {
new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(nestedReader.get().cursor);
RowCursorExtensions.Skip(this.cursor.clone(), tempReference_row,
RowCursors.skip(this.cursor.clone(), tempReference_row,
tempReference_cursor);
nestedReader.get().argValue.cursor = tempReference_cursor.get();
this.row = tempReference_row.get();

View File

@@ -12,7 +12,7 @@ import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.UnixDateTime;
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import com.azure.data.cosmos.serialization.hybridrow.RowCursors;
import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutResolver;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType;
@@ -491,7 +491,7 @@ public final class RowWriter {
//ORIGINAL LINE: case LayoutUDT scopeType:
case LayoutUDT
scopeType:
Layout udt = this.row.resolver().Resolve(typeArg.typeArgs().schemaId().clone());
Layout udt = this.row.resolver().resolve(typeArg.typeArgs().schemaId().clone());
Reference<RowCursor> tempReference_cursor9 =
new Reference<RowCursor>(this.cursor);
Out<RowCursor> tempOut_nestedScope9 =
@@ -569,7 +569,7 @@ public final class RowWriter {
new Reference<RowBuffer>(this.row);
Reference<RowCursor> tempReference_cursor12 =
new Reference<RowCursor>(nestedWriter.cursor);
RowCursorExtensions.MoveNext(this.cursor.clone(), tempReference_row2
RowCursors.moveNext(this.cursor.clone(), tempReference_row2
, tempReference_cursor12);
nestedWriter.cursor = tempReference_cursor12.get();
this.row = tempReference_row2.get();
@@ -815,7 +815,7 @@ public final class RowWriter {
this = tempReference_this.get();
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(this.row);
RowCursorExtensions.MoveNext(this.cursor.clone(),
RowCursors.moveNext(this.cursor.clone(),
tempReference_row);
this.row = tempReference_row.get();
}
@@ -854,7 +854,7 @@ public final class RowWriter {
this = tempReference_this.get();
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(this.row);
RowCursorExtensions.MoveNext(this.cursor.clone(),
RowCursors.moveNext(this.cursor.clone(),
tempReference_row);
this.row = tempReference_row.get();
}
@@ -893,7 +893,7 @@ public final class RowWriter {
this = tempReference_this.get();
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(this.row);
RowCursorExtensions.MoveNext(this.cursor.clone(),
RowCursors.moveNext(this.cursor.clone(),
tempReference_row);
this.row = tempReference_row.get();
}
@@ -933,7 +933,7 @@ public final class RowWriter {
this = tempReference_this.get();
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(this.row);
RowCursorExtensions.MoveNext(this.cursor.clone(),
RowCursors.moveNext(this.cursor.clone(),
tempReference_row);
this.row = tempReference_row.get();
}

View File

@@ -29,7 +29,7 @@ import java.util.HashMap;
*/
public final class Layout {
public static final Layout EMPTY = SystemSchema.LayoutResolver.Resolve(SystemSchema.EmptySchemaId);
public static final Layout EMPTY = SystemSchema.LayoutResolver.resolve(SystemSchema.EmptySchemaId);
private final String name;
private final int numBitmaskBytes;

View File

@@ -51,7 +51,7 @@ public final class LayoutNull extends LayoutType<NullValue> {
return result;
}
value.setAndGet(b.get().ReadSparseNull(edit).clone());
value.setAndGet(b.get().readSparseNull(edit).clone());
return Result.Success;
}

View File

@@ -7,5 +7,5 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
public abstract class LayoutResolver {
public abstract Layout Resolve(SchemaId schemaId);
public abstract Layout resolve(SchemaId schemaId);
}

View File

@@ -44,7 +44,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
}
@Override
public Layout Resolve(SchemaId schemaId) {
public Layout resolve(SchemaId schemaId) {
Layout layout;
// TODO: C# TO JAVA CONVERTER: There is no Java ConcurrentHashMap equivalent to this .NET
// ConcurrentDictionary method:
@@ -63,7 +63,7 @@ public final class LayoutResolverNamespace extends LayoutResolver {
}
}
layout = this.parent == null ? null : this.parent.Resolve(schemaId.clone());
layout = this.parent == null ? null : this.parent.resolve(schemaId.clone());
if (layout != null) {
// TODO: C# TO JAVA CONVERTER: There is no Java ConcurrentHashMap equivalent to this .NET
// ConcurrentDictionary method:

View File

@@ -14,7 +14,7 @@ public final class LayoutResolverSimple extends LayoutResolver {
}
@Override
public Layout Resolve(SchemaId schemaId) {
public Layout resolve(SchemaId schemaId) {
return this.resolver.invoke(schemaId.clone());
}
}

View File

@@ -9,9 +9,13 @@ import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import com.azure.data.cosmos.serialization.hybridrow.RowCursors;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import javax.annotation.Nonnull;
import static com.google.common.base.Preconditions.checkNotNull;
public abstract class LayoutScope extends LayoutType {
private boolean isFixedArity;
@@ -81,13 +85,14 @@ public abstract class LayoutScope extends LayoutType {
}
/**
* Returns true if writing an item in the specified typed scope would elide the type code
* because it is implied by the type arguments.
* {@code true} if writing an item in the specified typed scope would elide the type code because it is implied by the
* type arguments
*
* @param edit
* @return True if the type code is implied (not written), false otherwise.
* @param edit a non-null {@link RowCursor} specifying a typed scope
* @return {@code true} if the type code is implied (not written); {@code false} otherwise.
*/
public boolean HasImplicitTypeCode(Reference<RowCursor> edit) {
public boolean hasImplicitTypeCode(@Nonnull final RowCursor edit) {
checkNotNull(edit, "expected non-null edit");
return false;
}
@@ -163,7 +168,7 @@ public abstract class LayoutScope extends LayoutType {
Reference<RowCursor> tempReference_childScope2 =
new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(scope.get().clone(), b,
RowCursors.skip(scope.get().clone(), b,
tempReference_childScope2);
childScope = tempReference_childScope2.get();
return Result.Success;

View File

@@ -147,7 +147,7 @@ public abstract class LayoutType<T> implements ILayoutType {
if (exists) {
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
col.getOffset());
b.get().DeleteVariable(varOffset, this.isVarint());
b.get().deleteVariable(varOffset, this.isVarint());
b.get().UnsetBit(scope.get().start(), col.getNullBit().clone());
}
@@ -196,7 +196,7 @@ public abstract class LayoutType<T> implements ILayoutType {
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;
}
@@ -236,7 +236,7 @@ public abstract class LayoutType<T> implements ILayoutType {
return result;
}
if (!srcEdit.get().exists) {
if (!srcEdit.get().exists()) {
dstEdit.setAndGet(null);
return Result.NotFound;
}
@@ -247,7 +247,7 @@ public abstract class LayoutType<T> implements ILayoutType {
return Result.InsufficientPermissions;
}
if (!srcEdit.get().cellTypeArgs.equals(elementType.typeArgs())) {
if (!srcEdit.get().cellTypeArgs().equals(elementType.typeArgs())) {
b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null);
return Result.TypeConstraint;
@@ -261,13 +261,13 @@ public abstract class LayoutType<T> implements ILayoutType {
// Prepare the insertion at the destination.
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);
dstEdit.setAndGet(null);
return Result.NotFound;
}
if ((options == UpdateOptions.Insert) && dstEdit.get().exists) {
if ((options == UpdateOptions.Insert) && dstEdit.get().exists()) {
b.get().deleteSparse(srcEdit);
dstEdit.setAndGet(null);
return Result.Exists;
@@ -286,11 +286,11 @@ public abstract class LayoutType<T> implements ILayoutType {
*/
public static Result prepareSparseRead(Reference<RowBuffer> b, Reference<RowCursor> edit, LayoutCode code) {
if (!edit.get().exists) {
if (!edit.get().exists()) {
return Result.NotFound;
}
if (LayoutCodeTraits.Canonicalize(edit.get().cellType.layoutCode()) != code) {
if (LayoutCodeTraits.Canonicalize(edit.get().cellType().layoutCode()) != code) {
return Result.TypeMismatch;
}
@@ -308,7 +308,7 @@ public abstract class LayoutType<T> implements ILayoutType {
*/
public static Result prepareSparseWrite(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgument typeArg, UpdateOptions options) {
if (edit.get().immutable() || (edit.get().scopeType().isUniqueScope() && !edit.get().deferUniqueIndex)) {
if (edit.get().immutable() || (edit.get().scopeType().isUniqueScope() && !edit.get().deferUniqueIndex())) {
return Result.InsufficientPermissions;
}
@@ -332,11 +332,11 @@ public abstract class LayoutType<T> implements ILayoutType {
edit.get().exists = false; // InsertAt never overwrites an existing item.
}
if ((options == UpdateOptions.Update) && (!edit.get().exists)) {
if ((options == UpdateOptions.Update) && (!edit.get().exists())) {
return Result.NotFound;
}
if ((options == UpdateOptions.Insert) && edit.get().exists) {
if ((options == UpdateOptions.Insert) && edit.get().exists()) {
return Result.Exists;
}

View File

@@ -45,7 +45,7 @@ public final class LayoutUDT extends LayoutPropertyScope {
@Override
public Result WriteScope(Reference<RowBuffer> b, Reference<RowCursor> edit,
TypeArgumentList typeArgs, Out<RowCursor> value, UpdateOptions options) {
Layout udt = b.get().resolver().Resolve(typeArgs.schemaId().clone());
Layout udt = b.get().resolver().resolve(typeArgs.schemaId().clone());
Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options);
if (result != Result.Success) {
value.setAndGet(null);

View File

@@ -10,7 +10,7 @@ import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.RowOptions;
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import com.azure.data.cosmos.serialization.hybridrow.RowCursors;
public abstract class LayoutUniqueScope extends LayoutIndexedScope {
protected LayoutUniqueScope(LayoutCode code, boolean immutable, boolean isSizedScope, boolean isTypedScope) {
@@ -140,7 +140,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
Reference<RowCursor> tempReference_childScope2 =
new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(scope.get().clone(), b,
RowCursors.skip(scope.get().clone(), b,
tempReference_childScope2);
childScope = tempReference_childScope2.get();
return Result.Success;

View File

@@ -52,7 +52,7 @@ public final class LayoutVarUInt extends LayoutType<Long> {
return result;
}
value.setAndGet(b.get().ReadSparseVarUInt(edit));
value.setAndGet(b.get().readSparseVarUInt(edit));
return Result.Success;
}

View File

@@ -5,43 +5,67 @@
package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.core.Utf8String;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import javax.annotation.Nonnull;
import static com.google.common.base.Preconditions.checkNotNull;
public final class StringToken implements Cloneable {
public long id;
public Utf8String path;
public byte[] varint;
public static final StringToken NONE = new StringToken();
public StringToken() {
}
private final long id;
private final Utf8String path;
private final ByteBuf varint;
public StringToken(long id, Utf8String path) {
this.varint = new byte[StringToken.Count7BitEncodedUInt(id)];
StringToken.Write7BitEncodedUInt(this.varint, id);
public StringToken(long id, @Nonnull Utf8String path) {
checkNotNull(path);
byte[] buffer = new byte[count7BitEncodedUInt(id)];
StringToken.write7BitEncodedUInt(buffer, id);
this.varint = Unpooled.wrappedBuffer(buffer).asReadOnly();
this.path = path;
this.id = id;
}
private StringToken() {
this.id = 0L;
this.path = Utf8String.EMPTY;
this.varint = Unpooled.wrappedBuffer(new byte[1]).setInt(0, 0).asReadOnly();
}
public boolean isNull() {
return this.varint() == null;
}
public long id() {
return this.id;
}
public Utf8String path() {
return this.path;
}
public ByteBuf varint() {
return this.varint;
}
@Override
public StringToken clone() {
protected StringToken clone() {
try {
final StringToken token = (StringToken)super.clone();
token.id = this.id;
token.path = this.path;
token.varint = this.varint;
return token;
return (StringToken) super.clone();
} catch (CloneNotSupportedException error) {
assert false : error;
throw new IllegalStateException(error);
}
}
public boolean isNull() {
return this.varint == null;
}
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.
int i = 0;
@@ -54,7 +78,7 @@ public final class StringToken implements Cloneable {
return ++i;
}
private static int Write7BitEncodedUInt(byte[] buffer, long value) {
private static int write7BitEncodedUInt(byte[] buffer, long value) {
// Write an unsigned long 7 bits at a time. The high bit of the byte, when set, indicates there are more bytes.
int i = 0;

View File

@@ -4,7 +4,6 @@
package com.azure.data.cosmos.serialization.hybridrow.layouts;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Utf8String;
import com.azure.data.cosmos.core.UtfAnyString;
@@ -44,18 +43,10 @@ public final class StringTokenizer {
* Looks up a token's corresponding string.
*
* @param token The token to look up.
* @param path If successful, the token's assigned string.
* @return True if successful, false otherwise.
*/
public boolean tryFindString(long token, Out<Utf8String> path) {
if (token >= (long)this.strings.size()) {
path.setAndGet(null);
return false;
}
path.setAndGet(this.strings.get((int) token));
return true;
public Optional<Utf8String> tryFindString(long token) {
return token >= (long)this.strings.size() ? Optional.empty() : Optional.of(this.strings.get((int) token));
}
/**
@@ -112,7 +103,7 @@ public final class StringTokenizer {
this.tokens.put(path, token);
this.strings.add(path);
checkState((long)this.strings.size() - 1 == token.id);
checkState((long)this.strings.size() - 1 == token.id());
return token;
}
}

View File

@@ -64,7 +64,7 @@ public final class RecordIOFormatter {
private static <T> Result FormatObject(ISpanResizer<Byte> resizer, int initialCapacity, Layout layout, T obj,
RowWriter.WriterFunc<T> writer, Out<RowBuffer> row) {
row.setAndGet(new RowBuffer(initialCapacity, resizer));
row.get().InitLayout(HybridRowVersion.V1, layout, SystemSchema.LayoutResolver);
row.get().initLayout(HybridRowVersion.V1, layout, SystemSchema.LayoutResolver);
Result r = RowWriter.WriteBuffer(row.clone(), obj, writer);
if (r != Result.Success) {
row.setAndGet(null);

View File

@@ -140,7 +140,7 @@ public final class BsonRowGenerator implements Closeable {
this.writer.WriteStartDocument();
HashMap<Utf8String, Object> dict = (HashMap<Utf8String, Object>)value;
Layout udt = this.resolver.Resolve(typeArg.typeArgs().schemaId().clone());
Layout udt = this.resolver.resolve(typeArg.typeArgs().schemaId().clone());
for (LayoutColumn c : udt.columns()) {
this.LayoutCodeSwitch(c.getPath(), c.getTypeArg().clone(), dict.get(c.getPath()));
}

View File

@@ -11,7 +11,7 @@ import com.azure.data.cosmos.serialization.hybridrow.ISpanResizer;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import com.azure.data.cosmos.serialization.hybridrow.RowCursors;
import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutColumn;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutResolver;
@@ -50,7 +50,7 @@ public final class CodeGenRowGenerator {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
public CodeGenRowGenerator(int capacity, Layout layout, LayoutResolver resolver, ISpanResizer<Byte> resizer) {
this.row = new RowBuffer(capacity, resizer);
this.row.InitLayout(HybridRowVersion.V1, layout, resolver);
this.row.initLayout(HybridRowVersion.V1, layout, resolver);
switch (layout.name()) {
case "Hotels":
@@ -95,8 +95,8 @@ public final class CodeGenRowGenerator {
}
public void Reset() {
Layout layout = this.row.resolver().Resolve(this.row.header().getSchemaId().clone());
this.row.InitLayout(HybridRowVersion.V1, layout, this.row.resolver());
Layout layout = this.row.resolver().resolve(this.row.header().schemaId().clone());
this.row.initLayout(HybridRowVersion.V1, layout, this.row.resolver());
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
@@ -157,7 +157,7 @@ public final class CodeGenRowGenerator {
Out<StringToken> tempOut_postalCodeToken = new Out<StringToken>();
layout.getTokenizer().TryFindToken(this.postalCode.getPath(), tempOut_postalCodeToken);
this.postalCodeToken = tempOut_postalCodeToken.get();
this.postalCodeSerializer = new PostalCodeHybridRowSerializer(resolver.Resolve(this.postalCode.getTypeArgs().schemaId().clone()), resolver);
this.postalCodeSerializer = new PostalCodeHybridRowSerializer(resolver.resolve(this.postalCode.getTypeArgs().schemaId().clone()), resolver);
}
@Override
@@ -200,7 +200,7 @@ public final class CodeGenRowGenerator {
}
Reference<RowCursor> tempReference_childScope2 = new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(root.get().clone(), row, tempReference_childScope2);
RowCursors.skip(root.get().clone(), row, tempReference_childScope2);
childScope = tempReference_childScope2.get();
return Result.Success;
}
@@ -269,7 +269,7 @@ public final class CodeGenRowGenerator {
}
Reference<RowCursor> tempReference_childScope2 = new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(root.get().clone(), row, tempReference_childScope2);
RowCursors.skip(root.get().clone(), row, tempReference_childScope2);
childScope = tempReference_childScope2.get();
}
@@ -353,7 +353,7 @@ public final class CodeGenRowGenerator {
this.addresses.getTypeArgs().clone()) });
this.addressSerializer =
new AddressHybridRowSerializer(resolver.Resolve(this.addresses.getTypeArgs().get(1).typeArgs().schemaId().clone()), resolver);
new AddressHybridRowSerializer(resolver.resolve(this.addresses.getTypeArgs().get(1).typeArgs().schemaId().clone()), resolver);
this.addressSerializerWriter = (Reference<RowBuffer> b, Reference<RowCursor> scope,
HashMap<Utf8String, Object> context) -> addressSerializer.WriteBuffer(b,
scope, context);
@@ -422,7 +422,7 @@ public final class CodeGenRowGenerator {
Reference<RowCursor> tempReference_childScope =
new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(root.get().clone(), row,
RowCursors.skip(root.get().clone(), row,
tempReference_childScope);
childScope = tempReference_childScope.get();
root.get().Find(row, this.phoneNumbersToken.clone());
@@ -450,7 +450,7 @@ public final class CodeGenRowGenerator {
Reference<RowCursor> tempReference_childScope2 =
new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(root.get().clone(), row,
RowCursors.skip(root.get().clone(), row,
tempReference_childScope2);
childScope = tempReference_childScope2.get();
root.get().Find(row, this.addressesToken.clone());
@@ -527,7 +527,7 @@ public final class CodeGenRowGenerator {
Reference<RowCursor> tempReference_childScope4 =
new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(root.get().clone(), row,
RowCursors.skip(root.get().clone(), row,
tempReference_childScope4);
childScope = tempReference_childScope4.get();
@@ -665,7 +665,7 @@ public final class CodeGenRowGenerator {
}
Reference<RowCursor> tempReference_childScope = new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(root.get().clone(), row, tempReference_childScope);
RowCursors.skip(root.get().clone(), row, tempReference_childScope);
childScope = tempReference_childScope.get();
}
@@ -796,7 +796,7 @@ public final class CodeGenRowGenerator {
layout.getTokenizer().TryFindToken(this.address.getPath(), tempOut_addressToken);
this.addressToken = tempOut_addressToken.get();
this.addressSerializer =
new AddressHybridRowSerializer(resolver.Resolve(this.address.getTypeArgs().schemaId().clone()),
new AddressHybridRowSerializer(resolver.resolve(this.address.getTypeArgs().schemaId().clone()),
resolver);
}
@@ -849,7 +849,7 @@ public final class CodeGenRowGenerator {
Reference<RowCursor> tempReference_childScope2 =
new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(root.get().clone(), row,
RowCursors.skip(root.get().clone(), row,
tempReference_childScope2);
childScope = tempReference_childScope2.get();
return Result.Success;
@@ -925,7 +925,7 @@ public final class CodeGenRowGenerator {
}
Reference<RowCursor> tempReference_childScope2 = new Reference<RowCursor>(childScope);
RowCursorExtensions.Skip(root.get().clone(), row, tempReference_childScope2);
RowCursors.skip(root.get().clone(), row, tempReference_childScope2);
childScope = tempReference_childScope2.get();
}

View File

@@ -44,7 +44,7 @@ public final class JsonModelRowGenerator {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
public JsonModelRowGenerator(int capacity, Layout layout, LayoutResolver resolver, ISpanResizer<Byte> resizer) {
this.row = new RowBuffer(capacity, resizer);
this.row.InitLayout(HybridRowVersion.V1, layout, resolver);
this.row.initLayout(HybridRowVersion.V1, layout, resolver);
}
public int getLength() {
@@ -62,12 +62,12 @@ public final class JsonModelRowGenerator {
// TODO: C# TO JAVA CONVERTER: C# to Java Converter cannot determine whether this System.IO.Stream is input or
// output:
public boolean ReadFrom(InputStream stream, int length) {
return this.row.ReadFrom(stream, length, HybridRowVersion.V1, this.row.resolver());
return this.row.readFrom(stream, length, HybridRowVersion.V1, this.row.resolver());
}
public void Reset() {
Layout layout = this.row.resolver().Resolve(this.row.header().getSchemaId().clone());
this.row.InitLayout(HybridRowVersion.V1, layout, this.row.resolver());
Layout layout = this.row.resolver().resolve(this.row.header().schemaId().clone());
this.row.initLayout(HybridRowVersion.V1, layout, this.row.resolver());
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:

View File

@@ -6,12 +6,11 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import com.azure.data.cosmos.serialization.hybridrow.RowCursors;
import java.nio.file.Files;
import java.util.ArrayList;
@@ -46,7 +45,7 @@ public final class CustomerExampleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateGuest()
public void CreateGuest() {
RowBuffer row = new RowBuffer(1024 * 1024);
row.InitLayout(HybridRowVersion.V1, this.guestLayout, this.customerResolver);
row.initLayout(HybridRowVersion.V1, this.guestLayout, this.customerResolver);
Guest g1 = new Guest();
g1.Id = UUID.fromString("64d9d6d3-fd6b-4556-8c6e-d960a7ece7b9");
@@ -184,7 +183,7 @@ public final class CustomerExampleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateHotel()
public void CreateHotel() {
RowBuffer row = new RowBuffer(0);
row.InitLayout(HybridRowVersion.V1, this.hotelLayout, this.customerResolver);
row.initLayout(HybridRowVersion.V1, this.hotelLayout, this.customerResolver);
Hotel h1 = this.hotelExample;
Reference<RowBuffer> tempReference_row =
@@ -218,7 +217,7 @@ public final class CustomerExampleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void FrozenHotel()
public void FrozenHotel() {
RowBuffer row = new RowBuffer(0);
row.InitLayout(HybridRowVersion.V1, this.hotelLayout, this.customerResolver);
row.initLayout(HybridRowVersion.V1, this.hotelLayout, this.customerResolver);
Hotel h1 = this.hotelExample;
Reference<RowBuffer> tempReference_row =
@@ -435,7 +434,7 @@ public final class CustomerExampleUnitTests {
postalCodeScope = tempReference_postalCodeScope.get();
Reference<RowCursor> tempReference_postalCodeScope2 =
new Reference<RowCursor>(postalCodeScope);
RowCursorExtensions.Skip(addressScope.get().clone(), row,
RowCursors.skip(addressScope.get().clone(), row,
tempReference_postalCodeScope2);
postalCodeScope = tempReference_postalCodeScope2.get();
return a;
@@ -556,13 +555,13 @@ public final class CustomerExampleUnitTests {
tempReference_addressesScope2, tempOut_pairScope));
pairScope = tempOut_pairScope.get();
addressesScope = tempReference_addressesScope2.get();
assert RowCursorExtensions.MoveNext(pairScope.clone(), row);
assert RowCursors.moveNext(pairScope.clone(), row);
Reference<RowCursor> tempReference_pairScope2 = new Reference<RowCursor>(pairScope);
String key;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
ResultAssert.IsSuccess(t0.<LayoutUtf8>TypeAs().ReadSparse(row, tempReference_pairScope2, out key));
pairScope = tempReference_pairScope2.get();
assert RowCursorExtensions.MoveNext(pairScope.clone(), row);
assert RowCursors.moveNext(pairScope.clone(), row);
Reference<RowCursor> tempReference_pairScope3 = new Reference<RowCursor>(pairScope);
RowCursor addressScope;
Out<RowCursor> tempOut_addressScope = new Out<RowCursor>();
@@ -574,7 +573,7 @@ public final class CustomerExampleUnitTests {
addressScope = tempReference_addressScope.get();
g.Addresses.put(key, value);
Reference<RowCursor> tempReference_addressScope2 = new Reference<RowCursor>(addressScope);
assert !RowCursorExtensions.MoveNext(pairScope.clone(), row, tempReference_addressScope2);
assert !RowCursors.moveNext(pairScope.clone(), row, tempReference_addressScope2);
addressScope = tempReference_addressScope2.get();
}
pairScope = tempReference_pairScope.get();
@@ -621,7 +620,7 @@ public final class CustomerExampleUnitTests {
addressScope = tempReference_addressScope.get();
Reference<RowCursor> tempReference_addressScope2 =
new Reference<RowCursor>(addressScope);
RowCursorExtensions.Skip(root.get().clone(), row,
RowCursors.skip(root.get().clone(), row,
tempReference_addressScope2);
addressScope = tempReference_addressScope2.get();
return h;
@@ -684,7 +683,7 @@ public final class CustomerExampleUnitTests {
postalCodeScope = tempReference_postalCodeScope.get();
Reference<RowCursor> tempReference_postalCodeScope2 =
new Reference<RowCursor>(postalCodeScope);
RowCursorExtensions.Skip(addressScope.get().clone(), row,
RowCursors.skip(addressScope.get().clone(), row,
tempReference_postalCodeScope2);
postalCodeScope = tempReference_postalCodeScope2.get();
}
@@ -733,7 +732,7 @@ public final class CustomerExampleUnitTests {
Reference<RowCursor> tempReference_emailScope =
new Reference<RowCursor>(emailScope);
RowCursorExtensions.Skip(root.get().clone(), row,
RowCursors.skip(root.get().clone(), row,
tempReference_emailScope);
emailScope = tempReference_emailScope.get();
}
@@ -761,7 +760,7 @@ public final class CustomerExampleUnitTests {
Reference<RowCursor> tempReference_phoneNumbersScope =
new Reference<RowCursor>(phoneNumbersScope);
RowCursorExtensions.Skip(root.get().clone(), row,
RowCursors.skip(root.get().clone(), row,
tempReference_phoneNumbersScope);
phoneNumbersScope = tempReference_phoneNumbersScope.get();
}
@@ -830,7 +829,7 @@ public final class CustomerExampleUnitTests {
Reference<RowCursor> tempReference_addressesScope =
new Reference<RowCursor>(addressesScope);
RowCursorExtensions.Skip(root.get().clone(), row,
RowCursors.skip(root.get().clone(), row,
tempReference_addressesScope);
addressesScope = tempReference_addressesScope.get();
}
@@ -865,7 +864,7 @@ public final class CustomerExampleUnitTests {
addressScope = tempReference_addressScope.get();
Reference<RowCursor> tempReference_addressScope2 =
new Reference<RowCursor>(addressScope);
RowCursorExtensions.Skip(root.get().clone(), row,
RowCursors.skip(root.get().clone(), row,
tempReference_addressScope2);
addressScope = tempReference_addressScope2.get();
}

View File

@@ -10,7 +10,7 @@ import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import com.azure.data.cosmos.serialization.hybridrow.RowCursors;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutColumn;
import java.nio.file.Files;
@@ -37,7 +37,7 @@ public final class NullableUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateNullables()
public void CreateNullables() {
RowBuffer row = new RowBuffer(NullableUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Nullables t1 = new Nullables();
t1.NullBool = new ArrayList<Boolean>(Arrays.asList(true, false, null));
@@ -125,7 +125,7 @@ public final class NullableUnitTests {
return r;
}
if (RowCursorExtensions.MoveNext(nullableScope.get().clone(), row)) {
if (RowCursors.moveNext(nullableScope.get().clone(), row)) {
ResultAssert.IsSuccess(LayoutNullable.HasValue(row, nullableScope.clone()));
return itemType.getTypeArgs().get(0).getType().<LayoutType<TValue>>TypeAs().ReadSparse(row,
nullableScope.clone(), item);
@@ -267,7 +267,7 @@ public final class NullableUnitTests {
tupleScope = tempOut_tupleScope.get();
scope = tempReference_scope4.get();
assert RowCursorExtensions.MoveNext(tupleScope.clone()
assert RowCursors.moveNext(tupleScope.clone()
, row);
Reference<RowCursor> tempReference_tupleScope2 =
new Reference<RowCursor>(tupleScope);
@@ -283,7 +283,7 @@ public final class NullableUnitTests {
tupleScope = tempReference_tupleScope2.get();
Reference<RowCursor> tempReference_nullableScope4 =
new Reference<RowCursor>(nullableScope);
assert RowCursorExtensions.MoveNext(tupleScope.clone()
assert RowCursors.moveNext(tupleScope.clone()
, row, tempReference_nullableScope4);
nullableScope = tempReference_nullableScope4.get();
Reference<RowCursor> tempReference_tupleScope3 =
@@ -300,7 +300,7 @@ public final class NullableUnitTests {
Reference<RowCursor> tempReference_nullableScope5 =
new Reference<RowCursor>(nullableScope);
assert !RowCursorExtensions.MoveNext(tupleScope.clone(), row, tempReference_nullableScope5);
assert !RowCursors.moveNext(tupleScope.clone(), row, tempReference_nullableScope5);
nullableScope = tempReference_nullableScope5.get();
value.NullTuple.add((item1, item2))
}
@@ -339,7 +339,7 @@ public final class NullableUnitTests {
tupleScope = tempOut_tupleScope2.get();
scope = tempReference_scope5.get();
assert RowCursorExtensions.MoveNext(tupleScope.clone()
assert RowCursors.moveNext(tupleScope.clone()
, row);
Reference<RowCursor> tempReference_tupleScope5 =
new Reference<RowCursor>(tupleScope);
@@ -356,7 +356,7 @@ public final class NullableUnitTests {
Reference<RowCursor> tempReference_nullableScope6 =
new Reference<RowCursor>(nullableScope);
assert RowCursorExtensions.MoveNext(tupleScope.clone()
assert RowCursors.moveNext(tupleScope.clone()
, row, tempReference_nullableScope6);
nullableScope = tempReference_nullableScope6.get();
Reference<RowCursor> tempReference_tupleScope6 =
@@ -373,7 +373,7 @@ public final class NullableUnitTests {
Reference<RowCursor> tempReference_nullableScope7 =
new Reference<RowCursor>(nullableScope);
assert !RowCursorExtensions.MoveNext(tupleScope.clone(), row, tempReference_nullableScope7);
assert !RowCursors.moveNext(tupleScope.clone(), row, tempReference_nullableScope7);
nullableScope = tempReference_nullableScope7.get();
value.NullMap.put(itemKey != null ? itemKey : UUID.Empty, itemValue);
}

View File

@@ -227,7 +227,7 @@ public class RecordIOUnitTests {
private Result WriteAddress(MemorySpanResizer<Byte> resizer, Address obj,
Out<ReadOnlyMemory<Byte>> buffer) {
RowBuffer row = new RowBuffer(RecordIOUnitTests.InitialRowSize, resizer);
row.InitLayout(HybridRowVersion.V1, this.addressLayout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.addressLayout, this.resolver);
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(row);
Result r = RowWriter.WriteBuffer(tempReference_row, obj, AddressSerializer.Write);

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Float128;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.NullValue;
@@ -72,7 +71,7 @@ public final class RowOperationDispatcher {
this.dispatcher = dispatcher;
this.Row = new RowBuffer(RowOperationDispatcher.InitialRowSize);
this.Resolver = resolver;
this.Row.InitLayout(HybridRowVersion.V1, layout, this.Resolver);
this.Row.initLayout(HybridRowVersion.V1, layout, this.Resolver);
}
private RowOperationDispatcher(IDispatcher dispatcher, LayoutResolver resolver, String expected) {
@@ -82,7 +81,7 @@ public final class RowOperationDispatcher {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] bytes = ByteConverter.ToBytes(expected);
byte[] bytes = ByteConverter.ToBytes(expected);
this.Row.ReadFrom(bytes, HybridRowVersion.V1, this.Resolver);
this.Row.readFrom(bytes, HybridRowVersion.V1, this.Resolver);
}
// TODO: C# TO JAVA CONVERTER: The C# 'struct' constraint has no equivalent in Java:

View File

@@ -197,7 +197,7 @@ public final class RowReaderUnitTests {
RowBuffer row = new RowBuffer(0, resizer);
Layout layout = this.resolver.Resolve(tangible.ListHelper.find(this.schema.getSchemas(), x -> x.Name.equals(
"Mixed")).SchemaId);
row.InitLayout(HybridRowVersion.V1, layout, this.resolver);
row.initLayout(HybridRowVersion.V1, layout, this.resolver);
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(row);

View File

@@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.Float128;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.NullValue;
@@ -52,7 +51,7 @@ public final class RowWriterUnitTests {
assert layout != null;
RowBuffer row = new RowBuffer(RowWriterUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, layout, this.resolver);
row.initLayout(HybridRowVersion.V1, layout, this.resolver);
int writerLength = 0;
Reference<RowBuffer> tempReference_row =

View File

@@ -66,7 +66,7 @@ public final class SerializerUnitTest {
// Write the request by serializing it to a row.
RowBuffer row = new RowBuffer(SerializerUnitTest.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(row);
Result r = RowWriter.WriteBuffer(tempReference_row, request, BatchRequestSerializer.Write);

View File

@@ -4,7 +4,6 @@
package com.azure.data.cosmos.serialization.hybridrow.unit;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result;
@@ -26,7 +25,7 @@ public final class TaggedUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateTaggedApi()
public void CreateTaggedApi() {
RowBuffer row = new RowBuffer(TaggedUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
TaggedApi c1 = new TaggedApi();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:

View File

@@ -34,7 +34,7 @@ public final class TupleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateCoordCounter()
public void CreateCoordCounter() {
RowBuffer row = new RowBuffer(TupleUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
row.initLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
PerfCounter c1 = new PerfCounter();
c1.Name = "CoordInserts";
@@ -70,7 +70,7 @@ public final class TupleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateCounter()
public void CreateCounter() {
RowBuffer row = new RowBuffer(TupleUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
row.initLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
PerfCounter c1 = this.counterExample;
Reference<RowBuffer> tempReference_row =
@@ -100,7 +100,7 @@ public final class TupleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateMinMeanMaxCounter()
public void CreateMinMeanMaxCounter() {
RowBuffer row = new RowBuffer(TupleUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
row.initLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
PerfCounter c1 = new PerfCounter();
c1.Name = "RowInserts";
@@ -135,7 +135,7 @@ public final class TupleUnitTests {
RowBuffer row = new RowBuffer(TupleUnitTests.InitialRowSize);
Layout layout = this.countersResolver.Resolve(tangible.ListHelper.find(this.counterSchema.getSchemas(),
x -> x.Name.equals("CounterSet")).SchemaId);
row.InitLayout(HybridRowVersion.V1, layout, this.countersResolver);
row.initLayout(HybridRowVersion.V1, layout, this.countersResolver);
LayoutColumn col;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
@@ -280,7 +280,7 @@ public final class TupleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void PreventInsertsAndDeletesInFixedArityCounter()
public void PreventInsertsAndDeletesInFixedArityCounter() {
RowBuffer row = new RowBuffer(TupleUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
row.initLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
PerfCounter c1 = this.counterExample;
Reference<RowBuffer> tempReference_row =
@@ -373,7 +373,7 @@ public final class TupleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void VerifyTypeConstraintsCoordCounter()
public void VerifyTypeConstraintsCoordCounter() {
RowBuffer row = new RowBuffer(TupleUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
row.initLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
PerfCounter c1 = new PerfCounter();
c1.Name = "RowInserts";
@@ -464,7 +464,7 @@ public final class TupleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void VerifyTypeConstraintsCounter()
public void VerifyTypeConstraintsCounter() {
RowBuffer row = new RowBuffer(TupleUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
row.initLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
PerfCounter c1 = this.counterExample;
Reference<RowBuffer> tempReference_row =
@@ -540,7 +540,7 @@ public final class TupleUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void VerifyTypeConstraintsMinMeanMaxCounter()
public void VerifyTypeConstraintsMinMeanMaxCounter() {
RowBuffer row = new RowBuffer(TupleUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
row.initLayout(HybridRowVersion.V1, this.countersLayout, this.countersResolver);
PerfCounter c1 = new PerfCounter();
c1.Name = "RowInserts";
@@ -877,7 +877,7 @@ public final class TupleUnitTests {
}
private static void WriteCoord(Reference<RowBuffer> row, Reference<RowCursor> coordScope, TypeArgumentList typeArgs, Coord cd) {
Layout coordLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone());
Layout coordLayout = row.get().resolver().resolve(typeArgs.getSchemaId().clone());
LayoutColumn c;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
assert coordLayout.TryFind("lat", out c);

View File

@@ -10,7 +10,7 @@ import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion;
import com.azure.data.cosmos.serialization.hybridrow.Result;
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
import com.azure.data.cosmos.serialization.hybridrow.RowCursorExtensions;
import com.azure.data.cosmos.serialization.hybridrow.RowCursors;
import java.nio.file.Files;
import java.util.ArrayList;
@@ -34,7 +34,7 @@ public final class TypedArrayUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateTags()
public void CreateTags() {
RowBuffer row = new RowBuffer(TypedArrayUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Tagged t1 = new Tagged();
t1.Title = "Thriller";
@@ -221,7 +221,7 @@ public final class TypedArrayUnitTests {
ResultAssert.IsSuccess(innerLayout.ReadScope(row, tempReference_ratingsScope, tempOut_innerScope));
innerScope = tempOut_innerScope.get();
ratingsScope = tempReference_ratingsScope.get();
while (RowCursorExtensions.MoveNext(innerScope.clone()
while (RowCursors.moveNext(innerScope.clone()
, row)) {
LayoutFloat64 itemLayout = innerType.getTypeArgs().get(0).getType().<LayoutFloat64>TypeAs();
Reference<RowCursor> tempReference_innerScope2
@@ -299,7 +299,7 @@ public final class TypedArrayUnitTests {
ResultAssert.IsSuccess(innerLayout.ReadScope(row, tempReference_priorityScope, tempOut_tupleScope));
tupleScope = tempOut_tupleScope.get();
priorityScope = tempReference_priorityScope.get();
assert RowCursorExtensions.MoveNext(tupleScope.clone()
assert RowCursors.moveNext(tupleScope.clone()
, row);
Reference<RowCursor> tempReference_tupleScope2 =
new Reference<RowCursor>(tupleScope);
@@ -311,7 +311,7 @@ public final class TypedArrayUnitTests {
tempReference_tupleScope2, out item1));
tupleScope = tempReference_tupleScope2.get();
assert RowCursorExtensions.MoveNext(tupleScope.clone()
assert RowCursors.moveNext(tupleScope.clone()
, row);
Reference<RowCursor> tempReference_tupleScope3 =
new Reference<RowCursor>(tupleScope);
@@ -332,7 +332,7 @@ public final class TypedArrayUnitTests {
private static void WriteSimilarMatch(Reference<RowBuffer> row, Reference<RowCursor> matchScope
, TypeArgumentList typeArgs, SimilarMatch m) {
Layout matchLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone());
Layout matchLayout = row.get().resolver().resolve(typeArgs.getSchemaId().clone());
LayoutColumn c;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:

View File

@@ -35,7 +35,7 @@ public final class TypedMapUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateMovies()
public void CreateMovies() {
RowBuffer row = new RowBuffer(TypedMapUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
// ReSharper disable StringLiteralTypo
Movie t1 = new Movie();
@@ -88,7 +88,7 @@ public final class TypedMapUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void FindAndDelete()
public void FindAndDelete() {
RowBuffer row = new RowBuffer(TypedMapUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(row);
RowCursor root = RowCursor.Create(tempReference_row);
@@ -184,7 +184,7 @@ public final class TypedMapUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void FindInMap()
public void FindInMap() {
RowBuffer row = new RowBuffer(TypedMapUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(row);
RowCursor root = RowCursor.Create(tempReference_row);
@@ -284,7 +284,7 @@ public final class TypedMapUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void PreventUniquenessViolations()
public void PreventUniquenessViolations() {
RowBuffer row = new RowBuffer(TypedMapUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(row);
RowCursor root = RowCursor.Create(tempReference_row);
@@ -475,7 +475,7 @@ public final class TypedMapUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void PreventUpdatesInNonUpdatableScope()
public void PreventUpdatesInNonUpdatableScope() {
RowBuffer row = new RowBuffer(TypedMapUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(row);
RowCursor root = RowCursor.Create(tempReference_row);
@@ -677,7 +677,7 @@ public final class TypedMapUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void UpdateInMap()
public void UpdateInMap() {
RowBuffer row = new RowBuffer(TypedMapUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(row);
RowCursor root = RowCursor.Create(tempReference_row);
@@ -1179,7 +1179,7 @@ public final class TypedMapUnitTests {
}
private static void WriteEarnings(Reference<RowBuffer> row, Reference<RowCursor> udtScope, TypeArgumentList typeArgs, Earnings m) {
Layout udt = row.get().resolver().Resolve(typeArgs.getSchemaId().clone());
Layout udt = row.get().resolver().resolve(typeArgs.getSchemaId().clone());
LayoutColumn c;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
assert udt.TryFind("domestic", out c);

View File

@@ -31,7 +31,7 @@ public final class TypedSetUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void CreateTodos()
public void CreateTodos() {
RowBuffer row = new RowBuffer(TypedSetUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Todo t1 = new Todo();
t1.Attendees = new ArrayList<String>(Arrays.asList("jason", "janice", "joshua"));
@@ -86,7 +86,7 @@ public final class TypedSetUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void FindAndDelete()
public void FindAndDelete() {
RowBuffer row = new RowBuffer(TypedSetUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
ArrayList<UUID> expected = new ArrayList<UUID>(Arrays.asList(UUID.fromString("{4674962B-CE11-4916-81C5" +
"-0421EE36F168}"), UUID.fromString("{7499C40E-7077-45C1-AE5F-3E384966B3B9}"), UUID.fromString("{B7BC39C2" +
@@ -182,7 +182,7 @@ public final class TypedSetUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void FindInSet()
public void FindInSet() {
RowBuffer row = new RowBuffer(TypedSetUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Todo t1 = new Todo();
t1.Attendees = new ArrayList<String>(Arrays.asList("jason", "janice", "joshua"));
@@ -357,7 +357,7 @@ public final class TypedSetUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void PreventUniquenessViolations()
public void PreventUniquenessViolations() {
RowBuffer row = new RowBuffer(TypedSetUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Todo t1 = new Todo();
t1.Attendees = new ArrayList<String>(Arrays.asList("jason"));
@@ -697,7 +697,7 @@ public final class TypedSetUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void PreventUpdatesInNonUpdatableScope()
public void PreventUpdatesInNonUpdatableScope() {
RowBuffer row = new RowBuffer(TypedSetUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
// Write a set and then try to write directly into it.
LayoutColumn c;
@@ -892,7 +892,7 @@ public final class TypedSetUnitTests {
Todo t1 = new Todo();
t1.Projects = new ArrayList<UUID>(permutation);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
Reference<RowBuffer> tempReference_row =
new Reference<RowBuffer>(row);
ResultAssert.IsSuccess(RowWriter.WriteBuffer(tempReference_row, t1, TypedSetUnitTests.SerializeTodo));
@@ -977,7 +977,7 @@ public final class TypedSetUnitTests {
//ORIGINAL LINE: [TestMethod][Owner("jthunter")] public void UpdateInSet()
public void UpdateInSet() {
RowBuffer row = new RowBuffer(TypedSetUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
row.initLayout(HybridRowVersion.V1, this.layout, this.resolver);
ArrayList<UUID> expected = new ArrayList<UUID>(Arrays.asList(UUID.fromString("{4674962B-CE11-4916-81C5" +
"-0421EE36F168}"), UUID.fromString("{7499C40E-7077-45C1-AE5F-3E384966B3B9}"), UUID.fromString("{B7BC39C2" +
@@ -1466,7 +1466,7 @@ public final class TypedSetUnitTests {
}
private static void WriteShoppingItem(Reference<RowBuffer> row, Reference<RowCursor> matchScope, TypeArgumentList typeArgs, ShoppingItem m) {
Layout matchLayout = row.get().resolver().Resolve(typeArgs.getSchemaId().clone());
Layout matchLayout = row.get().resolver().resolve(typeArgs.getSchemaId().clone());
LayoutColumn c;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these cannot be converted using the 'Out' helper class unless the method is within the code being modified:
assert matchLayout.TryFind("label", out c);