org.apache.flink.core.memory.DataInputView - java examples

Here are the examples of the java api org.apache.flink.core.memory.DataInputView taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : TypeSerializer.java
Copyright Apache License 2.0
Author : apache
/**
 * De-serializes a record from the given source input view.
 *
 * @param source The input view from which to read the data.
 * @return The deserialized element.
 *
 * @throws IOException Thrown, if the de-serialization encountered an I/O related error. Typically raised by the
 *                     input view, which may have an underlying I/O channel from which it reads.
 */
public abstract T deserialize(DataInputView source) throws IOException;

19 View Complete Implementation : NullMaskUtils.java
Copyright Apache License 2.0
Author : apache
public static void readIntoNullMask(int len, DataInputView source, boolean[] nullMask) throws IOException {
    int b = 0x00;
    int bytePos = 0;
    int fieldPos = 0;
    int numPos = 0;
    while (fieldPos < len) {
        // read byte
        b = source.readUnsignedByte();
        bytePos = 0;
        numPos = Math.min(8, len - fieldPos);
        while (bytePos < numPos) {
            nullMask[fieldPos + bytePos] = (b & 0x80) > 0;
            b = b << 1;
            bytePos += 1;
        }
        fieldPos += numPos;
    }
}

19 View Complete Implementation : TypeComparator.java
Copyright Apache License 2.0
Author : apache
/**
 * Reads the record back while de-normalizing the key fields. This must only be used when
 * for all the key fields the full normalized key is used, which is hinted by the
 * {@code #supportsSerializationWithKeyNormalization()} method.
 *
 * @param reuse The reuse object into which to read the record data.
 * @param source The stream from which to read the data,
 *
 * @see #supportsSerializationWithKeyNormalization()
 * @see #writeWithKeyNormalization(Object, DataOutputView)
 * @see org.apache.flink.types.NormalizableKey#copyNormalizedKey(MemorySegment, int, int)
 */
public abstract T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException;

19 View Complete Implementation : TypeSerializerSerializationUtil.java
Copyright Apache License 2.0
Author : apache
/**
 * Reads from a data input view a {@link TypeSerializer} that was previously
 * written using {@link #writeSerializer(DataOutputView, TypeSerializer)}.
 *
 * <p>If deserialization fails for any reason (corrupted serializer bytes, serializer clreplaced
 * no longer in clreplacedpath, serializer clreplaced no longer valid, etc.), an {@link IOException} is thrown.
 *
 * @param in the data input view.
 * @param userCodeClreplacedLoader the user code clreplaced loader to use.
 *
 * @param <T> Data type of the serializer.
 *
 * @return the deserialized serializer.
 */
public static <T> TypeSerializer<T> tryReadSerializer(DataInputView in, ClreplacedLoader userCodeClreplacedLoader) throws IOException {
    return tryReadSerializer(in, userCodeClreplacedLoader, false);
}

19 View Complete Implementation : PojoSerializerSnapshotData.java
Copyright Apache License 2.0
Author : apache
/**
 * Creates a {@link PojoSerializerSnapshotData} from serialized data stream.
 *
 * <p>This factory method is meant to be used in regular read paths, i.e. when reading back a snapshot
 * of the {@link PojoSerializer}. POJO fields, registered subclreplaced clreplacedes, and non-registered subclreplaced
 * clreplacedes may no longer be present anymore.
 */
static <T> PojoSerializerSnapshotData<T> createFrom(DataInputView in, ClreplacedLoader userCodeClreplacedLoader) throws IOException {
    return PojoSerializerSnapshotData.readSnapshotData(in, userCodeClreplacedLoader);
}

19 View Complete Implementation : LocalTimeComparator.java
Copyright Apache License 2.0
Author : apache
// --------------------------------------------------------------------------------------------
// Static Helpers for Date Comparison
// --------------------------------------------------------------------------------------------
public static int compareSerializedLocalTime(DataInputView firstSource, DataInputView secondSource, boolean ascendingComparison) throws IOException {
    int cmp = firstSource.readByte() - secondSource.readByte();
    if (cmp == 0) {
        cmp = firstSource.readByte() - secondSource.readByte();
        if (cmp == 0) {
            cmp = firstSource.readByte() - secondSource.readByte();
            if (cmp == 0) {
                cmp = firstSource.readInt() - secondSource.readInt();
            }
        }
    }
    return ascendingComparison ? cmp : -cmp;
}

