本文整理汇总了Java中org.apache.flink.core.memory.DataOutputViewStreamWrapper.close方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutputViewStreamWrapper.close方法的具体用法?Java DataOutputViewStreamWrapper.close怎么用?Java DataOutputViewStreamWrapper.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.core.memory.DataOutputViewStreamWrapper
的用法示例。
在下文中一共展示了DataOutputViewStreamWrapper.close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerialization
import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
public static void testSerialization(String[] values) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
DataOutputViewStreamWrapper serializer = new DataOutputViewStreamWrapper(baos);
for (String value : values) {
StringValue sv = new StringValue(value);
sv.write(serializer);
}
serializer.close();
baos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
DataInputViewStreamWrapper deserializer = new DataInputViewStreamWrapper(bais);
int num = 0;
while (bais.available() > 0) {
StringValue deser = new StringValue();
deser.read(deserializer);
assertEquals("DeserializedString differs from original string.", values[num], deser.getValue());
num++;
}
assertEquals("Wrong number of deserialized values", values.length, num);
}
示例2: write
import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
@Override
public void write(DataOutputView out) throws IOException {
int num = this.aggNames.length;
out.writeInt(num);
ByteArrayOutputStream boas = new ByteArrayOutputStream();
DataOutputViewStreamWrapper bufferStream = new DataOutputViewStreamWrapper(boas);
for (int i = 0; i < num; i++) {
// aggregator name and type
out.writeUTF(this.aggNames[i]);
out.writeUTF(this.aggregates[i].getClass().getName());
// aggregator value indirect as a byte array
this.aggregates[i].write(bufferStream);
bufferStream.flush();
byte[] bytes = boas.toByteArray();
out.writeInt(bytes.length);
out.write(bytes);
boas.reset();
}
bufferStream.close();
boas.close();
}
示例3: checkpointRecordQueueState
import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
private void checkpointRecordQueueState() throws Exception {
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final DataOutputViewStreamWrapper dataOutputView = new DataOutputViewStreamWrapper(byteArrayOutputStream);
try {
snapshotQueueState(this.priorityQueue, dataOutputView);
this.queuedRecordsState.clear();
this.queuedRecordsState.add(byteArrayOutputStream.toByteArray());
} finally {
dataOutputView.close();
byteArrayOutputStream.close();
}
}
示例4: checkpointRecordQueueState
import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
private void checkpointRecordQueueState() throws Exception {
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final DataOutputViewStreamWrapper dataOutputView = new DataOutputViewStreamWrapper(byteArrayOutputStream);
try {
snapshotQueueState(this.priorityQueue, dataOutputView);
this.queuedRecordsState.clear();
this.queuedRecordsState.add(byteArrayOutputStream.toByteArray());
} finally {
dataOutputView.close();
byteArrayOutputStream.close();
}
}
示例5: close
import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
try {
DataOutputViewStreamWrapper o = this.outView;
if (o != null) {
o.close();
}
}
finally {
super.close();
}
}