(this is not currently an issue since we don't do read repair for range queries.)
511039
public Iterable<Row> resolve()
    {
        ArrayList<RowIterator> iters = new ArrayList<RowIterator>(responses.size());
        int n = 0;
        for (MessageIn<RangeSliceReply> response : responses)
        {
            RangeSliceReply reply = response.payload;
            n = Math.max(n, reply.rows.size());
            iters.add(new RowIterator(reply.rows.iterator(), response.from));
        }
        // for each row, compute the combination of all different versions seen, and repair incomplete versions
        // TODO do we need to call close?
        CloseableIterator<Row> iter = MergeIterator.get(iters, pairComparator, new Reducer());

        List<Row> resolvedRows = new ArrayList<Row>(n);
        while (iter.hasNext())
            resolvedRows.add(iter.next());

        return resolvedRows;
    }
261864
def fix_e713(self, result):
        """"""
        (line_index, offset, target) = get_index_offset_contents(result,
                                                                 self.source)

        # to convert once 'not in' -> 'in'
        before_target = target[:offset]
        target = target[offset:]
        match_notin = COMPARE_NEGATIVE_REGEX_THROUGH.search(target)
        notin_pos_start, notin_pos_end = 0, 0
        if match_notin:
            notin_pos_start = match_notin.start(1)
            notin_pos_end = match_notin.end()
            target = '{}{} {}'.format(
                target[:notin_pos_start], 'in', target[notin_pos_end:])

        # fix 'not in'
        match = COMPARE_NEGATIVE_REGEX.search(target)
        if match:
            if match.group(3) == 'in':
                pos_start = match.start(1)
                new_target = '{5}{0}{1} {2} {3} {4}'.format(
                    target[:pos_start], match.group(2), match.group(1),
                    match.group(3), target[match.end():], before_target)
                if match_notin:
                    # revert 'in' -> 'not in'
                    pos_start = notin_pos_start + offset
                    pos_end = notin_pos_end + offset - 4     # len('not ')
                    new_target = '{}{} {}'.format(
                        new_target[:pos_start], 'not in', new_target[pos_end:])
                self.source[line_index] = new_target
909115
private int skipAhead(RunContainer skippingOn, int pos, int targetToExceed) {
    int left = pos;
    int span = 1;
    int probePos = 0;
    int end;
    // jump ahead to find a spot where end > targetToExceed (if it exists)
    do {
      probePos = left + span;
      if (probePos >= skippingOn.nbrruns - 1) {
        // expect it might be quite common to find the container cannot be advanced as far as
        // requested. Optimize for it.
        probePos = skippingOn.nbrruns - 1;
        end = toIntUnsigned(skippingOn.getValue(probePos))
            + toIntUnsigned(skippingOn.getLength(probePos)) + 1;
        if (end <= targetToExceed) {
          return skippingOn.nbrruns;
        }
      }
      end = toIntUnsigned(skippingOn.getValue(probePos))
          + toIntUnsigned(skippingOn.getLength(probePos)) + 1;
      span *= 2;
    } while (end <= targetToExceed);
    int right = probePos;
    // left and right are both valid positions. Invariant: left <= targetToExceed && right >
    // targetToExceed
    // do a binary search to discover the spot where left and right are separated by 1, and
    // invariant is maintained.
    while (right - left > 1) {
      int mid = (right + left) / 2;
      int midVal = toIntUnsigned(skippingOn.getValue(mid))
          + toIntUnsigned(skippingOn.getLength(mid)) + 1;
      if (midVal > targetToExceed) {
        right = mid;
      } else {
        left = mid;
      }
    }
    return right;
  }
625191
def _iter_ns_range(self):
    """"""
    while True:
      if self._current_key_range is None:
        query = self._ns_range.make_datastore_query()
        namespace_result = query.Get(1)
        if not namespace_result:
          break

        namespace = namespace_result[0].name() or ""
        self._current_key_range = key_range.KeyRange(
            namespace=namespace, _app=self._ns_range.app)
        yield ALLOW_CHECKPOINT

      for key, o in self._iter_key_range(
          copy.deepcopy(self._current_key_range)):
        # The caller must consume yielded values so advancing the KeyRange
        # before yielding is safe.
        self._current_key_range.advance(key)
        yield o

      if (self._ns_range.is_single_namespace or
          self._current_key_range.namespace == self._ns_range.namespace_end):
        break
      self._ns_range = self._ns_range.with_start_after(
          self._current_key_range.namespace)
      self._current_key_range = None
1036558
function negate(ranges /*:[Range rg]*/) {
  var MIN_CHAR="\u0000",
      // work around UglifyJS's bug
      // it will convert unicode escape to raw char
      // that will cause error in IE
      // because IE recognize "\uFFFF" in source code as "\uFFFD"
      MAX_CHAR=String.fromCharCode(0xFFFF);

  ranges=classify(ranges).ranges;
  var negated=[];
  if (!ranges.length) return negated;
  if (ranges[0][0]!==MIN_CHAR) ranges.unshift(MAX_CHAR);
  var hi=ranges.length-1;
  if ((ranges[hi][1] || ranges[hi][0])!==MAX_CHAR) ranges.push(MIN_CHAR);
  ranges.reduce(function (acc,r) {
    var start=succ(acc[1] || acc[0]),end=pred(r[0]);
    if (start<end) negated.push(start+end);
    if (start===end) negated.push(start);
    return r;
  });
  return negated;
}
1369304
private void issueRequestIfNeeded() {
        //compute read length based on current offset up to which the events are read.
        int updatedReadLength = computeReadLength(offset + buffer.dataAvailable());
        if (!receivedEndOfSegment && !receivedTruncated && updatedReadLength > 0 && outstandingRequest == null) {
            log.trace("Issuing read request for segment {} of {} bytes", getSegmentId(), updatedReadLength);
            outstandingRequest = asyncInput.read(offset + buffer.dataAvailable(), updatedReadLength);
        }
    }
52885
public void repairIndex() throws IOException {
        byte[] currentLargestKey = new byte[keySize];
        int maxChunk = getChunkIndex(getFilledUpFromContentStart());
        for (int currentChunkId = 0; currentChunkId <= maxChunk; currentChunkId++) {
            long currentOffset = (currentChunkId + 1) * getChunkSize() - elementSize;
            if (currentOffset < getFilledUpFromContentStart()) {
                read(currentOffset, currentLargestKey);
            } else {
                read(getFilledUpFromContentStart() - elementSize, currentLargestKey);
            }
            getIndex().setLargestKey(currentChunkId, currentLargestKey);
        }
    }
714510
public void repairSurvivors()
    {
        // cancel() and repair() must be synchronized by the caller (the deliver lock,
        // currently). If cancelled and the last repair message arrives, don't send
        // out corrections!
        if (this.m_promotionResult.isCancelled()) {
            repairLogger.debug(m_whoami + "Skipping repair message creation for cancelled Term.");
            return;
        }

        int queued = 0;
        if (repairLogger.isDebugEnabled()) {
            repairLogger.debug(m_whoami + "received all repair logs and is repairing surviving replicas.");
        }
        for (Iv2RepairLogResponseMessage li : m_repairLogUnion) {
            if (repairLogger.isDebugEnabled()) {
                repairLogger.debug(m_whoami + "RepairResponse:\n" + li);
            }
            List<Long> needsRepair = new ArrayList<Long>(5);
            for (Entry<Long, ReplicaRepairStruct> entry : m_replicaRepairStructs.entrySet()) {
                if  (entry.getValue().needs(li.getHandle())) {
                    ++queued;
                    if (repairLogger.isDebugEnabled()) {
                        repairLogger.debug(m_whoami + "repairing " + CoreUtils.hsIdToString(entry.getKey()) +
                                ". Max seen " + TxnEgo.txnIdToString(entry.getValue().m_maxSpHandleSeen) + ". Repairing with " +
                                TxnEgo.txnIdToString(li.getHandle()));
                    }
                    needsRepair.add(entry.getKey());
                }
            }
            if (!needsRepair.isEmpty()) {
                if (repairLogger.isDebugEnabled()) {
                    repairLogger.debug(m_whoami + "repairing: " + CoreUtils.hsIdCollectionToString(needsRepair) +
                            " with message: " + li.getPayload());
                }
                m_mailbox.repairReplicasWith(needsRepair, li.getPayload());
            }
        }
        if (repairLogger.isDebugEnabled()) {
            repairLogger.debug(m_whoami + "finished queuing " + queued + " replica repair messages.");
        }

        m_promotionResult.set(new RepairResult(m_maxSeenTxnId));
    }
1083413
@Override
	public long skip(long n) throws IOException {
		if (n < 0L) {
			throw new IllegalArgumentException("skip value is negative");
		}
		synchronized (lock) {
			ensureOpen();
			long r = n;
			while (r > 0) {
				if (nextChar >= nChars) {
					fill();
				}
				if (nextChar >= nChars) /* EOF */ {
					break;
				}
				if (skipLF) {
					skipLF = false;
					if (cb[nextChar] == '\n') {
						nextChar++;
					}
				}
				long d = nChars - nextChar;
				if (r <= d) {
					nextChar += r;
					r = 0;
					break;
				} else {
					r -= d;
					nextChar = nChars;
				}
			}
			bytesRead = bytesRead + (n - r);
			return n - r;
		}
	}
246149
function skipIndex() {
		if( childType && childType.indexOf('[]') === childType.length-2 ) {
			childType = childType.substring(0, childType.length-2);
		}
	}
891083
private void checkRange(long index) {
    Assert.indexNot(isEmpty(), "segment is empty");
    Assert.indexNot(index < firstIndex(), index + " is less than the first index in the segment");
    Assert.indexNot(index > lastIndex(), index + " is greater than the last index in the segment");
  }
1008350
function(ranges) {
      let unstaggeredRanges = [];
      ranges.forEach(function(range) {
        let isStaggered = unstaggeredRanges.some(function(unstaggeredRange) {
          let isStartInside =
            range[0] > unstaggeredRange[0] && range[0] < unstaggeredRange[1];
          let isStopInside =
            range[1] > unstaggeredRange[0] && range[1] < unstaggeredRange[1];
          return isStartInside !== isStopInside; // xor
        });
        if (!isStaggered) {
          unstaggeredRanges.push(range);
        }
      });
      return unstaggeredRanges;
    }
446353
private void cleanupQueryStates() {
        completeRequestSpan(currentRequest());
        finishedDecoding();
        queryInfoObservable = null;
        queryRowObservable = null;
        queryErrorObservable = null;
        queryStatusObservable = null;
        querySignatureObservable = null;
        queryParsingState = QUERY_STATE_INITIAL;
    }
741874
@Override
  protected void removeRange(int fromIndex, int toIndex) {
    rangeCheck(fromIndex, toIndex);
    for (int i = fromIndex, j = toIndex; j < size; j++) {
      elements[i] = elements[j];
    }
    size -= (toIndex - fromIndex);
  }
85432
static void checkClosedOpen(final Range<Long> range) {
        checkNotNull(range);
        checkArgument(BoundType.CLOSED == range.lowerBoundType(), "range must be [closed, open), lower bound type was open");
        checkArgument(BoundType.OPEN == range.upperBoundType(), "range must be [closed, open), upper bound type was closed");
    }
773825
@Override
  public void exitSimple_range(VersionParser.Simple_rangeContext ctx)
  {
    String operator = ctx.getChild(0).getText();
    Object o = stack.pop();
    if (o instanceof SemanticVersion) {
      //range = new SemanticVersionRange((SemanticVersion)o);
      switch (operator) {
        case "~>":
          // Special case for "pessimistic" range, see
          // https://www.devalot.com/articles/2012/04/gem-versions.html
          SemanticVersion sv = (SemanticVersion) o;
          VersionRange from = new VersionRange(">=", sv);
          VersionRange to = new VersionRange("<", sv.getNextParentVersion());
          range = new AndRange(from, to);
          break;
        default:
          range = new VersionRange(operator, (SemanticVersion) o);
          break;
      }
      stack.push(range);
    }
    else {
      throw new InvalidRangeRuntimeException("Expected a semantic version, got a " + o.getClass().getSimpleName());
    }
  }
237752
private void negateRange(final short[] buffer, final int startIndex, final int lastIndex,
      final int startRange, final int lastRange) {
    // compute the negation into buffer

    int outPos = 0;
    int inPos = startIndex; // value here always >= valInRange,
    // until it is exhausted
    // n.b., we can start initially exhausted.

    int valInRange = startRange;
    for (; valInRange < lastRange && inPos <= lastIndex; ++valInRange) {
      if ((short) valInRange != content[inPos]) {
        buffer[outPos++] = (short) valInRange;
      } else {
        ++inPos;
      }
    }

    // if there are extra items (greater than the biggest
    // pre-existing one in range), buffer them
    for (; valInRange < lastRange; ++valInRange) {
      buffer[outPos++] = (short) valInRange;
    }

    if (outPos != buffer.length) {
      throw new RuntimeException(
          "negateRange: outPos " + outPos + " whereas buffer.length=" + buffer.length);
    }
    // copy back from buffer...caller must ensure there is room
    int i = startIndex;
    for (short item : buffer) {
      content[i++] = item;
    }
  }