Progressed on port

This commit is contained in:
David Noble
2019-09-03 02:38:24 -07:00
parent 7ae43bf830
commit eb13d61895
14 changed files with 840 additions and 385 deletions

View File

@@ -1,7 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.core;
public class Codecs {
}

View File

@@ -18,6 +18,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
@@ -202,68 +203,6 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
return this.length; return this.length;
} }
public static boolean opEquals(Utf8String left, Utf8String right) {
if (null == left) {
return null == right;
}
return left.equals(right);
}
public static boolean opGreaterThan(Utf8String left, Utf8String right) {
return left != null && left.compareTo(right) > 0;
}
public static boolean opGreaterThan(Utf8String left, String right) {
return left != null && left.compareTo(right) > 0;
}
public static boolean opGreaterThan(String left, Utf8String right) {
return right == null || right.compareTo(left) <= 0;
}
public static boolean opGreaterThanOrEquals(Utf8String left, Utf8String right) {
return left == null ? right == null : left.compareTo(right) >= 0;
}
public static boolean opGreaterThanOrEquals(Utf8String left, String right) {
return left == null ? right == null : left.compareTo(right) >= 0;
}
public static boolean opGreaterThanOrEquals(String left, Utf8String right) {
return right == null ? left != null : right.compareTo(left) < 0;
}
public static boolean opLessThan(Utf8String left, Utf8String right) {
return left == null ? right != null : left.compareTo(right) < 0;
}
public static boolean opLessThan(Utf8String left, String right) {
return left == null ? right != null : left.compareTo(right) < 0;
}
public static boolean opLessThan(String left, Utf8String right) {
return right == null ? left == null : right.compareTo(left) >= 0;
}
public static boolean opLessThanOrEquals(Utf8String left, Utf8String right) {
return left == null || left.compareTo(right) <= 0;
}
public static boolean opLessThanOrEquals(Utf8String left, String right) {
return left == null || left.compareTo(right) <= 0;
}
public static boolean opLessThanOrEquals(String left, Utf8String right) {
return right != null && right.compareTo(left) > 0;
}
public static boolean opNotEquals(Utf8String left, Utf8String right) {
if (null == left) {
return null != right;
}
return !left.equals(right);
}
@Override @Override
public CharSequence subSequence(int start, int end) { public CharSequence subSequence(int start, int end) {
checkArgument(start < 0 || end < 0 || start > end || end > this.length, "start: %s, end: %s", start, end); checkArgument(start < 0 || end < 0 || start > end || end > this.length, "start: %s, end: %s", start, end);
@@ -281,14 +220,15 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
} }
/** /**
* Creates a {@link Utf8String} from a UTF16 encoding string. * Creates a {@link Utf8String} from a UTF16 encoding string
*
* @param string The UTF16 encoding string.
* @return A new {@link Utf8String}.
* <p> * <p>
* This method must transcode the UTF-16 into UTF-8 which both requires allocation and is a size of data operation. * This method must transcode the UTF-16 into UTF-8 which both requires allocation and is a size of data operation.
*
* @param string A UTF-16 encoding string or {@code null}
* @return A new {@link Utf8String} or {@code null}, if {@code string} is {@code null}
*/ */
public static Utf8String transcodeUtf16(final String string) { @Nullable
public static Utf8String transcodeUtf16(@Nullable final String string) {
if (string == null) { if (string == null) {
return null; return null;
@@ -308,17 +248,34 @@ public final class Utf8String implements CharSequence, Comparable<Utf8String> {
} }
/** /**
* Parses the contents of a byte buffer to prove it contains a valid UTF-8 character sequence * Creates a new {@link Utf8String} from a {@link ByteBuf} with UTF-8 character validation
* <p>
* The {@link Utf8String} created retains the {@link ByteBuf}. (No data is transferred.)
* *
* @param buffer The byte buffer to validate * @param buffer The {@link ByteBuf} to validate and assign to the {@link Utf8String} created.
* @return A {@link Utf8String} instance, if the @{code buffer} validates or a value of @{link Optional#empty} * @return A {@link Utf8String} instance, if the @{code buffer} validates or a value of @{link Optional#empty}
* otherwise. * otherwise.
*/ */
public static Optional<Utf8String> tryParseUtf8Bytes(@Nonnull final ByteBuf buffer) { @Nonnull
public static Optional<Utf8String> from(@Nonnull final ByteBuf buffer) {
checkNotNull(buffer); checkNotNull(buffer);
return Utf8.isWellFormed(buffer.array()) ? Optional.of(new Utf8String(buffer)) : Optional.empty(); return Utf8.isWellFormed(buffer.array()) ? Optional.of(new Utf8String(buffer)) : Optional.empty();
} }
/**
* Creates a new {@link Utf8String} from a {@link ByteBuf} without UTF-8 character validation
* <p>
* The {@link Utf8String} created retains the {@link ByteBuf}. (No data is transferred.)
*
* @param buffer The {@link ByteBuf} to assign to the {@link Utf8String} created.
* @return a new {@link Utf8String}
*/
@Nonnull
public static Utf8String fromUnsafe(@Nonnull ByteBuf buffer) {
checkNotNull(buffer);
return new Utf8String(buffer);
}
private static int decodedLength(final ByteBuf buffer) { private static int decodedLength(final ByteBuf buffer) {
final CodePointIterable iterable = new CodePointIterable(buffer, -1); final CodePointIterable iterable = new CodePointIterable(buffer, -1);

View File

@@ -0,0 +1,113 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.core.codecs;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import javax.annotation.Nonnull;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
public final class DateTimeCodec {
private static final int BYTES = Long.BYTES;
private static final long FLAGS_MASK = 0xC000000000000000L;
private static final long KIND_AMBIGUOUS = 0xC000000000000000L;
private static final long KIND_LOCAL = 0x8000000000000000L;
private static final long KIND_UTC = 0x4000000000000000L;
private static final long TICKS_MASK = 0x3FFFFFFFFFFFFFFFL;
private static final ZoneOffset ZONE_OFFSET_LOCAL = OffsetDateTime.now().getOffset();
private static final int ZONE_OFFSET_LOCAL_TOTAL_SECONDS = ZONE_OFFSET_LOCAL.getTotalSeconds();
private static final int ZONE_OFFSET_UTC_TOTAL_SECONDS = ZoneOffset.UTC.getTotalSeconds();
private DateTimeCodec() {
}
/**
* Decode an {@link OffsetDateTime} from a {@code System.DateTimeCodec} as serialized by {@code MemoryMarshal.Write}
*
* @param bytes a {@link byte} array containing the serialized value to be decoded
* @return a new {@link OffsetDateTime}
* @see <a href="https://referencesource.microsoft.com/mscorlib/a.html#df6b1eba7461813b">
* struct DateTimeCodec source</a>
*/
public static OffsetDateTime decode(@Nonnull final byte[] bytes) {
checkNotNull(bytes);
return decode(Unpooled.wrappedBuffer(bytes));
}
/**
* Decode an {@link OffsetDateTime} from a {@code System.DateTimeCodec} as serialized by {@code MemoryMarshal.Write}
*
* @param in a {@link ByteBuf} containing the serialized value to be decoded
* @return a new {@link OffsetDateTime}
* @see <a href="https://referencesource.microsoft.com/mscorlib/a.html#df6b1eba7461813b">
* struct DateTimeCodec source</a>
*/
public static OffsetDateTime decode(@Nonnull final ByteBuf in) {
checkNotNull(in, "expected non-null in");
checkArgument(in.readableBytes() >= BYTES, "expected %s readable bytes, not %s",
BYTES,
in.readableBytes());
final long data = in.readLongLE();
final long epochSecond = data & TICKS_MASK;
final ZoneOffset zoneOffset = (data & FLAGS_MASK) == KIND_UTC ? ZoneOffset.UTC : ZONE_OFFSET_LOCAL;
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(epochSecond), zoneOffset);
}
/**
* Encode an {@link OffsetDateTime} as a {@code System.DateTimeCodec} serialized by {@code MemoryMarshal.Write}
*
* @param offsetDateTime an {@link OffsetDateTime} to be encoded
* @return a new byte array containing the encoded {@code offsetDateTime}
* @see <a href="https://referencesource.microsoft.com/mscorlib/a.html#df6b1eba7461813b">
* struct DateTimeCodec source</a>
*/
public static byte[] encode(final OffsetDateTime offsetDateTime) {
final byte[] bytes = new byte[BYTES];
encode(offsetDateTime, Unpooled.wrappedBuffer(bytes));
return bytes;
}
/**
* Encode an {@link OffsetDateTime} as a {@code System.DateTimeCodec} serialized by {@code MemoryMarshal.Write}
*
* @param offsetDateTime an {@link OffsetDateTime} to be encoded
* @param out an output {@link ByteBuf}
* @see <a href="https://referencesource.microsoft.com/mscorlib/a.html#df6b1eba7461813b">
* struct DateTimeCodec source</a>
*/
public static void encode(final OffsetDateTime offsetDateTime, final ByteBuf out) {
final long epochSecond = offsetDateTime.toEpochSecond();
checkArgument(epochSecond <= TICKS_MASK, "expected offsetDateTime epoch second in range [0, %s], not %s",
TICKS_MASK,
epochSecond);
final int zoneOffsetTotalSeconds = offsetDateTime.getOffset().getTotalSeconds();
final long value;
if (zoneOffsetTotalSeconds == ZONE_OFFSET_UTC_TOTAL_SECONDS) {
value = epochSecond | KIND_UTC;
} else if (zoneOffsetTotalSeconds == ZONE_OFFSET_LOCAL_TOTAL_SECONDS) {
value = epochSecond | KIND_LOCAL;
} else {
value = epochSecond | KIND_AMBIGUOUS;
}
out.writeLongLE(value);
}
}

View File

@@ -0,0 +1,187 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.core.codecs;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import javax.annotation.Nonnull;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.math.RoundingMode;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static java.lang.Math.max;
import static java.lang.Math.min;
public final class DecimalCodec {
public static final int BYTES = 4 * Integer.BYTES;
private static final int FLAGS_MASK_INVALID = 0b01111111000000001111111111111111;
private static final int FLAGS_MASK_POWER = 0b00000000111111110000000000000000;
private static final int FLAGS_MASK_SIGN = 0b10000000000000000000000000000000;
private static final BigInteger MAGNITUDE_MAX = new BigInteger(new byte[] { (byte)0x00,
(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF,
(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF,
(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF });
private static final BigInteger MAGNITUDE_MIN = new BigInteger(new byte[] { (byte)0xFF,
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01 });
private static final MathContext REDUCED_PRECISION = new MathContext(28, RoundingMode.HALF_EVEN);
private static final int SCALE_MAX = 28;
private static final int SCALE_MIN = 0;
private static final int SCALE_SHIFT = 16;
private static final int VALUE_LENGTH = 3 * Integer.BYTES;
private DecimalCodec() {
}
/**
* Decode a {@link BigDecimal} from a {@code System.DecimalCodec} as serialized by {@code MemoryMarshal.Write}
*
* @param bytes a {@link byte} array containing the serialized {@code System.DecimalCodec} to be decoded
* @return a new {@link BigDecimal}
* @see <a href="https://referencesource.microsoft.com/mscorlib/system/decimal.cs.html">
* struct DecimalCodec source</a>
*/
public static BigDecimal decode(@Nonnull final byte[] bytes) {
checkNotNull(bytes);
return decode(Unpooled.wrappedBuffer(bytes));
}
/**
* Decode a {@link BigDecimal} from a {@code System.DecimalCodec} value serialized by {@code MemoryMarshal.Write}
*
* @param in a {@link ByteBuf} containing the serialized {@code System.DecimalCodec} to be decoded
* @return a new {@link BigDecimal}
* @see <a href="https://referencesource.microsoft.com/mscorlib/system/decimal.cs.html">
* struct DecimalCodec source</a>
*/
public static BigDecimal decode(@Nonnull final ByteBuf in) {
checkNotNull(in, "expected non-null in");
checkArgument(in.readableBytes() >= BYTES, "expected %s readable bytes, not %s",
BYTES,
in.readableBytes());
// The flags field is--and must be--interpreted as follows
//
// Bits Interpretation
// ----- --------------------------------------------------------------------------------------------
// 0-15 unused and must be zero
// 16-23 a value between 0 and 28 specifying the number of digits to the right of the decimal point
// 24-30 unused and must be zero
// 31 specifies the sign of the value, 1 meaning negative and 0 meaning non-negative
final int flags = in.readIntLE();
checkState((flags & FLAGS_MASK_INVALID) == 0, "invalid flags field: %s", flags);
final int scale = (flags | FLAGS_MASK_POWER) >>> SCALE_SHIFT;
checkState(scale <= SCALE_MAX);
final int signum = (flags & FLAGS_MASK_SIGN) == 0 ? 1 : -1;
final byte[] buffer = new byte[VALUE_LENGTH];
in.readBytes(buffer);
int i = VALUE_LENGTH;
int j = 0;
while (i > j) {
final byte b = buffer[--i];
buffer[i] = buffer[j];
buffer[j++] = b;
}
return new BigDecimal(new BigInteger(signum, buffer), scale);
}
/**
* Encode a {@link BigDecimal} as a {@code System.DecimalCodec} serialized by {@code MemoryMarshal.Write}
*
* @param bigDecimal a {@link BigDecimal} to be encoded
* @return a new byte array containing the encoded {@code bigDecimal}
* @see <a href="https://referencesource.microsoft.com/mscorlib/system/decimal.cs.html">
* struct DecimalCodec source</a>
*/
public static byte[] encode(final BigDecimal bigDecimal) {
final byte[] bytes = new byte[BYTES];
encode(bigDecimal, Unpooled.wrappedBuffer(bytes));
return bytes;
}
/**
* Encode a {@link BigDecimal} as a {@code System.DecimalCodec} serialized by {@code MemoryMarshal.Write}
*
* @param value a {@link BigDecimal} to be encoded
* @param out an output {@link ByteBuf}
* @see <a href="https://referencesource.microsoft.com/mscorlib/system/decimal.cs.html">
* struct DecimalCodec source</a>
*/
public static void encode(@Nonnull BigDecimal value, @Nonnull final ByteBuf out) {
checkNotNull(value, "expected non-null value");
checkNotNull(value, "expected non-null out");
final int signum = value.signum();
if (signum == 0) {
out.writeZero(BYTES);
return;
}
BigInteger unscaledValue = value.unscaledValue();
if (unscaledValue.compareTo(MAGNITUDE_MIN) < 0 || unscaledValue.compareTo(MAGNITUDE_MAX) > 0) {
value = value.stripTrailingZeros();
unscaledValue = value.unscaledValue();
if (unscaledValue.compareTo(MAGNITUDE_MIN) < 0 || unscaledValue.compareTo(MAGNITUDE_MAX) > 0) {
value = new BigDecimal(unscaledValue, min(max(value.scale(), SCALE_MIN), SCALE_MAX), REDUCED_PRECISION);
unscaledValue = value.unscaledValue();
}
}
if (value.scale() < SCALE_MIN) {
value = value.setScale(SCALE_MIN, RoundingMode.HALF_EVEN);
unscaledValue = value.unscaledValue();
} else if (value.scale() > SCALE_MAX) {
value = value.setScale(SCALE_MAX, RoundingMode.HALF_EVEN);
unscaledValue = value.unscaledValue();
}
final byte[] bytes = unscaledValue.toByteArray();
final byte[] buffer = new byte[VALUE_LENGTH];
final int flags;
if (signum == -1) {
flags = FLAGS_MASK_SIGN | value.scale() << SCALE_SHIFT;
int carry = 1;
for (int i = buffer.length, j = 0; i-- > 0; j++) {
final int n = ((bytes[i] ^ 0b1111_1111) & 0b1111_1111) + carry;
if ((n & 0b1_0000_0000) == 0) {
carry = 0;
}
buffer[j] = bytes[i];
}
} else {
flags = value.scale() << SCALE_SHIFT;
for (int i = buffer.length, j = 0; i-- > 0; j++) {
buffer[j] = bytes[i];
}
}
out.writeIntLE(flags);
out.writeBytes(buffer, 0, 4);
out.writeBytes(buffer, 8, 4);
out.writeBytes(buffer, 4, 4);
}
}

View File

@@ -0,0 +1,72 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.core.codecs;
import com.azure.data.cosmos.serialization.hybridrow.Float128;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import javax.annotation.Nonnull;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
public final class Float128Codec {
public static final int BYTES = 2 * Long.BYTES;
private Float128Codec() {
}
/**
* Decode a {@link Float128} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
*
* @param bytes a {@link byte} array containing the serialized {@link Float128} to be decoded
* @return a new {@link Float128}
*/
public static Float128 decode(@Nonnull final byte[] bytes) {
checkNotNull(bytes);
return decode(Unpooled.wrappedBuffer(bytes));
}
/**
* Decode a {@link Float128} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
*
* @param in a {@link ByteBuf} containing the serialized {@link Float128} to be decoded
* @return a new {@link Float128}
*/
public static Float128 decode(@Nonnull final ByteBuf in) {
checkNotNull(in, "expected non-null in");
checkArgument(in.readableBytes() >= BYTES, "expected %s readable bytes, not %s",
BYTES,
in.readableBytes());
return new Float128(in.readLongLE(), in.readLongLE());
}
/**
* Encodes a {@link Float128} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
*
* @param value a {@link Float128} to be encoded
* @return a new byte array containing the encoded
*/
public static byte[] encode(final Float128 value) {
final byte[] bytes = new byte[BYTES];
encode(value, Unpooled.wrappedBuffer(bytes));
return bytes;
}
/**
* Encodes a {@link Float128} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
*
* @param value a {@link Float128} to be encoded
* @param out an output {@link ByteBuf}
*/
public static void encode(final Float128 value, final ByteBuf out) {
out.writeLongLE(value.high());
out.writeLongLE(value.low());
}
}

View File

@@ -0,0 +1,93 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.core.codecs;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import javax.annotation.Nonnull;
import java.util.UUID;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
public final class GuidCodec {
public static final int BYTES = 2 * Long.BYTES;
private GuidCodec() {
}
/**
* Decode a {@link UUID} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
*
* @param bytes a {@link byte} array containing the serialized {@link UUID} to be decoded
* @return a new {@link UUID}
*/
public static UUID decode(@Nonnull final byte[] bytes) {
checkNotNull(bytes);
return decode(Unpooled.wrappedBuffer(bytes));
}
/**
* Decode a {@link UUID} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
*
* @param in a {@link ByteBuf} containing the serialized {@link UUID} to be decoded
* @return a new {@link UUID}
*/
public static UUID decode(@Nonnull final ByteBuf in) {
checkNotNull(in, "expected non-null in");
checkArgument(in.readableBytes() >= BYTES, "expected %s readable bytes, not %s",
BYTES,
in.readableBytes());
long mostSignificantBits = in.readUnsignedIntLE() << 32;
mostSignificantBits |= (0x000000000000FFFFL & in.readShortLE()) << 16;
mostSignificantBits |= (0x000000000000FFFFL & in.readShortLE());
long leastSignificantBits = (0x000000000000FFFFL & in.readShortLE()) << (32 + 16);
for (int shift = 32 + 8; shift >= 0; shift -= 8) {
leastSignificantBits |= (0x00000000000000FFL & in.readByte()) << shift;
}
return new UUID(mostSignificantBits, leastSignificantBits);
}
/**
* Encodes a {@link UUID} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
*
* @param uuid a {@link UUID} to be encoded
* @return a new byte array containing the encoded
*/
public static byte[] encode(final UUID uuid) {
final byte[] bytes = new byte[BYTES];
encode(uuid, Unpooled.wrappedBuffer(bytes));
return bytes;
}
/**
* Encodes a {@link UUID} as serialized by Microsoft APIs like {@code System.GuidCodec.ToByteArray}
*
* @param uuid a {@link UUID} to be encoded
* @param out an output {@link ByteBuf}
*/
public static void encode(final UUID uuid, final ByteBuf out) {
final long mostSignificantBits = uuid.getMostSignificantBits();
out.writeIntLE((int) ((mostSignificantBits & 0xFFFFFFFF00000000L) >>> 32));
out.writeShortLE((short) ((mostSignificantBits & 0x00000000FFFF0000L) >>> 16));
out.writeShortLE((short) (mostSignificantBits & 0x000000000000FFFFL));
final long leastSignificantBits = uuid.getLeastSignificantBits();
out.writeShortLE((short) ((leastSignificantBits & 0xFFFF000000000000L) >>> (32 + 16)));
out.writeShort((short) ((leastSignificantBits & 0x0000FFFF00000000L) >>> 32));
out.writeInt((int) (leastSignificantBits & 0x00000000FFFFFFFFL));
}
}

View File

@@ -3,10 +3,6 @@
package com.azure.data.cosmos.serialization.hybridrow; package com.azure.data.cosmos.serialization.hybridrow;
// TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java:
///#pragma warning disable CA1051 // Do not declare visible instance fields
/** /**
* An IEEE 128-bit floating point value. * An IEEE 128-bit floating point value.
* <p> * <p>
@@ -25,19 +21,12 @@ package com.azure.data.cosmos.serialization.hybridrow;
* </item> * </item>
* </list> * </list>
*/ */
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [DebuggerDisplay("{" + nameof(Float128.Low) + "," + nameof(Float128.High) + "}")][StructLayout
// (LayoutKind.Sequential, Pack = 1)] public readonly struct Float128
//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(Float128.Low) + "," + nameof(Float128.High) + "}")][StructLayout
// (LayoutKind.Sequential, Pack = 1)] public readonly struct Float128
//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct:
public final class Float128 { public final class Float128 {
/** /**
* The size (in bytes) of a {@link Float128}. * The size (in bytes) of a {@link Float128}.
*/ */
public static final int Size = (Long.SIZE / Byte.SIZE) + (Long.SIZE / Byte.SIZE); public static final int SIZE = (Long.SIZE / Byte.SIZE) + (Long.SIZE / Byte.SIZE);
private final long high; private final long high;
private final long low; private final long low;

View File

@@ -6,6 +6,10 @@ package com.azure.data.cosmos.serialization.hybridrow;
import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Out;
import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.core.Reference;
import com.azure.data.cosmos.core.Utf8String; import com.azure.data.cosmos.core.Utf8String;
import com.azure.data.cosmos.core.codecs.DateTimeCodec;
import com.azure.data.cosmos.core.codecs.DecimalCodec;
import com.azure.data.cosmos.core.codecs.Float128Codec;
import com.azure.data.cosmos.core.codecs.GuidCodec;
import com.azure.data.cosmos.serialization.hybridrow.io.RowWriter; import com.azure.data.cosmos.serialization.hybridrow.io.RowWriter;
import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout; import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout;
import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutArray; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutArray;
@@ -62,6 +66,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.util.Iterator; import java.util.Iterator;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@@ -136,35 +141,43 @@ public final class RowBuffer {
checkState(HybridRowHeader.SIZE + layout.size() <= this.length()); checkState(HybridRowHeader.SIZE + layout.size() <= this.length());
} }
public UUID readGuid(int offset) { public ByteBuf readSparseBinary(RowCursor edit) {
this.readSparsePrimitiveTypeCode(edit, LayoutTypes.BINARY);
return MemoryMarshal.<UUID>Read(this.buffer.Slice(offset)); ByteBuf value = this.readBinary(edit.valueOffset());
edit.endOffset(this.buffer.readerIndex());
return value;
} }
public short ReadInt16(int offset) { public boolean readSparseBoolean(RowCursor edit) {
return MemoryMarshal.<Short>Read(this.buffer.Slice(offset)); this.readSparsePrimitiveTypeCode(edit, LayoutTypes.BOOLEAN);
edit.endOffset(edit.valueOffset());
return edit.cellType() == LayoutTypes.BOOLEAN;
} }
public LocalDateTime ReadDateTime(int offset) { public OffsetDateTime readSparseDateTime(RowCursor edit) {
return MemoryMarshal.<LocalDateTime>Read(this.buffer.Slice(offset)); this.readSparsePrimitiveTypeCode(edit, LayoutTypes.DATE_TIME);
edit.endOffset(edit.valueOffset() + Long.SIZE);
return this.readDateTime(edit.valueOffset());
} }
public BigDecimal ReadDecimal(int offset) { public BigDecimal readDecimal(int offset) {
return MemoryMarshal.<BigDecimal>Read(this.buffer.Slice(offset)); Item<BigDecimal> item = this.read(() -> DecimalCodec.decode(this.buffer), offset);
return item.value();
} }
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: public ByteBuf readFixedBinary(int offset, int length) {
//ORIGINAL LINE: internal ReadOnlySpan<byte> ReadFixedBinary(int offset, int len) Item<ByteBuf> item = this.read(() -> this.buffer.readSlice(length), offset);
public ReadOnlySpan<Byte> ReadFixedBinary(int offset, int len) { return item.value();
return this.buffer.Slice(offset, len);
} }
public Utf8Span ReadFixedString(int offset, int len) { public Utf8String readFixedString(int offset, int length) {
return Utf8Span.UnsafeFromUtf8BytesNoValidation(this.buffer.Slice(offset, len)); Item<Utf8String> item = this.read(() -> Utf8String.fromUnsafe(this.buffer.readSlice(length)), offset);
return item.value();
} }
public Float128 ReadFloat128(int offset) { public Float128 ReadFloat128(int offset) {
return MemoryMarshal.<Float128>Read(this.buffer.Slice(offset)); Item<Float128> item = this.read(() -> Float128Codec.decode(this.buffer), offset);
return item.value();
} }
public float ReadFloat32(int offset) { public float ReadFloat32(int offset) {
@@ -187,30 +200,23 @@ public final class RowBuffer {
return new SchemaId(this.ReadInt32(offset)); return new SchemaId(this.ReadInt32(offset));
} }
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: public BigDecimal ReadSparseDecimal(Reference<RowCursor> edit) {
//ORIGINAL LINE: internal ReadOnlySpan<byte> ReadSparseBinary(ref RowCursor edit) this.readSparsePrimitiveTypeCode(edit, LayoutType.Decimal);
public ReadOnlySpan<Byte> ReadSparseBinary(Reference<RowCursor> edit) { // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof':
this.readSparsePrimitiveTypeCode(edit, LayoutType.Binary); edit.get().endOffset = edit.get().valueOffset() + sizeof(BigDecimal);
int sizeLenInBytes; return this.readDecimal(edit.get().valueOffset());
Out<Integer> tempOut_sizeLenInBytes = new Out<Integer>();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: ReadOnlySpan<byte> span = this.ReadBinary(edit.valueOffset, out int sizeLenInBytes);
ReadOnlySpan<Byte> span = this.ReadBinary(edit.get().valueOffset(), tempOut_sizeLenInBytes);
sizeLenInBytes = tempOut_sizeLenInBytes.get();
edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes + span.Length;
return span;
} }
public boolean ReadSparseBool(Reference<RowCursor> edit) { public Float128 ReadSparseFloat128(Reference<RowCursor> edit) {
this.readSparsePrimitiveTypeCode(edit, LayoutType.Boolean); this.readSparsePrimitiveTypeCode(edit, LayoutType.Float128);
edit.get().endOffset = edit.get().valueOffset(); edit.get().endOffset = edit.get().valueOffset() + Float128.SIZE;
return edit.get().cellType() == LayoutType.Boolean; return this.ReadFloat128(edit.get().valueOffset()).clone();
} }
public LocalDateTime ReadSparseDateTime(Reference<RowCursor> edit) { public float ReadSparseFloat32(Reference<RowCursor> edit) {
this.readSparsePrimitiveTypeCode(edit, LayoutType.DateTime); this.readSparsePrimitiveTypeCode(edit, LayoutType.Float32);
edit.get().endOffset = edit.get().valueOffset() + 8; edit.get().endOffset = edit.get().valueOffset() + (Float.SIZE / Byte.SIZE);
return this.ReadDateTime(edit.get().valueOffset()); return this.ReadFloat32(edit.get().valueOffset());
} }
public MongoDbObjectId ReadSparseMongoDbObjectId(Reference<RowCursor> edit) { public MongoDbObjectId ReadSparseMongoDbObjectId(Reference<RowCursor> edit) {
@@ -229,23 +235,30 @@ public final class RowBuffer {
return span; return span;
} }
public BigDecimal ReadSparseDecimal(Reference<RowCursor> edit) { public long ReadSparseVarInt(Reference<RowCursor> edit) {
this.readSparsePrimitiveTypeCode(edit, LayoutType.Decimal); this.readSparsePrimitiveTypeCode(edit, LayoutType.VarInt);
// TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': int sizeLenInBytes;
edit.get().endOffset = edit.get().valueOffset() + sizeof(BigDecimal); Out<Integer> tempOut_sizeLenInBytes = new Out<Integer>();
return this.ReadDecimal(edit.get().valueOffset()); long value = this.read7BitEncodedInt(edit.get().valueOffset(), tempOut_sizeLenInBytes);
sizeLenInBytes = tempOut_sizeLenInBytes.get();
edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes;
return value;
} }
public Float128 ReadSparseFloat128(Reference<RowCursor> edit) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
this.readSparsePrimitiveTypeCode(edit, LayoutType.Float128); //ORIGINAL LINE: internal ushort ReadUInt16(int offset)
edit.get().endOffset = edit.get().valueOffset() + Float128.Size; public short ReadUInt16(int offset) {
return this.ReadFloat128(edit.get().valueOffset()).clone(); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: return MemoryMarshal.Read<ushort>(this.buffer.Slice(offset));
return MemoryMarshal.<Short>Read(this.buffer.Slice(offset));
} }
public float ReadSparseFloat32(Reference<RowCursor> edit) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
this.readSparsePrimitiveTypeCode(edit, LayoutType.Float32); //ORIGINAL LINE: internal uint ReadUInt32(int offset)
edit.get().endOffset = edit.get().valueOffset() + (Float.SIZE / Byte.SIZE); public int ReadUInt32(int offset) {
return this.ReadFloat32(edit.get().valueOffset()); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: return MemoryMarshal.Read<uint>(this.buffer.Slice(offset));
return MemoryMarshal.<Integer>Read(this.buffer.Slice(offset));
} }
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
@@ -286,32 +299,6 @@ public final class RowBuffer {
return this.ReadUnixDateTime(edit.get().valueOffset()).clone(); return this.ReadUnixDateTime(edit.get().valueOffset()).clone();
} }
public long ReadSparseVarInt(Reference<RowCursor> edit) {
this.readSparsePrimitiveTypeCode(edit, LayoutType.VarInt);
int sizeLenInBytes;
Out<Integer> tempOut_sizeLenInBytes = new Out<Integer>();
long value = this.read7BitEncodedInt(edit.get().valueOffset(), tempOut_sizeLenInBytes);
sizeLenInBytes = tempOut_sizeLenInBytes.get();
edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes;
return value;
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: internal ushort ReadUInt16(int offset)
public short ReadUInt16(int offset) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: return MemoryMarshal.Read<ushort>(this.buffer.Slice(offset));
return MemoryMarshal.<Short>Read(this.buffer.Slice(offset));
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: internal uint ReadUInt32(int offset)
public int ReadUInt32(int offset) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: return MemoryMarshal.Read<uint>(this.buffer.Slice(offset));
return MemoryMarshal.<Integer>Read(this.buffer.Slice(offset));
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: internal ulong ReadUInt64(int offset) //ORIGINAL LINE: internal ulong ReadUInt64(int offset)
public long ReadUInt64(int offset) { public long ReadUInt64(int offset) {
@@ -339,7 +326,7 @@ public final class RowBuffer {
Out<Integer> tempOut__ = new Out<Integer>(); Out<Integer> tempOut__ = new Out<Integer>();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: return this.ReadBinary(offset, out int _); //ORIGINAL LINE: return this.ReadBinary(offset, out int _);
ReadOnlySpan<Byte> tempVar = this.ReadBinary(offset, tempOut__); ReadOnlySpan<Byte> tempVar = this.readBinary(offset);
_ = tempOut__.get(); _ = tempOut__.get();
return tempVar; return tempVar;
} }
@@ -434,6 +421,26 @@ public final class RowBuffer {
this.length(this.length() + shiftDelete); this.length(this.length() + shiftDelete);
} }
public void UnsetBit(int offset, LayoutBit bit) {
checkState(LayoutBit.opNotEquals(bit.clone(), LayoutBit.INVALID));
// TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context:
//ORIGINAL LINE: this.buffer[bit.GetOffset(offset)] &= unchecked((byte)~(1 << bit.GetBit()));
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
this.buffer[bit.offset(offset)] &= (byte) ~(1 << bit.bit());
}
public void WriteDateTime(int offset, LocalDateTime value) {
Reference<LocalDateTime> tempReference_value = new Reference<LocalDateTime>(value);
MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value);
value = tempReference_value.get();
}
public void WriteDecimal(int offset, BigDecimal value) {
Reference<BigDecimal> tempReference_value = new Reference<BigDecimal>(value);
MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value);
value = tempReference_value.get();
}
/** /**
* Rebuild the unique index for a set/map scope. * Rebuild the unique index for a set/map scope.
* *
@@ -547,26 +554,6 @@ public final class RowBuffer {
return Result.Success; return Result.Success;
} }
public void UnsetBit(int offset, LayoutBit bit) {
checkState(LayoutBit.opNotEquals(bit.clone(), LayoutBit.INVALID));
// TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context:
//ORIGINAL LINE: this.buffer[bit.GetOffset(offset)] &= unchecked((byte)~(1 << bit.GetBit()));
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
this.buffer[bit.offset(offset)] &= (byte) ~(1 << bit.bit());
}
public void WriteDateTime(int offset, LocalDateTime value) {
Reference<LocalDateTime> tempReference_value = new Reference<LocalDateTime>(value);
MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value);
value = tempReference_value.get();
}
public void WriteDecimal(int offset, BigDecimal value) {
Reference<BigDecimal> tempReference_value = new Reference<BigDecimal>(value);
MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value);
value = tempReference_value.get();
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: internal void WriteFixedBinary(int offset, ReadOnlySpan<byte> value, int len) //ORIGINAL LINE: internal void WriteFixedBinary(int offset, ReadOnlySpan<byte> value, int len)
public void WriteFixedBinary(int offset, ReadOnlySpan<Byte> value, int len) { public void WriteFixedBinary(int offset, ReadOnlySpan<Byte> value, int len) {
@@ -767,7 +754,7 @@ public final class RowBuffer {
} }
public void WriteSparseFloat128(Reference<RowCursor> edit, Float128 value, UpdateOptions options) { public void WriteSparseFloat128(Reference<RowCursor> edit, Float128 value, UpdateOptions options) {
int numBytes = Float128.Size; int numBytes = Float128.SIZE;
int metaBytes; int metaBytes;
Out<Integer> tempOut_metaBytes = new Out<Integer>(); Out<Integer> tempOut_metaBytes = new Out<Integer>();
int spaceNeeded; int spaceNeeded;
@@ -781,7 +768,7 @@ public final class RowBuffer {
metaBytes = tempOut_metaBytes.get(); metaBytes = tempOut_metaBytes.get();
this.writeSparseMetadata(edit, LayoutType.Float128, TypeArgumentList.EMPTY, metaBytes); this.writeSparseMetadata(edit, LayoutType.Float128, TypeArgumentList.EMPTY, metaBytes);
this.writeFloat128(edit.get().valueOffset(), value); this.writeFloat128(edit.get().valueOffset(), value);
checkState(spaceNeeded == metaBytes + Float128.Size); checkState(spaceNeeded == metaBytes + Float128.SIZE);
edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; edit.get().endOffset = edit.get().metaOffset() + spaceNeeded;
this.length(this.length() + shift); this.length(this.length() + shift);
} }
@@ -806,14 +793,6 @@ public final class RowBuffer {
this.length(this.length() + shift); this.length(this.length() + shift);
} }
// TODO: DANOBLE: Support MongoDbObjectId values
// public void WriteMongoDbObjectId(int offset, MongoDbObjectId value) {
// Reference<azure.data.cosmos.serialization.hybridrow.MongoDbObjectId> tempReference_value =
// new Reference<azure.data.cosmos.serialization.hybridrow.MongoDbObjectId>(value);
// MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value);
// value = tempReference_value.get();
// }
public void WriteSparseGuid(Reference<RowCursor> edit, UUID value, UpdateOptions options) { public void WriteSparseGuid(Reference<RowCursor> edit, UUID value, UpdateOptions options) {
int numBytes = 16; int numBytes = 16;
int metaBytes; int metaBytes;
@@ -874,6 +853,14 @@ public final class RowBuffer {
this.length(this.length() + shift); this.length(this.length() + shift);
} }
// TODO: DANOBLE: Support MongoDbObjectId values
// public void WriteMongoDbObjectId(int offset, MongoDbObjectId value) {
// Reference<azure.data.cosmos.serialization.hybridrow.MongoDbObjectId> tempReference_value =
// new Reference<azure.data.cosmos.serialization.hybridrow.MongoDbObjectId>(value);
// MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value);
// value = tempReference_value.get();
// }
public void WriteSparseInt64(Reference<RowCursor> edit, long value, UpdateOptions options) { public void WriteSparseInt64(Reference<RowCursor> edit, long value, UpdateOptions options) {
int numBytes = (Long.SIZE / Byte.SIZE); int numBytes = (Long.SIZE / Byte.SIZE);
int metaBytes; int metaBytes;
@@ -1422,44 +1409,6 @@ public final class RowBuffer {
this.length(this.length() + shift.get()); this.length(this.length() + shift.get());
} }
public void WriteUnixDateTime(int offset, UnixDateTime value) {
Reference<UnixDateTime> tempReference_value =
new Reference<UnixDateTime>(value);
MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value);
value = tempReference_value.get();
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: internal void WriteVariableBinary(int offset, ReadOnlySpan<byte> value, bool exists, out int shift)
public void WriteVariableBinary(int offset, ReadOnlySpan<Byte> value, boolean exists,
Out<Integer> shift) {
int numBytes = value.Length;
int spaceNeeded;
Out<Integer> tempOut_spaceNeeded = new Out<Integer>();
this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift);
spaceNeeded = tempOut_spaceNeeded.get();
int sizeLenInBytes = this.WriteBinary(offset, value);
checkState(spaceNeeded == numBytes + sizeLenInBytes);
this.length(this.length() + shift.get());
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: internal void WriteVariableBinary(int offset, ReadOnlySequence<byte> value, bool exists, out int
// shift)
public void WriteVariableBinary(int offset, ReadOnlySequence<Byte> value, boolean exists,
Out<Integer> shift) {
int numBytes = (int)value.Length;
int spaceNeeded;
Out<Integer> tempOut_spaceNeeded = new Out<Integer>();
this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift);
spaceNeeded = tempOut_spaceNeeded.get();
int sizeLenInBytes = this.WriteBinary(offset, value);
checkState(spaceNeeded == numBytes + sizeLenInBytes);
this.length(this.length() + shift.get());
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: internal void WriteVariableUInt(int offset, ulong value, bool exists, out int shift) //ORIGINAL LINE: internal void WriteVariableUInt(int offset, ulong value, bool exists, out int shift)
public void WriteVariableUInt(int offset, long value, boolean exists, Out<Integer> shift) { public void WriteVariableUInt(int offset, long value, boolean exists, Out<Integer> shift) {
@@ -1497,42 +1446,42 @@ public final class RowBuffer {
this.buffer.setIntLE(offset, (int) (value - decrement)); this.buffer.setIntLE(offset, (int) (value - decrement));
} }
/** public void WriteUnixDateTime(int offset, UnixDateTime value) {
* Compute the byte offset from the beginning of the row for a given variable column's value. Reference<UnixDateTime> tempReference_value =
* new Reference<UnixDateTime>(value);
* @param layout The (optional) layout of the current scope. MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value);
* @param scopeOffset The 0-based offset to the beginning of the scope's value. value = tempReference_value.get();
* @param varIndex The 0-based index of the variable column within the variable segment. }
* @return The byte offset from the beginning of the row where the variable column's value should be
* located.
*/
public int computeVariableValueOffset(Layout layout, int scopeOffset, int varIndex) {
if (layout == null) {
return scopeOffset;
}
int index = layout.numFixed() + varIndex; //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
ReadOnlySpan<LayoutColumn> columns = layout.columns(); //ORIGINAL LINE: internal void WriteVariableBinary(int offset, ReadOnlySpan<byte> value, bool exists, out int shift)
checkState(index <= columns.Length); public void WriteVariableBinary(int offset, ReadOnlySpan<Byte> value, boolean exists,
int offset = scopeOffset + layout.size(); Out<Integer> shift) {
for (int i = layout.numFixed(); i < index; i++) { int numBytes = value.Length;
LayoutColumn col = columns[i]; int spaceNeeded;
if (this.readBit(scopeOffset, col.getNullBit().clone())) { Out<Integer> tempOut_spaceNeeded = new Out<Integer>();
int lengthSizeInBytes; this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift);
Out<Integer> tempOut_lengthSizeInBytes = new Out<Integer>(); spaceNeeded = tempOut_spaceNeeded.get();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: ulong valueSizeInBytes = this.Read7BitEncodedUInt(offset, out int lengthSizeInBytes);
long valueSizeInBytes = this.read7BitEncodedUInt(offset, tempOut_lengthSizeInBytes);
lengthSizeInBytes = tempOut_lengthSizeInBytes.get();
if (col.type().getIsVarint()) {
offset += lengthSizeInBytes;
} else {
offset += (int) valueSizeInBytes + lengthSizeInBytes;
}
}
}
return offset; int sizeLenInBytes = this.WriteBinary(offset, value);
checkState(spaceNeeded == numBytes + sizeLenInBytes);
this.length(this.length() + shift.get());
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: internal void WriteVariableBinary(int offset, ReadOnlySequence<byte> value, bool exists, out int
// shift)
public void WriteVariableBinary(int offset, ReadOnlySequence<Byte> value, boolean exists,
Out<Integer> shift) {
int numBytes = (int)value.Length;
int spaceNeeded;
Out<Integer> tempOut_spaceNeeded = new Out<Integer>();
this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift);
spaceNeeded = tempOut_spaceNeeded.get();
int sizeLenInBytes = this.WriteBinary(offset, value);
checkState(spaceNeeded == numBytes + sizeLenInBytes);
this.length(this.length() + shift.get());
} }
/** /**
@@ -1579,6 +1528,44 @@ public final class RowBuffer {
return this.readHeader(); return this.readHeader();
} }
/**
* Compute the byte offset from the beginning of the row for a given variable column's value.
*
* @param layout The (optional) layout of the current scope.
* @param scopeOffset The 0-based offset to the beginning of the scope's value.
* @param varIndex The 0-based index of the variable column within the variable segment.
* @return The byte offset from the beginning of the row where the variable column's value should be
* located.
*/
public int computeVariableValueOffset(Layout layout, int scopeOffset, int varIndex) {
if (layout == null) {
return scopeOffset;
}
int index = layout.numFixed() + varIndex;
ReadOnlySpan<LayoutColumn> columns = layout.columns();
checkState(index <= columns.Length);
int offset = scopeOffset + layout.size();
for (int i = layout.numFixed(); i < index; i++) {
LayoutColumn col = columns[i];
if (this.readBit(scopeOffset, col.getNullBit().clone())) {
int lengthSizeInBytes;
Out<Integer> tempOut_lengthSizeInBytes = new Out<Integer>();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: ulong valueSizeInBytes = this.Read7BitEncodedUInt(offset, out int lengthSizeInBytes);
long valueSizeInBytes = this.read7BitEncodedUInt(offset, tempOut_lengthSizeInBytes);
lengthSizeInBytes = tempOut_lengthSizeInBytes.get();
if (col.type().getIsVarint()) {
offset += lengthSizeInBytes;
} else {
offset += (int) valueSizeInBytes + lengthSizeInBytes;
}
}
}
return offset;
}
public void incrementUInt32(final int offset, final long increment) { public void incrementUInt32(final int offset, final long increment) {
final long value = this.buffer.getUnsignedIntLE(offset); final long value = this.buffer.getUnsignedIntLE(offset);
this.buffer.setIntLE(offset, (int) (value + increment)); this.buffer.setIntLE(offset, (int) (value + increment));
@@ -1671,19 +1658,26 @@ public final class RowBuffer {
} }
public long read7BitEncodedUInt(int offset, Out<Integer> lengthInBytes) { public long read7BitEncodedUInt(int offset, Out<Integer> lengthInBytes) {
return this.read(this::read7BitEncodedUInt, offset, lengthInBytes); Item<Long> item = this.read(this::read7BitEncodedUInt, offset);
lengthInBytes.set(item.length());
return item.value();
} }
public boolean readBit(int offset, LayoutBit bit) { public boolean readBit(final int offset, @Nonnull final LayoutBit bit) {
checkNotNull(bit, "expected non-null bit");
if (bit.isInvalid()) { if (bit.isInvalid()) {
return true; return true;
} }
// TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context: Item<Boolean> item = this.read(() -> (this.buffer.readByte() & (byte) (1 << bit.bit())) != 0, bit.offset(offset));
//ORIGINAL LINE: return (this.buffer[bit.GetOffset(offset)] & unchecked((byte)(1 << bit.GetBit()))) != 0; return item.value();
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: }
return (this.buffer[bit.offset(offset)] & (byte) (1 << bit.bit())) != 0;
public OffsetDateTime readDateTime(int offset) {
Item<OffsetDateTime> item = this.read(() -> DateTimeCodec.decode(this.buffer), offset);
return item.value();
} }
/** /**
@@ -1752,17 +1746,23 @@ public final class RowBuffer {
return this.validateHeader(version); return this.validateHeader(version);
} }
public HybridRowHeader readHeader() { public UUID readGuid(int offset) {
HybridRowVersion version = HybridRowVersion.from(this.buffer.readByte()); return this.read(() -> GuidCodec.decode(this.buffer), offset).value();
SchemaId schemaId = SchemaId.from(this.buffer.readIntLE()); }
return new HybridRowHeader(version, schemaId);
public HybridRowHeader readHeader(int offset) {
return this.read(this::readHeader, offset).value();
}
public short readInt16(int offset) {
return this.read(this.buffer::readShortLE, offset).value();
} }
public long readInt64(int offset) { public long readInt64(int offset) {
return MemoryMarshal.<Long>Read(this.buffer.Slice(offset)); return this.read(this.buffer::readLongLE, offset).value();
} }
public byte readInt8(int offset, Out<Integer> lengthInBytes) { public byte readInt8(int offset, @Nonnull Out<Integer> lengthInBytes) {
return this.read(this.buffer::readByte, offset, lengthInBytes); return this.read(this.buffer::readByte, offset, lengthInBytes);
} }
@@ -1781,7 +1781,7 @@ public final class RowBuffer {
public short readSparseInt16(RowCursor edit) { public short readSparseInt16(RowCursor edit) {
this.readSparsePrimitiveTypeCode(edit, LayoutTypes.INT_16); this.readSparsePrimitiveTypeCode(edit, LayoutTypes.INT_16);
edit.endOffset(edit.valueOffset() + (Short.SIZE / Byte.SIZE)); edit.endOffset(edit.valueOffset() + (Short.SIZE / Byte.SIZE));
return this.ReadInt16(edit.valueOffset()); return this.readInt16(edit.valueOffset());
} }
public int readSparseInt32(RowCursor edit) { public int readSparseInt32(RowCursor edit) {
@@ -1813,6 +1813,29 @@ public final class RowBuffer {
return NullValue.Default; return NullValue.Default;
} }
public int readSparsePathLen(
@Nonnull final Layout layout, final int offset, @Nonnull final Out<Integer> pathLenInBytes,
@Nonnull final Out<Integer> pathOffset) {
checkNotNull(layout);
checkNotNull(pathOffset);
checkNotNull(pathLenInBytes);
final Item<Long> item = this.read(this::read7BitEncodedUInt, offset);
final int token = item.value().intValue();
if (token < layout.tokenizer().count()) {
pathLenInBytes.set(item.length());
pathOffset.set(offset);
return token;
}
final int numBytes = token - layout.tokenizer().count();
pathLenInBytes.set(numBytes + item.length());
pathOffset.set(offset + item.length());
return token;
}
public Utf8String readSparsePath(RowCursor edit) { public Utf8String readSparsePath(RowCursor edit) {
final Optional<Utf8String> path = edit.layout().tokenizer().tryFindString(edit.longValue().pathToken); final Optional<Utf8String> path = edit.layout().tokenizer().tryFindString(edit.longValue().pathToken);
@@ -1825,26 +1848,6 @@ public final class RowBuffer {
return Utf8String.unsafeFromUtf8BytesNoValidation(this.buffer.Slice(edit.pathOffset(), numBytes)); return Utf8String.unsafeFromUtf8BytesNoValidation(this.buffer.Slice(edit.pathOffset(), numBytes));
} }
public int readSparsePathLen(
@Nonnull final Layout layout, final int offset, @Nonnull final Out<Integer> pathLenInBytes,
@Nonnull final Out<Integer> pathOffset) {
final int start = this.buffer.readerIndex();
final int token = (int) this.read7BitEncodedUInt();
final int end = this.buffer.readerIndex();
if (token < layout.tokenizer().count()) {
pathLenInBytes.set(end - start);
pathOffset.set(start);
return token;
}
final int numBytes = token - layout.tokenizer().count();
pathLenInBytes.set(numBytes + (end - start));
pathOffset.set(end);
return token;
}
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal LayoutType ReadSparseTypeCode(int //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal LayoutType ReadSparseTypeCode(int
// offset) // offset)
@@ -2181,7 +2184,7 @@ public final class RowBuffer {
int shift; int shift;
Out<Integer> tempOut_shift = new Out<Integer>(); Out<Integer> tempOut_shift = new Out<Integer>();
this.ensureSparse(edit, LayoutTypes.FLOAT_32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, this.ensureSparse(edit, LayoutTypes.FLOAT_32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes,
tempOut_spaceNeeded, tempOut_shift); tempOut_spaceNeeded, tempOut_shift);
shift = tempOut_shift.get(); shift = tempOut_shift.get();
spaceNeeded = tempOut_spaceNeeded.get(); spaceNeeded = tempOut_spaceNeeded.get();
metaBytes = tempOut_metaBytes.get(); metaBytes = tempOut_metaBytes.get();
@@ -2198,7 +2201,7 @@ public final class RowBuffer {
public void writeSparseTypeCode(int offset, LayoutCode code) { public void writeSparseTypeCode(int offset, LayoutCode code) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: this.WriteUInt8(offset, (byte)code); //ORIGINAL LINE: this.WriteUInt8(offset, (byte)code);
this.WriteUInt8(offset, (byte) code.value()); this.WriteUInt8(offset, code.value());
} }
/** /**
@@ -2240,6 +2243,16 @@ public final class RowBuffer {
return 1; return 1;
} }
/**
* Compute the number of bytes necessary to store the signed integer using the varint encoding.
*
* @param value The value to be encoded
* @return The number of bytes needed to store the varint encoding of {@code value}
*/
private static int Count7BitEncodedInt(long value) {
return RowBuffer.count7BitEncodedUInt(RowBuffer.rotateSignToLsb(value));
}
/** /**
* Compares the values of two encoded key-value pair fields using the hybrid row binary * Compares the values of two encoded key-value pair fields using the hybrid row binary
* collation. * collation.
@@ -2306,14 +2319,14 @@ public final class RowBuffer {
return this.CompareFieldValue(leftKey.clone(), leftKeyLen, rightKey.clone(), rightKeyLen); return this.CompareFieldValue(leftKey.clone(), leftKeyLen, rightKey.clone(), rightKeyLen);
} }
/** //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
* Compute the number of bytes necessary to store the signed integer using the varint encoding. //ORIGINAL LINE: private int WriteBinary(int offset, ReadOnlySpan<byte> value)
* private int WriteBinary(int offset, ReadOnlySpan<Byte> value) {
* @param value The value to be encoded //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
* @return The number of bytes needed to store the varint encoding of {@code value} //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length);
*/ int sizeLenInBytes = this.write7BitEncodedUInt(offset, (long) value.Length);
private static int Count7BitEncodedInt(long value) { value.CopyTo(this.buffer.Slice(offset + sizeLenInBytes));
return RowBuffer.count7BitEncodedUInt(RowBuffer.rotateSignToLsb(value)); return sizeLenInBytes;
} }
private void EnsureVariable(int offset, boolean isVarint, int numBytes, boolean exists, private void EnsureVariable(int offset, boolean isVarint, int numBytes, boolean exists,
@@ -2420,11 +2433,9 @@ public final class RowBuffer {
return true; return true;
} }
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: private ByteBuf readBinary(int offset) {
//ORIGINAL LINE: private ReadOnlySpan<byte> ReadBinary(int offset, out int sizeLenInBytes) Item<Long> item = this.read(this::read7BitEncodedUInt, offset);
private ReadOnlySpan<Byte> ReadBinary(int offset, Out<Integer> sizeLenInBytes) { return this.buffer.readSlice(item.length);
int numBytes = (int) this.read7BitEncodedUInt(offset, sizeLenInBytes);
return this.buffer.Slice(offset + sizeLenInBytes.get(), numBytes);
} }
private Utf8Span ReadString(int offset, Out<Integer> sizeLenInBytes) { private Utf8Span ReadString(int offset, Out<Integer> sizeLenInBytes) {
@@ -2432,16 +2443,6 @@ public final class RowBuffer {
return Utf8Span.UnsafeFromUtf8BytesNoValidation(this.buffer.Slice(offset + sizeLenInBytes.get(), numBytes)); return Utf8Span.UnsafeFromUtf8BytesNoValidation(this.buffer.Slice(offset + sizeLenInBytes.get(), numBytes));
} }
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: private int WriteBinary(int offset, ReadOnlySpan<byte> value)
private int WriteBinary(int offset, ReadOnlySpan<Byte> value) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length);
int sizeLenInBytes = this.write7BitEncodedUInt(offset, (long) value.Length);
value.CopyTo(this.buffer.Slice(offset + sizeLenInBytes));
return sizeLenInBytes;
}
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: private int WriteBinary(int offset, ReadOnlySequence<byte> value) //ORIGINAL LINE: private int WriteBinary(int offset, ReadOnlySequence<byte> value)
private int WriteBinary(int offset, ReadOnlySequence<Byte> value) { private int WriteBinary(int offset, ReadOnlySequence<Byte> value) {
@@ -2452,6 +2453,32 @@ public final class RowBuffer {
return sizeLenInBytes; return sizeLenInBytes;
} }
private static int countSparsePath(@Nonnull final RowCursor edit) {
if (!edit.writePathToken().isNull()) {
StringToken token = edit.writePathToken();
ByteBuf varint = token.varint();
return varint.readerIndex() + varint.readableBytes();
}
Optional<StringToken> optional = edit.layout().tokenizer().findToken(edit.writePath());
if (optional.isPresent()) {
StringToken token = optional.get();
edit.writePathToken(token);
ByteBuf varint = token.varint();
return varint.readerIndex() + varint.readableBytes();
}
Utf8String path = edit.writePath().toUtf8();
assert path != null;
int numBytes = path.length();
int sizeLenInBytes = RowBuffer.count7BitEncodedUInt(edit.layout().tokenizer().count() + numBytes);
return sizeLenInBytes + numBytes;
}
/** /**
* Return the size (in bytes) of the default sparse value for the type. * Return the size (in bytes) of the default sparse value for the type.
* *
@@ -2550,32 +2577,6 @@ public final class RowBuffer {
throw new IllegalStateException(lenientFormat("Not Implemented: %s", code)); throw new IllegalStateException(lenientFormat("Not Implemented: %s", code));
} }
private static int countSparsePath(@Nonnull final RowCursor edit) {
if (!edit.writePathToken().isNull()) {
StringToken token = edit.writePathToken();
ByteBuf varint = token.varint();
return varint.readerIndex() + varint.readableBytes();
}
Optional<StringToken> optional = edit.layout().tokenizer().findToken(edit.writePath());
if (optional.isPresent()) {
StringToken token = optional.get();
edit.writePathToken(token);
ByteBuf varint = token.varint();
return varint.readerIndex() + varint.readableBytes();
}
Utf8String path = edit.writePath().toUtf8();
assert path != null;
int numBytes = path.length();
int sizeLenInBytes = RowBuffer.count7BitEncodedUInt((long) (edit.layout().tokenizer().count() + numBytes));
return sizeLenInBytes + numBytes;
}
private void ensure(int size) { private void ensure(int size) {
this.buffer.ensureWritable(size); this.buffer.ensureWritable(size);
} }
@@ -2685,11 +2686,25 @@ public final class RowBuffer {
this.ensureSparse(edit, cellType, typeArgs, numBytes, rowOptions, metaBytes, spaceNeeded, shift); this.ensureSparse(edit, cellType, typeArgs, numBytes, rowOptions, metaBytes, spaceNeeded, shift);
} }
private <T> T read(Supplier<T> supplier, int offset, Out<Integer> lengthInBytes) { private <T> Item<T> read(@Nonnull final Supplier<T> supplier, int offset) {
checkNotNull(supplier);
this.buffer.readerIndex(offset); this.buffer.readerIndex(offset);
T value = supplier.get(); T value = supplier.get();
lengthInBytes.set(this.buffer.readerIndex() - offset);
return value; return Item.of(value, offset, this.buffer.readerIndex() - offset);
}
private <T> T read(@Nonnull final Supplier<T> supplier, int offset, @Nonnull Out<Integer> lengthInBytes) {
checkNotNull(supplier);
checkNotNull(lengthInBytes);
Item<T> item = this.read(supplier, offset);
lengthInBytes.set(item.length());
return item.value();
} }
private long read7BitEncodedUInt() { private long read7BitEncodedUInt() {
@@ -2713,6 +2728,12 @@ public final class RowBuffer {
return result; return result;
} }
private HybridRowHeader readHeader() {
HybridRowVersion version = HybridRowVersion.from(this.buffer.readByte());
SchemaId schemaId = SchemaId.from(this.buffer.readIntLE());
return new HybridRowHeader(version, schemaId);
}
/** /**
* Read the metadata of an encoded sparse field. * Read the metadata of an encoded sparse field.
* *
@@ -2766,10 +2787,11 @@ public final class RowBuffer {
edit.scopeType().readSparsePath(this, edit); edit.scopeType().readSparsePath(this, edit);
} }
private void readSparsePrimitiveTypeCode(@Nonnull RowCursor edit, LayoutType code) { private void readSparsePrimitiveTypeCode(@Nonnull final RowCursor edit, @Nonnull final LayoutType code) {
checkNotNull(edit); checkNotNull(edit, "expected non-null edit");
checkArgument(edit.exists()); checkNotNull(code, "expected non-null code");
checkArgument(edit.exists(), "expected edit.exists value of true, not false");
if (edit.scopeType().hasImplicitTypeCode(edit)) { if (edit.scopeType().hasImplicitTypeCode(edit)) {
if (edit.scopeType() instanceof LayoutNullable) { if (edit.scopeType() instanceof LayoutNullable) {
@@ -2788,8 +2810,8 @@ public final class RowBuffer {
} }
} else { } else {
if (code == LayoutTypes.BOOLEAN) { if (code == LayoutTypes.BOOLEAN) {
code = this.readSparseTypeCode(edit.metaOffset()); final LayoutType layoutType = this.readSparseTypeCode(edit.metaOffset());
checkState(code == LayoutTypes.BOOLEAN || code == LayoutTypes.BooleanFalse); checkState(layoutType == LayoutTypes.BOOLEAN || layoutType == LayoutTypes.BooleanFalse);
} else { } else {
checkState(this.readSparseTypeCode(edit.metaOffset()) == code); checkState(this.readSparseTypeCode(edit.metaOffset()) == code);
} }
@@ -2799,10 +2821,10 @@ public final class RowBuffer {
checkState(edit.pathOffset() == 0); checkState(edit.pathOffset() == 0);
checkState(edit.pathToken() == 0); checkState(edit.pathToken() == 0);
} else { } else {
int offset = edit.metaOffset() + LayoutCode.SIZE;
Out<Integer> pathLenInBytes = new Out<>(); Out<Integer> pathLenInBytes = new Out<>();
Out<Integer> pathOffset = new Out<>(); Out<Integer> pathOffset = new Out<>();
int token = this.readSparsePathLen(edit.layout(), edit.metaOffset() + (LayoutCode.SIZE / Byte.SIZE), int token = this.readSparsePathLen(edit.layout(), offset, pathLenInBytes, pathOffset);
pathLenInBytes, pathOffset);
checkState(edit.pathOffset() == pathOffset.get()); checkState(edit.pathOffset() == pathOffset.get());
checkState(edit.pathToken() == token); checkState(edit.pathToken() == token);
} }
@@ -3165,6 +3187,35 @@ public final class RowBuffer {
return sizeLenInBytes; return sizeLenInBytes;
} }
private static class Item<T> {
private int length;
private int offset;
private T value;
private Item(T value, int offset, int length) {
this.value = value;
this.offset = offset;
this.length = length;
}
public int length() {
return this.length;
}
public static <T> Item<T> of(T value, int offset, int length) {
return new Item<>(value, offset, length);
}
public int offset() {
return this.offset;
}
public T value() {
return this.value;
}
}
/** /**
* Represents a single item within a set/map scope that needs to be indexed * Represents a single item within a set/map scope that needs to be indexed
* <p> * <p>
@@ -3182,11 +3233,11 @@ public final class RowBuffer {
* The layout code of the value. * The layout code of the value.
*/ */
public LayoutCode code() { public LayoutCode code() {
return Code; return this.Code;
} }
public UniqueIndexItem code(LayoutCode code) { public UniqueIndexItem code(LayoutCode code) {
Code = code; this.Code = code;
return this; return this;
} }
@@ -3194,11 +3245,11 @@ public final class RowBuffer {
* If existing, the offset to the metadata of the existing field, otherwise the location to insert a new field * If existing, the offset to the metadata of the existing field, otherwise the location to insert a new field
*/ */
public int metaOffset() { public int metaOffset() {
return MetaOffset; return this.MetaOffset;
} }
public UniqueIndexItem metaOffset(int metaOffset) { public UniqueIndexItem metaOffset(int metaOffset) {
MetaOffset = metaOffset; this.MetaOffset = metaOffset;
return this; return this;
} }
@@ -3206,11 +3257,11 @@ public final class RowBuffer {
* Size of the target element * Size of the target element
*/ */
public int size() { public int size() {
return Size; return this.Size;
} }
public UniqueIndexItem size(int size) { public UniqueIndexItem size(int size) {
Size = size; this.Size = size;
return this; return this;
} }
@@ -3218,11 +3269,11 @@ public final class RowBuffer {
* If existing, the offset to the value of the existing field, otherwise undefined * If existing, the offset to the value of the existing field, otherwise undefined
*/ */
public int valueOffset() { public int valueOffset() {
return ValueOffset; return this.ValueOffset;
} }
public UniqueIndexItem valueOffset(int valueOffset) { public UniqueIndexItem valueOffset(int valueOffset) {
ValueOffset = valueOffset; this.ValueOffset = valueOffset;
return this; return this;
} }
} }

View File

@@ -372,7 +372,7 @@ public final class RowReader {
Reference<RowCursor> tempReference_cursor = Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseBinary(tempReference_cursor)); value.setAndGet(this.row.readSparseBinary(tempReference_cursor));
this.cursor = tempReference_cursor.get(); this.cursor = tempReference_cursor.get();
return Result.Success; return Result.Success;
default: default:
@@ -399,7 +399,7 @@ public final class RowReader {
Reference<RowCursor> tempReference_cursor = Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseBool(tempReference_cursor)); value.setAndGet(this.row.readSparseBoolean(tempReference_cursor));
this.cursor = tempReference_cursor.get(); this.cursor = tempReference_cursor.get();
return Result.Success; return Result.Success;
default: default:
@@ -426,7 +426,7 @@ public final class RowReader {
Reference<RowCursor> tempReference_cursor = Reference<RowCursor> tempReference_cursor =
new Reference<RowCursor>(this.cursor); new Reference<RowCursor>(this.cursor);
value.setAndGet(this.row.ReadSparseDateTime(tempReference_cursor)); value.setAndGet(this.row.readSparseDateTime(tempReference_cursor));
this.cursor = tempReference_cursor.get(); this.cursor = tempReference_cursor.get();
return Result.Success; return Result.Success;
default: default:

View File

@@ -57,7 +57,7 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
return Result.NotFound; return Result.NotFound;
} }
value.setAndGet(b.get().ReadFixedBinary(scope.get().start() + col.getOffset(), col.getSize())); value.setAndGet(b.get().readFixedBinary(scope.get().start() + col.getOffset(), col.getSize()));
return Result.Success; return Result.Success;
} }
@@ -85,7 +85,7 @@ public final class LayoutBinary extends LayoutType<byte[]> implements ILayoutSpa
return result; return result;
} }
value.setAndGet(b.get().ReadSparseBinary(edit)); value.setAndGet(b.get().readSparseBinary(edit));
return Result.Success; return Result.Success;
} }

View File

@@ -35,7 +35,7 @@ public final class LayoutDateTime extends LayoutType<DateTime> {
return Result.NotFound; return Result.NotFound;
} }
value.setAndGet(b.get().ReadDateTime(scope.get().start() + col.getOffset())); value.setAndGet(b.get().readDateTime(scope.get().start() + col.getOffset()));
return Result.Success; return Result.Success;
} }
@@ -48,7 +48,7 @@ public final class LayoutDateTime extends LayoutType<DateTime> {
return result; return result;
} }
value.setAndGet(b.get().ReadSparseDateTime(edit)); value.setAndGet(b.get().readSparseDateTime(edit));
return Result.Success; return Result.Success;
} }

