private boolean isSupportedType(Type type) { return ImmutableSet.<Type>of(TINYINT, SMALLINT, INTEGER, BIGINT, REAL, DOUBLE, BOOLEAN, DATE, TIMESTAMP, VARBINARY).contains(type) || isVarcharType(type) || type instanceof DecimalType; } }
public static Slice truncateToLength(Slice slice, Type type) { requireNonNull(type, "type is null"); if (!isVarcharType(type)) { throw new IllegalArgumentException("type must be the instance of VarcharType"); } return truncateToLength(slice, VarcharType.class.cast(type)); }
public static int computeTruncatedLength(Slice slice, int offset, int length, int maxCodePointCount, boolean isCharType) { if (isCharType) { // truncate the characters and then remove the trailing white spaces return byteCountWithoutTrailingSpace(slice, offset, length, maxCodePointCount); } if (maxCodePointCount >= 0 && length > maxCodePointCount) { return byteCount(slice, offset, length, maxCodePointCount); } return length; }
@Override public Slice getSlice() { Slice slice = Slices.wrappedBuffer(value.slice()); return Varchars.truncateToLength(slice, columnType); } }
public static Slice truncateToLength(Slice slice, VarcharType varcharType) { requireNonNull(varcharType, "varcharType is null"); return truncateToLength(slice, varcharType.getLength()); }
private boolean isSupportedType(Type type) { return ImmutableSet.<Type>of(TINYINT, SMALLINT, INTEGER, BIGINT, REAL, DOUBLE, BOOLEAN, DATE, TIMESTAMP, VARBINARY).contains(type) || isVarcharType(type) || type instanceof DecimalType; } }
@Override public Slice getSlice() { String textValue = value.isValueNode() ? value.asText() : value.toString(); Slice slice = utf8Slice(textValue); if (isVarcharType(columnHandle.getType())) { slice = truncateToLength(slice, columnHandle.getType()); } return slice; } }
public static Slice truncateToLengthAndTrimSpaces(Slice slice, int maxLength) { requireNonNull(slice, "slice is null"); if (maxLength < 0) { throw new IllegalArgumentException("Max length must be greater or equal than zero"); } return trimTrailingSpaces(truncateToLength(slice, maxLength)); }
public static int computeTruncatedLength(Slice slice, int offset, int length, int maxCodePointCount, boolean isCharType) { if (isCharType) { // truncate the characters and then remove the trailing white spaces return byteCountWithoutTrailingSpace(slice, offset, length, maxCodePointCount); } if (maxCodePointCount >= 0 && length > maxCodePointCount) { return byteCount(slice, offset, length, maxCodePointCount); } return length; }
private boolean isSupportedPrimitive(Type type) { return isVarcharType(type) || ImmutableList.of( BigintType.BIGINT, BooleanType.BOOLEAN, DoubleType.DOUBLE, VarbinaryType.VARBINARY).contains(type); }
@Override public Slice getSlice() { String textValue = value.isValueNode() ? value.asText() : value.toString(); Slice slice = utf8Slice(textValue); if (isVarcharType(columnHandle.getType())) { slice = truncateToLength(slice, columnHandle.getType()); } return slice; } }
@Override public Slice getSlice() { return truncateToLength(utf8Slice(tokens[columnIndex]), columnType); } };
public static int byteCountWithoutTrailingSpace(Slice slice, int offset, int length, int codePointCount) { int truncatedLength = byteCount(slice, offset, length, codePointCount); return byteCountWithoutTrailingSpace(slice, offset, truncatedLength); }
private static boolean isSupportedType(Type type) { if (isVarcharType(type)) { return true; } if (ImmutableList.of(BIGINT, INTEGER, SMALLINT, TINYINT, BOOLEAN, DOUBLE).contains(type)) { return true; } return false; }
if (isVarcharType(type)) { value = truncateToLength(value, type);
@Override public Slice getSlice() { return truncateToLength(utf8Slice(tokens[columnIndex]), columnType); } };
public static Slice truncateToLength(Slice slice, int maxLength) { requireNonNull(slice, "slice is null"); if (maxLength < 0) { throw new IllegalArgumentException("Max length must be greater or equal than zero"); } if (maxLength == 0) { return Slices.EMPTY_SLICE; } return slice.slice(0, byteCount(slice, 0, slice.length(), maxLength)); }
private static boolean isSupportedType(Type type) { if (isVarcharType(type)) { return true; } if (ImmutableList.of(BIGINT, INTEGER, SMALLINT, TINYINT, BOOLEAN, DOUBLE).contains(type)) { return true; } return false; }
@Override protected void readValue(BlockBuilder blockBuilder, Type type) { if (definitionLevel == columnDescriptor.getMaxDefinitionLevel()) { Binary binary = valuesReader.readBytes(); Slice value; if (binary.length() == 0) { value = EMPTY_SLICE; } else { value = wrappedBuffer(binary.getBytes()); } if (isVarcharType(type)) { value = truncateToLength(value, type); } if (isCharType(type)) { value = truncateToLengthAndTrimSpaces(value, type); } type.writeSlice(blockBuilder, value); } else if (isValueNull()) { blockBuilder.appendNull(); } }
@Override public Slice getSlice() { Slice slice = Slices.wrappedBuffer(value.slice()); return Varchars.truncateToLength(slice, columnType); } }