本文整理了Java中com.datastax.driver.core.Metadata.newTupleType()
方法的一些代码示例,展示了Metadata.newTupleType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.newTupleType()
方法的具体详情如下:
包路径:com.datastax.driver.core.Metadata
类名称:Metadata
方法名:newTupleType
[英]Creates a tuple type given a list of types.
[中]根据类型列表创建元组类型。
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Creates a tuple type given a list of types.
*
* @param types the types for the tuple type.
* @return the newly created tuple type.
*/
public TupleType newTupleType(DataType... types) {
return newTupleType(Arrays.asList(types));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
shallowUserTypes));
return cluster.getMetadata().newTupleType(types);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@SuppressWarnings("deprecation")
@Test(groups = "short")
public void should_handle_collections_of_tuples() {
String query;
BuiltStatement statement;
query = "UPDATE foo SET l=[(1,2)] WHERE k=1;";
TupleType tupleType = cluster().getMetadata().newTupleType(cint(), cint());
List<TupleValue> list = ImmutableList.of(tupleType.newValue(1, 2));
statement = update("foo").with(set("l", list)).where(eq("k", 1));
assertThat(statement.toString()).isEqualTo(query);
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_handle_tuple() throws Exception {
String query = "INSERT INTO foo (k,x) VALUES (0,(1));";
TupleType tupleType = cluster().getMetadata().newTupleType(cint());
BuiltStatement insert = insertInto("foo").value("k", 0).value("x", tupleType.newValue(1));
assertEquals(insert.toString(), query);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/** Helper method for creating nested tuples */
private TupleValue nestedTuplesCreatorHelper(int depth) {
if (depth == 1) {
TupleType baseTuple = cluster().getMetadata().newTupleType(DataType.cint());
return baseTuple.newValue(303);
} else {
TupleValue innerTuple = nestedTuplesCreatorHelper(depth - 1);
TupleType t = cluster().getMetadata().newTupleType(innerTuple.getType());
return t.newValue(innerTuple);
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void simpleValueTest() throws Exception {
TupleType t =
cluster().getMetadata().newTupleType(DataType.cint(), DataType.text(), DataType.cfloat());
TupleValue v = t.newValue();
v.setInt(0, 1);
v.setString(1, "a");
v.setFloat(2, 1.0f);
assertEquals(v.getType().getComponentTypes().size(), 3);
assertEquals(v.getType().getComponentTypes().get(0), DataType.cint());
assertEquals(v.getType().getComponentTypes().get(1), DataType.text());
assertEquals(v.getType().getComponentTypes().get(2), DataType.cfloat());
assertEquals(v.getInt(0), 1);
assertEquals(v.getString(1), "a");
assertEquals(v.getFloat(2), 1.0f);
assertEquals(TypeCodec.tuple(t).format(v), "(1,'a',1.0)");
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
case TUPLE:
allcollectiontypes.setTupleValue(
index, cluster().getMetadata().newTupleType(dataType).newValue(sampleElement));
代码示例来源:origin: com.yugabyte/cassandra-driver-core
/**
* Creates a tuple type given a list of types.
*
* @param types the types for the tuple type.
* @return the newly created tuple type.
*/
public TupleType newTupleType(DataType... types) {
return newTupleType(Arrays.asList(types));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_parse_tuple_types() {
assertThat(parse("tuple<int,list<text>>", cluster(), null, null, null, false, false))
.isEqualTo(cluster().getMetadata().newTupleType(cint(), list(text())));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private void setUpTupleTypes(Cluster cluster) {
locationType = cluster.getMetadata().newTupleType(cfloat(), cfloat());
locationValue = locationType.newValue().setFloat(0, 37.387224f).setFloat(1, -121.9733837f);
// insert a tuple of a different dimension
partialLocationValueInserted =
cluster.getMetadata().newTupleType(cfloat()).newValue().setFloat(0, 37.387224f);
// retrieve the partial tuple with null missing values
partialLocationValueRetrieved = locationType.newValue(37.387224f, null);
location = new Location(37.387224f, -121.9733837f);
partialLocation = new Location(37.387224f, 0.0f);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void simpleWriteReadTest() throws Exception {
session().execute("USE " + keyspace);
PreparedStatement ins = session().prepare("INSERT INTO t(k, v) VALUES (?, ?)");
PreparedStatement sel = session().prepare("SELECT * FROM t WHERE k=?");
TupleType t =
cluster().getMetadata().newTupleType(DataType.cint(), DataType.text(), DataType.cfloat());
int k = 1;
TupleValue v = t.newValue(1, "a", 1.0f);
session().execute(ins.bind(k, v));
TupleValue v2 = session().execute(sel.bind(k)).one().getTupleValue("v");
assertEquals(v2, v);
// Test simple statement interpolation
k = 2;
v = t.newValue(2, "b", 2.0f);
session().execute("INSERT INTO t(k, v) VALUES (?, ?)", k, v);
v2 = session().execute(sel.bind(k)).one().getTupleValue("v");
assertEquals(v2, v);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Validates that tuple values generated from an attached type (cluster-provided TupleType) and a
* detached type (using TupleType.of) are the same.
*
* @since 2.2.0
*/
@Test(groups = "short")
public void detachedTupleTypeTest() {
TupleType detachedType =
TupleType.of(
protocolVersion,
CodecRegistry.DEFAULT_INSTANCE,
DataType.cint(),
DataType.text(),
DataType.cfloat());
TupleValue detachedValue = detachedType.newValue(1, "hello", 2.0f);
TupleType attachedType =
cluster().getMetadata().newTupleType(DataType.cint(), DataType.text(), DataType.cfloat());
TupleValue attachedValue = attachedType.newValue(1, "hello", 2.0f);
assertThat(detachedValue).isEqualTo(attachedValue);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
cluster()
.getMetadata()
.newTupleType(DataType.text(), DataType.cint(), DataType.uuid(), DataType.blob());
TupleValue v = t.newValue(null, null, null, null);
userType.setTupleValue("b", v);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
cluster()
.getMetadata()
.newTupleType(DataType.ascii(), DataType.cint(), DataType.cboolean());
TupleType t1 = cluster().getMetadata().newTupleType(DataType.ascii(), DataType.cint());
TupleValue partial = t1.newValue("bar", 456);
TupleValue partionResult = t.newValue("bar", 456, null);
TupleType t2 = cluster().getMetadata().newTupleType(DataType.ascii());
TupleValue subpartial = t2.newValue("zoo");
TupleValue subpartialResult = t.newValue("zoo", null, null);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
cluster()
.getMetadata()
.newTupleType(cluster().getMetadata().newTupleType(cint()), map(cint(), cint()));
FunctionMetadata function = keyspace.getFunction("complex", argumentType);
assertThat(function).isNotNull();
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_ignore_case() {
assertThat(parse("INT", cluster(), null, null, null, false, false)).isEqualTo(cint());
assertThat(parse("SET<BIGint>", cluster(), null, null, null, false, false))
.isEqualTo(set(bigint()));
assertThat(
parse("FROZEN<mAp<Date,Tuple<timeUUID>>>", cluster(), null, null, null, false, false))
.isEqualTo(map(date(), cluster().getMetadata().newTupleType(timeuuid()), true));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
assertThat(b).hasField("f1", set(d));
assertThat(c).hasField("f1", map(e, d));
assertThat(d).hasField("f1", metadata.newTupleType(f, g, h));
assertThat(e).hasField("f1", list(g));
assertThat(f).hasField("f1", h);
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
@SuppressWarnings("deprecation")
@Test(groups = "short")
public void should_handle_collections_of_tuples() {
String query;
BuiltStatement statement;
query = "UPDATE foo SET l=[(1,2)] WHERE k=1;";
TupleType tupleType = cluster().getMetadata().newTupleType(cint(), cint());
List<TupleValue> list = ImmutableList.of(tupleType.newValue(1, 2));
statement = update("foo").with(set("l", list)).where(eq("k", 1));
assertThat(statement.toString()).isEqualTo(query);
}
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
@Test(groups = "short")
public void should_handle_tuple() throws Exception {
String query = "INSERT INTO foo (k,x) VALUES (0,(1));";
TupleType tupleType = cluster().getMetadata().newTupleType(cint());
BuiltStatement insert = insertInto("foo").value("k", 0).value("x", tupleType.newValue(1));
assertEquals(insert.toString(), query);
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
private void setUpTupleTypes(Cluster cluster) {
locationType = cluster.getMetadata().newTupleType(cfloat(), cfloat());
locationValue = locationType.newValue().setFloat(0, 37.387224f).setFloat(1, -121.9733837f);
// insert a tuple of a different dimension
partialLocationValueInserted =
cluster.getMetadata().newTupleType(cfloat()).newValue().setFloat(0, 37.387224f);
// retrieve the partial tuple with null missing values
partialLocationValueRetrieved = locationType.newValue(37.387224f, null);
location = new Location(37.387224f, -121.9733837f);
partialLocation = new Location(37.387224f, 0.0f);
}
内容来源于网络,如有侵权,请联系作者删除!