分享

hbase源码Get、Scan在服务端是如何处理?

本帖最后由 pig2 于 2014-10-18 00:44 编辑
问题导读
1、如何理解Scan的扫描流程?

2、Scan的参数有哪些?

3、怎样通过列族获得相应的Store?




Get
我们打开HRegionServer找到get方法。Get的方法处理分两种,设置了ClosestRowBefore和没有设置的,一般来讲,我们都是知道了明确的rowkey,不太会设置这个参数,它默认是false的。

  1. if (get.hasClosestRowBefore() && get.getClosestRowBefore()) {
  2.     byte[] row = get.getRow().toByteArray();
  3.     byte[] family = get.getColumn(0).getFamily().toByteArray();
  4.     r = region.getClosestRowBefore(row, family);
  5. } else {
  6.    Get clientGet = ProtobufUtil.toGet(get);
  7.    if (existence == null) {
  8.       r = region.get(clientGet);
  9.    }
  10. }   
复制代码

所以我们走的是HRegion的get方法,杀过去。
  1. public Result get(final Get get) throws IOException {
  2.     checkRow(get.getRow(), "Get");
  3.     // 检查列族,以下省略代码一百字
  4.     List<Cell> results = get(get, true);
  5.     return Result.create(results, get.isCheckExistenceOnly() ? !results.isEmpty() : null);
  6. }
复制代码


先检查get的row是否在这个region里面,然后检查列族,如果没有的话,它会根据表定义给补全的,然后它转身又进入了另外一个get方法,真是狠心啊!
  1.     List<Cell> results = new ArrayList<Cell>();
  2.     Scan scan = new Scan(get);
  3.     RegionScanner scanner = null;
  4.     try {
  5.       scanner = getScanner(scan);
  6.       scanner.next(results);
  7.     } finally {
  8.       if (scanner != null)
  9.         scanner.close();
  10.     }
复制代码

从上面可以看得出来,为什么我要把get和Scanner一起讲了吧,因为get也是一种特殊的Scan的方法,它只寻找一个row的数据。

Scan
下面开始讲Scan,在《HTable探秘》里面有个细节不知道注意到没,在查询之前,它要先OpenScanner获得要给ScannerId,这个OpenScanner其实也调用了scan方法,但是它过去不是干活的,而是先过去注册一个Scanner,订个租约,然后再把这个返回的ScannerId再次发送一个scan请求,这次才开始调用开始扫描。

扫描的时候,走的是这一段
  1.       if (!done) {
  2.               long maxResultSize = scanner.getMaxResultSize();
  3.               if (maxResultSize <= 0) {
  4.                 maxResultSize = maxScannerResultSize;
  5.               }
  6.               List<Cell> values = new ArrayList<Cell>();
  7.               MultiVersionConsistencyControl.setThreadReadPoint(scanner.getMvccReadPoint());
  8.               region.startRegionOperation(Operation.SCAN);
  9.               try {
  10.                 int i = 0;
  11.                 synchronized(scanner) {
  12.                   for (; i < rows && currentScanResultSize < maxResultSize; i++) {
  13.                     // 它用的是这个nextRaw方法
  14.                     boolean moreRows = scanner.nextRaw(values);
  15.                     if (!values.isEmpty()) {
  16.                        results.add(Result.create(values));
  17.                     }
  18.                     if (!moreRows) {
  19.                       break;
  20.                     }
  21.                     values.clear();
  22.                   }
  23.                 }
  24.               } finally {
  25.                 region.closeRegionOperation();
  26.               }
  27.             }
  28.             // 没找到设置moreResults为false,找到了把结果添加到builder里面去
  29.             if (scanner.isFilterDone() && results.isEmpty()) {
  30.               moreResults = false;
  31.               results = null;
  32.             } else {
  33.               addResults(builder, results, controller);
  34.             }
  35.           }
  36.         }
复制代码

这里面有controller和result,这块的话,我求证了一下RpcServer那块,如果Rpc传输的时候使用了codec来压缩的话,就用controller返回结果,否则用response返回。
这块就不管了不是重点,下面我们看一下RegionScanner。

