public static Slice truncateToLengthAndTrimSpaces(Slice slice, Type type) { requireNonNull(type, "type is null"); if (!isCharType(type)) { throw new IllegalArgumentException("type must be the instance of CharType"); } return truncateToLengthAndTrimSpaces(slice, CharType.class.cast(type)); }
public static Slice padSpaces(Slice slice, Type type) { requireNonNull(type, "type is null"); if (!isCharType(type)) { throw new IllegalArgumentException("type must be the instance of CharType"); } return padSpaces(slice, CharType.class.cast(type)); }
private static boolean hasDataSize(Type type) { return isVarcharType(type) || isCharType(type); }
public static Set<ColumnStatisticType> getSupportedColumnStatistics(Type type) { if (type.equals(BOOLEAN)) { return ImmutableSet.of(NUMBER_OF_NON_NULL_VALUES, NUMBER_OF_TRUE_VALUES); } if (isNumericType(type) || type.equals(DATE) || type.equals(TIMESTAMP)) { // TODO #7122 support non-legacy TIMESTAMP return ImmutableSet.of(MIN_VALUE, MAX_VALUE, NUMBER_OF_DISTINCT_VALUES, NUMBER_OF_NON_NULL_VALUES); } if (isVarcharType(type) || isCharType(type)) { // TODO Collect MIN,MAX once it is used by the optimizer return ImmutableSet.of(NUMBER_OF_NON_NULL_VALUES, NUMBER_OF_DISTINCT_VALUES, TOTAL_SIZE_IN_BYTES, MAX_VALUE_SIZE_IN_BYTES); } if (type.equals(VARBINARY)) { return ImmutableSet.of(NUMBER_OF_NON_NULL_VALUES, TOTAL_SIZE_IN_BYTES, MAX_VALUE_SIZE_IN_BYTES); } if (type instanceof ArrayType || type instanceof RowType || type instanceof MapType) { return ImmutableSet.of(); } // Throwing here to make sure this method is updated when a new type is added in Hive connector throw new IllegalArgumentException("Unsupported type: " + type); }
return Types.VARCHAR; if (isCharType(type)) { return Types.CHAR;
private static Integer charOctetLength(Type type) { if (isVarcharType(type)) { return ((VarcharType) type).getLength(); } if (isCharType(type)) { return ((CharType) type).getLength(); } if (type.equals(VARBINARY)) { return Integer.MAX_VALUE; } return null; }
return ((VarcharType) type).getLength(); if (isCharType(type)) { return ((CharType) type).getLength();
public static int getMaxCodePointCount(Type type) { if (isVarcharType(type)) { VarcharType varcharType = (VarcharType) type; return varcharType.isUnbounded() ? -1 : varcharType.getLengthSafe(); } if (isCharType(type)) { return ((CharType) type).getLength(); } if (isVarbinaryType(type)) { return -1; } throw new IllegalArgumentException("Unsupported encoding " + type.getDisplayName()); }
if (isCharType(type)) { CharType charType = (CharType) type; int charLength = charType.getLength();
boolean isCharType = isCharType(type); if (length > 0) {
return value; else if (isCharType(type)) { return value;
value = truncateToLength(value, type); if (isCharType(type)) { value = truncateToLengthAndTrimSpaces(value, type);
prefilledValue = varcharPartitionKey(columnValue, name, type); else if (isCharType(type)) { prefilledValue = charPartitionKey(columnValue, name, type);
statement.setBigDecimal(parameter, readBigDecimal((DecimalType) type, block, position)); else if (isVarcharType(type) || isCharType(type)) { statement.setString(parameter, type.getSlice(block, position).toStringUtf8());
private static boolean isValidPartitionType(Type type) { return type instanceof DecimalType || BOOLEAN.equals(type) || TINYINT.equals(type) || SMALLINT.equals(type) || INTEGER.equals(type) || BIGINT.equals(type) || REAL.equals(type) || DOUBLE.equals(type) || DATE.equals(type) || TIMESTAMP.equals(type) || isVarcharType(type) || isCharType(type); }
@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(); } }
return createDomain(type, hasNullValue, columnStatistics.getDecimalStatistics(), value -> encodeUnscaledValue(rescale(value, (DecimalType) type).unscaledValue())); else if (isCharType(type) && columnStatistics.getStringStatistics() != null) { return createDomain(type, hasNullValue, columnStatistics.getStringStatistics(), value -> truncateToLengthAndTrimSpaces(value, type));
parseStringColumn(column); else if (isCharType(type)) { parseStringColumn(column);
return cursor.getDouble(field); else if (isVarcharType(type) || isCharType(type) || VARBINARY.equals(type)) { return cursor.getSlice(field);
assertInstanceOf(value, String.class); else if (isCharType(column.getType())) { assertInstanceOf(value, String.class);