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.length > 0
                && comparator.compare(finishColumn, curColPosition.lastName) > 0)
            || (startColumn.length > 0
                && comparator.compare(startColumn, curColPosition.firstName) < 0)) return false;
      } else {
        if ((startColumn.length > 0 && comparator.compare(startColumn, curColPosition.lastName) > 0)
            || (finishColumn.length > 0
                && comparator.compare(finishColumn, curColPosition.firstName) < 0)) return false;
      }

      boolean outOfBounds = false;

      // seek to current block
      // curIndexInfo.offset is the relative offset from the first block
      file.seek(firstBlockPos + curColPosition.offset);

      // read all columns of current block into memory!
      DataInputStream blockIn =
          ColumnFamily.serializer()
              .getBlockInputStream(file, curColPosition.sizeOnDisk, compressContext);
      try {
        int size = 0;
        while ((size < curColPosition.width) && !outOfBounds) {
          IColumn column = emptyColumnFamily.getColumnSerializer().deserialize(blockIn);
          size += column.serializedSize();
          if (reversed) blockColumns.addFirst(column);
          else blockColumns.addLast(column);

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

          if (outOfBounds) break;
        }
      } catch (IOException e) {
        logger.error(e.toString());
        throw e;
      } finally {
        ColumnFamily.serializer().releaseBlockInputStream(blockIn, compressContext);
      }

      if (reversed) curRangeIndex--;
      else curRangeIndex++;
      return true;
    }
Esempio n. 2
0
 public static boolean isRelevant(IColumn column, IColumnContainer container, int gcBefore) {
   // the column itself must be not gc-able (it is live, or a still relevant tombstone, or has live
   // subcolumns), (1)
   // and if its container is deleted, the column must be changed more recently than the container
   // tombstone (2)
   // (since otherwise, the only thing repair cares about is the container tombstone)
   long maxChange = column.mostRecentLiveChangeAt();
   return (!column.isMarkedForDelete()
           || column.getLocalDeletionTime() > gcBefore
           || maxChange > column.getMarkedForDeleteAt()) // (1)
       && (!container.isMarkedForDelete() || maxChange > container.getMarkedForDeleteAt()); // (2)
 }
    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.length > 0
                && comparator.compare(finishColumn, curColPosition.lastName) > 0)
            || (startColumn.length > 0
                && comparator.compare(startColumn, curColPosition.firstName) < 0)) return false;
      } else {
        if ((startColumn.length > 0 && comparator.compare(startColumn, curColPosition.lastName) > 0)
            || (finishColumn.length > 0
                && comparator.compare(finishColumn, curColPosition.firstName) < 0)) return false;
      }

      boolean outOfBounds = false;

      file.reset();
      long curOffset = file.skipBytes((int) curColPosition.offset);
      assert curOffset == curColPosition.offset;
      while (file.bytesPastMark() < curColPosition.offset + curColPosition.width && !outOfBounds) {
        IColumn column = emptyColumnFamily.getColumnSerializer().deserialize(file);
        if (reversed) blockColumns.addFirst(column);
        else blockColumns.addLast(column);

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

        if (outOfBounds) break;
      }

      if (reversed) curRangeIndex--;
      else curRangeIndex++;
      return true;
    }
 private boolean isColumnNeeded(IColumn column) {
   if (startColumn.length == 0 && finishColumn.length == 0) return true;
   else if (startColumn.length == 0 && !reversed)
     return comparator.compare(column.name(), finishColumn) <= 0;
   else if (startColumn.length == 0 && reversed)
     return comparator.compare(column.name(), finishColumn) >= 0;
   else if (finishColumn.length == 0 && !reversed)
     return comparator.compare(column.name(), startColumn) >= 0;
   else if (finishColumn.length == 0 && reversed)
     return comparator.compare(column.name(), startColumn) <= 0;
   else if (!reversed)
     return comparator.compare(column.name(), startColumn) >= 0
         && comparator.compare(column.name(), finishColumn) <= 0;
   else // if reversed
   return comparator.compare(column.name(), startColumn) <= 0
         && comparator.compare(column.name(), finishColumn) >= 0;
 }