mirror of
https://github.com/microsoft/HybridRow.git
synced 2026-01-19 09:23:19 +00:00
Progressed on port from dotnet to java
This commit is contained in:
@@ -11,6 +11,7 @@ import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutScope;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTuple;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutType;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutTypes;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.StringToken;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgument;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.layouts.TypeArgumentList;
|
||||
@@ -26,7 +27,7 @@ public final class RowCursor {
|
||||
/**
|
||||
* For types with generic parameters (e.g. {@link LayoutTuple}, the type parameters.
|
||||
*/
|
||||
public TypeArgumentList cellTypeArgs = new TypeArgumentList();
|
||||
public TypeArgumentList cellTypeArgs;
|
||||
/**
|
||||
* If true, this scope is an unique index scope whose index will be built after its items are written.
|
||||
*/
|
||||
@@ -54,41 +55,39 @@ public final class RowCursor {
|
||||
private Layout layout;
|
||||
private int metaOffset;
|
||||
private LayoutScope scopeType;
|
||||
private TypeArgumentList scopeTypeArgs = new TypeArgumentList();
|
||||
private TypeArgumentList scopeTypeArgs;
|
||||
private int start;
|
||||
private int valueOffset;
|
||||
private UtfAnyString writePath;
|
||||
private StringToken writePathToken = new StringToken();
|
||||
|
||||
public static RowCursor Create(Reference<RowBuffer> row) {
|
||||
public static RowCursor Create(RowBuffer row) {
|
||||
|
||||
final SchemaId schemaId = row.get().ReadSchemaId(1);
|
||||
final Layout layout = row.get().resolver().Resolve(schemaId);
|
||||
final int sparseSegmentOffset = row.get().computeVariableValueOffset(layout, HybridRowHeader.SIZE,
|
||||
layout.numVariable());
|
||||
final SchemaId schemaId = row.ReadSchemaId(1);
|
||||
final Layout layout = row.resolver().Resolve(schemaId);
|
||||
final int sparseSegmentOffset = row.computeVariableValueOffset(layout, HybridRowHeader.SIZE, layout.numVariable());
|
||||
|
||||
final RowCursor cursor = new RowCursor()
|
||||
return new RowCursor()
|
||||
.layout(layout)
|
||||
.scopeType(LayoutType.UDT)
|
||||
.scopeType(LayoutTypes.UDT)
|
||||
.scopeTypeArgs(new TypeArgumentList(schemaId))
|
||||
.start(HybridRowHeader.SIZE)
|
||||
.metaOffset(sparseSegmentOffset)
|
||||
.valueOffset(sparseSegmentOffset);
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public static RowCursor Create(RowBuffer row) {
|
||||
public static RowCursor CreateForAppend(RowBuffer row) {
|
||||
|
||||
final SchemaId schemaId = row.ReadSchemaId(1);
|
||||
final Layout layout = row.Resolver.Resolve(schemaId);
|
||||
final int sparseSegmentOffset = row.computeVariableValueOffset(layout, HybridRowHeader.Size,
|
||||
layout.NumVariable);
|
||||
final Layout layout = row.resolver().Resolve(schemaId);
|
||||
|
||||
return new RowCursor()
|
||||
.layout(layout)
|
||||
.scopeType(LayoutType.UDT)
|
||||
.scopeTypeArgs(new TypeArgumentList(schemaId, HybridRowHeader.SIZE, sparseSegmentOffset, sparseSegmentOffset);
|
||||
.scopeType(LayoutTypes.UDT)
|
||||
.scopeTypeArgs(new TypeArgumentList(schemaId))
|
||||
.start(HybridRowHeader.SIZE)
|
||||
.metaOffset(row.length())
|
||||
.valueOffset(row.length());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,18 +102,6 @@ public final class RowCursor {
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: 'ref return' methods are not converted by C# to Java Converter:
|
||||
// public static ref RowCursor CreateForAppend(ref RowBuffer row, out RowCursor cursor)
|
||||
// {
|
||||
// SchemaId schemaId = row.ReadSchemaId(1);
|
||||
// Layout layout = row.Resolver.Resolve(schemaId);
|
||||
// cursor = new RowCursor { layout = layout, scopeType = LayoutType.UDT, scopeTypeArgs = new
|
||||
// TypeArgumentList(schemaId), start = HybridRowHeader.Size, metaOffset = row.Length, valueOffset = row
|
||||
// .Length};
|
||||
//
|
||||
// return ref cursor;
|
||||
// }
|
||||
|
||||
/**
|
||||
* If {@code true}, this scope's nested fields cannot be updated individually
|
||||
* <p>
|
||||
@@ -213,19 +200,19 @@ public final class RowCursor {
|
||||
}
|
||||
|
||||
TypeArgument scopeTypeArg = (this.scopeType() instanceof LayoutEndScope)
|
||||
? new TypeArgument()
|
||||
: new TypeArgument(this.scopeType(), this.scopeTypeArgs().clone());
|
||||
? TypeArgument.NONE
|
||||
: new TypeArgument(this.scopeType(), this.scopeTypeArgs());
|
||||
|
||||
TypeArgument typeArg = (this.cellType == null) || (this.cellType instanceof LayoutEndScope)
|
||||
? new TypeArgument()
|
||||
: new TypeArgument(this.cellType, this.cellTypeArgs.clone());
|
||||
? TypeArgument.NONE
|
||||
: new TypeArgument(this.cellType, this.cellTypeArgs);
|
||||
|
||||
String pathOrIndex = this.writePath().isNull() ? String.valueOf(this.index()) : this.writePath().toString();
|
||||
|
||||
return lenientFormat("%s[%s] : %s@%s/%s%s",
|
||||
scopeTypeArg.clone(),
|
||||
scopeTypeArg,
|
||||
pathOrIndex,
|
||||
typeArg.clone(),
|
||||
typeArg,
|
||||
this.metaOffset(),
|
||||
this.valueOffset(),
|
||||
this.immutable() ? " immutable" : "");
|
||||
|
||||
@@ -6,6 +6,7 @@ package com.azure.data.cosmos.serialization.hybridrow.io;
|
||||
|
||||
import com.azure.data.cosmos.core.Out;
|
||||
import com.azure.data.cosmos.core.Reference;
|
||||
import com.azure.data.cosmos.core.Utf8String;
|
||||
import com.azure.data.cosmos.core.UtfAnyString;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Float128;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.NullValue;
|
||||
@@ -51,10 +52,6 @@ import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
|
||||
///#pragma warning disable CA1034 // Nested types should not be visible
|
||||
|
||||
|
||||
/**
|
||||
* A forward-only, streaming, field reader for {@link RowBuffer}.
|
||||
* <p>
|
||||
@@ -66,10 +63,6 @@ import static com.google.common.base.Preconditions.checkState;
|
||||
* Modifying a {@link RowBuffer} invalidates any reader or child reader associated with it. In
|
||||
* general {@link RowBuffer}'s should not be mutated while being enumerated.
|
||||
*/
|
||||
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ
|
||||
// from the original:
|
||||
//ORIGINAL LINE: public ref struct RowReader
|
||||
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# ref struct:
|
||||
public final class RowReader {
|
||||
|
||||
private int columnIndex;
|
||||
|
||||
@@ -7,9 +7,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
import com.azure.data.cosmos.core.Utf8String;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.schemas.StorageKind;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
|
||||
//ORIGINAL LINE: [DebuggerDisplay("{FullPath + \": \" + Type.Name + TypeArgs.ToString()}")] public sealed class
|
||||
// LayoutColumn
|
||||
public final class LayoutColumn {
|
||||
/**
|
||||
* For bool fields, 0-based index into the bit mask for the bool value.
|
||||
|
||||
@@ -8,9 +8,15 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public final class TypeArgument {
|
||||
|
||||
public static final TypeArgument NONE = new TypeArgument();
|
||||
private final LayoutType type;
|
||||
private final TypeArgumentList typeArgs;
|
||||
|
||||
private TypeArgument() {
|
||||
this.type = null;
|
||||
this.typeArgs = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the {@link TypeArgument} struct.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user