use of org.brackit.xquery.node.stream.ArrayStream in project sirix by sirixdb.
the class DBCollection method getDocuments.
@Override
public Stream<DBNode> getDocuments(final boolean updatable) throws DocumentException {
final List<Path> resources = mDatabase.listResources();
final List<DBNode> documents = new ArrayList<>(resources.size());
for (final Path resourcePath : resources) {
try {
final String resourceName = resourcePath.getFileName().toString();
final ResourceManager resource = mDatabase.getResourceManager(ResourceManagerConfiguration.newBuilder(resourceName).build());
final XdmNodeReadTrx trx = updatable ? resource.beginNodeWriteTrx() : resource.beginNodeReadTrx();
documents.add(new DBNode(trx, this));
} catch (final SirixException e) {
throw new DocumentException(e.getCause());
}
}
return new ArrayStream<DBNode>(documents.toArray(new DBNode[documents.size()]));
}
Aggregations