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

The following examples show how to use org.apache.cassandra.db.marshal.InetAddressType. 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: CassandraTypeConverterTest.java    From debezium-incubator with Apache License 2.0 5 votes vote down vote up
@Test
public void testInet() {
    DataType inetType = DataType.inet();
    AbstractType<?> convertedType = CassandraTypeConverter.convert(inetType);

    InetAddressType expectedType = InetAddressType.instance;

    Assert.assertEquals(expectedType, convertedType);
}
 
Example #3
Source File: CassandraTypeDeserializerTest.java    From debezium-incubator with Apache License 2.0 5 votes vote down vote up
@Test
public void testInetAddressType() throws UnknownHostException {
    InetAddress sourceInetAddress = InetAddress.getLocalHost();
    // the address is the only thing that cassandra will seralize for an inetadress.
    String expectedInetAddress = "/" + sourceInetAddress.getHostAddress();

    ByteBuffer serializedInetAddress = InetAddressType.instance.decompose(sourceInetAddress);

    Object deserializedInetAddress = CassandraTypeDeserializer.deserialize(InetAddressType.instance, serializedInetAddress);

    Assert.assertEquals(expectedInetAddress, deserializedInetAddress);
}
 
Example #4
Source File: CellValidatorTest.java    From deep-spark with Apache License 2.0 5 votes vote down vote up
public void testDataTypeNoCollectionInstantiation() {
    DataType type = DataType.inet();

    CellValidator cv = cellValidator(type);
    assertNotNull(cv);
    assertEquals(cv.getValidatorClassName(), InetAddressType.class.getCanonicalName());
    assertNull(cv.getValidatorTypes());
    assertEquals(cv.validatorKind(), Kind.NOT_A_COLLECTION);
    assertEquals(DataType.Name.INET, cv.getCqlTypeName());

    assertNotNull(cv.getAbstractType());
    assertEquals(cv.getAbstractType(), InetAddressType.instance);
}
 
Example #5
Source File: ColumnMapperInet.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
/**
 * Builds a new {@link ColumnMapperInet}.
 */
@JsonCreator
public ColumnMapperInet() {
    super(new AbstractType<?>[]{AsciiType.instance, UTF8Type.instance, InetAddressType.instance},
          new AbstractType[]{});
}
 
Example #6
Source File: Inets.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public Inets(String name, GeneratorConfig config)
{
    super(InetAddressType.instance, config, name, InetAddress.class);
    buf = new byte[4];
}