use of com.couchbase.client.java.json.JsonArray in project couchbase-jvm-clients by couchbase.
the class ViewOptionsTest method shouldTruncateLargeKeysInToString.
@Test
void shouldTruncateLargeKeysInToString() {
StringBuilder largeString = new StringBuilder(142);
for (int i = 0; i < 140; i++) {
largeString.append('a');
}
largeString.append("bc");
JsonArray keysArray = JsonArray.from(largeString.toString());
ViewOptions options = viewOptions().keys(keysArray);
assertEquals("", options.export());
assertEquals("ViewQuery{params=\"\", keys=\"{\"keys\":[\"aaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaa...\"(155 chars total)}", options.toString());
}
use of com.couchbase.client.java.json.JsonArray in project couchbase-jvm-clients by couchbase.
the class DocIdQuery method injectParams.
@Override
protected void injectParams(JsonObject input) {
if (docIds.isEmpty()) {
throw InvalidArgumentException.fromMessage("DocID query needs at least one document ID");
}
JsonArray ids = JsonArray.from(docIds);
input.put("ids", ids);
}
use of com.couchbase.client.java.json.JsonArray in project couchbase-jvm-clients by couchbase.
the class GeoPolygonQuery method injectParams.
@Override
protected void injectParams(final JsonObject input) {
final JsonArray points = JsonArray.create();
for (Coordinate coordinate : coordinates) {
points.add(JsonArray.from(coordinate.lon(), coordinate.lat()));
}
input.put("polygon_points", points);
if (field != null) {
input.put("field", field);
}
}
use of com.couchbase.client.java.json.JsonArray in project couchbase-jvm-clients by couchbase.
the class PhraseQuery method injectParams.
@Override
protected void injectParams(JsonObject input) {
if (terms.isEmpty()) {
throw InvalidArgumentException.fromMessage("Phrase query must at least have one term");
}
JsonArray terms = JsonArray.from(this.terms);
input.put("terms", terms);
if (field != null) {
input.put("field", this.field);
}
}
use of com.couchbase.client.java.json.JsonArray in project couchbase-jvm-clients by couchbase.
the class AsyncQueryIndexManager method exec.
private CompletableFuture<QueryResult> exec(QueryType queryType, CharSequence statement, CommonOptions<?>.BuiltCommonOptions options, String spanName, String bucketName, JsonArray parameters) {
QueryOptions queryOpts = toQueryOptions(options).readonly(requireNonNull(queryType) == READ_ONLY);
if (parameters != null && !parameters.isEmpty()) {
queryOpts.parameters(parameters);
}
RequestSpan parent = cluster.environment().requestTracer().requestSpan(spanName, options.parentSpan().orElse(null));
parent.attribute(TracingIdentifiers.ATTR_SYSTEM, TracingIdentifiers.ATTR_SYSTEM_COUCHBASE);
if (bucketName != null) {
parent.attribute(TracingIdentifiers.ATTR_NAME, bucketName);
}
queryOpts.parentSpan(parent);
return cluster.query(statement.toString(), queryOpts).exceptionally(t -> {
throw translateException(t);
}).whenComplete((r, t) -> parent.end());
}
Aggregations