View File

@@ -65,7 +65,7 @@ public final class LayoutGuid extends LayoutType<UUID> {
} }
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, Guid value, //ORIGINAL LINE: public override Result WriteSparse(ref RowBuffer b, ref RowCursor edit, GuidCodec value,
// UpdateOptions options = UpdateOptions.Upsert) // UpdateOptions options = UpdateOptions.Upsert)
@Override @Override
public Result writeSparse(RowBuffer b, RowCursor edit, UUID value, public Result writeSparse(RowBuffer b, RowCursor edit, UUID value,

View File

@@ -45,7 +45,7 @@ public final class LayoutUtf8 extends LayoutType<String> implements ILayoutUtf8S
return Result.NotFound; return Result.NotFound;
} }
value.setAndGet(b.get().ReadFixedString(scope.get().start() + col.getOffset(), col.getSize())); value.setAndGet(b.get().readFixedString(scope.get().start() + col.getOffset(), col.getSize()));
return Result.Success; return Result.Success;
} }

View File

@@ -44,9 +44,9 @@ public final class NullableUnitTests {
t1.NullSet = new ArrayList<String>(Arrays.asList(null, "abc", "def")); t1.NullSet = new ArrayList<String>(Arrays.asList(null, "abc", "def"));
t1.NullTuple = new ArrayList<(Integer, Long) > (Arrays.asList((1, 2), (null, 3),(4, null),(null, null))) t1.NullTuple = new ArrayList<(Integer, Long) > (Arrays.asList((1, 2), (null, 3),(4, null),(null, null)))
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: t1.NullMap = new Dictionary<System.Guid, Nullable<byte>> { { System.Guid.Parse //ORIGINAL LINE: t1.NullMap = new Dictionary<System.GuidCodec, Nullable<byte>> { { System.GuidCodec.Parse
// ("{00000000-0000-0000-0000-000000000000}"), 1 }, { System.Guid.Parse // ("{00000000-0000-0000-0000-000000000000}"), 1 }, { System.GuidCodec.Parse
// ("{4674962B-CE11-4916-81C5-0421EE36F168}"), 20 }, { System.Guid.Parse // ("{4674962B-CE11-4916-81C5-0421EE36F168}"), 20 }, { System.GuidCodec.Parse
// ("{7499C40E-7077-45C1-AE5F-3E384966B3B9}"), null }}; // ("{7499C40E-7077-45C1-AE5F-3E384966B3B9}"), null }};
t1.NullMap = new HashMap<UUID, Byte>(Map.ofEntries(Map.entry(UUID.fromString("{00000000-0000-0000-0000" + t1.NullMap = new HashMap<UUID, Byte>(Map.ofEntries(Map.entry(UUID.fromString("{00000000-0000-0000-0000" +
"-000000000000}"), 1), Map.entry(UUID.fromString("{4674962B-CE11-4916-81C5-0421EE36F168}"), 20), "-000000000000}"), 1), Map.entry(UUID.fromString("{4674962B-CE11-4916-81C5-0421EE36F168}"), 20),
@@ -318,7 +318,7 @@ public final class NullableUnitTests {
// cannot be converted using the 'Ref' helper class unless the method is within the code being modified: // cannot be converted using the 'Ref' helper class unless the method is within the code being modified:
if (c.<LayoutUniqueScope>typeAs().ReadScope(row, ref scope, out scope) == Result.Success) { if (c.<LayoutUniqueScope>typeAs().ReadScope(row, ref scope, out scope) == Result.Success) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: value.NullMap = new Dictionary<Guid, Nullable<byte>>(); //ORIGINAL LINE: value.NullMap = new Dictionary<GuidCodec, Nullable<byte>>();
value.NullMap = new HashMap<UUID, Byte>(); value.NullMap = new HashMap<UUID, Byte>();
RowCursor tupleScope = null; RowCursor tupleScope = null;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'ref' keyword - these
@@ -621,7 +621,7 @@ public final class NullableUnitTests {
ResultAssert.IsSuccess(c.<LayoutUniqueScope>typeAs().WriteScope(row, ref outerScope, ResultAssert.IsSuccess(c.<LayoutUniqueScope>typeAs().WriteScope(row, ref outerScope,
c.typeArgs().clone(), out outerScope)); c.typeArgs().clone(), out outerScope));
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: foreach ((Guid key, Nullable<byte> itemValue) in value.NullMap) //ORIGINAL LINE: foreach ((GuidCodec key, Nullable<byte> itemValue) in value.NullMap)
for ((UUID key,Byte itemValue) :value.NullMap) for ((UUID key,Byte itemValue) :value.NullMap)
{ {
Reference<RowCursor> tempReference_outerScope8 = Reference<RowCursor> tempReference_outerScope8 =
@@ -690,7 +690,7 @@ public final class NullableUnitTests {
public ArrayList<Float> NullArray; public ArrayList<Float> NullArray;
public ArrayList<Boolean> NullBool; public ArrayList<Boolean> NullBool;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public Dictionary<Guid, Nullable<byte>> NullMap; //ORIGINAL LINE: public Dictionary<GuidCodec, Nullable<byte>> NullMap;
public HashMap<UUID, Byte> NullMap; public HashMap<UUID, Byte> NullMap;
public ArrayList<(Integer,Long)>NullTuple public ArrayList<(Integer,Long)>NullTuple
public ArrayList<String> NullSet; public ArrayList<String> NullSet;