当前位置: 首页>>代码示例>>Java>>正文


Java Insert.value方法代码示例

本文整理汇总了Java中com.datastax.driver.core.querybuilder.Insert.value方法的典型用法代码示例。如果您正苦于以下问题:Java Insert.value方法的具体用法?Java Insert.value怎么用?Java Insert.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.datastax.driver.core.querybuilder.Insert的用法示例。


在下文中一共展示了Insert.value方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createInsertQuery

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
private Insert createInsertQuery(EntityEvent entityEvent) {
    Insert insert = QueryBuilder.insertInto(tableName);
    insert.value(ENTITY_ID, entityEvent.getEventKey().getEntityId());
    insert.value(VERSION, entityEvent.getEventKey().getVersion());
    insert.value(OP_ID, entityEvent.getOpId());
    insert.value(OP_DATE, entityEvent.getOpDate());
    insert.value(EVENT_TYPE, entityEvent.getEventType());
    insert.value(STATUS, entityEvent.getStatus().name());
    insert.value(AUDIT_INFO, entityEvent.getAuditInfo());
    insert.value(EVENT_DATA, entityEvent.getEventData());
    insert.ifNotExists();
    return insert;
}
 
开发者ID:kloiasoft,项目名称:eventapis,代码行数:14,代码来源:CassandraEventRecorder.java

示例2: save

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
public void save(List<Event> events) {
    final BatchStatement batch = new BatchStatement();
    for (final Event event : events) {
        final Map<String, Object> parsedEvent = parse(event);
        if (parsedEvent.isEmpty()) {
            log.warn("Event {} could not be mapped", event);
            continue;
        }
        if (!hasPrimaryKey(parsedEvent)) {
            break;
        }
        final Insert insert = QueryBuilder.insertInto(table);
        for (final Map.Entry<String, Object> entry : parsedEvent.entrySet()) {
            insert.value(entry.getKey(), entry.getValue());
        }
        if (log.isTraceEnabled()) {
            log.trace("Preparing insert for table {}: {}", table.getName(), insert.getQueryString());
        }
        batch.add(insert);
    }
    if (batch.getStatements().isEmpty()) {
        log.warn("No event produced insert query for table {}", table.getName());
        return;
    }
    batch.setConsistencyLevel(consistencyLevel);
    session.execute(batch);
}
 
开发者ID:madbrain,项目名称:flume-examples,代码行数:28,代码来源:CassandraSink.java

示例3: 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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:CassandraUtils.java

示例4: simpleCasandraInsert

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
@Test
public void simpleCasandraInsert() {
    FieldModel model = SampleModels.wrapper();
    Insert insertRequest = QueryBuilder.insertInto("fields_model");
    insertRequest.value("snapshot_id", UUID.randomUUID());
    insertRequest.values(
            model.stream().map(e -> e.getKey().name()).collect(toList()),
            model.stream().map(Entry::getValue).collect(toList()));
    print(insertRequest.getQueryString(codecRegistry()));
}
 
开发者ID:lesfurets,项目名称:dOOv,代码行数:11,代码来源:CassandraQueryBuilderTest.java

示例5: map

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
@Override
public Statement map(List<String> keys, Number value) {
    Insert statement = QueryBuilder.insertInto(KEYSPACE_NAME, TABLE_NAME);
    statement.value(WORD_KEY_NAME, keys.get(0));
    statement.value(SOURCE_KEY_NAME, keys.get(1));
    statement.value(VALUE_NAME, value);
    return statement;
}
 
开发者ID:hpcc-systems,项目名称:storm-cassandra-cql,代码行数:9,代码来源:WordCountAndSourceMapper.java

示例6: migrate

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
@Override
public void migrate(Session session) throws Exception {
    Insert insert = QueryBuilder.insertInto("test1");
    insert.value("space", "web");
    insert.value("key", "google");
    insert.value("value", "google.com");

    session.execute(insert);
}
 
开发者ID:Contrast-Security-OSS,项目名称:cassandra-migration,代码行数:10,代码来源:V3_0__Third.java

示例7: migrate

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
@Override
public void migrate(Session session) throws Exception {
    Insert insert = QueryBuilder.insertInto("test1");
    insert.value("space", "web");
    insert.value("key", "facebook");
    insert.value("value", "facebook.com");

    session.execute(insert);
}
 
开发者ID:Contrast-Security-OSS,项目名称:cassandra-migration,代码行数:10,代码来源:V3_0_1__Three_zero_one.java

