文档

获取Partition列表

更新时间:

本文介绍如何通过Java SDK获取Collection中所有Partition名称的列表。

前提条件

接口定义

// class DashVectorCollection

public Response<List<String>> listPartitions();

使用示例

说明
  1. 需要使用您的api-key替换示例中的YOUR_API_KEY、您的Cluster Endpoint替换示例中的YOUR_CLUSTER_ENDPOINT,代码才能正常运行。

  2. 本示例需要参考新建Collection-使用示例提前创建好名称为quickstart的Collection。

import com.aliyun.dashvector.DashVectorClient;
import com.aliyun.dashvector.DashVectorCollection;
import com.aliyun.dashvector.common.DashVectorException;
import com.aliyun.dashvector.models.responses.Response;

import java.util.List;

public class Main {
    public static void main(String[] args) throws DashVectorException {
        DashVectorClient client = new DashVectorClient("YOUR_API_KEY", "YOUR_CLUSTER_ENDPOINT");
        DashVectorCollection collection = client.get("quickstart");
      
        Response<List<String>> response = collection.listPartitions();
    
        System.out.println(response);
        // example output:
        // {"code":0,"message":"","requestId":"d72a4f14-ff9a-4e39-89d4-ce023d34d37f","output":["default","shoes"]}
    }
}

入参描述

出参描述

说明

返回结果为Response<List<String>>对象,Response<List<String>>对象中可获取本次操作结果信息,如下表所示。

方法

类型

描述

示例

getCode()

int

返回值,参考返回状态码说明

0

getMessage()

String

返回消息

success

getReqeuestId()

String

请求唯一id

19215409-ea66-4db9-8764-26ce2eb5bb99

getOutput()

List<String>

Collection中所有Partition的列表

['shoes', 'default']

isSuccess()

Boolean

判断请求是否成功

true

  • 本页导读 (0)
文档反馈