本文整理汇总了Java中org.apache.flink.core.memory.DataOutputView.writeBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutputView.writeBoolean方法的具体用法?Java DataOutputView.writeBoolean怎么用?Java DataOutputView.writeBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.core.memory.DataOutputView
的用法示例。
在下文中一共展示了DataOutputView.writeBoolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void serialize(
State<TXN, CONTEXT> record,
DataOutputView target) throws IOException {
final TransactionHolder<TXN> pendingTransaction = record.getPendingTransaction();
transactionSerializer.serialize(pendingTransaction.handle, target);
target.writeLong(pendingTransaction.transactionStartTime);
final List<TransactionHolder<TXN>> pendingCommitTransactions = record.getPendingCommitTransactions();
target.writeInt(pendingCommitTransactions.size());
for (TransactionHolder<TXN> pendingTxn : pendingCommitTransactions) {
transactionSerializer.serialize(pendingTxn.handle, target);
target.writeLong(pendingTxn.transactionStartTime);
}
Optional<CONTEXT> context = record.getContext();
if (context.isPresent()) {
target.writeBoolean(true);
contextSerializer.serialize(context.get(), target);
} else {
target.writeBoolean(false);
}
}
示例2: 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) {
keySerializer.copy(source, target);
boolean isNull = source.readBoolean();
target.writeBoolean(isNull);
if (!isNull) {
valueSerializer.copy(source, target);
}
}
}
示例3: copy
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void copy(
DataInputView source, DataOutputView target) throws IOException {
TXN pendingTxnHandle = transactionSerializer.deserialize(source);
transactionSerializer.serialize(pendingTxnHandle, target);
final long pendingTxnStartTime = source.readLong();
target.writeLong(pendingTxnStartTime);
int numPendingCommitTxns = source.readInt();
target.writeInt(numPendingCommitTxns);
for (int i = 0; i < numPendingCommitTxns; i++) {
TXN pendingCommitTxnHandle = transactionSerializer.deserialize(source);
transactionSerializer.serialize(pendingCommitTxnHandle, target);
final long pendingCommitTxnStartTime = source.readLong();
target.writeLong(pendingCommitTxnStartTime);
}
boolean hasContext = source.readBoolean();
target.writeBoolean(hasContext);
if (hasContext) {
CONTEXT context = contextSerializer.deserialize(source);
contextSerializer.serialize(context, target);
}
}
示例4: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void serialize(HashMap<K, V> map, DataOutputView target) throws IOException {
final int size = map.size();
target.writeInt(size);
for (Map.Entry<K, V> entry : map.entrySet()) {
keySerializer.serialize(entry.getKey(), target);
if (entry.getValue() == null) {
target.writeBoolean(true);
} else {
target.writeBoolean(false);
valueSerializer.serialize(entry.getValue(), target);
}
}
}
示例5: 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);
}
}
示例6: copy
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void copy(
DataInputView source, DataOutputView target) throws IOException {
boolean hasTransactionalId = source.readBoolean();
target.writeBoolean(hasTransactionalId);
if (hasTransactionalId) {
target.writeUTF(source.readUTF());
}
target.writeLong(source.readLong());
target.writeShort(source.readShort());
}
示例7: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void serialize(Either<L, R> record, DataOutputView target) throws IOException {
if (record.isLeft()) {
target.writeBoolean(true);
leftSerializer.serialize(record.left(), target);
}
else {
target.writeBoolean(false);
rightSerializer.serialize(record.right(), target);
}
}
示例8: copy
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
boolean isLeft = source.readBoolean();
target.writeBoolean(isLeft);
if (isLeft) {
leftSerializer.copy(source, target);
}
else {
rightSerializer.copy(source, target);
}
}
示例9: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void serialize(boolean[] 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.writeBoolean(record[i]);
}
}
示例10: write
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void write(DataOutputView out) throws IOException {
out.writeInt(val);
out.writeBoolean(isLong);
if (isLong) {
out.write(BUFFER);
}
}
示例11: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@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);
}
}
}
示例12: write
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@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);
}
}
示例13: serialize
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public void serialize(T value, DataOutputView target) throws IOException {
int flags = 0;
// handle null values
if (value == null) {
flags |= IS_NULL;
target.writeByte(flags);
return;
}
Integer subclassTag = -1;
Class<?> actualClass = value.getClass();
TypeSerializer subclassSerializer = null;
if (clazz != actualClass) {
subclassTag = registeredClasses.get(actualClass);
if (subclassTag != null) {
flags |= IS_TAGGED_SUBCLASS;
subclassSerializer = registeredSerializers[subclassTag];
} else {
flags |= IS_SUBCLASS;
subclassSerializer = getSubclassSerializer(actualClass);
}
} else {
flags |= NO_SUBCLASS;
}
target.writeByte(flags);
// if its a registered subclass, write the class tag id, otherwise write the full classname
if ((flags & IS_SUBCLASS) != 0) {
target.writeUTF(actualClass.getName());
} else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
target.writeByte(subclassTag);
}
// if its a subclass, use the corresponding subclass serializer,
// otherwise serialize each field with our field serializers
if ((flags & NO_SUBCLASS) != 0) {
try {
for (int i = 0; i < numFields; i++) {
Object o = (fields[i] != null) ? fields[i].get(value) : null;
if (o == null) {
target.writeBoolean(true); // null field handling
} else {
target.writeBoolean(false);
fieldSerializers[i].serialize(o, target);
}
}
} catch (IllegalAccessException e) {
throw new RuntimeException("Error during POJO copy, this should not happen since we check the fields before.", e);
}
} else {
// subclass
if (subclassSerializer != null) {
subclassSerializer.serialize(value, target);
}
}
}
示例14: copy
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
// copy the flags
int flags = source.readByte();
target.writeByte(flags);
if ((flags & IS_NULL) != 0) {
// is a null value, nothing further to copy
return;
}
TypeSerializer<?> subclassSerializer = null;
if ((flags & IS_SUBCLASS) != 0) {
String className = source.readUTF();
target.writeUTF(className);
try {
Class<?> subclass = Class.forName(className, true, Thread.currentThread()
.getContextClassLoader());
subclassSerializer = getSubclassSerializer(subclass);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Cannot instantiate class.", e);
}
} else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
int subclassTag = source.readByte();
target.writeByte(subclassTag);
subclassSerializer = registeredSerializers[subclassTag];
}
if ((flags & NO_SUBCLASS) != 0) {
for (int i = 0; i < numFields; i++) {
boolean isNull = source.readBoolean();
target.writeBoolean(isNull);
if (!isNull) {
fieldSerializers[i].copy(source, target);
}
}
} else {
if (subclassSerializer != null) {
subclassSerializer.copy(source, target);
}
}
}
示例15: copy
import org.apache.flink.core.memory.DataOutputView; //导入方法依赖的package包/类
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
target.writeBoolean(source.readBoolean());
}