19 View Complete Implementation : TypeSerializerSnapshotSerializationUtil.java
Copyright Apache License 2.0
Author : apache
/**
 * Reads from a data input view a {@link TypeSerializerSnapshot} that was previously
 * written using {@link TypeSerializerSnapshotSerializationUtil#writeSerializerSnapshot(DataOutputView, TypeSerializerSnapshot, TypeSerializer)}.
 *
 * @param in the data input view
 * @param userCodeClreplacedLoader the user code clreplaced loader to use
 * @param existingPriorSerializer the prior serializer. This would only be non-null if we are
 *                                restoring from a snapshot taken with Flink version <= 1.6.
 *
 * @return the read serializer configuration snapshot
 */
public static <T> TypeSerializerSnapshot<T> readSerializerSnapshot(DataInputView in, ClreplacedLoader userCodeClreplacedLoader, @Nullable TypeSerializer<T> existingPriorSerializer) throws IOException {
    final TypeSerializerSnapshotSerializationProxy<T> proxy = new TypeSerializerSnapshotSerializationProxy<>(userCodeClreplacedLoader, existingPriorSerializer);
    proxy.read(in);
    return proxy.getSerializerSnapshot();
}

19 View Complete Implementation : TypeSerializer.java
Copyright Apache License 2.0
Author : apache
/**
 * De-serializes a record from the given source input view into the given reuse record instance if mutable.
 *
 * @param reuse The record instance into which to de-serialize the data.
 * @param source The input view from which to read the data.
 * @return The deserialized element.
 *
 * @throws IOException Thrown, if the de-serialization encountered an I/O related error. Typically raised by the
 *                     input view, which may have an underlying I/O channel from which it reads.
 */
public abstract T deserialize(T reuse, DataInputView source) throws IOException;

19 View Complete Implementation : StringValueArrayComparator.java
Copyright Apache License 2.0
Author : apache
/**
 * Read the length of the next serialized {@code StringValue}.
 *
 * @param source the input view containing the record
 * @return the length of the next serialized {@code StringValue}
 * @throws IOException if the input view raised an exception when reading the length
 */
private static int readStringLength(DataInputView source) throws IOException {
    int len = source.readByte() & 0xFF;
    if (len >= HIGH_BIT) {
        int shift = 7;
        int curr;
        len = len & 0x7F;
        while ((curr = source.readByte() & 0xFF) >= HIGH_BIT) {
            len |= (curr & 0x7F) << shift;
            shift += 7;
        }
        len |= curr << shift;
    }
    return len;
}

19 View Complete Implementation : NestedSerializersSnapshotDelegate.java
Copyright Apache License 2.0
Author : apache
/**
 * Reads the composite snapshot of all the contained serializers.
 */
public static NestedSerializersSnapshotDelegate readNestedSerializerSnapshots(DataInputView in, ClreplacedLoader cl) throws IOException {
    final int magicNumber = in.readInt();
    if (magicNumber != MAGIC_NUMBER) {
        throw new IOException(String.format("Corrupt data, magic number mismatch. Expected %8x, found %8x", MAGIC_NUMBER, magicNumber));
    }
    final int version = in.readInt();
    if (version != VERSION) {
        throw new IOException("Unrecognized version: " + version);
    }
    final int numSnapshots = in.readInt();
    final TypeSerializerSnapshot<?>[] nestedSnapshots = new TypeSerializerSnapshot<?>[numSnapshots];
    for (int i = 0; i < numSnapshots; i++) {
        nestedSnapshots[i] = TypeSerializerSnapshot.readVersionedSnapshot(in, cl);
    }
    return new NestedSerializersSnapshotDelegate(nestedSnapshots);
}

19 View Complete Implementation : LinkedOptionalMapSerializer.java
Copyright Apache License 2.0
Author : apache
public static <K, V> LinkedOptionalMap<K, V> readOptionalMap(DataInputView in, BiFunctionWithException<DataInputView, String, K, IOException> keyReader, BiFunctionWithException<DataInputView, String, V, IOException> valueReader) throws IOException {
    final long header = in.readLong();
    checkState(header == HEADER, "Corrupted stream received header %s", header);
    long mapSize = in.readInt();
    LinkedOptionalMap<K, V> map = new LinkedOptionalMap<>();
    for (int i = 0; i < mapSize; i++) {
        String keyName = in.readUTF();
        final K key;
        if (in.readBoolean()) {
            key = tryReadFrame(in, keyName, keyReader);
        } else {
            key = null;
        }
        final V value;
        if (in.readBoolean()) {
            value = tryReadFrame(in, keyName, valueReader);
        } else {
            value = null;
        }
        map.put(keyName, key, value);
    }
    return map;
}

