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


Java CloseableIterables类代码示例

本文整理汇总了Java中org.calrissian.mango.collect.CloseableIterables的典型用法代码示例。如果您正苦于以下问题:Java CloseableIterables类的具体用法?Java CloseableIterables怎么用?Java CloseableIterables使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CloseableIterables类属于org.calrissian.mango.collect包,在下文中一共展示了CloseableIterables类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: wrapBatchScanner

import org.calrissian.mango.collect.CloseableIterables; //导入依赖的package包/类
/**
 * Creates a {@link CloseableIterable} from a BatchScanner, autoclosing the iterator when exhausted.
 * <p>
 * This method is necessary because BatchScanner does not implement Closeable, yet defines a close() method that must be called to free thread resources.
 * 
 * @param bs BatchScanner to wrap
 * @return {@link CloseableIterable}
 * @see CloseableIterables#autoClose(CloseableIterable)
 */
@SuppressWarnings("unchecked")
public static final CloseableIterable<Entry<Key, Value>> wrapBatchScanner(final BatchScanner bs) {
    notNull(bs);
    if (bs instanceof CloseableIterable)
        return (CloseableIterable<Entry<Key, Value>>) bs;

    return CloseableIterables.autoClose(new FluentCloseableIterable<Entry<Key, Value>>() {
        @Override
        protected void doClose() throws IOException {
            bs.close();
        }

        @Override
        protected Iterator<Entry<Key, Value>> retrieveIterator() {
            return bs.iterator();
        }
    });
}
 
开发者ID:tequalsme,项目名称:accumulo-starter,代码行数:28,代码来源:BatchScannerIterables.java

示例2: queryElements

import org.calrissian.mango.collect.CloseableIterables; //导入依赖的package包/类
private <T> CloseableIterable<T> queryElements(Set<String> elementTypes, Function<Entity, T> function) {

        Node query = queryBuilder.end().build();
        Node filter = filters.end().build();

        CloseableIterable<Entity> entities = query.children().size() > 0 ?
                graphStore.query(elementTypes, query, null, auths) :
                graphStore.getAllByType(elementTypes, null, auths);
        CloseableIterable<T> elements = transform(entities, function);

        if (filter.children().size() > 0)
            elements = CloseableIterables.filter(elements, new EntityFilterPredicate(criteriaFromNode(filter)));

        if (limit > -1)
            return CloseableIterables.limit(elements, limit);
        else
            return elements;
    }
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:19,代码来源:EntityGraphQuery.java

示例3: query

import org.calrissian.mango.collect.CloseableIterables; //导入依赖的package包/类
@Override
public CloseableIterable<RyaStatement> query(final BatchRyaQuery batchRyaQuery)
        throws RyaDAOException {
    Preconditions.checkNotNull(batchRyaQuery);

    final Map<RyaStatement, BindingSet> queries = new HashMap<>();

    for (final RyaStatement stmt : batchRyaQuery.getQueries()) {
        queries.put(stmt, new MapBindingSet());
    }

    Iterator<RyaStatement> iterator = new RyaStatementCursorIterator(queryWithBindingSet(queries.entrySet(), getConf()));
    return CloseableIterables.wrap((Iterable<RyaStatement>) () -> iterator);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:15,代码来源:MongoDBQueryEngine.java

示例4: getVertices

import org.calrissian.mango.collect.CloseableIterables; //导入依赖的package包/类
/**
 * Retrieves all the vertices with the given vertex types configured on the current instance
 */
@Override
public CloseableIterable<Vertex> getVertices() {
    CloseableIterable<Entity> entities = graphStore.getAllByType(vertexTypes, null, auths);
    return CloseableIterables.transform(entities, new VertexEntityXform(graphStore, auths));
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:9,代码来源:EntityGraph.java

示例5: getEdges

import org.calrissian.mango.collect.CloseableIterables; //导入依赖的package包/类
/**
 * Returns all edges with the entity edge types configured on this instance
 */
@Override
public CloseableIterable<Edge> getEdges() {
    CloseableIterable<Entity> entities = graphStore.getAllByType(edgeTypes, null, auths);
    return CloseableIterables.transform(entities, new EdgeEntityXform(graphStore, auths));
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:9,代码来源:EntityGraph.java

示例6: transform

import org.calrissian.mango.collect.CloseableIterables; //导入依赖的package包/类
/**
 * Transforms Entry<Key, Value> (provided by BatchScanner) using the supplied Function, while wrapping the BatchScanner so that it is properly closed upon
 * completion.
 * 
 * @param bs BatchScanner
 * @return CloseableIterable<T>
 * @see #wrapBatchScanner(BatchScanner)
 */
public static final <T> CloseableIterable<T> transform(BatchScanner bs, Function<Entry<Key, Value>, T> function) {
    return CloseableIterables.transform(wrapBatchScanner(bs), function);
}
 
开发者ID:tequalsme,项目名称:accumulo-starter,代码行数:12,代码来源:BatchScannerIterables.java


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