liuxiaocs7 commented on code in PR #7901:
URL: https://github.com/apache/hbase/pull/7901#discussion_r2937996331
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RowCache.java:
##########
@@ -110,16 +229,67 @@ boolean tryGetFromCache(RowCacheKey key, Get get,
List<Cell> results) {
}
results.addAll(row.getCells());
- // TODO: implement update of metrics
return true;
}
- void populateCache(List<Cell> results, RowCacheKey key) {
- // TODO: implement with barrier to avoid cache read during mutation
- try {
- rowCacheStrategy.cacheRow(key, new RowCells(results));
- } catch (CloneNotSupportedException ignored) {
- // Not able to cache row cells, ignore
- }
+ void populateCache(HRegion region, List<Cell> results, RowCacheKey key) {
+ // The row cache is populated only when no region level barriers remain
+ regionLevelBarrierMap.computeIfAbsent(region, t -> {
+ // The row cache is populated only when no row level barriers remain
+ rowLevelBarrierMap.computeIfAbsent(key, k -> {
+ try {
+ rowCacheStrategy.cacheRow(key, new RowCells(results));
+ } catch (CloneNotSupportedException ignored) {
+ // Not able to cache row cells, ignore
+ }
+ return null;
+ });
+ return null;
+ });
+ }
+
+ void createRegionLevelBarrier(HRegion region) {
+ regionLevelBarrierMap.computeIfAbsent(region, k -> new
AtomicInteger(0)).incrementAndGet();
+ }
+
+ void increaseRowCacheSeqNum(HRegion region) {
+ region.increaseRowCacheSeqNum();
+ }
+
+ void removeTableLevelBarrier(HRegion region) {
+ regionLevelBarrierMap.computeIfPresent(region, (k, counter) -> {
+ int remaining = counter.decrementAndGet();
+ return (remaining <= 0) ? null : counter;
+ });
+ }
Review Comment:
this method should be renamed by `removeRegionLevelBarrier`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]