tencent cloud

TDSQL Boundless

Release Notes
Product Introduction
Overview
Scenarios
Product Architecture
Instance Types
Compatibility Notes
Usage specification recommendations
Kernel Features
Kernel Overview
Kernel Version Release Notes
Functionality Features
Performance Features
Billing
Billing Overview
Purchase Method
Pricing Details
Renewal
Overdue Payments
Refund
Getting Started
Creating an Instance
Connect to Instances
User Guide
Data Migration
Data Subscription
Instance Management
Parameter Configuration
Account Management
Security Group
Backup and Restoration
Database Auditing
Tag Management
Use Cases
Technical Evolution and Usage Practices of Online DDL
Lock Mechanism Analysis and Troubleshooting Practices
Data Intelligent Scheduling and Related Practices for Performance Optimization
TDSQL Boundless Selection Guide and Practical Tutorial
Developer Guide
Developer Guide (MySQL Compatibility Mode)
Developer Guide (HBase Compatibility Mode)
Performance Tuning
Performance Tuning Overview
SQL Tuning
DDL Tuning
Performance White Paper
Performance Overview
TPC-C Test
Sysbench Test
API Documentation
History
Introduction
API Category
Making API Requests
Instance APIs
Security Group APIs
Task APIs
Backup APIs
Rollback APIs
Parameter APIs
Database APIs
Data Types
Error Codes
General Reference
System Architecture
SQL Reference
Database Parameter Description
TPC-H benchmark data model reference
Error Code Information
Security and Compliance
FAQs
Agreements
Service Level Agreement
Terms of Service
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Data operations

PDF
Focus Mode
Font Size
Last updated: 2026-02-10 10:54:57

scan

setCaching

Function: Limits the number of rows returned by the RPC server in a single response. By default, there is no limit. Higher values can accelerate query speeds, while lower values reduce client memory consumption. Adjust this setting based on business needs to balance query performance against memory usage.
Method Signature:
public Scan setCaching(int caching);
Parameter:
caching: the number of rows returned per single RPC.
Example:
Scan scan = new Scan();
scan.setCaching(500); // Each RPC returns a maximum of 500 rows

setMaxResultSize

Function: Limits the maximum number of bytes returned by the RPC server in a single response. By default, there is no limit. Please note when using to avoid returning excessive data at once, which may cause memory overflow.
Method Signature:
public Scan setMaxResultSize(long maxResultSize);
Parameter:
maxResultSize: the maximum bytes returned per single RPC.
Example:
Scan scan = new Scan();
scan.setMaxResultSize(1024 * 1024); // Each RPC returns a maximum of 1MB of data

setAllowPartialResults

Function: Sets whether to allow returning partial row data. Default is false, meaning that at least one full row of data is returned each time. Please note when using to avoid returning excessive data at once, which may cause memory overflow.
Method Signature:
public Scan setAllowPartialResults(final boolean allowPartialResults);
Parameter:
allowPartialResults: whether to allow returning partial row data.
Example:
Scan scan = new Scan();
scan.setAllowPartialResults(true); // Allows returning partial row data

withStartRow and withStopRow

Function: Specifies the start row and end row for scanning, including whether to include these row keys.
Method Signature:
public Scan withStartRow(byte[] startRow);
public Scan withStopRow(byte[] stopRow);
Parameter:
startRow: The starting row key.
stopRow: The end row key.
Example:
Scan scan = new Scan();
byte[] startRow = Bytes.toBytes("row1");
byte[] stopRow = Bytes.toBytes("row5");
scan.withStartRow(startRow);
scan.withStopRow(stopRow);

setLimit

Function: Sets the maximum number of results for scanning to prevent returning a large amount of data at once from causing memory overflow.
Method Signature:
public Scan setLimit(int limit);
Parameter:
limit: Maximum number of results.
Example:
Scan scan = new Scan();
scan.setLimit(100); // Returns a maximum of 100 rows of data

renewLease

Function: Extends the validity period of the ResultScanner. The default validity period is 60 seconds, after which the scanner automatically closes.
Method Signature:
ResultScanner.renewLease();
Example:
ResultScanner scanner = hTable.getScanner(scan);
Thread.sleep(5 * 1000);
scanner.next();
Thread.sleep(20 * 1000);
scanner.renewLease(); // Renews the validity period of the scanner

get

checkExistenceOnly

