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

The following examples show how to use org.apache.cassandra.db.marshal.IntegerType. 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: BlobPlacementFactory.java    From emodb with Apache License 2.0 6 votes vote down vote up
@Override
public Placement newPlacement(String placement) throws ConnectionException {
    String[] parsed = PlacementUtil.parsePlacement(placement);
    String keyspaceName = parsed[0];
    String cfPrefix = parsed[1];

    CassandraKeyspace keyspace = _keyspaceMap.get(keyspaceName);
    if (keyspace == null) {
        throw new UnknownPlacementException(format(
                "Placement string refers to unknown or non-local Cassandra keyspace: %s", keyspaceName), placement);
    }

    KeyspaceDefinition keyspaceDef = keyspace.getAstyanaxKeyspace().describeKeyspace();
    ColumnFamily<ByteBuffer,Composite> columnFamily = getColumnFamily(keyspaceDef, cfPrefix, "blob", placement,
            new SpecificCompositeSerializer(CompositeType.getInstance(Arrays.<AbstractType<?>>asList(
                    AsciiType.instance, IntegerType.instance))));

    return new BlobPlacement(placement, keyspace, columnFamily);
}
 
Example #2
Source File: CellValidatorTest.java    From deep-spark with Apache License 2.0 6 votes vote down vote up
public void testValidatorClassToKind() {
    assertEquals(Kind.validatorClassToKind(null), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(TimeUUIDType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(UTF8Type.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(Int32Type.class), Kind.NOT_A_COLLECTION);

    assertEquals(Kind.validatorClassToKind(BooleanType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(TimestampType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(DecimalType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(LongType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(DoubleType.class), Kind.NOT_A_COLLECTION);

    assertEquals(Kind.validatorClassToKind(FloatType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(InetAddressType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(IntegerType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(UUIDType.class), Kind.NOT_A_COLLECTION);

    assertEquals(Kind.validatorClassToKind(SetType.class), Kind.SET);
    assertEquals(Kind.validatorClassToKind(ListType.class), Kind.LIST);
    assertEquals(Kind.validatorClassToKind(MapType.class), Kind.MAP);
}
 
Example #3
Source File: Term.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the typed value, serialized to a ByteBuffer.
 *
 * @return a ByteBuffer of the value.
 * @throws InvalidRequestException if unable to coerce the string to its type.
 */
public ByteBuffer getByteBuffer() throws InvalidRequestException
{
    switch (type)
    {
        case STRING:
            return AsciiType.instance.fromString(text);
        case INTEGER:
            return IntegerType.instance.fromString(text);
        case UUID:
            // we specifically want the Lexical class here, not "UUIDType," because we're supposed to have
            // a uuid-shaped string here, and UUIDType also accepts integer or date strings (and turns them into version 1 uuids).
            return LexicalUUIDType.instance.fromString(text);
        case FLOAT:
          return FloatType.instance.fromString(text);
    }

    // FIXME: handle scenario that should never happen
    return null;
}
 
Example #4
Source File: IndexHelperTest.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
public void testIndexHelper()
{
    List<IndexInfo> indexes = new ArrayList<IndexInfo>();
    indexes.add(new IndexInfo(cn(0L), cn(5L), 0, 0));
    indexes.add(new IndexInfo(cn(10L), cn(15L), 0, 0));
    indexes.add(new IndexInfo(cn(20L), cn(25L), 0, 0));

    CellNameType comp = new SimpleDenseCellNameType(IntegerType.instance);

    assertEquals(0, IndexHelper.indexFor(cn(-1L), indexes, comp, false, -1));
    assertEquals(0, IndexHelper.indexFor(cn(5L), indexes, comp, false, -1));
    assertEquals(1, IndexHelper.indexFor(cn(12L), indexes, comp, false, -1));
    assertEquals(2, IndexHelper.indexFor(cn(17L), indexes, comp, false, -1));
    assertEquals(3, IndexHelper.indexFor(cn(100L), indexes, comp, false, -1));
    assertEquals(3, IndexHelper.indexFor(cn(100L), indexes, comp, false, 0));
    assertEquals(3, IndexHelper.indexFor(cn(100L), indexes, comp, false, 1));
    assertEquals(3, IndexHelper.indexFor(cn(100L), indexes, comp, false, 2));
    assertEquals(-1, IndexHelper.indexFor(cn(100L), indexes, comp, false, 3));

    assertEquals(-1, IndexHelper.indexFor(cn(-1L), indexes, comp, true, -1));
    assertEquals(0, IndexHelper.indexFor(cn(5L), indexes, comp, true, -1));
    assertEquals(1, IndexHelper.indexFor(cn(17L), indexes, comp, true, -1));
    assertEquals(2, IndexHelper.indexFor(cn(100L), indexes, comp, true, -1));
    assertEquals(0, IndexHelper.indexFor(cn(100L), indexes, comp, true, 0));
    assertEquals(1, IndexHelper.indexFor(cn(12L), indexes, comp, true, -1));
    assertEquals(1, IndexHelper.indexFor(cn(100L), indexes, comp, true, 1));
    assertEquals(2, IndexHelper.indexFor(cn(100L), indexes, comp, true, 2));
    assertEquals(-1, IndexHelper.indexFor(cn(100L), indexes, comp, true, 4));
}
 
Example #5
Source File: MvccLogEntrySerializationStrategyV2Impl.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MultiTenantColumnFamilyDefinition> getColumnFamilies() {
    //create the CF entity data.  We want it reversed b/c we want the most recent version at the top of the
    //row for fast seeks
    MultiTenantColumnFamilyDefinition cf =
        new MultiTenantColumnFamilyDefinition( CF_ENTITY_LOG_V2, BytesType.class.getSimpleName(),
            ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")",
            IntegerType.class.getSimpleName(), MultiTenantColumnFamilyDefinition.CacheOption.KEYS );


    return Collections.singleton( cf );
}
 
Example #6
Source File: MvccLogEntrySerializationStrategyV1Impl.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MultiTenantColumnFamilyDefinition> getColumnFamilies() {
    //create the CF entity data.  We want it reversed b/c we want the most recent version at the top of the
    //row for fast seeks
    MultiTenantColumnFamilyDefinition cf =
            new MultiTenantColumnFamilyDefinition( CF_ENTITY_LOG, BytesType.class.getSimpleName(),
                    ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")",
                    IntegerType.class.getSimpleName(), MultiTenantColumnFamilyDefinition.CacheOption.KEYS );


    return Collections.singleton( cf );
}
 
Example #7
Source File: RandomPartitioner.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public AbstractType<?> getTokenValidator()
{
    return IntegerType.instance;
}
 
Example #8
Source File: BigIntegers.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public BigIntegers(String name, GeneratorConfig config)
{
    super(IntegerType.instance, config, name, BigInteger.class);
}
 
Example #9
Source File: KeyCollisionTest.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public AbstractType<?> getTokenValidator()
{
    return IntegerType.instance;
}