19 View Complete Implementation : SimpleVersionedSerialization.java
Copyright Apache License 2.0
Author : apache
/**
 * Deserializes the version and datum from a stream.
 *
 * <p>This method deserializes data serialized via
 * {@link #writeVersionAndSerialize(SimpleVersionedSerializer, Object, DataOutputView)}.
 *
 * <p>The first four bytes will be interpreted as the version. The next four bytes will be
 * interpreted as the length of the datum bytes, then length-many bytes will be read.
 * Finally, the datum is deserialized via the {@link SimpleVersionedSerializer#deserialize(int, byte[])}
 * method.
 *
 * @param serializer The serializer to serialize the datum with.
 * @param in The stream to deserialize from.
 */
public static <T> T readVersionAndDeSerialize(SimpleVersionedSerializer<T> serializer, DataInputView in) throws IOException {
    checkNotNull(serializer, "serializer");
    checkNotNull(in, "in");
    final int version = in.readInt();
    final int length = in.readInt();
    final byte[] data = new byte[length];
    in.readFully(data);
    return serializer.deserialize(version, data);
}

19 View Complete Implementation : InstantiationUtil.java
Copyright Apache License 2.0
Author : apache
/**
 * Loads a clreplaced by name from the given input stream and reflectively instantiates it.
 *
 * <p>This method will use {@link DataInputView#readUTF()} to read the clreplaced name, and
 * then attempt to load the clreplaced from the given ClreplacedLoader.
 *
 * @param in The stream to read the clreplaced name from.
 * @param cl The clreplaced loader to resolve the clreplaced.
 *
 * @throws IOException Thrown, if the clreplaced name could not be read, the clreplaced could not be found.
 */
public static <T> Clreplaced<T> resolveClreplacedByName(DataInputView in, ClreplacedLoader cl) throws IOException {
    return resolveClreplacedByName(in, cl, Object.clreplaced);
}

19 View Complete Implementation : TypeComparator.java
Copyright Apache License 2.0
Author : apache
/**
 * Compares two records in serialized form. The return value indicates the order of the two in the same way
 * as defined by {@link java.util.Comparator#compare(Object, Object)}.
 * <p>
 * This method may de-serialize the records or compare them directly based on their binary representation.
 *
 * @param firstSource The input view containing the first record.
 * @param secondSource The input view containing the second record.
 * @return An integer defining the oder among the objects in the same way as {@link java.util.Comparator#compare(Object, Object)}.
 * @throws IOException Thrown, if any of the input views raised an exception when reading the records.
 *
 *  @see java.util.Comparator#compare(Object, Object)
 */
public abstract int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException;

19 View Complete Implementation : StringValueArrayComparator.java
Copyright Apache License 2.0
Author : apache
/**
 * Read the next character from the serialized {@code StringValue}.
 *
 * @param source the input view containing the record
 * @return the next {@code char} of the current serialized {@code StringValue}
 * @throws IOException if the input view raised an exception when reading the length
 */
private static char readStringChar(DataInputView source) throws IOException {
    int c = source.readByte() & 0xFF;
    if (c >= HIGH_BIT) {
        int shift = 7;
        int curr;
        c = c & 0x7F;
        while ((curr = source.readByte() & 0xFF) >= HIGH_BIT) {
            c |= (curr & 0x7F) << shift;
            shift += 7;
        }
        c |= curr << shift;
    }
    return (char) c;
}

19 View Complete Implementation : PojoFieldUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Reads a field from the given {@link DataInputView}.
 *
 * <p>This read methods avoids Java serialization, by reading the clreplacedname of the field's declaring clreplaced
 * and dynamically loading it. The field is also read by field name and obtained via reflection.
 *
 * @param in the input view to read from.
 * @param userCodeClreplacedLoader the user clreplacedloader.
 *
 * @return the read field.
 */
static Field readField(DataInputView in, ClreplacedLoader userCodeClreplacedLoader) throws IOException {
    Clreplaced<?> declaringClreplaced = InstantiationUtil.resolveClreplacedByName(in, userCodeClreplacedLoader);
    String fieldName = in.readUTF();
    return getField(fieldName, declaringClreplaced);
}

19 View Complete Implementation : LocalDateComparator.java
Copyright Apache License 2.0
Author : apache
// --------------------------------------------------------------------------------------------
// Static Helpers for Date Comparison
// --------------------------------------------------------------------------------------------
public static int compareSerializedLocalDate(DataInputView firstSource, DataInputView secondSource, boolean ascendingComparison) throws IOException {
    int cmp = firstSource.readInt() - secondSource.readInt();
    if (cmp == 0) {
        cmp = firstSource.readByte() - secondSource.readByte();
        if (cmp == 0) {
            cmp = firstSource.readByte() - secondSource.readByte();
        }
    }
    return ascendingComparison ? cmp : -cmp;
}

