当前位置: 首页>>代码示例>>Java>>正文


Java DataInputView类代码示例

本文整理汇总了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");
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:LargeObjectType.java

示例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;
		}
	}

}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:StateInitializationContextImplTest.java

示例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);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:HashMapSerializer.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:OperatorStateOutputCheckpointStreamTest.java

示例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;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:RowSerializer.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:TypeSerializerSerializationUtil.java

示例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);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:KryoRegistrationSerializerConfigSnapshot.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:Record.java

示例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;
    }
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:15,代码来源:CoderTypeSerializer.java

示例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;
}
 
开发者ID:apache,项目名称:beam,代码行数:8,代码来源:EncodedValueSerializer.java

示例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();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:ShortValueArray.java

示例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;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:StringArraySerializer.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:15,代码来源:KeyedStateCheckpointOutputStreamTest.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:FlinkKafkaProducer011.java

示例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;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:Kafka010ITCase.java


注:本文中的org.apache.flink.core.memory.DataInputView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。