@Override protected TypeSerializer<?>[] getNestedSerializers(MapSerializer outerSerializer) { return new TypeSerializer<?>[] { outerSerializer.getKeySerializer(), outerSerializer.getValueSerializer() }; } }
/** * Create a new {@code MapStateDescriptor} with the given name and the given type serializers. * * @param name The name of the {@code MapStateDescriptor}. * @param keySerializer The type serializer for the keys in the state. * @param valueSerializer The type serializer for the values in the state. */ public MapStateDescriptor(String name, TypeSerializer<UK> keySerializer, TypeSerializer<UV> valueSerializer) { super(name, new MapSerializer<>(keySerializer, valueSerializer), null); }
@Override public Map<K, V> copy(Map<K, V> from, Map<K, V> reuse) { return copy(from); }
/** * Gets the serializer for the keys in the state. * * @return The serializer for the keys in the state. */ public TypeSerializer<UK> getKeySerializer() { final TypeSerializer<Map<UK, UV>> rawSerializer = getSerializer(); if (!(rawSerializer instanceof MapSerializer)) { throw new IllegalStateException("Unexpected serializer type."); } return ((MapSerializer<UK, UV>) rawSerializer).getKeySerializer(); }
/** * Gets the serializer for the values in the state. * * @return The serializer for the values in the state. */ public TypeSerializer<UV> getValueSerializer() { final TypeSerializer<Map<UK, UV>> rawSerializer = getSerializer(); if (!(rawSerializer instanceof MapSerializer)) { throw new IllegalStateException("Unexpected serializer type."); } return ((MapSerializer<UK, UV>) rawSerializer).getValueSerializer(); } }
@Override public Map<K, V> deserialize(Map<K, V> reuse, DataInputView source) throws IOException { return deserialize(source); }
/** * Gets the serializer for the keys in the state. * * @return The serializer for the keys in the state. */ public TypeSerializer<UK> getKeySerializer() { final TypeSerializer<Map<UK, UV>> rawSerializer = getSerializer(); if (!(rawSerializer instanceof MapSerializer)) { throw new IllegalStateException("Unexpected serializer type."); } return ((MapSerializer<UK, UV>) rawSerializer).getKeySerializer(); }
/** * Returns the serializer for the map values in the state. * * @return The serializer for the map values in the state. */ public TypeSerializer<MV> getMapValueSerializer() { return getValueSerializer().getValueSerializer(); }
@Override public Map<K, V> deserialize(Map<K, V> reuse, DataInputView source) throws IOException { return deserialize(source); }
RocksDBMapIterator( final RocksDB db, final byte[] keyPrefixBytes, final TypeSerializer<UK> keySerializer, final TypeSerializer<UV> valueSerializer, DataInputDeserializer dataInputView) { this.db = db; this.keyPrefixBytes = keyPrefixBytes; this.keySerializer = keySerializer; this.valueSerializer = valueSerializer; this.dataInputView = dataInputView; }
@Override protected MapSerializer createOuterSerializerWithNestedSerializers(TypeSerializer<?>[] nestedSerializers) { @SuppressWarnings("unchecked") TypeSerializer<K> keySerializer = (TypeSerializer<K>) nestedSerializers[0]; @SuppressWarnings("unchecked") TypeSerializer<V> valueSerializer = (TypeSerializer<V>) nestedSerializers[1]; return new MapSerializer<>(keySerializer, valueSerializer); }
/** * Returns the serializer for the map keys in the state. * * @return The serializer for the map keys in the state. */ public TypeSerializer<MK> getMapKeySerializer() { return getValueSerializer().getKeySerializer(); }
/** * Gets the serializer for the values in the state. * * @return The serializer for the values in the state. */ public TypeSerializer<UV> getValueSerializer() { final TypeSerializer<Map<UK, UV>> rawSerializer = getSerializer(); if (!(rawSerializer instanceof MapSerializer)) { throw new IllegalStateException("Unexpected serializer type."); } return ((MapSerializer<UK, UV>) rawSerializer).getValueSerializer(); } }
@Override public Map<K, V> copy(Map<K, V> from, Map<K, V> reuse) { return copy(from); }
@Override public Map<K, V> deserialize(Map<K, V> reuse, DataInputView source) throws IOException { return deserialize(source); }
@Override public boolean equals(Object obj) { return obj == this || (obj != null && obj.getClass() == getClass() && keySerializer.equals(((MapSerializer<?, ?>) obj).getKeySerializer()) && valueSerializer.equals(((MapSerializer<?, ?>) obj).getValueSerializer())); }
@Override protected TypeSerializer<Map<Long, String>> createSerializer() { return new MapSerializer<>(LongSerializer.INSTANCE, StringSerializer.INSTANCE); }
/** * Gets the serializer for the keys in the state. * * @return The serializer for the keys in the state. */ public TypeSerializer<UK> getKeySerializer() { final TypeSerializer<Map<UK, UV>> rawSerializer = getSerializer(); if (!(rawSerializer instanceof MapSerializer)) { throw new IllegalStateException("Unexpected serializer type."); } return ((MapSerializer<UK, UV>) rawSerializer).getKeySerializer(); }
/** * Returns the serializer for the map values in the state. * * @return The serializer for the map values in the state. */ public TypeSerializer<MV> getMapValueSerializer() { return getValueSerializer().getValueSerializer(); }
@Override public Map<K, V> copy(Map<K, V> from, Map<K, V> reuse) { return copy(from); }