本文整理汇总了Java中org.apache.flink.core.memory.DataInputView类的典型用法代码示例。如果您正苦于以下问题:Java DataInputView类的具体用法?Java DataInputView怎么用?Java DataInputView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataInputView类属于org.apache.flink.core.memory包,在下文中一共展示了DataInputView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
final int len = in.readInt();
this.len = len;
for (int i = 0; i < len / 8; i++) {
if (in.readLong() != i) {
throw new IOException("corrupt serialization");
}
}
for (int i = 0; i < len % 8; i++) {
if (in.readByte() != i) {
throw new IOException("corrupt serialization");
}
}
}
示例2: getOperatorStateStreams
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Test
public void getOperatorStateStreams() throws Exception {
int i = 0;
int s = 0;
for (StatePartitionStreamProvider streamProvider : initializationContext.getRawOperatorStateInputs()) {
if (0 == i % 4) {
++i;
}
Assert.assertNotNull(streamProvider);
try (InputStream is = streamProvider.getStream()) {
DataInputView div = new DataInputViewStreamWrapper(is);
int val = div.readInt();
Assert.assertEquals(i * NUM_HANDLES + s, val);
}
++s;
if (s == i % 4) {
s = 0;
++i;
}
}
}
示例3: copy
import org.apache.flink.core.memory.DataInputView; //导入依赖的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);
}
}
}
示例4: verifyRead
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
private static void verifyRead(OperatorStateHandle fullHandle, int numPartitions) throws IOException {
int count = 0;
try (FSDataInputStream in = fullHandle.openInputStream()) {
OperatorStateHandle.StateMetaInfo metaInfo = fullHandle.getStateNameToPartitionOffsets().
get(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME);
long[] offsets = metaInfo.getOffsets();
Assert.assertNotNull(offsets);
DataInputView div = new DataInputViewStreamWrapper(in);
for (int i = 0; i < numPartitions; ++i) {
in.seek(offsets[i]);
Assert.assertEquals(i, div.readInt());
++count;
}
}
Assert.assertEquals(numPartitions, count);
}
示例5: deserialize
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public Row deserialize(DataInputView source) throws IOException {
int len = fieldSerializers.length;
Row result = new Row(len);
// read null mask
readIntoNullMask(len, source, nullMask);
for (int i = 0; i < len; i++) {
if (nullMask[i]) {
result.setField(i, null);
} else {
result.setField(i, fieldSerializers[i].deserialize(source));
}
}
return result;
}
示例6: read
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void read(DataInputView in) throws IOException {
super.read(in);
String serializerConfigClassname = in.readUTF();
Class<? extends TypeSerializerConfigSnapshot> serializerConfigSnapshotClass;
try {
serializerConfigSnapshotClass = (Class<? extends TypeSerializerConfigSnapshot>)
Class.forName(serializerConfigClassname, true, userCodeClassLoader);
} catch (ClassNotFoundException e) {
throw new IOException(
"Could not find requested TypeSerializerConfigSnapshot class "
+ serializerConfigClassname + " in classpath.", e);
}
serializerConfigSnapshot = InstantiationUtil.instantiate(serializerConfigSnapshotClass);
serializerConfigSnapshot.setUserCodeClassLoader(userCodeClassLoader);
serializerConfigSnapshot.read(in);
}
示例7: read
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
super.read(in);
int numKryoRegistrations = in.readInt();
kryoRegistrations = new LinkedHashMap<>(numKryoRegistrations);
KryoRegistrationSerializationProxy proxy;
for (int i = 0; i < numKryoRegistrations; i++) {
String classTag = in.readUTF();
proxy = new KryoRegistrationSerializationProxy(getUserCodeClassLoader());
proxy.read(in);
kryoRegistrations.put(classTag, proxy.kryoRegistration);
}
}
示例8: read
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
final int len = readVarLengthInt(in);
this.binaryLen = len;
// ensure out byte array is large enough
byte[] data = this.binaryData;
if (data == null || data.length < len) {
data = new byte[len];
this.binaryData = data;
}
// read the binary data
in.readFully(data, 0, len);
initFields(data, 0, len);
}
示例9: deserialize
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public T deserialize(DataInputView dataInputView) throws IOException {
try {
DataInputViewWrapper inputWrapper = new DataInputViewWrapper(dataInputView);
return coder.decode(inputWrapper);
} catch (CoderException e) {
Throwable cause = e.getCause();
if (cause instanceof EOFException) {
throw (EOFException) cause;
} else {
throw e;
}
}
}
示例10: deserialize
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public byte[] deserialize(DataInputView source) throws IOException {
final int len = source.readInt();
byte[] result = new byte[len];
source.readFully(result);
return result;
}
示例11: read
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
position = in.readInt();
mark = 0;
ensureCapacity(position);
for (int i = 0; i < position; i++) {
data[i] = in.readShort();
}
}
示例12: deserialize
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public String[] deserialize(DataInputView source) throws IOException {
final int len = source.readInt();
String[] array = new String[len];
for (int i = 0; i < len; i++) {
array[i] = StringValue.readString(source);
}
return array;
}
示例13: verifyRead
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
private static void verifyRead(KeyGroupsStateHandle fullHandle, KeyGroupRange keyRange) throws IOException {
int count = 0;
try (FSDataInputStream in = fullHandle.openInputStream()) {
DataInputView div = new DataInputViewStreamWrapper(in);
for (int kg : fullHandle.getKeyGroupRange()) {
long off = fullHandle.getOffsetForKeyGroup(kg);
in.seek(off);
Assert.assertEquals(kg, div.readInt());
++count;
}
}
Assert.assertEquals(keyRange.getNumberOfKeyGroups(), count);
}
示例14: deserialize
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public KafkaTransactionState deserialize(DataInputView source) throws IOException {
String transactionalId = null;
if (source.readBoolean()) {
transactionalId = source.readUTF();
}
long producerId = source.readLong();
short epoch = source.readShort();
return new KafkaTransactionState(transactionalId, producerId, epoch, null);
}
示例15: deserialize
import org.apache.flink.core.memory.DataInputView; //导入依赖的package包/类
@Override
public Long deserialize(byte[] messageKey, byte[] message, String topic, int partition, long offset) throws IOException {
cnt++;
DataInputView in = new DataInputViewStreamWrapper(new ByteArrayInputStream(message));
Long e = ser.deserialize(in);
return e;
}