热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.couchbase.client.java.query.N1qlQueryResult.finalSuccess()方法的使用及代码示例

本文整理了Java中com.couchbase.client.java.query.N1qlQueryResult.finalSuccess()方法的一些代码示例,展示

本文整理了Java中com.couchbase.client.java.query.N1qlQueryResult.finalSuccess()方法的一些代码示例,展示了N1qlQueryResult.finalSuccess()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。N1qlQueryResult.finalSuccess()方法的具体详情如下:
包路径:com.couchbase.client.java.query.N1qlQueryResult
类名称:N1qlQueryResult
方法名:finalSuccess

N1qlQueryResult.finalSuccess介绍

[英]Denotes the success or failure of the query. It could fail slower than with #parseSuccess(), for example if a fatal error comes up while streaming the results to the client. This method blocks until the query is over and the success can be established.
[中]表示查询的成功或失败。它的失败速度可能比使用#parseSuccess()慢,例如,如果将结果流式传输到客户端时出现致命错误。此方法会一直阻塞,直到查询结束并确定成功。

代码示例

代码示例来源:origin: brianfrankcooper/YCSB

));
if (!queryResult.parseSuccess() || !queryResult.finalSuccess()) {
throw new RuntimeException("Error while parsing N1QL Result. Query: " + scanSpecQuery
+ ", Errors: " + queryResult.errors());

代码示例来源:origin: brianfrankcooper/YCSB

));
if (!queryResult.parseSuccess() || !queryResult.finalSuccess()) {
throw new DBException("Error while parsing N1QL Result. Query: " + readQuery
+ ", Errors: " + queryResult.errors());

代码示例来源:origin: brianfrankcooper/YCSB

/**
* Performs the {@link #delete(String, String)} (String, String)} operation via N1QL ("DELETE").
*
* If this option should be used, the "-p couchbase.kv=false" property must be set.
*
* @param docId the document ID.
* @return The result of the operation.
*/
private Status deleteN1ql(final String docId) throws Exception {
String deleteQuery = "DELETE FROM `" + bucketName + "` USE KEYS [$1]";
N1qlQueryResult queryResult = bucket.query(N1qlQuery.parameterized(
deleteQuery,
JsonArray.from(docId),
N1qlParams.build().adhoc(adhoc).maxParallelism(maxParallelism)
));
if (!queryResult.parseSuccess() || !queryResult.finalSuccess()) {
throw new DBException("Error while parsing N1QL Result. Query: " + deleteQuery
+ ", Errors: " + queryResult.errors());
}
return Status.OK;
}

代码示例来源:origin: brianfrankcooper/YCSB

/**
* Performs the {@link #insert(String, String, Map)} operation via N1QL ("INSERT").
*
* If this option should be used, the "-p couchbase.kv=false" property must be set.
*
* @param docId the document ID
* @param values the values to update the document with.
* @return The result of the operation.
*/
private Status insertN1ql(final String docId, final Map values)
throws Exception {
String insertQuery = "INSERT INTO `" + bucketName + "`(KEY,VALUE) VALUES ($1,$2)";
N1qlQueryResult queryResult = bucket.query(N1qlQuery.parameterized(
insertQuery,
JsonArray.from(docId, valuesToJsonObject(values)),
N1qlParams.build().adhoc(adhoc).maxParallelism(maxParallelism)
));
if (!queryResult.parseSuccess() || !queryResult.finalSuccess()) {
throw new DBException("Error while parsing N1QL Result. Query: " + insertQuery
+ ", Errors: " + queryResult.errors());
}
return Status.OK;
}

代码示例来源:origin: brianfrankcooper/YCSB

/**
* Performs the {@link #update(String, String, Map)} operation via N1QL ("UPDATE").
*
* If this option should be used, the "-p couchbase.kv=false" property must be set.
*
* @param docId the document ID
* @param values the values to update the document with.
* @return The result of the operation.
*/
private Status updateN1ql(final String docId, final Map values)
throws Exception {
String fields = encodeN1qlFields(values);
String updateQuery = "UPDATE `" + bucketName + "` USE KEYS [$1] SET " + fields;
N1qlQueryResult queryResult = bucket.query(N1qlQuery.parameterized(
updateQuery,
JsonArray.from(docId),
N1qlParams.build().adhoc(adhoc).maxParallelism(maxParallelism)
));
if (!queryResult.parseSuccess() || !queryResult.finalSuccess()) {
throw new DBException("Error while parsing N1QL Result. Query: " + updateQuery
+ ", Errors: " + queryResult.errors());
}
return Status.OK;
}

代码示例来源:origin: brianfrankcooper/YCSB

/**
* Performs the {@link #upsert(String, String, Map)} operation via N1QL ("UPSERT").
*
* If this option should be used, the "-p couchbase.upsert=true -p couchbase.kv=false" properties must be set.
*
* @param docId the document ID
* @param values the values to update the document with.
* @return The result of the operation.
*/
private Status upsertN1ql(final String docId, final Map values)
throws Exception {
String upsertQuery = "UPSERT INTO `" + bucketName + "`(KEY,VALUE) VALUES ($1,$2)";
N1qlQueryResult queryResult = bucket.query(N1qlQuery.parameterized(
upsertQuery,
JsonArray.from(docId, valuesToJsonObject(values)),
N1qlParams.build().adhoc(adhoc).maxParallelism(maxParallelism)
));
if (!queryResult.parseSuccess() || !queryResult.finalSuccess()) {
throw new DBException("Error while parsing N1QL Result. Query: " + upsertQuery
+ ", Errors: " + queryResult.errors());
}
return Status.OK;
}

代码示例来源:origin: testcontainers/testcontainers-java

@Test
public void shouldExecuteN1ql() {
getBucket().query(N1qlQuery.simple("INSERT INTO " + TEST_BUCKET + " (KEY, VALUE) VALUES ('" + ID + "', " + DOCUMENT + ")"));
N1qlQueryResult query = getBucket().query(N1qlQuery.simple("SELECT * FROM " + TEST_BUCKET + " USE KEYS '" + ID + "'"));
Assert.assertTrue(query.parseSuccess());
Assert.assertTrue(query.finalSuccess());
List n1qlQueryRows = query.allRows();
Assert.assertEquals(1, n1qlQueryRows.size());
Assert.assertEquals(DOCUMENT, n1qlQueryRows.get(0).value().get(TEST_BUCKET).toString());
}

代码示例来源:origin: Impetus/Kundera

/**
* Validate query results.
*
* @param query
* the query
* @param result
* the result
*/
private void validateQueryResults(String query, N1qlQueryResult result)
{
LOGGER.debug("Query output status: " + result.finalSuccess());
if (!result.finalSuccess())
{
StringBuilder errorBuilder = new StringBuilder();
for (JsonObject obj : result.errors())
{
errorBuilder.append(obj.toString());
errorBuilder.append("\n");
}
errorBuilder.deleteCharAt(errorBuilder.length() - 1);
String errors = errorBuilder.toString();
LOGGER.error(errors);
throw new KunderaException("Not able to execute query/statement:" + query + ". More details : " + errors);
}
}

代码示例来源:origin: org.springframework.data/spring-data-couchbase

@Override
public List findByN1QLProjection(N1qlQuery n1ql, Class entityClass) {
checkN1ql();
try {
N1qlQueryResult queryResult = queryN1QL(n1ql);
if (queryResult.finalSuccess()) {
List allRows = queryResult.allRows();
List result = new ArrayList(allRows.size());
for (N1qlQueryRow row : allRows) {
JsonObject json = row.value();
T decoded = translationService.decodeFragment(json.toString(), entityClass);
result.add(decoded);
}
return result;
}
else {
StringBuilder message = new StringBuilder("Unable to execute query due to the following n1ql errors: ");
for (JsonObject error : queryResult.errors()) {
message.append('\n').append(error);
}
throw new CouchbaseQueryExecutionException(message.toString());
}
}
catch (TranscodingException e) {
throw new CouchbaseQueryExecutionException("Unable to execute query", e);
}
}

代码示例来源:origin: org.slinkyframework/slinky-environment-builder-couchbase

private void createPrimaryIndex(Bucket bucket, CouchbaseBuildDefinition buildDefinition) {
LOG.debug("Creating primary index in bucket '{}'", buildDefinition.getBucketName());
N1qlQueryResult result = bucket.query(N1qlQuery.simple(
Index.createPrimaryIndex().on(bucket.name())
));
if (!result.finalSuccess()) {
LOG.error("Failed to create primary index: {}", result.errors());
throw new EnvironmentBuilderException("Failed to create primary index for " + buildDefinition.getBucketName());
}
LOG.debug("Primary index created in bucket '{}'", buildDefinition.getBucketName());
}

代码示例来源:origin: spring-projects/spring-data-couchbase

@Override
public List findByN1QLProjection(N1qlQuery n1ql, Class entityClass) {
checkN1ql();
try {
N1qlQueryResult queryResult = queryN1QL(n1ql);
if (queryResult.finalSuccess()) {
List allRows = queryResult.allRows();
List result = new ArrayList(allRows.size());
for (N1qlQueryRow row : allRows) {
JsonObject json = row.value();
T decoded = translationService.decodeFragment(json.toString(), entityClass);
result.add(decoded);
}
return result;
}
else {
StringBuilder message = new StringBuilder("Unable to execute query due to the following n1ql errors: ");
for (JsonObject error : queryResult.errors()) {
message.append('\n').append(error);
}
throw new CouchbaseQueryExecutionException(message.toString());
}
}
catch (TranscodingException e) {
throw new CouchbaseQueryExecutionException("Unable to execute query", e);
}
}

代码示例来源:origin: org.apereo.cas/cas-server-support-couchbase-core

/**
* Query and get a result by username.
*
* @param usernameAttribute the username attribute
* @param usernameValue the username value
* @return the n1ql query result
* @throws GeneralSecurityException the general security exception
*/
public N1qlQueryResult query(final String usernameAttribute, final String usernameValue) throws GeneralSecurityException {
val theBucket = getBucket();
val statement = Select.select("*")
.from(Expression.i(theBucket.name()))
.where(Expression.x(usernameAttribute).eq('\'' + usernameValue + '\''));
LOGGER.debug("Running query [{}] on bucket [{}]", statement.toString(), theBucket.name());
val query = N1qlQuery.simple(statement);
val result = theBucket.query(query, timeout, TimeUnit.MILLISECONDS);
if (!result.finalSuccess()) {
LOGGER.error("Couchbase query failed with [{}]", result.errors()
.stream()
.map(JsonObject::toString)
.collect(Collectors.joining(",")));
throw new GeneralSecurityException("Could not locate account for user " + usernameValue);
}
return result;
}

代码示例来源:origin: spring-projects/spring-data-couchbase

N1qlQueryResult queryResult = queryN1QL(n1ql);
if (queryResult.finalSuccess()) {
List allRows = queryResult.allRows();
List result = new ArrayList(allRows.size());

代码示例来源:origin: org.springframework.data/spring-data-couchbase

N1qlQueryResult queryResult = queryN1QL(n1ql);
if (queryResult.finalSuccess()) {
List allRows = queryResult.allRows();
List result = new ArrayList(allRows.size());

代码示例来源:origin: org.teiid.connectors/connector-couchbase

@Override
public N1qlQueryResult execute(String statement) throws ResourceException {
N1qlQueryResult result = this.bucket.query(N1qlQuery.simple(statement, N1qlParams.build().consistency(scanConsistency)));
if (!result.finalSuccess()) {
throw new ResourceException(UTIL.gs("query_error", result.errors()), result.status()); //$NON-NLS-1$
}
return result;
}

代码示例来源:origin: org.teiid.wildfly.connectors/connector-couchbase

@Override
public N1qlQueryResult execute(String statement) throws TranslatorException {
N1qlQueryResult result = this.bucket.query(N1qlQuery.simple(statement, N1qlParams.build().consistency(scanConsistency)));
if (!result.finalSuccess()) {
TranslatorException te = new TranslatorException(UTIL.gs("query_error", result.errors())); //$NON-NLS-1$
te.setCode(result.status());
throw te;
}
return result;
}

推荐阅读
author-avatar
aixiangsui2011
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有