RegionScanner详解与代码拆分
我们冲过去看RegionScannerImpl吧,它在HRegion里面,我们直接去看nextRaw方法就可以了,get方法的那个next方法也是调用了nextRaw方法。
  1. if (outResults.isEmpty()) {
  2.      // 把结果存到outResults当中
  3.         returnResult = nextInternal(outResults, limit);
  4. } else {
  5.         List<Cell> tmpList = new ArrayList<Cell>();
  6.         returnResult = nextInternal(tmpList, limit);
  7.         outResults.addAll(tmpList);
  8. }
复制代码

去nextInternal方法吧,这方法真大,尼玛,我要歇菜了,我们进入下一个阶段吧。
  1. /**  把查询出来的结果保存到results当中  */
  2.     private boolean nextInternal(List<Cell> results, int limit)
  3.     throws IOException {
  4.       while (true) {
  5.         //从storeHeap里面取出一个来
  6.         KeyValue current = this.storeHeap.peek();
  7.         byte[] currentRow = null;
  8.         int offset = 0;
  9.         short length = 0;
  10.         if (current != null) {
  11.           currentRow = current.getBuffer();
  12.           offset = current.getRowOffset();
  13.           length = current.getRowLength();
  14.         }
  15.         //检查一下到这个row是否应该停止了
  16.         boolean stopRow = isStopRow(currentRow, offset, length);
  17.         if (joinedContinuationRow == null) {
  18.           // 如果要停止了,就用filter的filterRowCells过滤一下results.
  19.           if (stopRow) {
  20.             if (filter != null && filter.hasFilterRow()) {
  21.               //使用filter过滤掉一些cells
  22.               filter.filterRowCells(results);
  23.             }
  24.             return false;
  25.           }
  26.           // 如果有filter的话,过滤通过
  27.           if (filterRowKey(currentRow, offset, length)) {
  28.             boolean moreRows = nextRow(currentRow, offset, length);
  29.             if (!moreRows) return false;
  30.             results.clear();
  31.             continue;
  32.           }
  33.           //把结果保存到results当中
  34.           KeyValue nextKv = populateResult(results, this.storeHeap, limit, currentRow, offset,
  35.               length);
  36.           // Ok, we are good, let's try to get some results from the main heap.
  37.           // 在populateResult找到了足够limit数量的
  38.           if (nextKv == KV_LIMIT) {
  39.             if (this.filter != null && filter.hasFilterRow()) {
  40.               throw new IncompatibleFilterException(
  41.                 "Filter whose hasFilterRow() returns true is incompatible with scan with limit!");
  42.             }
  43.             return true; // We hit the limit.
  44.           }
  45.           stopRow = nextKv == null ||
  46.               isStopRow(nextKv.getBuffer(), nextKv.getRowOffset(), nextKv.getRowLength());
  47.           // save that the row was empty before filters applied to it.
  48.           final boolean isEmptyRow = results.isEmpty();
  49.           // We have the part of the row necessary for filtering (all of it, usually).
  50.           // First filter with the filterRow(List). 过滤一下刚才找出来的
  51.           if (filter != null && filter.hasFilterRow()) {
  52.             filter.filterRowCells(results);
  53.           }
  54.           //如果result的空的,啥也没找到,这是。。。悲剧啊
  55.           if (isEmptyRow) {
  56.             boolean moreRows = nextRow(currentRow, offset, length);
  57.             if (!moreRows) return false;
  58.             results.clear();
  59.             // This row was totally filtered out, if this is NOT the last row,
  60.             // we should continue on. Otherwise, nothing else to do.
  61.             if (!stopRow) continue;
  62.             return false;
  63.           }
  64.           // Ok, we are done with storeHeap for this row.
  65.           // Now we may need to fetch additional, non-essential data into row.
  66.           // These values are not needed for filter to work, so we postpone their
  67.           // fetch to (possibly) reduce amount of data loads from disk.
  68.           if (this.joinedHeap != null) {
  69.             KeyValue nextJoinedKv = joinedHeap.peek();
  70.             // If joinedHeap is pointing to some other row, try to seek to a correct one.
  71.             boolean mayHaveData =
  72.               (nextJoinedKv != null && nextJoinedKv.matchingRow(currentRow, offset, length))
  73.               || (this.joinedHeap.requestSeek(KeyValue.createFirstOnRow(currentRow, offset, length),
  74.                 true, true)
  75.                 && joinedHeap.peek() != null
  76.                 && joinedHeap.peek().matchingRow(currentRow, offset, length));
  77.             if (mayHaveData) {
  78.               joinedContinuationRow = current;
  79.               populateFromJoinedHeap(results, limit);
  80.             }
  81.           }
  82.         } else {
  83.           // Populating from the joined heap was stopped by limits, populate some more.
  84.           populateFromJoinedHeap(results, limit);
  85.         }
  86.         // We may have just called populateFromJoinedMap and hit the limits. If that is
  87.         // the case, we need to call it again on the next next() invocation.
  88.         if (joinedContinuationRow != null) {
  89.           return true;
  90.         }
  91.         // Finally, we are done with both joinedHeap and storeHeap.
  92.         // Double check to prevent empty rows from appearing in result. It could be
  93.         // the case when SingleColumnValueExcludeFilter is used.
  94.         if (results.isEmpty()) {
  95.           boolean moreRows = nextRow(currentRow, offset, length);
  96.           if (!moreRows) return false;
  97.           if (!stopRow) continue;
  98.         }
  99.         // We are done. Return the result.
  100.         return !stopRow;
  101.       }
  102.     }
复制代码


上面那段代码真的很长很臭,尼玛。。被我折叠起来了,有兴趣的看一眼就行,我们先分解开来看吧,这里面有两个Heap,一个是storeHeap,一个是JoinedHeap,他们啥时候用呢?看一下它的构造方法吧
  1. for (Map.Entry<byte[], NavigableSet<byte[]>> entry :
  2.           scan.getFamilyMap().entrySet()) {
  3.         //遍历列族和列的映射关系,设置store相关的内容
  4.         Store store = stores.get(entry.getKey());
  5.         KeyValueScanner scanner = store.getScanner(scan, entry.getValue());
  6.         if (this.filter == null || !scan.doLoadColumnFamiliesOnDemand()
  7.           || this.filter.isFamilyEssential(entry.getKey())) {
  8.           scanners.add(scanner);
  9.         } else {
  10.           joinedScanners.add(scanner);
  11.         }
  12.       }
  13.       this.storeHeap = new KeyValueHeap(scanners, comparator);
  14.       if (!joinedScanners.isEmpty()) {
  15.         this.joinedHeap = new KeyValueHeap(joinedScanners, comparator);
  16.       }
  17. }
复制代码

如果joinedScanners不空的话,就new一个joinedHeap出来,但是我们看看它的成立条件,有点儿难吧。

1、filter不为null

2、scan设置了doLoadColumnFamiliesOnDemand为true

3、设置了的filter的isFamilyEssential方法返回false,这个估计得自己写一个,因为我刚才去看了几个filter的这个方法默认都是用的FilterBase的方法返回false。

好的,到这里我们有可以把上面那段代码砍掉很大一部分了,它的成立条件比较困难,所以很难出现了,那我们就挑重点的storeHeap来讲吧,我们先看着这三行。
  1. Store store = stores.get(entry.getKey());
  2. KeyValueScanner scanner = store.getScanner(scan, entry.getValue());
  3. this.storeHeap = new KeyValueHeap(scanners, comparator);
复制代码

通过列族获得相应的Store,然后通过getScanner返回scanner加到KeyValueHeap当中,我们应该去刺探一下HStore的getScanner方法,它new了一个StoreScanner返回,继续看StoreScanner。
  1. public StoreScanner(Store store, ScanInfo scanInfo, Scan scan, final NavigableSet<byte[]> columns) throws IOException {
  2.     matcher = new ScanQueryMatcher(scan, scanInfo, columns,
  3.         ScanType.USER_SCAN, Long.MAX_VALUE, HConstants.LATEST_TIMESTAMP,
  4.         oldestUnexpiredTS);
  5.     // 返回MemStore、所有StoreFile的Scanner.
  6.     List<KeyValueScanner> scanners = getScannersNoCompaction();
  7.     //explicitColumnQuery:是否过滤列族 lazySeekEnabledGlobally默认是true 如果文件数量超过1个,isParallelSeekEnabled就是true
  8.     if (explicitColumnQuery && lazySeekEnabledGlobally) {
  9.       for (KeyValueScanner scanner : scanners) {
  10.         scanner.requestSeek(matcher.getStartKey(), false, true);
  11.       }
  12.     } else {
  13.       if (!isParallelSeekEnabled) {
  14.         for (KeyValueScanner scanner : scanners) {
  15.           scanner.seek(matcher.getStartKey());
  16.         }
  17.       } else {
  18.      //一般走这里,并行查
  19.         parallelSeek(scanners, matcher.getStartKey());
  20.       }
  21.     }
  22.     // 一个堆里面包括了两个scanner,MemStore、StoreFile的Scanner
  23.     heap = new KeyValueHeap(scanners, store.getComparator());
  24.     this.store.addChangedReaderObserver(this);
  25.   }
