Java Code Examples for org.apache.flink.core.memory.DataInputView#readUnsignedByte()

The following examples show how to use org.apache.flink.core.memory.DataInputView#readUnsignedByte() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Record.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	int val = source.readUnsignedByte();
	target.writeByte(val);
	
	if (val >= MAX_BIT) {
		int shift = 7;
		int curr;
		val = val & 0x7f;
		while ((curr = source.readUnsignedByte()) >= MAX_BIT) {
			target.writeByte(curr);
			val |= (curr & 0x7f) << shift;
			shift += 7;
		}
		target.writeByte(curr);
		val |= curr << shift;
	}
	
	target.write(source, val);
}
 
Example 2
Source File: NullMaskUtils.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public static void readIntoNullMask(
	int len,
	DataInputView source,
	boolean[] nullMask) throws IOException {

	int b = 0x00;
	int bytePos = 0;

	int fieldPos = 0;
	int numPos = 0;
	while (fieldPos < len) {
		// read byte
		b = source.readUnsignedByte();
		bytePos = 0;
		numPos = Math.min(8, len - fieldPos);
		while (bytePos < numPos) {
			nullMask[fieldPos + bytePos] = (b & 0x80) > 0;
			b = b << 1;
			bytePos += 1;
		}
		fieldPos += numPos;
	}
}
 
Example 3
Source File: Record.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	int val = source.readUnsignedByte();
	target.writeByte(val);
	
	if (val >= MAX_BIT) {
		int shift = 7;
		int curr;
		val = val & 0x7f;
		while ((curr = source.readUnsignedByte()) >= MAX_BIT) {
			target.writeByte(curr);
			val |= (curr & 0x7f) << shift;
			shift += 7;
		}
		target.writeByte(curr);
		val |= curr << shift;
	}
	
	target.write(source, val);
}
 
Example 4
Source File: MaskUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("UnusedAssignment")
public static void readIntoMask(DataInputView source, boolean[] mask) throws IOException {
	final int len = mask.length;

	int b = 0x00;
	int bytePos = 0;

	int fieldPos = 0;
	int numPos = 0;
	while (fieldPos < len) {
		// read byte
		b = source.readUnsignedByte();
		bytePos = 0;
		numPos = Math.min(8, len - fieldPos);
		while (bytePos < numPos) {
			mask[fieldPos + bytePos] = (b & 0x80) > 0;
			b = b << 1;
			bytePos += 1;
		}
		fieldPos += numPos;
	}
}
 
Example 5
Source File: RecordSerializer.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	int val = source.readUnsignedByte();
	target.writeByte(val);
	
	if (val >= MAX_BIT) {
		int shift = 7;
		int curr;
		val = val & 0x7f;
		while ((curr = source.readUnsignedByte()) >= MAX_BIT) {
			target.writeByte(curr);
			val |= (curr & 0x7f) << shift;
			shift += 7;
		}
		target.writeByte(curr);
		val |= curr << shift;
	}
	
	target.write(source, val);
}
 
Example 6
Source File: NullMaskUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
public static void readIntoNullMask(
	int len,
	DataInputView source,
	boolean[] nullMask) throws IOException {

	int b = 0x00;
	int bytePos = 0;

	int fieldPos = 0;
	int numPos = 0;
	while (fieldPos < len) {
		// read byte
		b = source.readUnsignedByte();
		bytePos = 0;
		numPos = Math.min(8, len - fieldPos);
		while (bytePos < numPos) {
			nullMask[fieldPos + bytePos] = (b & 0x80) > 0;
			b = b << 1;
			bytePos += 1;
		}
		fieldPos += numPos;
	}
}
 
Example 7
Source File: RheemValue.java    From rheem with Apache License 2.0 6 votes vote down vote up
@Override
public void read(DataInputView dataInputView) throws IOException {

    int len = dataInputView.readUnsignedByte();

    if (len >= HIGH_BIT) {
        int shift = 7;
        int curr;
        len = len & 0x7f;
        while ((curr = dataInputView.readUnsignedByte()) >= HIGH_BIT) {
            len |= (curr & 0x7f) << shift;
            shift += 7;
        }
        len |= curr << shift;
    }

    byte[] array = new byte[len];

    dataInputView.read(array);

    this.data = convertToObject(array);
}
 
Example 8
Source File: RecordSerializer.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	int val = source.readUnsignedByte();
	target.writeByte(val);
	
	if (val >= MAX_BIT) {
		int shift = 7;
		int curr;
		val = val & 0x7f;
		while ((curr = source.readUnsignedByte()) >= MAX_BIT) {
			target.writeByte(curr);
			val |= (curr & 0x7f) << shift;
			shift += 7;
		}
		target.writeByte(curr);
		val |= curr << shift;
	}
	
	target.write(source, val);
}
 
Example 9
Source File: RecordSerializer.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	int val = source.readUnsignedByte();
	target.writeByte(val);
	
	if (val >= MAX_BIT) {
		int shift = 7;
		int curr;
		val = val & 0x7f;
		while ((curr = source.readUnsignedByte()) >= MAX_BIT) {
			target.writeByte(curr);
			val |= (curr & 0x7f) << shift;
			shift += 7;
		}
		target.writeByte(curr);
		val |= curr << shift;
	}
	
	target.write(source, val);
}
 
