Ejemplo n.º 1
0
    private SimpleBlockFetcher() throws IOException {
      IColumnSerializer columnSerializer = emptyColumnFamily.getColumnSerializer();
      int columns = file.readInt();
      for (int i = 0; i < columns; i++) {
        IColumn column = columnSerializer.deserialize(file);
        if (reversed) blockColumns.addFirst(column);
        else blockColumns.addLast(column);

        /* see if we can stop seeking. */
        boolean outOfBounds = false;
        if (!reversed && finishColumn.remaining() > 0)
          outOfBounds = comparator.compare(column.name(), finishColumn) >= 0;
        else if (reversed && startColumn.remaining() > 0)
          outOfBounds = comparator.compare(column.name(), startColumn) >= 0;
        if (outOfBounds) break;
      }
    }
Ejemplo n.º 2
0
    public boolean getNextBlock() throws IOException {
      if (curRangeIndex < 0 || curRangeIndex >= indexes.size()) return false;

      /* seek to the correct offset to the data, and calculate the data size */
      IndexHelper.IndexInfo curColPosition = indexes.get(curRangeIndex);

      /* see if this read is really necessary. */
      if (reversed) {
        if ((finishColumn.remaining() > 0
                && comparator.compare(finishColumn, curColPosition.lastName) > 0)
            || (startColumn.remaining() > 0
                && comparator.compare(startColumn, curColPosition.firstName) < 0)) return false;
      } else {
        if ((startColumn.remaining() > 0
                && comparator.compare(startColumn, curColPosition.lastName) > 0)
            || (finishColumn.remaining() > 0
                && comparator.compare(finishColumn, curColPosition.firstName) < 0)) return false;
      }

      boolean outOfBounds = false;
      long positionToSeek = basePosition + curColPosition.offset;

      // With new promoted indexes, our first seek in the data file will happen at that point.
      if (file == null)
        file = originalInput == null ? sstable.getFileDataInput(positionToSeek) : originalInput;

      IColumnSerializer columnSerializer = emptyColumnFamily.getColumnSerializer();
      file.seek(positionToSeek);
      FileMark mark = file.mark();
      while (file.bytesPastMark(mark) < curColPosition.width && !outOfBounds) {
        IColumn column = columnSerializer.deserialize(file);
        if (reversed) blockColumns.addFirst(column);
        else blockColumns.addLast(column);

        /* see if we can stop seeking. */
        if (!reversed && finishColumn.remaining() > 0)
          outOfBounds = comparator.compare(column.name(), finishColumn) >= 0;
        else if (reversed && startColumn.remaining() > 0)
          outOfBounds = comparator.compare(column.name(), startColumn) >= 0;
      }

      if (reversed) curRangeIndex--;
      else curRangeIndex++;
      return true;
    }