當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryBuilder.insertInto方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.querybuilder.QueryBuilder.insertInto方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilder.insertInto方法的具體用法?Java QueryBuilder.insertInto怎麽用?Java QueryBuilder.insertInto使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.querybuilder.QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder.insertInto方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cqlBuilders

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
private static void cqlBuilders() {
    FieldModel model = SampleModels.wrapper();
    Create create = SchemaBuilder.createTable("Field").addClusteringColumn(LOGIN.name(), text())
            .addPartitionKey("snapshot_id", timeuuid());

    model.getFieldInfos().stream().filter(f -> f.id() != LOGIN)
            .forEach(f -> create.addColumn(f.id().name(), cqlType(f)));

    Create.Options createWithOptions = create.withOptions().clusteringOrder(LOGIN.name(), DESC);
    System.out.println(createWithOptions);

    Insert insert = QueryBuilder.insertInto("Field");
    model.stream().forEach(e -> insert.value(e.getKey().name(), e.getValue()));

    System.out.println(insert.getQueryString(codecRegistry()));
}
 
開發者ID:lesfurets,項目名稱:dOOv,代碼行數:17,代碼來源:LiveCode.java

示例2: createInsertQuery

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的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

示例3: save

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的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

示例4: simpleCasandraInsert

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的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.QueryBuilder; //導入方法依賴的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.QueryBuilder; //導入方法依賴的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.QueryBuilder; //導入方法依賴的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: createInsertStatement

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的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

示例9: save

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的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


注:本文中的com.datastax.driver.core.querybuilder.QueryBuilder.insertInto方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。