19 View Complete Implementation : CompositeTypeSerializerSnapshot.java
Copyright Apache License 2.0
Author : apache
/**
 * Reads the outer snapshot, i.e. any information beyond the nested serializers of the outer serializer.
 *
 * <p>The base implementation of this methods reads nothing, i.e. it replacedumes that the outer serializer
 * only has nested serializers and no extra information. Otherwise, if the outer serializer contains
 * some extra information that has been persisted as part of the serializer snapshot, this
 * must be overridden. Note that this method and the corresponding methods
 * {@link #writeOuterSnapshot(DataOutputView)}, {@link #isOuterSnapshotCompatible(TypeSerializer)}
 * needs to be implemented.
 *
 * @param readOuterSnapshotVersion the read version of the outer snapshot.
 * @param in the {@link DataInputView} to read the outer snapshot from.
 * @param userCodeClreplacedLoader the user code clreplaced loader.
 */
protected void readOuterSnapshot(int readOuterSnapshotVersion, DataInputView in, ClreplacedLoader userCodeClreplacedLoader) throws IOException {
}

19 View Complete Implementation : TypeSerializerSnapshotMigrationTestBase.java
Copyright Apache License 2.0
Author : apache
private TypeSerializerSnapshot<ElementT> snapshotUnderTest() {
    DataInputView input = contentsOf(testSpecification.getSnapshotDataLocation());
    try {
        if (!testSpecification.getTestMigrationVersion().isNewerVersionThan(MigrationVersion.v1_6)) {
            return readPre17SnapshotFormat(input);
        } else {
            return readSnapshot(input);
        }
    } catch (IOException e) {
        throw new RuntimeException("Unable to read " + testSpecification.getSnapshotDataLocation(), e);
    }
}

19 View Complete Implementation : TypeSerializerUpgradeTestBase.java
Copyright Apache License 2.0
Author : apache
/**
 * replacederts that a given {@link TypeSerializer} is valid, given a {@link DataInputView} of serialized data.
 *
 * <p>A serializer is valid, iff:
 * <ul>
 *     <li>1. The serializer can read and then write again the given serialized data.
 *     <li>2. The serializer can produce a serializer snapshot which can be written and then read back again.
 *     <li>3. The serializer's produced snapshot is capable of creating a restore serializer.
 *     <li>4. The restore serializer created from the serializer snapshot can read and then
 *            write again data written by step 1.
 * </ul>
 */
private static <T> void replacedertSerializerIsValid(TypeSerializer<T> serializer, DataInputView dataInput, T expectedData) throws Exception {
    DataInputView serializedData = readAndThenWriteData(dataInput, serializer, serializer, expectedData);
    TypeSerializerSnapshot<T> snapshot = writeAndThenReadSerializerSnapshot(serializer);
    TypeSerializer<T> restoreSerializer = snapshot.restoreSerializer();
    readAndThenWriteData(serializedData, restoreSerializer, restoreSerializer, expectedData);
}

18 View Complete Implementation : StreamElementSerializer.java
Copyright Apache License 2.0
Author : apache
@Override
public StreamElement deserialize(DataInputView source) throws IOException {
    int tag = source.readByte();
    if (tag == TAG_REC_WITH_TIMESTAMP) {
        long timestamp = source.readLong();
        return new StreamRecord<T>(typeSerializer.deserialize(source), timestamp);
    } else if (tag == TAG_REC_WITHOUT_TIMESTAMP) {
        return new StreamRecord<T>(typeSerializer.deserialize(source));
    } else if (tag == TAG_WATERMARK) {
        return new Watermark(source.readLong());
    } else if (tag == TAG_STREAM_STATUS) {
        return new StreamStatus(source.readInt());
    } else if (tag == TAG_LATENCY_MARKER) {
        return new LatencyMarker(source.readLong(), new OperatorID(source.readLong(), source.readLong()), source.readInt());
    } else {
        throw new IOException("Corrupt stream, found tag: " + tag);
    }
}

18 View Complete Implementation : GenericTypeComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public int compareSerialized(final DataInputView firstSource, final DataInputView secondSource) throws IOException {
    if (this.reference == null) {
        this.reference = this.serializer.createInstance();
    }
    if (this.tmpReference == null) {
        this.tmpReference = this.serializer.createInstance();
    }
    this.reference = this.serializer.deserialize(this.reference, firstSource);
    this.tmpReference = this.serializer.deserialize(this.tmpReference, secondSource);
    int cmp = this.reference.compareTo(this.tmpReference);
    return this.ascending ? cmp : -cmp;
}

