GetIndexBuildProgressParam.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package io.milvus.param.index;
  20. import io.milvus.exception.ParamException;
  21. import io.milvus.param.Constant;
  22. import io.milvus.param.ParamUtils;
  23. import lombok.Getter;
  24. import lombok.NonNull;
  25. import lombok.ToString;
  26. import org.apache.commons.lang3.StringUtils;
  27. /**
  28. * Parameters for <code>getIndexBuildProgress</code> interface.
  29. */
  30. @Getter
  31. @ToString
  32. public class GetIndexBuildProgressParam {
  33. private final String databaseName;
  34. private final String collectionName;
  35. private final String indexName;
  36. private GetIndexBuildProgressParam(@NonNull Builder builder) {
  37. this.databaseName = builder.databaseName;
  38. this.collectionName = builder.collectionName;
  39. this.indexName = builder.indexName;
  40. }
  41. public static Builder newBuilder() {
  42. return new Builder();
  43. }
  44. /**
  45. * Builder for {@link GetIndexBuildProgressParam} class.
  46. */
  47. public static final class Builder {
  48. private String databaseName;
  49. private String collectionName;
  50. private String indexName = Constant.DEFAULT_INDEX_NAME;
  51. private Builder() {
  52. }
  53. /**
  54. * Sets the database name. database name can be nil.
  55. *
  56. * @param databaseName database name
  57. * @return <code>Builder</code>
  58. */
  59. public Builder withDatabaseName(String databaseName) {
  60. this.databaseName = databaseName;
  61. return this;
  62. }
  63. /**
  64. * Sets the collection name. Collection name cannot be empty or null.
  65. *
  66. * @param collectionName collection name
  67. * @return <code>Builder</code>
  68. */
  69. public Builder withCollectionName(@NonNull String collectionName) {
  70. this.collectionName = collectionName;
  71. return this;
  72. }
  73. /**
  74. * The name of target index.
  75. * If no index name is specified, the default index name("_default_idx") is used.
  76. *
  77. * @param indexName index name
  78. * @return <code>Builder</code>
  79. */
  80. public Builder withIndexName(@NonNull String indexName) {
  81. this.indexName = indexName;
  82. return this;
  83. }
  84. /**
  85. * Verifies parameters and creates a new {@link GetIndexBuildProgressParam} instance.
  86. *
  87. * @return {@link GetIndexBuildProgressParam}
  88. */
  89. public GetIndexBuildProgressParam build() throws ParamException {
  90. ParamUtils.CheckNullEmptyString(collectionName, "Collection name");
  91. if (indexName == null || StringUtils.isBlank(indexName)) {
  92. indexName = Constant.DEFAULT_INDEX_NAME;
  93. }
  94. return new GetIndexBuildProgressParam(this);
  95. }
  96. }
  97. }