mirror of
https://github.com/microsoft/HybridRow.git
synced 2026-01-21 02:13:18 +00:00
Progressed on port from dotnet to java
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* An immutable 128-bit hash code.
|
||||
*
|
||||
* The hash code is represented by two {@code long} values: {@link #low()} and {@link #high()}.
|
||||
*/
|
||||
@Immutable
|
||||
public class HashCode128 {
|
||||
|
||||
private final long high;
|
||||
private final long low;
|
||||
|
||||
private HashCode128(final long low, final long high) {
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
}
|
||||
|
||||
private HashCode128(ByteBuf buffer) {
|
||||
this.low = buffer.readLongLE();
|
||||
this.high = buffer.readLongLE();
|
||||
}
|
||||
|
||||
public long high() {
|
||||
return this.high;
|
||||
}
|
||||
|
||||
public long low() {
|
||||
return this.low;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static HashCode128 from(@Nonnull final byte[] buffer) {
|
||||
|
||||
checkNotNull(buffer, "expected non-null buffer");
|
||||
checkArgument(buffer.length >= 2 * Long.BYTES, "expected buffer length >= 16, not %s", buffer.length);
|
||||
|
||||
return new HashCode128(Unpooled.wrappedBuffer(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a {@link HashCode128} from a {@link ByteBuf}.
|
||||
* <p>
|
||||
* The hash code is read as a pair of long values serialized in little-endian format. The values are read from the
|
||||
* buffer's current reader index which is advanced by 16 bytes: the length of two long values.
|
||||
*
|
||||
* @param buffer The buffer from which to read the hash code.
|
||||
* @return The hash code read.
|
||||
*/
|
||||
@Nonnull
|
||||
public static HashCode128 from(@Nonnull final ByteBuf buffer) {
|
||||
|
||||
checkNotNull(buffer, "expected non-null buffer");
|
||||
|
||||
final int length = buffer.writerIndex() - buffer.readerIndex();
|
||||
checkArgument(length >= 2 * Long.BYTES, "expected at least 16 readable bytes in buffer, not %s", length);
|
||||
|
||||
return new HashCode128(buffer);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static HashCode128 of(long low, long high) {
|
||||
return new HashCode128(low, high);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.internal;
|
||||
|
||||
import com.azure.data.cosmos.core.Utf8String;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.HashCode128;
|
||||
import com.google.common.base.Utf8;
|
||||
import com.google.common.hash.HashCode;
|
||||
import com.google.common.hash.HashFunction;
|
||||
@@ -40,69 +42,50 @@ public final class Murmur3Hash {
|
||||
*
|
||||
* @param item The data to hash
|
||||
* @param seed The seed with which to initialize
|
||||
* @return The 128-bit hash represented as two 64-bit words encapsulated by a {@link Code} instance
|
||||
* @return The 128-bit hash represented as two 64-bit words encapsulated by a {@link HashCode128} instance
|
||||
*/
|
||||
public static Code Hash128(@Nonnull final String item, @Nonnull final Code seed) {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static HashCode128 Hash128(@Nonnull final String item, @Nonnull final HashCode128 seed) {
|
||||
|
||||
checkNotNull(item, "value: null, seed: %s", seed);
|
||||
checkNotNull(seed, "value: %s, seed: null", item);
|
||||
|
||||
if (item.isEmpty()) {
|
||||
Hash128(EMPTY_STRING, seed);
|
||||
return Hash128(EMPTY_STRING, seed);
|
||||
}
|
||||
|
||||
final int encodedLength = Utf8.encodedLength(item);
|
||||
ByteBuf buffer = allocator.buffer(encodedLength, encodedLength);
|
||||
Utf8String value = Utf8String.transcodeUtf16(item);
|
||||
|
||||
try {
|
||||
final int count = buffer.writeCharSequence(item, UTF_8);
|
||||
assert count == encodedLength : lenientFormat("count: %s, encodedLength: %s");
|
||||
return Hash128(buffer, seed);
|
||||
return Hash128(value.content(), seed);
|
||||
} finally {
|
||||
buffer.release();
|
||||
value.release();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a 128-bit Murmur3Hash 128-bit value for a {@link boolean} data item
|
||||
* Computes a 128-bit Murmur3Hash 128-bit value for a {@link boolean} data item.
|
||||
*
|
||||
* @param item The data to hash
|
||||
* @param seed The seed with which to initialize
|
||||
* @return The 128-bit hash represented as two 64-bit words encapsulated by a {@link Code} instance
|
||||
* @param item The data to hash.
|
||||
* @param seed The seed with which to initialize.
|
||||
* @return The 128-bit hash represented as two 64-bit words encapsulated by a {@link HashCode128} instance.
|
||||
*/
|
||||
public static Code Hash128(boolean item, Code seed) {
|
||||
public static HashCode128 Hash128(boolean item, HashCode128 seed) {
|
||||
return Murmur3Hash.Hash128(item ? TRUE : FALSE, seed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a 128-bit Murmur3Hash 128-bit value for a {@link ByteBuf} data item
|
||||
* Computes a 128-bit Murmur3Hash 128-bit value for a {@link ByteBuf} data item.
|
||||
*
|
||||
* @param item The data to hash
|
||||
* @param seed The seed with which to initialize
|
||||
* @return The 128-bit hash represented as two 64-bit words encapsulated by a {@link Code} instance
|
||||
* @return The 128-bit hash represented as two 64-bit words encapsulated by a {@link HashCode128} instance.
|
||||
*/
|
||||
public static Code Hash128(ByteBuf item, Code seed) {
|
||||
// TODO: DANOBLE: Fork and update or hack murmur3_128 to support a 128-bit seed value or push for a 32-bit seed
|
||||
HashFunction hashFunction = Hashing.murmur3_128(Long.valueOf(seed.high | 0xFFFFFFFFL).intValue());
|
||||
public static HashCode128 Hash128(ByteBuf item, HashCode128 seed) {
|
||||
// TODO: DANOBLE: Support 128-bit hash code seeds by bringing in the murmur3 hash code from the Cosmos Java SDK
|
||||
HashFunction hashFunction = Hashing.murmur3_128(Long.valueOf(seed.high() | 0xFFFFFFFFL).intValue());
|
||||
HashCode hashCode = hashFunction.hashBytes(item.array());
|
||||
return new Code(hashCode);
|
||||
}
|
||||
|
||||
@Immutable
|
||||
public static final class Code {
|
||||
|
||||
public final long low, high;
|
||||
|
||||
public Code(long low, long high) {
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
}
|
||||
|
||||
private Code(HashCode hashCode) {
|
||||
ByteBuf buffer = Unpooled.wrappedBuffer(hashCode.asBytes());
|
||||
this.low = buffer.readLongLE();
|
||||
this.high = buffer.readLongLE();
|
||||
}
|
||||
return HashCode128.from(hashCode.asBytes());
|
||||
}
|
||||
|
||||
private static final class Constant {
|
||||
|
||||
@@ -123,7 +123,7 @@ public class Schema {
|
||||
*
|
||||
* @return list of zero or more logical paths that form the partition key
|
||||
*/
|
||||
@Nonnull
|
||||
@Nullable
|
||||
public final List<PartitionKey> partitionKeys() {
|
||||
return this.partitionKeys;
|
||||
}
|
||||
@@ -140,6 +140,7 @@ public class Schema {
|
||||
*
|
||||
* @return list of zero or more logical paths that form the partition key
|
||||
*/
|
||||
@Nullable
|
||||
public final List<PrimarySortKey> primarySortKeys() {
|
||||
return this.primaryKeys;
|
||||
}
|
||||
@@ -156,6 +157,7 @@ public class Schema {
|
||||
*
|
||||
* @return list of zero or more property definitions that define the columns within the schema
|
||||
*/
|
||||
@Nonnull
|
||||
public final List<Property> properties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
@@ -3,218 +3,190 @@
|
||||
|
||||
package com.azure.data.cosmos.serialization.hybridrow.schemas;
|
||||
|
||||
import com.azure.data.cosmos.serialization.hybridrow.HashCode128;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.SchemaId;
|
||||
import com.azure.data.cosmos.serialization.hybridrow.internal.Murmur3Hash;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.base.Strings.lenientFormat;
|
||||
|
||||
public final class SchemaHash {
|
||||
|
||||
public static class Code {
|
||||
/**
|
||||
* Computes the logical hash for a logical schema.
|
||||
*
|
||||
* @param namespace The namespace within which <paramref name="schema" /> is defined.
|
||||
* @param schema The logical schema to compute the hash of.
|
||||
* @param seed The seed to initialized the hash function.
|
||||
* @return The logical 128-bit hash as a two-tuple (low, high).
|
||||
*/
|
||||
public static HashCode128 ComputeHash(Namespace namespace, Schema schema, HashCode128 seed) {
|
||||
HashCode128 hash = seed;
|
||||
|
||||
private final long low;
|
||||
private final long high;
|
||||
hash = Murmur3Hash.Hash128(schema.schemaId().value(), hash);
|
||||
hash = Murmur3Hash.Hash128(schema.type().value(), hash);
|
||||
hash = SchemaHash.ComputeHash(namespace, schema.options(), hash);
|
||||
|
||||
private Code(long low, long high) {
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
}
|
||||
if (schema.partitionKeys() != null) {
|
||||
for (PartitionKey partitionKey : schema.partitionKeys()) {
|
||||
hash = SchemaHash.ComputeHash(namespace, partitionKey, hash);
|
||||
}
|
||||
}
|
||||
|
||||
public long high() {
|
||||
return this.high;
|
||||
}
|
||||
if (schema.primarySortKeys() != null) {
|
||||
for (PrimarySortKey p : schema.primarySortKeys()) {
|
||||
hash = SchemaHash.ComputeHash(namespace, p, hash);
|
||||
}
|
||||
}
|
||||
|
||||
public long low() {
|
||||
return this.low;
|
||||
}
|
||||
}
|
||||
if (schema.staticKeys() != null) {
|
||||
for (StaticKey p : schema.staticKeys()) {
|
||||
hash = SchemaHash.ComputeHash(namespace, p, hash);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the logical hash for a logical schema.
|
||||
* @param ns The namespace within which <paramref name="schema" /> is defined.
|
||||
* @param schema The logical schema to compute the hash of.
|
||||
* @param seed The seed to initialized the hash function.
|
||||
* @return The logical 128-bit hash as a two-tuple (low, high).
|
||||
*/
|
||||
public static Code ComputeHash(Namespace ns, Schema schema, Code seed)
|
||||
{
|
||||
Code hash = seed;
|
||||
if (schema.properties() != null) {
|
||||
for (Property p : schema.properties()) {
|
||||
hash = SchemaHash.ComputeHash(namespace, p, hash);
|
||||
}
|
||||
}
|
||||
|
||||
hash = Murmur3Hash.Hash128(schema.schemaId(), hash);
|
||||
hash = Murmur3Hash.Hash128(schema.type(), hash);
|
||||
hash = SchemaHash.ComputeHash(ns, schema.options(), hash);
|
||||
return hash;
|
||||
}
|
||||
|
||||
if (schema.partitionKeys() != null)
|
||||
{
|
||||
foreach (PartitionKey p in schema.PartitionKeys)
|
||||
{
|
||||
hash = SchemaHash.ComputeHash(ns, p, hash);
|
||||
}
|
||||
}
|
||||
private static HashCode128 ComputeHash(Namespace namespace, SchemaOptions options, HashCode128 seed) {
|
||||
|
||||
if (schema.PrimarySortKeys != null)
|
||||
{
|
||||
foreach (PrimarySortKey p in schema.PrimarySortKeys)
|
||||
{
|
||||
hash = SchemaHash.ComputeHash(ns, p, hash);
|
||||
}
|
||||
}
|
||||
HashCode128 hash = seed;
|
||||
|
||||
if (schema.StaticKeys != null)
|
||||
{
|
||||
foreach (StaticKey p in schema.StaticKeys)
|
||||
{
|
||||
hash = SchemaHash.ComputeHash(ns, p, hash);
|
||||
}
|
||||
}
|
||||
hash = Murmur3Hash.Hash128(options != null && options.disallowUnschematized(), hash);
|
||||
hash = Murmur3Hash.Hash128(options != null && options.enablePropertyLevelTimestamp(), hash);
|
||||
hash = Murmur3Hash.Hash128(options != null && options.disableSystemPrefix(), hash);
|
||||
|
||||
if (schema.Properties != null)
|
||||
{
|
||||
foreach (Property p in schema.Properties)
|
||||
{
|
||||
hash = SchemaHash.ComputeHash(ns, p, hash);
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
private static HashCode128 ComputeHash(Namespace ns, Property p, HashCode128 seed) {
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Methods returning tuples are not converted by C# to Java Converter:
|
||||
// private static(ulong low, ulong high) ComputeHash(Namespace ns, SchemaOptions options, (ulong low, ulong high)
|
||||
// seed = default)
|
||||
// {
|
||||
// (ulong low, ulong high) hash = seed;
|
||||
// hash = Murmur3Hash.Hash128(options == null ? null : options.DisallowUnschematized ?? false, hash);
|
||||
// hash = Murmur3Hash.Hash128(options == null ? null : options.EnablePropertyLevelTimestamp ?? false,
|
||||
// hash);
|
||||
// if (options == null ? null : options.DisableSystemPrefix ?? false)
|
||||
// {
|
||||
// hash = Murmur3Hash.Hash128(true, hash);
|
||||
// }
|
||||
//
|
||||
// return hash;
|
||||
// }
|
||||
HashCode128 hash = seed;
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Methods returning tuples are not converted by C# to Java Converter:
|
||||
// private static(ulong low, ulong high) ComputeHash(Namespace ns, Property p, (ulong low, ulong high) seed =
|
||||
// default)
|
||||
// {
|
||||
// Contract.Requires(p != null);
|
||||
// (ulong low, ulong high) hash = seed;
|
||||
// hash = Murmur3Hash.Hash128(p.Path, hash);
|
||||
// hash = SchemaHash.ComputeHash(ns, p.PropertyType, hash);
|
||||
// return hash;
|
||||
// }
|
||||
hash = Murmur3Hash.Hash128(p.path(), hash);
|
||||
hash = SchemaHash.ComputeHash(ns, p.propertyType(), hash);
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Methods returning tuples are not converted by C# to Java Converter:
|
||||
// private static(ulong low, ulong high) ComputeHash(Namespace ns, PropertyType p, (ulong low, ulong high) seed =
|
||||
// default)
|
||||
// {
|
||||
// Contract.Requires(p != null);
|
||||
// (ulong low, ulong high) hash = seed;
|
||||
// hash = Murmur3Hash.Hash128(p.Type, hash);
|
||||
// hash = Murmur3Hash.Hash128(p.Nullable, hash);
|
||||
// if (p.ApiType != null)
|
||||
// {
|
||||
// hash = Murmur3Hash.Hash128(p.ApiType, hash);
|
||||
// }
|
||||
//
|
||||
// switch (p)
|
||||
// {
|
||||
// case PrimitivePropertyType pp:
|
||||
// hash = Murmur3Hash.Hash128(pp.Storage, hash);
|
||||
// hash = Murmur3Hash.Hash128(pp.Length, hash);
|
||||
// break;
|
||||
// case ScopePropertyType pp:
|
||||
// hash = Murmur3Hash.Hash128(pp.Immutable, hash);
|
||||
// switch (p)
|
||||
// {
|
||||
// case ArrayPropertyType spp:
|
||||
// if (spp.Items != null)
|
||||
// {
|
||||
// hash = SchemaHash.ComputeHash(ns, spp.Items, hash);
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case ObjectPropertyType spp:
|
||||
// if (spp.Properties != null)
|
||||
// {
|
||||
// foreach (Property opp in spp.Properties)
|
||||
// {
|
||||
// hash = SchemaHash.ComputeHash(ns, opp, hash);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case MapPropertyType spp:
|
||||
// if (spp.Keys != null)
|
||||
// {
|
||||
// hash = SchemaHash.ComputeHash(ns, spp.Keys, hash);
|
||||
// }
|
||||
//
|
||||
// if (spp.Values != null)
|
||||
// {
|
||||
// hash = SchemaHash.ComputeHash(ns, spp.Values, hash);
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case SetPropertyType spp:
|
||||
// if (spp.Items != null)
|
||||
// {
|
||||
// hash = SchemaHash.ComputeHash(ns, spp.Items, hash);
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case TaggedPropertyType spp:
|
||||
// if (spp.Items != null)
|
||||
// {
|
||||
// foreach (PropertyType pt in spp.Items)
|
||||
// {
|
||||
// hash = SchemaHash.ComputeHash(ns, pt, hash);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case TuplePropertyType spp:
|
||||
// if (spp.Items != null)
|
||||
// {
|
||||
// foreach (PropertyType pt in spp.Items)
|
||||
// {
|
||||
// hash = SchemaHash.ComputeHash(ns, pt, hash);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case UdtPropertyType spp:
|
||||
// Schema udtSchema;
|
||||
// if (spp.SchemaId == SchemaId.Invalid)
|
||||
// {
|
||||
// udtSchema = ns.Schemas.Find(s => s.Name == spp.Name);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// udtSchema = ns.Schemas.Find(s => s.SchemaId == spp.SchemaId);
|
||||
// if (udtSchema.Name != spp.Name)
|
||||
// {
|
||||
// throw new Exception(string.Format("Ambiguous schema reference: '{0}:{1}'", spp
|
||||
// .Name, spp.SchemaId));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (udtSchema == null)
|
||||
// {
|
||||
// throw new Exception(string.Format("Cannot resolve schema reference '{0}:{1}'", spp
|
||||
// .Name, spp.SchemaId));
|
||||
// }
|
||||
//
|
||||
// hash = SchemaHash.ComputeHash(ns, udtSchema, hash);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// return hash;
|
||||
// }
|
||||
return hash;
|
||||
}
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Methods returning tuples are not converted by C# to Java Converter:
|
||||
private static HashCode128 ComputeHash(Namespace namespace, PropertyType p, HashCode128 seed) {
|
||||
|
||||
HashCode128 hash = seed;
|
||||
|
||||
hash = Murmur3Hash.Hash128(p.type(), hash);
|
||||
hash = Murmur3Hash.Hash128(p.nullable(), hash);
|
||||
|
||||
if (p.apiType() != null) {
|
||||
hash = Murmur3Hash.Hash128(p.apiType(), hash);
|
||||
}
|
||||
|
||||
if (p instanceof PrimitivePropertyType) {
|
||||
PrimitivePropertyType pp = (PrimitivePropertyType) p;
|
||||
hash = Murmur3Hash.Hash128(pp.storage(), hash);
|
||||
hash = Murmur3Hash.Hash128(pp.length(), hash);
|
||||
return hash;
|
||||
}
|
||||
|
||||
checkState(p instanceof ScopePropertyType);
|
||||
ScopePropertyType pp = (ScopePropertyType) p;
|
||||
hash = Murmur3Hash.Hash128(pp.immutable(), hash);
|
||||
|
||||
if (p instanceof ArrayPropertyType) {
|
||||
ArrayPropertyType spp = (ArrayPropertyType) p;
|
||||
if (spp.items() != null) {
|
||||
hash = SchemaHash.ComputeHash(namespace, spp.items(), hash);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
if (p instanceof ObjectPropertyType) {
|
||||
ObjectPropertyType spp = (ObjectPropertyType) p;
|
||||
if (spp.properties() != null) {
|
||||
for (Property opp : spp.properties()) {
|
||||
hash = SchemaHash.ComputeHash(namespace, opp, hash);
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
if (p instanceof MapPropertyType) {
|
||||
|
||||
MapPropertyType spp = (MapPropertyType) p;
|
||||
|
||||
if (spp.keys() != null) {
|
||||
hash = SchemaHash.ComputeHash(namespace, spp.keys(), hash);
|
||||
}
|
||||
|
||||
if (spp.values() != null) {
|
||||
hash = SchemaHash.ComputeHash(namespace, spp.values(), hash);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
if (p instanceof SetPropertyType) {
|
||||
|
||||
SetPropertyType spp = (SetPropertyType) p;
|
||||
|
||||
if (spp.items() != null) {
|
||||
hash = SchemaHash.ComputeHash(namespace, spp.items(), hash);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
if (p instanceof TaggedPropertyType) {
|
||||
|
||||
TaggedPropertyType spp = (TaggedPropertyType) p;
|
||||
|
||||
if (spp.items() != null) {
|
||||
for (PropertyType pt : spp.items()) {
|
||||
hash = SchemaHash.ComputeHash(namespace, pt, hash);
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
if (p instanceof TuplePropertyType) {
|
||||
|
||||
TuplePropertyType spp = (TuplePropertyType) p;
|
||||
|
||||
if (spp.items() != null) {
|
||||
for (PropertyType pt : spp.items()) {
|
||||
hash = SchemaHash.ComputeHash(namespace, pt, hash);
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
if (p instanceof UdtPropertyType) {
|
||||
|
||||
UdtPropertyType spp = (UdtPropertyType) p;
|
||||
Schema udtSchema;
|
||||
|
||||
if (spp.schemaId() == SchemaId.INVALID) {
|
||||
udtSchema = namespace.schemas().Find(s = > s.name() == spp.name());
|
||||
} else {
|
||||
udtSchema = namespace.schemas().Find(s = > s.schemaId() == spp.schemaId());
|
||||
checkState(udtSchema.name().equals(spp.name()), "Ambiguous schema reference: '%s:%s'", spp.name(), spp.schemaId());
|
||||
}
|
||||
|
||||
checkState(udtSchema != null, "Cannot resolve schema reference '{0}:{1}'", spp.name(), spp.schemaId());
|
||||
return SchemaHash.ComputeHash(namespace, udtSchema, hash);
|
||||
}
|
||||
|
||||
throw new IllegalStateException(lenientFormat("unrecognized property type: %s", p.getClass()));
|
||||
}
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Methods returning tuples are not converted by C# to Java Converter:
|
||||
// private static(ulong low, ulong high) ComputeHash(Namespace ns, PartitionKey key, (ulong low, ulong high) seed
|
||||
// = default)
|
||||
// {
|
||||
|
||||
@@ -30,39 +30,39 @@ public class MurmurHash3UnitTests {
|
||||
// 0x0EB26F6D1CCEB258UL), (0xA3B6D57EBEB965D1UL, 0xE8078FCC5D8C2E3EUL), (0x91ABF587B38224F6UL,
|
||||
// 0x35899665A8A9252CUL), (0xF05B1AF0487EE2D4UL, 0x5D7496C1665DDE12UL)};
|
||||
|
||||
private static final Murmur3Hash.Code[] EXPECTED_VALUES = new Murmur3Hash.Code[] {
|
||||
new Murmur3Hash.Code(0x56F1549659CBEE1AL, 0xCEB3EE124C3E3855L),
|
||||
new Murmur3Hash.Code(0xFE84B58886F9D717L, 0xD24C5DE024F5EA6BL),
|
||||
new Murmur3Hash.Code(0x89F6250648BB11BFL, 0x95595FB9D4CF58B0L),
|
||||
new Murmur3Hash.Code(0xC76AFDB39EDC6262L, 0xB9286AF4FADAF497L),
|
||||
new Murmur3Hash.Code(0xC2CB4D9B3C9C247EL, 0xB465D40116B8B7A2L),
|
||||
new Murmur3Hash.Code(0x317178F5B26D0B35L, 0x1D564F53E2E468ADL),
|
||||
new Murmur3Hash.Code(0xE8D75F7C05F43F09L, 0xA81CEA052AE92D6FL),
|
||||
new Murmur3Hash.Code(0x8F837665508C08A8L, 0x2A74E6E47E5497BCL),
|
||||
new Murmur3Hash.Code(0x609778FDA1AFD731L, 0x3EB1A0E3BFC653E4L),
|
||||
new Murmur3Hash.Code(0x0F59B8965FA49D1AL, 0xCB3BC158243A5DEEL),
|
||||
new Murmur3Hash.Code(0x7A6D0AC9C98F5908L, 0xBC93D3042C3E7178L),
|
||||
new Murmur3Hash.Code(0x863FE5AEBA9A3DFAL, 0xDF42416658CB87C5L),
|
||||
new Murmur3Hash.Code(0xDB4C82337C8FB216L, 0xCA7616B64ABF6B3DL),
|
||||
new Murmur3Hash.Code(0x0049223177425B48L, 0x25510D7246BC3C2CL),
|
||||
new Murmur3Hash.Code(0x31AC129B24F82CABL, 0xCD7174C2040E9834L),
|
||||
new Murmur3Hash.Code(0xCE39465288116345L, 0x1CE6A26BA2E9E67DL),
|
||||
new Murmur3Hash.Code(0xD2BE55791E13DB17L, 0xCF30BF3D93B3A9FAL),
|
||||
new Murmur3Hash.Code(0x43E323DD0F079145L, 0xF06721555571ABBAL),
|
||||
new Murmur3Hash.Code(0xB0CE9F170A96F5BCL, 0x18EE95960369D702L),
|
||||
new Murmur3Hash.Code(0xBFFAF6BEBC84A2A9L, 0xE0612B6FC0C9D502L),
|
||||
new Murmur3Hash.Code(0x33E2D699697BC2DAL, 0xB7E9CD6313DE05EEL),
|
||||
new Murmur3Hash.Code(0xCBFD7D8DA2A962BFL, 0xCF4C281A7750E88AL),
|
||||
new Murmur3Hash.Code(0xBD8D863F83863088L, 0x01AFFBDE3D405D35L),
|
||||
new Murmur3Hash.Code(0xBA2E05DF3328C7DBL, 0x9620867ADDFE6579L),
|
||||
new Murmur3Hash.Code(0xC57BD1FB63CA0947L, 0xE1391F8454D4EA9FL),
|
||||
new Murmur3Hash.Code(0x6AB710460A5BF9BAL, 0x11D7E13FBEF63775L),
|
||||
new Murmur3Hash.Code(0x55C2C7C95F41C483L, 0xA4DCC9F547A89563L),
|
||||
new Murmur3Hash.Code(0x8AA5A2031027F216L, 0x1653FC7AD6CC6104L),
|
||||
new Murmur3Hash.Code(0xAD8A899FF093D9A5L, 0x0EB26F6D1CCEB258L),
|
||||
new Murmur3Hash.Code(0xA3B6D57EBEB965D1L, 0xE8078FCC5D8C2E3EL),
|
||||
new Murmur3Hash.Code(0x91ABF587B38224F6L, 0x35899665A8A9252CL),
|
||||
new Murmur3Hash.Code(0xF05B1AF0487EE2D4L, 0x5D7496C1665DDE12L) };
|
||||
private static final Murmur3Hash.HashCode128[] EXPECTED_VALUES = new Murmur3Hash.HashCode128[] {
|
||||
new Murmur3Hash.HashCode128(0x56F1549659CBEE1AL, 0xCEB3EE124C3E3855L),
|
||||
new Murmur3Hash.HashCode128(0xFE84B58886F9D717L, 0xD24C5DE024F5EA6BL),
|
||||
new Murmur3Hash.HashCode128(0x89F6250648BB11BFL, 0x95595FB9D4CF58B0L),
|
||||
new Murmur3Hash.HashCode128(0xC76AFDB39EDC6262L, 0xB9286AF4FADAF497L),
|
||||
new Murmur3Hash.HashCode128(0xC2CB4D9B3C9C247EL, 0xB465D40116B8B7A2L),
|
||||
new Murmur3Hash.HashCode128(0x317178F5B26D0B35L, 0x1D564F53E2E468ADL),
|
||||
new Murmur3Hash.HashCode128(0xE8D75F7C05F43F09L, 0xA81CEA052AE92D6FL),
|
||||
new Murmur3Hash.HashCode128(0x8F837665508C08A8L, 0x2A74E6E47E5497BCL),
|
||||
new Murmur3Hash.HashCode128(0x609778FDA1AFD731L, 0x3EB1A0E3BFC653E4L),
|
||||
new Murmur3Hash.HashCode128(0x0F59B8965FA49D1AL, 0xCB3BC158243A5DEEL),
|
||||
new Murmur3Hash.HashCode128(0x7A6D0AC9C98F5908L, 0xBC93D3042C3E7178L),
|
||||
new Murmur3Hash.HashCode128(0x863FE5AEBA9A3DFAL, 0xDF42416658CB87C5L),
|
||||
new Murmur3Hash.HashCode128(0xDB4C82337C8FB216L, 0xCA7616B64ABF6B3DL),
|
||||
new Murmur3Hash.HashCode128(0x0049223177425B48L, 0x25510D7246BC3C2CL),
|
||||
new Murmur3Hash.HashCode128(0x31AC129B24F82CABL, 0xCD7174C2040E9834L),
|
||||
new Murmur3Hash.HashCode128(0xCE39465288116345L, 0x1CE6A26BA2E9E67DL),
|
||||
new Murmur3Hash.HashCode128(0xD2BE55791E13DB17L, 0xCF30BF3D93B3A9FAL),
|
||||
new Murmur3Hash.HashCode128(0x43E323DD0F079145L, 0xF06721555571ABBAL),
|
||||
new Murmur3Hash.HashCode128(0xB0CE9F170A96F5BCL, 0x18EE95960369D702L),
|
||||
new Murmur3Hash.HashCode128(0xBFFAF6BEBC84A2A9L, 0xE0612B6FC0C9D502L),
|
||||
new Murmur3Hash.HashCode128(0x33E2D699697BC2DAL, 0xB7E9CD6313DE05EEL),
|
||||
new Murmur3Hash.HashCode128(0xCBFD7D8DA2A962BFL, 0xCF4C281A7750E88AL),
|
||||
new Murmur3Hash.HashCode128(0xBD8D863F83863088L, 0x01AFFBDE3D405D35L),
|
||||
new Murmur3Hash.HashCode128(0xBA2E05DF3328C7DBL, 0x9620867ADDFE6579L),
|
||||
new Murmur3Hash.HashCode128(0xC57BD1FB63CA0947L, 0xE1391F8454D4EA9FL),
|
||||
new Murmur3Hash.HashCode128(0x6AB710460A5BF9BAL, 0x11D7E13FBEF63775L),
|
||||
new Murmur3Hash.HashCode128(0x55C2C7C95F41C483L, 0xA4DCC9F547A89563L),
|
||||
new Murmur3Hash.HashCode128(0x8AA5A2031027F216L, 0x1653FC7AD6CC6104L),
|
||||
new Murmur3Hash.HashCode128(0xAD8A899FF093D9A5L, 0x0EB26F6D1CCEB258L),
|
||||
new Murmur3Hash.HashCode128(0xA3B6D57EBEB965D1L, 0xE8078FCC5D8C2E3EL),
|
||||
new Murmur3Hash.HashCode128(0x91ABF587B38224F6L, 0x35899665A8A9252CL),
|
||||
new Murmur3Hash.HashCode128(0xF05B1AF0487EE2D4L, 0x5D7496C1665DDE12L) };
|
||||
|
||||
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
|
||||
// ORIGINAL LINE:
|
||||
|
||||
Reference in New Issue
Block a user