use of org.bboxdb.network.packages.response.MultipleTupleStartResponse in project bboxdb by jnidzwetzki.
the class ContinuousBoundingBoxClientQuery method fetchAndSendNextTuples.
@Override
public void fetchAndSendNextTuples(final short packageSequence) throws IOException, PackageEncodeException {
try {
long sendTuplesInThisPage = 0;
clientConnectionHandler.writeResultPackage(new MultipleTupleStartResponse(packageSequence));
while (queryActive) {
if (sendTuplesInThisPage >= tuplesPerPage) {
clientConnectionHandler.writeResultPackage(new PageEndResponse(packageSequence));
clientConnectionHandler.flushPendingCompressionPackages();
return;
}
// Send next tuple or wait
final Tuple tuple = tupleQueue.take();
final JoinedTuple joinedTuple = new JoinedTuple(tuple, requestTable.getFullname());
clientConnectionHandler.writeResultTuple(packageSequence, joinedTuple);
totalSendTuples++;
sendTuplesInThisPage++;
}
// All tuples are send
clientConnectionHandler.writeResultPackage(new MultipleTupleEndResponse(packageSequence));
clientConnectionHandler.flushPendingCompressionPackages();
} catch (InterruptedException e) {
logger.debug("Got interrupted excetion");
close();
Thread.currentThread().interrupt();
}
}
use of org.bboxdb.network.packages.response.MultipleTupleStartResponse in project bboxdb by jnidzwetzki.
the class StreamClientQuery method fetchAndSendNextTuples.
/* (non-Javadoc)
* @see org.bboxdb.network.server.ClientQuery#fetchAndSendNextTuples(short)
*/
@Override
public void fetchAndSendNextTuples(final short packageSequence) throws IOException, PackageEncodeException {
long sendTuplesInThisPage = 0;
clientConnectionHandler.writeResultPackage(new MultipleTupleStartResponse(packageSequence));
while (!isDataExhausted()) {
if (activeOperatorIterator == null) {
setupNewIterator();
}
// Unable to set up a new iterator
if (activeOperatorIterator == null) {
break;
}
while (activeOperatorIterator.hasNext()) {
// Handle page end
if (pageResult == true && sendTuplesInThisPage >= tuplesPerPage) {
clientConnectionHandler.writeResultPackage(new PageEndResponse(packageSequence));
clientConnectionHandler.flushPendingCompressionPackages();
return;
}
// Send next tuple
final JoinedTuple tuple = activeOperatorIterator.next();
clientConnectionHandler.writeResultTuple(packageSequence, tuple);
totalSendTuples++;
sendTuplesInThisPage++;
}
closeIteratorNE();
}
// All tuples are send
clientConnectionHandler.writeResultPackage(new MultipleTupleEndResponse(packageSequence));
clientConnectionHandler.flushPendingCompressionPackages();
}
use of org.bboxdb.network.packages.response.MultipleTupleStartResponse in project bboxdb by jnidzwetzki.
the class MultipleTupleStartHandler method handleServerResult.
/**
* Handle the multiple tuple start package
* @return
*/
@Override
public boolean handleServerResult(final BBoxDBConnection bBoxDBConnection, final ByteBuffer encodedPackage, final NetworkOperationFuture future) throws PackageEncodeException {
if (logger.isDebugEnabled()) {
logger.debug("Handle multiple tuple start package");
}
final MultipleTupleStartResponse result = MultipleTupleStartResponse.decodePackage(encodedPackage);
final Map<Short, List<PagedTransferableEntity>> resultBuffer = bBoxDBConnection.getResultBuffer();
resultBuffer.put(result.getSequenceNumber(), new ArrayList<>());
return false;
}
use of org.bboxdb.network.packages.response.MultipleTupleStartResponse in project bboxdb by jnidzwetzki.
the class KeyClientQuery method fetchAndSendNextTuples.
@Override
public void fetchAndSendNextTuples(final short packageSequence) throws IOException, PackageEncodeException {
long sendTuplesInThisPage = 0;
clientConnectionHandler.writeResultPackage(new MultipleTupleStartResponse(packageSequence));
final Iterator<Tuple> tupleListIterator = tuplesForKey.iterator();
while (tupleListIterator.hasNext()) {
if (pageResult == true && sendTuplesInThisPage >= tuplesPerPage) {
clientConnectionHandler.writeResultPackage(new PageEndResponse(packageSequence));
clientConnectionHandler.flushPendingCompressionPackages();
return;
}
// Send next tuple
final Tuple tuple = tupleListIterator.next();
tupleListIterator.remove();
final JoinedTuple joinedTuple = new JoinedTuple(tuple, requestTable.getFullname());
clientConnectionHandler.writeResultTuple(packageSequence, joinedTuple);
totalSendTuples++;
sendTuplesInThisPage++;
}
// All tuples are send
clientConnectionHandler.writeResultPackage(new MultipleTupleEndResponse(packageSequence));
clientConnectionHandler.flushPendingCompressionPackages();
}
Aggregations