0
0
Hadoopdata~5 mins

CRUD operations in HBase in Hadoop - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: CRUD operations in HBase
O(1)
Understanding Time Complexity

When working with HBase, it is important to understand how the time to perform create, read, update, and delete actions changes as the data grows.

We want to know how the time needed grows when we add more data or perform more operations.

Scenario Under Consideration

Analyze the time complexity of the following HBase CRUD operations.


// Put operation to add or update a row
Put put = new Put(Bytes.toBytes("row1"));
put.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("qual"), Bytes.toBytes("value"));
table.put(put);

// Get operation to read a row
Get get = new Get(Bytes.toBytes("row1"));
Result result = table.get(get);

// Delete operation to remove a row
Delete delete = new Delete(Bytes.toBytes("row1"));
table.delete(delete);
    

This code shows how to add or update a row, read a row, and delete a row in HBase.

Identify Repeating Operations

Look at what repeats or takes time in these operations.

  • Primary operation: Accessing a single row by its key.
  • How many times: Each operation works on one row at a time, so it happens once per operation.
How Execution Grows With Input

As the number of rows in the table grows, each operation still targets one row by key.

Input Size (n)Approx. Operations
10About 1 step per operation
100About 1 step per operation
1000About 1 step per operation

Pattern observation: The time to perform each operation stays roughly the same no matter how many rows exist.

Final Time Complexity

Time Complexity: O(1)

This means each create, read, update, or delete action takes about the same time regardless of table size.

Common Mistake

[X] Wrong: "CRUD operations get slower as the table grows because there are more rows to check."

[OK] Correct: HBase uses keys and indexes to jump directly to the row, so it does not scan all rows each time.

Interview Connect

Understanding that HBase CRUD operations run in constant time helps you explain how big data systems handle large datasets efficiently.

Self-Check

"What if we tried to scan the entire table instead of accessing by row key? How would the time complexity change?"