复制代码


对上面的代码,我们再慢慢来分解。

1、先new了一个ScanQueryMatcher,它是一个用来过滤的类,传参数的时候,需要传递scan和oldestUnexpiredTS进去,oldestUnexpiredTS是个参数,是(当前时间-列族的生存周期),小于这个时间戳的kv视为已经过期了,在它初始化的时候,我们注意一下它的startKey和stopRow,这个startKey要注意,它可不是我们设置的那个startRow,而是用这个startRow来new了一个DeleteFamily类型的KeyValue。
  1. this.stopRow = scan.getStopRow();
  2. this.startKey = KeyValue.createFirstDeleteFamilyOnRow(scan.getStartRow())
复制代码

2、接着我们看getScannersNoCompaction这个方法,它这里是返回了两个Scanner,MemStoreScanner和所有StoreFile的Scanner,在从StoreHeap中peak出来一个kv的时候,是从他们当中交替取出kv来的,StoreHeap从它的名字上面来看像是用了堆排序的算法,它的peek方法和next方法真有点儿复杂,下一章讲MemStore的时候再讲吧。
  1. //获取所有的storefile,默认的实现没有用上startRow和stopRow
  2. storeFilesToScan = this.storeEngine.getStoreFileManager().getFilesForScanOrGet(isGet, startRow, stopRow);
  3. memStoreScanners = this.memstore.getScanners();
复制代码

默认的getStoreFileManager的getFilesForScanOrGet是返回了所有的StoreFile的Scanner,而不是通过startRow和stopRow做过滤,它的注释里面给出的解释,里面的files默认是按照seq id来排序的,而不是startKey,需要优化的可以从这里下手。

3、然后就开始先seek一下,而不是全表扫啊!
  1. //过滤列族的情况
  2. scanner.requestSeek(matcher.getStartKey(), false, true);
  3. //一般走这里,并行查
  4. parallelSeek(scanners, matcher.getStartKey());
复制代码

scanner.requestSeek不是所有情况都要seek,是查询Delete的时候,如果查询的kv的时间戳比文件的最大时间戳小,就seek到上次未查询到的kv;它这里可能会用上DeleteFamily删除真个family这种情况。

parallelSeek就是开多线程去调用Scanner的seek方法, MemStore的seek很简单,因为它的kv集合是一个排序好的集合,HFile的seek比较复杂,下面我用一个图来表达吧。
1.png
在搜索HFile的时候,key先从一级索引找,通过它定位到细的二级索引,然后再定位到具体的block上面,到了HFileBlock之后,就不是seek了,就是遍历,遍历没什么好说的,不熟悉的朋友建议先回去看看《StoreFile存储格式》。注意哦,这个key就是我们的startKey哦,所以大家知道为什么要在scan的时候要设置StartKey了吗?

nextInternal的流程
通过前面的分析,我们可以把nextInternal分解与拆分、抹去一些不必要的代码,我发现代码还是很难懂,所以我画了一个过程图出来代替那段代码。
1.png




特别注意事项:
1、这个图是被我处理过的简化之后的图,还有在放弃该row的kv们 之后并非都要进行是StopRow的判断,只是为了合并这个流程,我加上去的isStopRow的判断,但并不影响整个流程。

2、!isStopRow代表返回代码的(!isStopRow)的意思, 根据isStopRow的当前值来返回true或者false

3、true意味着退出,并且还有结果,false意味着退出,没有结果

诶,看到这里,还是没看到它是怎么用ScanQueryMatcher去过滤被删除的kv们啊,好,接下来我们重点考察这个问题。

ScanQueryMatcher如何过滤已经被删除的KeyValue
这个过程屏蔽在了filterRow之后通过的把该row的kv接到结果集的这一步里面去了。它在里面不停的调用KeyValueHeap的next方法,match的调用正好在这个方法。我们现在就去追踪这遗失的部分。

我们直接去看它的match方法就好了,别的不用看了,它处理的情况好多好多,尼玛,这是要死人的节奏啊。

