mirror of
https://github.com/microsoft/HybridRow.git
synced 2026-01-19 17:33:13 +00:00
Progressed on port from dotnet to java
This commit is contained in:
@@ -15,6 +15,7 @@ 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.ByteBufHolder;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -37,7 +38,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
@JsonSerialize(using = Utf8String.JsonSerializer.class)
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public final class Utf8String implements CharSequence, Comparable<Utf8String> {
|
||||
public final class Utf8String implements ByteBufHolder, CharSequence, Comparable<Utf8String> {
|
||||
|
||||
public static final Utf8String EMPTY = new Utf8String(Unpooled.EMPTY_BUFFER, 0);
|
||||
public static final Utf8String NULL = new Utf8String();
|
||||
@@ -74,6 +75,114 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
|
||||
return this.buffer == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the read-only {@link ByteBuf} holding the content of this {@link Utf8String}
|
||||
* <p>
|
||||
* A value of {@code null} is returns, if this {@link Utf8String} is null.
|
||||
* @return reference to the read-only {@link ByteBuf} holding the content of this {@link Utf8String}.
|
||||
*/
|
||||
@Nullable
|
||||
public ByteBuf content() {
|
||||
return this.buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a deep copy of this {@link Utf8String}
|
||||
*/
|
||||
@Override
|
||||
public Utf8String copy() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicates this {@link Utf8String}
|
||||
* <p>
|
||||
* Be aware that this will not automatically call {@link #retain()}.
|
||||
*/
|
||||
@Override
|
||||
public Utf8String duplicate() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicates this {@link Utf8String}
|
||||
* <p>
|
||||
* This method returns a retained duplicate unlike {@link #duplicate()}.
|
||||
*
|
||||
* @see ByteBuf#retainedDuplicate()
|
||||
*/
|
||||
@Override
|
||||
public Utf8String retainedDuplicate() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link Utf8String} which contains the specified {@code content}
|
||||
*
|
||||
* @param content text of the {@link Utf8String} to be created.
|
||||
*/
|
||||
@Override
|
||||
public Utf8String replace(ByteBuf content) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reference count of this {@link Utf8String}
|
||||
* <p>
|
||||
* If {@code 0}, it means this object has been deallocated.
|
||||
*/
|
||||
@Override
|
||||
public int refCnt() {
|
||||
return this.buffer.refCnt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Utf8String retain() {
|
||||
this.buffer.retain();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Utf8String retain(int increment) {
|
||||
this.buffer.retain(increment);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Utf8String touch() {
|
||||
this.buffer.touch();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Utf8String touch(Object hint) {
|
||||
this.buffer.touch(hint);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decreases the reference count by {@code 1} and deallocates this object if the reference count reaches at
|
||||
* {@code 0}.
|
||||
*
|
||||
* @return {@code true} if and only if the reference count became {@code 0} and this object has been deallocated
|
||||
*/
|
||||
@Override
|
||||
public boolean release() {
|
||||
return this.buffer.release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Decreases the reference count by the specified {@code decrement} and deallocates this object if the reference
|
||||
* count reaches at {@code 0}.
|
||||
*
|
||||
* @param decrement
|
||||
* @return {@code true} if and only if the reference count became {@code 0} and this object has been deallocated
|
||||
*/
|
||||
@Override
|
||||
public boolean release(int decrement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char charAt(final int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
@@ -296,7 +405,7 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
|
||||
private final int length;
|
||||
private int index;
|
||||
|
||||
public CodePointIterable(final ByteBuf buffer, final int length) {
|
||||
CodePointIterable(final ByteBuf buffer, final int length) {
|
||||
this.buffer = buffer;
|
||||
this.length = length;
|
||||
this.index = 0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -52,7 +52,7 @@ public final class RowCursor implements Cloneable {
|
||||
|
||||
final SchemaId schemaId = row.readSchemaId(1);
|
||||
final Layout layout = row.resolver().resolve(schemaId);
|
||||
final int sparseSegmentOffset = row.computeVariableValueOffset(layout, HybridRowHeader.SIZE, layout.numVariable());
|
||||
final int sparseSegmentOffset = row.ComputeVariableValueOffset(layout, HybridRowHeader.SIZE, layout.numVariable());
|
||||
|
||||
return new RowCursor()
|
||||
.layout(layout)
|
||||
|
||||
@@ -23,7 +23,7 @@ public final class RowCursors {
|
||||
|
||||
if (!(edit.cellType() instanceof LayoutEndScope)) {
|
||||
while (row.sparseIteratorMoveNext(edit)) {
|
||||
if (path.equals(row.readSparsePath(edit))) {
|
||||
if (path.equals(row.ReadSparsePath(edit))) {
|
||||
edit.exists(true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -9,89 +9,68 @@ package com.azure.data.cosmos.serialization.hybridrow;
|
||||
* A {@link UnixDateTime} is a fixed length value-type providing millisecond
|
||||
* granularity as a signed offset from the Unix Epoch (midnight, January 1, 1970 UTC).
|
||||
*/
|
||||
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
|
||||
//ORIGINAL LINE: [DebuggerDisplay("{" + nameof(UnixDateTime.Milliseconds) + "}")][StructLayout(LayoutKind.Sequential,
|
||||
// Pack = 1)] public readonly struct UnixDateTime : IEquatable<UnixDateTime>
|
||||
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ
|
||||
// from the original:
|
||||
//ORIGINAL LINE: [DebuggerDisplay("{" + nameof(UnixDateTime.Milliseconds) + "}")][StructLayout(LayoutKind.Sequential,
|
||||
// Pack = 1)] public readonly struct UnixDateTime : IEquatable<UnixDateTime>
|
||||
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct:
|
||||
public final class UnixDateTime implements IEquatable<UnixDateTime> {
|
||||
public final class UnixDateTime {
|
||||
/**
|
||||
* The unix epoch.
|
||||
* {@link UnixDateTime} values are signed values centered on {@link Epoch}.
|
||||
* <para />
|
||||
* This is the same value as default({@link UnixDateTime}).
|
||||
* Unix epoch
|
||||
* <p>
|
||||
* {@link UnixDateTime} values are signed values centered on this value.
|
||||
*/
|
||||
public static final UnixDateTime Epoch = new UnixDateTime();
|
||||
public static final UnixDateTime EPOCH = new UnixDateTime();
|
||||
|
||||
/**
|
||||
* The size (in bytes) of a UnixDateTime.
|
||||
* Size in bytes of a {@link UnixDateTime}
|
||||
*/
|
||||
public static final int Size = (Long.SIZE / Byte.SIZE);
|
||||
/**
|
||||
* The number of milliseconds since {@link Epoch}.
|
||||
* This value may be negative.
|
||||
*/
|
||||
private long Milliseconds;
|
||||
public static final int BYTES = Long.SIZE;
|
||||
|
||||
private long milliseconds;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the {@link UnixDateTime} struct.
|
||||
*
|
||||
* @param milliseconds The number of milliseconds since {@link Epoch}.
|
||||
* @param milliseconds The number of milliseconds since {@link EPOCH}.
|
||||
*/
|
||||
public UnixDateTime() {
|
||||
private UnixDateTime() {
|
||||
}
|
||||
|
||||
public UnixDateTime(long milliseconds) {
|
||||
this.Milliseconds = milliseconds;
|
||||
}
|
||||
|
||||
public long getMilliseconds() {
|
||||
return Milliseconds;
|
||||
this.milliseconds = milliseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is the same value as {@link other}.
|
||||
* {@code> true} if this value is the same as another value
|
||||
*
|
||||
* @param other The value to compare against.
|
||||
* @return True if the two values are the same.
|
||||
* @param other value to compare
|
||||
* @return {code true} if this value is the same as the {code other}
|
||||
*/
|
||||
public boolean equals(UnixDateTime other) {
|
||||
return this.getMilliseconds() == other.getMilliseconds();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link object.Equals(object)} overload.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (null == obj) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj instanceof UnixDateTime && this.equals((UnixDateTime)obj);
|
||||
return this.milliseconds() == other.milliseconds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (null == other) {
|
||||
return false;
|
||||
}
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
return other instanceof UnixDateTime && this.equals((UnixDateTime)other);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link object.GetHashCode} overload.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (new Long(this.getMilliseconds())).hashCode();
|
||||
return Long.valueOf(this.milliseconds).hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Operator == overload.
|
||||
* The number of milliseconds since {@link #EPOCH}
|
||||
* <p>
|
||||
* This value may be negative
|
||||
*/
|
||||
public static boolean opEquals(UnixDateTime left, UnixDateTime right) {
|
||||
return left.equals(right.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
* Operator != overload.
|
||||
*/
|
||||
public static boolean opNotEquals(UnixDateTime left, UnixDateTime right) {
|
||||
return !left.equals(right.clone());
|
||||
public long milliseconds() {
|
||||
return this.milliseconds;
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public final class RowReader {
|
||||
|
||||
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:
|
||||
@@ -216,7 +216,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:
|
||||
@@ -839,7 +839,7 @@ public final class RowReader {
|
||||
|
||||
Reference<RowCursor> tempReference_cursor =
|
||||
new Reference<RowCursor>(this.cursor);
|
||||
value.setAndGet(this.row.ReadSparseString(tempReference_cursor));
|
||||
value.setAndGet(this.row.readSparseString(tempReference_cursor));
|
||||
this.cursor = tempReference_cursor.get();
|
||||
return Result.Success;
|
||||
default:
|
||||
@@ -868,7 +868,7 @@ public final class RowReader {
|
||||
|
||||
Reference<RowCursor> tempReference_cursor =
|
||||
new Reference<RowCursor>(this.cursor);
|
||||
value.setAndGet(this.row.ReadSparseUInt16(tempReference_cursor));
|
||||
value.setAndGet(this.row.readSparseUInt16(tempReference_cursor));
|
||||
this.cursor = tempReference_cursor.get();
|
||||
return Result.Success;
|
||||
default:
|
||||
@@ -897,7 +897,7 @@ public final class RowReader {
|
||||
|
||||
Reference<RowCursor> tempReference_cursor =
|
||||
new Reference<RowCursor>(this.cursor);
|
||||
value.setAndGet(this.row.ReadSparseUInt32(tempReference_cursor));
|
||||
value.setAndGet(this.row.readSparseUInt32(tempReference_cursor));
|
||||
this.cursor = tempReference_cursor.get();
|
||||
return Result.Success;
|
||||
default:
|
||||
@@ -926,7 +926,7 @@ public final class RowReader {
|
||||
|
||||
Reference<RowCursor> tempReference_cursor =
|
||||
new Reference<RowCursor>(this.cursor);
|
||||
value.setAndGet(this.row.ReadSparseUInt64(tempReference_cursor));
|
||||
value.setAndGet(this.row.readSparseUInt64(tempReference_cursor));
|
||||
this.cursor = tempReference_cursor.get();
|
||||
return Result.Success;
|
||||
default:
|
||||
@@ -955,7 +955,7 @@ public final class RowReader {
|
||||
|
||||
Reference<RowCursor> tempReference_cursor =
|
||||
new Reference<RowCursor>(this.cursor);
|
||||
value.setAndGet(this.row.ReadSparseUInt8(tempReference_cursor));
|
||||
value.setAndGet(this.row.readSparseUInt8(tempReference_cursor));
|
||||
this.cursor = tempReference_cursor.get();
|
||||
return Result.Success;
|
||||
default:
|
||||
@@ -982,7 +982,7 @@ public final class RowReader {
|
||||
|
||||
Reference<RowCursor> tempReference_cursor =
|
||||
new Reference<RowCursor>(this.cursor);
|
||||
value.setAndGet(this.row.ReadSparseUnixDateTime(tempReference_cursor).clone());
|
||||
value.setAndGet(this.row.readSparseUnixDateTime(tempReference_cursor).clone());
|
||||
this.cursor = tempReference_cursor.get();
|
||||
return Result.Success;
|
||||
default:
|
||||
@@ -1009,7 +1009,7 @@ public final class RowReader {
|
||||
|
||||
Reference<RowCursor> tempReference_cursor =
|
||||
new Reference<RowCursor>(this.cursor);
|
||||
value.setAndGet(this.row.ReadSparseVarInt(tempReference_cursor));
|
||||
value.setAndGet(this.row.readSparseVarInt(tempReference_cursor));
|
||||
this.cursor = tempReference_cursor.get();
|
||||
return Result.Success;
|
||||
default:
|
||||
|
||||
@@ -117,9 +117,9 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
col.getOffset());
|
||||
value.setAndGet(b.get().ReadVariableBinary(varOffset));
|
||||
value.setAndGet(b.get().readVariableBinary(varOffset));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
}
|
||||
|
||||
b.get().WriteFixedBinary(scope.get().start() + col.getOffset(), value, col.getSize());
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
}
|
||||
|
||||
b.get().WriteFixedBinary(scope.get().start() + col.getOffset(), value, col.getSize());
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -255,13 +255,13 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
}
|
||||
|
||||
boolean exists = b.get().readBit(scope.get().start(), col.getNullBit().clone());
|
||||
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
col.getOffset());
|
||||
int shift;
|
||||
Out<Integer> tempOut_shift = new Out<Integer>();
|
||||
b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift);
|
||||
shift = tempOut_shift.get();
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
scope.get().metaOffset(scope.get().metaOffset() + shift);
|
||||
scope.get().valueOffset(scope.get().valueOffset() + shift);
|
||||
return Result.Success;
|
||||
@@ -283,13 +283,13 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
|
||||
}
|
||||
|
||||
boolean exists = b.get().readBit(scope.get().start(), col.getNullBit().clone());
|
||||
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
col.getOffset());
|
||||
int shift;
|
||||
Out<Integer> tempOut_shift = new Out<Integer>();
|
||||
b.get().WriteVariableBinary(varOffset, value, exists, tempOut_shift);
|
||||
shift = tempOut_shift.get();
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
scope.get().metaOffset(scope.get().metaOffset() + shift);
|
||||
scope.get().valueOffset(scope.get().valueOffset() + shift);
|
||||
return Result.Success;
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class LayoutBit {
|
||||
* @return The bit of the byte within the bitmask.
|
||||
*/
|
||||
public int bit() {
|
||||
return this.index() % LayoutTypes.BitsPerByte;
|
||||
return this.index() % Byte.SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public final class LayoutBit {
|
||||
* @return The byte offset containing this bit.
|
||||
*/
|
||||
public int offset(int offset) {
|
||||
return offset + (this.index() / LayoutTypes.BitsPerByte);
|
||||
return offset + (this.index() / Byte.SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,7 +102,7 @@ public final class LayoutBit {
|
||||
* The number of bytes needed to hold all bits so far allocated.
|
||||
*/
|
||||
public final int getNumBytes() {
|
||||
return LayoutBit.divCeiling(this.next, LayoutTypes.BitsPerByte);
|
||||
return LayoutBit.divCeiling(this.next, Byte.SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,12 +63,12 @@ public final class LayoutBoolean extends LayoutType<Boolean> {
|
||||
}
|
||||
|
||||
if (value) {
|
||||
b.get().SetBit(scope.get().start(), col.getBooleanBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getBooleanBit().clone());
|
||||
} else {
|
||||
b.get().UnsetBit(scope.get().start(), col.getBooleanBit().clone());
|
||||
b.get().unsetBit(scope.get().start(), col.getBooleanBit().clone());
|
||||
}
|
||||
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ public final class LayoutDateTime extends LayoutType<DateTime> {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteDateTime(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().writeDateTime(scope.get().start() + col.getOffset(), value);
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ public final class LayoutFloat32 extends LayoutType<Float> {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteFloat32(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().writeFloat32(scope.get().start() + col.getOffset(), value);
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public final class LayoutFloat32 extends LayoutType<Float> {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.get().writeSparseFloat32(edit, value, options);
|
||||
b.get().WriteSparseFloat32(edit, value, options);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ public final class LayoutFloat64 extends LayoutType<Double> {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteFloat64(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().writeFloat64(scope.get().start() + col.getOffset(), value);
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class LayoutInt16 extends LayoutType<Short> {
|
||||
}
|
||||
|
||||
b.get().writeInt16(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class LayoutInt32 extends LayoutType<Integer> {
|
||||
}
|
||||
|
||||
b.get().writeInt32(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class LayoutInt64 extends LayoutType<Long> {
|
||||
}
|
||||
|
||||
b.get().writeInt64(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class LayoutInt8 extends LayoutType<Byte> {
|
||||
}
|
||||
|
||||
b.get().writeInt8(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
|
||||
import com.azure.data.cosmos.core.Out;
|
||||
import com.azure.data.cosmos.core.Reference;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.Result;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowBuffer;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.RowCursor;
|
||||
@@ -80,7 +79,7 @@ public abstract class LayoutScope extends LayoutType {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.deleteSparse(edit);
|
||||
b.DeleteSparse(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public abstract class LayoutType<T> implements ILayoutType {
|
||||
return Result.TypeMismatch;
|
||||
}
|
||||
|
||||
b.UnsetBit(scope.start(), column.nullBit());
|
||||
b.unsetBit(scope.start(), column.nullBit());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public abstract class LayoutType<T> implements ILayoutType {
|
||||
return result;
|
||||
}
|
||||
|
||||
b.deleteSparse(edit);
|
||||
b.DeleteSparse(edit);
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -148,9 +148,9 @@ public abstract class LayoutType<T> implements ILayoutType {
|
||||
boolean exists = b.readBit(scope.start(), column.nullBit());
|
||||
|
||||
if (exists) {
|
||||
int varOffset = b.computeVariableValueOffset(scope.layout(), scope.start(), column.offset());
|
||||
int varOffset = b.ComputeVariableValueOffset(scope.layout(), scope.start(), column.offset());
|
||||
b.deleteVariable(varOffset, this.isVarint());
|
||||
b.UnsetBit(scope.start(), column.nullBit());
|
||||
b.unsetBit(scope.start(), column.nullBit());
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
@@ -245,19 +245,19 @@ public abstract class LayoutType<T> implements ILayoutType {
|
||||
}
|
||||
|
||||
if (destinationScope.immutable()) {
|
||||
b.deleteSparse(srcEdit);
|
||||
b.DeleteSparse(srcEdit);
|
||||
dstEdit.setAndGet(null);
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
if (!srcEdit.cellTypeArgs().equals(elementType.typeArgs())) {
|
||||
b.deleteSparse(srcEdit);
|
||||
b.DeleteSparse(srcEdit);
|
||||
dstEdit.setAndGet(null);
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
|
||||
if (options == UpdateOptions.InsertAt) {
|
||||
b.deleteSparse(srcEdit);
|
||||
b.DeleteSparse(srcEdit);
|
||||
dstEdit.setAndGet(null);
|
||||
return Result.TypeConstraint;
|
||||
}
|
||||
@@ -265,13 +265,13 @@ public abstract class LayoutType<T> implements ILayoutType {
|
||||
// Prepare the insertion at the destination.
|
||||
dstEdit.setAndGet(b.prepareSparseMove(destinationScope, srcEdit));
|
||||
if ((options == UpdateOptions.Update) && (!dstEdit.get().exists())) {
|
||||
b.deleteSparse(srcEdit);
|
||||
b.DeleteSparse(srcEdit);
|
||||
dstEdit.setAndGet(null);
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
if ((options == UpdateOptions.Insert) && dstEdit.get().exists()) {
|
||||
b.deleteSparse(srcEdit);
|
||||
b.DeleteSparse(srcEdit);
|
||||
dstEdit.setAndGet(null);
|
||||
return Result.Exists;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts;
|
||||
public abstract class LayoutTypes {
|
||||
public static final LayoutArray ARRAY = new LayoutArray(false);
|
||||
public static final LayoutBinary BINARY = new LayoutBinary();
|
||||
public static final int BitsPerByte = 8;
|
||||
public static final LayoutBoolean BOOLEAN = new LayoutBoolean(true);
|
||||
public static final LayoutBoolean BooleanFalse = new LayoutBoolean(false);
|
||||
public static final LayoutDateTime DATE_TIME = new LayoutDateTime();
|
||||
|
||||
@@ -58,7 +58,7 @@ public final class LayoutUDT extends LayoutPropertyScope {
|
||||
@Override
|
||||
public int writeTypeArgument(Reference<RowBuffer> row, int offset, TypeArgumentList value) {
|
||||
row.get().writeSparseTypeCode(offset, this.LayoutCode);
|
||||
row.get().WriteSchemaId(offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), value.schemaId().clone());
|
||||
row.get().writeSchemaId(offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), value.schemaId().clone());
|
||||
return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + SchemaId.SIZE;
|
||||
}
|
||||
}
|
||||
@@ -68,8 +68,8 @@ public final class LayoutUInt16 extends LayoutType<Short> {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteUInt16(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().writeUInt16(scope.get().start() + col.getOffset(), value);
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ public final class LayoutUInt32 extends LayoutType<Integer> {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteUInt32(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().writeUInt32(scope.get().start() + col.getOffset(), value);
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ public final class LayoutUInt64 extends LayoutType<Long> {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteUInt64(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().writeUInt64(scope.get().start() + col.getOffset(), value);
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ public final class LayoutUInt8 extends LayoutType<Byte> {
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteUInt8(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().writeUInt8(scope.get().start() + col.getOffset(), value);
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope {
|
||||
}
|
||||
|
||||
// Check if the search found the result.
|
||||
b.get().deleteSparse(patternScope);
|
||||
b.get().DeleteSparse(patternScope);
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
public final class LayoutUnixDateTime extends LayoutType<com.azure.data.cosmos.serialization.hybridrow.UnixDateTime> {
|
||||
public LayoutUnixDateTime() {
|
||||
super(com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.UNIX_DATE_TIME,
|
||||
com.azure.data.cosmos.serialization.hybridrow.UnixDateTime.Size);
|
||||
com.azure.data.cosmos.serialization.hybridrow.UnixDateTime.BYTES);
|
||||
}
|
||||
|
||||
public boolean isFixed() {
|
||||
|
||||
@@ -68,7 +68,7 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
|
||||
return result;
|
||||
}
|
||||
|
||||
value.setAndGet(b.get().ReadSparseString(edit));
|
||||
value.setAndGet(b.get().readSparseString(edit));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
|
||||
return Result.NotFound;
|
||||
}
|
||||
|
||||
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
col.getOffset());
|
||||
value.setAndGet(b.get().ReadVariableString(varOffset));
|
||||
value.setAndGet(b.get().readVariableString(varOffset));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
|
||||
return Result.InsufficientPermissions;
|
||||
}
|
||||
|
||||
b.get().WriteFixedString(scope.get().start() + col.getOffset(), value);
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().writeFixedString(scope.get().start() + col.getOffset(), value);
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@@ -173,13 +173,13 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
|
||||
}
|
||||
|
||||
boolean exists = b.get().readBit(scope.get().start(), col.getNullBit().clone());
|
||||
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
col.getOffset());
|
||||
int shift;
|
||||
Out<Integer> tempOut_shift = new Out<Integer>();
|
||||
b.get().WriteVariableString(varOffset, value, exists, tempOut_shift);
|
||||
shift = tempOut_shift.get();
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
scope.get().metaOffset(scope.get().metaOffset() + shift);
|
||||
scope.get().valueOffset(scope.get().valueOffset() + shift);
|
||||
return Result.Success;
|
||||
|
||||
@@ -98,13 +98,13 @@ public final class LayoutVarInt extends LayoutType<Long> {
|
||||
}
|
||||
|
||||
boolean exists = b.get().readBit(scope.get().start(), col.getNullBit().clone());
|
||||
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
col.getOffset());
|
||||
int shift;
|
||||
Out<Integer> tempOut_shift = new Out<Integer>();
|
||||
b.get().WriteVariableInt(varOffset, value, exists, tempOut_shift);
|
||||
shift = tempOut_shift.get();
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
scope.get().metaOffset(scope.get().metaOffset() + shift);
|
||||
scope.get().valueOffset(scope.get().valueOffset() + shift);
|
||||
return Result.Success;
|
||||
|
||||
@@ -115,13 +115,13 @@ public final class LayoutVarUInt extends LayoutType<Long> {
|
||||
}
|
||||
|
||||
boolean exists = b.get().readBit(scope.get().start(), col.getNullBit().clone());
|
||||
int varOffset = b.get().computeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout(), scope.get().start(),
|
||||
col.getOffset());
|
||||
int shift;
|
||||
Out<Integer> tempOut_shift = new Out<Integer>();
|
||||
b.get().WriteVariableUInt(varOffset, value, exists, tempOut_shift);
|
||||
shift = tempOut_shift.get();
|
||||
b.get().SetBit(scope.get().start(), col.getNullBit().clone());
|
||||
b.get().setBit(scope.get().start(), col.getNullBit().clone());
|
||||
scope.get().metaOffset(scope.get().metaOffset() + shift);
|
||||
scope.get().valueOffset(scope.get().valueOffset() + shift);
|
||||
return Result.Success;
|
||||
|
||||
@@ -101,7 +101,7 @@ 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 void WriteTo(OutputStream stream) {
|
||||
this.row.WriteTo(stream);
|
||||
this.row.writeTo(stream);
|
||||
}
|
||||
|
||||
public JsonModelRowGenerator clone() {
|
||||
|
||||
@@ -417,7 +417,7 @@ public final class RowOperationDispatcher {
|
||||
|
||||
public String RowToHex() {
|
||||
try (MemoryStream stm = new MemoryStream()) {
|
||||
this.Row.WriteTo(stm);
|
||||
this.Row.writeTo(stm);
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
//ORIGINAL LINE: ReadOnlyMemory<byte> bytes = stm.GetBuffer().AsMemory(0, (int)stm.Position);
|
||||
ReadOnlyMemory<Byte> bytes = stm.GetBuffer().AsMemory(0, (int)stm.Position);
|
||||
|
||||
Reference in New Issue
Block a user