本文整理了Java中com.datastax.driver.core.querybuilder.Insert.values()
方法的一些代码示例,展示了Insert.values()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Insert.values()
方法的具体详情如下:
包路径:com.datastax.driver.core.querybuilder.Insert
类名称:Insert
方法名:values
[英]Adds multiple column/value pairs to the values inserted by this INSERT statement.
[中]将多个列/值对添加到此INSERT语句插入的值。
代码示例来源:origin: apache/storm
.values(allFields, Collections.<Object>nCopies(allFields.size(), bindMarker()));
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Adds multiple column/value pairs to the values inserted by this {@code INSERT} statement.
*
* @param names a list of column names to insert/update.
* @param values a list of values to insert/update. The {@code i}th value in {@code values} will
* be inserted for the {@code i}th column in {@code names}.
* @return the {@code INSERT} statement those options are part of.
* @throws IllegalArgumentException if {@code names.length != values.length}.
*/
public Insert values(String[] names, Object[] values) {
return statement.values(names, values);
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Adds multiple column/value pairs to the values inserted by this INSERT statement.
*
* @param names a list of column names to insert/update.
* @param values a list of values to insert/update. The {@code i}th value in {@code values} will
* be inserted for the {@code i}th column in {@code names}.
* @return this INSERT statement.
* @throws IllegalArgumentException if {@code names.length != values.length}.
* @throws IllegalStateException if this method is called and the {@link #json(Object)} method has
* been called before, because it's not possible to mix {@code INSERT JSON} syntax with
* regular {@code INSERT} syntax.
*/
public Insert values(String[] names, Object[] values) {
return values(Arrays.asList(names), Arrays.asList(values));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void routingKeyColumnCaseSensitivityForQuotedIdentifiersTest() throws Exception {
BuiltStatement query;
TableMetadata table = cluster().getMetadata().getKeyspace(keyspace).getTable(TABLE_CASE_QUOTED);
assertNotNull(table);
ProtocolVersion protocolVersion =
cluster().getConfiguration().getProtocolOptions().getProtocolVersion();
CodecRegistry codecRegistry = CodecRegistry.DEFAULT_INSTANCE;
query =
insertInto(table)
.values(
new String[] {"\"theKey\"", "a", "b", "\"tHEkEY\""}, new Object[] {42, 1, 2, 3});
ByteBuffer bb = ByteBuffer.allocate(4);
bb.putInt(0, 42);
assertEquals(query.getRoutingKey(protocolVersion, codecRegistry), bb);
query =
insertInto(table)
.values(new String[] {"theKey", "a", "b", "\"tHEkEY\""}, new Object[] {42, 1, 2, 3});
assertNull(query.getRoutingKey(protocolVersion, codecRegistry));
query =
insertInto(table)
.values(new String[] {"theKey", "a", "b", "theKey"}, new Object[] {42, 1, 2, 3});
assertNull(query.getRoutingKey(protocolVersion, codecRegistry));
}
代码示例来源:origin: com.yugabyte/cassandra-driver-core
/**
* Adds multiple column/value pairs to the values inserted by this INSERT statement.
*
* @param names a list of column names to insert/update.
* @param values a list of values to insert/update. The {@code i}th
* value in {@code values} will be inserted for the {@code i}th column
* in {@code names}.
* @return the INSERT statement those options are part of.
* @throws IllegalArgumentException if {@code names.length != values.length}.
*/
public Insert values(String[] names, Object[] values) {
return statement.values(names, values);
}
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
/**
* Adds multiple column/value pairs to the values inserted by this INSERT statement.
*
* @param names a list of column names to insert/update.
* @param values a list of values to insert/update. The {@code i}th
* value in {@code values} will be inserted for the {@code i}th column
* in {@code names}.
* @return the INSERT statement those options are part of.
* @throws IllegalArgumentException if {@code names.length != values.length}.
*/
public Insert values(String[] names, Object[] values) {
return statement.values(names, values);
}
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
/**
* Adds multiple column/value pairs to the values inserted by this INSERT statement.
*
* @param names a list of column names to insert/update.
* @param values a list of values to insert/update. The {@code i}th
* value in {@code values} will be inserted for the {@code i}th column
* in {@code names}.
* @return the INSERT statement those options are part of.
* @throws IllegalArgumentException if {@code names.length != values.length}.
*/
public Insert values(String[] names, Object[] values) {
return statement.values(names, values);
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void textRoutingKeyTest() throws Exception {
BuiltStatement query;
TableMetadata table = cluster().getMetadata().getKeyspace(keyspace).getTable(TABLE_TEXT);
assertNotNull(table);
ProtocolVersion protocolVersion =
cluster().getConfiguration().getProtocolOptions().getProtocolVersion();
CodecRegistry codecRegistry = CodecRegistry.DEFAULT_INSTANCE;
String txt = "If she weighs the same as a duck... she's made of wood.";
query = insertInto(table).values(new String[] {"k", "a", "b"}, new Object[] {txt, 1, 2});
assertEquals(
query.getRoutingKey(protocolVersion, codecRegistry), ByteBuffer.wrap(txt.getBytes()));
session().execute(query);
query = select().from(table).where(eq("k", txt));
assertEquals(
query.getRoutingKey(protocolVersion, codecRegistry), ByteBuffer.wrap(txt.getBytes()));
Row row = session().execute(query).one();
assertEquals(row.getString("k"), txt);
assertEquals(row.getInt("a"), 1);
assertEquals(row.getInt("b"), 2);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
protected void write(int n, boolean batch, ConsistencyLevel cl) {
// We don't use insert for our test because the resultSet don't ship the queriedHost
// Also note that we don't use tracing because this would trigger requests that screw up the
// test
for (int i = 0; i < n; ++i)
if (batch)
// BUG: WriteType == SIMPLE
session()
.execute(
batch()
.add(insertInto(tableName).values(new String[] {"k", "i"}, new Object[] {0, 0}))
.setConsistencyLevel(cl));
else
session()
.execute(
new SimpleStatement(String.format("INSERT INTO %s(k, i) VALUES (0, 0)", tableName))
.setConsistencyLevel(cl));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void intRoutingKeyTest() throws Exception {
BuiltStatement query;
TableMetadata table = cluster().getMetadata().getKeyspace(keyspace).getTable(TABLE_INT);
assertNotNull(table);
ProtocolVersion protocolVersion =
cluster().getConfiguration().getProtocolOptions().getProtocolVersion();
CodecRegistry codecRegistry = CodecRegistry.DEFAULT_INSTANCE;
query = insertInto(table).values(new String[] {"k", "a", "b"}, new Object[] {42, 1, 2});
ByteBuffer bb = ByteBuffer.allocate(4);
bb.putInt(0, 42);
assertEquals(query.getRoutingKey(protocolVersion, codecRegistry), bb);
session().execute(query);
query = select().from(table).where(eq("k", 42));
assertEquals(query.getRoutingKey(protocolVersion, codecRegistry), bb);
Row row = session().execute(query).one();
assertEquals(row.getInt("k"), 42);
assertEquals(row.getInt("a"), 1);
assertEquals(row.getInt("b"), 2);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
insert =
insertInto("foo")
.values(
new String[] {"a", "b"},
new Object[] {
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
CodecRegistry codecRegistry = CodecRegistry.DEFAULT_INSTANCE;
query = insertInto(table).values(new String[] {"theKey", "a", "b"}, new Object[] {42, 1, 2});
ByteBuffer bb = ByteBuffer.allocate(4);
bb.putInt(0, 42);
assertEquals(row.getInt("b"), 2);
query = insertInto(table).values(new String[] {"ThEkEy", "a", "b"}, new Object[] {42, 1, 2});
bb = ByteBuffer.allocate(4);
bb.putInt(0, 42);
代码示例来源:origin: otaviojava/Easy-Cassandra
@Override
public InsertBuilder<T> values(String[] names, Object[] values) {
insert.values(classBean.toColumn(names), values);
return this;
}
@Override
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
batch =
batch()
.add(insertInto(table).values(new String[] {"k", "a"}, new Object[] {42, 1}))
.add(update(table).using(ttl(400)));
assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), bb);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
insert =
insertInto("foo")
.values(
new String[] {"a", "b"},
new Object[] {
insert =
insertInto("foo", "bar")
.values(
new String[] {"a", "b"},
new Object[] {
.using(timestamp(42))
.value("c", 123)
.values(
new String[] {"a", "b"},
new Object[] {
insertInto("foo").values(new String[] {"a", "b"}, new Object[] {1, 2, 3});
fail("Expected an IllegalArgumentException");
} catch (IllegalArgumentException e) {
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
.add(
insertInto("foo")
.values(
new String[] {"a", "b"},
new Object[] {
代码示例来源:origin: Stratio/stratio-cassandra-test
public CassandraUtils insert(String[] names, Object[] values) {
execute(QueryBuilder.insertInto(keyspace, table).values(names, values));
return this;
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
insertInto("foo").value("k", 1).value("v", Sets.newHashSet(now())),
insertInto("foo").value("k", 1).value("v", Sets.newHashSet(uuid())),
insertInto("foo").values(new String[] {"k", "v"}, new Object[] {1, fcall("token", "k")}),
insertInto("foo").values(new String[] {"k", "v"}, new Object[] {1, now()}),
insertInto("foo").values(new String[] {"k", "v"}, new Object[] {1, uuid()}),
insertInto("foo")
.values(
new String[] {"k", "v"},
new Object[] {1, ImmutableMap.of("foo", fcall("token", "k"))}),
insertInto("foo")
.values(new String[] {"k", "v"}, new Object[] {1, ImmutableMap.of("foo", now())}),
insertInto("foo")
.values(new String[] {"k", "v"}, new Object[] {1, ImmutableMap.of("foo", uuid())}),
insertInto("foo")
.values(
new String[] {"k", "v"},
new Object[] {1, ImmutableMap.of(fcall("token", "k"), "foo")}),
insertInto("foo")
.values(new String[] {"k", "v"}, new Object[] {1, ImmutableMap.of(now(), "foo")}),
insertInto("foo")
.values(new String[] {"k", "v"}, new Object[] {1, ImmutableMap.of(uuid(), "foo")}),
update("foo").with(set("v", fcall("token", "k"))).where(eq("k", 1)),
update("foo").with(set("v", now())).where(eq("k", 1)),
insertInto("foo").values(new String[] {"k", "v"}, new Object[] {1, raw("foo()")}),
insertInto("foo")
.values(
new String[] {"k", "v"}, new Object[] {1, ImmutableMap.of("foo", raw("foo()"))}),
insertInto("foo")
代码示例来源:origin: org.apache.gora/gora-cassandra
/**
* This method return the CQL query to insert data in to the table.
* refer : http://docs.datastax.com/en/cql/3.1/cql/cql_reference/insert_r.html
*
* @param mapping Cassandra Mapping {@link CassandraMapping}
* @param fields available fields
* @return CQL Query
*/
static String getInsertDataQuery(CassandraMapping mapping, List<String> fields) {
String[] columnNames = getColumnNames(mapping, fields);
String[] objects = new String[fields.size()];
Arrays.fill(objects, "?");
return QueryBuilder.insertInto(mapping.getKeySpace().getName(), mapping.getCoreName()).values(columnNames, objects).getQueryString();
}
代码示例来源:origin: apache/gora
/**
* This method return the CQL query to insert data in to the table.
* refer : http://docs.datastax.com/en/cql/3.1/cql/cql_reference/insert_r.html
*
* @param mapping Cassandra Mapping {@link CassandraMapping}
* @param fields available fields
* @return CQL Query
*/
static String getInsertDataQuery(CassandraMapping mapping, List<String> fields) {
String[] columnNames = getColumnNames(mapping, fields);
String[] objects = new String[fields.size()];
Arrays.fill(objects, "?");
return QueryBuilder.insertInto(mapping.getKeySpace().getName(), mapping.getCoreName()).values(columnNames, objects).getQueryString();
}
内容来源于网络,如有侵权,请联系作者删除!