From 7ae43bf830009ca0198483eeeeb76a5b38339173 Mon Sep 17 00:00:00 2001 From: David Noble Date: Sun, 1 Sep 2019 14:26:40 -0700 Subject: [PATCH] Renamed jre as java because Java is used to can refer to two things: the platform and the language. In this case we are referring to the Java Platform, not the Java Runtime Environment. --- {jre => java}/pom.xml | 0 .../com/azure/data/cosmos/core/Codecs.java | 7 + .../java/com/azure/data/cosmos/core/Json.java | 0 .../java/com/azure/data/cosmos/core/Out.java | 0 .../com/azure/data/cosmos/core/Reference.java | 0 .../azure/data/cosmos/core/Utf8String.java | 0 .../azure/data/cosmos/core/UtfAnyString.java | 0 .../serialization/hybridrow/Float128.java | 0 .../hybridrow/HybridRowHeader.java | 0 .../hybridrow/HybridRowVersion.java | 0 .../serialization/hybridrow/ISpanResizer.java | 0 .../hybridrow/MemorySpanResizer.java | 0 .../serialization/hybridrow/NullValue.java | 0 .../serialization/hybridrow/Result.java | 28 +- .../serialization/hybridrow/RowBuffer.java | 3479 ++++++++--------- .../serialization/hybridrow/RowCursor.java | 34 +- .../serialization/hybridrow/RowCursors.java | 2 +- .../serialization/hybridrow/RowOptions.java | 0 .../serialization/hybridrow/SchemaId.java | 0 .../serialization/hybridrow/UnixDateTime.java | 0 .../hybridrow/internal/Murmur3Hash.java | 0 .../hybridrow/io/IRowSerializable.java | 0 .../serialization/hybridrow/io/RowReader.java | 14 +- .../hybridrow/io/RowReaderExtensions.java | 0 .../serialization/hybridrow/io/RowWriter.java | 2 +- .../json/RowReaderJsonExtensions.java | 0 .../hybridrow/json/RowReaderJsonSettings.java | 0 .../layouts/ILayoutSequenceWritable.java | 0 .../layouts/ILayoutSpanReadable.java | 0 .../layouts/ILayoutSpanWritable.java | 0 .../hybridrow/layouts/ILayoutType.java | 0 .../layouts/ILayoutUtf8SpanReadable.java | 0 .../layouts/ILayoutUtf8SpanWritable.java | 0 .../hybridrow/layouts/Layout.java | 0 .../hybridrow/layouts/LayoutArray.java | 33 +- .../hybridrow/layouts/LayoutBinary.java | 0 .../hybridrow/layouts/LayoutBit.java | 8 +- .../hybridrow/layouts/LayoutBoolean.java | 0 .../hybridrow/layouts/LayoutBuilder.java | 0 .../hybridrow/layouts/LayoutCode.java | 0 .../hybridrow/layouts/LayoutCodeTraits.java | 0 .../hybridrow/layouts/LayoutColumn.java | 0 .../layouts/LayoutCompilationException.java | 0 .../hybridrow/layouts/LayoutCompiler.java | 0 .../hybridrow/layouts/LayoutDateTime.java | 0 .../hybridrow/layouts/LayoutDecimal.java | 0 .../hybridrow/layouts/LayoutEndScope.java | 9 +- .../hybridrow/layouts/LayoutFloat128.java | 0 .../hybridrow/layouts/LayoutFloat32.java | 0 .../hybridrow/layouts/LayoutFloat64.java | 0 .../hybridrow/layouts/LayoutGuid.java | 0 .../hybridrow/layouts/LayoutIndexedScope.java | 16 +- .../hybridrow/layouts/LayoutInt16.java | 0 .../hybridrow/layouts/LayoutInt32.java | 0 .../hybridrow/layouts/LayoutInt64.java | 0 .../hybridrow/layouts/LayoutInt8.java | 0 .../layouts/LayoutMongoDbObjectId.java | 0 .../hybridrow/layouts/LayoutNull.java | 0 .../hybridrow/layouts/LayoutNullable.java | 61 +- .../hybridrow/layouts/LayoutObject.java | 9 +- .../layouts/LayoutPropertyScope.java | 0 .../hybridrow/layouts/LayoutResolver.java | 0 .../layouts/LayoutResolverNamespace.java | 0 .../layouts/LayoutResolverSimple.java | 0 .../hybridrow/layouts/LayoutScope.java | 194 + .../hybridrow/layouts/LayoutTagged.java | 10 +- .../hybridrow/layouts/LayoutTagged2.java | 10 +- .../hybridrow/layouts/LayoutTuple.java | 8 +- .../hybridrow/layouts/LayoutType.java | 7 +- .../hybridrow/layouts/LayoutTypedArray.java | 10 +- .../hybridrow/layouts/LayoutTypedMap.java | 10 +- .../hybridrow/layouts/LayoutTypedSet.java | 10 +- .../hybridrow/layouts/LayoutTypedTuple.java | 10 +- .../hybridrow/layouts/LayoutTypes.java | 32 +- .../hybridrow/layouts/LayoutUDT.java | 8 +- .../hybridrow/layouts/LayoutUInt16.java | 0 .../hybridrow/layouts/LayoutUInt32.java | 0 .../hybridrow/layouts/LayoutUInt64.java | 0 .../hybridrow/layouts/LayoutUInt8.java | 0 .../hybridrow/layouts/LayoutUniqueScope.java | 6 +- .../hybridrow/layouts/LayoutUnixDateTime.java | 0 .../hybridrow/layouts/LayoutUtf8.java | 0 .../hybridrow/layouts/LayoutVarInt.java | 0 .../hybridrow/layouts/LayoutVarUInt.java | 0 .../layouts/SamplingStringComparer.java | 0 .../layouts/SamplingUtf8StringComparer.java | 0 .../hybridrow/layouts/StringToken.java | 0 .../hybridrow/layouts/StringTokenizer.java | 0 .../hybridrow/layouts/SystemSchema.java | 0 .../hybridrow/layouts/TypeArgument.java | 0 .../hybridrow/layouts/TypeArgumentList.java | 0 .../hybridrow/layouts/UpdateOptions.java | 0 .../hybridrow/recordio/Record.java | 0 .../hybridrow/recordio/RecordIOFormatter.java | 0 .../hybridrow/recordio/RecordIOParser.java | 0 .../hybridrow/recordio/RecordIOStream.java | 0 .../hybridrow/recordio/RecordSerializer.java | 0 .../hybridrow/recordio/Segment.java | 0 .../hybridrow/recordio/SegmentSerializer.java | 0 .../hybridrow/schemas/ArrayPropertyType.java | 0 .../hybridrow/schemas/MapPropertyType.java | 0 .../hybridrow/schemas/Namespace.java | 0 .../hybridrow/schemas/ObjectPropertyType.java | 0 .../hybridrow/schemas/PartitionKey.java | 0 .../hybridrow/schemas/PrimarySortKey.java | 0 .../schemas/PrimitivePropertyType.java | 0 .../hybridrow/schemas/Property.java | 0 .../schemas/PropertySchemaConverter.java | 0 .../hybridrow/schemas/PropertyType.java | 0 .../hybridrow/schemas/Schema.java | 0 .../hybridrow/schemas/SchemaException.java | 0 .../hybridrow/schemas/SchemaHash.java | 0 .../schemas/SchemaLanguageVersion.java | 0 .../hybridrow/schemas/SchemaOptions.java | 0 .../hybridrow/schemas/SchemaValidator.java | 0 .../hybridrow/schemas/ScopePropertyType.java | 0 .../hybridrow/schemas/SetPropertyType.java | 0 .../hybridrow/schemas/SortDirection.java | 0 .../hybridrow/schemas/StaticKey.java | 0 .../hybridrow/schemas/StorageKind.java | 0 .../schemas/StrictBooleanConverter.java | 0 .../schemas/StrictIntegerConverter.java | 0 .../hybridrow/schemas/TaggedPropertyType.java | 0 .../hybridrow/schemas/TuplePropertyType.java | 0 .../hybridrow/schemas/TypeKind.java | 0 .../hybridrow/schemas/UdtPropertyType.java | 0 .../src/main/java/tangible/Action0Param.java | 0 .../src/main/java/tangible/Func0Param.java | 0 .../src/main/java/tangible/Func1Param.java | 0 .../src/main/java/tangible/ListHelper.java | 0 .../src/main/java/tangible/StringHelper.java | 0 .../main/java/tangible/TryParseHelper.java | 0 .../hybridrow/perf/BenchmarkSuiteBase.java | 0 .../perf/BsonJsonModelRowGenerator.java | 0 .../hybridrow/perf/BsonReaderExtensions.java | 0 .../hybridrow/perf/BsonRowGenerator.java | 0 .../perf/CodeGenMicroBenchmarkSuite.java | 0 .../hybridrow/perf/CodeGenRowGenerator.java | 2 +- .../perf/GenerateBenchmarkSuite.java | 0 .../hybridrow/perf/JsonModelRowGenerator.java | 0 .../hybridrow/perf/Measurements.java | 0 .../perf/MicroBenchmarkSuiteBase.java | 0 .../hybridrow/perf/ProtobufRowGenerator.java | 0 .../hybridrow/perf/ReaderBenchmark.java | 0 .../hybridrow/perf/RowReaderExtensions.java | 0 .../perf/SchematizedMicroBenchmarkSuite.java | 0 .../hybridrow/perf/TestData.java | 0 .../UnschematizedMicroBenchmarkSuite.java | 0 .../perf/cassandrahotel/protobuf/Address.java | 316 ++ .../Available_Rooms_By_Hotel_Date.java | 320 ++ .../CassandraHotelSchemaReflection.java | 120 + .../perf/cassandrahotel/protobuf/Guests.java | 445 +++ .../perf/cassandrahotel/protobuf/Hotels.java | 316 ++ .../cassandrahotel/protobuf/PostalCode.java | 232 ++ .../hybridrow/unit/ArrayAssert.java | 0 .../hybridrow/unit/AssertThrowsException.java | 0 .../unit/CrossVersioningUnitTests.java | 0 .../unit/CustomerExampleUnitTests.java | 0 .../hybridrow/unit/DeleteRowDispatcher.java | 0 .../hybridrow/unit/IDispatchable.java | 0 .../hybridrow/unit/IDispatcher.java | 0 .../unit/LayoutCompilerUnitTests.java | 0 .../hybridrow/unit/LayoutTypeUnitTests.java | 0 .../hybridrow/unit/NullRowDispatcher.java | 0 .../hybridrow/unit/NullableUnitTests.java | 0 .../hybridrow/unit/PermuteExtensions.java | 0 .../unit/RandomGeneratorUnitTests.java | 0 .../hybridrow/unit/ReadRowDispatcher.java | 0 .../hybridrow/unit/RecordIOUnitTests.java | 0 .../hybridrow/unit/ResultAssert.java | 0 .../hybridrow/unit/RowBufferUnitTests.java | 0 .../unit/RowOperationDispatcher.java | 0 .../hybridrow/unit/RowReaderUnitTests.java | 0 .../hybridrow/unit/RowWriterUnitTests.java | 0 .../hybridrow/unit/SchemaHashUnitTests.java | 0 .../hybridrow/unit/SchemaIdUnitTests.java | 0 .../hybridrow/unit/SchemaUnitTests.java | 0 .../hybridrow/unit/SerializerUnitTest.java | 0 .../hybridrow/unit/TaggedUnitTests.java | 0 .../hybridrow/unit/TupleUnitTests.java | 0 .../hybridrow/unit/TypedArrayUnitTests.java | 0 .../hybridrow/unit/TypedMapUnitTests.java | 0 .../hybridrow/unit/TypedSetUnitTests.java | 0 .../unit/UpdateOptionsUnitTests.java | 0 .../hybridrow/unit/WriteRowDispatcher.java | 0 .../unit/customerschema/Address.java | 0 .../customerschema/AddressSerializer.java | 0 .../hybridrow/unit/customerschema/Guest.java | 0 .../hybridrow/unit/customerschema/Hotel.java | 0 .../unit/customerschema/PostalCode.java | 0 .../customerschema/PostalCodeSerializer.java | 0 .../unit/internal/MurmurHash3UnitTests.java | 0 .../hybridrow/layouts/LayoutScope.java | 189 - 193 files changed, 3840 insertions(+), 2117 deletions(-) rename {jre => java}/pom.xml (100%) create mode 100644 java/src/main/java/com/azure/data/cosmos/core/Codecs.java rename {jre => java}/src/main/java/com/azure/data/cosmos/core/Json.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/core/Out.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/core/Reference.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/core/Utf8String.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Float128.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowHeader.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowVersion.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/ISpanResizer.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/MemorySpanResizer.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/NullValue.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Result.java (64%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java (75%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java (89%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java (93%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowOptions.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/UnixDateTime.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/internal/Murmur3Hash.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/IRowSerializable.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java (96%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java (97%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonSettings.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSequenceWritable.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanReadable.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanWritable.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanReadable.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanWritable.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java (60%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java (90%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompilationException.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java (79%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutIndexedScope.java (55%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java (58%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java (79%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutPropertyScope.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolver.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverSimple.java (100%) create mode 100644 java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java (87%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java (89%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java (90%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java (95%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java (87%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java (88%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java (87%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java (89%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java (68%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java (87%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java (94%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingStringComparer.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingUtf8StringComparer.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgument.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgumentList.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/UpdateOptions.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Record.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOStream.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordSerializer.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Segment.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ArrayPropertyType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/MapPropertyType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Namespace.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ObjectPropertyType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PartitionKey.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimarySortKey.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimitivePropertyType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Property.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertySchemaConverter.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Schema.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaException.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaHash.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaLanguageVersion.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaOptions.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ScopePropertyType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SetPropertyType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SortDirection.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StaticKey.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StorageKind.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictBooleanConverter.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictIntegerConverter.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TaggedPropertyType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TuplePropertyType.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java (100%) rename {jre => java}/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java (100%) rename {jre => java}/src/main/java/tangible/Action0Param.java (100%) rename {jre => java}/src/main/java/tangible/Func0Param.java (100%) rename {jre => java}/src/main/java/tangible/Func1Param.java (100%) rename {jre => java}/src/main/java/tangible/ListHelper.java (100%) rename {jre => java}/src/main/java/tangible/StringHelper.java (100%) rename {jre => java}/src/main/java/tangible/TryParseHelper.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BenchmarkSuiteBase.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonJsonModelRowGenerator.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonReaderExtensions.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenMicroBenchmarkSuite.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java (97%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/GenerateBenchmarkSuite.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/JsonModelRowGenerator.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/Measurements.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/MicroBenchmarkSuiteBase.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ProtobufRowGenerator.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ReaderBenchmark.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/RowReaderExtensions.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/SchematizedMicroBenchmarkSuite.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/TestData.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/UnschematizedMicroBenchmarkSuite.java (100%) create mode 100644 java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Address.java create mode 100644 java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Available_Rooms_By_Hotel_Date.java create mode 100644 java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/CassandraHotelSchemaReflection.java create mode 100644 java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Guests.java create mode 100644 java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Hotels.java create mode 100644 java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/PostalCode.java rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ArrayAssert.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/AssertThrowsException.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CrossVersioningUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CustomerExampleUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/DeleteRowDispatcher.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatchable.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatcher.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutCompilerUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutTypeUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullRowDispatcher.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/PermuteExtensions.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RandomGeneratorUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ReadRowDispatcher.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ResultAssert.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowBufferUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowOperationDispatcher.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowWriterUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaHashUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaIdUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TaggedUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/UpdateOptionsUnitTests.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Address.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Guest.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Hotel.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCode.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java (100%) rename {jre => java}/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/internal/MurmurHash3UnitTests.java (100%) delete mode 100644 jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java diff --git a/jre/pom.xml b/java/pom.xml similarity index 100% rename from jre/pom.xml rename to java/pom.xml diff --git a/java/src/main/java/com/azure/data/cosmos/core/Codecs.java b/java/src/main/java/com/azure/data/cosmos/core/Codecs.java new file mode 100644 index 0000000..a1a1c8b --- /dev/null +++ b/java/src/main/java/com/azure/data/cosmos/core/Codecs.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos.core; + +public class Codecs { +} diff --git a/jre/src/main/java/com/azure/data/cosmos/core/Json.java b/java/src/main/java/com/azure/data/cosmos/core/Json.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/core/Json.java rename to java/src/main/java/com/azure/data/cosmos/core/Json.java diff --git a/jre/src/main/java/com/azure/data/cosmos/core/Out.java b/java/src/main/java/com/azure/data/cosmos/core/Out.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/core/Out.java rename to java/src/main/java/com/azure/data/cosmos/core/Out.java diff --git a/jre/src/main/java/com/azure/data/cosmos/core/Reference.java b/java/src/main/java/com/azure/data/cosmos/core/Reference.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/core/Reference.java rename to java/src/main/java/com/azure/data/cosmos/core/Reference.java diff --git a/jre/src/main/java/com/azure/data/cosmos/core/Utf8String.java b/java/src/main/java/com/azure/data/cosmos/core/Utf8String.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/core/Utf8String.java rename to java/src/main/java/com/azure/data/cosmos/core/Utf8String.java diff --git a/jre/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java b/java/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java rename to java/src/main/java/com/azure/data/cosmos/core/UtfAnyString.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Float128.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Float128.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Float128.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Float128.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowHeader.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowHeader.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowHeader.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowHeader.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowVersion.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowVersion.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowVersion.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/HybridRowVersion.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/ISpanResizer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/ISpanResizer.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/ISpanResizer.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/ISpanResizer.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/MemorySpanResizer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/MemorySpanResizer.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/MemorySpanResizer.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/MemorySpanResizer.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/NullValue.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/NullValue.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/NullValue.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/NullValue.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Result.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Result.java similarity index 64% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Result.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Result.java index 9f71744..9f03056 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Result.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/Result.java @@ -3,6 +3,9 @@ package com.azure.data.cosmos.serialization.hybridrow; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + public enum Result { Success(0), Failure(1), @@ -40,31 +43,32 @@ public enum Result { */ Canceled(10); - public static final int SIZE = java.lang.Integer.SIZE; - private static java.util.HashMap mappings; - private int intValue; + public static final int SIZE = Integer.SIZE; + + private static Int2ObjectMap mappings; + private final int value; Result(int value) { - intValue = value; - getMappings().put(value, this); + this.value = value; + mappings().put(value, this); } - public int getValue() { - return intValue; + public static Result from(int value) { + return mappings().get(value); } - public static Result forValue(int value) { - return getMappings().get(value); + public int value() { + return this.value; } - private static java.util.HashMap getMappings() { + private static Int2ObjectMap mappings() { if (mappings == null) { synchronized (Result.class) { if (mappings == null) { - mappings = new java.util.HashMap(); + mappings = new Int2ObjectOpenHashMap<>(); } } } return mappings; } -} \ No newline at end of file +} diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java similarity index 75% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java index fa73aed..0de10ce 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowBuffer.java +++ b/java/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.Utf8String; -import com.azure.data.cosmos.serialization.hybridrow.RowBuffer.UniqueIndexItem; import com.azure.data.cosmos.serialization.hybridrow.io.RowWriter; import com.azure.data.cosmos.serialization.hybridrow.layouts.Layout; import com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutArray; @@ -58,12 +57,15 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import javax.annotation.Nonnull; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.Iterator; import java.util.Optional; import java.util.UUID; +import java.util.function.Supplier; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -114,7 +116,9 @@ public final class RowBuffer { * @param version The version of the Hybrid Row format to use for encoding the buffer. * @param resolver The resolver for UDTs. */ - public RowBuffer(@Nonnull final ByteBuf buffer, @Nonnull final HybridRowVersion version, @Nonnull final LayoutResolver resolver) { + public RowBuffer( + @Nonnull final ByteBuf buffer, @Nonnull final HybridRowVersion version, + @Nonnull final LayoutResolver resolver) { checkNotNull(buffer, "buffer"); checkNotNull(version, "version"); @@ -132,252 +136,13 @@ public final class RowBuffer { checkState(HybridRowHeader.SIZE + layout.size() <= this.length()); } - public long Read7BitEncodedInt(int offset, Out lenInBytes) { - return RowBuffer.rotateSignToMsb(this.read7BitEncodedUInt(offset, lenInBytes)); + public UUID readGuid(int offset) { + + return MemoryMarshal.Read(this.buffer.Slice(offset)); } - public void WriteNullable(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs, - UpdateOptions options, boolean hasValue, Out newScope) { - int numBytes = this.countDefaultValue(scopeType, typeArgs.clone()); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); - int numWritten = this.WriteDefaultValue(edit.get().valueOffset(), scopeType, typeArgs.clone()); - checkState(numBytes == numWritten); - checkState(spaceNeeded == metaBytes + numBytes); - if (hasValue) { - this.writeInt8(edit.get().valueOffset(), (byte) 1); - } - - int valueOffset = edit.get().valueOffset() + 1; - newScope.setAndGet(new RowCursor()); - newScope.get().scopeType(scopeType); - newScope.get().scopeTypeArgs(typeArgs.clone()); - newScope.get().start(edit.get().valueOffset()); - newScope.get().valueOffset(valueOffset); - newScope.get().metaOffset(valueOffset); - newScope.get().layout(edit.get().layout()); - newScope.get().count(2); - newScope.get().index(1); - - this.length(this.length() + shift); - Reference tempReference_this = - new Reference(this); - RowCursors.moveNext(newScope.get().clone(), tempReference_this); - this = tempReference_this.get(); - } - - /** - * Reads in the contents of the RowBuffer from an input stream and initializes the row buffer - * with the associated layout and rowVersion. - * - * @return true if the serialization succeeded. false if the input stream was corrupted. - */ - public boolean readFrom(@Nonnull final InputStream inputStream, final int byteCount, @Nonnull final HybridRowVersion version, @Nonnull final LayoutResolver resolver) { - - checkNotNull(inputStream, "inputStream"); - checkNotNull(resolver, "resolver"); - checkNotNull(version, "version"); - checkState(byteCount >= HybridRowHeader.SIZE, "expected byteCount >= %s, not %s", HybridRowHeader.SIZE, byteCount); - - this.reset(); - this.ensure(byteCount); - this.resolver = resolver; - - Span active = this.buffer.Slice(0, byteCount); - int bytesRead; - - do { - bytesRead = inputStream.Read(active); - active = active.Slice(bytesRead); - } while (bytesRead != 0); - - if (active.Length != 0) { - return false; - } - - return this.InitReadFrom(version); - } - - /** - * Compute the byte offsets from the beginning of the row for a given sparse field insertion - * into a set/map. - * - * @param scope The sparse scope to insert into. - * @param srcEdit The field to move into the set/map. - * @return The prepared edit context. - */ - public RowCursor prepareSparseMove(RowCursor scope, RowCursor srcEdit) { - checkArgument(scope.scopeType().isUniqueScope()); - - checkArgument(scope.index() == 0); - RowCursor dstEdit; - // 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: - scope.Clone(out dstEdit); - - dstEdit.metaOffset(scope.valueOffset()); - int srcSize = this.sparseComputeSize(srcEdit); - int srcBytes = srcSize - (srcEdit.valueOffset() - srcEdit.metaOffset()); - while (dstEdit.index() < dstEdit.count()) { - Reference tempReference_dstEdit = - new Reference(dstEdit); - this.readSparseMetadata(tempReference_dstEdit); - dstEdit = tempReference_dstEdit.get(); - Contract.Assert(dstEdit.pathOffset() == - default) - - int elmSize = -1; // defer calculating the full size until needed. - int cmp; - if (scope.get().scopeType() instanceof LayoutTypedMap) { - cmp = this.CompareKeyValueFieldValue(srcEdit.get().clone(), dstEdit); - } else { - Reference tempReference_dstEdit2 = - new Reference(dstEdit); - elmSize = this.sparseComputeSize(tempReference_dstEdit2); - dstEdit = tempReference_dstEdit2.get(); - int elmBytes = elmSize - (dstEdit.valueOffset() - dstEdit.metaOffset()); - cmp = this.CompareFieldValue(srcEdit.get().clone(), srcBytes, dstEdit, elmBytes); - } - - if (cmp <= 0) { - dstEdit.exists = cmp == 0; - return dstEdit; - } - - Reference tempReference_dstEdit3 = - new Reference(dstEdit); - elmSize = (elmSize == -1) ? this.sparseComputeSize(tempReference_dstEdit3) : elmSize; - dstEdit = tempReference_dstEdit3.get(); - dstEdit.index(dstEdit.index() + 1); - dstEdit.metaOffset(dstEdit.metaOffset() + elmSize); - } - - dstEdit.exists = false; - dstEdit.cellType = LayoutType.EndScope; - dstEdit.valueOffset(dstEdit.metaOffset()); - return dstEdit; - } - - /** - * Reads in the contents of the RowBuffer from an existing block of memory and initializes - * the row buffer with the associated layout and rowVersion. - * - * @return true if the serialization succeeded. false if the input stream was corrupted. - */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public bool ReadFrom(ReadOnlySpan input, HybridRowVersion rowVersion, LayoutResolver - // resolver) - public boolean readFrom(ReadOnlySpan input, HybridRowVersion rowVersion, LayoutResolver resolver) { - int bytesCount = input.Length; - checkState(bytesCount >= HybridRowHeader.SIZE); - - this.reset(); - this.resolver = resolver; - this.ensure(bytesCount); - checkState(this.buffer.Length >= bytesCount); - input.CopyTo(this.buffer); - this.length(bytesCount); - return this.InitReadFrom(rowVersion); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal void DecrementUInt32(int offset, uint decrement) - public void DecrementUInt32(int offset, int decrement) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: MemoryMarshal.Cast(this.buffer.Slice(offset))[0] -= decrement; - MemoryMarshal.Cast(this.buffer.Slice(offset))[0] -= decrement; - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal ReadOnlySpan ReadSparseBinary(ref RowCursor edit) - public ReadOnlySpan ReadSparseBinary(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutType.Binary); - int sizeLenInBytes; - Out tempOut_sizeLenInBytes = new Out(); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: ReadOnlySpan span = this.ReadBinary(edit.valueOffset, out int sizeLenInBytes); - ReadOnlySpan span = this.ReadBinary(edit.get().valueOffset(), tempOut_sizeLenInBytes); - sizeLenInBytes = tempOut_sizeLenInBytes.get(); - edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes + span.Length; - return span; - } - - public void deleteVariable(int offset, boolean isVarint) { - - int start = this.buffer.readerIndex(); - this.read7BitEncodedUInt(); - - ByteBuf remainder = this.buffer.slice(this.buffer.readerIndex(), this.buffer.readableBytes()); - this.buffer.readerIndex(start); - this.buffer.setBytes(start, remainder); - this.buffer.writerIndex(start + remainder.readableBytes()); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal void IncrementUInt32(int offset, uint increment) - public void IncrementUInt32(int offset, int increment) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: MemoryMarshal.Cast(this.buffer.Slice(offset))[0] += increment; - MemoryMarshal.Cast(this.buffer.Slice(offset))[0] += increment; - } - - public boolean ReadSparseBool(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutType.Boolean); - edit.get().endOffset = edit.get().valueOffset(); - return edit.get().cellType() == LayoutType.Boolean; - } - - public LocalDateTime ReadSparseDateTime(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutType.DateTime); - edit.get().endOffset = edit.get().valueOffset() + 8; - return this.ReadDateTime(edit.get().valueOffset()); - } - - public void WriteSchemaId(int offset, SchemaId value) { - this.writeInt32(offset, value.value()); - } - - public long read7BitEncodedUInt() { - - long b = this.buffer.readByte() & 0xFFL; - - if (b < 0x80L) { - return b; - } - - long result = b & 0x7FL; - int shift = 7; - - do { - checkState(shift < 10 * 7); - b = this.buffer.readByte() & 0xFFL; - result |= (b & 0x7FL) << shift; - shift += 7; - } while (b >= 0x80L); - - return result; - } - - public boolean readBit(int offset, LayoutBit bit) { - - if (bit.getIsInvalid()) { - return true; - } - - // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context: - //ORIGINAL LINE: return (this.buffer[bit.GetOffset(offset)] & unchecked((byte)(1 << bit.GetBit()))) != 0; - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - return (this.buffer[bit.offset(offset)] & (byte)(1 << bit.bit())) != 0; + public short ReadInt16(int offset) { + return MemoryMarshal.Read(this.buffer.Slice(offset)); } public LocalDateTime ReadDateTime(int offset) { @@ -410,6 +175,60 @@ public final class RowBuffer { return MemoryMarshal.Read(this.buffer.Slice(offset)); } + public int ReadInt32(int offset) { + return MemoryMarshal.Read(this.buffer.Slice(offset)); + } + + public MongoDbObjectId ReadMongoDbObjectId(int offset) { + return MemoryMarshal.Read(this.buffer.Slice(offset)); + } + + public SchemaId ReadSchemaId(int offset) { + return new SchemaId(this.ReadInt32(offset)); + } + + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal ReadOnlySpan ReadSparseBinary(ref RowCursor edit) + public ReadOnlySpan ReadSparseBinary(Reference edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutType.Binary); + int sizeLenInBytes; + Out tempOut_sizeLenInBytes = new Out(); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: ReadOnlySpan span = this.ReadBinary(edit.valueOffset, out int sizeLenInBytes); + ReadOnlySpan span = this.ReadBinary(edit.get().valueOffset(), tempOut_sizeLenInBytes); + sizeLenInBytes = tempOut_sizeLenInBytes.get(); + edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes + span.Length; + return span; + } + + public boolean ReadSparseBool(Reference edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutType.Boolean); + edit.get().endOffset = edit.get().valueOffset(); + return edit.get().cellType() == LayoutType.Boolean; + } + + public LocalDateTime ReadSparseDateTime(Reference edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutType.DateTime); + edit.get().endOffset = edit.get().valueOffset() + 8; + return this.ReadDateTime(edit.get().valueOffset()); + } + + public MongoDbObjectId ReadSparseMongoDbObjectId(Reference edit) { + this.readSparsePrimitiveTypeCode(edit, MongoDbObjectId); + edit.get().endOffset = edit.get().valueOffset() + MongoDbObjectId.Size; + return this.ReadMongoDbObjectId(edit.get().valueOffset()).clone(); + } + + public Utf8Span ReadSparseString(Reference edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutType.Utf8); + int sizeLenInBytes; + Out tempOut_sizeLenInBytes = new Out(); + Utf8Span span = this.ReadString(edit.get().valueOffset(), tempOut_sizeLenInBytes); + sizeLenInBytes = tempOut_sizeLenInBytes.get(); + edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes + span.Length; + return span; + } + public BigDecimal ReadSparseDecimal(Reference edit) { this.readSparsePrimitiveTypeCode(edit, LayoutType.Decimal); // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': @@ -423,113 +242,12 @@ public final class RowBuffer { return this.ReadFloat128(edit.get().valueOffset()).clone(); } - public UUID ReadGuid(int offset) { - return MemoryMarshal.Read(this.buffer.Slice(offset)); - } - public float ReadSparseFloat32(Reference edit) { this.readSparsePrimitiveTypeCode(edit, LayoutType.Float32); edit.get().endOffset = edit.get().valueOffset() + (Float.SIZE / Byte.SIZE); return this.ReadFloat32(edit.get().valueOffset()); } - public short ReadInt16(int offset) { - return MemoryMarshal.Read(this.buffer.Slice(offset)); - } - - public int ReadInt32(int offset) { - return MemoryMarshal.Read(this.buffer.Slice(offset)); - } - - public long ReadInt64(int offset) { - return MemoryMarshal.Read(this.buffer.Slice(offset)); - } - - public byte ReadInt8(int offset) { - // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context: - //ORIGINAL LINE: return unchecked((sbyte)this.buffer[offset]); - return (byte)this.buffer[offset]; - } - - public MongoDbObjectId ReadMongoDbObjectId(int offset) { - return MemoryMarshal.Read(this.buffer.Slice(offset)); - } - - public SchemaId ReadSchemaId(int offset) { - return new SchemaId(this.ReadInt32(offset)); - } - - public double ReadSparseFloat64(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutType.Float64); - edit.get().endOffset = edit.get().valueOffset() + (Double.SIZE / Byte.SIZE); - return this.ReadFloat64(edit.get().valueOffset()); - } - - public UUID ReadSparseGuid(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutType.Guid); - edit.get().endOffset = edit.get().valueOffset() + 16; - return this.ReadGuid(edit.get().valueOffset()); - } - - public short ReadSparseInt16(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutType.Int16); - edit.get().endOffset = edit.get().valueOffset() + (Short.SIZE / Byte.SIZE); - return this.ReadInt16(edit.get().valueOffset()); - } - - public int ReadSparseInt32(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutType.Int32); - edit.get().endOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); - return this.ReadInt32(edit.get().valueOffset()); - } - - public long ReadSparseInt64(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutType.Int64); - edit.get().endOffset = edit.get().valueOffset() + (Long.SIZE / Byte.SIZE); - return this.ReadInt64(edit.get().valueOffset()); - } - - public byte ReadSparseInt8(Reference edit) { - // TODO: Remove calls to ReadSparsePrimitiveTypeCode once moved to V2 read. - this.readSparsePrimitiveTypeCode(edit, LayoutType.Int8); - edit.get().endOffset = edit.get().valueOffset() + (Byte.SIZE / Byte.SIZE); - return this.ReadInt8(edit.get().valueOffset()); - } - - public MongoDbObjectId ReadSparseMongoDbObjectId(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, MongoDbObjectId); - edit.get().endOffset = edit.get().valueOffset() + MongoDbObjectId.Size; - return this.ReadMongoDbObjectId(edit.get().valueOffset()).clone(); - } - - public int ReadSparsePathLen(Layout layout, int offset, Out pathLenInBytes, - Out pathOffset) { - int sizeLenInBytes; - Out tempOut_sizeLenInBytes = new Out(); - int token = (int)this.read7BitEncodedUInt(offset, tempOut_sizeLenInBytes); - sizeLenInBytes = tempOut_sizeLenInBytes.get(); - if (token < layout.getTokenizer().getCount()) { - pathLenInBytes.setAndGet(sizeLenInBytes); - pathOffset.setAndGet(offset); - return token; - } - - int numBytes = token - layout.getTokenizer().getCount(); - pathLenInBytes.setAndGet(numBytes + sizeLenInBytes); - pathOffset.setAndGet(offset + sizeLenInBytes); - return token; - } - - public Utf8Span ReadSparseString(Reference edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutType.Utf8); - int sizeLenInBytes; - Out tempOut_sizeLenInBytes = new Out(); - Utf8Span span = this.ReadString(edit.get().valueOffset(), tempOut_sizeLenInBytes); - sizeLenInBytes = tempOut_sizeLenInBytes.get(); - edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes + span.Length; - return span; - } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: internal ushort ReadSparseUInt16(ref RowCursor edit) public short ReadSparseUInt16(Reference edit) { @@ -554,13 +272,6 @@ public final class RowBuffer { return this.ReadUInt64(edit.get().valueOffset()); } - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal LayoutType ReadSparseTypeCode(int - // offset) - public LayoutType readSparseTypeCode(int offset) { - return LayoutType.FromCode(LayoutCode.forValue(this.ReadUInt8(offset))); - } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: internal byte ReadSparseUInt8(ref RowCursor edit) public byte ReadSparseUInt8(Reference edit) { @@ -579,83 +290,104 @@ public final class RowBuffer { this.readSparsePrimitiveTypeCode(edit, LayoutType.VarInt); int sizeLenInBytes; Out tempOut_sizeLenInBytes = new Out(); - long value = this.Read7BitEncodedInt(edit.get().valueOffset(), tempOut_sizeLenInBytes); + long value = this.read7BitEncodedInt(edit.get().valueOffset(), tempOut_sizeLenInBytes); sizeLenInBytes = tempOut_sizeLenInBytes.get(); edit.get().endOffset = edit.get().valueOffset() + sizeLenInBytes; return value; } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal void WriteSparseBinary(ref RowCursor edit, ReadOnlySpan value, UpdateOptions - // options) - public void WriteSparseBinary(Reference edit, ReadOnlySpan value, UpdateOptions options) { - int len = value.Length; + //ORIGINAL LINE: internal ushort ReadUInt16(int offset) + public short ReadUInt16(int offset) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: int numBytes = len + RowBuffer.Count7BitEncodedUInt((ulong)len); - int numBytes = len + RowBuffer.count7BitEncodedUInt(len); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Binary, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Binary, TypeArgumentList.EMPTY, metaBytes); - int sizeLenInBytes = this.WriteBinary(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); + //ORIGINAL LINE: return MemoryMarshal.Read(this.buffer.Slice(offset)); + return MemoryMarshal.Read(this.buffer.Slice(offset)); } //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal void WriteSparseBinary(ref RowCursor edit, ReadOnlySequence value, UpdateOptions - // options) - public void WriteSparseBinary(Reference edit, ReadOnlySequence value, - UpdateOptions options) { - int len = (int)value.Length; + //ORIGINAL LINE: internal uint ReadUInt32(int offset) + public int ReadUInt32(int offset) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: int numBytes = len + RowBuffer.Count7BitEncodedUInt((ulong)len); - int numBytes = len + RowBuffer.count7BitEncodedUInt(len); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Binary, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Binary, TypeArgumentList.EMPTY, metaBytes); - int sizeLenInBytes = this.WriteBinary(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); + //ORIGINAL LINE: return MemoryMarshal.Read(this.buffer.Slice(offset)); + return MemoryMarshal.Read(this.buffer.Slice(offset)); } - public void WriteSparseFloat128(Reference edit, Float128 value, UpdateOptions options) { - int numBytes = Float128.Size; - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Float128, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Float128, TypeArgumentList.EMPTY, metaBytes); - this.writeFloat128(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + Float128.Size); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal ulong ReadUInt64(int offset) + public long ReadUInt64(int offset) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: return MemoryMarshal.Read(this.buffer.Slice(offset)); + return MemoryMarshal.Read(this.buffer.Slice(offset)); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal byte ReadUInt8(int offset) + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal byte ReadUInt8(int offset) + public byte ReadUInt8(int offset) { + return this.buffer[offset]; + } + + public UnixDateTime ReadUnixDateTime(int offset) { + return MemoryMarshal.Read(this.buffer.Slice(offset)); + } + + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal ReadOnlySpan ReadVariableBinary(int offset) + public ReadOnlySpan ReadVariableBinary(int offset) { + int _; + Out tempOut__ = new Out(); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: return this.ReadBinary(offset, out int _); + ReadOnlySpan tempVar = this.ReadBinary(offset, tempOut__); + _ = tempOut__.get(); + return tempVar; + } + + public long ReadVariableInt(int offset) { + int _; + Out tempOut__ = new Out(); + long tempVar = this.read7BitEncodedInt(offset, tempOut__); + _ = tempOut__.get(); + return tempVar; + } + + public Utf8Span ReadVariableString(int offset) { + int _; + Out tempOut__ = new Out(); + Utf8Span tempVar = this.ReadString(offset, tempOut__); + _ = tempOut__.get(); + return tempVar; + } + + public long ReadVariableUInt(int offset) { + int _; + Out tempOut__ = new Out(); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: return this.Read7BitEncodedUInt(offset, out int _); + long tempVar = this.read7BitEncodedUInt(); + _ = tempOut__.get(); + return tempVar; + } + + public void SetBit(int offset, LayoutBit bit) { + if (bit.getIsInvalid()) { + return; + } + + // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context: + //ORIGINAL LINE: this.buffer[bit.GetOffset(offset)] |= unchecked((byte)(1 << bit.GetBit())); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + this.buffer[bit.offset(offset)] |= (byte) (1 << bit.bit()); + } + + /** + * The length of row in bytes. + */ + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: public byte[] ToArray() + public byte[] ToArray() { + return this.buffer.Slice(0, this.length()).ToArray(); } public void TypedCollectionMoveField(Reference dstEdit, Reference srcEdit @@ -676,7 +408,7 @@ public final class RowBuffer { spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(dstEdit, srcEdit.get().cellType(), srcEdit.get().cellTypeArgs().clone(), metaBytes); + this.writeSparseMetadata(dstEdit, srcEdit.get().cellType(), srcEdit.get().cellTypeArgs().clone(), metaBytes); checkState(spaceNeeded == metaBytes + numBytes); if (srcEdit.get().metaOffset() >= dstEdit.get().metaOffset()) { srcEdit.get().metaOffset(srcEdit.get().metaOffset() + shiftInsert); @@ -815,352 +547,12 @@ public final class RowBuffer { return Result.Success; } - public void WriteSparseInt16(Reference edit, short value, UpdateOptions options) { - int numBytes = (Short.SIZE / Byte.SIZE); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Int16, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Int16, TypeArgumentList.EMPTY, metaBytes); - this.writeInt16(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + (Short.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); - } - - public void WriteSparseInt32(Reference edit, int value, UpdateOptions options) { - int numBytes = (Integer.SIZE / Byte.SIZE); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Int32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Int32, TypeArgumentList.EMPTY, metaBytes); - this.writeInt32(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + (Integer.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); - } - - public void WriteSparseInt64(Reference edit, long value, UpdateOptions options) { - int numBytes = (Long.SIZE / Byte.SIZE); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Int64, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Int64, TypeArgumentList.EMPTY, metaBytes); - this.writeInt64(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + (Long.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); - } - - // TODO: DANOBLE: Support MongoDbObjectId values - // public void WriteMongoDbObjectId(int offset, MongoDbObjectId value) { - // Reference tempReference_value = - // new Reference(value); - // MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value); - // value = tempReference_value.get(); - // } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal ushort ReadUInt16(int offset) - public short ReadUInt16(int offset) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: return MemoryMarshal.Read(this.buffer.Slice(offset)); - return MemoryMarshal.Read(this.buffer.Slice(offset)); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal uint ReadUInt32(int offset) - public int ReadUInt32(int offset) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: return MemoryMarshal.Read(this.buffer.Slice(offset)); - return MemoryMarshal.Read(this.buffer.Slice(offset)); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal ulong ReadUInt64(int offset) - public long ReadUInt64(int offset) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: return MemoryMarshal.Read(this.buffer.Slice(offset)); - return MemoryMarshal.Read(this.buffer.Slice(offset)); - } - - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal byte ReadUInt8(int offset) - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal byte ReadUInt8(int offset) - public byte ReadUInt8(int offset) { - return this.buffer[offset]; - } - - public UnixDateTime ReadUnixDateTime(int offset) { - return MemoryMarshal.Read(this.buffer.Slice(offset)); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal ReadOnlySpan ReadVariableBinary(int offset) - public ReadOnlySpan ReadVariableBinary(int offset) { - int _; - Out tempOut__ = new Out(); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: return this.ReadBinary(offset, out int _); - ReadOnlySpan tempVar = this.ReadBinary(offset, tempOut__); - _ = tempOut__.get(); - return tempVar; - } - - public long ReadVariableInt(int offset) { - int _; - Out tempOut__ = new Out(); - long tempVar = this.Read7BitEncodedInt(offset, tempOut__); - _ = tempOut__.get(); - return tempVar; - } - - public Utf8Span ReadVariableString(int offset) { - int _; - Out tempOut__ = new Out(); - Utf8Span tempVar = this.ReadString(offset, tempOut__); - _ = tempOut__.get(); - return tempVar; - } - - public long ReadVariableUInt(int offset) { - int _; - Out tempOut__ = new Out(); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: return this.Read7BitEncodedUInt(offset, out int _); - long tempVar = this.read7BitEncodedUInt(); - _ = tempOut__.get(); - return tempVar; - } - - /** - * Clears all content from the row. The row is empty after this method. - */ - public void reset() { - this.buffer.clear(); - this.resolver = null; - } - - public void WriteSparseInt8(Reference edit, byte value, UpdateOptions options) { - int numBytes = (Byte.SIZE / Byte.SIZE); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Int8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - - this.WriteSparseMetadata(edit, LayoutType.Int8, TypeArgumentList.EMPTY, metaBytes); - this.writeInt8(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + (Byte.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); - } - - public void WriteSparseArray(Reference edit, LayoutScope scopeType, UpdateOptions options, - Out newScope) { - int numBytes = (LayoutCode.SIZE / Byte.SIZE); // end scope type code. - TypeArgumentList typeArgs = TypeArgumentList.EMPTY; - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, scopeType, typeArgs.clone(), numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); - this.writeSparseTypeCode(edit.get().valueOffset(), LayoutCode.END_SCOPE); - checkState(spaceNeeded == metaBytes + numBytes); - newScope.setAndGet(new RowCursor()); - newScope.get().scopeType(scopeType); - newScope.get().scopeTypeArgs(typeArgs.clone()); - newScope.get().start(edit.get().valueOffset()); - newScope.get().valueOffset(edit.get().valueOffset()); - newScope.get().metaOffset(edit.get().valueOffset()); - newScope.get().layout(edit.get().layout()); - - this.length(this.length() + shift); - } - - public void SetBit(int offset, LayoutBit bit) { - if (bit.getIsInvalid()) { - return; - } - - // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context: - //ORIGINAL LINE: this.buffer[bit.GetOffset(offset)] |= unchecked((byte)(1 << bit.GetBit())); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - this.buffer[bit.offset(offset)] |= (byte)(1 << bit.bit()); - } - - public void WriteSparseString(Reference edit, Utf8Span value, UpdateOptions options) { - int len = value.Length; - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: int numBytes = len + RowBuffer.Count7BitEncodedUInt((ulong)len); - int numBytes = len + RowBuffer.count7BitEncodedUInt(len); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Utf8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Utf8, TypeArgumentList.EMPTY, metaBytes); - int sizeLenInBytes = this.WriteString(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); - } - - /** - * The length of row in bytes. - */ - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: public byte[] ToArray() - public byte[] ToArray() { - return this.buffer.Slice(0, this.length()).ToArray(); - } - - public void WriteSparseVarInt(Reference edit, long value, UpdateOptions options) { - int numBytes = RowBuffer.Count7BitEncodedInt(value); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.VarInt, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.VarInt, TypeArgumentList.EMPTY, metaBytes); - int sizeLenInBytes = this.write7BitEncodedInt(edit.get().valueOffset(), value); - checkState(sizeLenInBytes == numBytes); - checkState(spaceNeeded == metaBytes + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal void WriteSparseVarUInt(ref RowCursor edit, ulong value, UpdateOptions options) - public void WriteSparseVarUInt(Reference edit, long value, UpdateOptions options) { - int numBytes = RowBuffer.count7BitEncodedUInt(value); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.VarUInt, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.VarUInt, TypeArgumentList.EMPTY, metaBytes); - int sizeLenInBytes = this.write7BitEncodedUInt(edit.get().valueOffset(), value); - checkState(sizeLenInBytes == numBytes); - checkState(spaceNeeded == metaBytes + sizeLenInBytes); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); - } - - public void WriteSparseBool(Reference edit, boolean value, UpdateOptions options) { - int numBytes = 0; - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.EMPTY, - numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.EMPTY, - metaBytes); - checkState(spaceNeeded == metaBytes); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); - } - public void UnsetBit(int offset, LayoutBit bit) { checkState(LayoutBit.opNotEquals(bit.clone(), LayoutBit.INVALID)); // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context: //ORIGINAL LINE: this.buffer[bit.GetOffset(offset)] &= unchecked((byte)~(1 << bit.GetBit())); //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - this.buffer[bit.offset(offset)] &= (byte)~(1 << bit.bit()); - } - - public void WriteVariableInt(int offset, long value, boolean exists, Out shift) { - int numBytes = RowBuffer.Count7BitEncodedInt(value); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - this.EnsureVariable(offset, true, numBytes, exists, tempOut_spaceNeeded, shift); - spaceNeeded = tempOut_spaceNeeded.get(); - - int sizeLenInBytes = this.write7BitEncodedInt(offset, value); - checkState(sizeLenInBytes == numBytes); - checkState(spaceNeeded == numBytes); - this.length(this.length() + shift.get()); - } - - public void WriteSparseDateTime(Reference edit, LocalDateTime value, UpdateOptions options) { - int numBytes = 8; - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.DateTime, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.DateTime, TypeArgumentList.EMPTY, metaBytes); - this.WriteDateTime(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + 8); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); + this.buffer[bit.offset(offset)] &= (byte) ~(1 << bit.bit()); } public void WriteDateTime(int offset, LocalDateTime value) { @@ -1189,7 +581,7 @@ public final class RowBuffer { public void WriteFixedBinary(int offset, ReadOnlySequence value, int len) { value.CopyTo(this.buffer.Slice(offset, len)); if (value.Length < len) { - this.buffer.Slice(offset + (int)value.Length, len - (int)value.Length).Fill(0); + this.buffer.Slice(offset + (int) value.Length, len - (int) value.Length).Fill(0); } } @@ -1197,28 +589,6 @@ public final class RowBuffer { value.Span.CopyTo(this.buffer.Slice(offset)); } - public void WriteSparseDecimal(Reference edit, BigDecimal value, UpdateOptions options) { - // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': - int numBytes = sizeof(BigDecimal); - int metaBytes; - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, LayoutType.Decimal, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Decimal, TypeArgumentList.EMPTY, metaBytes); - this.WriteDecimal(edit.get().valueOffset(), value); - // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': - checkState(spaceNeeded == metaBytes + sizeof(BigDecimal)); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); - } - public void WriteFloat32(int offset, float value) { Reference tempReference_value = new Reference(value); MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value); @@ -1237,200 +607,183 @@ public final class RowBuffer { value = tempReference_value.get(); } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal void WriteVariableUInt(int offset, ulong value, bool exists, out int shift) - public void WriteVariableUInt(int offset, long value, boolean exists, Out shift) { - int numBytes = RowBuffer.count7BitEncodedUInt(value); + public void WriteNullable(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs, + UpdateOptions options, boolean hasValue, Out newScope) { + int numBytes = this.countDefaultValue(scopeType, typeArgs); + int metaBytes; + Out tempOut_metaBytes = new Out(); int spaceNeeded; Out tempOut_spaceNeeded = new Out(); - this.EnsureVariable(offset, true, numBytes, exists, tempOut_spaceNeeded, shift); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, scopeType, typeArgs, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, scopeType, typeArgs, metaBytes); + int numWritten = this.writeDefaultValue(edit.get().valueOffset(), scopeType, typeArgs); + checkState(numBytes == numWritten); + checkState(spaceNeeded == metaBytes + numBytes); + if (hasValue) { + this.writeInt8(edit.get().valueOffset(), (byte) 1); + } - int sizeLenInBytes = this.write7BitEncodedUInt(offset, value); - checkState(sizeLenInBytes == numBytes); - checkState(spaceNeeded == numBytes); - this.length(this.length() + shift.get()); + int valueOffset = edit.get().valueOffset() + 1; + newScope.setAndGet(new RowCursor()); + newScope.get().scopeType(scopeType); + newScope.get().scopeTypeArgs(typeArgs); + newScope.get().start(edit.get().valueOffset()); + newScope.get().valueOffset(valueOffset); + newScope.get().metaOffset(valueOffset); + newScope.get().layout(edit.get().layout()); + newScope.get().count(2); + newScope.get().index(1); + + this.length(this.length() + shift); + Reference tempReference_this = + new Reference(this); + RowCursors.moveNext(newScope.get().clone(), tempReference_this); + this = tempReference_this.get(); } - /** - * Compute the number of bytes necessary to store the unsigned 32-bit integer value using the varuint encoding - * - * @param value The value to be encoded - * @return The number of bytes needed to store the varuint encoding of {@code value} - */ - public static int count7BitEncodedUInt(long value) { - checkArgument(0 <= value && value <= 0x00000000FFFFFFFFL, "value: %s", value); - int i = 0; - while (value >= 0x80L) { - i++; - value >>>= 7; - } - i++; - return i; + public void WriteSchemaId(int offset, SchemaId value) { + this.writeInt32(offset, value.value()); } - /** - * Initializes a row to the minimal size for the given layout. - * - * @param version The version of the Hybrid Row format to use for encoding this row. - * @param layout The layout that describes the column layout of the row. - * @param resolver The resolver for UDTs. - *

- * The row is initialized to default row for the given layout. All fixed columns have their - * default values. All variable columns are null. No sparse columns are present. The row is - * valid. - */ - public void initLayout(HybridRowVersion version, Layout layout, LayoutResolver resolver) { - - checkNotNull(version, "version"); - checkNotNull(layout, "layout"); - checkNotNull(resolver, "resolver"); - - this.writeHeader(new HybridRowHeader(version, layout.schemaId())); - this.buffer.writeZero(layout.size()); - this.resolver = resolver; + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal void WriteSparseBinary(ref RowCursor edit, ReadOnlySpan value, UpdateOptions + // options) + public void WriteSparseBinary(Reference edit, ReadOnlySpan value, UpdateOptions options) { + int len = value.Length; + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: int numBytes = len + RowBuffer.Count7BitEncodedUInt((ulong)len); + int numBytes = len + RowBuffer.count7BitEncodedUInt(len); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Binary, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.Binary, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.WriteBinary(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } - /** - * Rotates the sign bit of a two's complement value to the least significant bit - * - * @param value A signed value. - * @return An unsigned value encoding the same value but with the sign bit in the LSB. - *

- * Moves the signed bit of a two's complement value to the least significant bit (LSB) by: - * - * - * If negative, take the two's complement. - * - * Left shift the value by 1 bit. - * - * If negative, set the LSB to 1. - * - * - */ - public static long rotateSignToLsb(long value) { - boolean isNegative = value < 0; - long unsignedValue = value; - unsignedValue = isNegative ? ((~unsignedValue + 1) << 1) + 1 : unsignedValue << 1; - return unsignedValue; + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal void WriteSparseBinary(ref RowCursor edit, ReadOnlySequence value, UpdateOptions + // options) + public void WriteSparseBinary(Reference edit, ReadOnlySequence value, + UpdateOptions options) { + int len = (int) value.Length; + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: int numBytes = len + RowBuffer.Count7BitEncodedUInt((ulong)len); + int numBytes = len + RowBuffer.count7BitEncodedUInt(len); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Binary, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.Binary, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.WriteBinary(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } - /** - * Undoes the rotation introduced by {@link #rotateSignToLsb}. - * - * @param unsignedValue An unsigned value with the sign bit in the LSB. - * @return A signed two's complement value encoding the same value. - */ - public static long rotateSignToMsb(long unsignedValue) { - boolean isNegative = unsignedValue % 2 != 0; - return isNegative ? (~(unsignedValue >>> 1) + 1) | 0x8000000000000000L : unsignedValue >>> 1; + public void WriteSparseBool(Reference edit, boolean value, UpdateOptions options) { + int numBytes = 0; + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.EMPTY, + numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, value ? LayoutType.Boolean : LayoutType.BooleanFalse, TypeArgumentList.EMPTY, + metaBytes); + checkState(spaceNeeded == metaBytes); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } - /** - * Produce a new scope from the current iterator position. - * - * @param edit An initialized iterator pointing at a scope. - * @param immutable True if the new scope should be marked immutable (read-only). - * @return A new scope beginning at the current iterator position. - */ - public RowCursor sparseIteratorReadScope(Reference edit, boolean immutable) { + public void WriteSparseDateTime(Reference edit, LocalDateTime value, UpdateOptions options) { + int numBytes = 8; + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.DateTime, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.DateTime, TypeArgumentList.EMPTY, metaBytes); + this.WriteDateTime(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + 8); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); + } - LayoutScope scopeType = edit.get().cellType() instanceof LayoutScope ? (LayoutScope) edit.get().cellType() : null; + public void WriteSparseDecimal(Reference edit, BigDecimal value, UpdateOptions options) { + // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': + int numBytes = sizeof(BigDecimal); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Decimal, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.Decimal, TypeArgumentList.EMPTY, metaBytes); + this.WriteDecimal(edit.get().valueOffset(), value); + // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'sizeof': + checkState(spaceNeeded == metaBytes + sizeof(BigDecimal)); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); + } - if (scopeType instanceof LayoutObject || scopeType instanceof LayoutArray) { - return new RowCursor() - .scopeType(scopeType) - .scopeTypeArgs(edit.get().cellTypeArgs()) - .start(edit.get().valueOffset()) - .valueOffset(edit.get().valueOffset()) - .metaOffset(edit.get().valueOffset()) - .layout(edit.get().layout()) - .immutable(immutable); - } - - if (scopeType instanceof LayoutTypedArray || scopeType instanceof LayoutTypedSet || scopeType instanceof LayoutTypedMap) { - - final int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size - - return new RowCursor() - .scopeType(scopeType) - .scopeTypeArgs(edit.get().cellTypeArgs()) - .start(edit.get().valueOffset()) - .valueOffset(valueOffset) - .metaOffset(valueOffset) - .layout(edit.get().layout()) - .immutable(immutable) - .count(this.ReadUInt32(edit.get().valueOffset())); - } - - if (scopeType instanceof LayoutTypedTuple || scopeType instanceof LayoutTuple || scopeType instanceof LayoutTagged || scopeType instanceof LayoutTagged2) { - - return new RowCursor() - .scopeType(scopeType) - .scopeTypeArgs(edit.get().cellTypeArgs()) - .start(edit.get().valueOffset()) - .valueOffset(edit.get().valueOffset()) - .metaOffset(edit.get().valueOffset()) - .layout(edit.get().layout()) - .immutable(immutable) - .count(edit.get().cellTypeArgs().count()); - } - - if (scopeType instanceof LayoutNullable) { - - boolean hasValue = this.ReadInt8(edit.get().valueOffset()) != 0; - - if (hasValue) { - - // Start at the T so it can be read. - final int valueOffset = edit.get().valueOffset() + 1; - - return new RowCursor() - .scopeType(scopeType) - .scopeTypeArgs(edit.get().cellTypeArgs()) - .start(edit.get().valueOffset()) - .valueOffset(valueOffset) - .metaOffset(valueOffset) - .layout(edit.get().layout()) - .immutable(immutable) - .count(2) - .index(1); - } else { - - // Start at the end of the scope, instead of at the T, so the T will be skipped. - final TypeArgument typeArg = edit.get().cellTypeArgs().get(0); - final int valueOffset = edit.get().valueOffset() + 1 + this.countDefaultValue(typeArg.type(), - typeArg.typeArgs()); - - return new RowCursor() - .scopeType(scopeType) - .scopeTypeArgs(edit.get().cellTypeArgs()) - .start(edit.get().valueOffset()) - .valueOffset(valueOffset) - .metaOffset(valueOffset) - .layout(edit.get().layout()) - .immutable(immutable) - .count(2) - .index(2); - } - } - - if (scopeType instanceof LayoutUDT) { - - final Layout udt = this.resolver.resolve(edit.get().cellTypeArgs().schemaId()); - final int valueOffset = this.computeVariableValueOffset(udt, edit.get().valueOffset(), udt.numVariable()); - - return new RowCursor() - .scopeType(scopeType) - .scopeTypeArgs(edit.get().cellTypeArgs()) - .start(edit.get().valueOffset()) - .valueOffset(valueOffset) - .metaOffset(valueOffset) - .layout(udt) - .immutable(immutable); - } - - throw new IllegalStateException(lenientFormat("Not a scope type: %s", scopeType)); + public void WriteSparseFloat128(Reference edit, Float128 value, UpdateOptions options) { + int numBytes = Float128.Size; + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Float128, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.Float128, TypeArgumentList.EMPTY, metaBytes); + this.writeFloat128(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + Float128.Size); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseFloat64(Reference edit, double value, UpdateOptions options) { @@ -1446,13 +799,21 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Float64, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, LayoutType.Float64, TypeArgumentList.EMPTY, metaBytes); this.WriteFloat64(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Double.SIZE / Byte.SIZE)); edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; this.length(this.length() + shift); } + // TODO: DANOBLE: Support MongoDbObjectId values + // public void WriteMongoDbObjectId(int offset, MongoDbObjectId value) { + // Reference tempReference_value = + // new Reference(value); + // MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value); + // value = tempReference_value.get(); + // } + public void WriteSparseGuid(Reference edit, UUID value, UpdateOptions options) { int numBytes = 16; int metaBytes; @@ -1466,48 +827,92 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Guid, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, LayoutType.Guid, TypeArgumentList.EMPTY, metaBytes); this.WriteGuid(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + 16); edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; this.length(this.length() + shift); } - public int write7BitEncodedInt(int offset, long value) { - return this.write7BitEncodedUInt(offset, RowBuffer.rotateSignToLsb(value)); + public void WriteSparseInt16(Reference edit, short value, UpdateOptions options) { + int numBytes = (Short.SIZE / Byte.SIZE); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Int16, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.Int16, TypeArgumentList.EMPTY, metaBytes); + this.writeInt16(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + (Short.SIZE / Byte.SIZE)); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } - /** - * Sets the specified 64-bit integer at the current {@link RowBuffer position} as a 7-bit encoded 32-bit value - *

- * The 64-bit integer value is written 7-bits at a time. The high bit of the byte, when set, indicates there are - * more bytes. An {@link IllegalArgumentException} is thrown, if the specified 64-bit integer value is outside - * the range of an unsigned 32-bit integer, [0, 0x00000000FFFFFFFFL]. - * - * @param ignored - * @param value a 64-bit integer constrained to the range of an unsigned 32-bit integer, [0, 0x00000000FFFFFFFFL] - * @return The number of bytes written - */ - public int write7BitEncodedUInt(final int ignored, final long value) { - checkArgument(0 <= value && value <= 0x00000000FFFFFFFFL); - long n = value; - int i = 0; - while (n >= 0x80L) { - this.buffer.writeByte((byte) (n | 0x80L)); - n >>>= 7; - } - this.buffer.writeByte((byte) n); - return i; + public void WriteSparseInt32(Reference edit, int value, UpdateOptions options) { + int numBytes = (Integer.SIZE / Byte.SIZE); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Int32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.Int32, TypeArgumentList.EMPTY, metaBytes); + this.writeInt32(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + (Integer.SIZE / Byte.SIZE)); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } - public void writeFloat128(int offset, Float128 value) { - this.buffer.writeLongLE(value.low()); - this.buffer.writeLongLE(value.high()); + public void WriteSparseInt64(Reference edit, long value, UpdateOptions options) { + int numBytes = (Long.SIZE / Byte.SIZE); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Int64, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.Int64, TypeArgumentList.EMPTY, metaBytes); + this.writeInt64(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + (Long.SIZE / Byte.SIZE)); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } - public void writeHeader(HybridRowHeader value) { - this.buffer.writeByte(value.version().value()); - this.buffer.writeIntLE(value.schemaId().value()); + public void WriteSparseInt8(Reference edit, byte value, UpdateOptions options) { + int numBytes = (Byte.SIZE / Byte.SIZE); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Int8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + + this.writeSparseMetadata(edit, LayoutType.Int8, TypeArgumentList.EMPTY, metaBytes); + this.writeInt8(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + (Byte.SIZE / Byte.SIZE)); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseMongoDbObjectId(Reference edit, MongoDbObjectId value, @@ -1525,7 +930,7 @@ public final class RowBuffer { spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, MongoDbObjectId, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, MongoDbObjectId, TypeArgumentList.EMPTY, metaBytes); this.WriteMongoDbObjectId(edit.get().valueOffset(), value.clone()); checkState(spaceNeeded == metaBytes + MongoDbObjectId.Size); edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; @@ -1545,7 +950,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Null, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, LayoutType.Null, TypeArgumentList.EMPTY, metaBytes); checkState(spaceNeeded == metaBytes); edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; this.length(this.length() + shift); @@ -1566,7 +971,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, scopeType, TypeArgumentList.EMPTY, metaBytes); this.writeSparseTypeCode(edit.get().valueOffset(), LayoutCode.END_SCOPE); checkState(spaceNeeded == metaBytes + numBytes); newScope.setAndGet(new RowCursor()); @@ -1580,8 +985,27 @@ public final class RowBuffer { this.length(this.length() + shift); } - public void writeInt16(final int ignored, final short value) { - this.buffer.writeShortLE(value); + public void WriteSparseString(Reference edit, Utf8Span value, UpdateOptions options) { + int len = value.Length; + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: int numBytes = len + RowBuffer.Count7BitEncodedUInt((ulong)len); + int numBytes = len + RowBuffer.count7BitEncodedUInt(len); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.Utf8, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.Utf8, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.writeString(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + len + sizeLenInBytes); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } public void WriteSparseTuple(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs @@ -1598,7 +1022,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); + this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); int valueOffset = edit.get().valueOffset(); for (int i = 0; i < typeArgs.count(); i++) { this.writeSparseTypeCode(valueOffset, LayoutCode.NULL); @@ -1634,7 +1058,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); + this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); // Clear all presence bits. this.buffer.Slice(edit.get().valueOffset(), udt.size()).Fill(0); @@ -1669,7 +1093,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UInt16, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, LayoutType.UInt16, TypeArgumentList.EMPTY, metaBytes); this.WriteUInt16(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Short.SIZE / Byte.SIZE)); edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; @@ -1691,7 +1115,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UInt32, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, LayoutType.UInt32, TypeArgumentList.EMPTY, metaBytes); this.WriteUInt32(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Integer.SIZE / Byte.SIZE)); edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; @@ -1713,7 +1137,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UInt64, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, LayoutType.UInt64, TypeArgumentList.EMPTY, metaBytes); this.WriteUInt64(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + (Long.SIZE / Byte.SIZE)); edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; @@ -1735,7 +1159,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UInt8, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, LayoutType.UInt8, TypeArgumentList.EMPTY, metaBytes); this.WriteUInt8(edit.get().valueOffset(), value); checkState(spaceNeeded == metaBytes + 1); edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; @@ -1756,28 +1180,62 @@ public final class RowBuffer { spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.UnixDateTime, TypeArgumentList.EMPTY, metaBytes); + this.writeSparseMetadata(edit, LayoutType.UnixDateTime, TypeArgumentList.EMPTY, metaBytes); this.WriteUnixDateTime(edit.get().valueOffset(), value.clone()); checkState(spaceNeeded == metaBytes + 8); edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; this.length(this.length() + shift); } - // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: - //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal void WriteSparseTypeCode(int offset, - // LayoutCode code) - public void writeSparseTypeCode(int offset, LayoutCode code) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: this.WriteUInt8(offset, (byte)code); - this.WriteUInt8(offset, (byte) code.value()); + public void WriteSparseVarInt(Reference edit, long value, UpdateOptions options) { + int numBytes = RowBuffer.Count7BitEncodedInt(value); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.VarInt, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.VarInt, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.write7BitEncodedInt(edit.get().valueOffset(), value); + checkState(sizeLenInBytes == numBytes); + checkState(spaceNeeded == metaBytes + sizeLenInBytes); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } - public void writeInt32(final int ignored, final int value) { - this.buffer.writeIntLE(value); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal void WriteSparseVarUInt(ref RowCursor edit, ulong value, UpdateOptions options) + public void WriteSparseVarUInt(Reference edit, long value, UpdateOptions options) { + int numBytes = RowBuffer.count7BitEncodedUInt(value); + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, LayoutType.VarUInt, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.VarUInt, TypeArgumentList.EMPTY, metaBytes); + int sizeLenInBytes = this.write7BitEncodedUInt(edit.get().valueOffset(), value); + checkState(sizeLenInBytes == numBytes); + checkState(spaceNeeded == metaBytes + sizeLenInBytes); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); } - public void writeInt64(final int ignored, final long value) { - this.buffer.writeLongLE(value); + /** + * Copies the content of the buffer into the target stream. + */ + public void WriteTo(OutputStream stream) { + stream.Write(this.buffer.Slice(0, this.length())); } public void WriteTypedArray(Reference edit, LayoutScope scopeType, TypeArgumentList typeArgs, @@ -1794,7 +1252,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); + this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); checkState(spaceNeeded == metaBytes + numBytes); this.WriteUInt32(edit.get().valueOffset(), 0); int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size @@ -1823,7 +1281,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); + this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); checkState(spaceNeeded == metaBytes + numBytes); this.WriteUInt32(edit.get().valueOffset(), 0); int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size @@ -1852,7 +1310,7 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); + this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); checkState(spaceNeeded == metaBytes + numBytes); this.WriteUInt32(edit.get().valueOffset(), 0); int valueOffset = edit.get().valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size @@ -1881,8 +1339,8 @@ public final class RowBuffer { shift = tempOut_shift.get(); spaceNeeded = tempOut_spaceNeeded.get(); metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); - int numWritten = this.WriteDefaultValue(edit.get().valueOffset(), scopeType, typeArgs.clone()); + this.writeSparseMetadata(edit, scopeType, typeArgs.clone(), metaBytes); + int numWritten = this.writeDefaultValue(edit.get().valueOffset(), scopeType, typeArgs.clone()); checkState(numBytes == numWritten); checkState(spaceNeeded == metaBytes + numBytes); newScope.setAndGet(new RowCursor()); @@ -1901,153 +1359,6 @@ public final class RowBuffer { this = tempReference_this.get(); } - public void WriteUnixDateTime(int offset, UnixDateTime value) { - Reference tempReference_value = - new Reference(value); - MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value); - value = tempReference_value.get(); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal void WriteVariableBinary(int offset, ReadOnlySpan value, bool exists, out int shift) - public void WriteVariableBinary(int offset, ReadOnlySpan value, boolean exists, - Out shift) { - int numBytes = value.Length; - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift); - spaceNeeded = tempOut_spaceNeeded.get(); - - int sizeLenInBytes = this.WriteBinary(offset, value); - checkState(spaceNeeded == numBytes + sizeLenInBytes); - this.length(this.length() + shift.get()); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: internal void WriteVariableBinary(int offset, ReadOnlySequence value, bool exists, out int - // shift) - public void WriteVariableBinary(int offset, ReadOnlySequence value, boolean exists, - Out shift) { - int numBytes = (int)value.Length; - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift); - spaceNeeded = tempOut_spaceNeeded.get(); - - int sizeLenInBytes = this.WriteBinary(offset, value); - checkState(spaceNeeded == numBytes + sizeLenInBytes); - this.length(this.length() + shift.get()); - } - - public RowBuffer clone() { - RowBuffer varCopy = new RowBuffer(); - - varCopy.allocator = this.allocator; - varCopy.buffer = this.buffer; - varCopy.resolver = this.resolver; - varCopy.length(this.length()); - - return varCopy; - } - - /** - * Delete the sparse field at the indicated path. - * - * @param edit The field to delete. - */ - public void deleteSparse(RowCursor edit) { - // If the field doesn't exist, then nothing to do. - if (!edit.exists()) { - return; - } - - int numBytes = 0; - int _; - Out tempOut__ = new Out(); - int _; - Out tempOut__2 = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.EnsureSparse(edit, edit.get().cellType(), edit.get().cellTypeArgs().clone(), numBytes, - RowOptions.Delete, tempOut__, tempOut__2, tempOut_shift); - shift = tempOut_shift.get(); - _ = tempOut__2.get(); - _ = tempOut__.get(); - this.length(this.length() + shift); - } - - /** - * Copies the content of the buffer into the target stream. - */ - public void WriteTo(OutputStream stream) { - stream.Write(this.buffer.Slice(0, this.length())); - } - - /** - * The root header for the row. - */ - public HybridRowHeader header() { - return this.readHeader(); - } - - /** - * Compute the byte offset from the beginning of the row for a given variable column's value. - * - * @param layout The (optional) layout of the current scope. - * @param scopeOffset The 0-based offset to the beginning of the scope's value. - * @param varIndex The 0-based index of the variable column within the variable segment. - * @return The byte offset from the beginning of the row where the variable column's value should be - * located. - */ - public int computeVariableValueOffset(Layout layout, int scopeOffset, int varIndex) { - if (layout == null) { - return scopeOffset; - } - - int index = layout.numFixed() + varIndex; - ReadOnlySpan columns = layout.columns(); - checkState(index <= columns.Length); - int offset = scopeOffset + layout.size(); - for (int i = layout.numFixed(); i < index; i++) { - LayoutColumn col = columns[i]; - if (this.readBit(scopeOffset, col.getNullBit().clone())) { - int lengthSizeInBytes; - Out tempOut_lengthSizeInBytes = new Out(); - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: ulong valueSizeInBytes = this.Read7BitEncodedUInt(offset, out int lengthSizeInBytes); - long valueSizeInBytes = this.read7BitEncodedUInt(offset, tempOut_lengthSizeInBytes); - lengthSizeInBytes = tempOut_lengthSizeInBytes.get(); - if (col.type().getIsVarint()) { - offset += lengthSizeInBytes; - } else { - offset += (int) valueSizeInBytes + lengthSizeInBytes; - } - } - } - - return offset; - } - - public HybridRowHeader readHeader() { - HybridRowVersion version = HybridRowVersion.from(this.buffer.readByte()); - SchemaId schemaId = SchemaId.from(this.buffer.readIntLE()); - return new HybridRowHeader(version, schemaId); - } - - /** - * The length of this {@link RowBuffer} in bytes. - */ - public int length() { - return this.buffer.readerIndex() + this.buffer.readableBytes(); - } - - /** - * The resolver for UDTs. - */ - public LayoutResolver resolver() { - return this.resolver; - } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: internal void WriteUInt16(int offset, ushort value) public void WriteUInt16(int offset, short value) { @@ -2086,11 +1397,417 @@ public final class RowBuffer { this.buffer[offset] = value; } + public void WriteVariableInt(int offset, long value, boolean exists, Out shift) { + int numBytes = RowBuffer.Count7BitEncodedInt(value); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + this.EnsureVariable(offset, true, numBytes, exists, tempOut_spaceNeeded, shift); + spaceNeeded = tempOut_spaceNeeded.get(); + + int sizeLenInBytes = this.write7BitEncodedInt(offset, value); + checkState(sizeLenInBytes == numBytes); + checkState(spaceNeeded == numBytes); + this.length(this.length() + shift.get()); + } + + public void WriteVariableString(int offset, Utf8Span value, boolean exists, Out shift) { + int numBytes = value.Length; + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift); + spaceNeeded = tempOut_spaceNeeded.get(); + + int sizeLenInBytes = this.writeString(offset, value); + checkState(spaceNeeded == numBytes + sizeLenInBytes); + this.length(this.length() + shift.get()); + } + + public void WriteUnixDateTime(int offset, UnixDateTime value) { + Reference tempReference_value = + new Reference(value); + MemoryMarshal.Write(this.buffer.Slice(offset), tempReference_value); + value = tempReference_value.get(); + } + + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal void WriteVariableBinary(int offset, ReadOnlySpan value, bool exists, out int shift) + public void WriteVariableBinary(int offset, ReadOnlySpan value, boolean exists, + Out shift) { + int numBytes = value.Length; + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift); + spaceNeeded = tempOut_spaceNeeded.get(); + + int sizeLenInBytes = this.WriteBinary(offset, value); + checkState(spaceNeeded == numBytes + sizeLenInBytes); + this.length(this.length() + shift.get()); + } + + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal void WriteVariableBinary(int offset, ReadOnlySequence value, bool exists, out int + // shift) + public void WriteVariableBinary(int offset, ReadOnlySequence value, boolean exists, + Out shift) { + int numBytes = (int)value.Length; + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift); + spaceNeeded = tempOut_spaceNeeded.get(); + + int sizeLenInBytes = this.WriteBinary(offset, value); + checkState(spaceNeeded == numBytes + sizeLenInBytes); + this.length(this.length() + shift.get()); + } + + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: internal void WriteVariableUInt(int offset, ulong value, bool exists, out int shift) + public void WriteVariableUInt(int offset, long value, boolean exists, Out shift) { + int numBytes = RowBuffer.count7BitEncodedUInt(value); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + this.EnsureVariable(offset, true, numBytes, exists, tempOut_spaceNeeded, shift); + spaceNeeded = tempOut_spaceNeeded.get(); + + int sizeLenInBytes = this.write7BitEncodedUInt(offset, value); + checkState(sizeLenInBytes == numBytes); + checkState(spaceNeeded == numBytes); + this.length(this.length() + shift.get()); + } + + /** + * Compute the number of bytes necessary to store the unsigned 32-bit integer value using the varuint encoding + * + * @param value The value to be encoded + * @return The number of bytes needed to store the varuint encoding of {@code value} + */ + public static int count7BitEncodedUInt(long value) { + checkArgument(0 <= value && value <= 0x00000000FFFFFFFFL, "value: %s", value); + int i = 0; + while (value >= 0x80L) { + i++; + value >>>= 7; + } + i++; + return i; + } + + public void decrementUInt32(int offset, long decrement) { + long value = this.buffer.getUnsignedIntLE(offset); + this.buffer.setIntLE(offset, (int) (value - decrement)); + } + + /** + * Compute the byte offset from the beginning of the row for a given variable column's value. + * + * @param layout The (optional) layout of the current scope. + * @param scopeOffset The 0-based offset to the beginning of the scope's value. + * @param varIndex The 0-based index of the variable column within the variable segment. + * @return The byte offset from the beginning of the row where the variable column's value should be + * located. + */ + public int computeVariableValueOffset(Layout layout, int scopeOffset, int varIndex) { + if (layout == null) { + return scopeOffset; + } + + int index = layout.numFixed() + varIndex; + ReadOnlySpan columns = layout.columns(); + checkState(index <= columns.Length); + int offset = scopeOffset + layout.size(); + for (int i = layout.numFixed(); i < index; i++) { + LayoutColumn col = columns[i]; + if (this.readBit(scopeOffset, col.getNullBit().clone())) { + int lengthSizeInBytes; + Out tempOut_lengthSizeInBytes = new Out(); + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: ulong valueSizeInBytes = this.Read7BitEncodedUInt(offset, out int lengthSizeInBytes); + long valueSizeInBytes = this.read7BitEncodedUInt(offset, tempOut_lengthSizeInBytes); + lengthSizeInBytes = tempOut_lengthSizeInBytes.get(); + if (col.type().getIsVarint()) { + offset += lengthSizeInBytes; + } else { + offset += (int) valueSizeInBytes + lengthSizeInBytes; + } + } + } + + return offset; + } + + /** + * Delete the sparse field at the indicated path. + * + * @param edit The field to delete. + */ + public void deleteSparse(RowCursor edit) { + // If the field doesn't exist, then nothing to do. + if (!edit.exists()) { + return; + } + + int numBytes = 0; + int _; + Out tempOut__ = new Out(); + int _; + Out tempOut__2 = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.EnsureSparse(edit, edit.get().cellType(), edit.get().cellTypeArgs().clone(), numBytes, + RowOptions.Delete, tempOut__, tempOut__2, tempOut_shift); + shift = tempOut_shift.get(); + _ = tempOut__2.get(); + _ = tempOut__.get(); + this.length(this.length() + shift); + } + + public void deleteVariable(int offset, boolean isVarint) { + + int start = this.buffer.readerIndex(); + this.read7BitEncodedUInt(); + + ByteBuf remainder = this.buffer.slice(this.buffer.readerIndex(), this.buffer.readableBytes()); + this.buffer.readerIndex(start); + this.buffer.setBytes(start, remainder); + this.buffer.writerIndex(start + remainder.readableBytes()); + } + + /** + * The root header for the row. + */ + public HybridRowHeader header() { + return this.readHeader(); + } + + public void incrementUInt32(final int offset, final long increment) { + final long value = this.buffer.getUnsignedIntLE(offset); + this.buffer.setIntLE(offset, (int) (value + increment)); + } + + /** + * Initializes a row to the minimal size for the given layout. + * + * @param version The version of the Hybrid Row format to use for encoding this row. + * @param layout The layout that describes the column layout of the row. + * @param resolver The resolver for UDTs. + *

+ * The row is initialized to default row for the given layout. All fixed columns have their + * default values. All variable columns are null. No sparse columns are present. The row is + * valid. + */ + public void initLayout(HybridRowVersion version, Layout layout, LayoutResolver resolver) { + + checkNotNull(version, "version"); + checkNotNull(layout, "layout"); + checkNotNull(resolver, "resolver"); + + this.writeHeader(new HybridRowHeader(version, layout.schemaId())); + this.buffer.writeZero(layout.size()); + this.resolver = resolver; + } + + /** + * The length of this {@link RowBuffer} in bytes. + */ + public int length() { + return this.buffer.readerIndex() + this.buffer.readableBytes(); + } + + /** + * Compute the byte offsets from the beginning of the row for a given sparse field insertion + * into a set/map. + * + * @param scope The sparse scope to insert into. + * @param srcEdit The field to move into the set/map. + * @return The prepared edit context. + */ + @Nonnull + public RowCursor prepareSparseMove(@Nonnull final RowCursor scope, @Nonnull final RowCursor srcEdit) { + + checkNotNull(srcEdit); + checkNotNull(scope); + checkArgument(scope.index() == 0); + checkArgument(scope.scopeType().isUniqueScope()); + + RowCursor dstEdit = scope.clone().metaOffset(scope.valueOffset()); + int srcSize = this.sparseComputeSize(srcEdit); + int srcBytes = srcSize - (srcEdit.valueOffset() - srcEdit.metaOffset()); + + while (dstEdit.index() < dstEdit.count()) { + + this.readSparseMetadata(dstEdit); + checkState(dstEdit.pathOffset() == 0); + + int elmSize = -1; // defer calculating the full size until needed + int cmp; + + if (scope.scopeType() instanceof LayoutTypedMap) { + cmp = this.CompareKeyValueFieldValue(srcEdit, dstEdit); + } else { + elmSize = this.sparseComputeSize(dstEdit); + int elmBytes = elmSize - (dstEdit.valueOffset() - dstEdit.metaOffset()); + cmp = this.CompareFieldValue(srcEdit, srcBytes, dstEdit, elmBytes); + } + + if (cmp <= 0) { + dstEdit.exists(cmp == 0); + return dstEdit; + } + + elmSize = elmSize == -1 ? this.sparseComputeSize(dstEdit) : elmSize; + dstEdit.index(dstEdit.index() + 1); + dstEdit.metaOffset(dstEdit.metaOffset() + elmSize); + } + + dstEdit.exists(false); + dstEdit.cellType(LayoutTypes.END_SCOPE); + dstEdit.valueOffset(dstEdit.metaOffset()); + + return dstEdit; + } + + public long read7BitEncodedInt(int offset, Out lengthInBytes) { + return RowBuffer.rotateSignToMsb(this.read7BitEncodedUInt(offset, lengthInBytes)); + } + + public long read7BitEncodedUInt(int offset, Out lengthInBytes) { + return this.read(this::read7BitEncodedUInt, offset, lengthInBytes); + } + + public boolean readBit(int offset, LayoutBit bit) { + + if (bit.isInvalid()) { + return true; + } + + // TODO: C# TO JAVA CONVERTER: There is no Java equivalent to 'unchecked' in this context: + //ORIGINAL LINE: return (this.buffer[bit.GetOffset(offset)] & unchecked((byte)(1 << bit.GetBit()))) != 0; + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + return (this.buffer[bit.offset(offset)] & (byte) (1 << bit.bit())) != 0; + } + + /** + * Reads in the contents of the current {@link RowBuffer} from an {@link InputStream} + *

+ * The {@link RowBuffer} is initialized with the associated layout and row {@code version}. + * + * @param inputStream the stream from which the contents of the current {@link RowBuffer} should be read + * @param byteCount the number of bytes to be read from the {@code inputStream} + * @param version the {@link HybridRowVersion} to be assigned to the current {@link RowBuffer} + * @param resolver the layout resolver to be used in parsing the {@code inputStream} + * @return {@code true} if the read succeeded; otherwise, if the {@link InputStream} was corrupted, {@code false} + */ + public boolean readFrom( + @Nonnull final InputStream inputStream, final int byteCount, @Nonnull final HybridRowVersion version, + @Nonnull final LayoutResolver resolver) { + + checkNotNull(inputStream, "expected non-null inputStream"); + checkNotNull(resolver, "expected non-null resolver"); + checkNotNull(version, "expected non-null version"); + checkState(byteCount >= HybridRowHeader.SIZE, "expected byteCount >= %s, not %s", HybridRowHeader.SIZE, + byteCount); + + this.reset(); + this.ensure(byteCount); + this.resolver = resolver; + + final int bytesRead; + + try { + bytesRead = this.buffer.writeBytes(inputStream, byteCount); + } catch (IOException error) { + return false; + } + + if (bytesRead != byteCount) { + return false; + } + + return this.validateHeader(version); + } + + /** + * Reads the contents of the current {@link RowBuffer} from a {@link ByteBuf} + *

+ * The {@link RowBuffer} is initialized with a copy of the specified input {@link ByteBuf} and the associated layout + * and row {@code version}. + * + * @param input the buffer from which the contents of the current {@link RowBuffer} should be read + * @param version the {@link HybridRowVersion} to be assigned to the current {@link RowBuffer} + * @param resolver the layout resolver to be used in parsing the {@code inputStream} + * @return {@code true} if the read succeeded; otherwise, if the {@link InputStream} was corrupted, {@code false} + */ + public boolean readFrom( + @Nonnull final ByteBuf input, @Nonnull final HybridRowVersion version, @Nonnull final LayoutResolver resolver) { + + checkNotNull(input); + checkNotNull(version); + checkNotNull(resolver); + checkState(input.readableBytes() >= HybridRowHeader.SIZE); + + this.reset(); + this.resolver = resolver; + this.buffer.writeBytes(this.buffer); + + return this.validateHeader(version); + } + + public HybridRowHeader readHeader() { + HybridRowVersion version = HybridRowVersion.from(this.buffer.readByte()); + SchemaId schemaId = SchemaId.from(this.buffer.readIntLE()); + return new HybridRowHeader(version, schemaId); + } + + public long readInt64(int offset) { + return MemoryMarshal.Read(this.buffer.Slice(offset)); + } + + public byte readInt8(int offset, Out lengthInBytes) { + return this.read(this.buffer::readByte, offset, lengthInBytes); + } + + public double readSparseFloat64(RowCursor edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutTypes.FLOAT_64); + edit.endOffset(edit.valueOffset() + (Double.SIZE / Byte.SIZE)); + return this.ReadFloat64(edit.valueOffset()); + } + + public UUID readSparseGuid(RowCursor edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutTypes.GUID); + edit.endOffset(edit.valueOffset() + 16); + return this.readGuid(edit.valueOffset()); + } + + public short readSparseInt16(RowCursor edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutTypes.INT_16); + edit.endOffset(edit.valueOffset() + (Short.SIZE / Byte.SIZE)); + return this.ReadInt16(edit.valueOffset()); + } + + public int readSparseInt32(RowCursor edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutTypes.INT_32); + edit.endOffset(edit.valueOffset() + (Integer.SIZE / Byte.SIZE)); + return this.ReadInt32(edit.valueOffset()); + } + + public long readSparseInt64(RowCursor edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutTypes.INT_64); + edit.endOffset(edit.valueOffset() + (Long.SIZE / Byte.SIZE)); + return this.readInt64(edit.valueOffset()); + } + + public byte readSparseInt8(RowCursor edit) { + // TODO: Remove calls to ReadSparsePrimitiveTypeCode once moved to V2 read. + this.readSparsePrimitiveTypeCode(edit, LayoutTypes.INT_8); + edit.endOffset(edit.valueOffset() + (Byte.SIZE / Byte.SIZE)); + return this.readInt8(edit.valueOffset()); + } + public NullValue readSparseNull(@Nonnull RowCursor edit) { checkNotNull(edit); - this.readSparsePrimitiveTypeCode(edit, LayoutTypes.Null); + this.readSparsePrimitiveTypeCode(edit, LayoutTypes.NULL); edit.endOffset(edit.valueOffset()); return NullValue.Default; @@ -2108,53 +1825,89 @@ public final class RowBuffer { return Utf8String.unsafeFromUtf8BytesNoValidation(this.buffer.Slice(edit.pathOffset(), numBytes)); } - public long readSparseVarUInt(RowCursor edit) { - this.readSparsePrimitiveTypeCode(edit, LayoutTypes.VarUInt); - int sizeLenInBytes; - Out tempOut_sizeLenInBytes = new Out(); - long value = this.read7BitEncodedUInt(edit.valueOffset(), tempOut_sizeLenInBytes); - sizeLenInBytes = tempOut_sizeLenInBytes.get(); - edit.endOffset(edit.valueOffset() + sizeLenInBytes); + public int readSparsePathLen( + @Nonnull final Layout layout, final int offset, @Nonnull final Out pathLenInBytes, + @Nonnull final Out pathOffset) { + final int start = this.buffer.readerIndex(); + final int token = (int) this.read7BitEncodedUInt(); + final int end = this.buffer.readerIndex(); + + if (token < layout.tokenizer().count()) { + pathLenInBytes.set(end - start); + pathOffset.set(start); + return token; + } + + final int numBytes = token - layout.tokenizer().count(); + pathLenInBytes.set(numBytes + (end - start)); + pathOffset.set(end); + return token; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal LayoutType ReadSparseTypeCode(int + // offset) + public LayoutType readSparseTypeCode(int offset) { + return LayoutType.FromCode(LayoutCode.forValue(this.ReadUInt8(offset))); + } + + public long readSparseVarUInt(RowCursor edit) { + this.readSparsePrimitiveTypeCode(edit, LayoutTypes.VAR_UINT); + int start = this.buffer.readerIndex(); + long value = this.read7BitEncodedUInt(); + edit.endOffset(edit.valueOffset() + (this.buffer.readerIndex() - start)); return value; } - public void writeInt8(final int ignored, final byte value) { - this.buffer.writeByte(value); + /** + * Clears all content from the row. The row is empty after this method. + */ + public void reset() { + this.buffer.clear(); + this.resolver = null; } - public void WriteVariableString(int offset, Utf8Span value, boolean exists, Out shift) { - int numBytes = value.Length; - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - this.EnsureVariable(offset, false, numBytes, exists, tempOut_spaceNeeded, shift); - spaceNeeded = tempOut_spaceNeeded.get(); - - int sizeLenInBytes = this.WriteString(offset, value); - checkState(spaceNeeded == numBytes + sizeLenInBytes); - this.length(this.length() + shift.get()); + /** + * The resolver for UDTs. + */ + public LayoutResolver resolver() { + return this.resolver; } - public void writeSparseFloat32(@Nonnull RowCursor edit, float value, @Nonnull UpdateOptions options) { + /** + * Rotates the sign bit of a two's complement value to the least significant bit + * + * @param value A signed value. + * @return An unsigned value encoding the same value but with the sign bit in the LSB. + *

+ * Moves the signed bit of a two's complement value to the least significant bit (LSB) by: + * + * + * If negative, take the two's complement. + * + * Left shift the value by 1 bit. + * + * If negative, set the LSB to 1. + * + * + */ + public static long rotateSignToLsb(long value) { + boolean isNegative = value < 0; + long unsignedValue = value; + unsignedValue = isNegative ? ((~unsignedValue + 1) << 1) + 1 : unsignedValue << 1; + return unsignedValue; + } - int numBytes = (Float.SIZE / Byte.SIZE); - int metaBytes; - - Out tempOut_metaBytes = new Out(); - int spaceNeeded; - Out tempOut_spaceNeeded = new Out(); - int shift; - Out tempOut_shift = new Out(); - this.ensureSparse(edit, LayoutTypes.FLOAT_32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, - tempOut_spaceNeeded, tempOut_shift); - shift = tempOut_shift.get(); - spaceNeeded = tempOut_spaceNeeded.get(); - metaBytes = tempOut_metaBytes.get(); - this.WriteSparseMetadata(edit, LayoutType.Float32, TypeArgumentList.EMPTY, metaBytes); - this.WriteFloat32(edit.get().valueOffset(), value); - checkState(spaceNeeded == metaBytes + (Float.SIZE / Byte.SIZE)); - edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; - this.length(this.length() + shift); + /** + * Undoes the rotation introduced by {@link #rotateSignToLsb}. + * + * @param unsignedValue An unsigned value with the sign bit in the LSB. + * @return A signed two's complement value encoding the same value. + */ + public static long rotateSignToMsb(long unsignedValue) { + boolean isNegative = unsignedValue % 2 != 0; + return isNegative ? (~(unsignedValue >>> 1) + 1) | 0x8000000000000000L : unsignedValue >>> 1; } /** @@ -2215,12 +1968,239 @@ public final class RowBuffer { } } - edit.cellType(LayoutTypes.EndScope); + edit.cellType(LayoutTypes.END_SCOPE); edit.exists(false); edit.valueOffset(edit.metaOffset()); return false; } + /** + * Produce a new scope from the current iterator position. + * + * @param edit An initialized iterator pointing at a scope. + * @param immutable True if the new scope should be marked immutable (read-only). + * @return A new scope beginning at the current iterator position. + */ + public RowCursor sparseIteratorReadScope(RowCursor edit, boolean immutable) { + + LayoutScope scopeType = edit.cellType() instanceof LayoutScope ? (LayoutScope) edit.cellType() : null; + + if (scopeType instanceof LayoutObject || scopeType instanceof LayoutArray) { + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.cellTypeArgs()) + .start(edit.valueOffset()) + .valueOffset(edit.valueOffset()) + .metaOffset(edit.valueOffset()) + .layout(edit.layout()) + .immutable(immutable); + } + + if (scopeType instanceof LayoutTypedArray || scopeType instanceof LayoutTypedSet || scopeType instanceof LayoutTypedMap) { + + final int valueOffset = edit.valueOffset() + (Integer.SIZE / Byte.SIZE); // Point after the Size + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.cellTypeArgs()) + .start(edit.valueOffset()) + .valueOffset(valueOffset) + .metaOffset(valueOffset) + .layout(edit.layout()) + .immutable(immutable) + .count(this.ReadUInt32(edit.valueOffset())); + } + + if (scopeType instanceof LayoutTypedTuple || scopeType instanceof LayoutTuple || scopeType instanceof LayoutTagged || scopeType instanceof LayoutTagged2) { + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.cellTypeArgs()) + .start(edit.valueOffset()) + .valueOffset(edit.valueOffset()) + .metaOffset(edit.valueOffset()) + .layout(edit.layout()) + .immutable(immutable) + .count(edit.cellTypeArgs().count()); + } + + if (scopeType instanceof LayoutNullable) { + + boolean hasValue = this.readInt8(edit.valueOffset()) != 0; + + if (hasValue) { + + // Start at the T so it can be read. + final int valueOffset = edit.valueOffset() + 1; + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.cellTypeArgs()) + .start(edit.valueOffset()) + .valueOffset(valueOffset) + .metaOffset(valueOffset) + .layout(edit.layout()) + .immutable(immutable) + .count(2) + .index(1); + } else { + + // Start at the end of the scope, instead of at the T, so the T will be skipped. + final TypeArgument typeArg = edit.cellTypeArgs().get(0); + final int valueOffset = edit.valueOffset() + 1 + this.countDefaultValue(typeArg.type(), + typeArg.typeArgs()); + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.cellTypeArgs()) + .start(edit.valueOffset()) + .valueOffset(valueOffset) + .metaOffset(valueOffset) + .layout(edit.layout()) + .immutable(immutable) + .count(2) + .index(2); + } + } + + if (scopeType instanceof LayoutUDT) { + + final Layout udt = this.resolver.resolve(edit.cellTypeArgs().schemaId()); + final int valueOffset = this.computeVariableValueOffset(udt, edit.valueOffset(), udt.numVariable()); + + return new RowCursor() + .scopeType(scopeType) + .scopeTypeArgs(edit.cellTypeArgs()) + .start(edit.valueOffset()) + .valueOffset(valueOffset) + .metaOffset(valueOffset) + .layout(udt) + .immutable(immutable); + } + + throw new IllegalStateException(lenientFormat("Not a scope type: %s", scopeType)); + } + + public int write7BitEncodedInt(int offset, long value) { + return this.write7BitEncodedUInt(offset, RowBuffer.rotateSignToLsb(value)); + } + + /** + * Sets the specified 64-bit integer at the current {@link RowBuffer position} as a 7-bit encoded 32-bit value + *

+ * The 64-bit integer value is written 7-bits at a time. The high bit of the byte, when set, indicates there are + * more bytes. An {@link IllegalArgumentException} is thrown, if the specified 64-bit integer value is outside + * the range of an unsigned 32-bit integer, [0, 0x00000000FFFFFFFFL]. + * + * @param ignored + * @param value a 64-bit integer constrained to the range of an unsigned 32-bit integer, [0, 0x00000000FFFFFFFFL] + * @return The number of bytes written + */ + public int write7BitEncodedUInt(final int ignored, final long value) { + checkArgument(0 <= value && value <= 0x00000000FFFFFFFFL); + long n = value; + int i = 0; + while (n >= 0x80L) { + this.buffer.writeByte((byte) (n | 0x80L)); + n >>>= 7; + } + this.buffer.writeByte((byte) n); + return i; + } + + public void writeFloat128(int offset, Float128 value) { + this.buffer.writeLongLE(value.low()); + this.buffer.writeLongLE(value.high()); + } + + public void writeHeader(HybridRowHeader value) { + this.buffer.writeByte(value.version().value()); + this.buffer.writeIntLE(value.schemaId().value()); + } + + public void writeInt16(final int ignored, final short value) { + this.buffer.writeShortLE(value); + } + + public void writeInt32(final int ignored, final int value) { + this.buffer.writeIntLE(value); + } + + public void writeInt64(final int ignored, final long value) { + this.buffer.writeLongLE(value); + } + + public void writeInt8(final int ignored, final byte value) { + this.buffer.writeByte(value); + } + + public void writeSparseArray( + @Nonnull final RowCursor edit, @Nonnull final LayoutScope scopeType, @Nonnull final UpdateOptions options, + @Nonnull final Out newScope) { + + checkNotNull(edit); + checkNotNull(scopeType); + checkNotNull(options); + checkNotNull(newScope); + + int numBytes = (LayoutCode.SIZE / Byte.SIZE); // end scope type code + TypeArgumentList typeArgs = TypeArgumentList.EMPTY; + int metaBytes; + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + + this.ensureSparse(edit, scopeType, typeArgs, numBytes, options, tempOut_metaBytes, tempOut_spaceNeeded, + tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, scopeType, typeArgs, metaBytes); + this.writeSparseTypeCode(edit.valueOffset(), LayoutCode.END_SCOPE); + checkState(spaceNeeded == metaBytes + numBytes); + + newScope.setAndGet(new RowCursor()) + .scopeType(scopeType) + .scopeTypeArgs(typeArgs) + .start(edit.valueOffset()) + .valueOffset(edit.valueOffset()) + .metaOffset(edit.valueOffset()) + .layout(edit.layout()); + } + + public void writeSparseFloat32(@Nonnull RowCursor edit, float value, @Nonnull UpdateOptions options) { + + int numBytes = (Float.SIZE / Byte.SIZE); + int metaBytes; + + Out tempOut_metaBytes = new Out(); + int spaceNeeded; + Out tempOut_spaceNeeded = new Out(); + int shift; + Out tempOut_shift = new Out(); + this.ensureSparse(edit, LayoutTypes.FLOAT_32, TypeArgumentList.EMPTY, numBytes, options, tempOut_metaBytes, + tempOut_spaceNeeded, tempOut_shift); + shift = tempOut_shift.get(); + spaceNeeded = tempOut_spaceNeeded.get(); + metaBytes = tempOut_metaBytes.get(); + this.writeSparseMetadata(edit, LayoutType.Float32, TypeArgumentList.EMPTY, metaBytes); + this.WriteFloat32(edit.get().valueOffset(), value); + checkState(spaceNeeded == metaBytes + (Float.SIZE / Byte.SIZE)); + edit.get().endOffset = edit.get().metaOffset() + spaceNeeded; + this.length(this.length() + shift); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [MethodImpl(MethodImplOptions.AggressiveInlining)] internal void WriteSparseTypeCode(int offset, + // LayoutCode code) + public void writeSparseTypeCode(int offset, LayoutCode code) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: this.WriteUInt8(offset, (byte)code); + this.WriteUInt8(offset, (byte) code.value()); + } + /** * Compares the values of two encoded fields using the hybrid row binary collation. * @@ -2242,7 +2222,8 @@ public final class RowBuffer { //ORIGINAL LINE: [SuppressMessage("Microsoft.StyleCop.CSharp.OrderingRules", "SA1201", Justification = "Logical // Grouping.")] private int CompareFieldValue(RowCursor left, int leftLen, RowCursor right, int rightLen) private int CompareFieldValue(RowCursor left, int leftLen, RowCursor right, int rightLen) { - if (left.cellType().LayoutCode.getValue() < right.cellType().LayoutCode.getValue()) { + + if (left.cellType().layoutCode().value() < right.cellType().layoutCode().value()) { return -1; } @@ -2326,39 +2307,15 @@ public final class RowBuffer { } /** - * Compute the number of bytes necessary to store the signed integer using the varint - * encoding. + * Compute the number of bytes necessary to store the signed integer using the varint encoding. * - * @param value The value to be encoded. - * @return The number of bytes needed to store the varint encoding of {@link value}. + * @param value The value to be encoded + * @return The number of bytes needed to store the varint encoding of {@code value} */ private static int Count7BitEncodedInt(long value) { return RowBuffer.count7BitEncodedUInt(RowBuffer.rotateSignToLsb(value)); } - private static int CountSparsePath(Reference edit) { - - if (!edit.get().writePathToken().isNull()) { - return edit.get().writePathToken().varint().length; - } - - Optional token = edit.get().layout().tokenizer().findToken(edit.get().writePath()); - - if (token.isPresent()) { - edit.get().writePathToken(token.get()); - return token.get().varint().length; - } - - int numBytes = edit.get().writePath().toUtf8().length(); - int sizeLenInBytes = RowBuffer.count7BitEncodedUInt((long) (edit.get().layout().tokenizer().count() + numBytes)); - - return sizeLenInBytes + numBytes; - } - - private void ensure(int size) { - this.buffer.ensureWritable(size); - } - private void EnsureVariable(int offset, boolean isVarint, int numBytes, boolean exists, Out spaceNeeded, Out shift) { int spaceAvailable = 0; @@ -2389,39 +2346,6 @@ public final class RowBuffer { } } - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: private int WriteBinary(int offset, ReadOnlySpan value) - private int WriteBinary(int offset, ReadOnlySpan value) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length); - int sizeLenInBytes = this.write7BitEncodedUInt(offset, (long) value.Length); - value.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); - return sizeLenInBytes; - } - - /** - * Reads in the contents of the RowBuffer from an input stream and initializes the row buffer - * with the associated layout and rowVersion. - * - * @return true if the serialization succeeded. false if the input stream was corrupted. - */ - private boolean InitReadFrom(HybridRowVersion rowVersion) { - HybridRowHeader header = this.readHeader(0).clone(); - Layout layout = this.resolver.resolve(header.schemaId().clone()); - checkState(SchemaId.opEquals(header.schemaId().clone(), layout.schemaId().clone())); - return (header.getVersion() == rowVersion) && (HybridRowHeader.SIZE + layout.size() <= this.length()); - } - - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: private int WriteBinary(int offset, ReadOnlySequence value) - private int WriteBinary(int offset, ReadOnlySequence value) { - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length); - int sizeLenInBytes = this.write7BitEncodedUInt(offset, (long) value.Length); - value.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); - return sizeLenInBytes; - } - /** * Sorts the array structure using the hybrid row binary * collation. @@ -2503,293 +2427,28 @@ public final class RowBuffer { return this.buffer.Slice(offset + sizeLenInBytes.get(), numBytes); } - private int WriteDefaultValue(int offset, LayoutType code, TypeArgumentList typeArgs) { - // JTHTODO: convert to a virtual? - switch (code) { - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutNull _: - case LayoutNull - _: - this.writeSparseTypeCode(offset, code.LayoutCode); - return 1; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutBoolean _: - case LayoutBoolean - _: - this.writeSparseTypeCode(offset, LayoutCode.BOOLEAN_FALSE); - return 1; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutInt8 _: - case LayoutInt8 - _: - this.writeInt8(offset, (byte)0); - return LayoutType.Int8.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutInt16 _: - case LayoutInt16 - _: - this.writeInt16(offset, (short)0); - return LayoutType.Int16.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutInt32 _: - case LayoutInt32 - _: - this.writeInt32(offset, 0); - return LayoutType.Int32.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutInt64 _: - case LayoutInt64 - _: - this.writeInt64(offset, 0); - return LayoutType.Int64.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUInt8 _: - case LayoutUInt8 - _: - this.WriteUInt8(offset, (byte)0); - return LayoutType.UInt8.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUInt16 _: - case LayoutUInt16 - _: - this.WriteUInt16(offset, (short)0); - return LayoutType.UInt16.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUInt32 _: - case LayoutUInt32 - _: - this.WriteUInt32(offset, 0); - return LayoutType.UInt32.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUInt64 _: - case LayoutUInt64 - _: - this.WriteUInt64(offset, 0); - return LayoutType.UInt64.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutFloat32 _: - case LayoutFloat32 - _: - this.WriteFloat32(offset, 0); - return LayoutType.Float32.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutFloat64 _: - case LayoutFloat64 - _: - this.WriteFloat64(offset, 0); - return LayoutType.Float64.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutFloat128 _: - case LayoutFloat128 - _: - this.writeFloat128(offset, null); - return LayoutType.Float128.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutDecimal _: - case LayoutDecimal - _: - this.WriteDecimal(offset, 0); - return LayoutType.Decimal.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutDateTime _: - case LayoutDateTime - _: - this.WriteDateTime(offset, LocalDateTime.MIN); - return LayoutType.DateTime.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUnixDateTime _: - case LayoutUnixDateTime - _: - this.WriteUnixDateTime(offset, null); - return LayoutType.UnixDateTime.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutGuid _: - case LayoutGuid - _: - this.WriteGuid(offset, null); - return LayoutType.Guid.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutMongoDbObjectId _: - case LayoutMongoDbObjectId - _: - this.WriteMongoDbObjectId(offset, null); - return MongoDbObjectId.Size; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUtf8 _: - case LayoutUtf8 - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutBinary _: - case LayoutBinary _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutVarInt _: - case LayoutVarInt _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutVarUInt _: - case LayoutVarUInt _: - - // Variable length types preceded by their varuint size take 1 byte for a size of 0. - return this.write7BitEncodedUInt(offset, 0); - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutObject _: - case LayoutObject - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutArray _: - case LayoutArray _: - - // Variable length sparse collection scopes take 1 byte for the end-of-scope terminator. - this.writeSparseTypeCode(offset, LayoutCode.END_SCOPE); - return (LayoutCode.SIZE / Byte.SIZE); - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedArray _: - case LayoutTypedArray - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedSet _: - case LayoutTypedSet _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedMap _: - case LayoutTypedMap _: - - // Variable length typed collection scopes preceded by their scope size take sizeof(uint) for a size of 0. - this.WriteUInt32(offset, 0); - return (Integer.SIZE / Byte.SIZE); - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTuple _: - case LayoutTuple - _: - - // Fixed arity sparse collections take 1 byte for end-of-scope plus a null for each element. - for (int i = 0; i < typeArgs.count(); i++) { - this.writeSparseTypeCode(offset, LayoutCode.NULL); - } - - this.writeSparseTypeCode(offset, LayoutCode.END_SCOPE); - return (LayoutCode.SIZE / Byte.SIZE) + ((LayoutCode.SIZE / Byte.SIZE) * typeArgs.count()); - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTypedTuple _: - case LayoutTypedTuple - _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTagged _: - case LayoutTagged _: - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutTagged2 _: - case LayoutTagged2 _: - - // Fixed arity typed collections take the sum of the default values of each element. The scope size is implied by the arity. - int sum = 0; - for (TypeArgument arg : typeArgs) { - sum += this.WriteDefaultValue(offset + sum, arg.type(), arg.typeArgs().clone()); - } - - return sum; - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutNullable _: - case LayoutNullable - _: - - // Nullables take the default values of the value plus null. The scope size is implied by the arity. - this.writeInt8(offset, (byte)0); - return 1 + this.WriteDefaultValue(offset + 1, typeArgs.get(0).type(), typeArgs.get(0).typeArgs().clone()); - - // TODO: C# TO JAVA CONVERTER: Java has no equivalent to C# pattern variables in 'case' statements: - //ORIGINAL LINE: case LayoutUDT _: - case LayoutUDT - _: - - // Clear all presence bits. - Layout udt = this.resolver.resolve(typeArgs.schemaId().clone()); - this.buffer.Slice(offset, udt.getSize()).Fill(0); - - // Write scope terminator. - this.writeSparseTypeCode(offset + udt.getSize(), LayoutCode.END_SCOPE); - return udt.getSize() + (LayoutCode.SIZE / Byte.SIZE); - - default: - throw new IllegalStateException(lenientFormat("Not Implemented: %s", code)); - return 0; - } - } - - private void WriteSparseMetadata(Reference edit, LayoutType cellType, - TypeArgumentList typeArgs, int metaBytes) { - int metaOffset = edit.get().metaOffset(); - if (!edit.get().scopeType().hasImplicitTypeCode(edit)) { - Reference tempReference_this = - new Reference(this); - metaOffset += cellType.writeTypeArgument(tempReference_this, metaOffset, typeArgs.clone()); - this = tempReference_this.get(); - } - - this.WriteSparsePath(edit, metaOffset); - edit.get().valueOffset(edit.get().metaOffset() + metaBytes); - checkState(edit.get().valueOffset() == edit.get().metaOffset() + metaBytes); - } - private Utf8Span ReadString(int offset, Out sizeLenInBytes) { int numBytes = (int) this.read7BitEncodedUInt(offset, sizeLenInBytes); return Utf8Span.UnsafeFromUtf8BytesNoValidation(this.buffer.Slice(offset + sizeLenInBytes.get(), numBytes)); } - private void WriteSparsePath(Reference edit, int offset) { - // Some scopes don't encode paths, therefore the cost is always zero. - if (edit.get().scopeType().isIndexedScope()) { - edit.get().pathToken = 0; - edit.get().pathOffset = 0; - return; - } - - StringToken _; - Out tempOut__ = - new Out(); - checkState(!edit.get().layout().getTokenizer().TryFindToken(edit.get().writePath(), tempOut__) || !edit.get().writePathToken().isNull()); - _ = tempOut__.get(); - if (!edit.get().writePathToken().isNull()) { - edit.get().writePathToken().varint().CopyTo(this.buffer.Slice(offset)); - edit.get().pathToken = edit.get().intValue().writePathToken.Id; - edit.get().pathOffset = offset; - } else { - // TODO: It would be better if we could avoid allocating here when the path is UTF16. - Utf8Span span = edit.get().writePath().ToUtf8String(); - edit.get().pathToken = edit.get().layout().getTokenizer().getCount() + span.Length; - //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: - //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)edit.pathToken); - int sizeLenInBytes = this.write7BitEncodedUInt(offset, edit.get().longValue().pathToken); - edit.get().pathOffset = offset + sizeLenInBytes; - span.Span.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); - } - } - - private int WriteString(int offset, Utf8Span value) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: private int WriteBinary(int offset, ReadOnlySpan value) + private int WriteBinary(int offset, ReadOnlySpan value) { //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length); int sizeLenInBytes = this.write7BitEncodedUInt(offset, (long) value.Length); - value.Span.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); + value.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); + return sizeLenInBytes; + } + + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: private int WriteBinary(int offset, ReadOnlySequence value) + private int WriteBinary(int offset, ReadOnlySequence value) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length); + int sizeLenInBytes = this.write7BitEncodedUInt(offset, (long) value.Length); + value.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); return sizeLenInBytes; } @@ -2891,9 +2550,40 @@ public final class RowBuffer { throw new IllegalStateException(lenientFormat("Not Implemented: %s", code)); } + private static int countSparsePath(@Nonnull final RowCursor edit) { + + if (!edit.writePathToken().isNull()) { + StringToken token = edit.writePathToken(); + ByteBuf varint = token.varint(); + return varint.readerIndex() + varint.readableBytes(); + } + + Optional optional = edit.layout().tokenizer().findToken(edit.writePath()); + + if (optional.isPresent()) { + StringToken token = optional.get(); + edit.writePathToken(token); + ByteBuf varint = token.varint(); + return varint.readerIndex() + varint.readableBytes(); + } + + Utf8String path = edit.writePath().toUtf8(); + assert path != null; + + int numBytes = path.length(); + int sizeLenInBytes = RowBuffer.count7BitEncodedUInt((long) (edit.layout().tokenizer().count() + numBytes)); + + return sizeLenInBytes + numBytes; + } + + private void ensure(int size) { + this.buffer.ensureWritable(size); + } + /** * Ensure that sufficient space exists in the row buffer to write the current value. - * @param edit The prepared edit indicating where and in what context the current write will + * + * @param edit The prepared edit indicating where and in what context the current write will * happen. * @param cellType The type of the field to be written. * @param typeArgs The type arguments of the field to be written. @@ -2906,9 +2596,9 @@ public final class RowBuffer { * @param shift On success, the number of bytes the length of the row buffer was increased */ private void ensureSparse( - RowCursor edit, LayoutType cellType, TypeArgumentList typeArgs, int numBytes, RowOptions options, - Out metaBytes, Out spaceNeeded, Out shift - ) { + @Nonnull final RowCursor edit, @Nonnull final LayoutType cellType, @Nonnull final TypeArgumentList typeArgs, + final int numBytes, @Nonnull final RowOptions options, @Nonnull final Out metaBytes, + @Nonnull final Out spaceNeeded, @Nonnull final Out shift) { int metaOffset = edit.metaOffset(); int spaceAvailable = 0; @@ -2917,12 +2607,12 @@ public final class RowBuffer { if (edit.scopeType().hasImplicitTypeCode(edit)) { metaBytes.setAndGet(0); } else { - metaBytes.setAndGet(cellType.CountTypeArgument(typeArgs)); + metaBytes.setAndGet(cellType.countTypeArgument(typeArgs)); } if (!edit.scopeType().isIndexedScope()) { checkState(edit.writePath() != null); - int pathLenInBytes = RowBuffer.CountSparsePath(edit); + int pathLenInBytes = RowBuffer.countSparsePath(edit); metaBytes.setAndGet(metaBytes.get() + pathLenInBytes); } @@ -2952,12 +2642,12 @@ public final class RowBuffer { if ((options == RowOptions.Insert) || (options == RowOptions.InsertAt) || ((options == RowOptions.Upsert) && !edit.get().exists())) { // Add one to the current scope count. checkState(!edit.exists()); - this.IncrementUInt32(edit.start(), 1); + this.incrementUInt32(edit.start(), 1); edit.count(edit.count() + 1); } else if ((options == RowOptions.Delete) && edit.exists()) { // Subtract one from the current scope count. checkState(this.ReadUInt32(edit.start()) > 0); - this.DecrementUInt32(edit.start(), 1); + this.decrementUInt32(edit.start(), 1); edit.count(edit.count() - 1); } } @@ -2972,107 +2662,6 @@ public final class RowBuffer { edit.exists(true); } } - } - - /** - * Compute the size of a sparse (primitive) field. - * - * @param cellType The type of the current sparse field. - * @param metaOffset The 0-based offset from the beginning of the row where the field begins. - * @param valueOffset The 0-based offset from the beginning of the row where the field's value - * begins. - * @return The length (in bytes) of the encoded field including the metadata and the value. - */ - private int SparseComputePrimitiveSize(LayoutType cellType, int metaOffset, int valueOffset) { - // JTHTODO: convert to a virtual? - int metaBytes = valueOffset - metaOffset; - LayoutCode code = cellType.LayoutCode; - switch (code) { - case NULL: - checkState(LayoutType.Null.Size == 0); - return metaBytes; - - case BOOLEAN: - case BOOLEAN_FALSE: - checkState(LayoutType.Boolean.Size == 0); - return metaBytes; - - case INT_8: - return metaBytes + LayoutType.Int8.Size; - - case INT_16: - return metaBytes + LayoutType.Int16.Size; - - case INT_32: - return metaBytes + LayoutType.Int32.Size; - - case INT_64: - return metaBytes + LayoutType.Int64.Size; - - case UINT_8: - return metaBytes + LayoutType.UInt8.Size; - - case UINT_16: - return metaBytes + LayoutType.UInt16.Size; - - case UINT_32: - return metaBytes + LayoutType.UInt32.Size; - - case UINT_64: - return metaBytes + LayoutType.UInt64.Size; - - case FLOAT_32: - return metaBytes + LayoutType.Float32.Size; - - case FLOAT_64: - return metaBytes + LayoutType.Float64.Size; - - case FLOAT_128: - return metaBytes + LayoutType.Float128.Size; - - case DECIMAL: - return metaBytes + LayoutType.Decimal.Size; - - case DATE_TIME: - return metaBytes + LayoutType.DateTime.Size; - - case UNIX_DATE_TIME: - return metaBytes + LayoutType.UnixDateTime.Size; - - case GUID: - return metaBytes + LayoutType.Guid.Size; - - case MONGODB_OBJECT_ID: - return metaBytes + MongoDbObjectId.Size; - - case UTF_8: - case BINARY: - // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: - ///#pragma warning disable SA1137 // Elements should have the same indentation - { - int sizeLenInBytes; - Out tempOut_sizeLenInBytes = new Out(); - int numBytes = (int)this.read7BitEncodedUInt(metaOffset + metaBytes, tempOut_sizeLenInBytes); - sizeLenInBytes = tempOut_sizeLenInBytes.get(); - return metaBytes + sizeLenInBytes + numBytes; - } - - case VAR_INT: - case VAR_UINT: { - int sizeLenInBytes; - Out tempOut_sizeLenInBytes2 = new Out(); - this.read7BitEncodedUInt(metaOffset + metaBytes, tempOut_sizeLenInBytes2); - sizeLenInBytes = tempOut_sizeLenInBytes2.get(); - return metaBytes + sizeLenInBytes; - } - // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: - ///#pragma warning restore SA1137 // Elements should have the same indentation - - default: - throw new IllegalStateException(lenientFormat("Not Implemented: %s", code)); - return 0; - } - } /** * metaBytes, Out spaceNeeded, Out shift - ) { - this.ensureSparse(edit, cellType, typeArgs, numBytes, RowOptions.from(options.value()), metaBytes, spaceNeeded, shift); + @Nonnull final RowCursor edit, @Nonnull final LayoutType cellType, @Nonnull final TypeArgumentList typeArgs, + final int numBytes, @Nonnull final UpdateOptions options, @Nonnull final Out metaBytes, + @Nonnull final Out spaceNeeded, @Nonnull final Out shift) { + + checkNotNull(edit); + checkNotNull(cellType); + checkNotNull(typeArgs); + checkNotNull(options); + checkNotNull(metaBytes); + checkNotNull(spaceNeeded); + checkNotNull(shift); + + final RowOptions rowOptions = RowOptions.from(options.value()); + this.ensureSparse(edit, cellType, typeArgs, numBytes, rowOptions, metaBytes, spaceNeeded, shift); + } + + private T read(Supplier supplier, int offset, Out lengthInBytes) { + this.buffer.readerIndex(offset); + T value = supplier.get(); + lengthInBytes.set(this.buffer.readerIndex() - offset); + return value; + } + + private long read7BitEncodedUInt() { + + long b = this.buffer.readByte() & 0xFFL; + + if (b < 0x80L) { + return b; + } + + long result = b & 0x7FL; + int shift = 7; + + do { + checkState(shift < 10 * 7); + b = this.buffer.readByte() & 0xFFL; + result |= (b & 0x7FL) << shift; + shift += 7; + } while (b >= 0x80L); + + return result; } /** @@ -3112,72 +2739,31 @@ public final class RowBuffer { * undefined. * . */ - private void readSparseMetadata(Reference edit) { - if (edit.get().scopeType().hasImplicitTypeCode(edit)) { - edit.get().scopeType().SetImplicitTypeCode(edit); - edit.get().valueOffset(edit.get().metaOffset()); + private void readSparseMetadata(@Nonnull final RowCursor edit) { + + checkNotNull(edit); + + if (edit.scopeType().hasImplicitTypeCode(edit)) { + edit.scopeType().setImplicitTypeCode(edit); + edit.valueOffset(edit.metaOffset()); } else { - edit.get().cellType = this.readSparseTypeCode(edit.get().metaOffset()); - edit.get().valueOffset(edit.get().metaOffset() + (LayoutCode.SIZE / Byte.SIZE)); - edit.get().cellTypeArgs = TypeArgumentList.EMPTY; - if (edit.get().cellType() instanceof LayoutEndScope) { + edit.cellType(this.readSparseTypeCode(edit.metaOffset())); + edit.valueOffset(edit.metaOffset() + (LayoutCode.SIZE / Byte.SIZE)); + edit.cellTypeArgs(TypeArgumentList.EMPTY); + if (edit.cellType() instanceof LayoutEndScope) { // Reached end of current scope without finding another field. - edit.get().pathToken = 0; - edit.get().pathOffset = 0; - edit.get().valueOffset(edit.get().metaOffset()); + edit.pathToken(0); + edit.pathOffset(0); + edit.valueOffset(edit.metaOffset()); return; } - Reference tempReference_this = - new Reference(this); - int sizeLenInBytes; - Out tempOut_sizeLenInBytes = new Out(); - edit.get().cellTypeArgs = edit.get().cellType().readTypeArgumentList(tempReference_this, - edit.get().valueOffset(), tempOut_sizeLenInBytes).clone(); - sizeLenInBytes = tempOut_sizeLenInBytes.get(); - this = tempReference_this.get(); - edit.get().valueOffset(edit.get().valueOffset() + sizeLenInBytes); + Out sizeLenInBytes = new Out<>(); + edit.cellTypeArgs(edit.cellType().readTypeArgumentList(this, edit.valueOffset(), sizeLenInBytes)); + edit.valueOffset(edit.valueOffset() + sizeLenInBytes.get()); } - Reference tempReference_this2 = new Reference(this); - edit.get().scopeType().ReadSparsePath(tempReference_this2, edit); - this = tempReference_this2.get(); - } - - /** - * Skip over a nested scope. - * - * @param edit The sparse scope to search. - * @return The 0-based byte offset immediately following the scope end marker. - */ - private int skipScope(RowCursor edit) { - - while (this.sparseIteratorMoveNext(edit)) { - } - - if (!edit.scopeType().isSizedScope()) { - edit.metaOffset(edit.metaOffset() + (LayoutCode.SIZE / Byte.SIZE)); // Move past the end of - // scope marker. - } - - return edit.metaOffset(); - } - - /** - * Compute the size of a sparse field - * - * @param edit The edit structure describing the field to measure. - * @return The length (in bytes) of the encoded field including the metadata and the value. - */ - private int sparseComputeSize(RowCursor edit) { - - if (!(edit.cellType() instanceof LayoutScope)) { - return this.SparseComputePrimitiveSize(edit.cellType(), edit.metaOffset(), edit.valueOffset()); - } - - // Compute offset to end of value for current value - RowCursor newScope = this.sparseIteratorReadScope(edit, true); - return this.skipScope(newScope) - edit.metaOffset(); + edit.scopeType().readSparsePath(this, edit); } private void readSparsePrimitiveTypeCode(@Nonnull RowCursor edit, LayoutType code) { @@ -3201,9 +2787,9 @@ public final class RowBuffer { checkState(edit.scopeTypeArgs().get(0).typeArgs().count() == 0); } } else { - if (code == LayoutTypes.Boolean) { + if (code == LayoutTypes.BOOLEAN) { code = this.readSparseTypeCode(edit.metaOffset()); - checkState(code == LayoutTypes.Boolean || code == LayoutTypes.BooleanFalse); + checkState(code == LayoutTypes.BOOLEAN || code == LayoutTypes.BooleanFalse); } else { checkState(this.readSparseTypeCode(edit.metaOffset()) == code); } @@ -3215,72 +2801,429 @@ public final class RowBuffer { } else { Out pathLenInBytes = new Out<>(); Out pathOffset = new Out<>(); - int token = this.ReadSparsePathLen(edit.layout(), edit.metaOffset() + (LayoutCode.SIZE / Byte.SIZE), - pathLenInBytes, pathOffset); + int token = this.readSparsePathLen(edit.layout(), edit.metaOffset() + (LayoutCode.SIZE / Byte.SIZE), + pathLenInBytes, pathOffset); checkState(edit.pathOffset() == pathOffset.get()); checkState(edit.pathToken() == token); } } + /** + * Skip over a nested scope + * + * @param edit The sparse scope to search + * @return The 0-based byte offset immediately following the scope end marker + */ + private int skipScope(RowCursor edit) { + + //noinspection StatementWithEmptyBody + while (this.sparseIteratorMoveNext(edit)) { + } + + if (!edit.scopeType().isSizedScope()) { + edit.metaOffset(edit.metaOffset() + (LayoutCode.SIZE / Byte.SIZE)); // move past end of scope marker + } + + return edit.metaOffset(); + } + + /** + * Compute the size of a sparse (primitive) field + * + * @param cellType The type of the current sparse field. + * @param metaOffset The 0-based offset from the beginning of the row where the field begins. + * @param valueOffset The 0-based offset from the beginning of the row where the field's value begins. + * @return The length (in bytes) of the encoded field including the metadata and the value. + */ + private int sparseComputePrimitiveSize(LayoutType cellType, int metaOffset, int valueOffset) { + + // TODO: JTHTODO: convert to a virtual? + + int metaBytes = valueOffset - metaOffset; + LayoutCode code = cellType.layoutCode(); + + switch (code) { + case NULL: + checkState(LayoutTypes.NULL.size() == 0); + return metaBytes; + + case BOOLEAN: + case BOOLEAN_FALSE: + checkState(LayoutTypes.BOOLEAN.size() == 0); + return metaBytes; + + case INT_8: + return metaBytes + LayoutTypes.INT_8.size(); + + case INT_16: + return metaBytes + LayoutTypes.INT_16.size(); + + case INT_32: + return metaBytes + LayoutTypes.INT_32.size(); + + case INT_64: + return metaBytes + LayoutTypes.INT_64.size(); + + case UINT_8: + return metaBytes + LayoutTypes.UINT_8.size(); + + case UINT_16: + return metaBytes + LayoutTypes.UINT_16.size(); + + case UINT_32: + return metaBytes + LayoutTypes.UINT_32.size(); + + case UINT_64: + return metaBytes + LayoutTypes.UINT_64.size(); + + case FLOAT_32: + return metaBytes + LayoutTypes.FLOAT_32.size(); + + case FLOAT_64: + return metaBytes + LayoutTypes.FLOAT_64.size(); + + case FLOAT_128: + return metaBytes + LayoutTypes.FLOAT_128.size(); + + case DECIMAL: + return metaBytes + LayoutTypes.DECIMAL.size(); + + case DATE_TIME: + return metaBytes + LayoutTypes.DATE_TIME.size(); + + case UNIX_DATE_TIME: + return metaBytes + LayoutTypes.UNIX_DATE_TIME.size(); + + case GUID: + return metaBytes + LayoutTypes.GUID.size(); + + case MONGODB_OBJECT_ID: + // return metaBytes + MongoDbObjectId.size(); + throw new UnsupportedOperationException(); + + case UTF_8: + case BINARY: { + int sizeLenInBytes; + Out tempOut_sizeLenInBytes = new Out<>(); + int numBytes = (int) this.read7BitEncodedUInt(metaOffset + metaBytes, tempOut_sizeLenInBytes); + sizeLenInBytes = tempOut_sizeLenInBytes.get(); + return metaBytes + sizeLenInBytes + numBytes; + } + + case VAR_INT: + case VAR_UINT: { + int sizeLenInBytes; + Out tempOut_sizeLenInBytes2 = new Out(); + this.read7BitEncodedUInt(metaOffset + metaBytes, tempOut_sizeLenInBytes2); + sizeLenInBytes = tempOut_sizeLenInBytes2.get(); + return metaBytes + sizeLenInBytes; + } + default: + throw new IllegalStateException(lenientFormat("Not Implemented: %s", code)); + return 0; + } + } + + /** + * Compute the size of a sparse field + * + * @param edit The edit structure describing the field to measure. + * @return The length (in bytes) of the encoded field including the metadata and the value. + */ + private int sparseComputeSize(RowCursor edit) { + + if (!(edit.cellType() instanceof LayoutScope)) { + return this.sparseComputePrimitiveSize(edit.cellType(), edit.metaOffset(), edit.valueOffset()); + } + + // Compute offset to end of value for current value + RowCursor newScope = this.sparseIteratorReadScope(edit, true); + return this.skipScope(newScope) - edit.metaOffset(); + } + + /** + * Reads and validates the header of the current {@link RowBuffer} + * + * @return {@code true} if the header validation succeeded; otherwise, if the header is invalid, {@code false} + */ + private boolean validateHeader(@Nonnull final HybridRowVersion version) { + + checkNotNull(version); + + Out lengthInBytes = new Out<>(); + HybridRowHeader header = this.read(this::readHeader, 0, lengthInBytes); + + Layout layout = this.resolver.resolve(header.schemaId()); + checkState(header.schemaId().equals(layout.schemaId())); + + return header.version().equals(version) && (HybridRowHeader.SIZE + layout.size()) <= this.length(); + } + + private int writeDefaultValue(int offset, LayoutType code, TypeArgumentList typeArgs) { + + // JTHTODO: convert to a virtual? + + if (code == LayoutTypes.NULL) { + this.writeSparseTypeCode(offset, code.layoutCode()); + return 1; + } + + if (code == LayoutTypes.BOOLEAN) { + this.writeSparseTypeCode(offset, LayoutCode.BOOLEAN_FALSE); + return 1; + } + + if (code == LayoutTypes.INT_8) { + this.writeInt8(offset, (byte) 0); + return LayoutTypes.INT_8.size(); + } + + if (code == LayoutTypes.INT_16) { + this.writeInt16(offset, (short) 0); + return LayoutTypes.INT_16.size(); + } + + if (code == LayoutTypes.INT_32) { + this.writeInt32(offset, 0); + return LayoutTypes.INT_32.size(); + } + + if (code == LayoutTypes.INT_64) { + this.writeInt64(offset, 0); + return LayoutTypes.INT_64.size(); + } + + if (code == LayoutTypes.UINT_8) { + this.WriteUInt8(offset, (byte) 0); + return LayoutTypes.UINT_8.size(); + } + + if (code == LayoutTypes.UINT_16) { + this.WriteUInt16(offset, (short) 0); + return LayoutTypes.UINT_16.size(); + } + + if (code == LayoutTypes.UINT_32) { + this.WriteUInt32(offset, 0); + return LayoutTypes.UINT_32.size(); + } + + if (code == LayoutTypes.UINT_64) { + this.WriteUInt64(offset, 0); + return LayoutTypes.UINT_64.size(); + } + + if (code == LayoutTypes.FLOAT_32) { + this.WriteFloat32(offset, 0); + return LayoutTypes.FLOAT_32.size(); + } + + if (code == LayoutTypes.FLOAT_64) { + this.WriteFloat64(offset, 0); + return LayoutTypes.FLOAT_64.size(); + } + + if (code == LayoutTypes.FLOAT_128) { + this.writeFloat128(offset, null); + return LayoutTypes.FLOAT_128.size(); + } + + if (code == LayoutTypes.DECIMAL) { + this.WriteDecimal(offset, BigDecimal.ZERO); + return LayoutTypes.DECIMAL.size(); + } + + if (code == LayoutTypes.DATE_TIME) { + this.WriteDateTime(offset, LocalDateTime.MIN); + return LayoutTypes.DATE_TIME.size(); + } + + if (code == LayoutTypes.UNIX_DATE_TIME) { + this.WriteUnixDateTime(offset, null); + return LayoutTypes.UNIX_DATE_TIME.size(); + } + + if (code == LayoutTypes.GUID) { + this.WriteGuid(offset, null); + return LayoutTypes.GUID.size(); + } + + if (code == LayoutTypes.MONGODB_OBJECT_ID) { + // TODO: DANOBLE: Add support for LayoutTypes.MONGODB_OBJECT_ID + // this.writeMongoDbObjectId(offset, null); + // return MongoDbObjectId.Size; + throw new UnsupportedOperationException(); + } + + if (code == LayoutTypes.UTF_8 || code == LayoutTypes.BINARY || code == LayoutTypes.VAR_INT || code == LayoutTypes.VAR_UINT) { + // Variable length types preceded by their varuint size take 1 byte for a size of 0. + return this.write7BitEncodedUInt(offset, 0); + } + + if (code == LayoutTypes.OBJECT || code == LayoutTypes.ARRAY) { + // Variable length sparse collection scopes take 1 byte for the end-of-scope terminator. + this.writeSparseTypeCode(offset, LayoutCode.END_SCOPE); + return (LayoutCode.SIZE / Byte.SIZE); + } + + if (code == LayoutTypes.TYPED_ARRAY || code == LayoutTypes.TypedSet || code == LayoutTypes.TypedMap) { + // Variable length typed collection scopes preceded by their scope size take sizeof(uint) for a size of 0. + this.WriteUInt32(offset, 0); + return (Integer.SIZE / Byte.SIZE); + } + + if (code == LayoutTypes.TUPLE) { + // Fixed arity sparse collections take 1 byte for end-of-scope plus a null for each element. + for (int i = 0; i < typeArgs.count(); i++) { + this.writeSparseTypeCode(offset, LayoutCode.NULL); + } + this.writeSparseTypeCode(offset, LayoutCode.END_SCOPE); + return (LayoutCode.SIZE / Byte.SIZE) + ((LayoutCode.SIZE / Byte.SIZE) * typeArgs.count()); + } + + if (code == LayoutTypes.TYPED_TUPLE || code == LayoutTypes.TAGGED || code == LayoutTypes.TAGGED_2) { + // Fixed arity typed collections take the sum of the default values of each element. The scope size is + // implied by the arity. + int sum = 0; + for (final Iterator iterator = typeArgs.elements().iterator(); iterator.hasNext(); ) { + final TypeArgument arg = iterator.next(); + sum += this.writeDefaultValue(offset + sum, arg.type(), arg.typeArgs()); + } + return sum; + } + + if (code == LayoutTypes.NULLABLE) { + // Nullables take the default values of the value plus null. The scope size is implied by the arity. + this.writeInt8(offset, (byte) 0); + return 1 + this.writeDefaultValue(offset + 1, typeArgs.get(0).type(), typeArgs.get(0).typeArgs()); + } + + if (code == LayoutTypes.UDT) { + + // Clear all presence bits. + Layout udt = this.resolver.resolve(typeArgs.schemaId()); + this.buffer.Slice(offset, udt.size()).Fill(0); + + // Write scope terminator. + this.writeSparseTypeCode(offset + udt.size(), LayoutCode.END_SCOPE); + return udt.size() + (LayoutCode.SIZE / Byte.SIZE); + } + throw new IllegalStateException(lenientFormat("Not Implemented: %s", code)); + } + + private void writeSparseMetadata( + @Nonnull final RowCursor edit, @Nonnull final LayoutType cellType, @Nonnull final TypeArgumentList typeArgs, + final int metaBytes) { + + int metaOffset = edit.metaOffset(); + + if (!edit.scopeType().hasImplicitTypeCode(edit)) { + metaOffset += cellType.writeTypeArgument(this, metaOffset, typeArgs); + } + + this.writeSparsePath(edit, metaOffset); + edit.valueOffset(edit.metaOffset() + metaBytes); + checkState(edit.valueOffset() == edit.metaOffset() + metaBytes); + } + + private void writeSparsePath(RowCursor edit, int offset) { + + // Some scopes don't encode paths, therefore the cost is always zero + + if (edit.scopeType().isIndexedScope()) { + edit.pathToken(0); + edit.pathOffset(0); + return; + } + + StringToken _; + Out tempOut__ = + new Out(); + checkState(!edit.layout().tokenizer().TryFindToken(edit.writePath(), tempOut__) || !edit.writePathToken().isNull()); + _ = tempOut__; + if (!edit.writePathToken().isNull()) { + edit.writePathToken().varint().CopyTo(this.buffer.Slice(offset)); + edit.pathToken(edit.intValue().writePathToken.Id); + edit.pathOffset(offset); + } else { + // TODO: It would be better if we could avoid allocating here when the path is UTF16. + Utf8Span span = edit.writePath().ToUtf8String(); + edit.pathToken = edit.layout().getTokenizer().getCount() + span.Length; + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)edit.pathToken); + int sizeLenInBytes = this.write7BitEncodedUInt(offset, edit.longValue().pathToken); + edit.pathOffset = offset + sizeLenInBytes; + span.Span.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); + } + } + + private int writeString(int offset, Utf8Span value) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: int sizeLenInBytes = this.Write7BitEncodedUInt(offset, (ulong)value.Length); + int sizeLenInBytes = this.write7BitEncodedUInt(offset, (long) value.Length); + value.Span.CopyTo(this.buffer.Slice(offset + sizeLenInBytes)); + return sizeLenInBytes; + } + /** * Represents a single item within a set/map scope that needs to be indexed *

* This structure is used when rebuilding a set/map index during row streaming via {@link RowWriter}.Each item * encodes its offsets and length within the row. */ - static final class UniqueIndexItem { + static final class UniqueIndexItem { - private LayoutCode Code = LayoutCode.values()[0]; - private int MetaOffset; - private int Size; - private int ValueOffset; + private LayoutCode Code = LayoutCode.values()[0]; + private int MetaOffset; + private int Size; + private int ValueOffset; - /** - * The layout code of the value. - */ - public LayoutCode code() { - return Code; - } + /** + * The layout code of the value. + */ + public LayoutCode code() { + return Code; + } - public UniqueIndexItem code(LayoutCode code) { - Code = code; - return this; - } + public UniqueIndexItem code(LayoutCode code) { + Code = code; + return this; + } - /** - * If existing, the offset to the metadata of the existing field, otherwise the location to insert a new field - */ - public int metaOffset() { - return MetaOffset; - } + /** + * If existing, the offset to the metadata of the existing field, otherwise the location to insert a new field + */ + public int metaOffset() { + return MetaOffset; + } - public UniqueIndexItem metaOffset(int metaOffset) { - MetaOffset = metaOffset; - return this; - } + public UniqueIndexItem metaOffset(int metaOffset) { + MetaOffset = metaOffset; + return this; + } - /** - * Size of the target element - */ - public int size() { - return Size; - } + /** + * Size of the target element + */ + public int size() { + return Size; + } - public UniqueIndexItem size(int size) { - Size = size; - return this; - } + public UniqueIndexItem size(int size) { + Size = size; + return this; + } - /** - * If existing, the offset to the value of the existing field, otherwise undefined - */ - public int valueOffset() { - return ValueOffset; - } + /** + * If existing, the offset to the value of the existing field, otherwise undefined + */ + public int valueOffset() { + return ValueOffset; + } - public UniqueIndexItem valueOffset(int valueOffset) { - ValueOffset = valueOffset; - return this; - } + public UniqueIndexItem valueOffset(int valueOffset) { + ValueOffset = valueOffset; + return this; + } } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java similarity index 89% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java index a3fbed7..e395837 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursor.java @@ -128,8 +128,8 @@ public final class RowCursor implements Cloneable { return this.endOffset; } - public RowCursor endOffset(int endOffset) { - this.endOffset = endOffset; + public RowCursor endOffset(int value) { + this.endOffset = value; return this; } @@ -140,8 +140,8 @@ public final class RowCursor implements Cloneable { return this.exists; } - public RowCursor exists(boolean exists) { - this.exists = exists; + public RowCursor exists(boolean value) { + this.exists = value; return this; } @@ -154,8 +154,8 @@ public final class RowCursor implements Cloneable { return this.immutable; } - public RowCursor immutable(boolean immutable) { - this.immutable = immutable; + public RowCursor immutable(boolean value) { + this.immutable = value; return this; } @@ -166,8 +166,8 @@ public final class RowCursor implements Cloneable { return this.index; } - public RowCursor index(int index) { - this.index = index; + public RowCursor index(int value) { + this.index = value; return this; } @@ -178,8 +178,8 @@ public final class RowCursor implements Cloneable { return this.layout; } - public RowCursor layout(Layout layout) { - this.layout = layout; + public RowCursor layout(Layout value) { + this.layout = value; return this; } @@ -191,8 +191,8 @@ public final class RowCursor implements Cloneable { return this.metaOffset; } - public RowCursor metaOffset(int metaOffset) { - this.metaOffset = metaOffset; + public RowCursor metaOffset(final int value) { + this.metaOffset = value; return this; } @@ -203,6 +203,11 @@ public final class RowCursor implements Cloneable { return this.pathOffset; } + public RowCursor pathOffset(final int value) { + this.pathOffset = value; + return this; + } + /** * If existing, the layout string token of scope relative path for reading. */ @@ -210,6 +215,11 @@ public final class RowCursor implements Cloneable { return this.pathToken; } + public RowCursor pathToken(int value) { + this.pathToken = value; + return this; + } + /** * The kind of scope within which this edit was prepared */ diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java similarity index 93% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java index 2f66c75..64aa1f7 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowCursors.java @@ -107,7 +107,7 @@ public final class RowCursors { return true; } - public static void skip(RowCursor edit, RowBuffer row, RowCursor childScope) { + public static void skip(@Nonnull final RowCursor edit, @Nonnull final RowBuffer row, @Nonnull final RowCursor childScope) { checkArgument(childScope.start() == edit.valueOffset()); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowOptions.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowOptions.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowOptions.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/RowOptions.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/UnixDateTime.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/UnixDateTime.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/UnixDateTime.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/UnixDateTime.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/internal/Murmur3Hash.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/internal/Murmur3Hash.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/internal/Murmur3Hash.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/internal/Murmur3Hash.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/IRowSerializable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/IRowSerializable.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/IRowSerializable.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/IRowSerializable.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java similarity index 96% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java index d62a132..5a33ce6 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReader.java @@ -143,7 +143,7 @@ public final class RowReader { this.cursor = cursor.get(); Reference row = new Reference<>(this.row); Reference tempReference_nullableScope = new Reference<>(nullableScope); - boolean tempVar = LayoutNullable.HasValue(row, tempReference_nullableScope) == Result.Success; + boolean tempVar = LayoutNullable.hasValue(row, tempReference_nullableScope) == Result.Success; nullableScope = tempReference_nullableScope.get(); this.row = row.get(); return tempVar; @@ -534,7 +534,7 @@ public final class RowReader { Reference tempReference_cursor = new Reference(this.cursor); - value.setAndGet(this.row.ReadSparseFloat64(tempReference_cursor)); + value.setAndGet(this.row.readSparseFloat64(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: @@ -561,7 +561,7 @@ public final class RowReader { Reference tempReference_cursor = new Reference(this.cursor); - value.setAndGet(this.row.ReadSparseGuid(tempReference_cursor)); + value.setAndGet(this.row.readSparseGuid(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: @@ -588,7 +588,7 @@ public final class RowReader { Reference tempReference_cursor = new Reference(this.cursor); - value.setAndGet(this.row.ReadSparseInt16(tempReference_cursor)); + value.setAndGet(this.row.readSparseInt16(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: @@ -615,7 +615,7 @@ public final class RowReader { Reference tempReference_cursor = new Reference(this.cursor); - value.setAndGet(this.row.ReadSparseInt32(tempReference_cursor)); + value.setAndGet(this.row.readSparseInt32(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: @@ -642,7 +642,7 @@ public final class RowReader { Reference tempReference_cursor = new Reference(this.cursor); - value.setAndGet(this.row.ReadSparseInt64(tempReference_cursor)); + value.setAndGet(this.row.readSparseInt64(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: @@ -669,7 +669,7 @@ public final class RowReader { Reference tempReference_cursor = new Reference(this.cursor); - value.setAndGet(this.row.ReadSparseInt8(tempReference_cursor)); + value.setAndGet(this.row.readSparseInt8(tempReference_cursor)); this.cursor = tempReference_cursor.get(); return Result.Success; default: diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowReaderExtensions.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java similarity index 97% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java index 9a76e1e..94ed203 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/io/RowWriter.java @@ -398,7 +398,7 @@ public final class RowWriter { new Reference(this.cursor); Out tempOut_nestedScope2 = new Out(); - this.row.WriteSparseArray(tempRef_cursor2, scopeType, UpdateOptions.Upsert, tempOut_nestedScope2); + this.row.writeSparseArray(tempRef_cursor2, scopeType, UpdateOptions.Upsert, tempOut_nestedScope2); nestedScope = tempOut_nestedScope2.get(); this.cursor = tempRef_cursor2.argValue; break; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonExtensions.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonSettings.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonSettings.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonSettings.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/json/RowReaderJsonSettings.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSequenceWritable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSequenceWritable.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSequenceWritable.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSequenceWritable.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanReadable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanReadable.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanReadable.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanReadable.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanWritable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanWritable.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanWritable.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutSpanWritable.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanReadable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanReadable.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanReadable.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanReadable.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanWritable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanWritable.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanWritable.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/ILayoutUtf8SpanWritable.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/Layout.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java similarity index 60% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java index 79ce871..0a0e5f9 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutArray.java @@ -4,53 +4,48 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.ARRAY_SCOPE; import static com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.IMMUTABLE_ARRAY_SCOPE; public final class LayoutArray extends LayoutIndexedScope { - private TypeArgument TypeArg = new TypeArgument(); - public LayoutArray(boolean immutable) { + public LayoutArray(final boolean immutable) { super(immutable ? IMMUTABLE_ARRAY_SCOPE : ARRAY_SCOPE, immutable, false, false, false, false); - this.TypeArg = new TypeArgument(this); } public String name() { - return this.Immutable ? "im_array" : "array"; - } - - public TypeArgument typeArg() { - return TypeArg; + return this.isImmutable() ? "im_array" : "array"; } @Override - public Result WriteScope( - Reference b, - Reference edit, - TypeArgumentList typeArgs, - Out value + public Result writeScope( + @Nonnull final RowBuffer b, + @Nonnull final RowCursor edit, + @Nonnull final TypeArgumentList typeArgs, + @Nonnull Out value ) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return this.writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { - Result result = prepareSparseWrite(b, edit, this.typeArg().clone(), options); + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { + Result result = prepareSparseWrite(b, edit, this.typeArg(), options); if (result != Result.Success) { value.setAndGet(null); return result; } - b.get().WriteSparseArray(edit, this, options, value.clone()); + b.writeSparseArray(edit, this, options, value); return Result.Success; } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBinary.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java similarity index 90% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java index 4f320a4..807de2d 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBit.java @@ -11,12 +11,12 @@ public final class LayoutBit { */ public static final LayoutBit INVALID = new LayoutBit(-1); - private int index; + private final int index; /** * Initializes a new instance of the {@link LayoutBit} struct. * - * @param index The 0-based offset into the layout bitmask. + * @param index The zero-based offset into the layout bitmask. */ public LayoutBit(int index) { checkArgument(index >= -1); @@ -52,6 +52,10 @@ public final class LayoutBit { return this.index; } + public boolean isInvalid() { + return this.index == INVALID.index; + } + /** * Returns the zero-based byte offset from the beginning of the row or scope that contains the bit from the bitmask *

diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBoolean.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutBuilder.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCode.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCodeTraits.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutColumn.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompilationException.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompilationException.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompilationException.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompilationException.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutCompiler.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDateTime.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutDecimal.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java similarity index 79% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java index 01c8cf3..62a8e7a 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutEndScope.java @@ -4,7 +4,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; @@ -25,17 +24,17 @@ public final class LayoutEndScope extends LayoutScope { @Override - public Result WriteScope(Reference b, Reference scope, + public Result writeScope(RowBuffer b, RowCursor scope, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, scope, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, scope, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor scope, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference scope, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor scope, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Contract.Fail("Cannot write an EndScope directly"); value.setAndGet(null); return Result.Failure; diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat128.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat32.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutFloat64.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutGuid.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutIndexedScope.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutIndexedScope.java similarity index 55% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutIndexedScope.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutIndexedScope.java index a31ed56..9d037f8 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutIndexedScope.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutIndexedScope.java @@ -3,23 +3,23 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; -import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + public abstract class LayoutIndexedScope extends LayoutScope { protected LayoutIndexedScope( - LayoutCode code, boolean immutable, boolean isSizedScope, boolean isFixedArity, boolean isUniqueScope, - boolean isTypedScope - ) { + @Nonnull final LayoutCode code, final boolean immutable, final boolean isSizedScope, final boolean isFixedArity, + final boolean isUniqueScope, final boolean isTypedScope) { + super(code, immutable, isSizedScope, true, isFixedArity, isUniqueScope, isTypedScope); } @Override - public void ReadSparsePath(Reference row, Reference edit) { - edit.get().pathToken = 0; - edit.get().pathOffset = 0; + public void readSparsePath(@Nonnull final RowBuffer row, @Nonnull final RowCursor edit) { + edit.pathToken(0); + edit.pathOffset(0); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt16.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt32.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt64.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutInt8.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutMongoDbObjectId.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNull.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java similarity index 58% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java index f201cd8..63521a0 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutNullable.java @@ -9,7 +9,10 @@ import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import javax.annotation.Nonnull; + import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; public final class LayoutNullable extends LayoutIndexedScope { @@ -22,49 +25,53 @@ public final class LayoutNullable extends LayoutIndexedScope { return this.Immutable ? "im_nullable" : "nullable"; } - public int countTypeArgument(TypeArgumentList value) { - checkState(value.count() == 1); - return (com.azure.data.cosmos.serialization.hybridrow.layouts.LayoutCode.SIZE / Byte.SIZE) + value.get(0).type().CountTypeArgument(value.get(0).typeArgs().clone()); + public int countTypeArgument(@Nonnull final TypeArgumentList value) { + checkNotNull(value, "expected non-null value"); + checkArgument(value.count() == 1); + return (LayoutCode.SIZE / Byte.SIZE) + value.get(0).type().countTypeArgument(value.get(0).typeArgs()); } @Override - public boolean HasImplicitTypeCode(Reference edit) { - checkState(edit.get().index() >= 0); - checkState(edit.get().scopeTypeArgs().count() == 1); - checkState(edit.get().index() == 1); - return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.get().scopeTypeArgs().get(0).type().LayoutCode); + public boolean hasImplicitTypeCode(@Nonnull final RowCursor edit) { + checkNotNull(edit, "expected non-null edit"); + checkArgument(edit.index() >= 0); + checkArgument(edit.scopeTypeArgs().count() == 1); + checkArgument(edit.index() == 1); + return !LayoutCodeTraits.AlwaysRequiresTypeCode(edit.scopeTypeArgs().get(0).type().layoutCode()); } - public static Result HasValue(Reference b, Reference scope) { - checkArgument(scope.get().scopeType() instanceof LayoutNullable); - checkState(scope.get().index() == 1 || scope.get().index() == 2, "Nullable scopes always point at the value"); - checkState(scope.get().scopeTypeArgs().count() == 1); - boolean hasValue = b.get().ReadInt8(scope.get().start()) != 0; + public static Result hasValue(@Nonnull final RowBuffer b, @Nonnull final RowCursor scope) { + checkNotNull(b); + checkNotNull(scope); + checkArgument(scope.scopeType() instanceof LayoutNullable); + checkArgument(scope.index() == 1 || scope.index() == 2); + checkArgument(scope.scopeTypeArgs().count() == 1); + boolean hasValue = b.readInt8(scope.start()) != 0; return hasValue ? Result.Success : Result.NotFound; } @Override - public TypeArgumentList readTypeArgumentList(Reference row, int offset, - Out lenInBytes) { - return new TypeArgumentList(new TypeArgument[] { LayoutType.readTypeArgument(row, offset, lenInBytes) }); + public TypeArgumentList readTypeArgumentList( + @Nonnull final RowBuffer row, int offset, @Nonnull final Out lenInBytes) { + return new TypeArgumentList(LayoutType.readTypeArgument(row, offset, lenInBytes)); } @Override - public void SetImplicitTypeCode(Reference edit) { - checkState(edit.get().index() == 1); - edit.get().cellType = edit.get().scopeTypeArgs().get(0).type(); - edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone(); + public void setImplicitTypeCode(RowCursor edit) { + checkState(edit.index() == 1); + edit.get().cellType(edit.get().scopeTypeArgs().get(0).type()); + edit.get().cellTypeArgs(edit.get().scopeTypeArgs().get(0).typeArgs()); } - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(Reference b, Reference edit, TypeArgumentList typeArgs, boolean hasValue, Out value) { - return WriteScope(b, edit, typeArgs, hasValue, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, hasValue, value, UpdateOptions.Upsert); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList typeArgs, bool // hasValue, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(Reference b, Reference edit, TypeArgumentList typeArgs, boolean hasValue, Out value, UpdateOptions options) { Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); @@ -78,17 +85,17 @@ public final class LayoutNullable extends LayoutIndexedScope { } @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { return this.WriteScope(b, edit, typeArgs.clone(), true, value, options); } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java similarity index 79% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java index 77d4dc5..cd0ec6d 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutObject.java @@ -4,7 +4,6 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; import com.azure.data.cosmos.serialization.hybridrow.Result; import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; import com.azure.data.cosmos.serialization.hybridrow.RowCursor; @@ -28,17 +27,17 @@ public final class LayoutObject extends LayoutPropertyScope { @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Result result = LayoutType.prepareSparseWrite(b, edit, this.typeArg().clone(), options); if (result != Result.Success) { value.setAndGet(null); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutPropertyScope.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutPropertyScope.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutPropertyScope.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutPropertyScope.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolver.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolver.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolver.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolver.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverNamespace.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverSimple.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverSimple.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverSimple.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutResolverSimple.java diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java new file mode 100644 index 0000000..f9f1a3d --- /dev/null +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos.serialization.hybridrow.layouts; + +import com.azure.data.cosmos.core.Out; +import com.azure.data.cosmos.core.Reference; +import com.azure.data.cosmos.serialization.hybridrow.Result; +import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; +import com.azure.data.cosmos.serialization.hybridrow.RowCursor; +import com.azure.data.cosmos.serialization.hybridrow.RowCursors; + +import javax.annotation.Nonnull; + +import static com.google.common.base.Preconditions.checkNotNull; + +public abstract class LayoutScope extends LayoutType { + + private final boolean isFixedArity; + private final boolean isIndexedScope; + private final boolean isSizedScope; + private final boolean isTypedScope; + private final boolean isUniqueScope; + + protected LayoutScope( + @Nonnull final LayoutCode code, final boolean immutable, final boolean isSizedScope, + final boolean isIndexedScope, final boolean isFixedArity, final boolean isUniqueScope, boolean isTypedScope) { + + super(code, immutable, 0); + this.isSizedScope = isSizedScope; + this.isIndexedScope = isIndexedScope; + this.isFixedArity = isFixedArity; + this.isUniqueScope = isUniqueScope; + this.isTypedScope = isTypedScope; + } + + /** + * Returns true if this is a fixed arity scope. + */ + public boolean isFixedArity() { + return this.isFixedArity; + } + + /** + * Returns true if this is an indexed scope. + */ + public boolean isIndexedScope() { + return this.isIndexedScope; + } + + /** + * Returns true if this is a sized scope. + */ + public boolean isSizedScope() { + return this.isSizedScope; + } + + /** + * Returns true if this is a typed scope. + */ + public boolean isTypedScope() { + return this.isTypedScope; + } + + /** + * Returns true if the scope's elements cannot be updated directly. + */ + public boolean isUniqueScope() { + return this.isUniqueScope; + } + + public final Result deleteScope(@Nonnull final RowBuffer b, @Nonnull final RowCursor edit) { + + checkNotNull(b); + checkNotNull(edit); + + Result result = LayoutType.prepareSparseDelete(b, edit, this.layoutCode()); + + if (result != Result.Success) { + return result; + } + + b.deleteSparse(edit); + return Result.Success; + } + + /** + * {@code true} if writing an item in the specified typed scope would elide the type code because it is implied by + * the type arguments + * + * @param edit a non-null {@link RowCursor} specifying a typed scope + * @return {@code true} if the type code is implied (not written); {@code false} otherwise. + */ + public boolean hasImplicitTypeCode(@Nonnull final RowCursor edit) { + checkNotNull(edit, "expected non-null edit"); + return false; + } + + @Nonnull + public final Result readScope( + @Nonnull final RowBuffer b, @Nonnull final RowCursor edit, @Nonnull final Out value) { + + checkNotNull(b); + checkNotNull(edit); + checkNotNull(value); + + Result result = LayoutType.prepareSparseRead(b, edit, this.layoutCode()); + + if (result != Result.Success) { + value.setAndGet(null); + return result; + } + + boolean immutable = this.isImmutable() || edit.immutable() || edit.scopeType().isUniqueScope(); + value.set(b.sparseIteratorReadScope(edit, immutable)); + return Result.Success; + } + + public void readSparsePath(@Nonnull final RowBuffer row, @Nonnull final RowCursor edit) { + Out pathLenInBytes = new Out<>(); + Out pathOffset = new Out<>(); + edit.pathToken(row.readSparsePathLen(edit.layout(), edit.valueOffset(), pathLenInBytes, pathOffset)); + edit.pathOffset(pathOffset.get()); + edit.valueOffset(edit.valueOffset() + pathLenInBytes.get()); + } + + public void setImplicitTypeCode(final RowCursor edit) { + throw new UnsupportedOperationException(); + } + + public abstract Result writeScope( + RowBuffer b, + RowCursor scope, + TypeArgumentList typeArgs, Out value); + + public abstract Result writeScope( + RowBuffer b, + RowCursor scope, + TypeArgumentList typeArgs, + UpdateOptions options, Out value); + + public Result writeScope( + RowBuffer b, + RowCursor scope, + TypeArgumentList typeArgs, + TContext context, WriterFunc func) { + return this.writeScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert); + } + + //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: + //ORIGINAL LINE: public virtual Result WriteScope(ref RowBuffer b, ref RowCursor scope, + // TypeArgumentList typeArgs, TContext context, WriterFunc func, UpdateOptions options = UpdateOptions + // .Upsert) + public Result writeScope( + RowBuffer b, + RowCursor scope, + TypeArgumentList typeArgs, + TContext context, WriterFunc func, UpdateOptions options) { + + final Out out = new Out<>(); + Result result = this.writeScope(b, scope, typeArgs, options, out); + + if (result != Result.Success) { + return result; + } + + final RowCursor childScope = out.get(); + + if (func != null) { + result = func.invoke(b, childScope, context); + if (result != Result.Success) { + this.deleteScope(b, scope); + return result; + } + } + + RowCursors.skip(scope, b, childScope); + return Result.Success; + } + + /** + * A function to write content into a {@link RowBuffer}. + * The type of the context value passed by the caller. + * + * @param b The row to write to. + * @param scope The type of the scope to write into. + * @param context A context value provided by the caller. + * @return The result. + */ + @FunctionalInterface + public interface WriterFunc { + @Nonnull Result invoke(RowBuffer b, RowCursor scope, TContext context); + } +} \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java similarity index 87% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java index 405acfb..e482d72 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged.java @@ -43,23 +43,23 @@ public final class LayoutTagged extends LayoutIndexedScope { } @Override - public void SetImplicitTypeCode(Reference edit) { + public void setImplicitTypeCode(RowCursor edit) { edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone(); } @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java similarity index 89% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java index df7e304..edcbc39 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTagged2.java @@ -56,23 +56,23 @@ public final class LayoutTagged2 extends LayoutIndexedScope { } @Override - public void SetImplicitTypeCode(Reference edit) { + public void setImplicitTypeCode(RowCursor edit) { edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone(); } @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java similarity index 90% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java index 187d40e..bec9fe0 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTuple.java @@ -50,17 +50,17 @@ public final class LayoutTuple extends LayoutIndexedScope { } @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java similarity index 95% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java index d2d2b6e..3d28c6e 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutType.java @@ -287,13 +287,14 @@ public abstract class LayoutType implements ILayoutType { * @param code The expected type of the field. * @return Success if the read is permitted, the error code otherwise. */ - public static Result prepareSparseRead(Reference b, Reference edit, LayoutCode code) { + public static Result prepareSparseRead( + @Nonnull final RowBuffer b, @Nonnull final RowCursor edit, @Nonnull LayoutCode code) { - if (!edit.get().exists()) { + if (!edit.exists()) { return Result.NotFound; } - if (LayoutCodeTraits.Canonicalize(edit.get().cellType().layoutCode()) != code) { + if (LayoutCodeTraits.Canonicalize(edit.cellType().layoutCode()) != code) { return Result.TypeMismatch; } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java similarity index 87% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java index e28983c..850be2b 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedArray.java @@ -38,23 +38,23 @@ public final class LayoutTypedArray extends LayoutIndexedScope { } @Override - public void SetImplicitTypeCode(Reference edit) { + public void setImplicitTypeCode(RowCursor edit) { edit.get().cellType = edit.get().scopeTypeArgs().get(0).type(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone(); } @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java similarity index 88% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java index 7be8397..480e467 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedMap.java @@ -58,24 +58,24 @@ public final class LayoutTypedMap extends LayoutUniqueScope { } @Override - public void SetImplicitTypeCode(Reference edit) { + public void setImplicitTypeCode(RowCursor edit) { edit.get().cellType = edit.get().scopeType().Immutable ? ImmutableTypedTuple : TypedTuple; edit.get().cellTypeArgs = edit.get().scopeTypeArgs().clone(); } @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java similarity index 87% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java index d67d256..d61a55b 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedSet.java @@ -45,23 +45,23 @@ public final class LayoutTypedSet extends LayoutUniqueScope { } @Override - public void SetImplicitTypeCode(Reference edit) { + public void setImplicitTypeCode(RowCursor edit) { edit.get().cellType = edit.get().scopeTypeArgs().get(0).type(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(0).typeArgs().clone(); } @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java similarity index 89% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java index a84bf80..dc30358 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypedTuple.java @@ -57,23 +57,23 @@ public final class LayoutTypedTuple extends LayoutIndexedScope { } @Override - public void SetImplicitTypeCode(Reference edit) { + public void setImplicitTypeCode(RowCursor edit) { edit.get().cellType = edit.get().scopeTypeArgs().get(edit.get().index()).type(); edit.get().cellTypeArgs = edit.get().scopeTypeArgs().get(edit.get().index()).typeArgs().clone(); } @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Result result = LayoutType.prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { value.setAndGet(null); diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java similarity index 68% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java index 566319b..22e4063 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutTypes.java @@ -7,14 +7,14 @@ package com.azure.data.cosmos.serialization.hybridrow.layouts; * Layout type definitions */ public abstract class LayoutTypes { - public static final LayoutArray Array = new LayoutArray(false); - public static final LayoutBinary Binary = new LayoutBinary(); + public static final LayoutArray ARRAY = new LayoutArray(false); + public static final LayoutBinary BINARY = new LayoutBinary(); public static final int BitsPerByte = 8; - public static final LayoutBoolean Boolean = new LayoutBoolean(true); + public static final LayoutBoolean BOOLEAN = new LayoutBoolean(true); public static final LayoutBoolean BooleanFalse = new LayoutBoolean(false); public static final LayoutDateTime DATE_TIME = new LayoutDateTime(); public static final LayoutDecimal DECIMAL = new LayoutDecimal(); - public static final LayoutEndScope EndScope = new LayoutEndScope(); + public static final LayoutEndScope END_SCOPE = new LayoutEndScope(); public static final LayoutFloat128 FLOAT_128 = new LayoutFloat128(); public static final LayoutFloat32 FLOAT_32 = new LayoutFloat32(); public static final LayoutFloat64 FLOAT_64 = new LayoutFloat64(); @@ -34,24 +34,24 @@ public abstract class LayoutTypes { public static final LayoutInt32 INT_32 = new LayoutInt32(); public static final LayoutInt64 INT_64 = new LayoutInt64(); public static final LayoutInt8 INT_8 = new LayoutInt8(); - public static final LayoutMongoDbObjectId MongoDbObjectId = new LayoutMongoDbObjectId(); - public static final LayoutNull Null = new LayoutNull(); - public static final LayoutNullable Nullable = new LayoutNullable(false); - public static final LayoutObject Object = new LayoutObject(false); - public static final LayoutTagged Tagged = new LayoutTagged(false); - public static final LayoutTagged2 Tagged2 = new LayoutTagged2(false); - public static final LayoutTuple Tuple = new LayoutTuple(false); - public static final LayoutTypedArray TypedArray = new LayoutTypedArray(false); + public static final LayoutMongoDbObjectId MONGODB_OBJECT_ID = new LayoutMongoDbObjectId(); + public static final LayoutNull NULL = new LayoutNull(); + public static final LayoutNullable NULLABLE = new LayoutNullable(false); + public static final LayoutObject OBJECT = new LayoutObject(false); + public static final LayoutTagged TAGGED = new LayoutTagged(false); + public static final LayoutTagged2 TAGGED_2 = new LayoutTagged2(false); + public static final LayoutTuple TUPLE = new LayoutTuple(false); + public static final LayoutTypedArray TYPED_ARRAY = new LayoutTypedArray(false); public static final LayoutTypedMap TypedMap = new LayoutTypedMap(false); public static final LayoutTypedSet TypedSet = new LayoutTypedSet(false); - public static final LayoutTypedTuple TypedTuple = new LayoutTypedTuple(false); + public static final LayoutTypedTuple TYPED_TUPLE = new LayoutTypedTuple(false); public static final LayoutUDT UDT = new LayoutUDT(false); public static final LayoutUInt16 UINT_16 = new LayoutUInt16(); public static final LayoutUInt32 UINT_32 = new LayoutUInt32(); public static final LayoutUInt64 UINT_64 = new LayoutUInt64(); public static final LayoutUInt8 UINT_8 = new LayoutUInt8(); public static final LayoutUnixDateTime UNIX_DATE_TIME = new LayoutUnixDateTime(); - public static final LayoutUtf8 Utf8 = new LayoutUtf8(); - public static final LayoutVarInt VarInt = new LayoutVarInt(); - public static final LayoutVarUInt VarUInt = new LayoutVarUInt(); + public static final LayoutUtf8 UTF_8 = new LayoutUtf8(); + public static final LayoutVarInt VAR_INT = new LayoutVarInt(); + public static final LayoutVarUInt VAR_UINT = new LayoutVarUInt(); } diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java similarity index 87% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java index 20834f2..e978479 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUDT.java @@ -33,17 +33,17 @@ public final class LayoutUDT extends LayoutPropertyScope { } @Override - public Result WriteScope(Reference b, Reference edit, + public Result writeScope(RowBuffer b, RowCursor edit, TypeArgumentList typeArgs, Out value) { - return WriteScope(b, edit, typeArgs, value, UpdateOptions.Upsert); + return writeScope(b, edit, typeArgs, UpdateOptions.Upsert, value); } //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: //ORIGINAL LINE: public override Result WriteScope(ref RowBuffer b, ref RowCursor edit, TypeArgumentList // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert) @Override - public Result WriteScope(Reference b, Reference edit, - TypeArgumentList typeArgs, Out value, UpdateOptions options) { + public Result writeScope(RowBuffer b, RowCursor edit, + TypeArgumentList typeArgs, UpdateOptions options, Out value) { Layout udt = b.get().resolver().resolve(typeArgs.schemaId().clone()); Result result = prepareSparseWrite(b, edit, new TypeArgument(this, typeArgs.clone()), options); if (result != Result.Success) { diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt16.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt32.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt64.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUInt8.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java similarity index 94% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java index f983774..6ab0b64 100644 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUniqueScope.java @@ -101,7 +101,7 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope { // TypeArgumentList typeArgs, TContext context, WriterFunc func, UpdateOptions options = UpdateOptions // .Upsert) @Override - public Result WriteScope(Reference b, Reference scope, + public Result writeScope(RowBuffer b, RowCursor scope, TypeArgumentList typeArgs, TContext context, WriterFunc func, UpdateOptions options) { RowCursor uniqueScope; @@ -146,8 +146,8 @@ public abstract class LayoutUniqueScope extends LayoutIndexedScope { } @Override - public Result WriteScope(Reference b, Reference scope, + public Result writeScope(RowBuffer b, RowCursor scope, TypeArgumentList typeArgs, TContext context, WriterFunc func) { - return WriteScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert); + return writeScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert); } } \ No newline at end of file diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUnixDateTime.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutUtf8.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarInt.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutVarUInt.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingStringComparer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingStringComparer.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingStringComparer.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingStringComparer.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingUtf8StringComparer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingUtf8StringComparer.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingUtf8StringComparer.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SamplingUtf8StringComparer.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringToken.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/StringTokenizer.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgument.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgument.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgument.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgument.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgumentList.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgumentList.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgumentList.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/TypeArgumentList.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/UpdateOptions.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/UpdateOptions.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/UpdateOptions.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/UpdateOptions.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Record.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Record.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Record.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Record.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOFormatter.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOParser.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOStream.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOStream.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOStream.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordIOStream.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordSerializer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordSerializer.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordSerializer.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/RecordSerializer.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Segment.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Segment.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Segment.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/Segment.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/recordio/SegmentSerializer.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ArrayPropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ArrayPropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ArrayPropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ArrayPropertyType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/MapPropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/MapPropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/MapPropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/MapPropertyType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Namespace.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Namespace.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Namespace.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Namespace.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ObjectPropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ObjectPropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ObjectPropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ObjectPropertyType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PartitionKey.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PartitionKey.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PartitionKey.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PartitionKey.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimarySortKey.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimarySortKey.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimarySortKey.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimarySortKey.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimitivePropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimitivePropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimitivePropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PrimitivePropertyType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Property.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Property.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Property.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Property.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertySchemaConverter.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertySchemaConverter.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertySchemaConverter.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertySchemaConverter.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Schema.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Schema.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Schema.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/Schema.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaException.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaException.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaException.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaException.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaHash.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaHash.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaHash.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaHash.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaLanguageVersion.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaLanguageVersion.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaLanguageVersion.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaLanguageVersion.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaOptions.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaOptions.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaOptions.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaOptions.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SchemaValidator.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ScopePropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ScopePropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ScopePropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/ScopePropertyType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SetPropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SetPropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SetPropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SetPropertyType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SortDirection.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SortDirection.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SortDirection.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/SortDirection.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StaticKey.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StaticKey.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StaticKey.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StaticKey.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StorageKind.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StorageKind.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StorageKind.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StorageKind.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictBooleanConverter.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictBooleanConverter.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictBooleanConverter.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictBooleanConverter.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictIntegerConverter.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictIntegerConverter.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictIntegerConverter.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/StrictIntegerConverter.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TaggedPropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TaggedPropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TaggedPropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TaggedPropertyType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TuplePropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TuplePropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TuplePropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TuplePropertyType.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java diff --git a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java similarity index 100% rename from jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java rename to java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java diff --git a/jre/src/main/java/tangible/Action0Param.java b/java/src/main/java/tangible/Action0Param.java similarity index 100% rename from jre/src/main/java/tangible/Action0Param.java rename to java/src/main/java/tangible/Action0Param.java diff --git a/jre/src/main/java/tangible/Func0Param.java b/java/src/main/java/tangible/Func0Param.java similarity index 100% rename from jre/src/main/java/tangible/Func0Param.java rename to java/src/main/java/tangible/Func0Param.java diff --git a/jre/src/main/java/tangible/Func1Param.java b/java/src/main/java/tangible/Func1Param.java similarity index 100% rename from jre/src/main/java/tangible/Func1Param.java rename to java/src/main/java/tangible/Func1Param.java diff --git a/jre/src/main/java/tangible/ListHelper.java b/java/src/main/java/tangible/ListHelper.java similarity index 100% rename from jre/src/main/java/tangible/ListHelper.java rename to java/src/main/java/tangible/ListHelper.java diff --git a/jre/src/main/java/tangible/StringHelper.java b/java/src/main/java/tangible/StringHelper.java similarity index 100% rename from jre/src/main/java/tangible/StringHelper.java rename to java/src/main/java/tangible/StringHelper.java diff --git a/jre/src/main/java/tangible/TryParseHelper.java b/java/src/main/java/tangible/TryParseHelper.java similarity index 100% rename from jre/src/main/java/tangible/TryParseHelper.java rename to java/src/main/java/tangible/TryParseHelper.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BenchmarkSuiteBase.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BenchmarkSuiteBase.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BenchmarkSuiteBase.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BenchmarkSuiteBase.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonJsonModelRowGenerator.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonJsonModelRowGenerator.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonJsonModelRowGenerator.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonJsonModelRowGenerator.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonReaderExtensions.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonReaderExtensions.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonReaderExtensions.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonReaderExtensions.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/BsonRowGenerator.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenMicroBenchmarkSuite.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenMicroBenchmarkSuite.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenMicroBenchmarkSuite.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenMicroBenchmarkSuite.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java similarity index 97% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java index 4cc4b11..35ab76d 100644 --- a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/CodeGenRowGenerator.java @@ -353,7 +353,7 @@ public final class CodeGenRowGenerator { this.addressSerializer = new AddressHybridRowSerializer(resolver.resolve(this.addresses.typeArgs().get(1).typeArgs().schemaId().clone()), resolver); - this.addressSerializerWriter = (Reference b, Reference scope, + this.addressSerializerWriter = (RowBuffer b, RowCursor scope, HashMap context) -> addressSerializer.WriteBuffer(b, scope, context); } diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/GenerateBenchmarkSuite.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/GenerateBenchmarkSuite.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/GenerateBenchmarkSuite.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/GenerateBenchmarkSuite.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/JsonModelRowGenerator.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/JsonModelRowGenerator.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/JsonModelRowGenerator.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/JsonModelRowGenerator.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/Measurements.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/Measurements.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/Measurements.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/Measurements.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/MicroBenchmarkSuiteBase.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/MicroBenchmarkSuiteBase.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/MicroBenchmarkSuiteBase.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/MicroBenchmarkSuiteBase.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ProtobufRowGenerator.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ProtobufRowGenerator.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ProtobufRowGenerator.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ProtobufRowGenerator.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ReaderBenchmark.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ReaderBenchmark.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ReaderBenchmark.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/ReaderBenchmark.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/RowReaderExtensions.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/RowReaderExtensions.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/RowReaderExtensions.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/RowReaderExtensions.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/SchematizedMicroBenchmarkSuite.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/SchematizedMicroBenchmarkSuite.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/SchematizedMicroBenchmarkSuite.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/SchematizedMicroBenchmarkSuite.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/TestData.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/TestData.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/TestData.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/TestData.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/UnschematizedMicroBenchmarkSuite.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/UnschematizedMicroBenchmarkSuite.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/UnschematizedMicroBenchmarkSuite.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/UnschematizedMicroBenchmarkSuite.java diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Address.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Address.java new file mode 100644 index 0000000..6fb3816 --- /dev/null +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Address.java @@ -0,0 +1,316 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos.serialization.hybridrow.perf.cassandrahotel.protobuf; + +import com.azure.data.cosmos.serialization.hybridrow.perf.*; +import com.google.protobuf.Message; +import com.google.protobuf.Parser; + +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: TestData/CassandraHotelSchema.proto +// + +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pb = Google.Protobuf; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbc = Google.Protobuf.Collections; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbr = Google.Protobuf.Reflection; + +public final class Address implements Message

{ + /** + * Field number for the "city" field. + */ + public static final int CityFieldNumber = 2; + /** + * Field number for the "postal_code" field. + */ + public static final int PostalCodeFieldNumber = 4; + /** + * Field number for the "state" field. + */ + public static final int StateFieldNumber = 3; + /** + * Field number for the "street" field. + */ + public static final int StreetFieldNumber = 1; + private static final Parser _parser = new Address().getParserForType(); + private static final Google.Protobuf.FieldCodec _single_city_codec = Google.Protobuf.FieldCodec.ForClassWrapper(18); + + // TODO: C# TO JAVA CONVERTER: Java does not support 'partial' methods: + // partial void OnConstruction(); + private static final Google.Protobuf.FieldCodec _single_state_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(26); + private static final Google.Protobuf.FieldCodec _single_street_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(10); + private Google.Protobuf.UnknownFieldSet _unknownFields; + private String city_; + private PostalCode postalCode_; + private String state_; + private String street_; + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Address() + public Address() { + OnConstruction(); + } + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Address(Address other) + public Address(Address other) { + this(); + setStreet(other.getStreet()); + setCity(other.getCity()); + setState(other.getState()); + setPostalCode(other.postalCode_ != null ? other.getPostalCode().Clone() : null); + _unknownFields = Google.Protobuf.UnknownFieldSet.Clone(other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string City + public String getCity() { + return city_; + } + + public void setCity(String value) { + city_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor + public Google.Protobuf.Reflection getDescriptor() { + return getDescriptor(); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf.Reflection + // .MessageDescriptor Descriptor + public static Google.Protobuf.Reflection.MessageDescriptor getDescriptor() { + return CassandraHotelSchemaReflection.getDescriptor().MessageTypes[1]; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf + // .MessageParser
Parser + public static Google.Protobuf.MessageParser
getParser() { + return _parser; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Microsoft.Azure.Cosmos.Serialization + // .HybridRow.Tests.Perf.CassandraHotel.Protobuf.PostalCode PostalCode + public PostalCode getPostalCode() { + return postalCode_; + } + + public void setPostalCode(PostalCode value) { + postalCode_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string State + public String getState() { + return state_; + } + + public void setState(String value) { + state_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string Street + public String getStreet() { + return street_; + } + + public void setStreet(String value) { + street_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() + public int CalculateSize() { + int size = 0; + if (street_ != null) { + size += _single_street_codec.CalculateSizeWithTag(getStreet()); + } + if (city_ != null) { + size += _single_city_codec.CalculateSizeWithTag(getCity()); + } + if (state_ != null) { + size += _single_state_codec.CalculateSizeWithTag(getState()); + } + if (postalCode_ != null) { + size += 1 + Google.Protobuf.CodedOutputStream.ComputeMessageSize(getPostalCode()); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Address Clone() + public Address Clone() { + return new Address(this); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Address other) + public void MergeFrom(Address other) { + if (other == null) { + return; + } + if (other.street_ != null) { + if (street_ == null || !other.getStreet().equals("")) { + setStreet(other.getStreet()); + } + } + if (other.city_ != null) { + if (city_ == null || !other.getCity().equals("")) { + setCity(other.getCity()); + } + } + if (other.state_ != null) { + if (state_ == null || !other.getState().equals("")) { + setState(other.getState()); + } + } + if (other.postalCode_ != null) { + if (postalCode_ == null) { + postalCode_ = new PostalCode(); + } + getPostalCode().MergeFrom(other.getPostalCode()); + } + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Google.Protobuf + // .CodedInputStream input) + public void MergeFrom(Google.Protobuf.CodedInputStream input) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: uint tag; + int tag; + while ((tag = input.ReadTag()) != 0) { + switch (tag) { + default: + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + String value = _single_street_codec.Read(input); + if (street_ == null || !value.equals("")) { + setStreet(value); + } + break; + } + case 18: { + String value = _single_city_codec.Read(input); + if (city_ == null || !value.equals("")) { + setCity(value); + } + break; + } + case 26: { + String value = _single_state_codec.Read(input); + if (state_ == null || !value.equals("")) { + setState(value); + } + break; + } + case 34: { + if (postalCode_ == null) { + postalCode_ = new PostalCode(); + } + input.ReadMessage(postalCode_); + break; + } + } + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(Google.Protobuf + // .CodedOutputStream output) + public void WriteTo(Google.Protobuf.CodedOutputStream output) { + if (street_ != null) { + _single_street_codec.WriteTagAndValue(output, getStreet()); + } + if (city_ != null) { + _single_city_codec.WriteTagAndValue(output, getCity()); + } + if (state_ != null) { + _single_state_codec.WriteTagAndValue(output, getState()); + } + if (postalCode_ != null) { + output.WriteRawTag(34); + output.WriteMessage(getPostalCode()); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) + @Override + public boolean equals(Object other) { + return Equals(other instanceof Address ? (Address)other : null); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Address other) + public boolean equals(Address other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!getStreet().equals(other.getStreet())) { + return false; + } + if (!getCity().equals(other.getCity())) { + return false; + } + if (!getState().equals(other.getState())) { + return false; + } + if (!getPostalCode().equals(other.getPostalCode())) { + return false; + } + return Equals(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() + @Override + public int hashCode() { + int hash = 1; + if (street_ != null) { + hash ^= getStreet().hashCode(); + } + if (city_ != null) { + hash ^= getCity().hashCode(); + } + if (state_ != null) { + hash ^= getState().hashCode(); + } + if (postalCode_ != null) { + hash ^= getPostalCode().hashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.hashCode(); + } + return hash; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() + @Override + public String toString() { + return Google.Protobuf.JsonFormatter.ToDiagnosticString(this); + } + +} \ No newline at end of file diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Available_Rooms_By_Hotel_Date.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Available_Rooms_By_Hotel_Date.java new file mode 100644 index 0000000..72933cd --- /dev/null +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Available_Rooms_By_Hotel_Date.java @@ -0,0 +1,320 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos.serialization.hybridrow.perf.cassandrahotel.protobuf; + +import com.azure.data.cosmos.serialization.hybridrow.perf.*; + +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: TestData/CassandraHotelSchema.proto +// + +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pb = Google.Protobuf; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbc = Google.Protobuf.Collections; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbr = Google.Protobuf.Reflection; + +public final class Available_Rooms_By_Hotel_Date implements Google.Protobuf.IMessage { + /** + * Field number for the "date" field. + */ + public static final int DateFieldNumber = 2; + /** + * Field number for the "hotel_id" field. + */ + public static final int HotelIdFieldNumber = 1; + /** + * Field number for the "is_available" field. + */ + public static final int IsAvailableFieldNumber = 4; + /** + * Field number for the "room_number" field. + */ + public static final int RoomNumberFieldNumber = 3; + private static final Google.Protobuf.MessageParser _parser = + new Google.Protobuf.MessageParser(() -> new Available_Rooms_By_Hotel_Date()); + private static final Google.Protobuf.FieldCodec _single_date_codec = + Google.Protobuf.FieldCodec.ForStructWrapper(18); + + // TODO: C# TO JAVA CONVERTER: Java does not support 'partial' methods: + // partial void OnConstruction(); + private static final Google.Protobuf.FieldCodec _single_hotelId_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(10); + private static final Google.Protobuf.FieldCodec _single_isAvailable_codec = + Google.Protobuf.FieldCodec.ForStructWrapper(34); + private static final Google.Protobuf.FieldCodec _single_roomNumber_codec = + Google.Protobuf.FieldCodec.ForStructWrapper(26); + private Google.Protobuf.UnknownFieldSet _unknownFields; + private Long date_; + private String hotelId_; + private Boolean isAvailable_; + private Integer roomNumber_; + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Available_Rooms_By_Hotel_Date() + public Available_Rooms_By_Hotel_Date() { + OnConstruction(); + } + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Available_Rooms_By_Hotel_Date + // (Available_Rooms_By_Hotel_Date other) + public Available_Rooms_By_Hotel_Date(Available_Rooms_By_Hotel_Date other) { + this(); + setHotelId(other.getHotelId()); + setDate(other.getDate()); + setRoomNumber(other.getRoomNumber()); + setIsAvailable(other.getIsAvailable()); + _unknownFields = Google.Protobuf.UnknownFieldSet.Clone(other._unknownFields); + } + + /** + * datetime + */ + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Nullable Date + public Long getDate() { + return date_; + } + + public void setDate(Long value) { + date_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor + public Google.Protobuf.Reflection getDescriptor() { + return getDescriptor(); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf.Reflection + // .MessageDescriptor Descriptor + public static Google.Protobuf.Reflection.MessageDescriptor getDescriptor() { + return CassandraHotelSchemaReflection.getDescriptor().MessageTypes[3]; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string HotelId + public String getHotelId() { + return hotelId_; + } + + public void setHotelId(String value) { + hotelId_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Nullable IsAvailable + public Boolean getIsAvailable() { + return isAvailable_; + } + + public void setIsAvailable(Boolean value) { + isAvailable_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf + // .MessageParser Parser + public static Google.Protobuf.MessageParser getParser() { + return _parser; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Nullable RoomNumber + public Integer getRoomNumber() { + return roomNumber_; + } + + public void setRoomNumber(Integer value) { + roomNumber_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() + public int CalculateSize() { + int size = 0; + if (hotelId_ != null) { + size += _single_hotelId_codec.CalculateSizeWithTag(getHotelId()); + } + if (date_ != null) { + size += _single_date_codec.CalculateSizeWithTag(getDate()); + } + if (roomNumber_ != null) { + size += _single_roomNumber_codec.CalculateSizeWithTag(getRoomNumber()); + } + if (isAvailable_ != null) { + size += _single_isAvailable_codec.CalculateSizeWithTag(getIsAvailable()); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Available_Rooms_By_Hotel_Date Clone() + public Available_Rooms_By_Hotel_Date Clone() { + return new Available_Rooms_By_Hotel_Date(this); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom + // (Available_Rooms_By_Hotel_Date other) + public void MergeFrom(Available_Rooms_By_Hotel_Date other) { + if (other == null) { + return; + } + if (other.hotelId_ != null) { + if (hotelId_ == null || !other.getHotelId().equals("")) { + setHotelId(other.getHotelId()); + } + } + if (other.date_ != null) { + if (date_ == null || other.getDate() != 0L) { + setDate(other.getDate()); + } + } + if (other.roomNumber_ != null) { + if (roomNumber_ == null || other.getRoomNumber() != 0) { + setRoomNumber(other.getRoomNumber()); + } + } + if (other.isAvailable_ != null) { + if (isAvailable_ == null || other.getIsAvailable() != false) { + setIsAvailable(other.getIsAvailable()); + } + } + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Google.Protobuf + // .CodedInputStream input) + public void MergeFrom(Google.Protobuf.CodedInputStream input) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: uint tag; + int tag; + while ((tag = input.ReadTag()) != 0) { + switch (tag) { + default: + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + String value = _single_hotelId_codec.Read(input); + if (hotelId_ == null || !value.equals("")) { + setHotelId(value); + } + break; + } + case 18: { + Long value = _single_date_codec.Read(input); + if (date_ == null || value != 0L) { + setDate(value); + } + break; + } + case 26: { + Integer value = _single_roomNumber_codec.Read(input); + if (roomNumber_ == null || value != 0) { + setRoomNumber(value); + } + break; + } + case 34: { + Boolean value = _single_isAvailable_codec.Read(input); + if (isAvailable_ == null || value != false) { + setIsAvailable(value); + } + break; + } + } + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(Google.Protobuf + // .CodedOutputStream output) + public void WriteTo(Google.Protobuf.CodedOutputStream output) { + if (hotelId_ != null) { + _single_hotelId_codec.WriteTagAndValue(output, getHotelId()); + } + if (date_ != null) { + _single_date_codec.WriteTagAndValue(output, getDate()); + } + if (roomNumber_ != null) { + _single_roomNumber_codec.WriteTagAndValue(output, getRoomNumber()); + } + if (isAvailable_ != null) { + _single_isAvailable_codec.WriteTagAndValue(output, getIsAvailable()); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) + @Override + public boolean equals(Object other) { + return Equals(other instanceof Available_Rooms_By_Hotel_Date ? (Available_Rooms_By_Hotel_Date)other : null); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals + // (Available_Rooms_By_Hotel_Date other) + public boolean equals(Available_Rooms_By_Hotel_Date other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!getHotelId().equals(other.getHotelId())) { + return false; + } + if (getDate() != other.getDate()) { + return false; + } + if (getRoomNumber() != other.getRoomNumber()) { + return false; + } + if (getIsAvailable() != other.getIsAvailable()) { + return false; + } + return Equals(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() + @Override + public int hashCode() { + int hash = 1; + if (hotelId_ != null) { + hash ^= getHotelId().hashCode(); + } + if (date_ != null) { + hash ^= getDate().hashCode(); + } + if (roomNumber_ != null) { + hash ^= getRoomNumber().hashCode(); + } + if (isAvailable_ != null) { + hash ^= getIsAvailable().hashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.hashCode(); + } + return hash; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() + @Override + public String toString() { + return Google.Protobuf.JsonFormatter.ToDiagnosticString(this); + } + +} \ No newline at end of file diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/CassandraHotelSchemaReflection.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/CassandraHotelSchemaReflection.java new file mode 100644 index 0000000..64b58d2 --- /dev/null +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/CassandraHotelSchemaReflection.java @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos.serialization.hybridrow.perf.cassandrahotel.protobuf; + +import com.azure.data.cosmos.serialization.hybridrow.perf.*; + +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: TestData/CassandraHotelSchema.proto +// + +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pb = Google.Protobuf; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbc = Google.Protobuf.Collections; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbr = Google.Protobuf.Reflection; + + +/** + * Holder for reflection information generated from TestData/CassandraHotelSchema.proto + */ +public final class CassandraHotelSchemaReflection { + + // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: + ///#region Descriptor + + private static Google.Protobuf.Reflection.FileDescriptor descriptor; + + static { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: byte[] descriptorData = System.Convert.FromBase64String(string.Concat + // ("CiNUZXN0RGF0YS9DYXNzYW5kcmFIb3RlbFNjaGVtYS5wcm90bxJITWljcm9z", + // "b2Z0LkF6dXJlLkNvc21vcy5TZXJpYWxpemF0aW9uLkh5YnJpZFJvdy5UZXN0", + // "cy5QZXJmLkNhc3NhbmRyYUhvdGVsGh5nb29nbGUvcHJvdG9idWYvd3JhcHBl", + // "cnMucHJvdG8iYgoKUG9zdGFsQ29kZRIoCgN6aXAYASABKAsyGy5nb29nbGUu", + // "cHJvdG9idWYuSW50MzJWYWx1ZRIqCgVwbHVzNBgCIAEoCzIbLmdvb2dsZS5w", + // "cm90b2J1Zi5JbnQzMlZhbHVlIvsBCgdBZGRyZXNzEiwKBnN0cmVldBgBIAEo", + // "CzIcLmdvb2dsZS5wcm90b2J1Zi5TdHJpbmdWYWx1ZRIqCgRjaXR5GAIgASgL", + // "MhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEisKBXN0YXRlGAMgASgL", + // "MhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEmkKC3Bvc3RhbF9jb2Rl", + // "GAQgASgLMlQuTWljcm9zb2Z0LkF6dXJlLkNvc21vcy5TZXJpYWxpemF0aW9u", + // "Lkh5YnJpZFJvdy5UZXN0cy5QZXJmLkNhc3NhbmRyYUhvdGVsLlBvc3RhbENv", + // "ZGUi9QEKBkhvdGVscxIuCghob3RlbF9pZBgBIAEoCzIcLmdvb2dsZS5wcm90", + // "b2J1Zi5TdHJpbmdWYWx1ZRIqCgRuYW1lGAIgASgLMhwuZ29vZ2xlLnByb3Rv", + // "YnVmLlN0cmluZ1ZhbHVlEisKBXBob25lGAMgASgLMhwuZ29vZ2xlLnByb3Rv", + // "YnVmLlN0cmluZ1ZhbHVlEmIKB2FkZHJlc3MYBCABKAsyUS5NaWNyb3NvZnQu", + // "QXp1cmUuQ29zbW9zLlNlcmlhbGl6YXRpb24uSHlicmlkUm93LlRlc3RzLlBl", + // "cmYuQ2Fzc2FuZHJhSG90ZWwuQWRkcmVzcyLeAQodQXZhaWxhYmxlX1Jvb21z", + // "X0J5X0hvdGVsX0RhdGUSLgoIaG90ZWxfaWQYASABKAsyHC5nb29nbGUucHJv", + // "dG9idWYuU3RyaW5nVmFsdWUSKQoEZGF0ZRgCIAEoCzIbLmdvb2dsZS5wcm90", + // "b2J1Zi5JbnQ2NFZhbHVlEjAKC3Jvb21fbnVtYmVyGAMgASgLMhsuZ29vZ2xl", + // "LnByb3RvYnVmLkludDMyVmFsdWUSMAoMaXNfYXZhaWxhYmxlGAQgASgLMhou", + // "Z29vZ2xlLnByb3RvYnVmLkJvb2xWYWx1ZSKfBAoGR3Vlc3RzEi4KCGd1ZXN0", + // "X2lkGAEgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEjAKCmZp", + // "cnN0X25hbWUYAiABKAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUS", + // "LwoJbGFzdF9uYW1lGAMgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1Zh", + // "bHVlEisKBXRpdGxlGAQgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1Zh", + // "bHVlEg4KBmVtYWlscxgFIAMoCRIVCg1waG9uZV9udW1iZXJzGAYgAygJEnIK", + // "CWFkZHJlc3NlcxgHIAMoCzJfLk1pY3Jvc29mdC5BenVyZS5Db3Ntb3MuU2Vy", + // "aWFsaXphdGlvbi5IeWJyaWRSb3cuVGVzdHMuUGVyZi5DYXNzYW5kcmFIb3Rl", + // "bC5HdWVzdHMuQWRkcmVzc2VzRW50cnkSNAoOY29uZmlybV9udW1iZXIYCCAB", + // "KAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUagwEKDkFkZHJlc3Nl", + // "c0VudHJ5EgsKA2tleRgBIAEoCRJgCgV2YWx1ZRgCIAEoCzJRLk1pY3Jvc29m", + // "dC5BenVyZS5Db3Ntb3MuU2VyaWFsaXphdGlvbi5IeWJyaWRSb3cuVGVzdHMu", + // "UGVyZi5DYXNzYW5kcmFIb3RlbC5BZGRyZXNzOgI4AUJUqgJRTWljcm9zb2Z0", + // "LkF6dXJlLkNvc21vcy5TZXJpYWxpemF0aW9uLkh5YnJpZFJvdy5UZXN0cy5Q", + // "ZXJmLkNhc3NhbmRyYUhvdGVsLlByb3RvYnVmYgZwcm90bzM=")); + byte[] descriptorData = System.Convert.FromBase64String(String.Concat( + "CiNUZXN0RGF0YS9DYXNzYW5kcmFIb3RlbFNjaGVtYS5wcm90bxJITWljcm9z", + "b2Z0LkF6dXJlLkNvc21vcy5TZXJpYWxpemF0aW9uLkh5YnJpZFJvdy5UZXN0", + "cy5QZXJmLkNhc3NhbmRyYUhvdGVsGh5nb29nbGUvcHJvdG9idWYvd3JhcHBl", + "cnMucHJvdG8iYgoKUG9zdGFsQ29kZRIoCgN6aXAYASABKAsyGy5nb29nbGUu", + "cHJvdG9idWYuSW50MzJWYWx1ZRIqCgVwbHVzNBgCIAEoCzIbLmdvb2dsZS5w", + "cm90b2J1Zi5JbnQzMlZhbHVlIvsBCgdBZGRyZXNzEiwKBnN0cmVldBgBIAEo", + "CzIcLmdvb2dsZS5wcm90b2J1Zi5TdHJpbmdWYWx1ZRIqCgRjaXR5GAIgASgL", + "MhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEisKBXN0YXRlGAMgASgL", + "MhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEmkKC3Bvc3RhbF9jb2Rl", + "GAQgASgLMlQuTWljcm9zb2Z0LkF6dXJlLkNvc21vcy5TZXJpYWxpemF0aW9u", + "Lkh5YnJpZFJvdy5UZXN0cy5QZXJmLkNhc3NhbmRyYUhvdGVsLlBvc3RhbENv", + "ZGUi9QEKBkhvdGVscxIuCghob3RlbF9pZBgBIAEoCzIcLmdvb2dsZS5wcm90", + "b2J1Zi5TdHJpbmdWYWx1ZRIqCgRuYW1lGAIgASgLMhwuZ29vZ2xlLnByb3Rv", + "YnVmLlN0cmluZ1ZhbHVlEisKBXBob25lGAMgASgLMhwuZ29vZ2xlLnByb3Rv", + "YnVmLlN0cmluZ1ZhbHVlEmIKB2FkZHJlc3MYBCABKAsyUS5NaWNyb3NvZnQu", + "QXp1cmUuQ29zbW9zLlNlcmlhbGl6YXRpb24uSHlicmlkUm93LlRlc3RzLlBl", + "cmYuQ2Fzc2FuZHJhSG90ZWwuQWRkcmVzcyLeAQodQXZhaWxhYmxlX1Jvb21z", + "X0J5X0hvdGVsX0RhdGUSLgoIaG90ZWxfaWQYASABKAsyHC5nb29nbGUucHJv", + "dG9idWYuU3RyaW5nVmFsdWUSKQoEZGF0ZRgCIAEoCzIbLmdvb2dsZS5wcm90", + "b2J1Zi5JbnQ2NFZhbHVlEjAKC3Jvb21fbnVtYmVyGAMgASgLMhsuZ29vZ2xl", + "LnByb3RvYnVmLkludDMyVmFsdWUSMAoMaXNfYXZhaWxhYmxlGAQgASgLMhou", + "Z29vZ2xlLnByb3RvYnVmLkJvb2xWYWx1ZSKfBAoGR3Vlc3RzEi4KCGd1ZXN0", + "X2lkGAEgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEjAKCmZp", + "cnN0X25hbWUYAiABKAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUS", + "LwoJbGFzdF9uYW1lGAMgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1Zh", + "bHVlEisKBXRpdGxlGAQgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1Zh", + "bHVlEg4KBmVtYWlscxgFIAMoCRIVCg1waG9uZV9udW1iZXJzGAYgAygJEnIK", + "CWFkZHJlc3NlcxgHIAMoCzJfLk1pY3Jvc29mdC5BenVyZS5Db3Ntb3MuU2Vy", + "aWFsaXphdGlvbi5IeWJyaWRSb3cuVGVzdHMuUGVyZi5DYXNzYW5kcmFIb3Rl", + "bC5HdWVzdHMuQWRkcmVzc2VzRW50cnkSNAoOY29uZmlybV9udW1iZXIYCCAB", + "KAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUagwEKDkFkZHJlc3Nl", + "c0VudHJ5EgsKA2tleRgBIAEoCRJgCgV2YWx1ZRgCIAEoCzJRLk1pY3Jvc29m", + "dC5BenVyZS5Db3Ntb3MuU2VyaWFsaXphdGlvbi5IeWJyaWRSb3cuVGVzdHMu", + "UGVyZi5DYXNzYW5kcmFIb3RlbC5BZGRyZXNzOgI4AUJUqgJRTWljcm9zb2Z0", + "LkF6dXJlLkNvc21vcy5TZXJpYWxpemF0aW9uLkh5YnJpZFJvdy5UZXN0cy5Q", + "ZXJmLkNhc3NhbmRyYUhvdGVsLlByb3RvYnVmYgZwcm90bzM=")); + descriptor = Google.Protobuf.Reflection.FileDescriptor.FromGeneratedCode(descriptorData, + new Google.Protobuf.Reflection.FileDescriptor[] { Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor }, new Google.Protobuf.Reflection.GeneratedClrTypeInfo(null, new Google.Protobuf.Reflection.GeneratedClrTypeInfo[] { new Google.Protobuf.Reflection.GeneratedClrTypeInfo(PostalCode.class, PostalCode.getParser(), new String[] { "Zip", "Plus4" }, null, null, null), new Google.Protobuf.Reflection.GeneratedClrTypeInfo(Address.class, Address.getParser(), new String[] { "Street", "City", "State", "PostalCode" }, null, null, null), new Google.Protobuf.Reflection.GeneratedClrTypeInfo(Hotels.class, Hotels.getParser(), new String[] { "HotelId", "Name", "Phone", "Address" }, null, null, null), new Google.Protobuf.Reflection.GeneratedClrTypeInfo(Available_Rooms_By_Hotel_Date.class, Available_Rooms_By_Hotel_Date.getParser(), new String[] { "HotelId", "Date", "RoomNumber", "IsAvailable" }, null, null, null), new Google.Protobuf.Reflection.GeneratedClrTypeInfo(Guests.class, Guests.getParser(), new String[] { "GuestId", "FirstName", "LastName", "Title", "Emails", "PhoneNumbers", "Addresses", "ConfirmNumber" }, null, null, new Google.Protobuf.Reflection.GeneratedClrTypeInfo[] { null }) })); + } + + /** + * File descriptor for TestData/CassandraHotelSchema.proto + */ + public static Google.Protobuf.Reflection.FileDescriptor getDescriptor() { + return descriptor; + } + // TODO: C# TO JAVA CONVERTER: There is no preprocessor in Java: + ///#endregion + +} \ No newline at end of file diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Guests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Guests.java new file mode 100644 index 0000000..2b9047c --- /dev/null +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Guests.java @@ -0,0 +1,445 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos.serialization.hybridrow.perf.cassandrahotel.protobuf; + +import com.azure.data.cosmos.serialization.hybridrow.perf.*; + +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: TestData/CassandraHotelSchema.proto +// + +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pb = Google.Protobuf; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbc = Google.Protobuf.Collections; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbr = Google.Protobuf.Reflection; + +public final class Guests implements Google.Protobuf.IMessage { + /** + * Field number for the "addresses" field. + */ + public static final int AddressesFieldNumber = 7; + /** + * Field number for the "confirm_number" field. + */ + public static final int ConfirmNumberFieldNumber = 8; + /** + * Field number for the "emails" field. + */ + public static final int EmailsFieldNumber = 5; + /** + * Field number for the "first_name" field. + */ + public static final int FirstNameFieldNumber = 2; + /** + * Field number for the "guest_id" field. + */ + public static final int GuestIdFieldNumber = 1; + /** + * Field number for the "last_name" field. + */ + public static final int LastNameFieldNumber = 3; + + // TODO: C# TO JAVA CONVERTER: Java does not support 'partial' methods: + // partial void OnConstruction(); + /** + * Field number for the "phone_numbers" field. + */ + public static final int PhoneNumbersFieldNumber = 6; + /** + * Field number for the "title" field. + */ + public static final int TitleFieldNumber = 4; + private static final Google.Protobuf.Collections.MapField.Codec _map_addresses_codec = + new Google.Protobuf.Collections.MapField.Codec(Google.Protobuf.FieldCodec.ForString(10), + Google.Protobuf.FieldCodec.ForMessage(18, + Address.getParser()), 58); + private static final Google.Protobuf.MessageParser _parser = + new Google.Protobuf.MessageParser(() -> new Guests()); + private static final Google.Protobuf.FieldCodec _repeated_emails_codec = + Google.Protobuf.FieldCodec.ForString(42); + private static final Google.Protobuf.FieldCodec _repeated_phoneNumbers_codec = + Google.Protobuf.FieldCodec.ForString(50); + private static final Google.Protobuf.FieldCodec _single_confirmNumber_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(66); + private static final Google.Protobuf.FieldCodec _single_firstName_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(18); + private static final Google.Protobuf.FieldCodec _single_guestId_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(10); + private static final Google.Protobuf.FieldCodec _single_lastName_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(26); + private static final Google.Protobuf.FieldCodec _single_title_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(34); + private final Google.Protobuf.Collections.MapField addresses_ = + new Google.Protobuf.Collections.MapField(); + private final Google.Protobuf.Collections.RepeatedField emails_ = + new Google.Protobuf.Collections.RepeatedField(); + private final Google.Protobuf.Collections.RepeatedField phoneNumbers_ = + new Google.Protobuf.Collections.RepeatedField(); + private Google.Protobuf.UnknownFieldSet _unknownFields; + private String confirmNumber_; + private String firstName_; + private String guestId_; + private String lastName_; + private String title_; + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Guests() + public Guests() { + OnConstruction(); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Guests(Guests other) + public Guests(Guests other) { + this(); + setGuestId(other.getGuestId()); + setFirstName(other.getFirstName()); + setLastName(other.getLastName()); + setTitle(other.getTitle()); + emails_ = other.emails_.Clone(); + phoneNumbers_ = other.phoneNumbers_.Clone(); + addresses_ = other.addresses_.Clone(); + setConfirmNumber(other.getConfirmNumber()); + _unknownFields = Google.Protobuf.UnknownFieldSet.Clone(other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Google.Protobuf.Collections + // .MapField + // Addresses + public Google.Protobuf.Collections.MapField getAddresses() { + return addresses_; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string ConfirmNumber + public String getConfirmNumber() { + return confirmNumber_; + } + + public void setConfirmNumber(String value) { + confirmNumber_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf.Reflection + // .MessageDescriptor Descriptor + public static Google.Protobuf.Reflection.MessageDescriptor getDescriptor() { + return CassandraHotelSchemaReflection.getDescriptor().MessageTypes[4]; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor + public Google.Protobuf.Reflection getDescriptor() { + return getDescriptor(); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Google.Protobuf.Collections + // .RepeatedField Emails + public Google.Protobuf.Collections.RepeatedField getEmails() { + return emails_; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string FirstName + public String getFirstName() { + return firstName_; + } + + public void setFirstName(String value) { + firstName_ = value; + } + + /** + * guid + */ + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string GuestId + public String getGuestId() { + return guestId_; + } + + public void setGuestId(String value) { + guestId_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string LastName + public String getLastName() { + return lastName_; + } + + public void setLastName(String value) { + lastName_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf + // .MessageParser Parser + public static Google.Protobuf.MessageParser getParser() { + return _parser; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Google.Protobuf.Collections + // .RepeatedField PhoneNumbers + public Google.Protobuf.Collections.RepeatedField getPhoneNumbers() { + return phoneNumbers_; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string Title + public String getTitle() { + return title_; + } + + public void setTitle(String value) { + title_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() + public int CalculateSize() { + int size = 0; + if (guestId_ != null) { + size += _single_guestId_codec.CalculateSizeWithTag(getGuestId()); + } + if (firstName_ != null) { + size += _single_firstName_codec.CalculateSizeWithTag(getFirstName()); + } + if (lastName_ != null) { + size += _single_lastName_codec.CalculateSizeWithTag(getLastName()); + } + if (title_ != null) { + size += _single_title_codec.CalculateSizeWithTag(getTitle()); + } + size += emails_.CalculateSize(_repeated_emails_codec); + size += phoneNumbers_.CalculateSize(_repeated_phoneNumbers_codec); + size += addresses_.CalculateSize(_map_addresses_codec); + if (confirmNumber_ != null) { + size += _single_confirmNumber_codec.CalculateSizeWithTag(getConfirmNumber()); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Guests Clone() + public Guests Clone() { + return new Guests(this); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Guests other) + public void MergeFrom(Guests other) { + if (other == null) { + return; + } + if (other.guestId_ != null) { + if (guestId_ == null || !other.getGuestId().equals("")) { + setGuestId(other.getGuestId()); + } + } + if (other.firstName_ != null) { + if (firstName_ == null || !other.getFirstName().equals("")) { + setFirstName(other.getFirstName()); + } + } + if (other.lastName_ != null) { + if (lastName_ == null || !other.getLastName().equals("")) { + setLastName(other.getLastName()); + } + } + if (other.title_ != null) { + if (title_ == null || !other.getTitle().equals("")) { + setTitle(other.getTitle()); + } + } + emails_.Add(other.emails_); + phoneNumbers_.Add(other.phoneNumbers_); + addresses_.Add(other.addresses_); + if (other.confirmNumber_ != null) { + if (confirmNumber_ == null || !other.getConfirmNumber().equals("")) { + setConfirmNumber(other.getConfirmNumber()); + } + } + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Google.Protobuf + // .CodedInputStream input) + public void MergeFrom(Google.Protobuf.CodedInputStream input) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: uint tag; + int tag; + while ((tag = input.ReadTag()) != 0) { + switch (tag) { + default: + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + String value = _single_guestId_codec.Read(input); + if (guestId_ == null || !value.equals("")) { + setGuestId(value); + } + break; + } + case 18: { + String value = _single_firstName_codec.Read(input); + if (firstName_ == null || !value.equals("")) { + setFirstName(value); + } + break; + } + case 26: { + String value = _single_lastName_codec.Read(input); + if (lastName_ == null || !value.equals("")) { + setLastName(value); + } + break; + } + case 34: { + String value = _single_title_codec.Read(input); + if (title_ == null || !value.equals("")) { + setTitle(value); + } + break; + } + case 42: { + emails_.AddEntriesFrom(input, _repeated_emails_codec); + break; + } + case 50: { + phoneNumbers_.AddEntriesFrom(input, _repeated_phoneNumbers_codec); + break; + } + case 58: { + addresses_.AddEntriesFrom(input, _map_addresses_codec); + break; + } + case 66: { + String value = _single_confirmNumber_codec.Read(input); + if (confirmNumber_ == null || !value.equals("")) { + setConfirmNumber(value); + } + break; + } + } + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(Google.Protobuf + // .CodedOutputStream output) + public void WriteTo(Google.Protobuf.CodedOutputStream output) { + if (guestId_ != null) { + _single_guestId_codec.WriteTagAndValue(output, getGuestId()); + } + if (firstName_ != null) { + _single_firstName_codec.WriteTagAndValue(output, getFirstName()); + } + if (lastName_ != null) { + _single_lastName_codec.WriteTagAndValue(output, getLastName()); + } + if (title_ != null) { + _single_title_codec.WriteTagAndValue(output, getTitle()); + } + emails_.WriteTo(output, _repeated_emails_codec); + phoneNumbers_.WriteTo(output, _repeated_phoneNumbers_codec); + addresses_.WriteTo(output, _map_addresses_codec); + if (confirmNumber_ != null) { + _single_confirmNumber_codec.WriteTagAndValue(output, getConfirmNumber()); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) + @Override + public boolean equals(Object other) { + return Equals(other instanceof Guests ? (Guests)other : null); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Guests other) + public boolean equals(Guests other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!getGuestId().equals(other.getGuestId())) { + return false; + } + if (!getFirstName().equals(other.getFirstName())) { + return false; + } + if (!getLastName().equals(other.getLastName())) { + return false; + } + if (!getTitle().equals(other.getTitle())) { + return false; + } + if (!emails_.equals(other.emails_)) { + return false; + } + if (!phoneNumbers_.equals(other.phoneNumbers_)) { + return false; + } + if (!getAddresses().equals(other.getAddresses())) { + return false; + } + if (!getConfirmNumber().equals(other.getConfirmNumber())) { + return false; + } + return Equals(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() + @Override + public int hashCode() { + int hash = 1; + if (guestId_ != null) { + hash ^= getGuestId().hashCode(); + } + if (firstName_ != null) { + hash ^= getFirstName().hashCode(); + } + if (lastName_ != null) { + hash ^= getLastName().hashCode(); + } + if (title_ != null) { + hash ^= getTitle().hashCode(); + } + hash ^= emails_.hashCode(); + hash ^= phoneNumbers_.hashCode(); + hash ^= getAddresses().hashCode(); + if (confirmNumber_ != null) { + hash ^= getConfirmNumber().hashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.hashCode(); + } + return hash; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() + @Override + public String toString() { + return Google.Protobuf.JsonFormatter.ToDiagnosticString(this); + } + +} \ No newline at end of file diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Hotels.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Hotels.java new file mode 100644 index 0000000..aca3549 --- /dev/null +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/Hotels.java @@ -0,0 +1,316 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos.serialization.hybridrow.perf.cassandrahotel.protobuf; + +import com.azure.data.cosmos.serialization.hybridrow.perf.*; + +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: TestData/CassandraHotelSchema.proto +// + +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pb = Google.Protobuf; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbc = Google.Protobuf.Collections; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbr = Google.Protobuf.Reflection; + +public final class Hotels implements Google.Protobuf.IMessage { + /** + * Field number for the "address" field. + */ + public static final int AddressFieldNumber = 4; + /** + * Field number for the "hotel_id" field. + */ + public static final int HotelIdFieldNumber = 1; + /** + * Field number for the "name" field. + */ + public static final int NameFieldNumber = 2; + /** + * Field number for the "phone" field. + */ + public static final int PhoneFieldNumber = 3; + private static final Google.Protobuf.MessageParser _parser = + new Google.Protobuf.MessageParser(() -> new Hotels()); + private static final Google.Protobuf.FieldCodec _single_hotelId_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(10); + + // TODO: C# TO JAVA CONVERTER: Java does not support 'partial' methods: + // partial void OnConstruction(); + private static final Google.Protobuf.FieldCodec _single_name_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(18); + private static final Google.Protobuf.FieldCodec _single_phone_codec = + Google.Protobuf.FieldCodec.ForClassWrapper(26); + private Google.Protobuf.UnknownFieldSet _unknownFields; + private Address address_; + private String hotelId_; + private String name_; + private String phone_; + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Hotels() + public Hotels() { + OnConstruction(); + } + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Hotels(Hotels other) + public Hotels(Hotels other) { + this(); + setHotelId(other.getHotelId()); + setName(other.getName()); + setPhone(other.getPhone()); + setAddress(other.address_ != null ? other.getAddress().Clone() : null); + _unknownFields = Google.Protobuf.UnknownFieldSet.Clone(other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Microsoft.Azure.Cosmos.Serialization + // .HybridRow.Tests.Perf.CassandraHotel.Protobuf.Address Address + public Address getAddress() { + return address_; + } + + public void setAddress(Address value) { + address_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor + public Google.Protobuf.Reflection getDescriptor() { + return getDescriptor(); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf.Reflection + // .MessageDescriptor Descriptor + public static Google.Protobuf.Reflection.MessageDescriptor getDescriptor() { + return CassandraHotelSchemaReflection.getDescriptor().MessageTypes[2]; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string HotelId + public String getHotelId() { + return hotelId_; + } + + public void setHotelId(String value) { + hotelId_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name + public String getName() { + return name_; + } + + public void setName(String value) { + name_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf + // .MessageParser Parser + public static Google.Protobuf.MessageParser getParser() { + return _parser; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public string Phone + public String getPhone() { + return phone_; + } + + public void setPhone(String value) { + phone_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() + public int CalculateSize() { + int size = 0; + if (hotelId_ != null) { + size += _single_hotelId_codec.CalculateSizeWithTag(getHotelId()); + } + if (name_ != null) { + size += _single_name_codec.CalculateSizeWithTag(getName()); + } + if (phone_ != null) { + size += _single_phone_codec.CalculateSizeWithTag(getPhone()); + } + if (address_ != null) { + size += 1 + Google.Protobuf.CodedOutputStream.ComputeMessageSize(getAddress()); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Hotels Clone() + public Hotels Clone() { + return new Hotels(this); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Hotels other) + public void MergeFrom(Hotels other) { + if (other == null) { + return; + } + if (other.hotelId_ != null) { + if (hotelId_ == null || !other.getHotelId().equals("")) { + setHotelId(other.getHotelId()); + } + } + if (other.name_ != null) { + if (name_ == null || !other.getName().equals("")) { + setName(other.getName()); + } + } + if (other.phone_ != null) { + if (phone_ == null || !other.getPhone().equals("")) { + setPhone(other.getPhone()); + } + } + if (other.address_ != null) { + if (address_ == null) { + address_ = new Address(); + } + getAddress().MergeFrom(other.getAddress()); + } + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Google.Protobuf + // .CodedInputStream input) + public void MergeFrom(Google.Protobuf.CodedInputStream input) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: uint tag; + int tag; + while ((tag = input.ReadTag()) != 0) { + switch (tag) { + default: + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + String value = _single_hotelId_codec.Read(input); + if (hotelId_ == null || !value.equals("")) { + setHotelId(value); + } + break; + } + case 18: { + String value = _single_name_codec.Read(input); + if (name_ == null || !value.equals("")) { + setName(value); + } + break; + } + case 26: { + String value = _single_phone_codec.Read(input); + if (phone_ == null || !value.equals("")) { + setPhone(value); + } + break; + } + case 34: { + if (address_ == null) { + address_ = new Address(); + } + input.ReadMessage(address_); + break; + } + } + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(Google.Protobuf + // .CodedOutputStream output) + public void WriteTo(Google.Protobuf.CodedOutputStream output) { + if (hotelId_ != null) { + _single_hotelId_codec.WriteTagAndValue(output, getHotelId()); + } + if (name_ != null) { + _single_name_codec.WriteTagAndValue(output, getName()); + } + if (phone_ != null) { + _single_phone_codec.WriteTagAndValue(output, getPhone()); + } + if (address_ != null) { + output.WriteRawTag(34); + output.WriteMessage(getAddress()); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) + @Override + public boolean equals(Object other) { + return Equals(other instanceof Hotels ? (Hotels)other : null); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Hotels other) + public boolean equals(Hotels other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!getHotelId().equals(other.getHotelId())) { + return false; + } + if (!getName().equals(other.getName())) { + return false; + } + if (!getPhone().equals(other.getPhone())) { + return false; + } + if (!getAddress().equals(other.getAddress())) { + return false; + } + return Equals(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() + @Override + public int hashCode() { + int hash = 1; + if (hotelId_ != null) { + hash ^= getHotelId().hashCode(); + } + if (name_ != null) { + hash ^= getName().hashCode(); + } + if (phone_ != null) { + hash ^= getPhone().hashCode(); + } + if (address_ != null) { + hash ^= getAddress().hashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.hashCode(); + } + return hash; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() + @Override + public String toString() { + return Google.Protobuf.JsonFormatter.ToDiagnosticString(this); + } + +} \ No newline at end of file diff --git a/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/PostalCode.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/PostalCode.java new file mode 100644 index 0000000..c415172 --- /dev/null +++ b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/perf/cassandrahotel/protobuf/PostalCode.java @@ -0,0 +1,232 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos.serialization.hybridrow.perf.cassandrahotel.protobuf; + +import com.azure.data.cosmos.serialization.hybridrow.perf.*; +import com.google.protobuf.Message; +import com.google.protobuf.Parser; + +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: TestData/CassandraHotelSchema.proto +// + +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pb = Google.Protobuf; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbc = Google.Protobuf.Collections; +//C# TO JAVA CONVERTER NOTE: There is no Java equivalent to C# namespace aliases: +//using pbr = Google.Protobuf.Reflection; + +public final class PostalCode implements Message { + /** + * Field number for the "plus4" field. + */ + public static final int Plus4FieldNumber = 2; + /** + * Field number for the "zip" field. + */ + public static final int ZipFieldNumber = 1; + private static final Parser _parser = new Parser(() -> new PostalCode()); + private static final Google.Protobuf.FieldCodec _single_plus4_codec = + Google.Protobuf.FieldCodec.ForStructWrapper(18); + private static final Google.Protobuf.FieldCodec _single_zip_codec = + Google.Protobuf.FieldCodec.ForStructWrapper(10); + private Google.Protobuf.UnknownFieldSet _unknownFields; + + // TODO: C# TO JAVA CONVERTER: Java does not support 'partial' methods: + // partial void OnConstruction(); + private Integer plus4_; + private Integer zip_; + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public PostalCode() + public PostalCode() { + OnConstruction(); + } + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public PostalCode(PostalCode other) + public PostalCode(PostalCode other) { + this(); + setZip(other.getZip()); + setPlus4(other.getPlus4()); + _unknownFields = Google.Protobuf.UnknownFieldSet.Clone(other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf.Reflection + // .MessageDescriptor Descriptor + public static Google.Protobuf.Reflection.MessageDescriptor getDescriptor() { + return CassandraHotelSchemaReflection.getDescriptor().MessageTypes[0]; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor + public Google.Protobuf.Reflection getDescriptor() { + return getDescriptor(); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public static Google.Protobuf + // .MessageParser Parser + public static Google.Protobuf.MessageParser getParser() { + return _parser; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Nullable Plus4 + public Integer getPlus4() { + return plus4_; + } + + public void setPlus4(Integer value) { + plus4_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public Nullable Zip + public Integer getZip() { + return zip_; + } + + public void setZip(Integer value) { + zip_ = value; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() + public int CalculateSize() { + int size = 0; + if (zip_ != null) { + size += _single_zip_codec.CalculateSizeWithTag(getZip()); + } + if (plus4_ != null) { + size += _single_plus4_codec.CalculateSizeWithTag(getPlus4()); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public PostalCode Clone() + public PostalCode Clone() { + return new PostalCode(this); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(PostalCode other) + public void MergeFrom(PostalCode other) { + if (other == null) { + return; + } + if (other.zip_ != null) { + if (zip_ == null || other.getZip() != 0) { + setZip(other.getZip()); + } + } + if (other.plus4_ != null) { + if (plus4_ == null || other.getPlus4() != 0) { + setPlus4(other.getPlus4()); + } + } + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Google.Protobuf + // .CodedInputStream input) + public void MergeFrom(Google.Protobuf.CodedInputStream input) { + //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java: + //ORIGINAL LINE: uint tag; + int tag; + while ((tag = input.ReadTag()) != 0) { + switch (tag) { + default: + _unknownFields = Google.Protobuf.UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Integer value = _single_zip_codec.Read(input); + if (zip_ == null || value != 0) { + setZip(value); + } + break; + } + case 18: { + Integer value = _single_plus4_codec.Read(input); + if (plus4_ == null || value != 0) { + setPlus4(value); + } + break; + } + } + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(Google.Protobuf + // .CodedOutputStream output) + public void WriteTo(Google.Protobuf.CodedOutputStream output) { + if (zip_ != null) { + _single_zip_codec.WriteTagAndValue(output, getZip()); + } + if (plus4_ != null) { + _single_plus4_codec.WriteTagAndValue(output, getPlus4()); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) + @Override + public boolean equals(Object other) { + return Equals(other instanceof PostalCode ? (PostalCode)other : null); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(PostalCode other) + public boolean equals(PostalCode other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (getZip() != other.getZip()) { + return false; + } + if (getPlus4() != other.getPlus4()) { + return false; + } + return Equals(_unknownFields, other._unknownFields); + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() + @Override + public int hashCode() { + int hash = 1; + if (zip_ != null) { + hash ^= getZip().hashCode(); + } + if (plus4_ != null) { + hash ^= getPlus4().hashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.hashCode(); + } + return hash; + } + + // TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes: + //ORIGINAL LINE: [System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() + @Override + public String toString() { + return Google.Protobuf.JsonFormatter.ToDiagnosticString(this); + } + +} \ No newline at end of file diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ArrayAssert.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ArrayAssert.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ArrayAssert.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ArrayAssert.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/AssertThrowsException.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/AssertThrowsException.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/AssertThrowsException.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/AssertThrowsException.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CrossVersioningUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CrossVersioningUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CrossVersioningUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CrossVersioningUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CustomerExampleUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CustomerExampleUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CustomerExampleUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/CustomerExampleUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/DeleteRowDispatcher.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/DeleteRowDispatcher.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/DeleteRowDispatcher.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/DeleteRowDispatcher.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatchable.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatchable.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatchable.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatchable.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatcher.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatcher.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatcher.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/IDispatcher.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutCompilerUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutCompilerUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutCompilerUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutCompilerUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutTypeUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutTypeUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutTypeUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/LayoutTypeUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullRowDispatcher.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullRowDispatcher.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullRowDispatcher.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullRowDispatcher.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/NullableUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/PermuteExtensions.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/PermuteExtensions.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/PermuteExtensions.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/PermuteExtensions.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RandomGeneratorUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RandomGeneratorUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RandomGeneratorUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RandomGeneratorUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ReadRowDispatcher.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ReadRowDispatcher.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ReadRowDispatcher.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ReadRowDispatcher.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RecordIOUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ResultAssert.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ResultAssert.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ResultAssert.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/ResultAssert.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowBufferUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowBufferUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowBufferUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowBufferUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowOperationDispatcher.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowOperationDispatcher.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowOperationDispatcher.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowOperationDispatcher.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowReaderUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowWriterUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowWriterUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowWriterUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/RowWriterUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaHashUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaHashUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaHashUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaHashUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaIdUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaIdUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaIdUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaIdUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SchemaUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/SerializerUnitTest.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TaggedUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TaggedUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TaggedUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TaggedUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TupleUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedArrayUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedMapUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/TypedSetUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/UpdateOptionsUnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/UpdateOptionsUnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/UpdateOptionsUnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/UpdateOptionsUnitTests.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/WriteRowDispatcher.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Address.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Address.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Address.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Address.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/AddressSerializer.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Guest.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Guest.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Guest.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Guest.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Hotel.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Hotel.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Hotel.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/Hotel.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCode.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCode.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCode.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCode.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/customerschema/PostalCodeSerializer.java diff --git a/jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/internal/MurmurHash3UnitTests.java b/java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/internal/MurmurHash3UnitTests.java similarity index 100% rename from jre/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/internal/MurmurHash3UnitTests.java rename to java/src/test/java/com/azure/data/cosmos/serialization/hybridrow/unit/internal/MurmurHash3UnitTests.java 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 deleted file mode 100644 index 34f48ac..0000000 --- a/jre/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/LayoutScope.java +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.data.cosmos.serialization.hybridrow.layouts; - -import com.azure.data.cosmos.core.Out; -import com.azure.data.cosmos.core.Reference; -import com.azure.data.cosmos.serialization.hybridrow.Result; -import com.azure.data.cosmos.serialization.hybridrow.RowBuffer; -import com.azure.data.cosmos.serialization.hybridrow.RowCursor; -import com.azure.data.cosmos.serialization.hybridrow.RowCursors; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; - -import javax.annotation.Nonnull; - -import static com.google.common.base.Preconditions.checkNotNull; - -public abstract class LayoutScope extends LayoutType { - - private boolean isFixedArity; - private boolean isIndexedScope; - private boolean isSizedScope; - private boolean isTypedScope; - private boolean isUniqueScope; - - protected LayoutScope( - LayoutCode code, boolean immutable, boolean isSizedScope, boolean isIndexedScope, boolean isFixedArity, - boolean isUniqueScope, boolean isTypedScope - ) { - super(code, immutable, 0); - - this.isSizedScope = isSizedScope; - this.isIndexedScope = isIndexedScope; - this.isFixedArity = isFixedArity; - this.isUniqueScope = isUniqueScope; - this.isTypedScope = isTypedScope; - } - - /** - * Returns true if this is a fixed arity scope. - */ - public boolean isFixedArity() { - return this.isFixedArity; - } - - /** - * Returns true if this is an indexed scope. - */ - public boolean isIndexedScope() { - return this.isIndexedScope; - } - - /** - * Returns true if this is a sized scope. - */ - public boolean isSizedScope() { - return this.isSizedScope; - } - - /** - * Returns true if this is a typed scope. - */ - public boolean isTypedScope() { - return this.isTypedScope; - } - - /** - * Returns true if the scope's elements cannot be updated directly. - */ - public boolean isUniqueScope() { - return this.isUniqueScope; - } - - public final Result deleteScope(@Nonnull final RowBuffer b, @Nonnull final RowCursor edit) { - - Result result = LayoutType.prepareSparseDelete(b, edit, this.layoutCode()); - - if (result != Result.Success) { - return result; - } - - b.deleteSparse(edit); - return Result.Success; - } - - /** - * {@code true} if writing an item in the specified typed scope would elide the type code because it is implied by the - * type arguments - * - * @param edit a non-null {@link RowCursor} specifying a typed scope - * @return {@code true} if the type code is implied (not written); {@code false} otherwise. - */ - public boolean hasImplicitTypeCode(@Nonnull final RowCursor edit) { - checkNotNull(edit, "expected non-null edit"); - return false; - } - - public final Result ReadScope(Reference b, Reference edit, Out value) { - - Result result = LayoutType.prepareSparseRead(b, edit, this.LayoutCode); - - if (result != Result.Success) { - value.setAndGet(null); - return result; - } - - value.setAndGet(b.get().sparseIteratorReadScope(edit, - this.Immutable || edit.get().immutable() || edit.get().scopeType().isUniqueScope()).clone()); - - return Result.Success; - } - - public void ReadSparsePath(Reference row, Reference edit) { - int pathLenInBytes; - Out tempOut_pathLenInBytes = new Out(); - Out tempOut_pathOffset = new Out(); - edit.get().pathToken = row.get().ReadSparsePathLen(edit.get().layout(), edit.get().valueOffset(), tempOut_pathLenInBytes, tempOut_pathOffset); - edit.get().pathOffset = tempOut_pathOffset.get(); - pathLenInBytes = tempOut_pathLenInBytes.get(); - edit.get().valueOffset(edit.get().valueOffset() + pathLenInBytes); - } - - public void SetImplicitTypeCode(Reference edit) { - throw new NotImplementedException(); - } - - public abstract Result WriteScope( - Reference b, Reference scope, TypeArgumentList typeArgs, - Out value); - - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public abstract Result WriteScope(ref RowBuffer b, ref RowCursor scope, TypeArgumentList - // typeArgs, out RowCursor value, UpdateOptions options = UpdateOptions.Upsert); - public abstract Result WriteScope(Reference b, Reference scope, - TypeArgumentList typeArgs, Out value, - UpdateOptions options); - - public Result WriteScope(Reference b, Reference scope, - TypeArgumentList typeArgs, TContext context, WriterFunc func) { - return WriteScope(b, scope, typeArgs, context, func, UpdateOptions.Upsert); - } - - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: - //ORIGINAL LINE: public virtual Result WriteScope(ref RowBuffer b, ref RowCursor scope, - // TypeArgumentList typeArgs, TContext context, WriterFunc func, UpdateOptions options = UpdateOptions - // .Upsert) - public Result WriteScope(Reference b, Reference scope, - TypeArgumentList typeArgs, TContext context, WriterFunc func, - UpdateOptions options) { - RowCursor childScope; - // 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.WriteScope(b, scope, typeArgs.clone(), out childScope, options); - if (r != Result.Success) { - return r; - } - - Reference tempReference_childScope = - new Reference(childScope); - // TODO: C# TO JAVA CONVERTER: The following line could not be converted: - r = func == null ? null : func.Invoke(ref b, ref childScope, context) ??Result.Success; - childScope = tempReference_childScope.get(); - if (r != Result.Success) { - this.deleteScope(b, scope); - return r; - } - - Reference tempReference_childScope2 = - new Reference(childScope); - RowCursors.skip(scope.get().clone(), b, - tempReference_childScope2); - childScope = tempReference_childScope2.get(); - return Result.Success; - } - - /** - * A function to write content into a {@link RowBuffer}. - * The type of the context value passed by the caller. - * - * @param b The row to write to. - * @param scope The type of the scope to write into. - * @param context A context value provided by the caller. - * @return The result. - */ - @FunctionalInterface - public interface WriterFunc { - Result invoke(Reference b, Reference scope, TContext context); - } -} \ No newline at end of file