本文整理汇总了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();
}
});
}
示例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;
}
示例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);
}
示例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));
}
示例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));
}
示例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);
}