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

The following examples show how to use org.apache.cassandra.db.marshal.BooleanType. 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: 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 #2
Source File: LazyCassandraUtils.java    From Hive-Cassandra with Apache License 2.0 6 votes vote down vote up
public static AbstractType getCassandraType(PrimitiveObjectInspector oi) {
  switch (oi.getPrimitiveCategory()) {
  case BOOLEAN:
    return BooleanType.instance;
  case INT:
    return Int32Type.instance;
  case LONG:
    return LongType.instance;
  case FLOAT:
    return FloatType.instance;
  case DOUBLE:
    return DoubleType.instance;
  case STRING:
    return UTF8Type.instance;
  case BYTE:
  case SHORT:
  case BINARY:
    return BytesType.instance;
  case TIMESTAMP:
    return DateType.instance;
  default:
    throw new RuntimeException("Hive internal error.");

  }
}
 
Example #3
Source File: CassandraTypeConverterTest.java    From debezium-incubator with Apache License 2.0 5 votes vote down vote up
@Test
public void testBoolean() {
    DataType booleanType = DataType.cboolean();
    AbstractType<?> convertedType = CassandraTypeConverter.convert(booleanType);

    BooleanType expectedType = BooleanType.instance;

    Assert.assertEquals(expectedType, convertedType);
}
 
Example #4
Source File: ModificationStatement.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public static ResultSet buildCasResultSet(String ksName, ByteBuffer key, String cfName, ColumnFamily cf, Iterable<ColumnDefinition> columnsWithConditions, boolean isBatch, QueryOptions options)
throws InvalidRequestException
{
    boolean success = cf == null;

    ColumnSpecification spec = new ColumnSpecification(ksName, cfName, CAS_RESULT_COLUMN, BooleanType.instance);
    ResultSet.Metadata metadata = new ResultSet.Metadata(Collections.singletonList(spec));
    List<List<ByteBuffer>> rows = Collections.singletonList(Collections.singletonList(BooleanType.instance.decompose(success)));

    ResultSet rs = new ResultSet(metadata, rows);
    return success ? rs : merge(rs, buildCasFailureResultSet(key, cf, columnsWithConditions, isBatch, options));
}
 
Example #5
Source File: MvccEntitySerializationStrategyV3Impl.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@Override
public java.util.Collection 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_DATA, BytesType.class.getSimpleName(),
                    BooleanType.class.getSimpleName() ,
                    BytesType.class.getSimpleName(), MultiTenantColumnFamilyDefinition.CacheOption.KEYS );


    return Collections.singleton( cf );
}
 
Example #6
Source File: NodeSerializationImpl.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<MultiTenantColumnFamilyDefinition> getColumnFamilies() {
    return Collections.singleton(
            new MultiTenantColumnFamilyDefinition( GRAPH_DELETE, BytesType.class.getSimpleName(),
                    BooleanType.class.getSimpleName(), BytesType.class.getSimpleName(),
                    MultiTenantColumnFamilyDefinition.CacheOption.ALL ) );
}
 
Example #7
Source File: ColumnMapperBoolean.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
/**
 * Builds a new {@link ColumnMapperBlob}.
 */
@JsonCreator
public ColumnMapperBoolean() {
    super(new AbstractType<?>[]{AsciiType.instance, UTF8Type.instance, BooleanType.instance}, new AbstractType[]{});
}
 
Example #8
Source File: Booleans.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public Booleans(String name, GeneratorConfig config)
{
    super(BooleanType.instance, config, name, Boolean.class);
}
 
Example #9
Source File: CassandraTypeDeserializerTest.java    From debezium-incubator with Apache License 2.0 3 votes vote down vote up
@Test
public void testBoolean() {
    Boolean expectedBoolean = true;

    ByteBuffer serializedBoolean = BooleanType.instance.decompose(expectedBoolean);

    Object deserializedBoolean = CassandraTypeDeserializer.deserialize(BooleanType.instance, serializedBoolean);

    Assert.assertEquals(expectedBoolean, deserializedBoolean);
}