18 View Complete Implementation : RecordComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public int compareSerialized(DataInputView source1, DataInputView source2) throws IOException {
    this.temp1.read(source1);
    this.temp2.read(source2);
    for (int i = 0; i < this.keyFields.length; i++) {
        @SuppressWarnings("rawtypes")
        final Comparable k1 = (Comparable) this.temp1.getField(this.keyFields[i], this.keyHolders[i]);
        @SuppressWarnings("rawtypes")
        final Comparable k2 = (Comparable) this.temp2.getField(this.keyFields[i], this.transientKeyHolders[i]);
        if (k1 == null || k2 == null) {
            throw new NullKeyFieldException(this.keyFields[i]);
        }
        @SuppressWarnings("unchecked")
        final int comp = k1.compareTo(k2);
        if (comp != 0) {
            return this.ascending[i] ? comp : -comp;
        }
    }
    return 0;
}

18 View Complete Implementation : LargeObjectType.java
Copyright Apache License 2.0
Author : apache
@Override
public void read(DataInputView in) throws IOException {
    final int len = in.readInt();
    this.len = len;
    for (int i = 0; i < len / 8; i++) {
        if (in.readLong() != i) {
            throw new IOException("corrupt serialization");
        }
    }
    for (int i = 0; i < len % 8; i++) {
        if (in.readByte() != i) {
            throw new IOException("corrupt serialization");
        }
    }
}

18 View Complete Implementation : InternalTimerServiceSerializationProxy.java
Copyright Apache License 2.0
Author : apache
@Override
protected void read(DataInputView in, boolean wasVersioned) throws IOException {
    int noOfTimerServices = in.readInt();
    for (int i = 0; i < noOfTimerServices; i++) {
        String serviceName = in.readUTF();
        int readerVersion = wasVersioned ? getReadVersion() : InternalTimersSnapshotReaderWriters.NO_VERSION;
        InternalTimersSnapshot<?, ?> restoredTimersSnapshot = InternalTimersSnapshotReaderWriters.getReaderForVersion(readerVersion, userCodeClreplacedLoader).readTimersSnapshot(in);
        InternalTimerServiceImpl<K, ?> timerService = registerOrGetTimerService(serviceName, restoredTimersSnapshot);
        timerService.restoreTimersForKeyGroup(restoredTimersSnapshot, keyGroupIdx);
    }
}

18 View Complete Implementation : RocksDBIncrementalRestoreOperation.java
Copyright Apache License 2.0
Author : apache
/**
 * Reads Flink's state meta data file from the state handle.
 */
private KeyedBackendSerializationProxy<K> readMetaData(StreamStateHandle metaStateHandle) throws Exception {
    FSDataInputStream inputStream = null;
    try {
        inputStream = metaStateHandle.openInputStream();
        cancelStreamRegistry.registerCloseable(inputStream);
        DataInputView in = new DataInputViewStreamWrapper(inputStream);
        return readMetaData(in);
    } finally {
        if (cancelStreamRegistry.unregisterCloseable(inputStream)) {
            inputStream.close();
        }
    }
}

18 View Complete Implementation : InstantComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
    final long lSeconds = firstSource.readLong();
    final long rSeconds = secondSource.readLong();
    final int comp;
    if (lSeconds == rSeconds) {
        final int lNanos = firstSource.readInt();
        final int rNanos = secondSource.readInt();
        comp = (lNanos < rNanos ? -1 : (lNanos == rNanos ? 0 : 1));
    } else {
        comp = lSeconds < rSeconds ? -1 : 1;
    }
    return ascendingComparison ? comp : -comp;
}

18 View Complete Implementation : TypeSerializerConfigSnapshot.java
Copyright Apache License 2.0
Author : apache
@Override
public final void readSnapshot(int readVersion, DataInputView in, ClreplacedLoader userCodeClreplacedLoader) throws IOException {
    if (readVersion != ADAPTER_VERSION) {
        throw new IOException("Wrong/unexpected version for the TypeSerializerConfigSnapshot: " + readVersion);
    }
    serializer = TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClreplacedLoader, true);
    // now delegate to the snapshots own reading code
    setUserCodeClreplacedLoader(userCodeClreplacedLoader);
    read(in);
}

18 View Complete Implementation : StateInitializationContextImplTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void getKeyedStateStreams() throws Exception {
    int readKeyGroupCount = 0;
    for (KeyGroupStateParreplacedionStreamProvider stateStreamProvider : initializationContext.getRawKeyedStateInputs()) {
        replacedert.replacedertNotNull(stateStreamProvider);
        try (InputStream is = stateStreamProvider.getStream()) {
            DataInputView div = new DataInputViewStreamWrapper(is);
            int val = div.readInt();
            ++readKeyGroupCount;
            replacedert.replacedertEquals(stateStreamProvider.getKeyGroupId(), val);
        }
    }
    replacedert.replacedertEquals(writtenKeyGroups, readKeyGroupCount);
}

