private static Type fromKuduClientType(org.apache.kudu.Type ktype, ColumnTypeAttributes attributes) { switch (ktype) { case STRING: return VarcharType.VARCHAR; case UNIXTIME_MICROS: return TimestampType.TIMESTAMP; case INT64: return BigintType.BIGINT; case INT32: return IntegerType.INTEGER; case INT16: return SmallintType.SMALLINT; case INT8: return TinyintType.TINYINT; case FLOAT: return RealType.REAL; case DOUBLE: return DoubleType.DOUBLE; case BOOL: return BooleanType.BOOLEAN; case BINARY: return VarbinaryType.VARBINARY; case DECIMAL: return DecimalType.createDecimalType(attributes.getPrecision(), attributes.getScale()); default: throw new IllegalStateException("Kudu type not implemented for " + ktype); } }
private static Type fromKuduClientType(org.apache.kudu.Type ktype, ColumnTypeAttributes attributes) { switch (ktype) { case STRING: return VarcharType.VARCHAR; case UNIXTIME_MICROS: return TimestampType.TIMESTAMP; case INT64: return BigintType.BIGINT; case INT32: return IntegerType.INTEGER; case INT16: return SmallintType.SMALLINT; case INT8: return TinyintType.TINYINT; case FLOAT: return RealType.REAL; case DOUBLE: return DoubleType.DOUBLE; case BOOL: return BooleanType.BOOLEAN; case BINARY: return VarbinaryType.VARBINARY; case DECIMAL: return DecimalType.createDecimalType(attributes.getPrecision(), attributes.getScale()); default: throw new IllegalStateException("Kudu type not implemented for " + ktype); } }
private static Type fromKuduClientType(org.apache.kudu.Type ktype, ColumnTypeAttributes attributes) { switch (ktype) { case STRING: return VarcharType.VARCHAR; case UNIXTIME_MICROS: return TimestampType.TIMESTAMP; case INT64: return BigintType.BIGINT; case INT32: return IntegerType.INTEGER; case INT16: return SmallintType.SMALLINT; case INT8: return TinyintType.TINYINT; case FLOAT: return RealType.REAL; case DOUBLE: return DoubleType.DOUBLE; case BOOL: return BooleanType.BOOLEAN; case BINARY: return VarbinaryType.VARBINARY; case DECIMAL: return DecimalType.createDecimalType(attributes.getPrecision(), attributes.getScale()); default: throw new IllegalStateException("Kudu type not implemented for " + ktype); } }
case DECIMAL: return Bytes.getDecimal(value.toByteArray(), typeAttributes.getPrecision(), typeAttributes.getScale()); default: throw new IllegalArgumentException("This type is unknown: " + type);
ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); return Bytes.getDecimal(value, typeAttributes.getPrecision(), typeAttributes.getScale()).toString(); default: throw new IllegalStateException(String.format("unknown column type %s", column.getType()));
int scale = column.getTypeAttributes().getScale(); int size = column.getTypeSize(); switch (size) {
ColumnTypeAttributes typeAttributes = col.getTypeAttributes(); sb.append(Bytes.getDecimal(rowAlloc, schema.getColumnOffset(idx), typeAttributes.getPrecision(), typeAttributes.getScale())); return; case BINARY:
/** * Set a BigDecimal for the lower bound * @param lowerBound value for the lower bound */ public void setLowerBound(BigDecimal lowerBound) { checkColumn(Type.DECIMAL); int precision = column.getTypeAttributes().getPrecision(); int scale = column.getTypeAttributes().getScale(); BigDecimal coercedVal = DecimalUtil.coerce(lowerBound, precision, scale); setLowerBoundInternal(Bytes.fromBigDecimal(coercedVal, precision)); }
public static Common.ColumnTypeAttributesPB columnTypeAttributesToPb( Common.ColumnTypeAttributesPB.Builder builder, ColumnSchema column) { ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); if (typeAttributes.hasPrecision()) { builder.setPrecision(typeAttributes.getPrecision()); } if (typeAttributes.hasScale()) { builder.setScale(typeAttributes.getScale()); } return builder.build(); }
/** * Set a BigDecimal for the upper bound * @param upperBound value for the upper bound */ public void setUpperBound(BigDecimal upperBound) { checkColumn(Type.DECIMAL); int precision = column.getTypeAttributes().getPrecision(); int scale = column.getTypeAttributes().getScale(); BigDecimal coercedVal = DecimalUtil.coerce(upperBound, precision, scale); setUpperBoundInternal(Bytes.fromBigDecimal(coercedVal, precision)); }
ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); int precision = typeAttributes.getPrecision(); int scale = typeAttributes.getScale();
ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); int precision = typeAttributes.getPrecision(); int scale = typeAttributes.getScale(); return Bytes.getDecimal(a.rowAlloc, offset, precision, scale) .equals(Bytes.getDecimal(b.rowAlloc, offset, precision, scale));
ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); int precision = typeAttributes.getPrecision(); int scale = typeAttributes.getScale(); BigDecimal val = Bytes.getDecimal(lower.rowAlloc, offset, precision, scale); BigDecimal smallestVal = DecimalUtil.smallestValue(scale);
int scale = column.getTypeAttributes().getScale(); BigDecimal existing = Bytes.getDecimal(rowAlloc, offset, precision, scale); BigDecimal max = DecimalUtil.maxValue(precision, scale);
/** * Add a Decimal for the specified column. * @param columnIndex the column's index in the schema * @param val value to add * @throws IllegalArgumentException if the value doesn't match the column's type * @throws IllegalStateException if the row was already applied * @throws IndexOutOfBoundsException if the column doesn't exist */ public void addDecimal(int columnIndex, BigDecimal val) { checkNotFrozen(); ColumnSchema column = schema.getColumnByIndex(columnIndex); ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); checkColumn(column, Type.DECIMAL); BigDecimal coercedVal = DecimalUtil.coerce(val,typeAttributes.getPrecision(), typeAttributes.getScale()); Bytes.setBigDecimal(rowAlloc, coercedVal, typeAttributes.getPrecision(), getPositionInRowAllocAndSetBitSet(columnIndex)); }
/** * Get the specified column's Decimal. * * @param columnIndex Column index in the schema * @return a BigDecimal * @throws IllegalArgumentException if the column is null, is unset, * or if the type doesn't match the column's type * @throws IndexOutOfBoundsException if the column doesn't exist */ public BigDecimal getDecimal(int columnIndex) { checkColumn(schema.getColumnByIndex(columnIndex), Type.DECIMAL); checkColumnExists(schema.getColumnByIndex(columnIndex)); checkValue(columnIndex); ColumnSchema column = schema.getColumnByIndex(columnIndex); ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); return Bytes.getDecimal(rowAlloc, schema.getColumnOffset(columnIndex), typeAttributes.getPrecision(), typeAttributes.getScale()); }
/** * Get the specified column's Decimal. * * @param columnIndex Column index in the schema * @return a BigDecimal. * @throws IllegalArgumentException if the column is null * @throws IndexOutOfBoundsException if the column doesn't exist */ public BigDecimal getDecimal(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.DECIMAL); ColumnSchema column = schema.getColumnByIndex(columnIndex); ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); return Bytes.getDecimal(this.rowData.getRawArray(), this.rowData.getRawOffset() + getCurrentRowDataOffsetForColumn(columnIndex), typeAttributes.getPrecision(), typeAttributes.getScale()); }
ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); addDecimal(index, DecimalUtil.minValue(typeAttributes.getPrecision(), typeAttributes.getScale())); break; case STRING:
ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); return KuduPredicate.newComparisonPredicate(column, op, Bytes.getDecimal(bound, typeAttributes.getPrecision(), typeAttributes.getScale())); default: throw new IllegalStateException(String.format("unknown column type %s", column.getType()));