@Override public void close() throws Exception { for (ResultCursor<T> rc: results) { rc.close(); } //index = 0; // close iterators? }
@Override public String queryDocumentByUri(String uri) throws Exception { String query = "for $doc in fn:doc(\"" + uri + "\")\n" + "return $doc\n"; try (ResultCursor<String> cursor = xRepo.getQueryManagement().executeQuery(query, null, new Properties())) { String result = null; if (!cursor.isEmpty()) { result = cursor.iterator().next(); // proc.convertToString(itr.next(), null); } return result; } }
@Override public boolean isComplete() { for (ResultCursor<T> cursor: results) { if (!cursor.isComplete()) { return false; } } return true; }
Iterator<XQItem> iter = result.iterator(); logger.trace("write; got result: {} with iter: {}", result, iter); try (Writer writer = new BufferedWriter(new OutputStreamWriter(os))) { } else { logger.trace("write; no next; idx: {}", idx); if (result.isComplete()) { logger.trace("write; no next, got complete; {}", idx); logger.debug("write; written {} chunks", idx); } catch (EofException ex) { logger.info("write; client has terminated connection at {} chunk, out of {} total chunks", idx, result.size()); } catch (Exception ex) { logger.error("write.error: error getting result from cursor ", ex); result.close(); } catch (Exception ex) { logger.error("write.error: closing cursor ", ex);
protected void checkCursorResult(ResultCursor<XQItemAccessor> results, String expected) throws Exception { try { Iterator<XQItemAccessor> iter = results.iterator(); assertTrue(iter.hasNext()); if (expected == null) { assertNotNull(iter.next().getObject()); } else { Properties props = new Properties(); props.setProperty("method", "text"); XQItem item = (XQItem) iter.next(); assertEquals(expected, item.getItemAsString(props)); } assertFalse(iter.hasNext()); } finally { results.close(); } }
IterableXQSequence(BagriXQDataFactory xqFactory, XQProcessor xqProcessor, ResultCursor<XQItemAccessor> cursor) { super(xqFactory, xqProcessor); this.cursor = cursor; this.iter = cursor.iterator(); accessed = false; }
@Override public boolean isEmpty() { for (ResultCursor<T> cursor: results) { if (!cursor.isEmpty()) { return false; } } return true; }
docs = new HashMap<>(cursor.size());
@Override public boolean isAsynch() { for (ResultCursor<T> cursor: results) { if (cursor.isAsynch()) { return true; } } return false; }
props.setProperty(pn_document_headers, String.valueOf(DocumentAccessor.HDR_URI)); try (ResultCursor<DocumentAccessor> uris = docMgr.getDocuments(query, props)) { if (uris.isEmpty()) { return Response.noContent().build();
@Override public String queryDocumentFromCollection() throws Exception { String query = "for $doc in fn:collection()\n" + "return $doc\n"; try (ResultCursor<String> cursor = xRepo.getQueryManagement().executeQuery(query, null, new Properties())) { String result = null; if (!cursor.isEmpty()) { result = cursor.iterator().next(); // proc.convertToString(itr.next(), null); } return result; } }
@Override public void close() throws XQException { if (!isClosed()) { super.close(); try { cursor.close(); } catch (Exception ex) { throw getXQException(ex); } } }
try { cursor = repo.getQueryManagement().executeQuery(query, params, props); empty = cursor.isEmpty(); } catch (BagriException ex) { logger.error("apply.error: ", ex);
if (rc.isComplete()) { results.remove(rc); return rc; return true; } else { if (curResult.isComplete()) { logger.trace("hasNext; complete"); curResult = null;
ResultCursor<XQItemAccessor> cursor = queryMgr.executeQuery(query, params, props); result = extractResult(cursor, props); cursor.close(); } else { XQStaticContext ctx = xqConn.getStaticContext();
ResultCursor<XQItemAccessor> cursor = queryMgr.executeQuery(query, null, props); result = extractResult(cursor, props); cursor.close(); } else { XQStaticContext ctx = xqConn.getStaticContext();