Search in sources :

Example 6 with CQL3Type

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);
}
Also used : CQL3Type(org.apache.cassandra.cql3.CQL3Type) Type(com.tuplejump.stargate.lucene.Type) FieldType(org.apache.lucene.document.FieldType) CQL3Type(org.apache.cassandra.cql3.CQL3Type)

Example 7 with CQL3Type

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));
}
Also used : CQL3Type(org.apache.cassandra.cql3.CQL3Type) Date(java.util.Date)

Aggregations

CQL3Type (org.apache.cassandra.cql3.CQL3Type)6 Type (com.tuplejump.stargate.lucene.Type)2 ArrayList (java.util.ArrayList)2 FieldType (org.apache.lucene.document.FieldType)2 Iterables (com.google.common.collect.Iterables)1 Options (com.tuplejump.stargate.lucene.Options)1 Properties (com.tuplejump.stargate.lucene.Properties)1 java.util (java.util)1 Date (java.util.Date)1 Collectors (java.util.stream.Collectors)1 Permission (org.apache.cassandra.auth.Permission)1 ColumnDefinition (org.apache.cassandra.config.ColumnDefinition)1 org.apache.cassandra.cql3 (org.apache.cassandra.cql3)1 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)1 Keyspace (org.apache.cassandra.db.Keyspace)1 AbstractType (org.apache.cassandra.db.marshal.AbstractType)1 CollectionType (org.apache.cassandra.db.marshal.CollectionType)1 View (org.apache.cassandra.db.view.View)1 org.apache.cassandra.exceptions (org.apache.cassandra.exceptions)1 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)1