public RecordBatches(final List<RecordBatchHolder> batches) { Preconditions.checkArgument(batches != null && batches.size() >= 1); this.batches = ImmutableList.copyOf(batches); int size = 0; if (batches != null) { for(RecordBatchHolder batch : batches) { size += batch.size(); } } this.size = size; this.schema = batches.get(0).getData().getContainer().getSchema(); }
private Pair<RecordBatchData, Integer> find(int index) { if (index >= recordBatches.getSize()) { throw new IllegalArgumentException(String.format("Invalid index %s", index)); } // Add the offset in the first batch int indexWorkspace = index; for(RecordBatchHolder batchHolder : recordBatches.getBatches()) { if (indexWorkspace < batchHolder.size()) { return new Pair<>(batchHolder.getData(), batchHolder.getStart() + indexWorkspace); } indexWorkspace -= batchHolder.size(); } throw new IllegalArgumentException(String.format("Invalid index %s", index)); }
private Pair<RecordBatchData, Integer> find(int index) { if (index >= getReturnedRowCount()) { throw new IllegalArgumentException(String.format("Invalid index %s", index)); } // Add the offset in the first batch int indexWorkspace = index; for(RecordBatchHolder batchHolder : delegate.getRecordBatches()) { if (indexWorkspace < batchHolder.size()) { return new Pair<>(batchHolder.getData(), batchHolder.getStart() + indexWorkspace); } indexWorkspace -= batchHolder.size(); } throw new IllegalArgumentException(String.format("Invalid index %s", index)); }
remaining -= batchHolder.size();