Search in sources :

Example 41 with Type

use of org.apache.cassandra.cql3.statements.schema.IndexTarget.Type 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)

Example 42 with Type

use of org.apache.cassandra.cql3.statements.schema.IndexTarget.Type 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)

Aggregations

CQL3Type (org.apache.cassandra.cql3.CQL3Type)14 ByteBuffer (java.nio.ByteBuffer)12 Test (org.junit.Test)12 AbstractType (org.apache.cassandra.db.marshal.AbstractType)11 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)10 ArrayList (java.util.ArrayList)9 List (java.util.List)8 ClientState (org.apache.cassandra.service.ClientState)8 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)7 ProtocolVersion (org.apache.cassandra.transport.ProtocolVersion)7 FunctionName (org.apache.cassandra.cql3.functions.FunctionName)6 InvalidRequestException (org.apache.cassandra.exceptions.InvalidRequestException)6 java.util (java.util)4 Collections (java.util.Collections)4 ChronicleQueue (net.openhft.chronicle.queue.ChronicleQueue)4 ExcerptTailer (net.openhft.chronicle.queue.ExcerptTailer)4 RollCycles (net.openhft.chronicle.queue.RollCycles)4 QueryOptions (org.apache.cassandra.cql3.QueryOptions)4 TableMetadata (org.apache.cassandra.schema.TableMetadata)4 Set (java.util.Set)3