use of org.apache.cassandra.cql3.CQL3Type in project stargate-core by tuplejump.
the class CassandraUtils method setFromAbstractType.
public static void setFromAbstractType(Properties properties, AbstractType type) {
if (properties.getType() != null)
return;
CQL3Type cqlType = type.asCQL3Type();
Type fromAbstractType = fromAbstractType(cqlType);
properties.setType(fromAbstractType);
}
use of org.apache.cassandra.cql3.CQL3Type in project stargate-core by tuplejump.
the class Fields method numericDocValuesField.
private static Field numericDocValuesField(String stripedName, final AbstractType abstractType, final ByteBuffer byteBufferValue) {
CQL3Type cqlType = abstractType.asCQL3Type();
if (cqlType == CQL3Type.Native.TIMESTAMP) {
Date date = (Date) abstractType.compose(byteBufferValue);
return new NumericDocValuesField(stripedName, date.getTime());
}
Number value = (Number) abstractType.compose(byteBufferValue);
if (cqlType == CQL3Type.Native.INT || cqlType == CQL3Type.Native.VARINT || cqlType == CQL3Type.Native.BIGINT || cqlType == CQL3Type.Native.COUNTER) {
return new NumericDocValuesField(stripedName, value.longValue());
} else if (cqlType == CQL3Type.Native.FLOAT) {
return new FloatDocValuesField(stripedName, value.floatValue());
} else if (cqlType == CQL3Type.Native.DECIMAL || cqlType == CQL3Type.Native.DOUBLE) {
return new DoubleDocValuesField(stripedName, value.doubleValue());
} else
throw new IllegalArgumentException(String.format("Invalid type for numeric doc values <%s>", cqlType));
}
Aggregations