List of usage examples for org.apache.cassandra.db.marshal MapType valueComparator
public AbstractType<V> valueComparator()
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);/* ww w . jav a2s .c o m*/ 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 w w w. java2s . 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();//from ww w.ja v a 2 s. co m if (dataTypeArg1.equals(varchar())) dataTypeArg1 = text(); Assert.assertEquals(Codec.rawTypeToDataType(mapType.nameComparator()), dataTypeArg0); Assert.assertEquals(Codec.rawTypeToDataType(mapType.valueComparator()), dataTypeArg1); }
From source file:com.tuplejump.stargate.cassandra.CassandraUtils.java
License:Apache License
public static AbstractType getValueValidator(AbstractType abstractType) { if (abstractType instanceof CollectionType) { if (abstractType instanceof MapType) { MapType mapType = (MapType) abstractType; return mapType.valueComparator(); } else if (abstractType instanceof SetType) { SetType setType = (SetType) abstractType; return setType.nameComparator(); } else if (abstractType instanceof ListType) { ListType listType = (ListType) abstractType; return listType.valueComparator(); }//from ww w . j a v a 2 s.co m } return abstractType; }