From 5f8e221e08690d554e51102c6fde44deb361adc5 Mon Sep 17 00:00:00 2001 From: David Noble Date: Sun, 25 Aug 2019 01:37:22 -0700 Subject: [PATCH] Progressed on port from C# to Java --- .../java/com/azure/data/cosmos/core/Out.java | 4 + .../com/azure/data/cosmos/core/Reference.java | 9 +- .../azure/data/cosmos/core/UtfAnyString.java | 833 ++++++++---------- .../serialization/hybridrow/RowBuffer.java | 81 +- .../serialization/hybridrow/RowCursor.java | 3 +- .../hybridrow/RowCursorExtensions.java | 3 +- .../serialization/hybridrow/io/RowReader.java | 159 ++-- .../hybridrow/io/RowReaderExtensions.java | 5 +- .../serialization/hybridrow/io/RowWriter.java | 5 +- .../json/RowReaderJsonExtensions.java | 5 +- .../hybridrow/layouts/Layout.java | 196 +++-- .../hybridrow/layouts/LayoutArray.java | 2 +- .../hybridrow/layouts/LayoutBinary.java | 19 +- .../hybridrow/layouts/LayoutBoolean.java | 9 +- .../hybridrow/layouts/LayoutCompiler.java | 14 +- .../hybridrow/layouts/LayoutDateTime.java | 9 +- .../hybridrow/layouts/LayoutDecimal.java | 9 +- .../hybridrow/layouts/LayoutEndScope.java | 3 +- .../hybridrow/layouts/LayoutFloat128.java | 9 +- .../hybridrow/layouts/LayoutFloat32.java | 9 +- .../hybridrow/layouts/LayoutFloat64.java | 9 +- .../hybridrow/layouts/LayoutGuid.java | 9 +- .../hybridrow/layouts/LayoutInt16.java | 9 +- .../hybridrow/layouts/LayoutInt32.java | 9 +- .../hybridrow/layouts/LayoutInt64.java | 9 +- .../hybridrow/layouts/LayoutInt8.java | 9 +- .../layouts/LayoutMongoDbObjectId.java | 9 +- .../hybridrow/layouts/LayoutNull.java | 7 +- .../hybridrow/layouts/LayoutNullable.java | 3 +- .../hybridrow/layouts/LayoutObject.java | 3 +- .../hybridrow/layouts/LayoutScope.java | 5 +- .../hybridrow/layouts/LayoutTagged.java | 3 +- .../hybridrow/layouts/LayoutTagged2.java | 6 +- .../hybridrow/layouts/LayoutTuple.java | 5 +- .../hybridrow/layouts/LayoutType.java | 21 +- .../hybridrow/layouts/LayoutType1.java | 3 +- .../hybridrow/layouts/LayoutTypedArray.java | 3 +- .../hybridrow/layouts/LayoutTypedMap.java | 7 +- .../hybridrow/layouts/LayoutTypedSet.java | 3 +- .../hybridrow/layouts/LayoutTypedTuple.java | 4 +- .../hybridrow/layouts/LayoutUDT.java | 5 +- .../hybridrow/layouts/LayoutUInt16.java | 9 +- .../hybridrow/layouts/LayoutUInt32.java | 9 +- .../hybridrow/layouts/LayoutUInt64.java | 9 +- .../hybridrow/layouts/LayoutUInt8.java | 9 +- .../hybridrow/layouts/LayoutUnixDateTime.java | 9 +- .../hybridrow/layouts/LayoutUtf8.java | 19 +- .../hybridrow/layouts/LayoutVarInt.java | 10 +- .../hybridrow/layouts/LayoutVarUInt.java | 11 +- .../hybridrow/layouts/StringToken.java | 2 + .../hybridrow/layouts/StringTokenizer.java | 121 +-- .../hybridrow/recordio/RecordIOFormatter.java | 4 +- .../hybridrow/recordio/RecordIOParser.java | 45 +- .../hybridrow/recordio/RecordIOStream.java | 8 +- .../hybridrow/recordio/RecordSerializer.java | 3 +- .../hybridrow/recordio/SegmentSerializer.java | 2 +- .../main/java/tangible/TryParseHelper.java | 14 +- .../hybridrow/perf/BsonRowGenerator.java | 4 +- .../hybridrow/perf/CodeGenRowGenerator.java | 5 +- .../hybridrow/unit/NullableUnitTests.java | 9 +- .../hybridrow/unit/RecordIOUnitTests.java | 9 +- .../hybridrow/unit/SerializerUnitTest.java | 13 +- .../hybridrow/unit/TypedMapUnitTests.java | 5 +- .../customerschema/AddressSerializer.java | 3 +- .../customerschema/PostalCodeSerializer.java | 3 +- 65 files changed, 853 insertions(+), 1009 deletions(-) diff --git a/jre/src/main/java/com/azure/data/cosmos/core/Out.java b/jre/src/main/java/com/azure/data/cosmos/core/Out.java index ac268e7..6df9abd 100644 --- a/jre/src/main/java/com/azure/data/cosmos/core/Out.java +++ b/jre/src/main/java/com/azure/data/cosmos/core/Out.java @@ -27,6 +27,10 @@ public final class Out { this.value = value; } + public T setAndGet(T value) { + return this.value = value; + } + /** * {@code true} if there is a value present, otherwise {@code false} *