示例8: 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());
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:28,代码来源:WriteQueryDataImpl.java

示例9: createInsertStatement

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
public Insert createInsertStatement(String streamName, List<ColumnNameTypeValue> columns, String timestampColumnName) {
    Insert insert = QueryBuilder.insertInto(addQuotes(STREAMING.STREAMING_KEYSPACE_NAME), addQuotes(streamName));
    for (ColumnNameTypeValue column : columns) {
        insert.value(addQuotes(column.getColumn()), column.getValue());
    }
    insert.value(addQuotes(timestampColumnName), UUIDs.timeBased());
    return insert;
}
 
开发者ID:Stratio,项目名称:Decision,代码行数:9,代码来源:SaveToCassandraOperationsService.java

示例10: save

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
public void save(final List<Event> events) {
  final BatchStatement batch = new BatchStatement();
  for (final Event event : events) {
    final Map<String, Object> parsedEvent = parse(event);
    if (parsedEvent.isEmpty()) {
      log.warn("Event {} could not be mapped. Suggestion: Cassandra is case sensitive, so maybe you can check field names.", event);
      continue;
    }
    if (!hasPrimaryKey(parsedEvent)) {
      break;
    }
    final Insert insert = QueryBuilder.insertInto(table);
    for (final Map.Entry<String, Object> entry : parsedEvent.entrySet()) {
      insert.value(entry.getKey(), entry.getValue());
    }
    if (log.isTraceEnabled()) {
      log.trace("Preparing insert for table {}: {}", table.getName(), insert.getQueryString());
    }
    batch.add(insert);
  }
  if (batch.getStatements().isEmpty()) {
    log.warn("No event produced insert query for table {}", table.getName());
    return;
  }
  batch.setConsistencyLevel(consistencyLevel);
  session.execute(batch);
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:28,代码来源:CassandraTable.java

示例11: declarePartitionKey

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
@Override public Insert declarePartitionKey(Insert insert) {
  return insert.value("service_span_name", QueryBuilder.bindMarker("service_span_name"));
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:4,代码来源:InsertTraceIdBySpanName.java

示例12: create

import com.datastax.driver.core.querybuilder.Insert; //导入方法依赖的package包/类
@Override
public <T> T create(T object, ConsistencyLevel consistency) {

    checkNotNull(object, "object argument");
    checkNotNull(consistency, "consistency argument");
    checkState(m_isOpen, format("%s is closed", getClass().getSimpleName()));
    checkArgument(
            object.getClass().isAnnotationPresent(ENTITY),
            format("%s not annotated with @%s", getClass().getSimpleName(), ENTITY.getCanonicalName()));

    Schema schema = getSchema(object);

    checkArgument(
            schema.getID().getValue(object) == null,
            format("property annotated with @%s must be null", ID.getCanonicalName()));

    // Object persistence (incl. indices)
    UUID id = UUID.randomUUID();
    Batch batch = batch();
    Insert insertStatement = insertInto(schema.getTableName()).value(schema.getID().getName(), id);

    for (ColumnSpec colSpec : schema.getColumns()) {
        
        insertStatement.value(colSpec.getName(), colSpec.getValue(object));
        
        if (colSpec.isIndexed()) {
            String tableName = indexTableName(schema.getTableName(), colSpec.getName());
            batch.add(
                    insertInto(tableName)
                        .value(colSpec.getName(), colSpec.getValue(object))
                        .value(joinColumnName(schema.getTableName()), id)
            );
        }
    }

    batch.add(insertStatement);

    // One-to-Many relationship persistence
    for (OneToManySpec relationSpec : schema.getOneToManys()) {
        Schema s = relationSpec.getSchema();

        Object relations = relationSpec.getValue(object);

        if (relations == null) {
            continue;
        }

        for (Object item : (Collection<?>) relations) {
            UUID relationID = (UUID) s.getID().getValue(item);

            if (relationID == null) {
                throw new IllegalStateException(
                        "encountered relation with null ID property (entity not persisted?)");
            }

            String joinTable = joinTableName(schema.getTableName(), s.getTableName());

            batch.add(
                    insertInto(joinTable)
                        .value(joinColumnName(schema.getTableName()), id)
                        .value(joinColumnName(s.getTableName()), relationID)
            );
        }

    }

    executeStatement(batch, consistency);

    schema.getID().setValue(object, id);
    cacheInstance(object);
    
    return object;
}
 
开发者ID:eevans,项目名称:lucidity,代码行数:74,代码来源:CassandraEntityStore.java


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