public static BigInteger readBigInteger(DataInputView source) throws IOException { final int len = source.readInt(); if (len < 4) { switch (len) { case 0: return null; case 1: return BigInteger.ZERO; case 2: return BigInteger.ONE; case 3: return BigInteger.TEN; } } final byte[] bytes = new byte[len - 4]; source.read(bytes); return new BigInteger(bytes); }
/** * Constructs a new {@code Context} by reading from a {@link DataInputView} that contains a * serialized context that we wrote in {@link * #writeToState(StateBackend.CheckpointStateOutputView)} */ @SuppressWarnings("unchecked") protected Context(DataInputView in, ClassLoader userClassloader) throws Exception { this.key = keySerializer.deserialize(in); this.window = windowSerializer.deserialize(in); this.watermarkTimer = in.readLong(); this.processingTimeTimer = in.readLong(); int stateSize = in.readInt(); byte[] stateData = new byte[stateSize]; in.read(stateData); state = InstantiationUtil.deserializeObject(stateData, userClassloader); this.windowBuffer = windowBufferFactory.create(); int numElements = in.readInt(); MultiplexingStreamRecordSerializer<IN> recordSerializer = new MultiplexingStreamRecordSerializer<>(inputSerializer); for (int i = 0; i < numElements; i++) { windowBuffer.storeElement(recordSerializer.deserialize(in).<IN>asRecord()); } }