private static int computeTotalByteLength( TypeSerializer<?> keySerializer, TypeSerializer<?> namespaceSerializer) { if (keySerializer.getLength() >= 0 && namespaceSerializer.getLength() >= 0) { // timestamp + key + namespace return Long.BYTES + keySerializer.getLength() + namespaceSerializer.getLength(); } else { return -1; } }
public static boolean isSerializerTypeVariableSized(@Nonnull TypeSerializer<?> serializer) { return serializer.getLength() < 0; }
public int getLength() { return (deserializer != null) ? deserializer.getLength() : serializer.getLength(); }
private NullableSerializer(@Nonnull TypeSerializer<T> originalSerializer, boolean padNullValueIfFixedLen) { this(originalSerializer, createPadding(originalSerializer.getLength(), padNullValueIfFixedLen)); }
private static int getLength(TypeSerializer<Object>[] fieldSerializers) { return Arrays.stream(fieldSerializers).allMatch(fs -> fs.getLength() > 0) ? Arrays.stream(fieldSerializers).mapToInt(TypeSerializer::getLength).sum() : -1; }
int length = serializer.getLength() > 0 ? serializer.getLength() : 1; DataOutputSerializer dos = new DataOutputSerializer(length); try { serializer.getLength() < 0 || serializer.getLength() == dos.getCopyOfBuffer().length, "The serialized form of the null value should have the same length " + "as any other if the length is fixed in the serializer");
@Test public void testSingleFieldSerializer() { TEST_FIELD_SERIALIZERS.forEach(t -> { @SuppressWarnings("unchecked") TypeSerializer<Object>[] fieldSerializers = new TypeSerializer[] { t.f0 }; List<Object>[] instances = Arrays.stream(t.f1) .map(Arrays::asList) .toArray((IntFunction<List<Object>[]>) List[]::new); runTests(t.f0.getLength(), fieldSerializers, instances); }); }
static PrecomputedParameters precompute( boolean immutableTargetType, TypeSerializer<Object>[] fieldSerializers) { Preconditions.checkNotNull(fieldSerializers); int totalLength = 0; boolean fieldsImmutable = true; boolean stateful = false; for (TypeSerializer<Object> fieldSerializer : fieldSerializers) { Preconditions.checkNotNull(fieldSerializer); if (fieldSerializer != fieldSerializer.duplicate()) { stateful = true; } if (!fieldSerializer.isImmutableType()) { fieldsImmutable = false; } if (fieldSerializer.getLength() < 0) { totalLength = -1; } totalLength = totalLength >= 0 ? totalLength + fieldSerializer.getLength() : totalLength; } return new PrecomputedParameters(immutableTargetType, fieldsImmutable, totalLength, stateful); } }
@Test public void testGetLength() { final int len = getLength(); if (len == 0) { fail("Broken serializer test base - zero length cannot be the expected length"); } try { TypeSerializer<T> serializer = getSerializer(); assertEquals(len, serializer.getLength()); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Exception in test: " + e.getMessage()); } }
private static int computeTotalByteLength( TypeSerializer<?> keySerializer, TypeSerializer<?> namespaceSerializer) { if (keySerializer.getLength() >= 0 && namespaceSerializer.getLength() >= 0) { // timestamp + key + namespace return Long.BYTES + keySerializer.getLength() + namespaceSerializer.getLength(); } else { return -1; } }
private static int computeTotalByteLength( TypeSerializer<?> keySerializer, TypeSerializer<?> namespaceSerializer) { if (keySerializer.getLength() >= 0 && namespaceSerializer.getLength() >= 0) { // timestamp + key + namespace return Long.BYTES + keySerializer.getLength() + namespaceSerializer.getLength(); } else { return -1; } }
@Override public int getLength() { return typeSerializer.getLength(); }
DefaultInMemorySorterFactory( @Nonnull TypeSerializerFactory<T> typeSerializerFactory, @Nonnull TypeComparator<T> typeComparator, int thresholdForInPlaceSorting) { this.typeSerializerFactory = typeSerializerFactory; this.typeComparator = typeComparator; TypeSerializer<T> typeSerializer = typeSerializerFactory.getSerializer(); this.useFixedLengthRecordSorter = typeComparator.supportsSerializationWithKeyNormalization() && typeSerializer.getLength() > 0 && typeSerializer.getLength() <= thresholdForInPlaceSorting; }
DefaultInMemorySorterFactory( @Nonnull TypeSerializerFactory<T> typeSerializerFactory, @Nonnull TypeComparator<T> typeComparator, int thresholdForInPlaceSorting) { this.typeSerializerFactory = typeSerializerFactory; this.typeComparator = typeComparator; TypeSerializer<T> typeSerializer = typeSerializerFactory.getSerializer(); this.useFixedLengthRecordSorter = typeComparator.supportsSerializationWithKeyNormalization() && typeSerializer.getLength() > 0 && typeSerializer.getLength() <= thresholdForInPlaceSorting; }
private NullableSerializer(@Nonnull TypeSerializer<T> originalSerializer, boolean padNullValueIfFixedLen) { this.originalSerializer = originalSerializer; this.padding = createPadding(originalSerializer.getLength(), padNullValueIfFixedLen); }
public HashTableProber(TypeComparator<PT> probeTypeComparator, TypePairComparator<PT, T> pairComparator) { super(probeTypeComparator, pairComparator); }
public HashTableProber(TypeComparator<PT> probeTypeComparator, TypePairComparator<PT, T> pairComparator) { super(probeTypeComparator, pairComparator); }