com.datastax.driver.core.TupleType Java Examples

The following examples show how to use com.datastax.driver.core.TupleType. 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: CassandraTypeConverterTest.java    From debezium-incubator with Apache License 2.0 5 votes vote down vote up
@Test
public void testTuple() {
    // tuple containing timestamp and smallint.
    // tuples are always frozen, so we don't need to test that.
    // we don't care about the protocol version or the codec registry.
    DataType tupleType = TupleType.of(null, null, DataType.timestamp(), DataType.smallint());
    AbstractType<?> convertedType = CassandraTypeConverter.convert(tupleType);

    List<AbstractType<?>> innerAbstractTypes = new ArrayList<>(2);
    innerAbstractTypes.add(TimestampType.instance);
    innerAbstractTypes.add(ShortType.instance);
    org.apache.cassandra.db.marshal.TupleType expectedType = new org.apache.cassandra.db.marshal.TupleType(innerAbstractTypes);

    Assert.assertEquals(expectedType, convertedType);
}
 
Example #2
Source File: EnqueuedMailsDaoUtil.java    From james-project with Apache License 2.0 5 votes vote down vote up
static ImmutableList<TupleValue> toTupleList(TupleType userHeaderNameHeaderValueTriple, PerRecipientHeaders perRecipientHeaders) {
    return perRecipientHeaders.getHeadersByRecipient()
        .entries()
        .stream()
        .map(entry -> userHeaderNameHeaderValueTriple.newValue(entry.getKey().asString(), entry.getValue().getName(), entry.getValue().getValue()))
        .collect(Guavate.toImmutableList());
}
 
Example #3
Source File: DatastaxTupleGetter.java    From SimpleFlatMapper with MIT License 5 votes vote down vote up
public static <P extends Tuple2<?, ?>> ContextualSourceMapper<GettableByIndexData, P> newTupleMapper(Type target, TupleType tt, DatastaxMapperFactory factory) {
    ConstantSourceMapperBuilder<GettableByIndexData, P, DatastaxColumnKey> builder =
            DatastaxUDTGetter.newFieldMapperBuilder(factory, target);

    List<DataType> componentTypes = tt.getComponentTypes();
    for(int i = 0; i < componentTypes.size(); i++) {
        FieldMapperColumnDefinition<DatastaxColumnKey> identity = FieldMapperColumnDefinition.identity();
        builder.addMapping(new DatastaxColumnKey(String.valueOf( i), i, componentTypes.get(i)),
                identity);
    }

    return builder.mapper();
}
 
Example #4
Source File: TupleValueSettableDataSetter.java    From SimpleFlatMapper with MIT License 5 votes vote down vote up
public static <T extends Tuple2<?, ?>> FieldMapper<T, SettableByIndexData> newTupleMapper(Type target, TupleType tt,
                                                                                          MapperConfig<DatastaxColumnKey, ?> config,
                                                                                          ReflectionService reflectionService) {
    SettableDataMapperBuilder<T> builder = newFieldMapperBuilder(config, reflectionService, target);
    List<DataType> componentTypes = tt.getComponentTypes();
    for(int i = 0; i < componentTypes.size(); i++) {
        builder.addColumn(new DatastaxColumnKey(String.valueOf(i), i, componentTypes.get(i)));
    }
    return builder.mapper();
}
 
Example #5
Source File: DatastaxTupleGetter.java    From SimpleFlatMapper with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public static <P extends  Tuple2<?, ?>> Getter<GettableByIndexData, P> newInstance(DatastaxMapperFactory factory, Type target,  TupleType tt, int index) {
    ContextualSourceMapper<GettableByIndexData, P> mapper = newTupleMapper(target, tt, factory);
    return new DatastaxTupleGetter<P>(mapper, index);
}
 
Example #6
Source File: ConverterToTupleValueMapper.java    From SimpleFlatMapper with MIT License 4 votes vote down vote up
public ConverterToTupleValueMapper(FieldMapper<I, TupleValue> mapper, TupleType tupleType) {
    this.mapper = mapper;
    this.tupleType = tupleType;
}