@Test(expected = EOFException.class) public void testSeekAfterEverythingWrongCount() throws IOException { Key seekKey = new Key("s", "t", "u", "v", 1); Key prevKey = new Key(); Key currKey = null; MutableByteSequence value = new MutableByteSequence(new byte[64], 0, 0); RelativeKey.fastSkip(in, seekKey, value, prevKey, currKey, expectedKeys.size() + 1); }
public static SkippR fastSkip(DataInput in, Key seekKey, MutableByteSequence value, Key prevKey, Key currKey, int entriesLeft) throws IOException { MutableByteSequence row, cf, cq, cv; MutableByteSequence prow, pcf, pcq, pcv; ByteSequence stopRow = seekKey.getRowData(); ByteSequence stopCF = seekKey.getColumnFamilyData(); ByteSequence stopCQ = seekKey.getColumnQualifierData(); long ts = -1; long pts = -1; boolean pdel = false; int rowCmp = -1, cfCmp = -1, cqCmp = -1; if (currKey != null) { prow = new MutableByteSequence(currKey.getRowData()); pcf = new MutableByteSequence(currKey.getColumnFamilyData()); pcq = new MutableByteSequence(currKey.getColumnQualifierData()); pcv = new MutableByteSequence(currKey.getColumnVisibilityData()); pts = currKey.getTimestamp(); row = new MutableByteSequence(currKey.getRowData()); cf = new MutableByteSequence(currKey.getColumnFamilyData()); cq = new MutableByteSequence(currKey.getColumnQualifierData()); cv = new MutableByteSequence(currKey.getColumnVisibilityData()); ts = currKey.getTimestamp(); rowCmp = row.compareTo(stopRow); cfCmp = cf.compareTo(stopCF); cqCmp = cq.compareTo(stopCQ); if (rowCmp >= 0) { if (rowCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cfCmp >= 0) { if (cfCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cqCmp >= 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } } } } else { row = new MutableByteSequence(new byte[64], 0, 0); cf = new MutableByteSequence(new byte[64], 0, 0); cq = new MutableByteSequence(new byte[64], 0, 0); cv = new MutableByteSequence(new byte[64], 0, 0); prow = new MutableByteSequence(new byte[64], 0, 0); pcf = new MutableByteSequence(new byte[64], 0, 0); pcq = new MutableByteSequence(new byte[64], 0, 0); pcv = new MutableByteSequence(new byte[64], 0, 0); } byte fieldsSame = -1; byte fieldsPrefixed = 0; int count = 0; Key newPrevKey = null; while (count < entriesLeft) { pdel = (fieldsSame & DELETED) == DELETED; fieldsSame = in.readByte(); if ((fieldsSame & PREFIX_COMPRESSION_ENABLED) == PREFIX_COMPRESSION_ENABLED) fieldsPrefixed = in.readByte(); else fieldsPrefixed = 0; boolean changed = false; if ((fieldsSame & ROW_SAME) != ROW_SAME) { MutableByteSequence tmp = prow; prow = row; row = tmp; if ((fieldsPrefixed & ROW_COMMON_PREFIX) == ROW_COMMON_PREFIX) readPrefix(in, row, prow); else read(in, row); rowCmp = row.compareTo(stopRow); changed = true; } if ((fieldsSame & CF_SAME) != CF_SAME) { MutableByteSequence tmp = pcf; pcf = cf; cf = tmp; if ((fieldsPrefixed & CF_COMMON_PREFIX) == CF_COMMON_PREFIX) readPrefix(in, cf, pcf); else read(in, cf); cfCmp = cf.compareTo(stopCF); changed = true; } if ((fieldsSame & CQ_SAME) != CQ_SAME) { MutableByteSequence tmp = pcq; pcq = cq; cq = tmp; if ((fieldsPrefixed & CQ_COMMON_PREFIX) == CQ_COMMON_PREFIX) readPrefix(in, cq, pcq); else read(in, cq); cqCmp = cq.compareTo(stopCQ); changed = true; } if ((fieldsSame & CV_SAME) != CV_SAME) { MutableByteSequence tmp = pcv; pcv = cv; cv = tmp; if ((fieldsPrefixed & CV_COMMON_PREFIX) == CV_COMMON_PREFIX) readPrefix(in, cv, pcv); else read(in, cv); } if ((fieldsSame & TS_SAME) != TS_SAME) { pts = ts; if ((fieldsPrefixed & TS_DIFF) == TS_DIFF) ts = WritableUtils.readVLong(in) + pts; else ts = WritableUtils.readVLong(in); } readValue(in, value); count++; if (changed && rowCmp >= 0) { if (rowCmp > 0) break; if (cfCmp >= 0) { if (cfCmp > 0) break; if (cqCmp >= 0) break; } } } if (count > 1) { MutableByteSequence trow, tcf, tcq, tcv; long tts; trow = (fieldsSame & ROW_SAME) == ROW_SAME ? row : prow; tcf = (fieldsSame & CF_SAME) == CF_SAME ? cf : pcf; tcq = (fieldsSame & CQ_SAME) == CQ_SAME ? cq : pcq; tcv = (fieldsSame & CV_SAME) == CV_SAME ? cv : pcv; tts = (fieldsSame & TS_SAME) == TS_SAME ? ts : pts; newPrevKey = new Key(trow.getBackingArray(), trow.offset(), trow.length(), tcf.getBackingArray(), tcf.offset(), tcf.length(), tcq.getBackingArray(), tcq.offset(), tcq.length(), tcv.getBackingArray(), tcv.offset(), tcv.length(), tts); newPrevKey.setDeleted(pdel); } else if (count == 1) { if (currKey != null) newPrevKey = currKey; else newPrevKey = prevKey; } else { throw new IllegalStateException(); } RelativeKey result = new RelativeKey(); result.key = new Key(row.getBackingArray(), row.offset(), row.length(), cf.getBackingArray(), cf.offset(), cf.length(), cq.getBackingArray(), cq.offset(), cq.length(), cv.getBackingArray(), cv.offset(), cv.length(), ts); result.key.setDeleted((fieldsSame & DELETED) != 0); result.prevKey = result.key; return new SkippR(result, count, newPrevKey); }
RelativeKey implements Writable { public static SkippR fastSkip(DataInput in, Key seekKey, MutableByteSequence value, Key prevKey, Key currKey, int entriesLeft) throws IOException { MutableByteSequence row, cf, cq, cv; MutableByteSequence prow, pcf, pcq, pcv; ByteSequence stopRow = seekKey.getRowData(); ByteSequence stopCF = seekKey.getColumnFamilyData(); ByteSequence stopCQ = seekKey.getColumnQualifierData(); long ts = -1; long pts = -1; boolean pdel = false; int rowCmp = -1, cfCmp = -1, cqCmp = -1; if (currKey != null) { prow = new MutableByteSequence(currKey.getRowData()); pcf = new MutableByteSequence(currKey.getColumnFamilyData()); pcq = new MutableByteSequence(currKey.getColumnQualifierData()); pcv = new MutableByteSequence(currKey.getColumnVisibilityData()); pts = currKey.getTimestamp(); row = new MutableByteSequence(currKey.getRowData()); cf = new MutableByteSequence(currKey.getColumnFamilyData()); cq = new MutableByteSequence(currKey.getColumnQualifierData()); cv = new MutableByteSequence(currKey.getColumnVisibilityData()); ts = currKey.getTimestamp(); rowCmp = row.compareTo(stopRow); cfCmp = cf.compareTo(stopCF); cqCmp = cq.compareTo(stopCQ); if (rowCmp >= 0) { if (rowCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cfCmp >= 0) { if (cfCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cqCmp >= 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } } } } else { row = new MutableByteSequence(new byte[64], 0, 0); cf = new MutableByteSequence(new byte[64], 0, 0); cq = new MutableByteSequence(new byte[64], 0, 0); cv = new MutableByteSequence(new byte[64], 0, 0); prow = new MutableByteSequence(new byte[64], 0, 0); pcf = new MutableByteSequence(new byte[64], 0, 0); pcq = new MutableByteSequence(new byte[64], 0, 0); pcv = new MutableByteSequence(new byte[64], 0, 0); } byte fieldsSame = -1; byte fieldsPrefixed = 0; int count = 0; Key newPrevKey = null; while (count < entriesLeft) { pdel = (fieldsSame & DELETED) == DELETED; fieldsSame = in.readByte(); if ((fieldsSame & PREFIX_COMPRESSION_ENABLED) == PREFIX_COMPRESSION_ENABLED) fieldsPrefixed = in.readByte(); else fieldsPrefixed = 0; boolean changed = false; if ((fieldsSame & ROW_SAME) != ROW_SAME) { MutableByteSequence tmp = prow; prow = row; row = tmp; if ((fieldsPrefixed & ROW_COMMON_PREFIX) == ROW_COMMON_PREFIX) readPrefix(in, row, prow); else read(in, row); rowCmp = row.compareTo(stopRow); changed = true; } if ((fieldsSame & CF_SAME) != CF_SAME) { MutableByteSequence tmp = pcf; pcf = cf; cf = tmp; if ((fieldsPrefixed & CF_COMMON_PREFIX) == CF_COMMON_PREFIX) readPrefix(in, cf, pcf); else read(in, cf); cfCmp = cf.compareTo(stopCF); changed = true; } if ((fieldsSame & CQ_SAME) != CQ_SAME) { MutableByteSequence tmp = pcq; pcq = cq; cq = tmp; if ((fieldsPrefixed & CQ_COMMON_PREFIX) == CQ_COMMON_PREFIX) readPrefix(in, cq, pcq); else read(in, cq); cqCmp = cq.compareTo(stopCQ); changed = true; } if ((fieldsSame & CV_SAME) != CV_SAME) { MutableByteSequence tmp = pcv; pcv = cv; cv = tmp; if ((fieldsPrefixed & CV_COMMON_PREFIX) == CV_COMMON_PREFIX) readPrefix(in, cv, pcv); else read(in, cv); } if ((fieldsSame & TS_SAME) != TS_SAME) { pts = ts; if ((fieldsPrefixed & TS_DIFF) == TS_DIFF) ts = WritableUtils.readVLong(in) + pts; else ts = WritableUtils.readVLong(in); } readValue(in, value); count++; if (changed && rowCmp >= 0) { if (rowCmp > 0) break; if (cfCmp >= 0) { if (cfCmp > 0) break; if (cqCmp >= 0) break; } } } if (count > 1) { MutableByteSequence trow, tcf, tcq, tcv; long tts; trow = (fieldsSame & ROW_SAME) == ROW_SAME ? row : prow; tcf = (fieldsSame & CF_SAME) == CF_SAME ? cf : pcf; tcq = (fieldsSame & CQ_SAME) == CQ_SAME ? cq : pcq; tcv = (fieldsSame & CV_SAME) == CV_SAME ? cv : pcv; tts = (fieldsSame & TS_SAME) == TS_SAME ? ts : pts; newPrevKey = new Key(trow.getBackingArray(), trow.offset(), trow.length(), tcf.getBackingArray(), tcf.offset(), tcf.length(), tcq.getBackingArray(), tcq.offset(), tcq.length(), tcv.getBackingArray(), tcv.offset(), tcv.length(), tts); newPrevKey.setDeleted(pdel); } else if (count == 1) { if (currKey != null) newPrevKey = currKey; else newPrevKey = prevKey; } else { throw new IllegalStateException(); } RelativeKey result = new RelativeKey(); result.key = new Key(row.getBackingArray(), row.offset(), row.length(), cf.getBackingArray(), cf.offset(), cf.length(), cq.getBackingArray(), cq.offset(), cq.length(), cv.getBackingArray(), cv.offset(), cv.length(), ts); result.key.setDeleted((fieldsSame & DELETED) != 0); result.prevKey = result.key; return new SkippR(result, count, newPrevKey); } }
RelativeKey implements Writable { public static SkippR fastSkip(DataInput in, Key seekKey, MutableByteSequence value, Key prevKey, Key currKey, int entriesLeft) throws IOException { MutableByteSequence row, cf, cq, cv; MutableByteSequence prow, pcf, pcq, pcv; ByteSequence stopRow = seekKey.getRowData(); ByteSequence stopCF = seekKey.getColumnFamilyData(); ByteSequence stopCQ = seekKey.getColumnQualifierData(); long ts = -1; long pts = -1; boolean pdel = false; int rowCmp = -1, cfCmp = -1, cqCmp = -1; if (currKey != null) { prow = new MutableByteSequence(currKey.getRowData()); pcf = new MutableByteSequence(currKey.getColumnFamilyData()); pcq = new MutableByteSequence(currKey.getColumnQualifierData()); pcv = new MutableByteSequence(currKey.getColumnVisibilityData()); pts = currKey.getTimestamp(); row = new MutableByteSequence(currKey.getRowData()); cf = new MutableByteSequence(currKey.getColumnFamilyData()); cq = new MutableByteSequence(currKey.getColumnQualifierData()); cv = new MutableByteSequence(currKey.getColumnVisibilityData()); ts = currKey.getTimestamp(); rowCmp = row.compareTo(stopRow); cfCmp = cf.compareTo(stopCF); cqCmp = cq.compareTo(stopCQ); if (rowCmp >= 0) { if (rowCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cfCmp >= 0) { if (cfCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cqCmp >= 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } } } } else { row = new MutableByteSequence(new byte[64], 0, 0); cf = new MutableByteSequence(new byte[64], 0, 0); cq = new MutableByteSequence(new byte[64], 0, 0); cv = new MutableByteSequence(new byte[64], 0, 0); prow = new MutableByteSequence(new byte[64], 0, 0); pcf = new MutableByteSequence(new byte[64], 0, 0); pcq = new MutableByteSequence(new byte[64], 0, 0); pcv = new MutableByteSequence(new byte[64], 0, 0); } byte fieldsSame = -1; byte fieldsPrefixed = 0; int count = 0; Key newPrevKey = null; while (count < entriesLeft) { pdel = (fieldsSame & DELETED) == DELETED; fieldsSame = in.readByte(); if ((fieldsSame & PREFIX_COMPRESSION_ENABLED) == PREFIX_COMPRESSION_ENABLED) fieldsPrefixed = in.readByte(); else fieldsPrefixed = 0; boolean changed = false; if ((fieldsSame & ROW_SAME) != ROW_SAME) { MutableByteSequence tmp = prow; prow = row; row = tmp; if ((fieldsPrefixed & ROW_COMMON_PREFIX) == ROW_COMMON_PREFIX) readPrefix(in, row, prow); else read(in, row); rowCmp = row.compareTo(stopRow); changed = true; } if ((fieldsSame & CF_SAME) != CF_SAME) { MutableByteSequence tmp = pcf; pcf = cf; cf = tmp; if ((fieldsPrefixed & CF_COMMON_PREFIX) == CF_COMMON_PREFIX) readPrefix(in, cf, pcf); else read(in, cf); cfCmp = cf.compareTo(stopCF); changed = true; } if ((fieldsSame & CQ_SAME) != CQ_SAME) { MutableByteSequence tmp = pcq; pcq = cq; cq = tmp; if ((fieldsPrefixed & CQ_COMMON_PREFIX) == CQ_COMMON_PREFIX) readPrefix(in, cq, pcq); else read(in, cq); cqCmp = cq.compareTo(stopCQ); changed = true; } if ((fieldsSame & CV_SAME) != CV_SAME) { MutableByteSequence tmp = pcv; pcv = cv; cv = tmp; if ((fieldsPrefixed & CV_COMMON_PREFIX) == CV_COMMON_PREFIX) readPrefix(in, cv, pcv); else read(in, cv); } if ((fieldsSame & TS_SAME) != TS_SAME) { pts = ts; if ((fieldsPrefixed & TS_DIFF) == TS_DIFF) ts = WritableUtils.readVLong(in) + pts; else ts = WritableUtils.readVLong(in); } readValue(in, value); count++; if (changed && rowCmp >= 0) { if (rowCmp > 0) break; if (cfCmp >= 0) { if (cfCmp > 0) break; if (cqCmp >= 0) break; } } } if (count > 1) { MutableByteSequence trow, tcf, tcq, tcv; long tts; trow = (fieldsSame & ROW_SAME) == ROW_SAME ? row : prow; tcf = (fieldsSame & CF_SAME) == CF_SAME ? cf : pcf; tcq = (fieldsSame & CQ_SAME) == CQ_SAME ? cq : pcq; tcv = (fieldsSame & CV_SAME) == CV_SAME ? cv : pcv; tts = (fieldsSame & TS_SAME) == TS_SAME ? ts : pts; newPrevKey = new Key(trow.getBackingArray(), trow.offset(), trow.length(), tcf.getBackingArray(), tcf.offset(), tcf.length(), tcq.getBackingArray(), tcq.offset(), tcq.length(), tcv.getBackingArray(), tcv.offset(), tcv.length(), tts); newPrevKey.setDeleted(pdel); } else if (count == 1) { if (currKey != null) newPrevKey = currKey; else newPrevKey = prevKey; } else { throw new IllegalStateException(); } RelativeKey result = new RelativeKey(); result.key = new Key(row.getBackingArray(), row.offset(), row.length(), cf.getBackingArray(), cf.offset(), cf.length(), cq.getBackingArray(), cq.offset(), cq.length(), cv.getBackingArray(), cv.offset(), cv.length(), ts); result.key.setDeleted((fieldsSame & DELETED) != 0); result.prevKey = result.key; return new SkippR(result, count, newPrevKey); } RelativeKey();  RelativeKey(Key prevKey, Key key); }
RelativeKey implements Writable { public static SkippR fastSkip(DataInput in, Key seekKey, MutableByteSequence value, Key prevKey, Key currKey, int entriesLeft) throws IOException { MutableByteSequence row, cf, cq, cv; MutableByteSequence prow, pcf, pcq, pcv; ByteSequence stopRow = seekKey.getRowData(); ByteSequence stopCF = seekKey.getColumnFamilyData(); ByteSequence stopCQ = seekKey.getColumnQualifierData(); long ts = -1; long pts = -1; boolean pdel = false; int rowCmp = -1, cfCmp = -1, cqCmp = -1; if (currKey != null) { prow = new MutableByteSequence(currKey.getRowData()); pcf = new MutableByteSequence(currKey.getColumnFamilyData()); pcq = new MutableByteSequence(currKey.getColumnQualifierData()); pcv = new MutableByteSequence(currKey.getColumnVisibilityData()); pts = currKey.getTimestamp(); row = new MutableByteSequence(currKey.getRowData()); cf = new MutableByteSequence(currKey.getColumnFamilyData()); cq = new MutableByteSequence(currKey.getColumnQualifierData()); cv = new MutableByteSequence(currKey.getColumnVisibilityData()); ts = currKey.getTimestamp(); rowCmp = row.compareTo(stopRow); cfCmp = cf.compareTo(stopCF); cqCmp = cq.compareTo(stopCQ); if (rowCmp >= 0) { if (rowCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cfCmp >= 0) { if (cfCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cqCmp >= 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } } } } else { row = new MutableByteSequence(new byte[64], 0, 0); cf = new MutableByteSequence(new byte[64], 0, 0); cq = new MutableByteSequence(new byte[64], 0, 0); cv = new MutableByteSequence(new byte[64], 0, 0); prow = new MutableByteSequence(new byte[64], 0, 0); pcf = new MutableByteSequence(new byte[64], 0, 0); pcq = new MutableByteSequence(new byte[64], 0, 0); pcv = new MutableByteSequence(new byte[64], 0, 0); } byte fieldsSame = -1; byte fieldsPrefixed = 0; int count = 0; Key newPrevKey = null; while (count < entriesLeft) { pdel = (fieldsSame & DELETED) == DELETED; fieldsSame = in.readByte(); if ((fieldsSame & PREFIX_COMPRESSION_ENABLED) == PREFIX_COMPRESSION_ENABLED) fieldsPrefixed = in.readByte(); else fieldsPrefixed = 0; boolean changed = false; if ((fieldsSame & ROW_SAME) != ROW_SAME) { MutableByteSequence tmp = prow; prow = row; row = tmp; if ((fieldsPrefixed & ROW_COMMON_PREFIX) == ROW_COMMON_PREFIX) readPrefix(in, row, prow); else read(in, row); rowCmp = row.compareTo(stopRow); changed = true; } if ((fieldsSame & CF_SAME) != CF_SAME) { MutableByteSequence tmp = pcf; pcf = cf; cf = tmp; if ((fieldsPrefixed & CF_COMMON_PREFIX) == CF_COMMON_PREFIX) readPrefix(in, cf, pcf); else read(in, cf); cfCmp = cf.compareTo(stopCF); changed = true; } if ((fieldsSame & CQ_SAME) != CQ_SAME) { MutableByteSequence tmp = pcq; pcq = cq; cq = tmp; if ((fieldsPrefixed & CQ_COMMON_PREFIX) == CQ_COMMON_PREFIX) readPrefix(in, cq, pcq); else read(in, cq); cqCmp = cq.compareTo(stopCQ); changed = true; } if ((fieldsSame & CV_SAME) != CV_SAME) { MutableByteSequence tmp = pcv; pcv = cv; cv = tmp; if ((fieldsPrefixed & CV_COMMON_PREFIX) == CV_COMMON_PREFIX) readPrefix(in, cv, pcv); else read(in, cv); } if ((fieldsSame & TS_SAME) != TS_SAME) { pts = ts; if ((fieldsPrefixed & TS_DIFF) == TS_DIFF) ts = WritableUtils.readVLong(in) + pts; else ts = WritableUtils.readVLong(in); } readValue(in, value); count++; if (changed && rowCmp >= 0) { if (rowCmp > 0) break; if (cfCmp >= 0) { if (cfCmp > 0) break; if (cqCmp >= 0) break; } } } if (count > 1) { MutableByteSequence trow, tcf, tcq, tcv; long tts; trow = (fieldsSame & ROW_SAME) == ROW_SAME ? row : prow; tcf = (fieldsSame & CF_SAME) == CF_SAME ? cf : pcf; tcq = (fieldsSame & CQ_SAME) == CQ_SAME ? cq : pcq; tcv = (fieldsSame & CV_SAME) == CV_SAME ? cv : pcv; tts = (fieldsSame & TS_SAME) == TS_SAME ? ts : pts; newPrevKey = new Key(trow.getBackingArray(), trow.offset(), trow.length(), tcf.getBackingArray(), tcf.offset(), tcf.length(), tcq.getBackingArray(), tcq.offset(), tcq.length(), tcv.getBackingArray(), tcv.offset(), tcv.length(), tts); newPrevKey.setDeleted(pdel); } else if (count == 1) { if (currKey != null) newPrevKey = currKey; else newPrevKey = prevKey; } else { throw new IllegalStateException(); } RelativeKey result = new RelativeKey(); result.key = new Key(row.getBackingArray(), row.offset(), row.length(), cf.getBackingArray(), cf.offset(), cf.length(), cq.getBackingArray(), cq.offset(), cq.length(), cv.getBackingArray(), cv.offset(), cv.length(), ts); result.key.setDeleted((fieldsSame & DELETED) != 0); result.prevKey = result.key; return new SkippR(result, count, newPrevKey); } RelativeKey();  RelativeKey(Key prevKey, Key key); void setPrevKey(Key pk); @Override void readFields(DataInput in); static SkippR fastSkip(DataInput in, Key seekKey, MutableByteSequence value, Key prevKey,
      Key currKey, int entriesLeft); Key getKey(); @Override void write(DataOutput out); }
