Example usage for org.apache.cassandra.db.marshal MapType nameComparator

List of usage examples for org.apache.cassandra.db.marshal MapType nameComparator

Introduction

In this page you can find the example usage for org.apache.cassandra.db.marshal MapType nameComparator.

Prototype

public AbstractType<K> nameComparator() 

Source Link

Usage

From source file:com.datastax.driver.core.CodecTest.java

License:Apache License

@Test(groups = "unit")
public void testCustomKeyMap() throws Exception {
    MapType<?, ?> mapType = (MapType) Codec.getCodec(DataType.map(CUSTOM_FOO, text()));
    Assert.assertNotNull(mapType);/*from   ww  w  . j a  v  a 2  s. c om*/
    Assert.assertEquals(mapType.nameComparator().getClass(), BytesType.class);
    Assert.assertEquals(mapType.valueComparator().getClass(), UTF8Type.class);
}

From source file:com.datastax.driver.core.CodecTest.java

License:Apache License

@Test(groups = "unit")
public void testCustomValueMap() throws Exception {
    MapType<?, ?> mapType = (MapType) Codec.getCodec(DataType.map(text(), CUSTOM_FOO));
    Assert.assertNotNull(mapType);//from  ww w .  j a v  a 2s  .  c om
    Assert.assertEquals(mapType.nameComparator().getClass(), UTF8Type.class);
    Assert.assertEquals(mapType.valueComparator().getClass(), BytesType.class);
}

From source file:com.datastax.driver.core.CodecTest.java

License:Apache License

private void testPairAgainstMapType(DataType dataTypeArg0, DataType dataTypeArg1, MapType<?, ?> mapType) {
    // Special case: DataType varchar yields Codec.rawTypeToDataType(...) => text causing assertion fail
    // Solution: Remove DataType.varchar and check that it yields DataType.text

    // In the map case this would be quite many combinations of text/varchar so I translate varchar to text
    // in order to expect text instead of varchar back from those cases:
    if (dataTypeArg0.equals(varchar()))
        dataTypeArg0 = text();/*ww  w. ja  v  a2 s  . co  m*/
    if (dataTypeArg1.equals(varchar()))
        dataTypeArg1 = text();

    Assert.assertEquals(Codec.rawTypeToDataType(mapType.nameComparator()), dataTypeArg0);
    Assert.assertEquals(Codec.rawTypeToDataType(mapType.valueComparator()), dataTypeArg1);
}