OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

KV - V4.3.5

  • OBKV overview
  • Architecture
  • OBKV-Table
    • Introduction to OBKV-Table
      • Overview
      • OBKV-Table operation types
      • Core features of OBKV-Table
      • Differences between replace and insert_or_update
      • Supported value types
      • OBKV-Table data models
    • Use the OBKV-Table Java client
      • Java development guide for OBKV-Table
      • Prepare for development with OBKV-Table
      • Use the OBKV-Table Java client to connect to a cluster
      • Set client parameters
      • Supported client interfaces
      • Use the OBKV-Table Java client
    • Use the OBKV-Table GO client
      • Use the OBKV-Table Go client to connect to a cluster
      • Overview of the Go client
      • Individual API operations
      • Batch operations
      • About queries
      • Aggregation API
      • Filters
    • FAQ
  • OBKV-HBase
    • Overview
    • OBKV-HBase core features
    • Compatibility with HBase
    • Deployment
    • Application development with OBKV-HBase
      • Overview of OBKV-HBase application development
      • Data model
      • Data model design
      • Connect to a cluster using the OBKV-HBase client
      • Migrate HBase business code to OBKV-HBase
      • Data operation examples
      • Delete expired data
    • OBKV-HBase migration guide
    • OBKV-HBase management
      • Overview
      • High availability
      • Security and permissions
      • Monitoring metrics
    • Performance test
    • OBKV-HBase integrations
      • Flink
        • Synchronize data to OBKV-HBase by using Flink
    • Views
    • FAQ

Download PDF

OBKV overview Architecture Overview OBKV-Table operation types Core features of OBKV-Table Differences between replace and insert_or_update Supported value types OBKV-Table data models Java development guide for OBKV-Table Prepare for development with OBKV-Table Use the OBKV-Table Java client to connect to a cluster Set client parameters Supported client interfaces Use the OBKV-Table Java client Use the OBKV-Table Go client to connect to a cluster Overview of the Go client Individual API operations Batch operations About queries Aggregation API Filters FAQ Overview OBKV-HBase core features Compatibility with HBase Deployment Overview of OBKV-HBase application development Data model Data model design Connect to a cluster using the OBKV-HBase client Migrate HBase business code to OBKV-HBase Data operation examples Delete expired data OBKV-HBase migration guide Overview High availability Security and permissions Monitoring metrics Performance test Views FAQ
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Database
  3. KV
  4. V4.3.5
iconOceanBase Database
KV - V 4.3.5
SQL
KV
  • V 4.3.5

Batch operations

Last Updated:2025-09-08 11:41:13  Updated
share
What is on this page
Create a batch executor
BatchExecutor API
Example

folded

share

Create a batch executor

The syntax is as follows:

// NewBatchExecutor create a batch executor.
NewBatchExecutor(tableName string) BatchExecutor

Input parameters:

  • tableName: the name of the table.

Response parameters:

  • BatchExecutor: the batch executor.

BatchExecutor API

The syntax is as follows:

type BatchExecutor interface {
    // AddInsertOp add an insert operation to the batch executor.
    AddInsertOp(rowKey []*table.Column, mutateValues []*table.Column, opts ...ObkvOption) error
    // AddUpdateOp add an update operation to the batch executor.
    AddUpdateOp(rowKey []*table.Column, mutateValues []*table.Column, opts ...ObkvOption) error
    // AddInsertOrUpdateOp add an insertOrUpdate operation to the batch executor
    AddInsertOrUpdateOp(rowKey []*table.Column, mutateValues []*table.Column, opts ...ObkvOption) error
    // AddReplaceOp add a replace operation to the batch executor
    AddReplaceOp(rowKey []*table.Column, mutateValues []*table.Column, opts ...ObkvOption) error
    // AddIncrementOp add an increment operation to the batch executor
    AddIncrementOp(rowKey []*table.Column, mutateValues []*table.Column, opts ...ObkvOption) error
    // AddAppendOp add an append operation to the batch executor
    AddAppendOp(rowKey []*table.Column, mutateValues []*table.Column, opts ...ObkvOption) error
    // AddDeleteOp add a delete operation to the batch executor
    AddDeleteOp(rowKey []*table.Column, opts ...ObkvOption) error
    // AddGetOp add a get operation to the batch executor.
    AddGetOp(rowKey []*table.Column, getColumns []string, opts ...ObkvOption) error
    // Execute a batch operation.
    // batch operation only ensures atomicity of a single partition.
    // BatchOperationResult contains the results of all operations.
    Execute(ctx context.Context) (BatchOperationResult, error)
}

Input parameters:

  • AddInsertOp: adds the Insert operation.
  • AddUpdateOp: adds the Update operation.
  • AddInsertOrUpdateOp: adds the InsertOrUpdate operation.
  • AddReplaceOp: adds the Replace operation.
  • AddIncrementOp: adds the Increment operation.
  • AddAppendOp: adds the Append operation.
  • AddDeleteOp: adds the Delete operation.
  • AddGetOp: adds the Get operation.
  • Execute: executes multiple operations at a time. The execution result is returned in BatchOperationResult.

The syntax of BatchOperationResult is as follows:

type BatchOperationResult interface {
    // IsEmptySet result is empty or not.
    IsEmptySet() bool
    // GetResults get all results.
    GetResults() []SingleResult
    // Size batch operation size.
    Size() int
    // SuccessIdx indexes of successful operation.
    SuccessIdx() []int
    // ErrorIdx indexes of unsuccessful operation.
    ErrorIdx() []int
}

Input parameters:

  • IsEmptySet: indicates whether the result is empty.
  • GetResults: the result array.
  • Size: the number of results.
  • SuccessIdx: the sequence number of a successful operation.
  • ErrorIdx: the sequence number of a failed operation.

Example

// CREATE TABLE test(c1 bigint, c2 bigint, PRIMARY KEY(c1)) PARTITION BY hash(c1) partitions 2;
func main() {
    const (
        configUrl    = "xxx"
        fullUserName = "user@tenant#cluster"
        passWord     = ""
        sysUserName  = "sysUser"
        sysPassWord  = ""
        tableName    = "test"
    )
    cfg := config.NewDefaultClientConfig()
    cli, err := client.NewClient(configUrl, fullUserName, passWord, sysUserName, sysPassWord, cfg)
    if err != nil {
        panic(err)
    }

    batchExecutor := cli.NewBatchExecutor(tableName)

    rowKey1 := []*table.Column{table.NewColumn("c1", int64(1))}
    rowKey2 := []*table.Column{table.NewColumn("c1", int64(2))}
    selectColumns1 := []string{"c1"}
    selectColumns2 := []string{"c2"}
    err = batchExecutor.AddGetOp(rowKey1, selectColumns1)
    if err != nil {
        panic(err)
    }
    err = batchExecutor.AddGetOp(rowKey2, selectColumns2)
    if err != nil {
        panic(err)
    }

    ctx, _ := context.WithTimeout(context.Background(), time.Duration(1000)*time.Millisecond) // 1000ms
    res, err := batchExecutor.Execute(ctx)
    if err != nil {
        panic(err)
    }

    if res.Size() != 2 {
        panic(err)
    }
    println(res.GetResults()[0].Entity().GetProperty("c1"))
    println(res.GetResults()[1].Entity().GetProperty("c2"))
}
  • In this example, two Get operations are executed at a time.
  • Two results are returned. Result 0 contains the value of c1, and Result 1 contains the value of c2.

Previous topic

Individual API operations
Last

Next topic

About queries
Next
What is on this page
Create a batch executor
BatchExecutor API
Example