18 View Complete Implementation : ByteValueArrayComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
    int firstCount = firstSource.readInt();
    int secondCount = secondSource.readInt();
    int minCount = Math.min(firstCount, secondCount);
    while (minCount-- > 0) {
        byte firstValue = firstSource.readByte();
        byte secondValue = secondSource.readByte();
        int cmp = Byte.compare(firstValue, secondValue);
        if (cmp != 0) {
            return ascendingComparison ? cmp : -cmp;
        }
    }
    int cmp = Integer.compare(firstCount, secondCount);
    return ascendingComparison ? cmp : -cmp;
}

18 View Complete Implementation : IntListSerializer.java
Copyright Apache License 2.0
Author : apache
@Override
public IntList deserialize(IntList record, DataInputView source) throws IOException {
    int key = source.readInt();
    record.setKey(key);
    int size = source.readInt();
    int[] value = new int[size];
    for (int i = 0; i < value.length; i++) {
        value[i] = source.readInt();
    }
    record.setValue(value);
    return record;
}

18 View Complete Implementation : InputViewIterator.java
Copyright Apache License 2.0
Author : apache
public clreplaced InputViewIterator<E> implements MutableObjecreplacederator<E> {

    private DataInputView inputView;

    private final TypeSerializer<E> serializer;

    public InputViewIterator(DataInputView inputView, TypeSerializer<E> serializer) {
        this.inputView = inputView;
        this.serializer = serializer;
    }

    @Override
    public E next(E reuse) throws IOException {
        try {
            return this.serializer.deserialize(reuse, this.inputView);
        } catch (EOFException e) {
            return null;
        }
    }

    @Override
    public E next() throws IOException {
        try {
            return this.serializer.deserialize(this.inputView);
        } catch (EOFException e) {
            return null;
        }
    }
}

18 View Complete Implementation : AvroSerializer.java
Copyright Apache License 2.0
Author : apache
@Override
public T deserialize(DataInputView source) throws IOException {
    if (CONCURRENT_ACCESS_CHECK) {
        enterExclusiveThread();
    }
    try {
        checkAvroInitialized();
        this.decoder.setIn(source);
        return this.reader.read(null, this.decoder);
    } finally {
        if (CONCURRENT_ACCESS_CHECK) {
            exitExclusiveThread();
        }
    }
}

18 View Complete Implementation : TypeSerializerSerializationUtil.java
Copyright Apache License 2.0
Author : apache
/**
 * Reads from a data input view a {@link TypeSerializer} that was previously
 * written using {@link #writeSerializer(DataOutputView, TypeSerializer)}.
 *
 * <p>If deserialization fails due to any exception, users can opt to use a dummy
 * {@link UnloadableDummyTypeSerializer} to hold the serializer bytes, otherwise an {@link IOException} is thrown.
 *
 * @param in the data input view.
 * @param userCodeClreplacedLoader the user code clreplaced loader to use.
 * @param useDummyPlaceholder whether or not to use a dummy {@link UnloadableDummyTypeSerializer} to hold the
 *                            serializer bytes in the case of a {@link ClreplacedNotFoundException} or
 *                            {@link InvalidClreplacedException}.
 *
 * @param <T> Data type of the serializer.
 *
 * @return the deserialized serializer.
 */
public static <T> TypeSerializer<T> tryReadSerializer(DataInputView in, ClreplacedLoader userCodeClreplacedLoader, boolean useDummyPlaceholder) throws IOException {
    final TypeSerializerSerializationUtil.TypeSerializerSerializationProxy<T> proxy = new TypeSerializerSerializationUtil.TypeSerializerSerializationProxy<>(userCodeClreplacedLoader);
    try {
        proxy.read(in);
        return proxy.getTypeSerializer();
    } catch (UnloadableTypeSerializerException e) {
        if (useDummyPlaceholder) {
            LOG.warn("Could not read a requested serializer. Replaced with a UnloadableDummyTypeSerializer.", e.getCause());
            return new UnloadableDummyTypeSerializer<>(e.getSerializerBytes(), e.getCause());
        } else {
            throw e;
        }
    }
}

18 View Complete Implementation : MetricDumpSerialization.java
Copyright Apache License 2.0
Author : apache
private static MetricDump.HistogramDump deserializeHistogram(DataInputView dis) throws IOException {
    QueryScopeInfo info = deserializeMetricInfo(dis);
    String name = dis.readUTF();
    long min = dis.readLong();
    long max = dis.readLong();
    double mean = dis.readDouble();
    double median = dis.readDouble();
    double stddev = dis.readDouble();
    double p75 = dis.readDouble();
    double p90 = dis.readDouble();
    double p95 = dis.readDouble();
    double p98 = dis.readDouble();
    double p99 = dis.readDouble();
    double p999 = dis.readDouble();
    return new MetricDump.HistogramDump(info, name, min, max, mean, median, stddev, p75, p90, p95, p98, p99, p999);
}