ScanQueryMatcher是用来处理一行数据之间的版本问题的,在每遇到一个新的row的时候,它都会先被设置matcher.setRow(row, offset, length)。
  1. if (limit < 0 || matcher.row == null || !Bytes.equals(row, offset, length, matcher.row,
  2.       matcher.rowOffset, matcher.rowLength)) {
  3.       this.countPerRow = 0;
  4.       matcher.setRow(row, offset, length);
  5. }
复制代码

上面这段代码在StoreScanner的next方法里面,每当一行结束之后,都会调用这个方法。

在讲match方法之前,我先讲一下rowkey的排序规则,rowkey 正序->family 正序->qualifier 正序->ts 降序->type 降序,那么对于同一个行、列族、列的数据,时间越近的排在前面,类型越大的排在前面,比如Delete就在Put前面,下面是它的类型表。
  1. //search用
  2. Minimum((byte)0),
  3. Put((byte)4),
  4. Delete((byte)8),
  5. DeleteFamilyVersion((byte)10),
  6. DeleteColumn((byte)12),
  7. DeleteFamily((byte)14),
  8. //search用
  9. Maximum((byte)255);
复制代码

为什么这里先KeyValue的排序规则呢,这当然有关系了,这关系着扫描的时候,谁先谁后的问题,如果时间戳小的在前面,下面这个过滤就不生效了。

下面我们看看它的match方法的检查规则。

1、和当前行比较
  1. //和当前的行进行比较,只有相等才继续,大于当前的行就要跳到下一行,小于说明有问题,停止
  2. int ret = this.rowComparator.compareRows(row, this.rowOffset, this.rowLength,
  3.         bytes, offset, rowLength);
  4. if (ret <= -1) {
  5.       return MatchCode.DONE;
  6. } else if (ret >= 1) {
  7.       return MatchCode.SEEK_NEXT_ROW;
  8. }
复制代码

2、检查是否所有列都查过了
  1. //所有的列都扫描过来
  2. if (this.columns.done()) {
  3.       stickyNextRow = true;
  4.       return MatchCode.SEEK_NEXT_ROW;
  5. }
复制代码

3、检查列的时间戳是否过期
  1. long timestamp = kv.getTimestamp();
  2. // 检查列的时间是否过期
  3. if (columns.isDone(timestamp)) {
  4.     return columns.getNextRowOrNextColumn(bytes, offset, qualLength);
  5. }
复制代码

4a、如果是Delete的类型,加到ScanDeleteTraker。
  1. if (kv.isDelete()) {
  2.     this.deletes.add(bytes, offset, qualLength, timestamp, type);
  3. }
复制代码

4b、如果不是,如果ScanDeleteTraker里面有Delete,就要让它经历ScanDeleteTraker的检验了(进宫前先验一下身)
  1. DeleteResult deleteResult = deletes.isDeleted(bytes, offset, qualLength,
  2.           timestamp);
  3.       switch (deleteResult) {
  4.         case FAMILY_DELETED:
  5.         case COLUMN_DELETED:
  6.           return columns.getNextRowOrNextColumn(bytes, offset, qualLength);
  7.         case VERSION_DELETED:
  8.         case FAMILY_VERSION_DELETED:
  9.           return MatchCode.SKIP;
  10.         case NOT_DELETED:
  11.           break;
  12.         default:
  13.           throw new RuntimeException("UNEXPECTED");
  14. }
复制代码

这里就要说一下刚才那几个Delete的了:

1)DeleteFamily是最凶狠的,生命周期也长,整个列族全删,基本上会一直存在

2)DeleteColum只删掉一个列,出现这个列的都会被干掉

3)DeleteFamilyVersion没遇到过

