Java Code Examples for org.apache.flink.core.memory.ByteArrayOutputStreamWithPos#getPosition()

The following examples show how to use org.apache.flink.core.memory.ByteArrayOutputStreamWithPos#getPosition() . 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: RocksDBUtils.java    From bravo with Apache License 2.0 6 votes vote down vote up
public static <N> void writeNameSpace(
		N namespace,
		TypeSerializer<N> namespaceSerializer,
		ByteArrayOutputStreamWithPos keySerializationStream,
		DataOutputView keySerializationDataOutputView,
		boolean ambiguousKeyPossible) throws IOException {

	int beforeWrite = keySerializationStream.getPosition();
	namespaceSerializer.serialize(namespace, keySerializationDataOutputView);

	if (ambiguousKeyPossible) {
		// write length of namespace
		writeLengthFrom(beforeWrite, keySerializationStream,
				keySerializationDataOutputView);
	}
}
 
Example 2
Source File: RocksDBUtils.java    From bravo with Apache License 2.0 6 votes vote down vote up
public static <K> void writeKey(
		K key,
		TypeSerializer<K> keySerializer,
		ByteArrayOutputStreamWithPos keySerializationStream,
		DataOutputView keySerializationDataOutputView,
		boolean ambiguousKeyPossible) throws IOException {
	// write key
	int beforeWrite = keySerializationStream.getPosition();
	keySerializer.serialize(key, keySerializationDataOutputView);

	if (ambiguousKeyPossible) {
		// write size of key
		writeLengthFrom(beforeWrite, keySerializationStream,
				keySerializationDataOutputView);
	}
}
 
Example 3
Source File: RocksDBUtils.java    From bravo with Apache License 2.0 5 votes vote down vote up
private static void writeLengthFrom(
		int fromPosition,
		ByteArrayOutputStreamWithPos keySerializationStream,
		DataOutputView keySerializationDateDataOutputView) throws IOException {
	int length = keySerializationStream.getPosition() - fromPosition;
	writeVariableIntBytes(length, keySerializationDateDataOutputView);
}