18 View Complete Implementation : IterationEventWithAggregators.java
Copyright Apache License 2.0
Author : apache
@Override
public void read(DataInputView in) throws IOException {
    int num = in.readInt();
    if (num == 0) {
        this.aggNames = NO_STRINGS;
        this.aggregates = NO_VALUES;
    } else {
        if (this.aggNames == null || num > this.aggNames.length) {
            this.aggNames = new String[num];
        }
        if (this.clreplacedNames == null || num > this.clreplacedNames.length) {
            this.clreplacedNames = new String[num];
        }
        if (this.serializedData == null || num > this.serializedData.length) {
            this.serializedData = new byte[num][];
        }
        for (int i = 0; i < num; i++) {
            this.aggNames[i] = in.readUTF();
            this.clreplacedNames[i] = in.readUTF();
            int len = in.readInt();
            byte[] data = new byte[len];
            this.serializedData[i] = data;
            in.readFully(data);
        }
        this.aggregates = null;
    }
}

18 View Complete Implementation : ValueComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
    if (reference == null) {
        reference = InstantiationUtil.instantiate(type, Value.clreplaced);
    }
    if (tempReference == null) {
        tempReference = InstantiationUtil.instantiate(type, Value.clreplaced);
    }
    reference.read(firstSource);
    tempReference.read(secondSource);
    int comp = reference.compareTo(tempReference);
    return ascendingComparison ? comp : -comp;
}

18 View Complete Implementation : GenericArraySerializer.java
Copyright Apache License 2.0
Author : apache
@Override
public C[] deserialize(DataInputView source) throws IOException {
    int len = source.readInt();
    C[] array = create(len);
    for (int i = 0; i < len; i++) {
        boolean isNonNull = source.readBoolean();
        if (isNonNull) {
            array[i] = componentSerializer.deserialize(source);
        } else {
            array[i] = null;
        }
    }
    return array;
}

18 View Complete Implementation : CopyableValueComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
    if (tempReference == null) {
        tempReference = InstantiationUtil.instantiate(type, CopyableValue.clreplaced);
    }
    reference.read(firstSource);
    tempReference.read(secondSource);
    int comp = reference.compareTo(tempReference);
    return ascendingComparison ? comp : -comp;
}

18 View Complete Implementation : GenericArraySerializerConfigSnapshot.java
Copyright Apache License 2.0
Author : apache
@Override
public void readSnapshot(int readVersion, DataInputView in, ClreplacedLoader clreplacedLoader) throws IOException {
    switch(readVersion) {
        case 1:
            readV1(in, clreplacedLoader);
            break;
        case 2:
            readV2(in, clreplacedLoader);
            break;
        default:
            throw new IllegalArgumentException("Unrecognized version: " + readVersion);
    }
}

18 View Complete Implementation : FloatValueArrayComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
    int firstCount = firstSource.readInt();
    int secondCount = secondSource.readInt();
    int minCount = Math.min(firstCount, secondCount);
    while (minCount-- > 0) {
        float firstValue = firstSource.readFloat();
        float secondValue = secondSource.readFloat();
        int cmp = Float.compare(firstValue, secondValue);
        if (cmp != 0) {
            return ascendingComparison ? cmp : -cmp;
        }
    }
    int cmp = Integer.compare(firstCount, secondCount);
    return ascendingComparison ? cmp : -cmp;
}

18 View Complete Implementation : StringValue.java
Copyright Apache License 2.0
Author : apache
// --------------------------------------------------------------------------------------------
// Serialization / De-Serialization
// --------------------------------------------------------------------------------------------
@Override
public void read(final DataInputView in) throws IOException {
    int len = in.readUnsignedByte();
    if (len >= HIGH_BIT) {
        int shift = 7;
        int curr;
        len = len & 0x7f;
        while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
            len |= (curr & 0x7f) << shift;
            shift += 7;
        }
        len |= curr << shift;
    }
    this.len = len;
    this.hashCode = 0;
    ensureSize(len);
    final char[] data = this.value;
    for (int i = 0; i < len; i++) {
        int c = in.readUnsignedByte();
        if (c < HIGH_BIT) {
            data[i] = (char) c;
        } else {
            int shift = 7;
            int curr;
            c = c & 0x7f;
            while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
                c |= (curr & 0x7f) << shift;
                shift += 7;
            }
            c |= curr << shift;
            data[i] = (char) c;
        }
    }
}

