协处理器定义为:
@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> c, Get get, List<Cell> result) throws IOException {
if (Bytes.equals(get.getRow(), ADMIN)) {//ADMIN:"admin"
Cell cell = CellBuilderFactory.create(CellBuilderType.DEEP_COPY)
.setFamily(COLUMN_FAMILY)
.setQualifier(COLUMN)
.setTimestamp(System.currentTimeMillis())
.setType(Cell.Type.Put)
.setValue(VALUE)
.build();
result.add(cell);
c.bypass();
}
}
并且已正确设置协处理器:
hbase(main):003:0> describe 'users'
Table users is ENABLED
users, {TABLE_ATTRIBUTES => {coprocessor$1 =>
'file:/home/hadoop/IdeaProjects/hbasedemo/target/hbasedemo-
1.0.jar|com.zhi.hbaseclient.
RegionObserverExample|1073741823|'}
COLUMN FAMILIES DESCRIPTION
{NAME => 'personalDet', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE =>
'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FA
LSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE',
TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0',
BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY =>
'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OP
EN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE
=> '65536'}
{NAME => 'salaryDet', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE =>
'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALS
E', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL
=> 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', B
LOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY =>
'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN
=> 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE =>
'65536'}
2 row(s)
Took 0.0161 seconds
但执行后获得'users','admin',则admin行的信息与预期相反:
hbase(main):004:0> get 'users','admin'
COLUMN CELL
personalDet:lastname timestamp=1545129509443, value=Admin
personalDet:name timestamp=1545129509443, value=Admin
1 row(s)
Took 0.0202 seconds
在这种情况下有什么我忽略的结果吗?