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

io.milvus.param.control.GetFlushStateParam Maven / Gradle / Ivy

There is a newer version: 2.4.8
Show newest version
package io.milvus.param.control;

import io.milvus.exception.ParamException;
import io.milvus.param.ParamUtils;
import lombok.Getter;
import lombok.NonNull;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

/**
 * Parameters for getMetric interface.
 */
@Getter
@ToString
public class GetFlushStateParam {
    private final String databaseName;
    private final String collectionName;
    private final List segmentIDs;
    private final Long flushTs;

    private GetFlushStateParam(@NonNull Builder builder) {
        this.databaseName = builder.databaseName;
        this.collectionName = builder.collectionName;
        this.segmentIDs = builder.segmentIDs;
        this.flushTs = builder.flushTs;
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    /**
     * Builder for {@link GetFlushStateParam} class.
     */
    public static final class Builder {
        private String databaseName;
        private String collectionName;
        private final List segmentIDs = new ArrayList<>(); // deprecated
        private Long flushTs = 0L;

        private Builder() {
        }

        /**
         * Sets the database name. database name can be nil.
         *
         * @param databaseName database name
         * @return Builder
         */
        public Builder withDatabaseName(String databaseName) {
            this.databaseName = databaseName;
            return this;
        }

        /**
         * Specify segments
         *
         * @param segmentIDs segments id list
         * @return Builder
         */
        @Deprecated
        public Builder withSegmentIDs(@NonNull List segmentIDs) {
            this.segmentIDs.addAll(segmentIDs);
            return this;
        }

        /**
         * Specify a segment
         *
         * @param segmentID segment id
         * @return Builder
         */
        @Deprecated
        public Builder addSegmentID(@NonNull Long segmentID) {
            this.segmentIDs.add(segmentID);
            return this;
        }

        /**
         * Sets the collection name. Collection name cannot be empty or null.
         *
         * @param collectionName collection name
         * @return Builder
         */
        public Builder withCollectionName(@NonNull String collectionName) {
            this.collectionName = collectionName;
            return this;
        }

        /**
         * Input a time stamp of a flush action, get its flush state
         *
         * @param flushTs a time stamp returned by the flush() response
         * @return Builder
         */
        public Builder withFlushTs(@NonNull Long flushTs) {
            this.flushTs = flushTs;
            return this;
        }

        /**
         * Verifies parameters and creates a new {@link GetFlushStateParam} instance.
         *
         * @return {@link GetFlushStateParam}
         */
        public GetFlushStateParam build() throws ParamException {
            ParamUtils.CheckNullEmptyString(collectionName, "Collection name");

            return new GetFlushStateParam(this);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy