本文整理汇总了Java中org.apache.ignite.cache.query.SqlFieldsQuery.setPageSize方法的典型用法代码示例。如果您正苦于以下问题:Java SqlFieldsQuery.setPageSize方法的具体用法?Java SqlFieldsQuery.setPageSize怎么用?Java SqlFieldsQuery.setPageSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.cache.query.SqlFieldsQuery
的用法示例。
在下文中一共展示了SqlFieldsQuery.setPageSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSqlFieldsQueryNotFullyFetchedMetrics
import org.apache.ignite.cache.query.SqlFieldsQuery; //导入方法依赖的package包/类
/**
* Test metrics for SQL fields queries.
*
* @throws Exception In case of error.
*/
public void testSqlFieldsQueryNotFullyFetchedMetrics() throws Exception {
IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A");
SqlFieldsQuery qry = new SqlFieldsQuery("select * from String");
qry.setPageSize(10);
checkQueryNotFullyFetchedMetrics(cache, qry, false);
}
示例2: testSqlFieldsCrossCacheQueryNotFullyFetchedMetrics
import org.apache.ignite.cache.query.SqlFieldsQuery; //导入方法依赖的package包/类
/**
* Test metrics for SQL cross cache queries.
*
* @throws Exception In case of error.
*/
public void testSqlFieldsCrossCacheQueryNotFullyFetchedMetrics() throws Exception {
IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A");
SqlFieldsQuery qry = new SqlFieldsQuery("select * from \"B\".String");
qry.setPageSize(10);
checkQueryNotFullyFetchedMetrics(cache, qry, false);
}
示例3: queryDistributedSql
import org.apache.ignite.cache.query.SqlFieldsQuery; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <K, V> QueryCursor<Cache.Entry<K, V>> queryDistributedSql(String schemaName, String cacheName,
SqlQuery qry, boolean keepBinary, int mainCacheId) {
String type = qry.getType();
H2TableDescriptor tblDesc = tableDescriptor(schemaName, cacheName, type);
if (tblDesc == null)
throw new IgniteSQLException("Failed to find SQL table for type: " + type,
IgniteQueryErrorCode.TABLE_NOT_FOUND);
String sql;
try {
sql = generateQuery(qry.getSql(), qry.getAlias(), tblDesc);
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
SqlFieldsQuery fqry = new SqlFieldsQuery(sql);
fqry.setArgs(qry.getArgs());
fqry.setPageSize(qry.getPageSize());
fqry.setDistributedJoins(qry.isDistributedJoins());
fqry.setPartitions(qry.getPartitions());
fqry.setLocal(qry.isLocal());
if (qry.getTimeout() > 0)
fqry.setTimeout(qry.getTimeout(), TimeUnit.MILLISECONDS);
final QueryCursor<List<?>> res =
queryDistributedSqlFields(schemaName, fqry, keepBinary, null, mainCacheId, true).get(0);
final Iterable<Cache.Entry<K, V>> converted = new Iterable<Cache.Entry<K, V>>() {
@Override public Iterator<Cache.Entry<K, V>> iterator() {
final Iterator<List<?>> iter0 = res.iterator();
return new Iterator<Cache.Entry<K, V>>() {
@Override public boolean hasNext() {
return iter0.hasNext();
}
@Override public Cache.Entry<K, V> next() {
List<?> l = iter0.next();
return new CacheEntryImpl<>((K)l.get(0), (V)l.get(1));
}
@Override public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
// No metadata for SQL queries.
return new QueryCursorImpl<Cache.Entry<K, V>>(converted) {
@Override public void close() {
res.close();
}
};
}
示例4: 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));
}
}
示例5: doSingleUpdate
import org.apache.ignite.cache.query.SqlFieldsQuery; //导入方法依赖的package包/类
/**
* Performs update.
*
* @param cache Cache.
* @param sqlText SQL text.
* @param args Parameters.
* @return Update counter.
* @throws SQLException If failed.
*/
private Integer doSingleUpdate(IgniteCache<?, ?> cache, String sqlText, List<Object> args) throws SQLException {
SqlFieldsQuery qry = new SqlFieldsQueryEx(sqlText, false);
qry.setPageSize(fetchSize);
qry.setLocal(locQry);
qry.setCollocated(collocatedQry);
qry.setDistributedJoins(distributedJoins);
qry.setSchema(schemaName);
qry.setArgs(args == null ? null : args.toArray());
QueryCursorImpl<List<?>> qryCursor = (QueryCursorImpl<List<?>>)cache.withKeepBinary().query(qry);
if (qryCursor.isQuery()) {
throw createJdbcSqlException(getError("Query produced result set", qry),
IgniteQueryErrorCode.STMT_TYPE_MISMATCH);
}
List<List<?>> rows = qryCursor.getAll();
if (F.isEmpty(rows))
return SUCCESS_NO_INFO;
if (rows.size() != 1)
throw new SQLException(getError("Expected single row for update operation result", qry));
List<?> row = rows.get(0);
if (F.isEmpty(row) || row.size() != 1)
throw new SQLException(getError("Expected row size of 1 for update operation", qry));
Object objRes = row.get(0);
if (!(objRes instanceof Long))
throw new SQLException(getError("Unexpected update result type", qry));
Long longRes = (Long)objRes;
if (longRes > Integer.MAX_VALUE) {
IgniteLogger log = ignite.log();
if (log != null)
log.warning(getError("Query updated row counter (" + longRes + ") exceeds integer range", qry));
return Integer.MAX_VALUE;
}
return longRes.intValue();
}