Java Code Examples for org.apache.flink.core.memory.DataOutputView#writeLong()

The following examples show how to use org.apache.flink.core.memory.DataOutputView#writeLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamElementSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	int tag = source.readByte();
	target.write(tag);

	if (tag == TAG_REC_WITH_TIMESTAMP) {
		// move timestamp
		target.writeLong(source.readLong());
		typeSerializer.copy(source, target);
	}
	else if (tag == TAG_REC_WITHOUT_TIMESTAMP) {
		typeSerializer.copy(source, target);
	}
	else if (tag == TAG_WATERMARK) {
		target.writeLong(source.readLong());
	}
	else if (tag == TAG_STREAM_STATUS) {
		target.writeInt(source.readInt());
	}
	else if (tag == TAG_LATENCY_MARKER) {
		target.writeLong(source.readLong());
		target.writeLong(source.readLong());
		target.writeLong(source.readLong());
		target.writeInt(source.readInt());
	} else {
		throw new IOException("Corrupt stream, found tag: " + tag);
	}
}
 
Example 2
Source File: DanglingPageRankITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutputView out) throws IOException {
	out.writeDouble(diff);
	out.writeDouble(rank);
	out.writeDouble(danglingRank);
	out.writeLong(numDanglingVertices);
	out.writeLong(numVertices);
	out.writeLong(edges);
}
 
Example 3
Source File: DanglingPageRankITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutputView out) throws IOException {
	out.writeDouble(diff);
	out.writeDouble(rank);
	out.writeDouble(danglingRank);
	out.writeLong(numDanglingVertices);
	out.writeLong(numVertices);
	out.writeLong(edges);
}
 
Example 4
Source File: DecimalDataSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	if (DecimalData.isCompact(precision)) {
		target.writeLong(source.readLong());
	} else {
		int len = source.readInt();
		target.writeInt(len);
		target.write(source, len);
	}
}
 
Example 5
Source File: LongValueArray.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutputView out) throws IOException {
	out.writeInt(position);

	for (int i = 0; i < position; i++) {
		out.writeLong(data[i]);
	}
}
 
Example 6
Source File: LongValueArray.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void write(DataOutputView out) throws IOException {
	out.writeInt(position);

	for (int i = 0; i < position; i++) {
		out.writeLong(data[i]);
	}
}
 
Example 7
Source File: FlinkKafkaProducer011.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(
		KafkaTransactionState record,
		DataOutputView target) throws IOException {
	if (record.transactionalId == null) {
		target.writeBoolean(false);
	} else {
		target.writeBoolean(true);
		target.writeUTF(record.transactionalId);
	}
	target.writeLong(record.producerId);
	target.writeShort(record.epoch);
}
 
Example 8
Source File: FlinkKafkaProducer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(
	FlinkKafkaProducer.KafkaTransactionState record,
	DataOutputView target) throws IOException {
	if (record.transactionalId == null) {
		target.writeBoolean(false);
	} else {
		target.writeBoolean(true);
		target.writeUTF(record.transactionalId);
	}
	target.writeLong(record.producerId);
	target.writeShort(record.epoch);
}
 
Example 9
Source File: CountWindow.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	target.writeLong(source.readLong());
}
 
Example 10
Source File: EventId.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	target.writeInt(source.readInt());
	target.writeLong(source.readLong());
}
 
Example 11
Source File: TimerSerializer.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	target.writeLong(source.readLong());
	keySerializer.copy(source, target);
	namespaceSerializer.copy(source, target);
}
 
Example 12
Source File: ValueID.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutputView out) throws IOException {
	out.writeLong(id.getMostSignificantBits());
	out.writeLong(id.getLeastSignificantBits());
}
 
Example 13
Source File: ValueID.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutputView out) throws IOException {
	out.writeLong(id.getMostSignificantBits());
	out.writeLong(id.getLeastSignificantBits());
}
 
Example 14
Source File: EventId.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(EventId record, DataOutputView target) throws IOException {
	target.writeInt(record.id);
	target.writeLong(record.timestamp);
}
 
Example 15
Source File: CustomSerializationITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutputView out) throws IOException {
	// write 8 bytes
	out.writeLong(42L);
}
 
Example 16
Source File: LongSerializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(Long record, DataOutputView target) throws IOException {
	target.writeLong(record);
}
 
Example 17
Source File: BlockInfo.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutputView out) throws IOException {
	out.writeLong(this.recordCount);
	out.writeLong(this.accumulatedRecordCount);
	out.writeLong(this.firstRecordStart);
}
 
Example 18
Source File: TestEvent.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void write(DataOutputView out) throws IOException {
	out.writeLong(magicNumber);
	out.writeInt(payload.length);
	out.write(payload);
}
 
Example 19
Source File: Configuration.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void write(final DataOutputView out) throws IOException {
	synchronized (this.confData) {
		out.writeInt(this.confData.size());

		for (Map.Entry<String, Object> entry : this.confData.entrySet()) {
			String key = entry.getKey();
			Object val = entry.getValue();

			StringValue.writeString(key, out);
			Class<?> clazz = val.getClass();

			if (clazz == String.class) {
				out.write(TYPE_STRING);
				StringValue.writeString((String) val, out);
			}
			else if (clazz == Integer.class) {
				out.write(TYPE_INT);
				out.writeInt((Integer) val);
			}
			else if (clazz == Long.class) {
				out.write(TYPE_LONG);
				out.writeLong((Long) val);
			}
			else if (clazz == Float.class) {
				out.write(TYPE_FLOAT);
				out.writeFloat((Float) val);
			}
			else if (clazz == Double.class) {
				out.write(TYPE_DOUBLE);
				out.writeDouble((Double) val);
			}
			else if (clazz == byte[].class) {
				out.write(TYPE_BYTES);
				byte[] bytes = (byte[]) val;
				out.writeInt(bytes.length);
				out.write(bytes);
			}
			else if (clazz == Boolean.class) {
				out.write(TYPE_BOOLEAN);
				out.writeBoolean((Boolean) val);
			}
			else {
				throw new IllegalArgumentException("Unrecognized type");
			}
		}
	}
}
 
Example 20
Source File: EventId.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	target.writeInt(source.readInt());
	target.writeLong(source.readLong());
}