Phoenix 二级索引源码分析

phoenix 二级索引使用协处理器构建的. 主要入口为org.apache.phoenix.hbase.index.Indexer这里有两个属性

  • protected IndexWriter writer;
  • protected IndexBuildManager builder;

在写入region之前(由region协处理器调用preBatchMutate)构建索引,在写入数据后(协处理器postBatchMutateIndispensably)写入索引

IndexBuildManager builder 构建索引调用过程

  • org.apache.phoenix.hbase.index.Indexer#preBatchMutate
  • org.apache.phoenix.hbase.index.Indexer#preBatchMutateWithExceptions
  • org/apache/phoenix/hbase/index/Indexer.java:501
  • org.apache.phoenix.hbase.index.builder.IndexBuildManager#getIndexUpdate
  • org/apache/phoenix/hbase/index/builder/IndexBuildManager.java:90
  • org.apache.phoenix.hbase.index.covered.NonTxIndexBuilder#getIndexUpdate
  • org.apache.phoenix.hbase.index.covered.NonTxIndexBuilder#addMutationsForBatch
  • org.apache.phoenix.hbase.index.covered.NonTxIndexBuilder#addUpdateForGivenTimestamp
  • org.apache.phoenix.hbase.index.covered.NonTxIndexBuilder#addCurrentStateMutationsForBatch
  • org.apache.phoenix.hbase.index.covered.IndexCodec#getIndexUpserts
  • org.apache.phoenix.index.PhoenixIndexCodec#getIndexUpserts
  • org/apache/phoenix/index/PhoenixIndexCodec.java:91
  • org.apache.phoenix.index.IndexMaintainer#buildUpdateMutation
  • org.apache.phoenix.index.IndexMaintainer#buildRowKey

IndexWriter writer 写入索引调用过程

  • org.apache.phoenix.hbase.index.Indexer#postBatchMutateIndispensably
  • org.apache.phoenix.hbase.index.Indexer#doPost
  • org.apache.phoenix.hbase.index.Indexer#doPostWithExceptions
  • org.apache.phoenix.hbase.index.write.IndexWriter#writeAndKillYourselfOnFailure(java.util.Collection>, boolean, int)
  • org.apache.phoenix.hbase.index.write.IndexWriter#writeAndKillYourselfOnFailure(com.google.common.collect.Multimap, boolean, int)
  • org.apache.phoenix.hbase.index.write.IndexCommitter#write
  • org.apache.phoenix.hbase.index.write.TrackingParallelWriterIndexCommitter#write

参考

  • https://mp.weixin.qq.com/s/ZC-8XC4Mcq2S7AqqziByJg
  • https://www.cnblogs.com/yankang/p/10617601.html
  • hbase doc 协处理器

你可能感兴趣的:(phoenix)