Function: checkExistenceOnly is used to set whether the Get operation returns only the result indicating whether data exists (obtained via the getExists() method of the Result), rather than returning the complete result set. This can be used to quickly check whether a row or cell exists, reducing network transmission and memory consumption.
Method Signature:
public Get setCheckExistenceOnly(boolean checkExistenceOnly);
Parameter:
checkExistenceOnly: If set to true, then the Get operation only returns whether the data exists; if set to false, then returns the complete result set.
Example:
// Create a Get object
Get get = new Get(Bytes.toBytes("row1"));

// Set to only check existence.
get.setCheckExistenceOnly(true);

// Perform the Get operation
Result result = table.get(get);

// Check whether the data exists
boolean exists = result.getExists();
System.out.println("Does the data exist: " + exists);

Obtain Entire Row of Data

Function: obtain the data of all column families and columns for the specified row.
Method Signature:
public Result get(Get get);
Parameter:
get: A Get object to specify the row key to be obtained.
Example:
// Obtain the entire row of data
Get get = new Get(Bytes.toBytes("row1"));
Result result = table.get(get);

Obtain All Columns of the Specified Column Family

Function: obtain the data of all columns in a specific column family for the specified row.
Method Signature:
public Get addFamily(byte[] family);
Parameter:
family: column family name.
Example:
Get getFamily = new Get(Bytes.toBytes("row1"));
getFamily.addFamily(Bytes.toBytes("cf1"));
Result familyResult = table.get(getFamily);

Obtain Specified Column

Function: obtain the data of a specific column in the specified row.
Method Signature:
public Get addColumn(byte[] family, byte[] qualifier);
Parameter:
family: column family name.
qualifier: column name.
Example:
Get getColumn = new Get(Bytes.toBytes("row1"));
getColumn.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"));
Result columnResult = table.get(getColumn);

Obtain Multiple Columns

Function: obtain the data of multiple columns in the specified row.
Method Signature:
public Get addColumn(byte[] family, byte[] qualifier);
Parameter:
family: column family name.
qualifier: column name.
Example:
Get getMultiple = new Get(Bytes.toBytes("row1"));
getMultiple.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"));
getMultiple.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col2"));
getMultiple.addColumn(Bytes.toBytes("cf2"), Bytes.toBytes("col3"));
Result multipleResult = table.get(getMultiple);

obtain the data of the specified version

Function: obtain data of multiple versions in the specified column.
Method Signature:
public Get setMaxVersions(int maxVersions);
Parameter:
maxVersions: maximum number of versions to obtain.
Example:
Get getVersion = new Get(Bytes.toBytes("row1"));
getVersion.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"));
getVersion.setMaxVersions(3); // obtain at most 3 versions
Result versionResult = table.get(getVersion);

To obtain data within a specified time range

Function: obtain data within a specific time range in the specified column.
Method Signature:
public Get setTimeRange(long minStamp, long maxStamp);
Parameter:
minStamp: minimum timestamp in the time range.
maxStamp: maximum timestamp in the time range.
Example:
Get getTimeRange = new Get(Bytes.toBytes("row1"));
getTimeRange.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"));
getTimeRange.setTimeRange(System.currentTimeMillis() - 3600000, System.currentTimeMillis());
Result timeRangeResult = table.get(getTimeRange);

mutate

Mutate operation is used for modifying data and mainly includes the following four operations:
1. Put: Insert or update data.
2. Delete: Delete data.
3. Append: Append data.
4. Increment: Increment data.

Put Operation

Function: Insert or update data.
Method Signature:
public Put addColumn(byte[] family, byte[] qualifier, byte[] value);
public Put addColumn(byte[] family, byte[] qualifier, long timestamp, byte[] value);
Parameter:
family: column family name.
qualifier: column name.
value: column value.
timestamp (optional): Timestamp.
Example:
// 1. Basic Put operation
Put put = new Put(Bytes.toBytes("row1"));
put.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"), Bytes.toBytes("value1"));
put.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col2"), Bytes.toBytes("value2"));
table.put(put);

// 2. Put with timestamp
Put putWithTimestamp = new Put(Bytes.toBytes("row1"));
long timestamp = System.currentTimeMillis();
putWithTimestamp.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"), timestamp, Bytes.toBytes("value1"));
table.put(putWithTimestamp);

Delete Operation

Function: Delete data.
Method Signature:
public Delete addColumn(byte[] family, byte[] qualifier);
public Delete addColumn(byte[] family, byte[] qualifier, long timestamp);
public Delete addColumns(byte[] family, byte[] qualifier);
public Delete addFamily(byte[] family);
Parameter:
family: column family name.
qualifier: column name.
timestamp (optional): Timestamp.
Example:
// 1. Delete the entire row
Delete deleteRow = new Delete(Bytes.toBytes("row1"));
table.delete(deleteRow);

