Search in sources :

Example 6 with TypeCodec

use of com.datastax.driver.core.TypeCodec in project apex-malhar by apache.

the class UserUpsertOperator method getCodecsForUserDefinedTypes.

@Override
public Map<String, TypeCodec> getCodecsForUserDefinedTypes() {
    Map<String, TypeCodec> allCodecs = new HashMap<>();
    CodecRegistry codecRegistry = cluster.getConfiguration().getCodecRegistry();
    UserType addressType = cluster.getMetadata().getKeyspace(getConnectionStateManager().getKeyspaceName()).getUserType("address");
    TypeCodec<UDTValue> addressTypeCodec = codecRegistry.codecFor(addressType);
    AddressCodec addressCodec = new AddressCodec(addressTypeCodec, Address.class);
    allCodecs.put("currentaddress", addressCodec);
    UserType userFullNameType = cluster.getMetadata().getKeyspace(getConnectionStateManager().getKeyspaceName()).getUserType("fullname");
    TypeCodec<UDTValue> userFullNameTypeCodec = codecRegistry.codecFor(userFullNameType);
    FullNameCodec fullNameCodec = new FullNameCodec(userFullNameTypeCodec, FullName.class);
    allCodecs.put("username", fullNameCodec);
    return allCodecs;
}
Also used : UDTValue(com.datastax.driver.core.UDTValue) HashMap(java.util.HashMap) TypeCodec(com.datastax.driver.core.TypeCodec) CodecRegistry(com.datastax.driver.core.CodecRegistry) UserType(com.datastax.driver.core.UserType)

Aggregations

TypeCodec (com.datastax.driver.core.TypeCodec)6 UDTValue (com.datastax.driver.core.UDTValue)3 UserType (com.datastax.driver.core.UserType)3 CodecRegistry (com.datastax.driver.core.CodecRegistry)2 DataType (com.datastax.driver.core.DataType)2 File (java.io.File)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Matcher (java.util.regex.Matcher)1