Interface RevisionDataInput
-
- All Superinterfaces:
java.io.DataInput
public interface RevisionDataInput extends java.io.DataInputExtension to DataInput that adds support for a few new constructs. An instance of RevisionDataInput is created for each Serialization Revision and closed when that Revision's serialization is fully consumed - it is not shared between multiple revisions. This interface is designed to be used to consume data serialized usingRevisionDataOutput.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceRevisionDataInput.ElementDeserializer<T>Defines a Function signature that can deserialize an element from a RevisionDataInput.
-
Method Summary
-
-
-
Method Detail
-
getBaseStream
java.io.InputStream getBaseStream()
Gets a pointer to the InputStream that this RevisionDataInput reads from.- Returns:
- The InputStream.
-
getRemaining
int getRemaining()
Gets the number of bytes remaining to read from theRevisionDataInput. NOTE: this may be different fromInputStream.available(); this returns the number of bytes remaining for reading from those that were declared usingRevisionDataOutput.length(int)at writing time.- Returns:
- The number of bytes remaining.
-
readCompactLong
long readCompactLong() throws java.io.IOExceptionDecodes a Long that has been serialized usingRevisionDataOutput.writeCompactLong(long). After this method is complete, the underlying InputStream may have advanced by 1, 2, 4, or 8 bytes. This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeCompactLong(long). It may throw a SerializationException (after reading 1 byte) or it may produce a result that is not as expected.- Returns:
- The decoded compact Long. This number should be in the interval [0, 2^62).
- Throws:
java.io.IOException- If an IO Exception occurred.
-
readCompactSignedLong
long readCompactSignedLong() throws java.io.IOExceptionDecodes a Long that has been serialized usingRevisionDataOutput.writeCompactSignedLong(long). After this method is complete, the underlying InputStream may have advanced by 1, 2, 4, or 8 bytes. This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeCompactSignedLong(long). It may throw a SerializationException (after reading 1 byte) or it may produce a result that is not as expected.- Returns:
- The decoded compact signed Long. This number should be in the interval [-2^61, 2^61).
- Throws:
java.io.IOException- If an IO Exception occurred.
-
readCompactInt
int readCompactInt() throws java.io.IOExceptionDecodes an Integer that has been serialized usingRevisionDataOutput.writeCompactInt(int). After this method is complete, the underlying InputStream may have advanced by 1, 2, 3, or 4 bytes. This method has undefined behavior if the data starting at the current position was not encoded using RevisionDataOutput.writeCompactInt(). It may throw a SerializationException (after reading 1 byte) or it may produce a result that is not as expected.- Returns:
- The decoded compact Integer. This number should be in the interval [0, 2^30).
- Throws:
java.io.IOException- If an IO Exception occurred.
-
readUUID
java.util.UUID readUUID() throws java.io.IOExceptionDecodes a UUID that has been serialized usingRevisionDataOutput.writeUUID(java.util.UUID). This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeUUID(java.util.UUID).- Returns:
- A new UUID.
- Throws:
java.io.IOException- If an IO Exception occurred.
-
readCollection
<T> java.util.Collection<T> readCollection(RevisionDataInput.ElementDeserializer<T> elementDeserializer) throws java.io.IOException
Decodes a generic Collection that has been serialized usingRevisionDataOutput.writeCollection(java.util.Collection<T>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<T>). The underlying type of the collection will be an ArrayList. Should a different type of Collection be desired, consider using the appropriate overload of this method. This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeCollection(java.util.Collection<T>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<T>).- Type Parameters:
T- Type of the elements in the Collection.- Parameters:
elementDeserializer- A Function that will decode a single element of the Collection from the given RevisionDataInput.- Returns:
- A new Collection. If the original collection passed to
RevisionDataOutput.writeCollection(java.util.Collection<T>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<T>)was null, this will return an empty collection. - Throws:
java.io.IOException- If an IO Exception occurred.
-
readCollection
<T,C extends java.util.Collection<T>> C readCollection(RevisionDataInput.ElementDeserializer<T> elementDeserializer, java.util.function.Supplier<C> newCollection) throws java.io.IOException
Decodes a specific Collection that has been serialized usingRevisionDataOutput.writeCollection(java.util.Collection<T>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<T>). This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeCollection(java.util.Collection<T>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<T>).- Type Parameters:
T- Type of the elements in the Collection.C- Type of the Collection desired to be instantiated and returned.- Parameters:
elementDeserializer- A Function that will decode a single element of the Collection from the given RevisionDataInput.newCollection- A Supplier that will create a new instance of the Collection type desired.- Returns:
- A new Collection. If the original Collection passed to
RevisionDataOutput.writeCollection(java.util.Collection<T>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<T>)was null, this will return an empty collection. - Throws:
java.io.IOException- If an IO Exception occurred.
-
readCollection
<T,C extends com.google.common.collect.ImmutableCollection<T>> void readCollection(RevisionDataInput.ElementDeserializer<T> elementDeserializer, com.google.common.collect.ImmutableCollection.Builder<T> newCollectionBuilder) throws java.io.IOException
Decodes a specific Collection that has been serialized usingRevisionDataOutput.writeCollection(java.util.Collection<T>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<T>). It populates the supplied builder with the deserialized collection elements. This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeCollection(java.util.Collection<T>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<T>).- Type Parameters:
T- Type of the elements in the Collection.C- Type of the Collection whose builder needs to be populated.- Parameters:
elementDeserializer- A Function that will decode a single element of the Collection from the given RevisionDataInput.newCollectionBuilder- AImmutableCollection.Builderthat will create a new instance of theImmutableCollectionof desired type.- Throws:
java.io.IOException- If an IO Exception occurred.
-
readArray
<T> T[] readArray(RevisionDataInput.ElementDeserializer<T> elementDeserializer, java.util.function.IntFunction<T[]> newArray) throws java.io.IOException
Decodes a specific array that has been serialized usingRevisionDataOutput.writeArray(Object[], RevisionDataOutput.ElementSerializer). This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeArray(Object[], RevisionDataOutput.ElementSerializer).- Type Parameters:
T- Type of the elements in the array.- Parameters:
elementDeserializer- A Function that will decode a single element of the Collection from the given RevisionDataInput.newArray- A Function that will create a new instance of the array type desired, with the specified length.- Returns:
- A new array. If the original array passed to
RevisionDataOutput.writeArray(T[], io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<T>)was null, this will return an empty array. - Throws:
java.io.IOException- If an IO Exception occurred.
-
readArray
byte[] readArray() throws java.io.IOExceptionDecodes a byte array that has been serialized usingRevisionDataOutput.writeArray(byte[]). This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeArray(byte[]).- Returns:
- A new byte array. If the original array passed to
RevisionDataOutput.writeArray(byte[])was null, this will return an empty array. - Throws:
java.io.IOException- If an IO Exception occurred.
-
readMap
<K,V> java.util.Map<K,V> readMap(RevisionDataInput.ElementDeserializer<K> keyDeserializer, RevisionDataInput.ElementDeserializer<V> valueDeserializer) throws java.io.IOException
Decodes a generic Map that has been serialized usingRevisionDataOutput.writeMap(java.util.Map<K, V>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<K>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<V>). The underlying type of the map will be a HashMap. Should a different type of Map be desired, consider using the appropriate overload of this method. This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeMap(java.util.Map<K, V>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<K>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<V>).- Type Parameters:
K- Type of the Keys in the Map.V- Type of the Values in the Map.- Parameters:
keyDeserializer- A Function that will decode a single Key of the Map from the given RevisionDataInput.valueDeserializer- A Function that will decode a single Value of the Map from the given RevisionDataInput.- Returns:
- A new Map. If the original Map passed to
RevisionDataOutput.writeMap(java.util.Map<K, V>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<K>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<V>)was null, this will return an empty map. - Throws:
java.io.IOException- If an IOException occurred.
-
readMap
<K,V,M extends java.util.Map<K,V>> M readMap(RevisionDataInput.ElementDeserializer<K> keyDeserializer, RevisionDataInput.ElementDeserializer<V> valueDeserializer, java.util.function.Supplier<M> newMap) throws java.io.IOException
Decodes a specific Map that has been serialized usingRevisionDataOutput.writeMap(java.util.Map<K, V>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<K>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<V>). This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeMap(java.util.Map<K, V>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<K>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<V>).- Type Parameters:
K- Type of the Keys in the Map.V- Type of the Values in the Map.M- Type of the Map desired to be instantiated and returned.- Parameters:
keyDeserializer- A Function that will decode a single Key of the Map from the given RevisionDataInput.valueDeserializer- A Function that will decode a single Value of the Map from the given RevisionDataInput.newMap- A Supplier that will create a new instance of the Map type desired.- Returns:
- A new Map. If the original Map passed to
RevisionDataOutput.writeMap(java.util.Map<K, V>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<K>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<V>)was null, this will return an empty map. - Throws:
java.io.IOException- If an IOException occurred.
-
readMap
<K,V,M extends com.google.common.collect.ImmutableMap<K,V>> void readMap(RevisionDataInput.ElementDeserializer<K> keyDeserializer, RevisionDataInput.ElementDeserializer<V> valueDeserializer, com.google.common.collect.ImmutableMap.Builder<K,V> newMapBuilder) throws java.io.IOException
Decodes a specific Map that has been serialized usingRevisionDataOutput.writeMap(java.util.Map<K, V>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<K>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<V>)and populates the supplied ImmutableMap builder and builds the immutable map. This method has undefined behavior if the data starting at the current position was not encoded usingRevisionDataOutput.writeMap(java.util.Map<K, V>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<K>, io.pravega.common.io.serialization.RevisionDataOutput.ElementSerializer<V>).- Type Parameters:
K- Type of the Keys in the Map.V- Type of the Values in the Map.M- Type of Map whose builder needs to be populated.- Parameters:
keyDeserializer- A Function that will decode a single Key of the Map from the given RevisionDataInput.valueDeserializer- A Function that will decode a single Value of the Map from the given RevisionDataInput.newMapBuilder- AnImmutableMap.Builderthat will create a new instance of theImmutableMaptype desired.- Throws:
java.io.IOException- If an IOException occurred.
-
-