本文整理汇总了Java中com.datastax.driver.core.querybuilder.Insert.using方法的典型用法代码示例。如果您正苦于以下问题:Java Insert.using方法的具体用法?Java Insert.using怎么用?Java Insert.using使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.querybuilder.Insert
的用法示例。
在下文中一共展示了Insert.using方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Indexer
import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
Indexer(Session session, @Nullable Integer indexTtl,
@Nullable ConcurrentMap<PartitionKeyToTraceId, Pair<Long>> sharedState, IndexSupport index) {
this.index = index;
this.boundName = UPPER_CAMEL.to(LOWER_HYPHEN, index.getClass().getSimpleName());
Insert insert = index.declarePartitionKey(QueryBuilder.insertInto(index.table())
.value("ts", QueryBuilder.bindMarker("ts"))
.value("trace_id", QueryBuilder.bindMarker("trace_id")));
if (indexTtl != null) {
insert.using(QueryBuilder.ttl(QueryBuilder.bindMarker("ttl_")));
}
this.prepared = session.prepare(insert);
this.indexTtl = indexTtl;
this.session = session;
this.timestampCodec = new TimestampCodec(session);
this.sharedState = sharedState;
}
示例2: generateInsert
import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
/**
* Generate Insert CQL.
*/
public static Insert generateInsert(String table, String[] columns, boolean ifNotExists, Integer ttl) {
Insert insert = insertInto(table);
for (String column : columns) {
insert = insert.value(column, bindMarker());
}
if (ifNotExists) {
insert = insert.ifNotExists();
}
if (ttl != null) {
insert.using(ttl(ttl));
}
return insert;
}
示例3: toInsertStatementAsync
import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
private static ListenableFuture<Statement> toInsertStatementAsync(WriteQueryData data, ExecutionSpec executionSpec, UDTValueMapper udtValueMapper, DBSession dbSession) {
final Insert insert = (data.getTablename().getKeyspacename() == null) ? insertInto(data.getTablename().getTablename())
: insertInto(data.getTablename().getKeyspacename(), data.getTablename().getTablename());
final List<Object> values = Lists.newArrayList();
for(Entry<String, Optional<Object>> entry : data.getValuesToMutate().entrySet()) {
insert.value(entry.getKey(), bindMarker());
values.add(udtValueMapper.toStatementValue(data.getTablename(), entry.getKey(), entry.getValue().orNull()));
}
if (data.getIfNotExits() != null) {
insert.ifNotExists();
if (executionSpec.getSerialConsistencyLevel() != null) {
insert.setSerialConsistencyLevel(executionSpec.getSerialConsistencyLevel());
}
}
if (executionSpec.getTtl() != null) {
insert.using(ttl(bindMarker()));
values.add((Integer) executionSpec.getTtl());
}
final ListenableFuture<PreparedStatement> preparedStatementFuture = dbSession.prepareAsync(insert);
return dbSession.bindAsync(preparedStatementFuture, values.toArray());
}
示例4: insertSQL
import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
private static String insertSQL(final String table, final int timeout) {
Insert insertInto = insertInto(table)
.value(ID, raw("?"))
.value(CREATED_AT, raw("?"))
.value(ACCESSED_AT, raw("?"))
.value(SAVED_AT, raw("?"))
.value(ATTRIBUTES, raw("?"));
if (timeout > 0) {
insertInto.using(ttl(timeout));
}
return insertInto.getQueryString();
}
示例5: maybeUseTtl
import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
private RegularStatement maybeUseTtl(Insert value) {
return indexTtl == null
? value
: value.using(QueryBuilder.ttl(QueryBuilder.bindMarker("ttl_")));
}