• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TupleType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.datastax.driver.core.TupleType的典型用法代码示例。如果您正苦于以下问题:Java TupleType类的具体用法?Java TupleType怎么用?Java TupleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TupleType类属于com.datastax.driver.core包,在下文中一共展示了TupleType类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: bindTuple

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
/**
 * Bind Tuple to BoundStatement.
 * 
 * @param bs
 * @param inList
 * @throws Exception
 */
public void bindTuple(Session session, BoundStatement bs,
		List<Object> inList) throws Exception {
	if (!isCollection()) {
		throw new Exception(
				"attempting to bind non-collection as collection");
	}
	LOG.trace("bindTuple: entered with {}", inList.toString());
	LOG.trace("bindTuple: first object's type {}", inList.get(0).getClass()
			.getCanonicalName());
	TupleType tupleType = Utils.getTupleType(session.getCluster()
			.getMetadata(), inList);
	TupleValue tv = tupleType.newValue(inList.toArray(new Object[inList
			.size()]));
	for (Integer pos : getPositions())
		bs.setTupleValue(pos, tv);
}
 
开发者ID:joef551,项目名称:camel-cql,代码行数:24,代码来源:CqlToken.java


示例2: doCreateCluster

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
private Cluster doCreateCluster(CassandraProperties properties) {
    Cluster cluster = Cluster.builder()
            .withClusterName(properties.getCluster())
            .withPort(properties.getPort())
            .addContactPoints(properties.getContactPoints())
            .withTimestampGenerator(getTimestampGenerator())
            .withPoolingOptions(
                    //TODO some default options - move to config
                    new PoolingOptions()
                            .setConnectionsPerHost(HostDistance.LOCAL, 4, 4)
                            .setConnectionsPerHost(HostDistance.REMOTE, 2, 2)
                            .setMaxRequestsPerConnection(HostDistance.LOCAL, 1024)
                            .setMaxRequestsPerConnection(HostDistance.REMOTE, 256)
            )
            .build();
    //almost all queries are idempotent except counter updates, so it's easier to mark them as idempotent
    cluster.getConfiguration().getQueryOptions().setDefaultIdempotence(true);
    
    CodecRegistry codecRegistry = cluster.getConfiguration().getCodecRegistry();

    TupleType tupleType = cluster.getMetadata()
            .newTupleType(DataType.timestamp(), DataType.varchar());
    codecRegistry.register(new ZonedDateTimeCodec(tupleType));

    QueryLogger queryLogger = QueryLogger.builder()
            .withConstantThreshold(100)
            .withMaxQueryStringLength(200)
            .build();
    cluster.register(queryLogger);

    return cluster;
}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:33,代码来源:CassandraConfiguration.java


示例3: getCql3Type

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
private static CQL3Type.Raw getCql3Type(DataType dt) throws Exception {
    CQL3Type.Raw type;
    switch (dt.getName()) {
    case LIST:
        type = CQL3Type.Raw.list(getCql3Type(dt.getTypeArguments().get(0)));
        break;
    case MAP:
        type = CQL3Type.Raw.map(getCql3Type(dt.getTypeArguments().get(0)),
                getCql3Type(dt.getTypeArguments().get(1)));
        break;
    case SET:
        type = CQL3Type.Raw.set(getCql3Type(dt.getTypeArguments().get(0)));
        break;
    case TUPLE:
        ArrayList<CQL3Type.Raw> tupleTypes = new ArrayList<CQL3Type.Raw>();
        for (DataType arg : ((TupleType) dt).getComponentTypes()) {
            tupleTypes.add(getCql3Type(arg));
        }
        type = CQL3Type.Raw.tuple(tupleTypes);
        break;
    case UDT: // Requires this UDT to already be loaded
        UserType udt = (UserType) dt;
        type = CQL3Type.Raw.userType(new UTName(new ColumnIdentifier(udt.getKeyspace(), true),
                new ColumnIdentifier(udt.getTypeName(), true)));
        break;
    default:
        type = CQL3Type.Raw.from(
                Enum.<CQL3Type.Native> valueOf(CQL3Type.Native.class, dt.getName().toString().toUpperCase()));
        break;
    }
    if (dt.isFrozen()) {
        type = CQL3Type.Raw.frozen(type);
    }
    return type;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:36,代码来源:BulkLoader.java


示例4: newTupleMapper

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
public static <P extends Tuple2<?, ?>> Mapper<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("elt" + i, i, componentTypes.get(i)),
                identity);
    }

    return builder.mapper();
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:14,代码来源:DatastaxTupleGetter.java