// 2. Delete the specified column family
Delete deleteFamily = new Delete(Bytes.toBytes("row1"));
deleteFamily.addFamily(Bytes.toBytes("cf1"));
table.delete(deleteFamily);

// 3. Delete the specified column
Delete deleteColumn = new Delete(Bytes.toBytes("row1"));
deleteColumn.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"));
table.delete(deleteColumn);

// 4. Delete the specified version
Delete deleteVersion = new Delete(Bytes.toBytes("row1"));
deleteVersion.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"), timestamp);
table.delete(deleteVersion);

// 5. Delete all versions of the column
Delete deleteAllVersions = new Delete(Bytes.toBytes("row1"));
deleteAllVersions.addColumns(Bytes.toBytes("cf1"), Bytes.toBytes("col1"));
table.delete(deleteAllVersions);

Append Operation

Function: Appending data to existing data.
Method Signature:
public Append add(byte[] family, byte[] qualifier, byte[] value);
Parameter:
family: column family name.
qualifier: column name.
value: the value to append.
Example:
// 1. Basic Append operation
Append append = new Append(Bytes.toBytes("row1"));
append.add(Bytes.toBytes("cf1"), Bytes.toBytes("col1"), Bytes.toBytes("_appended"));
Result appendResult = table.append(append);

// 2. Multiple-column Append
Append appendMultiple = new Append(Bytes.toBytes("row1"));
appendMultiple.add(Bytes.toBytes("cf1"), Bytes.toBytes("col1"), Bytes.toBytes("_suffix1"));
appendMultiple.add(Bytes.toBytes("cf1"), Bytes.toBytes("col2"), Bytes.toBytes("_suffix2"));
Result appendMultipleResult = table.append(appendMultiple);

Increment Operation

Function: Incrementing numeric columns.
Method Signature:
public Increment addColumn(byte[] family, byte[] qualifier, long amount);
Parameter:
family: column family name.
qualifier: column name.
amount: the incrementing value.
Example:
// 1. Basic Increment operation
Increment increment = new Increment(Bytes.toBytes("row1"));
increment.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("counter"), 1L);
Result incrementResult = table.increment(increment);

Batch Operations

Batch operations are used for batch processing of data, supporting operations such as Put, Get, Delete on multiple rows, or mixing multiple operations. Batch operations can reduce network overhead and improve the efficiency of data processing.

Batch Put Operation

Function: batch insert or update data.
Method Signature:
public void put(List<Put> puts);
Parameter:
puts: a list of multiple Put objects.
Example:
List<Put> puts = new ArrayList<>();
for (int i = 0; i < 100; i++) {
Put put = new Put(Bytes.toBytes("row" + i));
put.addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"), Bytes.toBytes("value" + i));
puts.add(put);
}
table.put(puts);


Batch Get Operation

Function: batch retrieve data.
Method Signature:
public Result[] get(List<Get> gets);
Parameter:
gets: contains a list of multiple Get objects.
Example:
List<Get> gets = new ArrayList<>();
for (int i = 0; i < 100; i++) {
Get get = new Get(Bytes.toBytes("row" + i));
gets.add(get);
}
Result[] results = table.get(gets);


Batch Delete Operation

Function: batch delete data.
Method Signature:
public void delete(List<Delete> deletes);
Parameter:
deletes: contains a list of multiple Delete objects.
Example:
List<Delete> deletes = new ArrayList<>();
for (int i = 0; i < 100; i++) {
Delete delete = new Delete(Bytes.toBytes("row" + i));
deletes.add(delete);
}
table.delete(deletes);

Mixed Batch Operation

Function: supports combining various operations such as Put, Get, Delete, Increment in a batch operation.
Method Signature:
public Object[] batch(List<? extends Row> actions, Object[] results);
Parameter:
actions: contains a list of multiple Row objects (such as Put, Get, Delete, Increment).
results: an array used for storing the results of operations.
Example:
List<Row> actions = new ArrayList<>();
actions.add(new Put(Bytes.toBytes("row1")).addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("col1"), Bytes.toBytes("value1")));
actions.add(new Get(Bytes.toBytes("row2")));
actions.add(new Delete(Bytes.toBytes("row3")));
actions.add(new Increment(Bytes.toBytes("row4")).addColumn(Bytes.toBytes("cf1"), Bytes.toBytes("counter"), 1L));

Object[] results = new Object[actions.size()];
table.batch(actions, results);


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback