@Override public void write(final DataOutputView out) throws IOException { out.writeInt(this.inetAddress.getAddress().length); out.write(this.inetAddress.getAddress()); out.writeInt(this.dataPort); StringUtils.writeNullableString(fqdnHostName, out); StringUtils.writeNullableString(hostName, out); }
@Override public void write(final DataOutputView out) throws IOException { out.writeInt(this.list.size()); for (final V value : this.list) { value.write(out); } }
public static boolean copyBigInteger(DataInputView source, DataOutputView target) throws IOException { final int len = source.readInt(); target.writeInt(len); if (len > 4) { target.write(source, len - 4); } return len == 0; // returns true if the copied record was null }
private OperatorStateHandle writeAllTestKeyGroups( OperatorStateCheckpointOutputStream stream, int numPartitions) throws Exception { DataOutputView dov = new DataOutputViewStreamWrapper(stream); for (int i = 0; i < numPartitions; ++i) { Assert.assertEquals(i, stream.getNumberOfPartitions()); stream.startNewPartition(); dov.writeInt(i); } return stream.closeAndGetHandle(); }
private void snapshotTimers(DataOutputView out) throws IOException { out.writeInt(watermarkTimersQueue.size()); for (Timer<K, W> timer : watermarkTimersQueue) { keySerializer.serialize(timer.key, out); windowSerializer.serialize(timer.window, out); out.writeLong(timer.timestamp); } out.writeInt(processingTimeTimers.size()); for (Timer<K, W> timer : processingTimeTimers) { keySerializer.serialize(timer.key, out); windowSerializer.serialize(timer.window, out); out.writeLong(timer.timestamp); } out.writeInt(processingTimeTimerTimestamps.entrySet().size()); for (Multiset.Entry<Long> timerTimestampCounts : processingTimeTimerTimestamps.entrySet()) { out.writeLong(timerTimestampCounts.getElement()); out.writeInt(timerTimestampCounts.getCount()); } }
@Override public void serialize(C[] value, DataOutputView target) throws IOException { target.writeInt(value.length); for (int i = 0; i < value.length; i++) { C val = value[i]; if (val == null) { target.writeBoolean(false); } else { target.writeBoolean(true); componentSerializer.serialize(val, target); } } }
@Override public void copy(DataInputView source, DataOutputView target) throws IOException { int len = source.readInt(); target.writeInt(len); for (int i = 0; i < len; i++) { boolean isNonNull = source.readBoolean(); target.writeBoolean(isNonNull); if (isNonNull) { componentSerializer.copy(source, target); } } }
public static void writeBigInteger(BigInteger record, DataOutputView target) throws IOException { // null value support if (record == null) { target.writeInt(0); return; } // fast paths for 0, 1, 10 // only reference equality is checked because equals would be too expensive else if (record == BigInteger.ZERO) { target.writeInt(1); return; } else if (record == BigInteger.ONE) { target.writeInt(2); return; } else if (record == BigInteger.TEN) { target.writeInt(3); return; } // default final byte[] bytes = record.toByteArray(); // the length we write is offset by four, because null and short-paths for ZERO, ONE, and TEN target.writeInt(bytes.length + 4); target.write(bytes); }
@Override public void write(DataOutputView out) throws IOException { if (uri == null) { out.writeBoolean(false); } else { out.writeBoolean(true); StringUtils.writeNullableString(uri.getScheme(), out); StringUtils.writeNullableString(uri.getUserInfo(), out); StringUtils.writeNullableString(uri.getHost(), out); out.writeInt(uri.getPort()); StringUtils.writeNullableString(uri.getPath(), out); StringUtils.writeNullableString(uri.getQuery(), out); StringUtils.writeNullableString(uri.getFragment(), out); } }
private void writeKVStateMetaData() throws IOException, InterruptedException { // write number of k/v states outputView.writeInt(stateBackend.kvStateInformation.size()); int kvStateId = 0; // iterate all column families, where each column family holds one k/v state, to write the // metadata for (Map.Entry<String, Tuple2<ColumnFamilyHandle, StateDescriptor<?, ?>>> column : stateBackend.kvStateInformation.entrySet()) { // be cooperative and check for interruption from time to time in the hot loop checkInterrupted(); // write StateDescriptor for this k/v state InstantiationUtil.serializeObject(outStream, column.getValue().f1); // retrieve iterator for this k/v states readOptions = new ReadOptions(); readOptions.setSnapshot(snapshot); RocksIterator iterator = stateBackend.db.newIterator(column.getValue().f0, readOptions); kvStateIterators.add(new Tuple2<>(iterator, kvStateId)); ++kvStateId; } }
@Override public void write(DataOutputView out) throws IOException { out.writeInt(splitNumber); }