4)Delete最差劲儿了,只能删除指定时间戳的,时间戳一定要对哦,否则一旦发现不对的,这个Delete就失效了,可以说,生命周期只有一次,下面是源代码。
  1. public DeleteResult isDeleted(byte [] buffer, int qualifierOffset,
  2.       int qualifierLength, long timestamp) {
  3.     //时间戳小于删除列族的时间戳,说明这个列族被删掉是后来的事情
  4.     if (hasFamilyStamp && timestamp <= familyStamp) {
  5.       return DeleteResult.FAMILY_DELETED;
  6.     }
  7.     //检查时间戳
  8.     if (familyVersionStamps.contains(Long.valueOf(timestamp))) {
  9.         return DeleteResult.FAMILY_VERSION_DELETED;
  10.     }
  11.     if (deleteBuffer != null) {
  12.       int ret = Bytes.compareTo(deleteBuffer, deleteOffset, deleteLength,
  13.           buffer, qualifierOffset, qualifierLength);
  14.       if (ret == 0) {
  15.         if (deleteType == KeyValue.Type.DeleteColumn.getCode()) {
  16.           return DeleteResult.COLUMN_DELETED;
  17.         }
  18.         // 坑爹的Delete它只删除相同时间戳的,遇到不想的它就pass了
  19.         if (timestamp == deleteTimestamp) {
  20.           return DeleteResult.VERSION_DELETED;
  21.         }
  22.         //时间戳不对,这个Delete失效了
  23.         deleteBuffer = null;
  24.       } else if(ret < 0){
  25.         // row比当前的大,这个Delete也失效了
  26.         deleteBuffer = null;
  27.       } else {
  28.         throw new IllegalStateException(...);
  29.       }
  30.     }
  31.     return DeleteResult.NOT_DELETED;
复制代码

上一章说过,Delete new出来之后什么都不设置,就是DeleteFamily级别的选手,所以在它之后的会全部被干掉,所以你们懂的,我们也会用DeleteColum来删除某一列数据,只要时间戳在它之前的kv就会被干掉,删某个指定版本的少,因为你得知道具体的时间戳,否则你删不了。

例子详解DeleteFamily
假设我们有这些数据
  1. KeyValue [] kvs1 = new KeyValue[] {
  2.         KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care"),
  3.         KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.DeleteFamily, "dont-care"),
  4.         KeyValueTestUtil.create("R1", "cf", "a", now-500, KeyValue.Type.Put, "dont-care"),
  5.         KeyValueTestUtil.create("R1", "cf", "a", now+500, KeyValue.Type.Put, "dont-care"),
  6.         KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care"),
  7.         KeyValueTestUtil.create("R2", "cf", "z", now, KeyValue.Type.Put, "dont-care")
  8. };
复制代码

Scan的参数是这些。
  1. Scan scanSpec = new Scan(Bytes.toBytes("R1"));
  2. scanSpec.setMaxVersions(3);
  3. scanSpec.setBatch(10);
  4. StoreScanner scan = new StoreScanner(scanSpec, scanInfo, scanType, getCols("a","z"), scanners);
复制代码


然后,我们先将他们排好序,是这样的。
  1. R1/cf:a/1400602376242(now+500)/Put/vlen=9/mvcc=0,
  2. R1/cf:a/1400602375742(now)/DeleteFamily/vlen=9/mvcc=0,
  3. R1/cf:a/1400602375742(now)/Put/vlen=9/mvcc=0,
  4. R1/cf:a/1400602375742(now)/Put/vlen=9/mvcc=0,
  5. R1/cf:a/1400602375242(now-500)/Put/vlen=9/mvcc=0,
  6. R2/cf:z/1400602375742(now)/Put/vlen=9/mvcc=0
复制代码

所以到最后,黄色的三行会被删除,只剩下第一行和最后一行,但是最后一行也会被排除掉,因为它已经换行了,不是同一个行的,不在这一轮进行比较,返回MatchCode.DONE。

---->回到前面是match过程
5、检查时间戳,即设置给Scan的时间戳,这个估计一般很少设置,时间戳过期,就返回下一个MatchCode.SEEK_NEXT_ROW。

6、检查列是否是Scan里面设置的需要查询的列。

7、检查列的版本,Scan设置的MaxVersion,超过了这个version就要赶紧闪人了哈,返回MatchCode.SEEK_NEXT_COL。

对于match的结果,有几个常见的:
1、MatchCode.INCLUDE_AND_SEEK_NEXT_COL 包括当前这个,跳到下一列,会引发StoreScanner的reseek方法。

2、MatchCode.SKIP 忽略掉,继续调用next方法。

3、MatchCode.SEEK_NEXT_ROW 不包括当前这个,继续调用next方法。

4、MatchCode.SEEK_NEXT_COL 不包括它,跳过下一列,会引发StoreScanner的reseek方法。

5、MatchCode.DONE rowkey变了,要留到下次进行比较了

讲到这里基本算结束了。

关于测试
呵呵,有兴趣测试的童鞋可以打开下hbase源码,找到TestStoreScanner这个类自己调试看下结果。




没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条