protected ORID[] getRange() {
    final ORID beginRange;
    final ORID endRange;

    final OSQLFilterCondition rootCondition =
        compiledFilter == null ? null : compiledFilter.getRootCondition();
    if (compiledFilter == null || rootCondition == null) {
      if (request instanceof OSQLSynchQuery)
        beginRange = ((OSQLSynchQuery<ODocument>) request).getNextPageRID();
      else beginRange = null;
      endRange = null;
    } else {
      final ORID conditionBeginRange = rootCondition.getBeginRidRange();
      final ORID conditionEndRange = rootCondition.getEndRidRange();
      final ORID nextPageRid;

      if (request instanceof OSQLSynchQuery)
        nextPageRid = ((OSQLSynchQuery<ODocument>) request).getNextPageRID();
      else nextPageRid = null;

      if (conditionBeginRange != null && nextPageRid != null)
        beginRange =
            conditionBeginRange.compareTo(nextPageRid) > 0 ? conditionBeginRange : nextPageRid;
      else if (conditionBeginRange != null) beginRange = conditionBeginRange;
      else beginRange = nextPageRid;

      endRange = conditionEndRange;
    }

    return new ORID[] {beginRange, endRange};
  }
  public int compareTo(final OIdentifiable iOther) {
    if (iOther == null) return 1;

    final ORID myRID = getIdentity();
    final ORID otherRID = iOther.getIdentity();

    if (myRID == null && otherRID == null) return 0;

    return myRID.compareTo(otherRID);
  }