OceanBase
English日本語简体中文
ドキュメントホーム
製品
エコシステム
リリース

データベース

OceanBase CloudOceanBaseデータベース

データベース

OceanBase CloudOceanBaseデータベース
OceanBase CloudOceanBaseデータベース

OceanBaseデータベース

KV - V4.4.2
  • OBKVの概要
  • OBKVのアーキテクチャ
  • OBKV-Table
    • OBKV-Table概要
      • OBKV-Tableの概要
      • OBKV-Tableのコア機能
      • OBKV-Tableデプロイの概要
    • シンプルなKey-Valueストレージのクイックスタート(Java)
    • OBKV-Table Javaクライアントを使ったアプリケーション開発
      • OBKV-Table Java開発ガイド
      • OBKV-Table開発の準備
      • OBKV-Table Javaクライアントを使用してクラスタに接続する
      • OBKV-Table操作例
        • OBKV-Tableへのデータ書き込み
        • OBKV-Tableによるデータのクエリ
        • OBKV-Tableでのデータ更新
        • OBKV-Tableによるデータの削除
      • OBKV-Table Javaクライアントのパラメータ設定
    • OBKV-Table管理
      • OBKV-Table管理の概要
      • OBKV-Tableの高可用性
      • OBKV-Tableのセキュリティ権限
      • OBKV-Tableモニタリングメトリクス
    • OBKV-Tableリファレンス
      • OBKV-Tableのデータモデル
      • OBKV-Tableの操作タイプ
      • OBKV-Tableがサポートするデータ型
      • OBKV-Table全文インデックス
      • OBKV-Tableのグローバルインデックスの使用範囲と例
      • OBKV-Tableの期限切れデータ削除
      • OBKV-Tableのグループコミット
      • OBKV-Tableの弱い整合性読み取りと最寄りデータセンターからの読み取り
      • OBKV-Table関連ビュー
    • OBKV-Table よくある質問
  • OBKV-HBase
    • OBKV-HBaseの概要
    • OBKV-HBaseのコア機能
    • OBKV-HBaseのデプロイ
    • OBKV-HBaseによるアプリケーション開発
      • OBKV-HBase アプリケーション開発の概要
      • OBKV-HBase Javaクライアントを使用したクラスタへの接続
      • HBaseの業務コードをOBKV-HBaseに移行する
      • OBKV-HBase データ操作の例
    • OBKV-HBase 移行ガイド
    • OBKV-HBase管理
      • OBKV-HBase管理の概要
      • OBKV-HBaseの高可用性
      • OBKV-HBaseのセキュリティ権限
      • OBKV-HBaseモニタリングメトリクス
    • OBKV-HBaseクエリの最適化
    • OBKV-HBaseの性能テスト
    • OBKV-HBaseリファレンス
      • OBKV-HBaseデータモデル
      • OBKV-HBaseのデータスキーマ
      • HBaseとの互換インターフェース
      • HBaseと互換性のあるフィルター
      • OBKV-HBaseの自動パーティション分割
      • OBKV-HBaseにおける期限切れデータの削除
      • OBKV-HBaseの弱い整合性読み取りと最寄りデータセンターからの読み取り
      • OBKV-HBase関連ビュー
    • OBKV-HBaseエコシステム統合
      • Flink連携
        • Flinkコネクタを使用してOBKV-HBaseにデータを同期する
        • ネイティブFlinkによるOBKV-HBaseへのアクセス
      • HiveによるOBKV-HBaseへのアクセス
      • SparkによるOBKV-HBaseへのアクセス
  • OBKVリリースノート
    • OBKV Enterprise版

PDF をダウンロード

このページには現在中国語/日本語版がなく、英語版を表示しています。
ドキュメントフィードバック
  1. ドキュメントセンター
  2. OceanBaseデータベース
  3. KV
  4. V4.4.2

Aggregation API

最終更新:2026-09-04 10:25:15

Get an AggExecutor
AggExecutor
Example

Get an AggExecutor

The syntax is as follows:

type Client interface {
    // NewAggExecutor create an aggregate executor.
    NewAggExecutor(tableName string, rangePairs []*table.RangePair, opts ...option.ObQueryOption) AggExecutor
}

Input parameters:

  • tableName: the name of the table.
  • rangePairs: the aggregation range.
  • opts: the optional parameters, some of which are supported. You can specify these parameters as needed.

Response parameters:

AggExecutor: the aggregation executor.

AggExecutor

The syntax is as follows:

type AggExecutor interface {
    // Min add a min operation to the agg executor.
    Min(columnName string) AggExecutor
    // Max add a max operation to the agg executor.
    Max(columnName string) AggExecutor
    // Count add a count operation to the agg executor.
    Count() AggExecutor
    // Sum add a sum operation to the agg executor.
    Sum(columnName string) AggExecutor
    // Avg add an avg operation to the agg executor.
    Avg(columnName string) AggExecutor
    // Execute an agg operation.
    // AggregateResult contains the results of all operations.
    Execute(ctx context.Context) (AggregateResult, error)
}

Input parameters:

  • Min(columnName string): calculates the minimum value of the column specified by columnName.
  • Max(columnName string): calculates the maximum value of the column specified by columnName.
  • Count(columnName string): calculates the number of rows within the range.
  • Sum(columnName string): calculates the sum of the column specified by columnName.
  • Avg(columnName string): calculates the average value of the column specified by columnName.
  • Execute(ctx context.Context): executes the aggregation operation.

Example

Get the sum of column c3, the minimum value of column c2, and the maximum value of column c1 for the rows whose c1 value is in the range of 0 to 100, as well as the total number of columns within the range.

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)
    }

    startRowKey := []*table.Column{table.NewColumn("c1", int64(0)), table.NewColumn("c2", table.Min)}
    endRowKey := []*table.Column{table.NewColumn("c1", int64(100)), table.NewColumn("c2", table.Max)}
    keyRanges := []*table.RangePair{table.NewRangePair(startRowKey, endRowKey)}

    // create agg executor
    aggExecutor := cli.NewAggExecutor(tableName, keyRanges).Sum("c3").Min("c2").Max("c1").Count()

    // get agg result
    res, err := aggExecutor.Execute(context.TODO())

    if err != nil {
        panic(err)
    }

    // get agg result value
    println(res.Value("sum(c3)").(int64))
    println(res.Value("min(c2)").(int64))
    println(res.Value("max(c1)").(int64))
    println(res.Value("count(*)").(int64))
}

次のトピック

OBKVの概要
次へ
このページの内容
Get an AggExecutor
AggExecutor
Example