本文整理汇总了Java中org.apache.ignite.cache.query.SqlFieldsQuery.setReplicatedOnly方法的典型用法代码示例。如果您正苦于以下问题:Java SqlFieldsQuery.setReplicatedOnly方法的具体用法?Java SqlFieldsQuery.setReplicatedOnly怎么用?Java SqlFieldsQuery.setReplicatedOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.cache.query.SqlFieldsQuery
的用法示例。
在下文中一共展示了SqlFieldsQuery.setReplicatedOnly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import org.apache.ignite.cache.query.SqlFieldsQuery; //导入方法依赖的package包/类
/**
*/
private SqlFieldsQuery query(String sql, boolean replicatedOnly) {
SqlFieldsQuery qry = new SqlFieldsQuery(sql);
if (replicatedOnly)
qry.setReplicatedOnly(true);
return qry;
}
示例2: sqlFieldsQuery
import org.apache.ignite.cache.query.SqlFieldsQuery; //导入方法依赖的package包/类
private SqlFieldsQuery sqlFieldsQuery(String sql) {
SqlFieldsQuery qry = new SqlFieldsQuery(sql);
if (isReplicatedOnly())
qry.setReplicatedOnly(true);
return qry;
}
示例3: run
import org.apache.ignite.cache.query.SqlFieldsQuery; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected VisorEither<VisorQueryResult> run(final VisorQueryTaskArg arg) {
try {
UUID nid = ignite.localNode().id();
SqlFieldsQuery qry = new SqlFieldsQuery(arg.getQueryText());
qry.setPageSize(arg.getPageSize());
qry.setLocal(arg.isLocal());
qry.setDistributedJoins(arg.isDistributedJoins());
qry.setEnforceJoinOrder(arg.isEnforceJoinOrder());
qry.setReplicatedOnly(arg.isReplicatedOnly());
qry.setLazy(arg.getLazy());
long start = U.currentTimeMillis();
List<FieldsQueryCursor<List<?>>> qryCursors;
String cacheName = arg.getCacheName();
if (F.isEmpty(cacheName))
qryCursors = ignite.context().query().querySqlFieldsNoCache(qry, true, false);
else {
IgniteCache<Object, Object> c = ignite.cache(cacheName);
if (c == null)
throw new SQLException("Fail to execute query. Cache not found: " + cacheName);
qryCursors = ((IgniteCacheProxy)c.withKeepBinary()).queryMultipleStatements(qry);
}
// In case of multiple statements leave opened only last cursor.
for (int i = 0; i < qryCursors.size() - 1; i++)
U.closeQuiet(qryCursors.get(i));
// In case of multiple statements return last cursor as result.
VisorQueryCursor<List<?>> cur = new VisorQueryCursor<>(F.last(qryCursors));
Collection<GridQueryFieldMetadata> meta = cur.fieldsMeta();
if (meta == null)
return new VisorEither<>(
new VisorExceptionWrapper(new SQLException("Fail to execute query. No metadata available.")));
else {
List<VisorQueryField> names = new ArrayList<>(meta.size());
for (GridQueryFieldMetadata col : meta)
names.add(new VisorQueryField(col.schemaName(), col.typeName(),
col.fieldName(), col.fieldTypeName()));
List<Object[]> rows = fetchSqlQueryRows(cur, arg.getPageSize());
// Query duration + fetch duration.
long duration = U.currentTimeMillis() - start;
boolean hasNext = cur.hasNext();
// Generate query ID to store query cursor in node local storage.
String qryId = SQL_QRY_NAME + "-" + UUID.randomUUID();
if (hasNext) {
ignite.cluster().<String, VisorQueryCursor<List<?>>>nodeLocalMap().put(qryId, cur);
scheduleResultSetHolderRemoval(qryId, ignite);
}
else
cur.close();
return new VisorEither<>(new VisorQueryResult(nid, qryId, names, rows, hasNext, duration));
}
}
catch (Throwable e) {
return new VisorEither<>(new VisorExceptionWrapper(e));
}
}