本文整理汇总了Java中org.apache.flink.types.ByteValue.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java ByteValue.setValue方法的具体用法?Java ByteValue.setValue怎么用?Java ByteValue.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.types.ByteValue
的用法示例。
在下文中一共展示了ByteValue.setValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseField
import org.apache.flink.types.ByteValue; //导入方法依赖的package包/类
@Override
public int parseField(byte[] bytes, int startPos, int limit, char delimiter, ByteValue reusable) {
int val = 0;
boolean neg = false;
this.result = reusable;
if (bytes[startPos] == '-') {
neg = true;
startPos++;
// check for empty field with only the sign
if (startPos == limit || bytes[startPos] == delimiter) {
setErrorState(ParseErrorState.NUMERIC_VALUE_ORPHAN_SIGN);
return -1;
}
}
for (int i = startPos; i < limit; i++) {
if (bytes[i] == delimiter) {
reusable.setValue((byte) (neg ? -val : val));
return i+1;
}
if (bytes[i] < 48 || bytes[i] > 57) {
setErrorState(ParseErrorState.NUMERIC_VALUE_ILLEGAL_CHARACTER);
return -1;
}
val *= 10;
val += bytes[i] - 48;
if (val > Byte.MAX_VALUE && (!neg || val > -Byte.MIN_VALUE)) {
setErrorState(ParseErrorState.NUMERIC_VALUE_OVERFLOW_UNDERFLOW);
return -1;
}
}
reusable.setValue((byte) (neg ? -val : val));
return limit;
}
示例2: copy
import org.apache.flink.types.ByteValue; //导入方法依赖的package包/类
@Override
public ByteValue copy(ByteValue from, ByteValue reuse) {
reuse.setValue(from.getValue());
return reuse;
}
示例3: parseField
import org.apache.flink.types.ByteValue; //导入方法依赖的package包/类
@Override
public int parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, ByteValue reusable) {
if (startPos == limit) {
setErrorState(ParseErrorState.EMPTY_COLUMN);
return -1;
}
int val = 0;
boolean neg = false;
this.result = reusable;
final int delimLimit = limit - delimiter.length + 1;
if (bytes[startPos] == '-') {
neg = true;
startPos++;
// check for empty field with only the sign
if (startPos == limit || (startPos < delimLimit && delimiterNext(bytes, startPos, delimiter))) {
setErrorState(ParseErrorState.NUMERIC_VALUE_ORPHAN_SIGN);
return -1;
}
}
for (int i = startPos; i < limit; i++) {
if (i < delimLimit && delimiterNext(bytes, i, delimiter)) {
if (i == startPos) {
setErrorState(ParseErrorState.EMPTY_COLUMN);
return -1;
}
reusable.setValue((byte) (neg ? -val : val));
return i + delimiter.length;
}
if (bytes[i] < 48 || bytes[i] > 57) {
setErrorState(ParseErrorState.NUMERIC_VALUE_ILLEGAL_CHARACTER);
return -1;
}
val *= 10;
val += bytes[i] - 48;
if (val > Byte.MAX_VALUE && (!neg || val > -Byte.MIN_VALUE)) {
setErrorState(ParseErrorState.NUMERIC_VALUE_OVERFLOW_UNDERFLOW);
return -1;
}
}
reusable.setValue((byte) (neg ? -val : val));
return limit;
}