phoenix源码分析


phoenix源码1概述和序列

包: ipc,regionserver,metric2,metric,protobuf

log,monitoring,trace,util,

mapredue,cache,call,memory,

parse,optimizer,compile,excute,expression,iterator

schema.MetaDataClient

join,query,

coprocessor,filter,

index,jdbc,

job

序列1

Squence1: PhoenixDriver with PhoenixEmbeddedDriver: ->connect ->new ConnectionQueryServicesImpl addConnection childService

ConnectionQueryServicesImpl实现:

hbase:

getAllTableRegions
generateColumnFamilyDescriptor
modifyColumnFamilyDescriptor
generateTableDescriptor
addCoprocessors
pollForUpdatedTableDescriptor
modifyTable

mutatemeta底层:

metaDataMutated->cli
updateData->cli
clearCache ->cli:Clears the Phoenix meta data cache on each region server
clearTableFromCache->cli
createSequence:returnSequences  drop current viladate increment
addTable
flushTable
addColumn->mm
removeColumn
removeTable->mm
dropTable
invalidateTables
dropTables
ensureLocalIndexTableCreated
ensureViewIndexTableCreated
ensureLocalIndexTableCreated
ensureViewIndexTableDropped
ensureLocalIndexTableDropped
dropColumn
updateIndexState
mmetaDataCoprocessorExec  
Invoke meta data coprocessor with one retry if the key was found to not be in the regions
phoenix.schema.change.delay
getTTLForEmptyCf

序列2

存: phoenixStatement/phoenixPreparedStatement->CreateTableCompiler->cli->createTable->mm

取:getTable

层0

  • ServerCacheClient.addServerCache
  • FromCompiler:Validates FROM clause and builds a ColumnResolver for resolving column references
  • excute.MutationState
  • iterator:TableResultIterator
  • ConnectionQueryServicesImpl.query的一些引用

层n

<-join.HashCacheClient,index.IndexMetaDataCacheClient

<-iterator->HashJoinPlan.execute

<-各种execute的plan里的iterator实现相互委托plan:ClientAggregatePlan->delegate->iterator->clientscan,hashjoinscan,sortmergejoin

<-compile.DeleteStateMent,PostDDlCompiler,UpsertCompiler/

或者直接jdbc.excuteQuery:

QueryPlan plan = stmt.compilePlan(PhoenixStatement.this, Sequence.ValueOp.RESERVE_SEQUENCE);
plan = connection.getQueryServices().getOptimizer().optimize(
        PhoenixStatement.this, plan);
// this will create its own trace internally, so we don't wrap this
// whole thing in tracing
ResultIterator resultIterator = plan.iterator();

总结:1.当执行jdbc.excuteQuery时候,直接编译plan,优化,使用物理plans执行得到结果。

学习sql解析: -hint 更改计划:优化器提示,表链接提示,hash,merge,反连接提示,索引提示 -index:普通,复合,位图,函数,

  • row source: driving table 驱动行源 join中小的row source
  • probed table:被探测表 内层表 大表行源
  • 组合索引:有引导列才走索引
  • predicate谓词:where的限制条件
  • 索引:unique,range,full,fast full
  • data物理访问:1.full,2.hash,3.rowid
  • 索引访问:1.rowids2.rowid3.descids
  • sort触发:orderby,gourpby,distinct,unoin,minus,mergejoin,createindex
  • optimizer: 规则rbo,成本cbo
  • optimizer mode:rule,choose,first row,all_rows
  • hash join,nested loop
大山 /
Published under (CC) BY-NC-SA in categories   tagged with