Example 10
Source File: StringValueSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	int len = source.readUnsignedByte();
	target.writeByte(len);

	if (len >= HIGH_BIT) {
		int shift = 7;
		int curr;
		len = len & 0x7f;
		while ((curr = source.readUnsignedByte()) >= HIGH_BIT) {
			target.writeByte(curr);
			len |= (curr & 0x7f) << shift;
			shift += 7;
		}
		target.writeByte(curr);
		len |= curr << shift;
	}

	for (int i = 0; i < len; i++) {
		int c = source.readUnsignedByte();
		target.writeByte(c);
		while (c >= HIGH_BIT) {
			c = source.readUnsignedByte();
			target.writeByte(c);
		}
	}
}
 
Example 11
Source File: MaskUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("UnusedAssignment")
public static void readIntoAndCopyMask(
		DataInputView source,
		DataOutputView target,
		boolean[] mask) throws IOException {
	final int len = mask.length;

	int b = 0x00;
	int bytePos = 0;

	int fieldPos = 0;
	int numPos = 0;
	while (fieldPos < len) {
		// read byte
		b = source.readUnsignedByte();
		// copy byte
		target.writeByte(b);
		bytePos = 0;
		numPos = Math.min(8, len - fieldPos);
		while (bytePos < numPos) {
			mask[fieldPos + bytePos] = (b & 0x80) > 0;
			b = b << 1;
			bytePos += 1;
		}
		fieldPos += numPos;
	}
}
 
Example 12
Source File: StringValue.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void copy(DataInputView in, DataOutputView target) throws IOException {
	int len = in.readUnsignedByte();
	target.writeByte(len);

	if (len >= HIGH_BIT) {
		int shift = 7;
		int curr;
		len = len & 0x7f;
		while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
			len |= (curr & 0x7f) << shift;
			shift += 7;
			target.writeByte(curr);
		}
		len |= curr << shift;
		target.writeByte(curr);
	}

	for (int i = 0; i < len; i++) {
		int c = in.readUnsignedByte();
		target.writeByte(c);
		while (c >= HIGH_BIT) {
			c = in.readUnsignedByte();
			target.writeByte(c);
		}
	}
}
 
Example 13
Source File: NullMaskSerDeUtils.java    From cascading-flink with Apache License 2.0 5 votes vote down vote up
public static void readNullMask(
		boolean[] mask, int length, DataInputView source) throws IOException {

	for(int fieldPos = 0; fieldPos < length; ) {
		// read byte
		int b = source.readUnsignedByte();
		for(int bytePos = 0; bytePos < 8 && fieldPos < length; bytePos++, fieldPos++) {
			mask[fieldPos] = (b & 0x80) > 0;
			b = b << 1;
		}
	}
}
 
Example 14
Source File: StringValue.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void copy(DataInputView in, DataOutputView target) throws IOException {
	int len = in.readUnsignedByte();
	target.writeByte(len);

	if (len >= HIGH_BIT) {
		int shift = 7;
		int curr;
		len = len & 0x7f;
		while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
			len |= (curr & 0x7f) << shift;
			shift += 7;
			target.writeByte(curr);
		}
		len |= curr << shift;
		target.writeByte(curr);
	}

	for (int i = 0; i < len; i++) {
		int c = in.readUnsignedByte();
		target.writeByte(c);
		while (c >= HIGH_BIT) {
			c = in.readUnsignedByte();
			target.writeByte(c);
		}
	}
}
 
Example 15
Source File: StringValueSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	int len = source.readUnsignedByte();
	target.writeByte(len);

	if (len >= HIGH_BIT) {
		int shift = 7;
		int curr;
		len = len & 0x7f;
		while ((curr = source.readUnsignedByte()) >= HIGH_BIT) {
			target.writeByte(curr);
			len |= (curr & 0x7f) << shift;
			shift += 7;
		}
		target.writeByte(curr);
		len |= curr << shift;
	}

	for (int i = 0; i < len; i++) {
		int c = source.readUnsignedByte();
		target.writeByte(c);
		while (c >= HIGH_BIT) {
			c = source.readUnsignedByte();
			target.writeByte(c);
		}
	}
}
 
Example 16
Source File: StringValue.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void copy(DataInputView in, DataOutputView target) throws IOException {
	int len = in.readUnsignedByte();
	target.writeByte(len);

	if (len >= HIGH_BIT) {
		int shift = 7;
		int curr;
		len = len & 0x7f;
		while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
			len |= (curr & 0x7f) << shift;
			shift += 7;
			target.writeByte(curr);
		}
		len |= curr << shift;
		target.writeByte(curr);
	}

	for (int i = 0; i < len; i++) {
		int c = in.readUnsignedByte();
		target.writeByte(c);
		while (c >= HIGH_BIT) {
			c = in.readUnsignedByte();
			target.writeByte(c);
		}
	}
}
 
Example 17
Source File: StringValueSerializer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
	int len = source.readUnsignedByte();
	target.writeByte(len);

	if (len >= HIGH_BIT) {
		int shift = 7;
		int curr;
		len = len & 0x7f;
		while ((curr = source.readUnsignedByte()) >= HIGH_BIT) {
			target.writeByte(curr);
			len |= (curr & 0x7f) << shift;
			shift += 7;
		}
		target.writeByte(curr);
		len |= curr << shift;
	}

	for (int i = 0; i < len; i++) {
		int c = source.readUnsignedByte();
		target.writeByte(c);
		while (c >= HIGH_BIT) {
			c = source.readUnsignedByte();
			target.writeByte(c);
		}
	}
}
 
Example 18
Source File: UnsignedByteType.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void read(DataInputView in) throws IOException {
	this.value = in.readUnsignedByte();
}
 
Example 19
Source File: UnsignedByteType.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void read(DataInputView in) throws IOException {
	this.value = in.readUnsignedByte();
}
 
Example 20
Source File: UnsignedByteType.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void read(DataInputView in) throws IOException {
	this.value = in.readUnsignedByte();
}