本文整理汇总了Java中org.apache.flink.core.memory.DataOutputView.writeInt方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutputView.writeInt方法的具体用法?Java DataOutputView.writeInt怎么用?Java DataOutputView.writeInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.core.memory.DataOutputView
的用法示例。
在下文中一共展示了DataOutputView.writeInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeCondition
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
private void serializeCondition(IterativeCondition<T> condition, DataOutputView out) throws IOException {
out.writeBoolean(condition != null);
if (condition != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(condition);
oos.close();
baos.close();
byte[] serCondition = baos.toByteArray();
out.writeInt(serCondition.length);
out.write(serCondition);
}
}
示例2: write
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void write(DataOutputView out) throws IOException {
out.writeUTF(kryoRegistration.getRegisteredClass().getName());
final KryoRegistration.SerializerDefinitionType serializerDefinitionType = kryoRegistration.getSerializerDefinitionType();
out.writeInt(serializerDefinitionType.ordinal());
switch (serializerDefinitionType) {
case UNSPECIFIED:
// nothing else to write
break;
case CLASS:
out.writeUTF(kryoRegistration.getSerializerClass().getName());
break;
case INSTANCE:
try (final DataOutputViewStream outViewWrapper = new DataOutputViewStream(out)) {
InstantiationUtil.serializeObject(outViewWrapper, kryoRegistration.getSerializableSerializerInstance());
}
break;
default:
// this should not happen; adding as a guard for the future
throw new IllegalStateException(
"Unrecognized Kryo registration serializer definition type: " + serializerDefinitionType);
}
}
示例3: writeBigInteger
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
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);
}
示例4: copy
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@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);
}
}
}
示例5: snapshotQueueState
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
protected void snapshotQueueState(PriorityQueue<StreamRecord<Tuple2<String, IN>>> queue, DataOutputView dataOutputView) throws IOException {
dataOutputView.writeInt(queue.size());
for (StreamRecord<Tuple2<String, IN>> record : queue) {
String streamId = record.getValue().f0;
dataOutputView.writeUTF(streamId);
this.getStreamRecordSerializer(streamId).serialize(record, dataOutputView);
}
}
示例6: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void serialize(byte[] record, DataOutputView target) throws IOException {
if (record == null) {
throw new IllegalArgumentException("The record must not be null.");
}
final int len = record.length;
target.writeInt(len);
target.write(record);
}
示例7: copyInternal
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
protected static void copyInternal(DataInputView source, DataOutputView target) throws IOException {
int count = source.readInt();
target.writeInt(count);
int bytes = ELEMENT_LENGTH_IN_BYTES * count;
target.write(source, bytes);
}
示例8: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void serialize(String[] record, DataOutputView target) throws IOException {
if (record == null) {
throw new IllegalArgumentException("The record must not be null.");
}
final int len = record.length;
target.writeInt(len);
for (int i = 0; i < len; i++) {
StringValue.writeString(record[i], target);
}
}
示例9: copy
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
final int size = source.readInt();
target.writeInt(size);
for (int i = 0; i < size; i++) {
elemSerializer.copy(source, target);
}
}
示例10: write
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void write(DataOutputView out) throws IOException {
out.writeInt(position);
for (int i = 0; i < position; i++) {
out.writeByte(data[i]);
}
}
示例11: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void serialize(float[] record, DataOutputView target) throws IOException {
if (record == null) {
throw new IllegalArgumentException("The record must not be null.");
}
final int len = record.length;
target.writeInt(len);
for (int i = 0; i < len; i++) {
target.writeFloat(record[i]);
}
}
示例12: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void serialize(Integer record, DataOutputView target) throws IOException {
Assert.assertFalse(disabled);
target.writeInt(record);
}
示例13: write
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void write(DataOutputView out) throws IOException {
out.writeLong(magicNumber);
out.writeInt(payload.length);
out.write(payload);
}
示例14: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void serialize(Integer record, DataOutputView target) throws IOException {
target.writeInt(record.intValue());
}
示例15: write
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void write(DataOutputView out) throws IOException {
// write 4 bytes
out.writeInt(42);
}