|
@@ -21,16 +21,12 @@ package io.milvus.param.collection;
|
|
|
|
|
|
import io.milvus.exception.ParamException;
|
|
import io.milvus.exception.ParamException;
|
|
import io.milvus.param.Constant;
|
|
import io.milvus.param.Constant;
|
|
-import io.milvus.param.IndexType;
|
|
|
|
-import io.milvus.param.MetricType;
|
|
|
|
import io.milvus.param.ParamUtils;
|
|
import io.milvus.param.ParamUtils;
|
|
import lombok.Getter;
|
|
import lombok.Getter;
|
|
import lombok.NonNull;
|
|
import lombok.NonNull;
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
-import java.util.Objects;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Parameters for <code>alterCollection</code> interface.
|
|
* Parameters for <code>alterCollection</code> interface.
|
|
@@ -38,13 +34,13 @@ import java.util.Objects;
|
|
@Getter
|
|
@Getter
|
|
public class AlterCollectionParam {
|
|
public class AlterCollectionParam {
|
|
private final String collectionName;
|
|
private final String collectionName;
|
|
|
|
+ private final String databaseName;
|
|
private final Map<String, String> properties = new HashMap<>();
|
|
private final Map<String, String> properties = new HashMap<>();
|
|
|
|
|
|
private AlterCollectionParam(@NonNull Builder builder) {
|
|
private AlterCollectionParam(@NonNull Builder builder) {
|
|
this.collectionName = builder.collectionName;
|
|
this.collectionName = builder.collectionName;
|
|
- if (builder.ttlSeconds >= 0) {
|
|
|
|
- this.properties.put(Constant.TTL_SECONDS, Integer.toString(builder.ttlSeconds));
|
|
|
|
- }
|
|
|
|
|
|
+ this.databaseName = builder.databaseName;
|
|
|
|
+ this.properties.putAll(builder.properties);
|
|
}
|
|
}
|
|
|
|
|
|
public static Builder newBuilder() {
|
|
public static Builder newBuilder() {
|
|
@@ -56,11 +52,9 @@ public class AlterCollectionParam {
|
|
*/
|
|
*/
|
|
public static final class Builder {
|
|
public static final class Builder {
|
|
private String collectionName;
|
|
private String collectionName;
|
|
|
|
+ private String databaseName;
|
|
|
|
|
|
- // The ttlSeconds value should be 0 or greater.
|
|
|
|
- // In server side, the default value is 0, which means TTL is disabled.
|
|
|
|
- // Here we set ttlSeconds = -1 to avoid being overwritten with unconscious
|
|
|
|
- private Integer ttlSeconds = -1;
|
|
|
|
|
|
+ private final Map<String, String> properties = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
private Builder() {
|
|
private Builder() {
|
|
@@ -77,9 +71,21 @@ public class AlterCollectionParam {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Sets the database name. database name can be nil.
|
|
|
|
+ *
|
|
|
|
+ * @param databaseName database name
|
|
|
|
+ * @return <code>Builder</code>
|
|
|
|
+ */
|
|
|
|
+ public Builder withDatabaseName(String databaseName) {
|
|
|
|
+ this.databaseName = databaseName;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Collection time to live (TTL) is the expiration time of data in a collection.
|
|
* Collection time to live (TTL) is the expiration time of data in a collection.
|
|
* Expired data in the collection will be cleaned up and will not be involved in searches or queries.
|
|
* Expired data in the collection will be cleaned up and will not be involved in searches or queries.
|
|
|
|
+ * In server side, the default value is 0, which means TTL is disabled.
|
|
* Specify TTL in the unit of seconds.
|
|
* Specify TTL in the unit of seconds.
|
|
*
|
|
*
|
|
* @param ttlSeconds TTL seconds, value should be 0 or greater
|
|
* @param ttlSeconds TTL seconds, value should be 0 or greater
|
|
@@ -89,7 +95,29 @@ public class AlterCollectionParam {
|
|
if (ttlSeconds < 0) {
|
|
if (ttlSeconds < 0) {
|
|
throw new ParamException("The ttlSeconds value should be 0 or greater");
|
|
throw new ParamException("The ttlSeconds value should be 0 or greater");
|
|
}
|
|
}
|
|
- this.ttlSeconds = ttlSeconds;
|
|
|
|
|
|
+
|
|
|
|
+ return this.withProperty(Constant.TTL_SECONDS, Integer.toString(ttlSeconds));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Enable MMap or not for index data files.
|
|
|
|
+ *
|
|
|
|
+ * @param enabledMMap enabled or not
|
|
|
|
+ * @return <code>Builder</code>
|
|
|
|
+ */
|
|
|
|
+ public Builder withMMapEnabled(boolean enabledMMap) {
|
|
|
|
+ return this.withProperty(Constant.MMAP_ENABLED, Boolean.toString(enabledMMap));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Basic method to set a key-value property.
|
|
|
|
+ *
|
|
|
|
+ * @param key the key
|
|
|
|
+ * @param value the value
|
|
|
|
+ * @return <code>Builder</code>
|
|
|
|
+ */
|
|
|
|
+ public Builder withProperty(@NonNull String key, @NonNull String value) {
|
|
|
|
+ this.properties.put(key, value);
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -114,6 +142,7 @@ public class AlterCollectionParam {
|
|
public String toString() {
|
|
public String toString() {
|
|
return "AlterCollectionParam{" +
|
|
return "AlterCollectionParam{" +
|
|
"collectionName='" + collectionName + '\'' +
|
|
"collectionName='" + collectionName + '\'' +
|
|
|
|
+ "dbName='" + databaseName + '\'' +
|
|
", properties='" + properties.toString() + '\'' +
|
|
", properties='" + properties.toString() + '\'' +
|
|
'}';
|
|
'}';
|
|
}
|
|
}
|