RelativeKey implements Writable { public static SkippR fastSkip(DataInput in, Key seekKey, MutableByteSequence value, Key prevKey, Key currKey, int entriesLeft) throws IOException { MutableByteSequence row, cf, cq, cv; MutableByteSequence prow, pcf, pcq, pcv; ByteSequence stopRow = seekKey.getRowData(); ByteSequence stopCF = seekKey.getColumnFamilyData(); ByteSequence stopCQ = seekKey.getColumnQualifierData(); long ts = -1; long pts = -1; boolean pdel = false; int rowCmp = -1, cfCmp = -1, cqCmp = -1; if (currKey != null) { prow = new MutableByteSequence(currKey.getRowData()); pcf = new MutableByteSequence(currKey.getColumnFamilyData()); pcq = new MutableByteSequence(currKey.getColumnQualifierData()); pcv = new MutableByteSequence(currKey.getColumnVisibilityData()); pts = currKey.getTimestamp(); row = new MutableByteSequence(currKey.getRowData()); cf = new MutableByteSequence(currKey.getColumnFamilyData()); cq = new MutableByteSequence(currKey.getColumnQualifierData()); cv = new MutableByteSequence(currKey.getColumnVisibilityData()); ts = currKey.getTimestamp(); rowCmp = row.compareTo(stopRow); cfCmp = cf.compareTo(stopCF); cqCmp = cq.compareTo(stopCQ); if (rowCmp >= 0) { if (rowCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cfCmp >= 0) { if (cfCmp > 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } if (cqCmp >= 0) { RelativeKey rk = new RelativeKey(); rk.key = rk.prevKey = new Key(currKey); return new SkippR(rk, 0, prevKey); } } } } else { row = new MutableByteSequence(new byte[64], 0, 0); cf = new MutableByteSequence(new byte[64], 0, 0); cq = new MutableByteSequence(new byte[64], 0, 0); cv = new MutableByteSequence(new byte[64], 0, 0); prow = new MutableByteSequence(new byte[64], 0, 0); pcf = new MutableByteSequence(new byte[64], 0, 0); pcq = new MutableByteSequence(new byte[64], 0, 0); pcv = new MutableByteSequence(new byte[64], 0, 0); } byte fieldsSame = -1; byte fieldsPrefixed = 0; int count = 0; Key newPrevKey = null; while (count < entriesLeft) { pdel = (fieldsSame & DELETED) == DELETED; fieldsSame = in.readByte(); if ((fieldsSame & PREFIX_COMPRESSION_ENABLED) == PREFIX_COMPRESSION_ENABLED) fieldsPrefixed = in.readByte(); else fieldsPrefixed = 0; boolean changed = false; if ((fieldsSame & ROW_SAME) != ROW_SAME) { MutableByteSequence tmp = prow; prow = row; row = tmp; if ((fieldsPrefixed & ROW_COMMON_PREFIX) == ROW_COMMON_PREFIX) readPrefix(in, row, prow); else read(in, row); rowCmp = row.compareTo(stopRow); changed = true; } if ((fieldsSame & CF_SAME) != CF_SAME) { MutableByteSequence tmp = pcf; pcf = cf; cf = tmp; if ((fieldsPrefixed & CF_COMMON_PREFIX) == CF_COMMON_PREFIX) readPrefix(in, cf, pcf); else read(in, cf); cfCmp = cf.compareTo(stopCF); changed = true; } if ((fieldsSame & CQ_SAME) != CQ_SAME) { MutableByteSequence tmp = pcq; pcq = cq; cq = tmp; if ((fieldsPrefixed & CQ_COMMON_PREFIX) == CQ_COMMON_PREFIX) readPrefix(in, cq, pcq); else read(in, cq); cqCmp = cq.compareTo(stopCQ); changed = true; } if ((fieldsSame & CV_SAME) != CV_SAME) { MutableByteSequence tmp = pcv; pcv = cv; cv = tmp; if ((fieldsPrefixed & CV_COMMON_PREFIX) == CV_COMMON_PREFIX) readPrefix(in, cv, pcv); else read(in, cv); } if ((fieldsSame & TS_SAME) != TS_SAME) { pts = ts; if ((fieldsPrefixed & TS_DIFF) == TS_DIFF) ts = WritableUtils.readVLong(in) + pts; else ts = WritableUtils.readVLong(in); } readValue(in, value); count++; if (changed && rowCmp >= 0) { if (rowCmp > 0) break; if (cfCmp >= 0) { if (cfCmp > 0) break; if (cqCmp >= 0) break; } } } if (count > 1) { MutableByteSequence trow, tcf, tcq, tcv; long tts; trow = (fieldsSame & ROW_SAME) == ROW_SAME ? row : prow; tcf = (fieldsSame & CF_SAME) == CF_SAME ? cf : pcf; tcq = (fieldsSame & CQ_SAME) == CQ_SAME ? cq : pcq; tcv = (fieldsSame & CV_SAME) == CV_SAME ? cv : pcv; tts = (fieldsSame & TS_SAME) == TS_SAME ? ts : pts; newPrevKey = new Key(trow.getBackingArray(), trow.offset(), trow.length(), tcf.getBackingArray(), tcf.offset(), tcf.length(), tcq.getBackingArray(), tcq.offset(), tcq.length(), tcv.getBackingArray(), tcv.offset(), tcv.length(), tts); newPrevKey.setDeleted(pdel); } else if (count == 1) { if (currKey != null) newPrevKey = currKey; else newPrevKey = prevKey; } else { throw new IllegalStateException(); } RelativeKey result = new RelativeKey(); result.key = new Key(row.getBackingArray(), row.offset(), row.length(), cf.getBackingArray(), cf.offset(), cf.length(), cq.getBackingArray(), cq.offset(), cq.length(), cv.getBackingArray(), cv.offset(), cv.length(), ts); result.key.setDeleted((fieldsSame & DELETED) != 0); result.prevKey = result.key; return new SkippR(result, count, newPrevKey); } RelativeKey();  RelativeKey(Key prevKey, Key key); void setPrevKey(Key pk); @Override void readFields(DataInput in); static SkippR fastSkip(DataInput in, Key seekKey, MutableByteSequence value, Key prevKey,
      Key currKey, int entriesLeft); Key getKey(); @Override void write(DataOutput out);  }