18 View Complete Implementation : InstantiationUtil.java
Copyright Apache License 2.0
Author : apache
/**
 * Loads a clreplaced by name from the given input stream and reflectively instantiates it.
 *
 * <p>This method will use {@link DataInputView#readUTF()} to read the clreplaced name, and
 * then attempt to load the clreplaced from the given ClreplacedLoader.
 *
 * <p>The resolved clreplaced is checked to be equal to or a subtype of the given supertype
 * clreplaced.
 *
 * @param in The stream to read the clreplaced name from.
 * @param cl The clreplaced loader to resolve the clreplaced.
 * @param supertype A clreplaced that the resolved clreplaced must extend.
 *
 * @throws IOException Thrown, if the clreplaced name could not be read, the clreplaced could not be found,
 *                     or the clreplaced is not a subtype of the given supertype clreplaced.
 */
public static <T> Clreplaced<T> resolveClreplacedByName(DataInputView in, ClreplacedLoader cl, Clreplaced<? super T> supertype) throws IOException {
    final String clreplacedName = in.readUTF();
    final Clreplaced<?> rawClazz;
    try {
        rawClazz = Clreplaced.forName(clreplacedName, false, cl);
    } catch (ClreplacedNotFoundException e) {
        throw new IOException("Could not find clreplaced '" + clreplacedName + "' in clreplacedpath.", e);
    }
    if (!supertype.isreplacedignableFrom(rawClazz)) {
        throw new IOException("The clreplaced " + clreplacedName + " is not a subclreplaced of " + supertype.getName());
    }
    @SuppressWarnings("unchecked")
    Clreplaced<T> clazz = (Clreplaced<T>) rawClazz;
    return clazz;
}

18 View Complete Implementation : AvroSerializer.java
Copyright Apache License 2.0
Author : apache
@Override
public T deserialize(T reuse, DataInputView source) throws IOException {
    if (CONCURRENT_ACCESS_CHECK) {
        enterExclusiveThread();
    }
    try {
        checkAvroInitialized();
        this.decoder.setIn(source);
        return this.reader.read(reuse, this.decoder);
    } finally {
        if (CONCURRENT_ACCESS_CHECK) {
            exitExclusiveThread();
        }
    }
}

18 View Complete Implementation : ListValue.java
Copyright Apache License 2.0
Author : apache
@Override
public void read(final DataInputView in) throws IOException {
    int size = in.readInt();
    this.list.clear();
    try {
        for (; size > 0; size--) {
            final V val = this.valueClreplaced.newInstance();
            val.read(in);
            this.list.add(val);
        }
    } catch (final InstantiationException e) {
        throw new RuntimeException(e);
    } catch (final IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}

18 View Complete Implementation : EitherSerializerSnapshot.java
Copyright Apache License 2.0
Author : apache
@Override
public void readSnapshot(int readVersion, DataInputView in, ClreplacedLoader clreplacedLoader) throws IOException {
    switch(readVersion) {
        case 1:
            readV1(in, clreplacedLoader);
            break;
        case 2:
            readV2(in, clreplacedLoader);
            break;
        default:
            throw new IllegalArgumentException("Unrecognized version: " + readVersion);
    }
}

18 View Complete Implementation : IntListComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public IntList readWithKeyDenormalization(IntList record, DataInputView source) throws IOException {
    record.setKey(source.readInt() + Integer.MIN_VALUE);
    int[] value = new int[source.readInt()];
    for (int i = 0; i < value.length; i++) {
        value[i] = source.readInt();
    }
    record.setValue(value);
    return record;
}

18 View Complete Implementation : StringUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Reads a non-null String from the given input.
 *
 * @param in The input to read from
 * @return The deserialized String
 *
 * @throws IOException Thrown, if the reading or the deserialization fails.
 */
public static String readString(DataInputView in) throws IOException {
    return StringValue.readString(in);
}

18 View Complete Implementation : SqlTimestampComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
    // compare Date part
    final int comp = DateComparator.compareSerializedDate(firstSource, secondSource, ascendingComparison);
    // compare nanos
    if (comp == 0) {
        final int i1 = firstSource.readInt();
        final int i2 = secondSource.readInt();
        final int comp2 = (i1 < i2 ? -1 : (i1 == i2 ? 0 : 1));
        return ascendingComparison ? comp2 : -comp2;
    }
    return comp;
}

18 View Complete Implementation : LongValueArrayComparator.java
Copyright Apache License 2.0
Author : apache
@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
    int firstCount = firstSource.readInt();
    int secondCount = secondSource.readInt();
    int minCount = Math.min(firstCount, secondCount);
    while (minCount-- > 0) {
        long firstValue = firstSource.readLong();
        long secondValue = secondSource.readLong();
        int cmp = Long.compare(firstValue, secondValue);
        if (cmp != 0) {
            return ascendingComparison ? cmp : -cmp;
        }
    }
    int cmp = Integer.compare(firstCount, secondCount);
    return ascendingComparison ? cmp : -cmp;
}