示例5: newTupleMapper

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
public static <T extends Tuple2<?, ?>> Mapper<T, SettableByIndexData> newTupleMapper(Type target, TupleType tt,
                                                                                     MapperConfig<DatastaxColumnKey, FieldMapperColumnDefinition<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("elt" + i, i, componentTypes.get(i)));
    }
    return builder.mapper();
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:11,代码来源:TupleValueSettableDataSetter.java


示例6: testCasscadingUnssuportedInsert

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
@Test
public void testCasscadingUnssuportedInsert() throws Exception {   
    
    DaoManager daoManager = new DaoManager(cassandra.getSession());
   
    Dao keyByAccountDao = daoManager.getKeyByAccountDao();

    
    String id = "act334345345344";
    byte[] key = new byte[] { 34, 56, 87, 88 };
    String email = "[email protected]";
    long time = System.currentTimeMillis(); 
    
    
    //////////////////////////////////////
    // insert
    // 3.x API change
    //TupleType idxType = TupleType.of(DataType.text(), DataType.bigint());
    TupleType idxType = TupleType.of(protocolVersion, codecRegistry,DataType.text(), DataType.bigint());
    try {
        keyByAccountDao.writeWhere(QueryBuilder.in(KeyByAccountColumns.ACCOUNT_ID.getName(), id))
                       .value(KeyByAccountColumns.KEY, key)
                       .addSetValue(KeyByAccountColumns.EMAIL_IDX, idxType.newValue(email, time))
                       .withConsistency(ConsistencyLevel.QUORUM)
                       .execute();
        Assert.fail("InvalidQueryException expected");
    } catch (InvalidQueryException expected) {}        

}
 
开发者ID:1and1,项目名称:Troilus,代码行数:30,代码来源:CascadingTest.java


