@Override public ITupleReference getValue(TxnId txnId, ITupleReference tuple) throws AlgebricksException, HyracksDataException { int numBytes = tupleWriter.bytesRequired(tuple); tupleBytes = new byte[numBytes]; tupleWriter.writeTuple(tuple, tupleBytes, 0); buf = ByteBuffer.wrap(tupleBytes); tupleReference.resetByTupleOffset(buf.array(), 0); return tupleReference; } }
@Override public void resetByTupleIndex(ITreeIndexFrame frame, int tupleIndex) { resetByTupleOffset(frame.getBuffer().array(), frame.getTupleOffset(tupleIndex)); }
@Override public long runExperiment(DataGenThread dataGen, int numThreads) throws InterruptedException { // Wait until the tupleBatchQueue is completely full. while (dataGen.tupleBatchQueue.remainingCapacity() != 0) { Thread.sleep(10); } long start = System.currentTimeMillis(); int tupleIndex = 0; for (int i = 0; i < numBatches; i++) { TupleBatch batch = dataGen.tupleBatchQueue.take(); for (int j = 0; j < batch.size(); j++) { // Copy the tuple to the buffer and set the pre-created tuple ref. tupleWriter.writeTuple(batch.get(j), tupleBuf.array(), tupleIndex * tupleSize); tuples.get(tupleIndex).resetByTupleOffset(tupleBuf.array(), tupleIndex * tupleSize); tupleIndex++; } } // Perform the sort. Collections.sort(tuples, tupleCmp); long end = System.currentTimeMillis(); long time = end - start; return time; }
@Override public void run() { int tupleIndex = 0; try { for (int i = 0; i < numBatches; i++) { TupleBatch batch = dataGen.tupleBatchQueue.take(); for (int j = 0; j < batch.size(); j++) { // Copy the tuple to the buffer and set the pre-created tuple ref. tupleWriter.writeTuple(batch.get(j), tupleBuf.array(), tupleIndex * tupleSize); tuples[tupleIndex].resetByTupleOffset(tupleBuf.array(), tupleIndex * tupleSize); skipList.add(tuples[tupleIndex]); tupleIndex++; } } } catch (Exception e) { System.out.println(tupleIndex); e.printStackTrace(); } } }
@Override public void run() { int tupleIndex = 0; try { for (int i = 0; i < numBatches; i++) { TupleBatch batch = dataGen.tupleBatchQueue.take(); for (int j = 0; j < batch.size(); j++) { // Copy the tuple to the buffer and set the pre-created tuple ref. tupleWriter.writeTuple(batch.get(j), tupleBuf.array(), tupleIndex * tupleSize); tuples[tupleIndex].resetByTupleOffset(tupleBuf.array(), tupleIndex * tupleSize); skipList.add(tuples[tupleIndex]); tupleIndex++; } } } catch (Exception e) { System.out.println(tupleIndex); e.printStackTrace(); } } }