diff --git a/jre/src/main/java/com/azure/data/cosmos/core/Reference.java b/jre/src/main/java/com/azure/data/cosmos/core/Reference.java index 18de7eb..b5ef38f 100644 --- a/jre/src/main/java/com/azure/data/cosmos/core/Reference.java +++ b/jre/src/main/java/com/azure/data/cosmos/core/Reference.java @@ -10,8 +10,8 @@ import java.util.Objects; * A container object which may or may not contain a non-null value * * This is a value-based class and as such use of identity-sensitive operations--including reference equality - * ({@code ==}), identity hash code, or synchronization--on instances of {@Ref} may have unpredictable results and - * should be avoided. + * ({@code ==}), identity hash code, or synchronization--on instances of {@Reference} may have unpredictable results + * and should be avoided. * * @param */ @@ -20,7 +20,7 @@ public final class Reference { private volatile T value; public Reference(T value) { - this.set(value); + this.setAndGet(value); } public T get() { @@ -30,6 +30,9 @@ public final class Reference { public void set(T value) { this.value = value; } + public T setAndGet(T value) { + return this.value = value; + } /** * {@code true} if there is a value present, otherwise {@code false} diff --git a/jre/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java b/jre/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java index db2627d..ffb6f3a 100644 --- a/jre/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java +++ b/jre/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java @@ -1,543 +1,418 @@ -package Microsoft.Azure.Cosmos.Core.Utf8; - -// ------------------------------------------------------------ +//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. -// ------------------------------------------------------------ +//------------------------------------------------------------ -//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: -///#pragma warning disable CA2225 // Operator overloads have named alternates +package com.azure.data.cosmos.core; -// ReSharper disable once UseNameofExpression +import javax.annotation.Nonnull; -/** A string whose memory representation may be either UTF8 or UTF16. - - This type supports polymorphic use of and - when equality, hashing, and comparison are needed against either encoding. An API leveraging - can avoid separate method overloads while still accepting either - encoding without imposing additional allocations. - -*/ -//C# TO JAVA CONVERTER TODO TASK: Java annotations will not correspond to .NET attributes: -//ORIGINAL LINE: [DebuggerDisplay("{ToString()}")] public readonly struct UtfAnyString : IEquatable, IComparable, IEquatable, IComparable, IEquatable, IComparable -//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ from the original: -//ORIGINAL LINE: [DebuggerDisplay("{ToString()}")] public readonly struct UtfAnyString : IEquatable, IComparable, IEquatable, IComparable, IEquatable, IComparable -//C# TO JAVA CONVERTER WARNING: Java has no equivalent to the C# readonly struct: -public final class UtfAnyString implements IEquatable, java.lang.Comparable, IEquatable, java.lang.Comparable, IEquatable, java.lang.Comparable -{ - public static UtfAnyString getEmpty() - { - return ""; +import static com.azure.data.cosmos.core.Utf8String.transcodeUtf16; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * A string whose memory representation may be either UTF-8 or UTF-16 + *

+ * This type supports polymorphic use of {@link String} and {@link Utf8String} when equality, hashing, and comparison + * are needed against either encoding. An API leveraging {@link UtfAnyString} can avoid separate method overloads + * while still accepting either encoding without imposing additional allocations. + */ +public final class UtfAnyString implements CharSequence, Comparable { + + private static final UtfAnyString EMPTY = new UtfAnyString(""); + private static final int NULL_HASHCODE = reduceHashCode(5_381, 5_381); + + private CharSequence buffer; + + public UtfAnyString() { } - private Object buffer; - -//C# TO JAVA CONVERTER TODO TASK: Java annotations will not correspond to .NET attributes: -//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] public UtfAnyString(string utf16String) - public UtfAnyString() - { + public UtfAnyString(final String string) { + this.buffer = string; } - public UtfAnyString(String utf16String) - { - this.buffer = utf16String; - } - -//C# TO JAVA CONVERTER TODO TASK: Java annotations will not correspond to .NET attributes: -//ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] public UtfAnyString(Utf8String utf8String) - public UtfAnyString(Utf8String utf8String) - { + public UtfAnyString(final Utf8String utf8String) { this.buffer = utf8String; } - public boolean getIsUtf8() - { - return this.buffer instanceof Utf8String; + private UtfAnyString(final CharSequence sequence) { + this.buffer = sequence; } - public boolean getIsUtf16() - { - return this.buffer instanceof String; + /** + * {@code true} if the {@link UtfAnyString} is empty + */ + public boolean isEmpty() { + return this.buffer != null && this.buffer.length() == 0; } - /** True if the length is empty. - */ - public boolean getIsNull() - { + /** + * {@code true} if the {@link UtfAnyString} is {@code null} + */ + public boolean isNull() { return null == this.buffer; } - /** True if the length is empty. - */ - public boolean getIsEmpty() - { - if (null == this.buffer) - { + public boolean isUtf16() { + return this.buffer instanceof String; + } + + public boolean isUtf8() { + return this.buffer instanceof Utf8String; + } + + /** + * Returns the {@code char} value at the specified {@code index} + *

+ * An index ranges from zero to {@link UtfAnyString#length()} minus one. The first {@code char} value of the + * sequence is at index zero, the next at index one, and so on, as for array indexing. If the {@code char} + * value specified by the {@code index} is a surrogate, the surrogate (not the surrogate pair) is returned. + * + * @param index the index of the {@code char} value to be returned + * @return the specified {@code char} value + * @throws IndexOutOfBoundsException if the {@code index} argument is negative or not less than + * {@link UtfAnyString#length()} + * @throws UnsupportedOperationException if this {@link UtfAnyString} is {@code null}. + */ + @Override + public char charAt(final int index) { + if (this.buffer == null) { + throw new UnsupportedOperationException("String is null"); + } + return this.buffer.charAt(index); + } + + public UtfAnyString clone() { + return new UtfAnyString(this.buffer); + } + + public int compareTo(@Nonnull final String other) { + + checkNotNull(other); + + if (other == this.buffer) { + return 0; + } + + if (this.buffer == null) { + return -1; + } + + return this.buffer instanceof String + ? ((String) this.buffer).compareTo(other) + : ((Utf8String) this.buffer).compareTo(other); + } + + public int compareTo(@Nonnull final Utf8String other) { + + checkNotNull(other); + + if (other == this.buffer) { + return 0; + } + + if (this.buffer == null) { + return -1; + } + + return this.buffer instanceof String + ? -other.compareTo((String) this.buffer) + : ((Utf8String) this.buffer).compareTo(other); + } + + @Override + public int compareTo(@Nonnull final UtfAnyString other) { + + checkNotNull(other); + + if (other.buffer == this.buffer) { + return 0; + } + + if (other.buffer == null) { + return 1; + } + + if (this.buffer == null) { + return -1; + } + + if (this.buffer instanceof String) { + return other.buffer instanceof String + ? ((String) this.buffer).compareTo((String) other.buffer) + : -((Utf8String) other.buffer).compareTo((String) this.buffer); + } + + return ((Utf8String) this.buffer).compareTo((Utf8String) other.buffer); + } + + public static UtfAnyString empty() { + return EMPTY; + } + + @Override + public boolean equals(final Object other) { + + if (other == null) { return false; } - switch (this.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: - return s.Length == 0; - default: - return ((Utf8String)this.buffer).getIsEmpty(); - } - } - -//C# TO JAVA CONVERTER TODO TASK: The following operator overload is not converted by C# to Java Converter: - public static implicit operator UtfAnyString(String utf16String) - { - return new UtfAnyString(utf16String); - } - -//C# TO JAVA CONVERTER TODO TASK: The following operator overload is not converted by C# to Java Converter: - public static implicit operator string(UtfAnyString str) - { - return str.buffer == null ? null : str.buffer.toString(); - } - - @Override - public String toString() - { - // ReSharper disable once AssignNullToNotNullAttribute - return this.buffer == null ? null : this.buffer.toString(); - } - - public Utf8String ToUtf8String() - { - if (null == this.buffer) - { - return null; + if (other instanceof String) { + return this.equals((String) other); } - switch (this.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: - return Utf8String.TranscodeUtf16(s); - default: - return (Utf8String)this.buffer; - } - } - - public boolean ReferenceEquals(UtfAnyString other) - { - return this.buffer == other.buffer; - } - - public boolean equals(UtfAnyString other) - { - if (null == this.buffer) - { - return null == other.buffer; + if (other instanceof Utf8String) { + return this.equals((Utf8String) other); } - switch (this.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: - return other.equals(s); - default: - return other.equals((Utf8String)this.buffer); - } - } - - public boolean equals(Utf8Span other) - { - return other.equals(this.buffer); - } - - @Override - public boolean equals(Object obj) - { - switch (obj) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: - return this.equals(s); -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case Utf8String s: - case Utf8String s: - return this.equals(s); -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case UtfAnyString s: - case UtfAnyString s: - return this.equals(s); + if (other instanceof UtfAnyString) { + return this.equals((UtfAnyString) other); } return false; } - public boolean equals(Utf8String other) - { - if (null == other) - { + public boolean equals(final String other) { + + if (null == this.buffer) { + return null == other; + } + + if (this.buffer instanceof String) { + return other.contentEquals(this.buffer); // skips the type check that String.equals performs + } + + return ((Utf8String) this.buffer).equals(other); + } + + public boolean equals(final Utf8String other) { + + if (null == other) { return null == this.buffer; } return other.equals(this.buffer); } - public boolean equals(String other) - { - if (null == this.buffer) - { - return null == other; + public boolean equals(final UtfAnyString other) { + + if (null == other) { + return false; } - switch (this.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: - return String.equals(s, other); - default: - return ((Utf8String)this.buffer).equals(other); + if (null == this.buffer) { + return null == other.buffer; } - } - public static boolean opEquals(UtfAnyString left, UtfAnyString right) - { - return left.equals(right.clone()); - } - - public static boolean opNotEquals(UtfAnyString left, UtfAnyString right) - { - return !left.equals(right.clone()); - } - - public static boolean opEquals(UtfAnyString left, String right) - { - return left.equals(right); - } - - public static boolean opNotEquals(UtfAnyString left, String right) - { - return !left.equals(right); - } - - public static boolean opEquals(String left, UtfAnyString right) - { - return right.equals(left); - } - - public static boolean opNotEquals(String left, UtfAnyString right) - { - return !right.equals(left); - } - - public static boolean opEquals(UtfAnyString left, Utf8String right) - { - return left.equals(right); - } - - public static boolean opNotEquals(UtfAnyString left, Utf8String right) - { - return !left.equals(right); - } - - public static boolean opEquals(Utf8String left, UtfAnyString right) - { - return right.equals(left); - } - - public static boolean opNotEquals(Utf8String left, UtfAnyString right) - { - return !right.equals(left); - } - - public static boolean opEquals(UtfAnyString left, Utf8Span right) - { - return left.equals(right); - } - - public static boolean opNotEquals(UtfAnyString left, Utf8Span right) - { - return !left.equals(right); - } - - public static boolean opEquals(Utf8Span left, UtfAnyString right) - { - return right.equals(left); - } - - public static boolean opNotEquals(Utf8Span left, UtfAnyString right) - { - return !right.equals(left); + return this.buffer instanceof String ? other.buffer.equals(this.buffer) : this.buffer.equals(other.buffer); } @Override - public int hashCode() - { -//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: -//ORIGINAL LINE: uint hash1 = 5381; - int hash1 = 5381; -//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: -//ORIGINAL LINE: uint hash2 = hash1; - int hash2 = hash1; + public int hashCode() { - if (null == this.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: There is no Java equivalent to 'unchecked' in this context: -//ORIGINAL LINE: return unchecked((int)(hash1 + (hash2 * 1566083941))); - return (int)(hash1 + (hash2 * 1566083941)); + final long[] hash = { 5_381, 5_381 }; + + if (this.buffer == null) { + return NULL_HASHCODE; } - switch (this.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: -//C# TO JAVA CONVERTER TODO TASK: There is no equivalent to an 'unchecked' block in Java: - unchecked - { - Utf16LittleEndianCodePointEnumerator thisEnumerator = new Utf16LittleEndianCodePointEnumerator(s); - for (int i = 0; thisEnumerator.MoveNext(); i++) - { -//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: -//ORIGINAL LINE: uint c = thisEnumerator.Current; - int c = thisEnumerator.Current; - if (i % 2 == 0) - { - hash1 = ((hash1 << 5) + hash1) ^ c; - } - else - { - hash2 = ((hash2 << 5) + hash2) ^ c; - } - } + if (this.buffer instanceof String) { - return (int)(hash1 + (hash2 * 1566083941)); + final int ignored = ((String) buffer).codePoints().reduce(0, (index, codePoint) -> { + if (index % 2 == 0) { + hash[0] = ((hash[0] << 5) + hash[0]) ^ codePoint; + } else { + hash[1] = ((hash[1] << 5) + hash[1]) ^ codePoint; } + return index; + }); - default: - return this.buffer.hashCode(); - } - } - - public static boolean opLessThan(UtfAnyString left, UtfAnyString right) - { - return left.CompareTo(right.clone()) < 0; - } - - public static boolean opLessThanOrEquals(UtfAnyString left, UtfAnyString right) - { - return left.CompareTo(right.clone()) <= 0; - } - - public static boolean opGreaterThan(UtfAnyString left, UtfAnyString right) - { - return left.CompareTo(right.clone()) > 0; - } - - public static boolean opGreaterThanOrEquals(UtfAnyString left, UtfAnyString right) - { - return left.CompareTo(right.clone()) >= 0; - } - - public static boolean opLessThan(UtfAnyString left, String right) - { - return left.CompareTo(right) < 0; - } - - public static boolean opLessThanOrEquals(UtfAnyString left, String right) - { - return left.CompareTo(right) <= 0; - } - - public static boolean opGreaterThan(UtfAnyString left, String right) - { - return left.CompareTo(right) > 0; - } - - public static boolean opGreaterThanOrEquals(UtfAnyString left, String right) - { - return left.CompareTo(right) >= 0; - } - - public static boolean opLessThan(String left, UtfAnyString right) - { - return right.CompareTo(left) >= 0; - } - - public static boolean opLessThanOrEquals(String left, UtfAnyString right) - { - return right.CompareTo(left) > 0; - } - - public static boolean opGreaterThan(String left, UtfAnyString right) - { - return right.CompareTo(left) <= 0; - } - - public static boolean opGreaterThanOrEquals(String left, UtfAnyString right) - { - return right.CompareTo(left) < 0; - } - - public static boolean opLessThan(UtfAnyString left, Utf8String right) - { - return left.CompareTo(right) < 0; - } - - public static boolean opLessThanOrEquals(UtfAnyString left, Utf8String right) - { - return left.CompareTo(right) <= 0; - } - - public static boolean opGreaterThan(UtfAnyString left, Utf8String right) - { - return left.CompareTo(right) > 0; - } - - public static boolean opGreaterThanOrEquals(UtfAnyString left, Utf8String right) - { - return left.CompareTo(right) >= 0; - } - - public static boolean opLessThan(Utf8String left, UtfAnyString right) - { - return right.CompareTo(left) >= 0; - } - - public static boolean opLessThanOrEquals(Utf8String left, UtfAnyString right) - { - return right.CompareTo(left) > 0; - } - - public static boolean opGreaterThan(Utf8String left, UtfAnyString right) - { - return right.CompareTo(left) <= 0; - } - - public static boolean opGreaterThanOrEquals(Utf8String left, UtfAnyString right) - { - return right.CompareTo(left) < 0; - } - - public static boolean opLessThan(UtfAnyString left, Utf8Span right) - { - return left.CompareTo(right) < 0; - } - - public static boolean opLessThanOrEquals(UtfAnyString left, Utf8Span right) - { - return left.CompareTo(right) <= 0; - } - - public static boolean opGreaterThan(UtfAnyString left, Utf8Span right) - { - return left.CompareTo(right) > 0; - } - - public static boolean opGreaterThanOrEquals(UtfAnyString left, Utf8Span right) - { - return left.CompareTo(right) >= 0; - } - - public static boolean opLessThan(Utf8Span left, UtfAnyString right) - { - return right.CompareTo(left) >= 0; - } - - public static boolean opLessThanOrEquals(Utf8Span left, UtfAnyString right) - { - return right.CompareTo(left) > 0; - } - - public static boolean opGreaterThan(Utf8Span left, UtfAnyString right) - { - return right.CompareTo(left) <= 0; - } - - public static boolean opGreaterThanOrEquals(Utf8Span left, UtfAnyString right) - { - return right.CompareTo(left) < 0; - } - - public int CompareTo(UtfAnyString other) - { - if (null == other.buffer) - { - return null == this.buffer ? 0 : 1; + return reduceHashCode(hash[0], hash[1]); } - switch (other.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: - return this.CompareTo(s); - default: - return this.CompareTo((Utf8String)other.buffer); - } + return this.buffer.hashCode(); } - public int CompareTo(Utf8String other) - { - if (null == this.buffer) - { - return null == other ? 0 : -1; - } - - switch (this.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: - return -other.getSpan().CompareTo(s); - default: - return -other.getSpan().CompareTo((Utf8String)this.buffer); + /** + * Returns the length of this character sequence. The length is the number + * of 16-bit {@code char}s in the sequence. + * + * @return the number of {@code char}s in this sequence + * + * @throws UnsupportedOperationException if this {@link UtfAnyString} is {@code null} + */ + @Override + public int length() { + if (this.buffer == null) { + throw new UnsupportedOperationException("String is null"); } + return this.buffer.length(); } - public int CompareTo(Utf8Span other) - { - if (null == this.buffer) - { - return -1; - } - - switch (this.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: - return -other.CompareTo(s); - default: - return -other.CompareTo((Utf8String)this.buffer); - } + public static boolean opEquals(UtfAnyString left, UtfAnyString right) { + return left.equals(right.clone()); } - public int CompareTo(String other) - { - if (null == this.buffer) - { - return null == other ? 0 : -1; - } - - switch (this.buffer) - { -//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C# pattern variables in 'case' statements: -//ORIGINAL LINE: case string s: - case String s: - return String.Compare(s, other, StringComparison.Ordinal); - default: - return ((Utf8String)this.buffer).compareTo(other); - } + public static boolean opEquals(UtfAnyString left, String right) { + return left.equals(right); } - public UtfAnyString clone() - { - UtfAnyString varCopy = new UtfAnyString(); + public static boolean opEquals(String left, UtfAnyString right) { + return right.equals(left); + } - varCopy.buffer = this.buffer; + public static boolean opEquals(UtfAnyString left, Utf8String right) { + return left.equals(right); + } - return varCopy; + public static boolean opEquals(Utf8String left, UtfAnyString right) { + return right.equals(left); + } + + public static boolean opGreaterThan(UtfAnyString left, UtfAnyString right) { + return left.compareTo(right.clone()) > 0; + } + + public static boolean opGreaterThan(UtfAnyString left, String right) { + return left.compareTo(right) > 0; + } + + public static boolean opGreaterThan(String left, UtfAnyString right) { + return right.compareTo(left) <= 0; + } + + public static boolean opGreaterThan(UtfAnyString left, Utf8String right) { + return left.compareTo(right) > 0; + } + + public static boolean opGreaterThan(Utf8String left, UtfAnyString right) { + return right.compareTo(left) <= 0; + } + + public static boolean opGreaterThanOrEquals(UtfAnyString left, UtfAnyString right) { + return left.compareTo(right.clone()) >= 0; + } + + public static boolean opGreaterThanOrEquals(UtfAnyString left, String right) { + return left.compareTo(right) >= 0; + } + + public static boolean opGreaterThanOrEquals(String left, UtfAnyString right) { + return right.compareTo(left) < 0; + } + + public static boolean opGreaterThanOrEquals(UtfAnyString left, Utf8String right) { + return left.compareTo(right) >= 0; + } + + public static boolean opGreaterThanOrEquals(Utf8String left, UtfAnyString right) { + return right.compareTo(left) < 0; + } + + public static boolean opLessThan(UtfAnyString left, UtfAnyString right) { + return left.compareTo(right.clone()) < 0; + } + + public static boolean opLessThan(UtfAnyString left, String right) { + return left.compareTo(right) < 0; + } + + public static boolean opLessThan(String left, UtfAnyString right) { + return right.compareTo(left) >= 0; + } + + public static boolean opLessThan(UtfAnyString left, Utf8String right) { + return left.compareTo(right) < 0; + } + + public static boolean opLessThan(Utf8String left, UtfAnyString right) { + return right.compareTo(left) >= 0; + } + + public static boolean opLessThanOrEquals(UtfAnyString left, UtfAnyString right) { + return left.compareTo(right.clone()) <= 0; + } + + public static boolean opLessThanOrEquals(UtfAnyString left, String right) { + return left.compareTo(right) <= 0; + } + + public static boolean opLessThanOrEquals(String left, UtfAnyString right) { + return right.compareTo(left) > 0; + } + + public static boolean opLessThanOrEquals(UtfAnyString left, Utf8String right) { + return left.compareTo(right) <= 0; + } + + public static boolean opLessThanOrEquals(Utf8String left, UtfAnyString right) { + return right.compareTo(left) > 0; + } + + public static boolean opNotEquals(UtfAnyString left, UtfAnyString right) { + return !left.equals(right.clone()); + } + + public static boolean opNotEquals(UtfAnyString left, String right) { + return !left.equals(right); + } + + public static boolean opNotEquals(String left, UtfAnyString right) { + return !right.equals(left); + } + + public static boolean opNotEquals(UtfAnyString left, Utf8String right) { + return !left.equals(right); + } + + public static boolean opNotEquals(Utf8String left, UtfAnyString right) { + return !right.equals(left); + } + + /** + * Returns a {@code CharSequence} that is a subsequence of this sequence + *

+ * The subsequence starts with the {@code char} value at the specified index and ends with the{@code char} value at + * index {@code end - 1}. The length (in {@code char}s) of the returned sequence is {@code end - start}, so if + * {@code start == end}, an empty sequence is returned. + * + * @param start the start index, inclusive + * @param end the end index, exclusive + * @return the specified subsequence + * @throws IndexOutOfBoundsException if {@code start} or {@code end} are negative, {@code end} is greater than + * {@link UtfAnyString#length()}, or {@code start} is greater than {@code + * end}. + * @throws UnsupportedOperationException if string is {@code null} + */ + @Override + @Nonnull + public CharSequence subSequence(final int start, final int end) { + if (this.buffer == null) { + throw new UnsupportedOperationException("String is null"); + } + return this.buffer.subSequence(start, end); + } + + @Override + @Nonnull + public String toString() { + return String.valueOf(this.buffer); + } + + public String toUtf16() { + if (null == this.buffer) { + return null; + } + return this.buffer instanceof String ? (String) this.buffer : this.buffer.toString(); + } + + public Utf8String toUtf8() { + if (null == this.buffer) { + return null; + } + return this.buffer instanceof String ? transcodeUtf16((String) this.buffer) : (Utf8String) this.buffer; + } + + private static int reduceHashCode(final long h1, final long h2) { + return Long.valueOf(h1 + (h2 * 1_566_083_941L)).intValue(); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java index 1b29692..a33e6ca 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutBit; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode; @@ -117,8 +116,8 @@ public final class RowBuffer { HybridRowHeader header = this.ReadHeader(0).clone(); checkState(header.getVersion() == version); Layout layout = resolver.Resolve(header.getSchemaId().clone()); - checkState(SchemaId.opEquals(header.getSchemaId().clone(), layout.getSchemaId().clone())); - checkState(HybridRowHeader.Size + layout.getSize() <= this.length); + checkState(SchemaId.opEquals(header.getSchemaId().clone(), layout.schemaId().clone())); + checkState(HybridRowHeader.Size + layout.size() <= this.length); } /** @@ -156,11 +155,11 @@ public final class RowBuffer { return scopeOffset; } - int index = layout.getNumFixed() + varIndex; - ReadOnlySpan columns = layout.getColumns(); + int index = layout.numFixed() + varIndex; + ReadOnlySpan columns = layout.columns(); checkState(index <= columns.Length); - int offset = scopeOffset + layout.getSize(); - for (int i = layout.getNumFixed(); i < index; i++) { + 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; @@ -277,14 +276,14 @@ public final class RowBuffer { this.resolver = resolver; // Ensure sufficient space for fixed schema fields. - this.Ensure(HybridRowHeader.Size + layout.getSize()); - this.length = HybridRowHeader.Size + layout.getSize(); + this.Ensure(HybridRowHeader.Size + layout.size()); + this.length = HybridRowHeader.Size + layout.size(); // Clear all presence bits. - this.buffer.Slice(HybridRowHeader.Size, layout.getSize()).Fill(0); + this.buffer.Slice(HybridRowHeader.Size, layout.size()).Fill(0); // Set the header. - this.WriteHeader(0, new HybridRowHeader(version, layout.getSchemaId().clone())); + this.WriteHeader(0, new HybridRowHeader(version, layout.schemaId().clone())); } /** @@ -360,7 +359,7 @@ public final class RowBuffer { //ORIGINAL LINE: ulong b = this.buffer[offset]; long b = this.buffer[offset]; if (b < 0x80L) { - lenInBytes.set(1); + lenInBytes.setAndGet(1); return b; } @@ -375,7 +374,7 @@ public final class RowBuffer { shift += 7; } while (b >= 0x80L); - lenInBytes.set(shift / 7); + lenInBytes.setAndGet(shift / 7); return retval; } @@ -625,14 +624,14 @@ public final class RowBuffer { int token = (int)this.Read7BitEncodedUInt(offset, tempOut_sizeLenInBytes); sizeLenInBytes = tempOut_sizeLenInBytes.get(); if (token < layout.getTokenizer().getCount()) { - pathLenInBytes.set(sizeLenInBytes); - pathOffset.set(offset); + pathLenInBytes.setAndGet(sizeLenInBytes); + pathOffset.setAndGet(offset); return token; } int numBytes = token - layout.getTokenizer().getCount(); - pathLenInBytes.set(numBytes + sizeLenInBytes); - pathOffset.set(offset + sizeLenInBytes); + pathLenInBytes.setAndGet(numBytes + sizeLenInBytes); + pathOffset.setAndGet(offset + sizeLenInBytes); return token; } @@ -1065,7 +1064,7 @@ public final class RowBuffer { { Layout udt = this.resolver.Resolve(edit.get().cellTypeArgs.getSchemaId().clone()); int valueOffset = this.ComputeVariableValueOffset(udt, edit.get().valueOffset, - udt.getNumVariable()); + udt.numVariable()); RowCursor tempVar6 = new RowCursor(); tempVar6.scopeType = scopeType; tempVar6.scopeTypeArgs = edit.get().cellTypeArgs.clone(); @@ -1407,7 +1406,7 @@ public final class RowBuffer { } int valueOffset = edit.get().valueOffset + 1; - newScope.set(new RowCursor()); + newScope.setAndGet(new RowCursor()); newScope.get().scopeType = scopeType; newScope.get().scopeTypeArgs = typeArgs.clone(); newScope.get().start = edit.get().valueOffset; @@ -1446,7 +1445,7 @@ public final class RowBuffer { this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); this.WriteSparseTypeCode(edit.get().valueOffset, LayoutCode.EndScope); checkState(spaceNeeded == metaBytes + numBytes); - newScope.set(new RowCursor()); + newScope.setAndGet(new RowCursor()); newScope.get().scopeType = scopeType; newScope.get().scopeTypeArgs = typeArgs.clone(); newScope.get().start = edit.get().valueOffset; @@ -1792,7 +1791,7 @@ public final class RowBuffer { this.WriteSparseMetadata(edit, scopeType, TypeArgumentList.Empty, metaBytes); this.WriteSparseTypeCode(edit.get().valueOffset, LayoutCode.EndScope); checkState(spaceNeeded == metaBytes + numBytes); - newScope.set(new RowCursor()); + newScope.setAndGet(new RowCursor()); newScope.get().scopeType = scopeType; newScope.get().scopeTypeArgs = TypeArgumentList.Empty; newScope.get().start = edit.get().valueOffset; @@ -1849,7 +1848,7 @@ public final class RowBuffer { this.WriteSparseTypeCode(valueOffset, LayoutCode.EndScope); checkState(spaceNeeded == metaBytes + numBytes); - newScope.set(new RowCursor()); + newScope.setAndGet(new RowCursor()); newScope.get().scopeType = scopeType; newScope.get().scopeTypeArgs = typeArgs.clone(); newScope.get().start = edit.get().valueOffset; @@ -1872,8 +1871,8 @@ public final class RowBuffer { public void WriteSparseUDT(Reference edit, LayoutScope scopeType, Layout udt, UpdateOptions options, Out newScope) { - TypeArgumentList typeArgs = new TypeArgumentList(udt.getSchemaId().clone()); - int numBytes = udt.getSize() + (LayoutCode.SIZE / Byte.SIZE); + TypeArgumentList typeArgs = new TypeArgumentList(udt.schemaId().clone()); + int numBytes = udt.size() + (LayoutCode.SIZE / Byte.SIZE); int metaBytes; Out tempOut_metaBytes = new Out(); int spaceNeeded; @@ -1888,13 +1887,13 @@ public final class RowBuffer { this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); // Clear all presence bits. - this.buffer.Slice(edit.get().valueOffset, udt.getSize()).Fill(0); + this.buffer.Slice(edit.get().valueOffset, udt.size()).Fill(0); // Write scope terminator. - int valueOffset = edit.get().valueOffset + udt.getSize(); + int valueOffset = edit.get().valueOffset + udt.size(); this.WriteSparseTypeCode(valueOffset, LayoutCode.EndScope); checkState(spaceNeeded == metaBytes + numBytes); - newScope.set(new RowCursor()); + newScope.setAndGet(new RowCursor()); newScope.get().scopeType = scopeType; newScope.get().scopeTypeArgs = typeArgs.clone(); newScope.get().start = edit.get().valueOffset; @@ -2083,7 +2082,7 @@ public final class RowBuffer { checkState(spaceNeeded == metaBytes + numBytes); this.WriteUInt32(edit.get().valueOffset, 0); int valueOffset = edit.get().valueOffset + (Integer.SIZE / Byte.SIZE); // Point after the Size - newScope.set(new RowCursor()); + newScope.setAndGet(new RowCursor()); newScope.get().scopeType = scopeType; newScope.get().scopeTypeArgs = typeArgs.clone(); newScope.get().start = edit.get().valueOffset; @@ -2112,7 +2111,7 @@ public final class RowBuffer { checkState(spaceNeeded == metaBytes + numBytes); this.WriteUInt32(edit.get().valueOffset, 0); int valueOffset = edit.get().valueOffset + (Integer.SIZE / Byte.SIZE); // Point after the Size - newScope.set(new RowCursor()); + newScope.setAndGet(new RowCursor()); newScope.get().scopeType = scopeType; newScope.get().scopeTypeArgs = typeArgs.clone(); newScope.get().start = edit.get().valueOffset; @@ -2141,7 +2140,7 @@ public final class RowBuffer { checkState(spaceNeeded == metaBytes + numBytes); this.WriteUInt32(edit.get().valueOffset, 0); int valueOffset = edit.get().valueOffset + (Integer.SIZE / Byte.SIZE); // Point after the Size - newScope.set(new RowCursor()); + newScope.setAndGet(new RowCursor()); newScope.get().scopeType = scopeType; newScope.get().scopeTypeArgs = typeArgs.clone(); newScope.get().start = edit.get().valueOffset; @@ -2170,7 +2169,7 @@ public final class RowBuffer { int numWritten = this.WriteDefaultValue(edit.get().valueOffset, scopeType, typeArgs.clone()); checkState(numBytes == numWritten); checkState(spaceNeeded == metaBytes + numBytes); - newScope.set(new RowCursor()); + newScope.setAndGet(new RowCursor()); newScope.get().scopeType = scopeType; newScope.get().scopeTypeArgs = typeArgs.clone(); newScope.get().start = edit.get().valueOffset; @@ -2701,15 +2700,15 @@ public final class RowBuffer { // Compute the metadata offsets if (edit.get().scopeType.HasImplicitTypeCode(edit)) { - metaBytes.set(0); + metaBytes.setAndGet(0); } else { - metaBytes.set(cellType.CountTypeArgument(typeArgs.clone())); + metaBytes.setAndGet(cellType.CountTypeArgument(typeArgs.clone())); } if (!edit.get().scopeType.IsIndexedScope) { checkState(edit.get().writePath != null); int pathLenInBytes = RowBuffer.CountSparsePath(edit); - metaBytes.set(metaBytes.get() + pathLenInBytes); + metaBytes.setAndGet(metaBytes.get() + pathLenInBytes); } if (edit.get().exists) { @@ -2717,8 +2716,8 @@ public final class RowBuffer { spaceAvailable = this.SparseComputeSize(edit); } - spaceNeeded.set(options == RowOptions.Delete ? 0 : metaBytes.get() + numBytes); - shift.set(spaceNeeded.get() - spaceAvailable); + spaceNeeded.setAndGet(options == RowOptions.Delete ? 0 : metaBytes.get() + numBytes); + shift.setAndGet(spaceNeeded.get() - spaceAvailable); if (shift.get() > 0) { this.Ensure(this.length + shift.get()); } @@ -2772,15 +2771,15 @@ public final class RowBuffer { } if (isVarint) { - spaceNeeded.set(numBytes); + spaceNeeded.setAndGet(numBytes); } else { spaceAvailable += (int)existingValueBytes; // size already in spaceAvailable //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: spaceNeeded = numBytes + RowBuffer.Count7BitEncodedUInt((ulong)numBytes); - spaceNeeded.set(numBytes + RowBuffer.Count7BitEncodedUInt(numBytes)); + spaceNeeded.setAndGet(numBytes + RowBuffer.Count7BitEncodedUInt(numBytes)); } - shift.set(spaceNeeded.get() - spaceAvailable); + shift.setAndGet(spaceNeeded.get() - spaceAvailable); if (shift.get() > 0) { this.Ensure(this.length + shift.get()); this.buffer.Slice(offset + spaceAvailable, this.length - (offset + spaceAvailable)).CopyTo(this.buffer.Slice(offset + spaceNeeded.get())); @@ -2798,8 +2797,8 @@ public final class RowBuffer { private boolean InitReadFrom(HybridRowVersion rowVersion) { HybridRowHeader header = this.ReadHeader(0).clone(); Layout layout = this.resolver.Resolve(header.getSchemaId().clone()); - checkState(SchemaId.opEquals(header.getSchemaId().clone(), layout.getSchemaId().clone())); - return (header.getVersion() == rowVersion) && (HybridRowHeader.Size + layout.getSize() <= this.length); + checkState(SchemaId.opEquals(header.getSchemaId().clone(), layout.schemaId().clone())); + return (header.getVersion() == rowVersion) && (HybridRowHeader.Size + layout.size() <= this.length); } /** diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java index a76de77..99054af 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java @@ -9,7 +9,6 @@ package com.azure.data.cosmos.serialization.hybridrow; // ReSharper disable InconsistentNaming -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope; @@ -107,7 +106,7 @@ public final class RowCursor { SchemaId schemaId = row.get().ReadSchemaId(1).clone(); Layout layout = row.get().getResolver().Resolve(schemaId.clone()); int sparseSegmentOffset = row.get().ComputeVariableValueOffset(layout, HybridRowHeader.Size, - layout.getNumVariable()); + layout.numVariable()); RowCursor tempVar = new RowCursor(); tempVar.layout = layout; tempVar.scopeType = LayoutType.UDT; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursorExtensions.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursorExtensions.java index 4ac75f7..d31ae66 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursorExtensions.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursorExtensions.java @@ -4,7 +4,6 @@ package com.azure.data.cosmos.serialization.hybridrow; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutEndScope; @@ -123,7 +122,7 @@ public final class RowCursorExtensions { // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: //#if DEBUG - childScope.set(null); + childScope.setAndGet(null); //#endif } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java index bf8e172..e99282e 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.io; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Float128; import com.azure.data.cosmos.serialization.hybridrow.NullValue; import com.azure.data.cosmos.serialization.hybridrow.Result; @@ -111,8 +110,8 @@ public final class RowReader { public RowReader(Reference row, final Checkpoint checkpoint) { this.row = row.get().clone(); - this.columns = checkpoint.Cursor.layout.getColumns(); - this.schematizedCount = checkpoint.Cursor.layout.getNumFixed() + checkpoint.Cursor.layout.getNumVariable(); + this.columns = checkpoint.Cursor.layout.columns(); + this.schematizedCount = checkpoint.Cursor.layout.numFixed() + checkpoint.Cursor.layout.numVariable(); this.state = checkpoint.State; this.cursor = checkpoint.Cursor.clone(); @@ -122,8 +121,8 @@ public final class RowReader { private RowReader(Reference row, final RowCursor scope) { this.cursor = scope.clone(); this.row = row.get().clone(); - this.columns = this.cursor.layout.getColumns(); - this.schematizedCount = this.cursor.layout.getNumFixed() + this.cursor.layout.getNumVariable(); + this.columns = this.cursor.layout.columns(); + this.schematizedCount = this.cursor.layout.numFixed() + this.cursor.layout.numVariable(); this.state = States.None; this.columnIndex = -1; @@ -354,7 +353,7 @@ public final class RowReader { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: Result r = this.ReadBinary(out ReadOnlySpan span); Result r = this.ReadBinary(out span); - value.set((r == Result.Success) ? span.ToArray() :) + value.setAndGet((r == Result.Success) ? span.ToArray() :) default return r; } @@ -373,17 +372,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutBinary)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseBinary(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseBinary(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(null); + value.setAndGet(null); return Result.Failure; } } @@ -400,17 +399,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutBoolean)) { - value.set(false); + value.setAndGet(false); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseBool(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseBool(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(false); + value.setAndGet(false); return Result.Failure; } } @@ -427,17 +426,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutDateTime)) { - value.set(LocalDateTime.MIN); + value.setAndGet(LocalDateTime.MIN); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseDateTime(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseDateTime(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(LocalDateTime.MIN); + value.setAndGet(LocalDateTime.MIN); return Result.Failure; } } @@ -454,17 +453,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutDecimal)) { - value.set(new BigDecimal(0)); + value.setAndGet(new BigDecimal(0)); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseDecimal(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseDecimal(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(new BigDecimal(0)); + value.setAndGet(new BigDecimal(0)); return Result.Failure; } } @@ -481,17 +480,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value.clone()); case Sparse: if (!(this.cursor.cellType instanceof LayoutFloat128)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseFloat128(tempReference_cursor).clone()); + value.setAndGet(this.row.ReadSparseFloat128(tempReference_cursor).clone()); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(null); + value.setAndGet(null); return Result.Failure; } } @@ -508,17 +507,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutFloat32)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseFloat32(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseFloat32(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -535,17 +534,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutFloat64)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseFloat64(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseFloat64(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -562,17 +561,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutGuid)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseGuid(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseGuid(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(null); + value.setAndGet(null); return Result.Failure; } } @@ -589,17 +588,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutInt16)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseInt16(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseInt16(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -616,17 +615,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutInt32)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseInt32(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseInt32(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -643,17 +642,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutInt64)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseInt64(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseInt64(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -670,17 +669,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutInt8)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseInt8(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseInt8(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -697,17 +696,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value.clone()); case Sparse: if (!(this.cursor.cellType instanceof LayoutMongoDbObjectId)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseMongoDbObjectId(tempReference_cursor).clone()); + value.setAndGet(this.row.ReadSparseMongoDbObjectId(tempReference_cursor).clone()); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(null); + value.setAndGet(null); return Result.Failure; } } @@ -724,17 +723,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value.clone()); case Sparse: if (!(this.cursor.cellType instanceof LayoutNull)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseNull(tempReference_cursor).clone()); + value.setAndGet(this.row.ReadSparseNull(tempReference_cursor).clone()); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(null); + value.setAndGet(null); return Result.Failure; } } @@ -807,7 +806,7 @@ public final class RowReader { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: Result r = this.ReadString(out span); - value.set((r == Result.Success) ? span.toString() :) + value.setAndGet((r == Result.Success) ? span.toString() :) default return r; } @@ -823,7 +822,7 @@ public final class RowReader { // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: Result r = this.ReadString(out span); - value.set((r == Result.Success) ? Utf8String.CopyFrom(span) :) + value.setAndGet((r == Result.Success) ? Utf8String.CopyFrom(span) :) default return r; } @@ -840,17 +839,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutUtf8)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseString(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseString(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(null); + value.setAndGet(null); return Result.Failure; } } @@ -869,17 +868,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutUInt16)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseUInt16(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseUInt16(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -898,17 +897,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutUInt32)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseUInt32(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseUInt32(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -927,17 +926,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutUInt64)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseUInt64(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseUInt64(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -956,17 +955,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutUInt8)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseUInt8(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseUInt8(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -983,17 +982,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value.clone()); case Sparse: if (!(this.cursor.cellType instanceof LayoutUnixDateTime)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseUnixDateTime(tempReference_cursor).clone()); + value.setAndGet(this.row.ReadSparseUnixDateTime(tempReference_cursor).clone()); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(null); + value.setAndGet(null); return Result.Failure; } } @@ -1010,17 +1009,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutVarInt)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseVarInt(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseVarInt(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -1039,17 +1038,17 @@ public final class RowReader { return this.ReadPrimitiveValue(value); case Sparse: if (!(this.cursor.cellType instanceof LayoutVarUInt)) { - value.set(0); + value.setAndGet(0); return Result.TypeMismatch; } Reference tempReference_cursor = new Reference(this.cursor); - value.set(this.row.ReadSparseVarUInt(tempReference_cursor)); + value.setAndGet(this.row.ReadSparseVarUInt(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: - value.set(0); + value.setAndGet(0); return Result.Failure; } } @@ -1107,7 +1106,7 @@ public final class RowReader { LayoutColumn col = this.columns[this.columnIndex]; LayoutType t = this.columns[this.columnIndex].Type; if (!(t instanceof LayoutType)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } @@ -1130,7 +1129,7 @@ public final class RowReader { return tempVar2; default: throw new IllegalStateException(); - value.set(null); + value.setAndGet(null); return Result.Failure; } } @@ -1145,7 +1144,7 @@ public final class RowReader { LayoutColumn col = this.columns[this.columnIndex]; LayoutType t = this.columns[this.columnIndex].Type; if (!(t instanceof ILayoutUtf8SpanReadable)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } @@ -1167,7 +1166,7 @@ public final class RowReader { return tempVar2; default: throw new IllegalStateException(); - value.set(null); + value.setAndGet(null); return Result.Failure; } } @@ -1183,7 +1182,7 @@ public final class RowReader { LayoutColumn col = this.columns[this.columnIndex]; LayoutType t = this.columns[this.columnIndex].Type; if (!(t instanceof ILayoutSpanReadable)) { - value.set(null); + value.setAndGet(null); return Result.TypeMismatch; } @@ -1204,7 +1203,7 @@ public final class RowReader { return tempVar2; default: throw new IllegalStateException(); - value.set(null); + value.setAndGet(null); return Result.Failure; } } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java index 08c91ff..378a190 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.io; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import java.util.ArrayList; @@ -61,11 +60,11 @@ public final class RowReaderExtensions { }); if (r != Result.Success) { - list.set(null); + list.setAndGet(null); return r; } - list.set(ctx.List); + list.setAndGet(ctx.List); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java index 14902dd..3e34909 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.io; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Float128; import com.azure.data.cosmos.serialization.hybridrow.NullValue; import com.azure.data.cosmos.serialization.hybridrow.Result; @@ -169,13 +168,13 @@ public final class RowWriter { RowWriter writer = new RowWriter(row, tempReference_scope); scope = tempReference_scope.get(); TypeArgument typeArg = new TypeArgument(LayoutType.UDT, - new TypeArgumentList(scope.layout.getSchemaId().clone())); + new TypeArgumentList(scope.layout.schemaId().clone())); Reference tempReference_writer = new Reference(writer); // TODO: C# TO JAVA CONVERTER: The following line could not be converted: Result result = func(ref writer, typeArg, context); writer = tempReference_writer.get(); - row.set(writer.row.clone()); + row.setAndGet(writer.row.clone()); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java index eaee737..5263e1f 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.json; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Float128; import com.azure.data.cosmos.serialization.hybridrow.NullValue; import com.azure.data.cosmos.serialization.hybridrow.Result; @@ -43,13 +42,13 @@ public final class RowReaderJsonExtensions { ctx.Builder.append("{"); Result result = RowReaderJsonExtensions.ToJson(reader, ctx.clone()); if (result != Result.Success) { - str.set(null); + str.setAndGet(null); return result; } ctx.Builder.append(ctx.NewLine); ctx.Builder.append("}"); - str.set(ctx.Builder.toString()); + str.setAndGet(ctx.Builder.toString()); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java index b376bb2..fab5740 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java @@ -6,6 +6,7 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Utf8String; +import com.azure.data.cosmos.core.UtfAnyString; import com.azure.data.cosmos.serialization.hybridrow.SchemaId; import com.azure.data.cosmos.serialization.hybridrow.schemas.Namespace; import com.azure.data.cosmos.serialization.hybridrow.schemas.Schema; @@ -28,69 +29,43 @@ import java.util.HashMap; */ public final class Layout { - // TODO: C# TO JAVA CONVERTER: - // Java annotations will not correspond to .NET attributes: - // ORIGINAL LINE: - // [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Type is immutable.")] public static readonly Layout Empty = SystemSchema.LayoutResolver.Resolve(SystemSchema.EmptySchemaId); + public static final Layout EMPTY = SystemSchema.LayoutResolver.Resolve(SystemSchema.EmptySchemaId); - public static final Layout Empty = SystemSchema.LayoutResolver.Resolve(SystemSchema.EmptySchemaId); - /** - * Name of the layout. - *

- * Usually this is the name of the {@link Schema} from which this {@link Layout} was generated. - */ - private String Name; - /** - * The number of bit mask bytes allocated within the layout. - *

- * A presence bit is allocated for each fixed and variable-length field. Sparse columns - * never have presence bits. Fixed boolean allocate an additional bit from the bitmask to store their - * value. - */ - private int NumBitmaskBytes; - /** - * The number of fixed columns. - */ - private int NumFixed; - /** - * The number of variable-length columns. - */ - private int NumVariable; - /** - * Unique identifier of the schema from which this {@link Layout} was generated. - */ - private com.azure.data.cosmos.serialization.hybridrow.SchemaId SchemaId = new SchemaId(); - /** - * Minimum required size of a row of this layout. - *

- * This size excludes all sparse columns, and assumes all columns (including variable) are - * null. - */ - private int Size; - private HashMap pathMap; - private HashMap pathStringMap; - private LayoutColumn[] topColumns; + private final String name; + private final int numBitmaskBytes; + private final int numFixed; + private final int numVariable; + private final HashMap pathMap; + private final HashMap pathStringMap; + private final SchemaId schemaId = new SchemaId(); + private final int size; + private final StringTokenizer tokenizer; + private final LayoutColumn[] topColumns; public Layout(String name, SchemaId schemaId, int numBitmaskBytes, int minRequiredSize, ArrayList columns) { - this.Name = name; - this.SchemaId = schemaId.clone(); - this.NumBitmaskBytes = numBitmaskBytes; - this.Size = minRequiredSize; - this.Tokenizer = new StringTokenizer(); + + this.name = name; + this.schemaId = schemaId.clone(); + this.numBitmaskBytes = numBitmaskBytes; + this.size = minRequiredSize; + this.tokenizer = new StringTokenizer(); this.pathMap = new HashMap(columns.size(), SamplingUtf8StringComparer.Default); this.pathStringMap = new HashMap(columns.size()); - this.NumFixed = 0; - this.NumVariable = 0; - ArrayList top = new ArrayList(columns.size()); + final ArrayList top = new ArrayList(columns.size()); + int numFixed = 0; + int numVariable = 0; + for (LayoutColumn c : columns) { - this.getTokenizer().Add(c.getPath()); + + this.tokenizer().add(c.getPath()); this.pathMap.put(c.getFullPath(), c); this.pathStringMap.put(c.getFullPath().toString(), c); + if (c.getStorage() == StorageKind.Fixed) { - this.NumFixed = this.getNumFixed() + 1; + numFixed++; } else if (c.getStorage() == StorageKind.Variable) { - this.NumVariable = this.getNumVariable() + 1; + numVariable++; } if (c.getParent() == null) { @@ -98,40 +73,11 @@ public final class Layout { } } + this.numFixed = numFixed; + this.numVariable = numVariable; this.topColumns = top.toArray(new LayoutColumn[0]); } - /** - * The set of top level columns defined in the layout (in left-to-right order). - */ - public ReadOnlySpan getColumns() { - return this.topColumns.AsSpan(); - } - - public String getName() { - return Name; - } - - public int getNumBitmaskBytes() { - return NumBitmaskBytes; - } - - public int getNumFixed() { - return NumFixed; - } - - public int getNumVariable() { - return NumVariable; - } - - public SchemaId getSchemaId() { - return SchemaId; - } - - public int getSize() { - return Size; - } - /** * Finds a column specification for a column with a matching path. * @@ -141,16 +87,17 @@ public final class Layout { */ public boolean TryFind(UtfAnyString path, Out column) { - if (path.IsNull) { - column.set(null); + if (path.isNull()) { + column.setAndGet(null); return false; } - if (path.IsUtf8) { - return (this.pathMap.containsKey(path.ToUtf8String()) && (column.set(this.pathMap.get(path.ToUtf8String()))) == column.get()); + if (path.isUtf8()) { + return (this.pathMap.containsKey(path.toUtf8()) && (column.setAndGet(this.pathMap.get(path.toUtf8()))) == column.get()); } - return (this.pathStringMap.containsKey(path) && (column.set(this.pathStringMap.get(path))) == column.get()); + String value = path.toUtf16(); + return (this.pathStringMap.containsKey(value) && (column.setAndGet(this.pathStringMap.get(value))) == column.get()); } /** @@ -161,19 +108,80 @@ public final class Layout { * @return True if a column with the path is found, otherwise false. */ public boolean TryFind(String path, Out column) { - return (this.pathStringMap.containsKey(path) && (column.set(this.pathStringMap.get(path))) == column.get()); + return (this.pathStringMap.containsKey(path) && (column.setAndGet(this.pathStringMap.get(path))) == column.get()); } /** - * Returns a human readable diagnostic string representation of this {@link Layout}. + * The set of top level columns defined in the layout (in left-to-right order). + */ + public ReadOnlySpan columns() { + return this.topColumns.AsSpan(); + } + + /** + * Name of the layout. + *

+ * Usually this is the name of the {@link Schema} from which this {@link Layout} was generated. + */ + public String name() { + return this.name; + } + + /** + * The number of bit mask bytes allocated within the layout. + *

+ * A presence bit is allocated for each fixed and variable-length field. Sparse columns never have presence bits. + * Fixed boolean allocate an additional bit from the bitmask to store their value. + */ + public int numBitmaskBytes() { + return this.numBitmaskBytes; + } + + /** + * The number of fixed columns. + */ + public int numFixed() { + return this.numFixed; + } + + /** + * The number of variable-length columns. + */ + public int numVariable() { + return this.numVariable; + } + + /** + * Unique identifier of the schema from which this {@link Layout} was generated. + */ + public SchemaId schemaId() { + return this.schemaId; + } + + /** + * Minimum required size of a row of this layout. + *

+ * This size excludes all sparse columns, and assumes all columns (including variable) are + * null. + */ + public int size() { + return this.size; + } + + /** + * Returns a human readable diagnostic string representation of this {@link Layout} + *

* This representation should only be used for debugging and diagnostic purposes. */ @Override public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Layout:\n"); sb.append(String.format("\tCount: %1$s\n", this.topColumns.length)); - sb.append(String.format("\tFixedSize: %1$s\n", this.getSize())); + sb.append(String.format("\tFixedSize: %1$s\n", this.size())); + for (LayoutColumn c : this.topColumns) { if (c.getType().getIsFixed()) { if (c.getType().getIsBool()) { @@ -192,9 +200,7 @@ public final class Layout { /** * A tokenizer for path strings. */ - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Bug in - // Analyzer. This is an auto-property not a method.")] public StringTokenizer Tokenizer - private StringTokenizer getTokenizer() { + public StringTokenizer tokenizer() { + return this.tokenizer; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java index 6cf610a..dc9dfcb 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java @@ -48,7 +48,7 @@ public final class LayoutArray extends LayoutIndexedScope { TypeArgumentList typeArgs, Out value, UpdateOptions options) { Result result = PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java index e7d8f65..4d3ae8e 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -44,7 +43,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: Result r = this.ReadFixed(ref b, ref scope, col, out ReadOnlySpan span); Result r = this.ReadFixed(b, scope, col, out span); - value.set((r == Result.Success) ? span.ToArray() :) + value.setAndGet((r == Result.Success) ? span.ToArray() :) default return r; } @@ -57,11 +56,11 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(col.getSize() >= 0); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(null); + value.setAndGet(null); return Result.NotFound; } - value.set(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; } @@ -75,7 +74,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: Result r = this.ReadSparse(ref b, ref edit, out ReadOnlySpan span); Result r = this.ReadSparse(b, edit, out span); - value.set((r == Result.Success) ? span.ToArray() :) + value.setAndGet((r == Result.Success) ? span.ToArray() :) default return r; } @@ -85,11 +84,11 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa public Result ReadSparse(Reference b, Reference edit, Out> value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } - value.set(b.get().ReadSparseBinary(edit)); + value.setAndGet(b.get().ReadSparseBinary(edit)); return Result.Success; } @@ -105,7 +104,7 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: Result r = this.ReadVariable(ref b, ref scope, col, out ReadOnlySpan span); Result r = this.ReadVariable(b, scope, col, out span); - value.set((r == Result.Success) ? span.ToArray() :) + value.setAndGet((r == Result.Success) ? span.ToArray() :) default return r; } @@ -117,13 +116,13 @@ public final class LayoutBinary extends LayoutType implements ILayoutSpa , Out> value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(null); + value.setAndGet(null); return Result.NotFound; } int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, col.getOffset()); - value.set(b.get().ReadVariableBinary(varOffset)); + value.setAndGet(b.get().ReadVariableBinary(varOffset)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java index dd55122..57b26cd 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -38,11 +37,11 @@ public final class LayoutBoolean extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(false); + value.setAndGet(false); return Result.NotFound; } - value.set(b.get().ReadBit(scope.get().start, col.getBoolBit().clone())); + value.setAndGet(b.get().ReadBit(scope.get().start, col.getBoolBit().clone())); return Result.Success; } @@ -51,11 +50,11 @@ public final class LayoutBoolean extends LayoutType { Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(false); + value.setAndGet(false); return result; } - value.set(b.get().ReadSparseBool(edit)); + value.setAndGet(b.get().ReadSparseBool(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java index dddda74..4f070f7 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java @@ -150,7 +150,7 @@ public final class LayoutCompiler { private static LayoutType LogicalToPhysicalType(Namespace ns, PropertyType logicalType, Out typeArgs) { - typeArgs.set(TypeArgumentList.Empty); + typeArgs.setAndGet(TypeArgumentList.Empty); boolean tempVar = (logicalType instanceof ScopePropertyType ? (ScopePropertyType)logicalType : null).getImmutable(); boolean immutable = @@ -218,7 +218,7 @@ public final class LayoutCompiler { itemType = itemType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable; } - typeArgs.set(new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, + typeArgs.setAndGet(new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, itemTypeArgs.clone()) })); return immutable ? LayoutType.ImmutableTypedArray : LayoutType.TypedArray; } @@ -238,7 +238,7 @@ public final class LayoutCompiler { itemType = itemType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable; } - typeArgs.set(new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, + typeArgs.setAndGet(new TypeArgumentList(new TypeArgument[] { new TypeArgument(itemType, itemTypeArgs.clone()) })); return immutable ? LayoutType.ImmutableTypedSet : LayoutType.TypedSet; } @@ -271,7 +271,7 @@ public final class LayoutCompiler { valueType = valueType.Immutable ? LayoutType.ImmutableNullable : LayoutType.Nullable; } - typeArgs.set(new TypeArgumentList(new TypeArgument[] + typeArgs.setAndGet(new TypeArgumentList(new TypeArgument[] { new TypeArgument(keyType, keyTypeArgs.clone()), new TypeArgument(valueType, valueTypeArgs.clone()) @@ -301,7 +301,7 @@ public final class LayoutCompiler { args[i] = new TypeArgument(itemType, itemTypeArgs.clone()); } - typeArgs.set(new TypeArgumentList(args)); + typeArgs.setAndGet(new TypeArgumentList(args)); return immutable ? LayoutType.ImmutableTypedTuple : LayoutType.TypedTuple; case Tagged: @@ -329,7 +329,7 @@ public final class LayoutCompiler { tgArgs[i + 1] = new TypeArgument(itemType, itemTypeArgs.clone()); } - typeArgs.set(new TypeArgumentList(tgArgs)); + typeArgs.setAndGet(new TypeArgumentList(tgArgs)); switch (tg.getItems().size()) { case 1: return immutable ? LayoutType.ImmutableTagged : LayoutType.Tagged; @@ -358,7 +358,7 @@ public final class LayoutCompiler { up.getName(), up.getSchemaId().clone())); } - typeArgs.set(new TypeArgumentList(udtSchema.getSchemaId().clone())); + typeArgs.setAndGet(new TypeArgumentList(udtSchema.getSchemaId().clone())); return immutable ? LayoutType.ImmutableUDT : LayoutType.UDT; default: diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java index baa5e5f..283a8c5 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -35,11 +34,11 @@ public final class LayoutDateTime extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(LocalDateTime.MIN); + value.setAndGet(LocalDateTime.MIN); return Result.NotFound; } - value.set(b.get().ReadDateTime(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadDateTime(scope.get().start + col.getOffset())); return Result.Success; } @@ -48,11 +47,11 @@ public final class LayoutDateTime extends LayoutType { Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(LocalDateTime.MIN); + value.setAndGet(LocalDateTime.MIN); return result; } - value.set(b.get().ReadSparseDateTime(edit)); + value.setAndGet(b.get().ReadSparseDateTime(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java index 70e7da1..29388d6 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -36,11 +35,11 @@ public final class LayoutDecimal extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(new BigDecimal(0)); + value.setAndGet(new BigDecimal(0)); return Result.NotFound; } - value.set(b.get().ReadDecimal(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadDecimal(scope.get().start + col.getOffset())); return Result.Success; } @@ -49,11 +48,11 @@ public final class LayoutDecimal extends LayoutType { Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(new BigDecimal(0)); + value.setAndGet(new BigDecimal(0)); return result; } - value.set(b.get().ReadSparseDecimal(edit)); + value.setAndGet(b.get().ReadSparseDecimal(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java index dbd8a72..1b09922 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -40,7 +39,7 @@ public final class LayoutEndScope extends LayoutScope { public Result WriteScope(Reference b, Reference scope, TypeArgumentList typeArgs, Out value, UpdateOptions options) { Contract.Fail("Cannot write an EndScope directly"); - value.set(null); + value.setAndGet(null); return Result.Failure; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java index 1ce47bb..19211df 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Float128; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; @@ -34,11 +33,11 @@ public final class LayoutFloat128 extends LayoutType value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(null); + value.setAndGet(null); return Result.NotFound; } - value.set(b.get().ReadFloat128(scope.get().start + col.getOffset()).clone()); + value.setAndGet(b.get().ReadFloat128(scope.get().start + col.getOffset()).clone()); return Result.Success; } @@ -47,11 +46,11 @@ public final class LayoutFloat128 extends LayoutType value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } - value.set(b.get().ReadSparseFloat128(edit).clone()); + value.setAndGet(b.get().ReadSparseFloat128(edit).clone()); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java index 10aadfc..040cf28 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -33,11 +32,11 @@ public final class LayoutFloat32 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadFloat32(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadFloat32(scope.get().start + col.getOffset())); return Result.Success; } @@ -46,11 +45,11 @@ public final class LayoutFloat32 extends LayoutType { Out value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseFloat32(edit)); + value.setAndGet(b.get().ReadSparseFloat32(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java index 5aedf2a..2bce34a 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -33,11 +32,11 @@ public final class LayoutFloat64 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadFloat64(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadFloat64(scope.get().start + col.getOffset())); return Result.Success; } @@ -46,11 +45,11 @@ public final class LayoutFloat64 extends LayoutType { Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseFloat64(edit)); + value.setAndGet(b.get().ReadSparseFloat64(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java index 7ee1aae..3a570e6 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -35,11 +34,11 @@ public final class LayoutGuid extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(null); + value.setAndGet(null); return Result.NotFound; } - value.set(b.get().ReadGuid(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadGuid(scope.get().start + col.getOffset())); return Result.Success; } @@ -48,11 +47,11 @@ public final class LayoutGuid extends LayoutType { Out value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } - value.set(b.get().ReadSparseGuid(edit)); + value.setAndGet(b.get().ReadSparseGuid(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java index 5e8d4c6..67a0384 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -33,11 +32,11 @@ public final class LayoutInt16 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadInt16(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadInt16(scope.get().start + col.getOffset())); return Result.Success; } @@ -46,11 +45,11 @@ public final class LayoutInt16 extends LayoutType { Out value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseInt16(edit)); + value.setAndGet(b.get().ReadSparseInt16(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java index f758cc2..0f7d8a3 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -33,11 +32,11 @@ public final class LayoutInt32 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadInt32(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadInt32(scope.get().start + col.getOffset())); return Result.Success; } @@ -46,11 +45,11 @@ public final class LayoutInt32 extends LayoutType { Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseInt32(edit)); + value.setAndGet(b.get().ReadSparseInt32(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java index 3e33066..ca6cfb4 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -33,11 +32,11 @@ public final class LayoutInt64 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadInt64(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadInt64(scope.get().start + col.getOffset())); return Result.Success; } @@ -46,11 +45,11 @@ public final class LayoutInt64 extends LayoutType { Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseInt64(edit)); + value.setAndGet(b.get().ReadSparseInt64(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java index 7640053..1d70dc0 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -33,11 +32,11 @@ public final class LayoutInt8 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadInt8(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadInt8(scope.get().start + col.getOffset())); return Result.Success; } @@ -46,11 +45,11 @@ public final class LayoutInt8 extends LayoutType { Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseInt8(edit)); + value.setAndGet(b.get().ReadSparseInt8(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java index 1d01aad..dab475e 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -34,11 +33,11 @@ public final class LayoutMongoDbObjectId extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(null); + value.setAndGet(null); return Result.NotFound; } - value.set(b.get().ReadMongoDbObjectId(scope.get().start + col.getOffset()).clone()); + value.setAndGet(b.get().ReadMongoDbObjectId(scope.get().start + col.getOffset()).clone()); return Result.Success; } @@ -47,11 +46,11 @@ public final class LayoutMongoDbObjectId extends LayoutType { Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } - value.set(b.get().ReadSparseMongoDbObjectId(edit).clone()); + value.setAndGet(b.get().ReadSparseMongoDbObjectId(edit).clone()); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java index 5907f5a..fdc1bbb 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.NullValue; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; @@ -38,7 +37,7 @@ public final class LayoutNull extends LayoutType { public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); - value.set(NullValue.Default); + value.setAndGet(NullValue.Default); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { return Result.NotFound; } @@ -51,11 +50,11 @@ public final class LayoutNull extends LayoutType { Out value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } - value.set(b.get().ReadSparseNull(edit).clone()); + value.setAndGet(b.get().ReadSparseNull(edit).clone()); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java index 735b325..fba4b1b 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -73,7 +72,7 @@ public final class LayoutNullable extends LayoutIndexedScope { UpdateOptions options) { Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java index 385e56d..5db5c59 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -44,7 +43,7 @@ public final class LayoutObject extends LayoutPropertyScope { TypeArgumentList typeArgs, Out value, UpdateOptions options) { Result result = LayoutType.PrepareSparseWrite(b, edit, this.getTypeArg().clone(), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java index 9eeacd3..a264340 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -77,11 +76,11 @@ public abstract class LayoutScope extends LayoutType { Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } - value.set(b.get().SparseIteratorReadScope(edit, + value.setAndGet(b.get().SparseIteratorReadScope(edit, this.Immutable || edit.get().immutable || edit.get().scopeType.IsUniqueScope).clone()); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java index 84125e5..6d29803 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -66,7 +65,7 @@ public final class LayoutTagged extends LayoutIndexedScope { TypeArgumentList typeArgs, Out value, UpdateOptions options) { Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java index 7e6c781..81f1e06 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java @@ -44,7 +44,7 @@ public final class LayoutTagged2 extends LayoutIndexedScope { @Override public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, Out lenInBytes) { - lenInBytes.set(0); + lenInBytes.setAndGet(0); TypeArgument[] retval = new TypeArgument[3]; retval[0] = new TypeArgument(UInt8, TypeArgumentList.Empty); for (int i = 1; i < 3; i++) { @@ -52,7 +52,7 @@ public final class LayoutTagged2 extends LayoutIndexedScope { Out tempOut_itemLenInBytes = new Out(); retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); - lenInBytes.set(lenInBytes.get() + itemLenInBytes); + lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); } return new TypeArgumentList(retval); @@ -78,7 +78,7 @@ public final class LayoutTagged2 extends LayoutIndexedScope { TypeArgumentList typeArgs, Out value, UpdateOptions options) { Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java index 6c25cf1..6413762 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -47,7 +46,7 @@ public final class LayoutTuple extends LayoutIndexedScope { Out tempOut_itemLenInBytes = new Out(); retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); - lenInBytes.set(lenInBytes.get() + itemLenInBytes); + lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); } return new TypeArgumentList(retval); @@ -67,7 +66,7 @@ public final class LayoutTuple extends LayoutIndexedScope { TypeArgumentList typeArgs, Out value, UpdateOptions options) { Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java index b44a561..1689ccc 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -385,44 +384,44 @@ public abstract class LayoutType implements ILayoutType { // Prepare the delete of the source. Result result = LayoutType.PrepareSparseDelete(b, srcEdit, elementType.getType().LayoutCode); if (result != Result.Success) { - dstEdit.set(null); + dstEdit.setAndGet(null); return result; } if (!srcEdit.get().exists) { - dstEdit.set(null); + dstEdit.setAndGet(null); return Result.NotFound; } if (destinationScope.get().immutable) { b.get().DeleteSparse(srcEdit); - dstEdit.set(null); + dstEdit.setAndGet(null); return Result.InsufficientPermissions; } if (!srcEdit.get().cellTypeArgs.equals(elementType.getTypeArgs().clone())) { b.get().DeleteSparse(srcEdit); - dstEdit.set(null); + dstEdit.setAndGet(null); return Result.TypeConstraint; } if (options == UpdateOptions.InsertAt) { b.get().DeleteSparse(srcEdit); - dstEdit.set(null); + dstEdit.setAndGet(null); return Result.TypeConstraint; } // Prepare the insertion at the destination. - dstEdit.set(b.get().PrepareSparseMove(destinationScope, srcEdit).clone()); + dstEdit.setAndGet(b.get().PrepareSparseMove(destinationScope, srcEdit).clone()); if ((options == UpdateOptions.Update) && (!dstEdit.get().exists)) { b.get().DeleteSparse(srcEdit); - dstEdit.set(null); + dstEdit.setAndGet(null); return Result.NotFound; } if ((options == UpdateOptions.Insert) && dstEdit.get().exists) { b.get().DeleteSparse(srcEdit); - dstEdit.set(null); + dstEdit.setAndGet(null); return Result.Exists; } @@ -504,12 +503,12 @@ public abstract class LayoutType implements ILayoutType { Out tempOut_argsLenInBytes = new Out(); TypeArgumentList itemTypeArgs = itemCode.ReadTypeArgumentList(row, offset + (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE), tempOut_argsLenInBytes).clone(); argsLenInBytes = tempOut_argsLenInBytes.get(); - lenInBytes.set((com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + argsLenInBytes); + lenInBytes.setAndGet((com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + argsLenInBytes); return new TypeArgument(itemCode, itemTypeArgs.clone()); } public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, Out lenInBytes) { - lenInBytes.set(0); + lenInBytes.setAndGet(0); return TypeArgumentList.Empty; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType1.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType1.java index 6233464..03be1cb 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType1.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType1.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -104,7 +103,7 @@ public abstract class LayoutType extends LayoutType { public Result ReadVariable(Reference b, Reference scope, LayoutColumn col , Out value) { - value.set(null); + value.setAndGet(null); return Result.Failure; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java index 0f6470c..45972f8 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -61,7 +60,7 @@ public final class LayoutTypedArray extends LayoutIndexedScope { TypeArgumentList typeArgs, Out value, UpdateOptions options) { Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java index b67a985..f8b07ce 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -48,14 +47,14 @@ public final class LayoutTypedMap extends LayoutUniqueScope { @Override public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, Out lenInBytes) { - lenInBytes.set(0); + lenInBytes.setAndGet(0); TypeArgument[] retval = new TypeArgument[2]; for (int i = 0; i < 2; i++) { int itemLenInBytes; Out tempOut_itemLenInBytes = new Out(); retval[i] = ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); - lenInBytes.set(lenInBytes.get() + itemLenInBytes); + lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); } return new TypeArgumentList(retval); @@ -82,7 +81,7 @@ public final class LayoutTypedMap extends LayoutUniqueScope { TypeArgumentList typeArgs, Out value, UpdateOptions options) { Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java index 611de6f..cc1065f 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -68,7 +67,7 @@ public final class LayoutTypedSet extends LayoutUniqueScope { TypeArgumentList typeArgs, Out value, UpdateOptions options) { Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java index e649655..5cb3d6c 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java @@ -53,7 +53,7 @@ public final class LayoutTypedTuple extends LayoutIndexedScope { Out tempOut_itemLenInBytes = new Out(); retval[i] = LayoutType.ReadTypeArgument(row, offset + lenInBytes.get(), tempOut_itemLenInBytes); itemLenInBytes = tempOut_itemLenInBytes.get(); - lenInBytes.set(lenInBytes.get() + itemLenInBytes); + lenInBytes.setAndGet(lenInBytes.get() + itemLenInBytes); } return new TypeArgumentList(retval); @@ -79,7 +79,7 @@ public final class LayoutTypedTuple extends LayoutIndexedScope { TypeArgumentList typeArgs, Out value, UpdateOptions options) { Result result = LayoutType.PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java index b0caeff..d7d1fc5 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -32,7 +31,7 @@ public final class LayoutUDT extends LayoutPropertyScope { public TypeArgumentList ReadTypeArgumentList(Reference row, int offset, Out lenInBytes) { SchemaId schemaId = row.get().ReadSchemaId(offset).clone(); - lenInBytes.set(SchemaId.Size); + lenInBytes.setAndGet(SchemaId.Size); return new TypeArgumentList(schemaId.clone()); } @@ -51,7 +50,7 @@ public final class LayoutUDT extends LayoutPropertyScope { Layout udt = b.get().getResolver().Resolve(typeArgs.getSchemaId().clone()); Result result = PrepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java index 9d6d291..8914966 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -38,11 +37,11 @@ public final class LayoutUInt16 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadUInt16(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadUInt16(scope.get().start + col.getOffset())); return Result.Success; } @@ -53,11 +52,11 @@ public final class LayoutUInt16 extends LayoutType { Out value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseUInt16(edit)); + value.setAndGet(b.get().ReadSparseUInt16(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java index 78ee192..504911e 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -38,11 +37,11 @@ public final class LayoutUInt32 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadUInt32(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadUInt32(scope.get().start + col.getOffset())); return Result.Success; } @@ -53,11 +52,11 @@ public final class LayoutUInt32 extends LayoutType { Out value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseUInt32(edit)); + value.setAndGet(b.get().ReadSparseUInt32(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java index 7c0ab31..8465935 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -38,11 +37,11 @@ public final class LayoutUInt64 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadUInt64(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadUInt64(scope.get().start + col.getOffset())); return Result.Success; } @@ -53,11 +52,11 @@ public final class LayoutUInt64 extends LayoutType { Out value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseUInt64(edit)); + value.setAndGet(b.get().ReadSparseUInt64(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java index 214f7dd..6927f9a 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -38,11 +37,11 @@ public final class LayoutUInt8 extends LayoutType { Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } - value.set(b.get().ReadUInt8(scope.get().start + col.getOffset())); + value.setAndGet(b.get().ReadUInt8(scope.get().start + col.getOffset())); return Result.Success; } @@ -53,11 +52,11 @@ public final class LayoutUInt8 extends LayoutType { Out value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseUInt8(edit)); + value.setAndGet(b.get().ReadSparseUInt8(edit)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java index aaada2e..01a91e5 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -35,11 +34,11 @@ public final class LayoutUnixDateTime extends LayoutType value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(null); + value.setAndGet(null); return Result.NotFound; } - value.set(b.get().ReadUnixDateTime(scope.get().start + col.getOffset()).clone()); + value.setAndGet(b.get().ReadUnixDateTime(scope.get().start + col.getOffset()).clone()); return Result.Success; } @@ -48,11 +47,11 @@ public final class LayoutUnixDateTime extends LayoutType value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } - value.set(b.get().ReadSparseUnixDateTime(edit).clone()); + value.setAndGet(b.get().ReadSparseUnixDateTime(edit).clone()); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java index 1e72ee6..ed121f8 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -35,7 +34,7 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: Result r = this.ReadFixed(b, scope, col, out span); - value.set((r == Result.Success) ? span.toString() :) + value.setAndGet((r == Result.Success) ? span.toString() :) default return r; } @@ -45,11 +44,11 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S checkArgument(scope.get().scopeType instanceof LayoutUDT); checkArgument(col.getSize() >= 0); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(null); + value.setAndGet(null); return Result.NotFound; } - value.set(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; } @@ -60,7 +59,7 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: Result r = this.ReadSparse(b, edit, out span); - value.set((r == Result.Success) ? span.toString() :) + value.setAndGet((r == Result.Success) ? span.toString() :) default return r; } @@ -68,11 +67,11 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S public Result ReadSparse(Reference b, Reference edit, Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(null); + value.setAndGet(null); return result; } - value.set(b.get().ReadSparseString(edit)); + value.setAndGet(b.get().ReadSparseString(edit)); return Result.Success; } @@ -83,7 +82,7 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S // TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these // cannot be converted using the 'Out' helper class unless the method is within the code being modified: Result r = this.ReadVariable(b, scope, col, out span); - value.set((r == Result.Success) ? span.toString() :) + value.setAndGet((r == Result.Success) ? span.toString() :) default return r; } @@ -92,13 +91,13 @@ public final class LayoutUtf8 extends LayoutType implements ILayoutUtf8S , Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(null); + value.setAndGet(null); return Result.NotFound; } int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, col.getOffset()); - value.set(b.get().ReadVariableString(varOffset)); + value.setAndGet(b.get().ReadVariableString(varOffset)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java index 9ad5957..ec5e341 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java @@ -36,7 +36,7 @@ public final class LayoutVarInt extends LayoutType { public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, Out value) { Contract.Fail("Not Implemented"); - value.set(0); + value.setAndGet(0); return Result.Failure; } @@ -44,11 +44,11 @@ public final class LayoutVarInt extends LayoutType { public Result ReadSparse(Reference b, Reference edit, Out value) { Result result = LayoutType.PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseVarInt(edit)); + value.setAndGet(b.get().ReadSparseVarInt(edit)); return Result.Success; } @@ -56,13 +56,13 @@ public final class LayoutVarInt extends LayoutType { public Result ReadVariable(Reference b, Reference scope, LayoutColumn col, Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, col.getOffset()); - value.set(b.get().ReadVariableInt(varOffset)); + value.setAndGet(b.get().ReadVariableInt(varOffset)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java index 0b482d2..cc935a3 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -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; @@ -42,7 +41,7 @@ public final class LayoutVarUInt extends LayoutType { public Result ReadFixed(Reference b, Reference scope, LayoutColumn col, Out value) { Contract.Fail("Not Implemented"); - value.set(0); + value.setAndGet(0); return Result.Failure; } @@ -52,11 +51,11 @@ public final class LayoutVarUInt extends LayoutType { public Result ReadSparse(Reference b, Reference edit, Out value) { Result result = PrepareSparseRead(b, edit, this.LayoutCode); if (result != Result.Success) { - value.set(0); + value.setAndGet(0); return result; } - value.set(b.get().ReadSparseVarUInt(edit)); + value.setAndGet(b.get().ReadSparseVarUInt(edit)); return Result.Success; } @@ -67,13 +66,13 @@ public final class LayoutVarUInt extends LayoutType { public Result ReadVariable(Reference b, Reference scope, LayoutColumn col, Out value) { checkArgument(scope.get().scopeType instanceof LayoutUDT); if (!b.get().ReadBit(scope.get().start, col.getNullBit().clone())) { - value.set(0); + value.setAndGet(0); return Result.NotFound; } int varOffset = b.get().ComputeVariableValueOffset(scope.get().layout, scope.get().start, col.getOffset()); - value.set(b.get().ReadVariableUInt(varOffset)); + value.setAndGet(b.get().ReadVariableUInt(varOffset)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java index c8ae1df..13dc863 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java @@ -4,6 +4,8 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; +import com.azure.data.cosmos.core.Utf8String; + //C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class may differ // from the original: //ORIGINAL LINE: public readonly struct StringToken diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java index 464539e..471bec3 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java @@ -5,58 +5,38 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; +import com.azure.data.cosmos.core.Utf8String; +import com.azure.data.cosmos.core.UtfAnyString; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Map; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; + public final class StringTokenizer { - /** - * The number of unique tokens described by the encoding. - */ - private int Count; - private HashMap stringTokens; - private ArrayList strings; - private HashMap tokens; + + private final HashMap stringTokens; + private final ArrayList strings; + private final HashMap tokens; + + private int count; /** * Initializes a new instance of the {@link StringTokenizer} class. */ public StringTokenizer() { - this.tokens = new HashMap(Map.ofEntries(Map.entry(Utf8String.Empty, - new StringToken(0, Utf8String.Empty)))); - this.stringTokens = new HashMap(Map.ofEntries(Map.entry("", new StringToken(0, - Utf8String.Empty)))); - this.strings = new ArrayList(Arrays.asList(Utf8String.Empty)); - this.setCount(1); - } - public int getCount() { - return Count; - } + this.tokens = new HashMap( + Map.ofEntries(Map.entry(Utf8String.EMPTY, new StringToken(0, Utf8String.EMPTY)))); - private void setCount(int value) { - Count = value; - } + this.stringTokens = new HashMap( + Map.ofEntries(Map.entry("", new StringToken(0, Utf8String.EMPTY)))); - /** - * Assign a token to the string. - * If the string already has a token, that token is returned instead. - * - * @param path The string to assign a new token. - * @return The token assigned to the string. - */ - public StringToken Add(Utf8String path) { - checkArgument(path != null); - - StringToken token; - if (this.tokens.containsKey(path) && (token = this.tokens.get(path)) == token) { - return token; - } - - token = this.AllocateToken(path).clone(); - return token; + this.strings = new ArrayList(Collections.singletonList(Utf8String.EMPTY)); + this.count = 1; } /** @@ -66,17 +46,14 @@ public final class StringTokenizer { * @param path If successful, the token's assigned string. * @return True if successful, false otherwise. */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public bool TryFindString(ulong token, out Utf8String path) - public boolean TryFindString(long token, Out path) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: if (token >= (ulong)this.strings.Count) + public boolean tryFindString(long token, Out path) { + if (token >= (long)this.strings.size()) { - path.set(null); + path.setAndGet(null); return false; } - path.set(this.strings.get((int)token)); + path.setAndGet(this.strings.get((int) token)); return true; } @@ -87,17 +64,45 @@ public final class StringTokenizer { * @param token If successful, the string's assigned token. * @return True if successful, false otherwise. */ - public boolean TryFindToken(UtfAnyString path, Out token) { - if (path.IsNull) { - token.set(null); + public boolean tryFindToken(UtfAnyString path, Out token) { + + if (path.isNull()) { + token.setAndGet(null); return false; } - if (path.IsUtf8) { - return (this.tokens.containsKey(path.ToUtf8String()) && (token.set(this.tokens.get(path.ToUtf8String()))) == token.get()); + if (path.isUtf8()) { + return (this.tokens.containsKey(path.toUtf8()) && (token.setAndGet(this.tokens.get(path.toUtf8()))) == token.get()); } - return (this.stringTokens.containsKey(path.toString()) && (token.set(this.stringTokens.get(path.toString()))) == token.get()); + return (this.stringTokens.containsKey(path.toUtf16()) && (token.setAndGet(this.stringTokens.get(path.toUtf16()))) == token.get()); + } + + /** + * Assign a token to the string. + * If the string already has a token, that token is returned instead. + * + * @param path The string to assign a new token. + * @return The token assigned to the string. + */ + public StringToken add(Utf8String path) { + + checkArgument(path != null); + StringToken token; + + if (this.tokens.containsKey(path) && (token = this.tokens.get(path)) == token) { + return token; + } + + token = this.allocateToken(path).clone(); + return token; + } + + /** + * The number of unique tokens described by the encoding. + */ + public int count() { + return this.count; } /** @@ -106,17 +111,15 @@ public final class StringTokenizer { * @param path The string that needs a new token. * @return The new allocated token. */ - private StringToken AllocateToken(Utf8String path) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: ulong id = (ulong)this.Count++; - long id = this.getCount(); - this.setCount(this.getCount() + 1); - StringToken token = new StringToken(id, path); + private StringToken allocateToken(Utf8String path) { + + final long id = this.count++; + final StringToken token = new StringToken(id, path); + this.tokens.put(path, token.clone()); this.stringTokens.put(path.toString(), token.clone()); this.strings.add(path); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: Contract.Assert((ulong)this.strings.Count - 1 == id); + checkState((long)this.strings.size() - 1 == id); return token.clone(); } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java index 73c4e84..7faf5b1 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java @@ -63,11 +63,11 @@ public final class RecordIOFormatter { // layout, T obj, RowWriter.WriterFunc writer, out RowBuffer row) private static Result FormatObject(ISpanResizer resizer, int initialCapacity, Layout layout, T obj, RowWriter.WriterFunc writer, Out row) { - row.set(new RowBuffer(initialCapacity, resizer)); + row.setAndGet(new RowBuffer(initialCapacity, resizer)); row.get().InitLayout(HybridRowVersion.V1, layout, SystemSchema.LayoutResolver); Result r = RowWriter.WriteBuffer(row.clone(), obj, writer); if (r != Result.Success) { - row.set(null); + row.setAndGet(null); return r; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java index 3e0a99e..b9aedce 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.recordio; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowHeader; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.Result; @@ -65,8 +64,8 @@ public final class RecordIOParser { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: Memory b = buffer; Memory b = buffer; - type.set(ProductionType.None); - record.set(null); + type.setAndGet(ProductionType.None); + record.setAndGet(null); switch (this.state) { case Start: this.state = State.NeedSegmentLength; @@ -74,8 +73,8 @@ public final class RecordIOParser { case NeedSegmentLength: { int minimalSegmentRowSize = HybridRowHeader.Size + RecordIOFormatter.SegmentLayout.getSize(); if (b.Length < minimalSegmentRowSize) { - need.set(minimalSegmentRowSize); - consumed.set(buffer.Length - b.Length); + need.setAndGet(minimalSegmentRowSize); + consumed.setAndGet(buffer.Length - b.Length); return Result.InsufficientBuffer; } @@ -105,8 +104,8 @@ public final class RecordIOParser { case NeedSegment: { if (b.Length < this.segment.Length) { - need.set(this.segment.Length); - consumed.set(buffer.Length - b.Length); + need.setAndGet(this.segment.Length); + consumed.setAndGet(buffer.Length - b.Length); return Result.InsufficientBuffer; } @@ -129,19 +128,19 @@ public final class RecordIOParser { break; } - record.set(b.Slice(0, span.Length)); + record.setAndGet(b.Slice(0, span.Length)); b = b.Slice(span.Length); - need.set(0); + need.setAndGet(0); this.state = State.NeedHeader; - consumed.set(buffer.Length - b.Length); - type.set(ProductionType.Segment); + consumed.setAndGet(buffer.Length - b.Length); + type.setAndGet(ProductionType.Segment); return Result.Success; } case NeedHeader: { if (b.Length < HybridRowHeader.Size) { - need.set(HybridRowHeader.Size); - consumed.set(buffer.Length - b.Length); + need.setAndGet(HybridRowHeader.Size); + consumed.setAndGet(buffer.Length - b.Length); return Result.InsufficientBuffer; } @@ -174,8 +173,8 @@ public final class RecordIOParser { case NeedRecord: { int minimalRecordRowSize = HybridRowHeader.Size + RecordIOFormatter.RecordLayout.getSize(); if (b.Length < minimalRecordRowSize) { - need.set(minimalRecordRowSize); - consumed.set(buffer.Length - b.Length); + need.setAndGet(minimalRecordRowSize); + consumed.setAndGet(buffer.Length - b.Length); return Result.InsufficientBuffer; } @@ -204,12 +203,12 @@ public final class RecordIOParser { case NeedRow: { if (b.Length < this.record.Length) { - need.set(this.record.Length); - consumed.set(buffer.Length - b.Length); + need.setAndGet(this.record.Length); + consumed.setAndGet(buffer.Length - b.Length); return Result.InsufficientBuffer; } - record.set(b.Slice(0, this.record.Length)); + record.setAndGet(b.Slice(0, this.record.Length)); // Validate that the record has not been corrupted. //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: @@ -221,17 +220,17 @@ public final class RecordIOParser { } b = b.Slice(this.record.Length); - need.set(0); + need.setAndGet(0); this.state = State.NeedHeader; - consumed.set(buffer.Length - b.Length); - type.set(ProductionType.Record); + consumed.setAndGet(buffer.Length - b.Length); + type.setAndGet(ProductionType.Record); return Result.Success; } } this.state = State.Error; - need.set(0); - consumed.set(buffer.Length - b.Length); + need.setAndGet(0); + consumed.setAndGet(buffer.Length - b.Length); return r; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOStream.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOStream.java index b990d74..416fec3 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOStream.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOStream.java @@ -317,11 +317,11 @@ public final class RecordIOStream { Result r = RecordIOFormatter.FormatRecord(body, tempOut_row, resizer); row = tempOut_row.get(); if (r != Result.Success) { - block.set(null); + block.setAndGet(null); return r; } - block.set(resizer.getMemory().Slice(0, row.Length)); + block.setAndGet(resizer.getMemory().Slice(0, row.Length)); return Result.Success; } @@ -344,11 +344,11 @@ public final class RecordIOStream { Result r = RecordIOFormatter.FormatSegment(segment.clone(), tempOut_row, resizer); row = tempOut_row.get(); if (r != Result.Success) { - block.set(null); + block.setAndGet(null); return r; } - block.set(resizer.getMemory().Slice(0, row.Length)); + block.setAndGet(resizer.getMemory().Slice(0, row.Length)); return Result.Success; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordSerializer.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordSerializer.java index 663dd42..2354b88 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordSerializer.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordSerializer.java @@ -6,12 +6,11 @@ package com.azure.data.cosmos.serialization.hybridrow.recordio; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; public final class RecordSerializer { public static Result Read(Reference reader, Out obj) { - obj.set(null); + obj.setAndGet(null); while (reader.get().Read()) { Result r; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java index 02fb0fc..f7f13d1 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java +++ b/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java @@ -28,7 +28,7 @@ public final class SegmentSerializer { } public static Result Read(Reference reader, Out obj) { - obj.set(null); + obj.setAndGet(null); while (reader.get().Read()) { Result r; diff --git a/jre/src/main/java/tangible/TryParseHelper.java b/jre/src/main/java/tangible/TryParseHelper.java index 9dff830..db39875 100644 --- a/jre/src/main/java/tangible/TryParseHelper.java +++ b/jre/src/main/java/tangible/TryParseHelper.java @@ -15,7 +15,7 @@ import com.azure.data.cosmos.core.Out; public final class TryParseHelper { public static boolean tryParseBoolean(String s, Out result) { try { - result.set(Boolean.parseBoolean(s)); + result.setAndGet(Boolean.parseBoolean(s)); return true; } catch (NumberFormatException e) { return false; @@ -24,7 +24,7 @@ public final class TryParseHelper { public static boolean tryParseByte(String s, Out result) { try { - result.set(Byte.parseByte(s)); + result.setAndGet(Byte.parseByte(s)); return true; } catch (NumberFormatException e) { return false; @@ -33,7 +33,7 @@ public final class TryParseHelper { public static boolean tryParseDouble(String s, Out result) { try { - result.set(Double.parseDouble(s)); + result.setAndGet(Double.parseDouble(s)); return true; } catch (NumberFormatException e) { return false; @@ -42,7 +42,7 @@ public final class TryParseHelper { public static boolean tryParseFloat(String s, Out result) { try { - result.set(Float.parseFloat(s)); + result.setAndGet(Float.parseFloat(s)); return true; } catch (NumberFormatException e) { return false; @@ -51,7 +51,7 @@ public final class TryParseHelper { public static boolean tryParseInt(String s, Out result) { try { - result.set(Integer.parseInt(s)); + result.setAndGet(Integer.parseInt(s)); return true; } catch (NumberFormatException e) { return false; @@ -60,7 +60,7 @@ public final class TryParseHelper { public static boolean tryParseLong(String s, Out result) { try { - result.set(Long.parseLong(s)); + result.setAndGet(Long.parseLong(s)); return true; } catch (NumberFormatException e) { return false; @@ -69,7 +69,7 @@ public final class TryParseHelper { public static boolean tryParseShort(String s, Out result) { try { - result.set(Short.parseShort(s)); + result.setAndGet(Short.parseShort(s)); return true; } catch (NumberFormatException e) { return false; diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java index b68f076..0926713 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java @@ -60,7 +60,7 @@ public final class BsonRowGenerator implements Closeable { public void WriteBuffer(HashMap dict) { this.writer.writeStartDocument(); - for (LayoutColumn c : this.layout.getColumns()) { + for (LayoutColumn c : this.layout.columns()) { this.LayoutCodeSwitch(c.getPath(), c.getTypeArg().clone(), dict.get(c.getPath())); } @@ -141,7 +141,7 @@ public final class BsonRowGenerator implements Closeable { HashMap dict = (HashMap)value; Layout udt = this.resolver.Resolve(typeArg.getTypeArgs().getSchemaId().clone()); - for (LayoutColumn c : udt.getColumns()) { + for (LayoutColumn c : udt.columns()) { this.LayoutCodeSwitch(c.getPath(), c.getTypeArg().clone(), dict.get(c.getPath())); } diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java index 7c0c2b7..9bd97e4 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.perf; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.ISpanResizer; import com.azure.data.cosmos.serialization.hybridrow.Result; @@ -53,7 +52,7 @@ public final class CodeGenRowGenerator { this.row = new RowBuffer(capacity, resizer); this.row.InitLayout(HybridRowVersion.V1, layout, resolver); - switch (layout.getName()) { + switch (layout.name()) { case "Hotels": this.dispatcher = new HotelsHybridRowSerializer(layout, resolver); break; @@ -67,7 +66,7 @@ public final class CodeGenRowGenerator { break; default: - throw new IllegalStateException(lenientFormat("Unknown schema will be ignored: %s", layout.getName())); + throw new IllegalStateException(lenientFormat("Unknown schema will be ignored: %s", layout.name())); this.dispatcher = null; break; } diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java index bb073fb..cfc3e2e 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; @@ -100,11 +99,11 @@ public final class NullableUnitTests { nullableScope.clone()); value = tempOut_value.get(); if ((r != Result.Success) && (r != Result.NotFound)) { - item.set(null); + item.setAndGet(null); return r; } - item.set((r == Result.NotFound) ? null : value); + item.setAndGet((r == Result.NotFound) ? null : value); return Result.Success; } @@ -122,7 +121,7 @@ public final class NullableUnitTests { Out nullableScope) { Result r = itemType.getType().TypeAs().ReadScope(row, scope, nullableScope.clone()); if (r != Result.Success) { - item.set(null); + item.setAndGet(null); return r; } @@ -133,7 +132,7 @@ public final class NullableUnitTests { } ResultAssert.NotFound(LayoutNullable.HasValue(row, nullableScope.clone())); - item.set(null); + item.setAndGet(null); return Result.NotFound; } diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java index af2e4fa..94c171d 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.MemorySpanResizer; import com.azure.data.cosmos.serialization.hybridrow.Result; @@ -171,7 +170,7 @@ public class RecordIOUnitTests { Result r = DiagnosticConverter.ReaderToString(tempReference_reader, out str); reader = tempReference_reader.get(); if (r != Result.Success) { - obj.set(null); + obj.setAndGet(null); return r; } @@ -206,7 +205,7 @@ public class RecordIOUnitTests { Result r = DiagnosticConverter.ReaderToString(tempReference_reader, out str); reader = tempReference_reader.get(); if (r != Result.Success) { - obj.set(null); + obj.setAndGet(null); return r; } @@ -234,11 +233,11 @@ public class RecordIOUnitTests { Result r = RowWriter.WriteBuffer(tempReference_row, obj, AddressSerializer.Write); row = tempReference_row.get(); if (r != Result.Success) { - buffer.set(null); + buffer.setAndGet(null); return r; } - buffer.set(resizer.getMemory().Slice(0, row.getLength())); + buffer.setAndGet(resizer.getMemory().Slice(0, row.getLength())); return Result.Success; } } \ No newline at end of file diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java index 58c6a11..b3bcd04 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; @@ -139,7 +138,7 @@ public final class SerializerUnitTest { public static Result Read(Reference reader, Out operation) { BatchOperation retval = new BatchOperation(); - operation.set(null); + operation.setAndGet(null); while (reader.get().Read()) { Result r; switch (reader.get().getPath()) { @@ -198,7 +197,7 @@ public final class SerializerUnitTest { } } - operation.set(retval); + operation.setAndGet(retval); return Result.Success; } @@ -245,7 +244,7 @@ public final class SerializerUnitTest { public static Result Read(Reference reader, Out header) { BatchRequestHeaders retval = new BatchRequestHeaders(); - header.set(null); + header.setAndGet(null); while (reader.get().Read()) { switch (reader.get().getPath()) { case "sampleRequestHeader": @@ -260,7 +259,7 @@ public final class SerializerUnitTest { } } - header.set(retval); + header.setAndGet(retval); return Result.Success; } @@ -283,11 +282,11 @@ public final class SerializerUnitTest { Result r = RowReaderExtensions.ReadList(reader.get().clone(), BatchOperationSerializer.Read, tempOut_operations); operations = tempOut_operations.get(); if (r != Result.Success) { - request.set(null); + request.setAndGet(null); return r; } - request.set(new BatchRequest()); + request.setAndGet(new BatchRequest()); request.get().Operations = operations; return Result.Success; diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java index d7a06dc..fd3157d 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.HybridRowVersion; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; @@ -968,7 +967,7 @@ public final class TypedMapUnitTests { private static Result ReadKeyValue(Reference row, Reference scope, TypeArgumentList typeArgs, Out> pair) { - pair.set(null); + pair.setAndGet(null); LayoutIndexedScope tupleLayout = LayoutType.TypedTuple; RowCursor tupleScope; Out tempOut_tupleScope = @@ -1003,7 +1002,7 @@ public final class TypedMapUnitTests { return r; } - pair.set(new KeyValuePair(key, value)); + pair.setAndGet(new KeyValuePair(key, value)); return Result.Success; } diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java index 5d60bf7..85074f0 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java @@ -6,14 +6,13 @@ package com.azure.data.cosmos.serialization.hybridrow.unit.customerschema; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import azure.data.cosmos.serialization.hybridrow.unit.*; import com.azure.data.cosmos.serialization.hybridrow.io.RowReader; public final class AddressSerializer { public static Result Read(Reference reader, Out

obj) { - obj.set(new Address()); + obj.setAndGet(new Address()); while (reader.get().Read()) { Result r; switch (reader.get().getPath()) { diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java index 8ad8821..a9963c6 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java +++ b/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java @@ -6,7 +6,6 @@ package com.azure.data.cosmos.serialization.hybridrow.unit.customerschema; import com.azure.data.cosmos.core.Out; import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.SchemaId; import com.azure.data.cosmos.serialization.hybridrow.io.RowReader; @@ -24,7 +23,7 @@ public final class PostalCodeSerializer { public static TypeArgument TypeArg = new TypeArgument(LayoutType.UDT, new TypeArgumentList(new SchemaId(1))); public static Result Read(Reference reader, Out obj) { - obj.set(new PostalCode()); + obj.setAndGet(new PostalCode()); while (reader.get().Read()) { Result r; switch (reader.get().getPath()) {