示例7: testCasscadingInsertError

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
@Test
public void testCasscadingInsertError() throws Exception {   
   
    Dao keyByAccountDao = new DaoImpl(cassandra.getSession(), KeyByAccountColumns.TABLE).withInterceptor(new ErroneousCascadeOnWriteInterceptor());
   
    
    String id = "act3354455445544";
    byte[] key = new byte[] { 34, 56, 87, 88 };
    String email = "[email protected]";
    long time = System.currentTimeMillis(); 
    
    
    //////////////////////////////////////
    // insert 
    try {
    	// 3.x API change
        //TupleType idxType = TupleType.of(DataType.text(), DataType.bigint());
    	TupleType idxType = TupleType.of(protocolVersion, codecRegistry,DataType.text(), DataType.bigint());
        keyByAccountDao.writeWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                       .value(KeyByAccountColumns.KEY, key)
                       .addSetValue(KeyByAccountColumns.EMAIL_IDX, idxType.newValue(email, time))
                       .withConsistency(ConsistencyLevel.QUORUM)
                       .execute();
        
        Assert.fail("ClassCastException exepcted");
    } catch (ClassCastException exepcted) { }
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:28,代码来源:CascadingTest.java


示例8: isBuildInType

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
static boolean isBuildInType(DataType dataType) {        
    if (dataType.isCollection()) {
        for (DataType type : dataType.getTypeArguments()) {
            if (!isBuildInType(type)) {
                return false;
            }
        }
        return true;

    } else {
        return DataType.allPrimitiveTypes().contains(dataType) || (TupleType.class.isAssignableFrom(dataType.getClass()));
    }
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:14,代码来源:UDTValueMapper.java


示例9: newInstance

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <P extends  Tuple2<?, ?>> Getter<GettableByIndexData, P> newInstance(DatastaxMapperFactory factory, Type target,  TupleType tt, int index) {
    Mapper<GettableByIndexData, P> mapper = newTupleMapper(target, tt, factory);
    return new DatastaxTupleGetter<P>(mapper, index);
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:6,代码来源:DatastaxTupleGetter.java


示例10: ConverterToTupleValueMapper

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
public ConverterToTupleValueMapper(Mapper<I, TupleValue> mapper, TupleType tupleType) {
    this.mapper = mapper;
    this.tupleType = tupleType;
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:5,代码来源:ConverterToTupleValueMapper.java


示例11: testCasscadingLwtDelete

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
@Test
public void testCasscadingLwtDelete() throws Exception {   
    
    DaoManager daoManager = new DaoManager(cassandra.getSession());
   
    Dao keyByAccountDao = daoManager.getKeyByAccountDao();
    Dao keyByEmailDao = daoManager.getKeyByEmailDao();

    
    String id = "act3344";
    byte[] key = new byte[] { 34, 56, 87, 88 };
    String email = "[email protected]";
    long time = System.currentTimeMillis(); 
    
    
    //////////////////////////////////////
    // insert 
    // 3.x API change
    //TupleType idxType = TupleType.of(DataType.text(), DataType.bigint());    
    TupleType idxType = TupleType.of(protocolVersion, codecRegistry,DataType.text(), DataType.bigint());
    keyByAccountDao.writeWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                   .value(KeyByAccountColumns.KEY, key)
                   .addSetValue(KeyByAccountColumns.EMAIL_IDX, idxType.newValue(email, time))
                   .withConsistency(ConsistencyLevel.QUORUM)
                   .execute();
    
    
    
    // test 
    Record record = keyByEmailDao.readWithKey(KeyByEmailColumns.EMAIL, email, KeyByEmailColumns.CREATED, time)
                                 .withConsistency(ConsistencyLevel.QUORUM)
                                 .execute()
                                 .get();
    Assert.assertEquals(id, record.getValue(KeyByEmailColumns.ACCOUNT_ID));
    Assert.assertArrayEquals(key, record.getValue(KeyByEmailColumns.KEY));
    
    record = keyByAccountDao.readWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                            .withConsistency(ConsistencyLevel.QUORUM)
                            .execute()
                            .get();
    Assert.assertEquals(id, record.getValue(KeyByAccountColumns.ACCOUNT_ID));
    Assert.assertEquals(email, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getString(0));
    Assert.assertEquals(time, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getLong(1));
    
    
    
    
    
    
    ///////////////////////////////////////////////////////
    // Delete
    try {
        keyByAccountDao.deleteWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                       .withConsistency(ConsistencyLevel.QUORUM)
                       .ifExists()
                       .execute();
        Assert.fail("InvalidQueryException expected");
    } catch (InvalidQueryException expected) {}        

    
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:62,代码来源:CascadingTest.java


示例12: testCasscadingUnsupportedDeleteQuery

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
@Test
public void testCasscadingUnsupportedDeleteQuery() throws Exception {   
    
    DaoManager daoManager = new DaoManager(cassandra.getSession());
   
    Dao keyByAccountDao = daoManager.getKeyByAccountDao();
    Dao keyByEmailDao = daoManager.getKeyByEmailDao();

    
    String id = "act3345445544";
    byte[] key = new byte[] { 34, 56, 87, 88 };
    String email = "[email protected]";
    long time = System.currentTimeMillis(); 
    
    
    //////////////////////////////////////
    // insert 
    // 3.x API change
    //TupleType idxType = TupleType.of(DataType.text(), DataType.bigint());     
    TupleType idxType = TupleType.of(protocolVersion, codecRegistry,DataType.text(), DataType.bigint());
    keyByAccountDao.writeWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                   .value(KeyByAccountColumns.KEY, key)
                   .addSetValue(KeyByAccountColumns.EMAIL_IDX, idxType.newValue(email, time))
                   .withConsistency(ConsistencyLevel.QUORUM)
                   .execute();
    
    
    
    // test 
    Record record = keyByEmailDao.readWithKey(KeyByEmailColumns.EMAIL, email, KeyByEmailColumns.CREATED, time)
                                 .withConsistency(ConsistencyLevel.QUORUM)
                                 .execute()
                                 .get();
    Assert.assertEquals(id, record.getValue(KeyByEmailColumns.ACCOUNT_ID));
    Assert.assertArrayEquals(key, record.getValue(KeyByEmailColumns.KEY));
    
    record = keyByAccountDao.readWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                            .withConsistency(ConsistencyLevel.QUORUM)
                            .execute()
                            .get();
    Assert.assertEquals(id, record.getValue(KeyByAccountColumns.ACCOUNT_ID));
    Assert.assertEquals(email, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getString(0));
    Assert.assertEquals(time, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getLong(1));

    
    
    
    
    
    
    ///////////////////////////////////////////////////////
    // Delete
    
    try {
        keyByAccountDao.deleteWhere(QueryBuilder.in(KeyByAccountColumns.ACCOUNT_ID.getName(), id))
                       .withConsistency(ConsistencyLevel.QUORUM)
                       .execute();
        Assert.fail("InvalidQueryException expected");
    } catch (InvalidQueryException expected) {}        
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:61,代码来源:CascadingTest.java


示例13: testCasscadingDeleteError

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
@Test
public void testCasscadingDeleteError() throws Exception {   
   
    Dao keyByAccountDao = new DaoImpl(cassandra.getSession(), KeyByAccountColumns.TABLE).withInterceptor(new ErroneousCascadeOnDeleteInterceptor());

    
    String id = "act3343343454544";
    byte[] key = new byte[] { 34, 56, 87, 88 };
    String email = "[email protected]";
    long time = System.currentTimeMillis(); 
    

    //////////////////////////////////////
    // insert 
    // 3.x API change
    //TupleType idxType = TupleType.of(DataType.text(), DataType.bigint());        
    TupleType idxType = TupleType.of(protocolVersion, codecRegistry,DataType.text(), DataType.bigint());
    keyByAccountDao.writeWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                   .value(KeyByAccountColumns.KEY, key)
                   .addSetValue(KeyByAccountColumns.EMAIL_IDX, idxType.newValue(email, time))
                   .withConsistency(ConsistencyLevel.QUORUM)
                   .execute();
    
    
    
    // test 
    
    Record record = keyByAccountDao.readWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                                   .withConsistency(ConsistencyLevel.QUORUM)
                                   .execute()
                                   .get();
    Assert.assertEquals(id, record.getValue(KeyByAccountColumns.ACCOUNT_ID));
    Assert.assertEquals(email, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getString(0));
    Assert.assertEquals(time, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getLong(1));

    
    
    
    
    ///////////////////////////////////////////////////////
    // Delete
    try {
        keyByAccountDao.deleteWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                       .withConsistency(ConsistencyLevel.QUORUM)
                       .execute();
        
        Assert.fail("ClassCastException exepcted");
    } catch (ClassCastException exepcted) { }
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:50,代码来源:CascadingTest.java


示例14: getTupleType

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
/**
 * Creates a Cassandra TupleType based on the given list of Objects. The
 * TupleType can then be used to create a TupleValue.
 * 
 * @param values
 * @return
 */
public static TupleType getTupleType(Metadata clusterMetaData,
		List<Object> values) throws IllegalArgumentException {
	List<DataType> dataTypes = new ArrayList<DataType>();
	for (Object value : values) {
		LOG.trace("getTupleType: Object type = "
				+ value.getClass().getCanonicalName());
		if (value instanceof ByteBuffer) {
			dataTypes.add(DataType.blob());
		} else if (value instanceof BigDecimal) {
			dataTypes.add(DataType.decimal());
		} else if (value instanceof BigInteger) {
			dataTypes.add(DataType.varint());
		} else if (value instanceof Boolean) {
			dataTypes.add(DataType.cboolean());
		} else if (value instanceof InetAddress) {
			dataTypes.add(DataType.inet());
		} else if (value instanceof Integer) {
			dataTypes.add(DataType.cint());
		} else if (value instanceof Short) {
			dataTypes.add(DataType.smallint());
		} else if (value instanceof Long) {
			dataTypes.add(DataType.counter());
		} else if (value instanceof Float) {
			dataTypes.add(DataType.cfloat());
		} else if (value instanceof Double) {
			dataTypes.add(DataType.cdouble());
		} else if (value instanceof Date) {
			dataTypes.add(DataType.timestamp());
		} else if (value instanceof String) {
			dataTypes.add(DataType.text());
		} else {
			throw new IllegalArgumentException("unknown data type of "
					+ value.getClass().getCanonicalName());
		}
	}
	return clusterMetaData.newTupleType(dataTypes
			.toArray(new DataType[dataTypes.size()]));
	// return TupleType.of(dataTypes.toArray(new
	// DataType[dataTypes.size()]));
}
 
开发者ID:joef551,项目名称:camel-cql,代码行数:48,代码来源:Utils.java


示例15: testCasscading

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
@Test
public void testCasscading() throws Exception {   
    
    DaoManager daoManager = new DaoManager(cassandra.getSession());
   
    Dao keyByAccountDao = daoManager.getKeyByAccountDao();
    Dao keyByEmailDao = daoManager.getKeyByEmailDao();

    
    String id = "act3344";
    byte[] key = new byte[] { 34, 56, 87, 88 };
    String email = "[email protected]";
    long time = System.currentTimeMillis(); 
    
    
    //////////////////////////////////////
    // insert 
   // TupleType idxType = TupleType.of(DataType.text(), DataType.bigint());
    TupleType idxType = TupleType.of(protocolVersion, codecRegistry,DataType.text(), DataType.bigint());
    keyByAccountDao.writeWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                   .value(KeyByAccountColumns.KEY, key)
                   .addSetValue(KeyByAccountColumns.EMAIL_IDX, idxType.newValue(email, time))
                   .withConsistency(ConsistencyLevel.QUORUM)
                   .execute();
    
    
    
    // test 
    Record record = keyByEmailDao.readWithKey(KeyByEmailColumns.EMAIL, email, KeyByEmailColumns.CREATED, time)
                                 .withConsistency(ConsistencyLevel.QUORUM)
                                 .execute()
                                 .get();
    Assert.assertEquals(id, record.getValue(KeyByEmailColumns.ACCOUNT_ID));
    Assert.assertArrayEquals(key, record.getValue(KeyByEmailColumns.KEY));
    
    record = keyByAccountDao.readWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                            .withConsistency(ConsistencyLevel.QUORUM)
                            .execute()
                            .get();
    Assert.assertEquals(id, record.getValue(KeyByAccountColumns.ACCOUNT_ID));
    Assert.assertEquals(email, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getString(0));
    Assert.assertEquals(time, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getLong(1));
    
    
    
    
    
    
    
    ///////////////////////////////////////////////////////
    // Delete
    
    keyByAccountDao.deleteWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                   .withConsistency(ConsistencyLevel.QUORUM)
                   .execute();
    
    
    
    Assert.assertEquals(Optional.empty(), keyByEmailDao.readWithKey(KeyByEmailColumns.EMAIL, email, KeyByEmailColumns.CREATED, time)
                                                       .withConsistency(ConsistencyLevel.QUORUM)
                                                       .execute());

    Assert.assertEquals(Optional.empty(), keyByAccountDao.readWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                                                         .withConsistency(ConsistencyLevel.QUORUM)
                                                         .execute());        
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:67,代码来源:CascadingTest.java


示例16: testCasscading2

import com.datastax.driver.core.TupleType; //导入依赖的package包/类
@Test
public void testCasscading2() throws Exception {   
    
    DaoManager daoManager = new DaoManager(cassandra.getSession());
   
    Dao keyByAccountDao = daoManager.getKeyByAccountDao();
    Dao keyByEmailDao = daoManager.getKeyByEmailDao();

    
    String id = "act3344";
    byte[] key = new byte[] { 34, 56, 87, 88 };
    String email = "[email protected]";
    long time = System.currentTimeMillis(); 
    
    
    //////////////////////////////////////
    // insert 
    // 3.x API change
    //TupleType idxType = TupleType.of(DataType.text(), DataType.bigint());
    TupleType idxType = TupleType.of(protocolVersion, codecRegistry,DataType.text(), DataType.bigint());
    keyByAccountDao.writeWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                   .value(KeyByAccountColumns.KEY, key)
                   .value(KeyByAccountColumns.EMAIL_IDX, ImmutableSet.of(idxType.newValue(email, time)))
                   .withConsistency(ConsistencyLevel.QUORUM)
                   .execute();
    
    
    
    // test 
    Record record = keyByEmailDao.readWithKey(KeyByEmailColumns.EMAIL, email, KeyByEmailColumns.CREATED, time)
                                 .withConsistency(ConsistencyLevel.QUORUM)
                                 .execute()
                                 .get();
    Assert.assertEquals(id, record.getValue(KeyByEmailColumns.ACCOUNT_ID));
    Assert.assertArrayEquals(key, record.getValue(KeyByEmailColumns.KEY));
    
    record = keyByAccountDao.readWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                            .withConsistency(ConsistencyLevel.QUORUM)
                            .execute()
                            .get();
    Assert.assertEquals(id, record.getValue(KeyByAccountColumns.ACCOUNT_ID));
    Assert.assertEquals(email, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getString(0));
    Assert.assertEquals(time, record.getValue(KeyByAccountColumns.EMAIL_IDX).iterator().next().getLong(1));
    
    
    
    
    
    
    
    ///////////////////////////////////////////////////////
    // Delete
    
    keyByAccountDao.deleteWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                   .withConsistency(ConsistencyLevel.QUORUM)
                   .execute();
    
    
    
    Assert.assertEquals(Optional.empty(), keyByEmailDao.readWithKey(KeyByEmailColumns.EMAIL, email, KeyByEmailColumns.CREATED, time)
                                                       .withConsistency(ConsistencyLevel.QUORUM)
                                                       .execute());

    Assert.assertEquals(Optional.empty(), keyByAccountDao.readWithKey(KeyByAccountColumns.ACCOUNT_ID, id)
                                                         .withConsistency(ConsistencyLevel.QUORUM)
                                                         .execute());        
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:68,代码来源:CascadingTest.java



注:本文中的com.datastax.driver.core.TupleType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Log4jContextFactory类代码示例发布时间:2022-05-23
下一篇:
Java PropertiesUtil类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap