Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Heibaiying BigData Notes AppendRegionObserver PrePut

From Leeroopedia
Revision as of 15:04, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Heibaiying_BigData_Notes_AppendRegionObserver_PrePut.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains HBase, Coprocessor, Server_Side_Logic
Last Updated 2026-02-10 10:30 GMT

Overview

Concrete HBase RegionObserver coprocessor that intercepts Put operations on the "article:content" column and appends new values to existing content instead of overwriting.

Description

AppendRegionObserver extends BaseRegionObserver and overrides the prePut hook to implement append-on-write semantics for a specific column. When a Put targets the "article" column family and "content" qualifier, the coprocessor reads the current cell value from the region, concatenates the new value onto it, and replaces the Put's column data with the combined result. This demonstrates the Observer coprocessor pattern for customizing HBase server-side write behavior.

Usage

Use this implementation as a reference when you need to customize HBase write behavior at the region server level, specifically when implementing append semantics, data validation, or transformation triggers that execute before data is persisted. The coprocessor must be registered on the target HBase table via the HBase shell or table descriptor.

Code Reference

Source Location

Signature

public class AppendRegionObserver extends BaseRegionObserver {

    private byte[] columnFamily = Bytes.toBytes("article");
    private byte[] qualifier = Bytes.toBytes("content");

    @Override
    public void prePut(
        ObserverContext<RegionCoprocessorEnvironment> e,
        Put put,
        WALEdit edit,
        Durability durability
    ) throws IOException
}

Import

import com.heibaiying.AppendRegionObserver;
// HBase coprocessor dependencies:
import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;

I/O Contract

Inputs

Name Type Required Description
e ObserverContext<RegionCoprocessorEnvironment> Yes The observer context providing access to the region environment
put Put Yes The Put mutation being intercepted, containing row key and column data
edit WALEdit Yes The Write-Ahead Log edit associated with this mutation
durability Durability Yes The durability setting for this mutation

Outputs

Name Type Description
(side effect) void Modifies the Put object in-place to contain the concatenated old + new value for the "article:content" column

Usage Examples

Registering the Coprocessor on a Table

# In HBase Shell: disable table, add coprocessor, enable table
disable 'article_table'
alter 'article_table', METHOD => 'table_att',
  'coprocessor' => 'hdfs:///coprocessor/append-region-observer.jar|com.heibaiying.AppendRegionObserver|1001|'
enable 'article_table'

Observing Append Behavior

# In HBase Shell: successive puts append content
put 'article_table', 'row1', 'article:content', 'Hello '
# Value is now: "Hello "

put 'article_table', 'row1', 'article:content', 'World!'
# Value is now: "Hello World!" (appended, not overwritten)

get 'article_table', 'row1', 'article:content'
# Returns: "Hello World!"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment