All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.milvus.response.MutationResultWrapper Maven / Gradle / Ivy

Go to download

Java SDK for Milvus, a distributed high-performance vector search engine. update grpc to 1.42.1 update protobuf to 3.19.1

There is a newer version: 2.2.2.1
Show newest version
package io.milvus.response;

import io.milvus.exception.ParamException;
import io.milvus.grpc.MutationResult;

import java.util.List;

import lombok.NonNull;

/**
 * Utility class to wrap response of insert/delete interface.
 */
public class MutationResultWrapper {
    private final MutationResult result;

    public MutationResultWrapper(@NonNull MutationResult result) {
        this.result = result;
    }

    /**
     * Gets the row count of the inserted entities.
     *
     * @return int row count of the inserted entities
     */
    public long getInsertCount() {
        return result.getInsertCnt();
    }

    /**
     * Gets the long ID array returned by insert interface.
     * Throw {@link ParamException} if the primary key type is not int64 type.
     *
     * @return List of Long, ID array returned by insert interface
     */
    public List getLongIDs() throws ParamException {
        if (result.getIDs().hasIntId()) {
            return result.getIDs().getIntId().getDataList();
        } else {
            throw new ParamException("The primary key is not long type, please try getStringIDs()");
        }
    }

    /**
     * Gets the string ID array returned by insert interface.
     * Throw {@link ParamException} if the primary key type is not string type.
     * Note that current release of Milvus doesn't support string type field, thus this method is reserved.
     *
     * @return List of String, ID array returned by insert interface
     */
    public List getStringIDs() throws ParamException {
        if (result.getIDs().hasStrId()) {
            return result.getIDs().getStrId().getDataList();
        } else {
            throw new ParamException("The primary key is not string type, please try getLongIDs()");
        }
    }

    /**
     * Gets the row count of the deleted entities. Currently, this value is always equal to input row count
     *
     * @return int row count of the deleted entities
     */
    public long getDeleteCount() {
        return result.getDeleteCnt();
    }

    /**
     * Get timestamp of the operation marked by server. You can use this timestamp as for guarantee timestamp of query/search api.
     *
     * Note: the timestamp is not an absolute timestamp, it is a hybrid value combined by UTC time and internal flags.
     *  We call it TSO, for more information: @see Hybrid Timestamp in Milvus
     *
     * @return int row count of the deleted entities
     */
    public long getOperationTs() {
        return result.getTimestamp();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy