private void computeNextStartPosition(byte[] lastColName, @Output List<RowResult<Value>> results) { firstRowStartColumnInclusive = RangeRequests.getNextStartRowUnlessTerminal(reverse, lastColName); // We need to handle the edge case where the column was lexicographically last if (firstRowStartColumnInclusive == null) { flushCurrentRow(results); currentRowName = RangeRequests.getNextStartRowUnlessTerminal(reverse, currentRowName); firstRowStartColumnInclusive = PtBytes.EMPTY_BYTE_ARRAY; if (currentRowName == null) { endOfResults = true; } } }
@Override protected Iterator<RowResult<Value>> computeNext() { if (endOfResults) { return endOfData(); } else { try (ConnectionSupplier conns = new ConnectionSupplier(connectionPool)) { List<RawSqlRow> sqlRows = loadSqlRows(conns); Map<Long, byte[]> overflowValues = overflowValueLoader.loadOverflowValues( conns, tableRef, sqlRows.stream() .map(r -> r.overflowId) .filter(Objects::nonNull) .collect(Collectors.toList())); List<RowResult<Value>> rowResults = createRowResults(sqlRows, overflowValues, maxRowsPerPage); if (rowResults.isEmpty()) { endOfResults = true; } else { byte[] lastRowName = rowResults.get(rowResults.size() - 1).getRowName(); startInclusive = RangeRequests.getNextStartRowUnlessTerminal(reverse, lastRowName); endOfResults = (rowResults.size() < maxRowsPerPage) || startInclusive == null; } return rowResults.iterator(); } } }
private CellTsPairToken computeNextStartPosition(List<CellTsPairInfo> results, boolean scannedSingleRow) { if (results.size() < sqlRowLimit) { if (scannedSingleRow) { // If we scanned a single row and reached the end, we just restart // from the lexicographically next row byte[] nextRow = RangeRequests.getNextStartRowUnlessTerminal(false, token.startRowInclusive()); if (nextRow == null) { return CellTsPairToken.end(); } else { cellTsPairsAlreadyExaminedInCurrentRow = 0L; return CellTsPairToken.startRow(nextRow); } } else { return CellTsPairToken.end(); } } else { CellTsPairInfo lastResult = Iterables.getLast(results); return CellTsPairToken.continueRow(lastResult); } }
private TimestampsByCellResultWithToken checkNextEntryAndCreateToken() { boolean singleRow = finishCellIfNoRowsYet(); if (iterator.hasNext()) { moreResults = true; AgnosticLightResultRow nextEntry = iterator.peek(); if (Arrays.equals(nextEntry.getBytes(DbKvs.ROW), currentRow)) { token = ImmutableToken.builder() .row(currentRow) .col(currentCol) .shouldSkip(singleRow) .build(); } else { flushRowBuffer(); token = ImmutableToken.builder().row(nextEntry.getBytes(DbKvs.ROW)).shouldSkip(false).build(); } } else { flushRowBuffer(); if (currentRow != null) { byte[] nextRow = RangeRequests.getNextStartRowUnlessTerminal(reverse, currentRow); if (nextRow != null) { moreResults = true; token = ImmutableToken.builder().row(nextRow).shouldSkip(false).build(); } } } return this; }
private void computeNextStartPosition(byte[] lastColName, @Output List<RowResult<Value>> results) { firstRowStartColumnInclusive = RangeRequests.getNextStartRowUnlessTerminal(reverse, lastColName); // We need to handle the edge case where the column was lexicographically last if (firstRowStartColumnInclusive == null) { flushCurrentRow(results); currentRowName = RangeRequests.getNextStartRowUnlessTerminal(reverse, currentRowName); firstRowStartColumnInclusive = PtBytes.EMPTY_BYTE_ARRAY; if (currentRowName == null) { endOfResults = true; } } }
@Override protected Iterator<RowResult<Value>> computeNext() { if (endOfResults) { return endOfData(); } else { try (ConnectionSupplier conns = new ConnectionSupplier(connectionPool)) { List<RawSqlRow> sqlRows = loadSqlRows(conns); Map<Long, byte[]> overflowValues = overflowValueLoader.loadOverflowValues( conns, tableRef, sqlRows.stream() .map(r -> r.overflowId) .filter(Objects::nonNull) .collect(Collectors.toList())); List<RowResult<Value>> rowResults = createRowResults(sqlRows, overflowValues, maxRowsPerPage); if (rowResults.isEmpty()) { endOfResults = true; } else { byte[] lastRowName = rowResults.get(rowResults.size() - 1).getRowName(); startInclusive = RangeRequests.getNextStartRowUnlessTerminal(reverse, lastRowName); endOfResults = (rowResults.size() < maxRowsPerPage) || startInclusive == null; } return rowResults.iterator(); } } }
private CellTsPairToken computeNextStartPosition(List<CellTsPairInfo> results, boolean scannedSingleRow) { if (results.size() < sqlRowLimit) { if (scannedSingleRow) { // If we scanned a single row and reached the end, we just restart // from the lexicographically next row byte[] nextRow = RangeRequests.getNextStartRowUnlessTerminal(false, token.startRowInclusive()); if (nextRow == null) { return CellTsPairToken.end(); } else { cellTsPairsAlreadyExaminedInCurrentRow = 0L; return CellTsPairToken.startRow(nextRow); } } else { return CellTsPairToken.end(); } } else { CellTsPairInfo lastResult = Iterables.getLast(results); return CellTsPairToken.continueRow(lastResult); } }
private TimestampsByCellResultWithToken checkNextEntryAndCreateToken() { boolean singleRow = finishCellIfNoRowsYet(); if (iterator.hasNext()) { moreResults = true; AgnosticLightResultRow nextEntry = iterator.peek(); if (Arrays.equals(nextEntry.getBytes(DbKvs.ROW), currentRow)) { token = ImmutableToken.builder() .row(currentRow) .col(currentCol) .shouldSkip(singleRow) .build(); } else { flushRowBuffer(); token = ImmutableToken.builder().row(nextEntry.getBytes(DbKvs.ROW)).shouldSkip(false).build(); } } else { flushRowBuffer(); if (currentRow != null) { byte[] nextRow = RangeRequests.getNextStartRowUnlessTerminal(reverse, currentRow); if (nextRow != null) { moreResults = true; token = ImmutableToken.builder().row(nextRow).shouldSkip(false).build(); } } } return this; }