当前位置: 首页>>代码示例>>Java>>正文


Java SqlFieldsQuery.setReplicatedOnly方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:11,代码来源:IgniteSqlSplitterSelfTest.java

示例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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:9,代码来源:IgniteCacheAbstractFieldsQuerySelfTest.java

示例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));
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:75,代码来源:VisorQueryTask.java


注:本文中的org.apache.ignite.cache.query.SqlFieldsQuery.setReplicatedOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。