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


Java DataInputView.readFully方法代码示例

本文整理汇总了Java中org.apache.flink.core.memory.DataInputView.readFully方法的典型用法代码示例。如果您正苦于以下问题:Java DataInputView.readFully方法的具体用法?Java DataInputView.readFully怎么用?Java DataInputView.readFully使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.core.memory.DataInputView的用法示例。


在下文中一共展示了DataInputView.readFully方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readBigInteger

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
public static BigInteger readBigInteger(DataInputView source) throws IOException {
	final int len = source.readInt();
	if (len < 4) {
		switch (len) {
			case 0:
				return null;
			case 1:
				return BigInteger.ZERO;
			case 2:
				return BigInteger.ONE;
			case 3:
				return BigInteger.TEN;
		}
	}
	final byte[] bytes = new byte[len - 4];
	source.readFully(bytes);
	return new BigInteger(bytes);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:BigIntSerializer.java

示例2: read

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
	super.read(in);

	// read in a way that allows the stream to recover from exceptions
	int serializerBytes = in.readInt();
	byte[] buffer = new byte[serializerBytes];
	in.readFully(buffer);
	try {
		typeSerializer = InstantiationUtil.deserializeObject(buffer, userClassLoader);
	} catch (ClassNotFoundException | InvalidClassException e) {
		if (ignoreClassNotFound) {
			// we create a dummy so that all the information is not lost when we get a new checkpoint before receiving
			// a proper typeserializer from the user
			typeSerializer =
					new ClassNotFoundDummyTypeSerializer<>(buffer);
			LOG.warn("Could not find requested TypeSerializer class in classpath. Created dummy.", e);
		} else {
			throw new IOException("Missing class for type serializer.", e);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:TypeSerializerSerializationProxy.java

示例3: 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

示例4: 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

示例5: read

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void read(DataInputView in) throws IOException {
	super.read(in);

	// read in a way that allows the stream to recover from exceptions
	int serializerBytes = in.readInt();
	byte[] buffer = new byte[serializerBytes];
	in.readFully(buffer);

	ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
	try (
		FailureTolerantObjectInputStream ois =
			new FailureTolerantObjectInputStream(new ByteArrayInputStream(buffer), userClassLoader)) {

		Thread.currentThread().setContextClassLoader(userClassLoader);
		typeSerializer = (TypeSerializer<T>) ois.readObject();
	} catch (ClassNotFoundException | InvalidClassException e) {
		if (useDummyPlaceholder) {
			// we create a dummy so that all the information is not lost when we get a new checkpoint before receiving
			// a proper typeserializer from the user
			typeSerializer =
				new UnloadableDummyTypeSerializer<>(buffer);
			LOG.warn("Could not find requested TypeSerializer class in classpath. Created dummy.", e);
		} else {
			throw new IOException("Unloadable class for type serializer.", e);
		}
	} finally {
		Thread.currentThread().setContextClassLoader(previousClassLoader);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:32,代码来源:TypeSerializerSerializationUtil.java

示例6: write

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void write(DataInputView source, int numBytes) throws IOException {
	if (numBytes > this.end - this.position) {
		throw new IOException("Could not write " + numBytes + " bytes since the buffer is full.");
	}

	source.readFully(this.memory,this.position, numBytes);
	this.position += numBytes;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:Record.java

示例7: write

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void write(DataInputView source, int numBytes) throws IOException {
	if (buffer.length - this.position < numBytes){
		throw new EOFException("Could not write " + numBytes + " bytes. Buffer overflow.");
	}

	source.readFully(this.buffer, this.position, numBytes);
	this.position += numBytes;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:DataOutputSerializer.java

示例8: write

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void write(DataInputView source, int numBytes) throws IOException {
	if(buffer.length - this.position < numBytes){
		throw new EOFException("Could not write " + numBytes + " bytes. Buffer overflow.");
	}

	source.readFully(this.buffer, this.position, numBytes);
	this.position += numBytes;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:TestDataOutputSerializer.java

示例9: read

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
	int num = in.readInt();
	if (num == 0) {
		this.aggNames = NO_STRINGS;
		this.aggregates = NO_VALUES;
	} else {
		if (this.aggNames == null || num > this.aggNames.length) {
			this.aggNames = new String[num];
		}
		if (this.classNames == null || num > this.classNames.length) {
			this.classNames = new String[num];
		}
		if (this.serializedData == null || num > this.serializedData.length) {
			this.serializedData = new byte[num][];
		}

		for (int i = 0; i < num; i++) {
			this.aggNames[i] = in.readUTF();
			this.classNames[i] = in.readUTF();

			int len = in.readInt();
			byte[] data = new byte[len];
			this.serializedData[i] = data;
			in.readFully(data);

		}

		this.aggregates = null;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:32,代码来源:IterationEventWithAggregators.java

示例10: read

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
	byte[] bytes = new byte[32941];
	in.readFully(bytes);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:6,代码来源:CustomSerializationITCase.java

示例11: read

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
	in.readFully(this.buf);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:NetworkStackThroughputITCase.java

示例12: read

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
	this.len = in.readInt();
	in.readFully(this.data, 0, this.len);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:6,代码来源:ByteSubArrayType.java

示例13: readSerializersAndConfigsWithResilience

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
/**
 * Reads from a data input view a list of serializers and their corresponding config snapshots
 * written using {@link #writeSerializersAndConfigsWithResilience(DataOutputView, List)}.
 * This is fault tolerant to any failures when deserializing the serializers. Serializers which
 * were not successfully deserialized will be replaced by {@code null}.
 *
 * @param in the data input view.
 * @param userCodeClassLoader the user code class loader to use.
 *
 * @return the deserialized serializer and config snapshot pairs.
 *
 * @throws IOException
 */
public static List<Tuple2<TypeSerializer<?>, TypeSerializerConfigSnapshot>> readSerializersAndConfigsWithResilience(
		DataInputView in,
		ClassLoader userCodeClassLoader) throws IOException {

	int numSerializersAndConfigSnapshots = in.readInt();

	int[] offsets = new int[numSerializersAndConfigSnapshots * 2];

	for (int i = 0; i < numSerializersAndConfigSnapshots; i++) {
		offsets[i * 2] = in.readInt();
		offsets[i * 2 + 1] = in.readInt();
	}

	int totalBytes = in.readInt();
	byte[] buffer = new byte[totalBytes];
	in.readFully(buffer);

	List<Tuple2<TypeSerializer<?>, TypeSerializerConfigSnapshot>> serializersAndConfigSnapshots =
		new ArrayList<>(numSerializersAndConfigSnapshots);

	TypeSerializer<?> serializer;
	TypeSerializerConfigSnapshot configSnapshot;
	try (
		ByteArrayInputStreamWithPos bufferWithPos = new ByteArrayInputStreamWithPos(buffer);
		DataInputViewStreamWrapper bufferWrapper = new DataInputViewStreamWrapper(bufferWithPos)) {

		for (int i = 0; i < numSerializersAndConfigSnapshots; i++) {

			bufferWithPos.setPosition(offsets[i * 2]);
			serializer = tryReadSerializer(bufferWrapper, userCodeClassLoader);

			bufferWithPos.setPosition(offsets[i * 2 + 1]);
			configSnapshot = readSerializerConfigSnapshot(bufferWrapper, userCodeClassLoader);

			serializersAndConfigSnapshots.add(
				new Tuple2<TypeSerializer<?>, TypeSerializerConfigSnapshot>(serializer, configSnapshot));
		}
	}

	return serializersAndConfigSnapshots;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:55,代码来源:TypeSerializerSerializationUtil.java

示例14: write

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void write(DataInputView source, int numBytes) throws IOException {
	byte[] buffer = new byte[numBytes];
	source.readFully(buffer);
	write(buffer);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:7,代码来源:SerializerTestBase.java

示例15: read

import org.apache.flink.core.memory.DataInputView; //导入方法依赖的package包/类
@Override
public void read(DataInputView in) throws IOException {
	this.magicNumber = in.readLong();
	this.payload = new byte[in.readInt()];
	in.readFully(this.payload);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:7,代码来源:TestEvent.java


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