org.apache.cassandra.db.marshal.CounterColumnType Java Examples

The following examples show how to use org.apache.cassandra.db.marshal.CounterColumnType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Constants.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException
{
    if (validator instanceof ReversedType<?>)
        validator = ((ReversedType<?>) validator).baseType;
    try
    {
        // BytesType doesn't want it's input prefixed by '0x'.
        if (type == Type.HEX && validator instanceof BytesType)
            return validator.fromString(text.substring(2));
        if (validator instanceof CounterColumnType)
            return LongType.instance.fromString(text);
        return validator.fromString(text);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
Example #2
Source File: CassandraTypeConverterTest.java    From debezium-incubator with Apache License 2.0 5 votes vote down vote up
@Test
public void testCounter() {
    DataType counterType = DataType.counter();
    AbstractType<?> convertedType = CassandraTypeConverter.convert(counterType);

    CounterColumnType expectedType = CounterColumnType.instance;

    Assert.assertEquals(expectedType, convertedType);
}
 
Example #3
Source File: CollationController.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public ColumnFamily getTopLevelColumns(boolean copyOnHeap)
{
    return filter.filter instanceof NamesQueryFilter
           && cfs.metadata.getDefaultValidator() != CounterColumnType.instance
           ? collectTimeOrderedData(copyOnHeap)
           : collectAllData(copyOnHeap);
}
 
Example #4
Source File: CassandraTypeDeserializerTest.java    From debezium-incubator with Apache License 2.0 3 votes vote down vote up
@Test
public void testCounterColumnType() {
    Long expectedCounterColumnType = 42L;

    ByteBuffer serializedCounter = CounterColumnType.instance.decompose(42L);

    Object deserializedCounter = CassandraTypeDeserializer.deserialize(CounterColumnType.instance, serializedCounter);

    Assert.assertEquals(expectedCounterColumnType, deserializedCounter);
}