@Override public void returnInputBuffer(BufferObjectDataInput in) { if (in == null) { return; } in.clear(); offerOrClose(inputQueue, in); }
private void tryFillInbox() { try { long totalBytes = 0; long totalItems = 0; for (BufferObjectDataInput received; (received = incoming.poll()) != null; ) { final int itemCount = received.readInt(); for (int i = 0; i < itemCount; i++) { final int mark = received.position(); final Object item = received.readObject(); final int itemSize = received.position() - mark; inbox.add(new ObjWithPtionIdAndSize(item, received.readInt(), itemSize)); } totalItems += itemCount; totalBytes += received.position(); received.close(); tracker.madeProgress(); } lazyAdd(bytesInCounter, totalBytes); lazyAdd(itemsInCounter, totalItems); } catch (IOException e) { throw rethrow(e); } }
private static boolean navigateContextToNextPortableTokenFromPortableField(PortableNavigatorContext ctx) throws IOException { BufferObjectDataInput in = ctx.getIn(); // find the field position that's stored in the fieldDefinition int the context and navigate to it int pos = getStreamPositionOfTheField(ctx); in.position(pos); // check if it's null, if so return false indicating that the navigation has failed boolean isNull = in.readBoolean(); if (isNull) { return false; } // read factory and class ID and validate if it's the same as expected in the fieldDefinition int factoryId = in.readInt(); int classId = in.readInt(); int versionId = in.readInt(); // initialise context with the given portable field for further navigation ctx.advanceContextToNextPortableToken(factoryId, classId, versionId); return true; }
private byte[] readSingleByteArray(PortablePosition position) throws IOException { validateType(position, FieldType.BYTE_ARRAY); in.position(position.getStreamPosition()); return in.readByteArray(); }
case BYTE: case BYTE_ARRAY: return (T) Byte.valueOf(in.readByte(position.getStreamPosition())); case SHORT: case SHORT_ARRAY: return (T) Short.valueOf(in.readShort(position.getStreamPosition())); case INT: case INT_ARRAY: return (T) Integer.valueOf(in.readInt(position.getStreamPosition())); case LONG: case LONG_ARRAY: return (T) Long.valueOf(in.readLong(position.getStreamPosition())); case FLOAT: case FLOAT_ARRAY: return (T) Float.valueOf(in.readFloat(position.getStreamPosition())); case DOUBLE: case DOUBLE_ARRAY: return (T) Double.valueOf(in.readDouble(position.getStreamPosition())); case BOOLEAN: case BOOLEAN_ARRAY: return (T) Boolean.valueOf(in.readBoolean(position.getStreamPosition())); case CHAR: case CHAR_ARRAY: return (T) Character.valueOf(in.readChar(position.getStreamPosition())); case UTF: case UTF_ARRAY: in.position(position.getStreamPosition()); return (T) in.readUTF(); case PORTABLE:
in.readInt(); int fieldCount = in.readInt(); int offset = in.position(); for (int i = 0; i < fieldCount; i++) { int pos = in.readInt(offset + i * Bits.INT_SIZE_IN_BYTES); in.position(pos); short len = in.readShort(); char[] chars = new char[len]; for (int k = 0; k < len; k++) { chars[k] = (char) in.readUnsignedByte(); FieldType type = FieldType.get(in.readByte()); String name = new String(chars); int fieldFactoryId = 0; if (in.readBoolean()) { register = false; fieldFactoryId = in.readInt(); fieldClassId = in.readInt(); fieldVersion = in.readInt(); readClassDefinition(in, fieldFactoryId, fieldClassId, fieldVersion); int k = in.readInt(); fieldFactoryId = in.readInt(); fieldClassId = in.readInt();
/** * Sets up the stream for the given frame which contains all info required to change to context for a given field. */ void advanceContextToGivenFrame(NavigationFrame frame) { in.position(frame.streamPosition); offset = frame.streamOffset; cd = frame.cd; }
if (inputProcessor == null) { input.position(offset); final byte packetVersion = input.readByte(); if (packetVersion != Packet.VERSION) { logger.warning("Received a JoinRequest with a different packet version, or encrypted. " return input.readObject(); } finally { input.close();
private String[] readMultiUTFArray(List<PortablePosition> positions) throws IOException { String[] result = new String[positions.size()]; for (int i = 0; i < result.length; i++) { PortablePosition position = positions.get(i); if (!position.isNullOrEmpty()) { validateType(position, FieldType.UTF); in.position(position.getStreamPosition()); result[i] = in.readUTF(); } } return result; }
private char[] readSingleCharArray(PortablePosition position) throws IOException { validateType(position, FieldType.CHAR_ARRAY); in.position(position.getStreamPosition()); return in.readCharArray(); }
private int[] readSingleIntArray(PortablePosition position) throws IOException { validateType(position, FieldType.INT_ARRAY); in.position(position.getStreamPosition()); return in.readIntArray(); }
private boolean[] readSingleBooleanArray(PortablePosition position) throws IOException { validateType(position, FieldType.BOOLEAN_ARRAY); in.position(position.getStreamPosition()); return in.readBooleanArray(); }
private long[] readSingleLongArray(PortablePosition position) throws IOException { validateType(position, FieldType.LONG_ARRAY); in.position(position.getStreamPosition()); return in.readLongArray(); }
private float[] readSingleFloatArray(PortablePosition position) throws IOException { validateType(position, FieldType.FLOAT_ARRAY); in.position(position.getStreamPosition()); return in.readFloatArray(); }
private String[] readSingleUTFArray(PortablePosition position) throws IOException { validateType(position, FieldType.UTF_ARRAY); in.position(position.getStreamPosition()); return in.readUTFArray(); }
private double[] readSingleDoubleArray(PortablePosition position) throws IOException { validateType(position, FieldType.DOUBLE_ARRAY); in.position(position.getStreamPosition()); return in.readDoubleArray(); }
private short[] readSingleShortArray(PortablePosition position) throws IOException { validateType(position, FieldType.SHORT_ARRAY); in.position(position.getStreamPosition()); return in.readShortArray(); }
private Traverser<Object> traverser(byte[] data) { BufferObjectDataInput in = serializationService.createObjectDataInput(data); return () -> uncheckCall(() -> { Object key = in.readObject(); if (key == SnapshotDataValueTerminator.INSTANCE) { in.close(); return null; } Object value = in.readObject(); return key instanceof BroadcastKey ? new BroadcastEntry(key, value) : entry(key, value); }); }
private boolean isQuote() throws IOException { return input.readByte() == '"'; }