Skip to content

Commit

Permalink
support indexType not specify
Browse files Browse the repository at this point in the history
Signed-off-by: lentitude2tk <[email protected]>
  • Loading branch information
lentitude2tk committed Jan 10, 2024
1 parent 7b91d7e commit 0d3e68f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/java/io/milvus/param/IndexType.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
public enum IndexType {
INVALID,
None(0),
//Only supported for float vectors
FLAT(1),
IVF_FLAT(2),
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/io/milvus/param/ParamUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static boolean IsBinaryMetric(MetricType metric) {
* @param idx index type
*/
public static boolean IsVectorIndex(IndexType idx) {
return idx != IndexType.INVALID && idx.getCode() < IndexType.TRIE.getCode();
return idx != IndexType.INVALID && idx != IndexType.None && idx.getCode() < IndexType.TRIE.getCode();
}

/**
Expand All @@ -231,7 +231,10 @@ public static boolean IsVectorIndex(IndexType idx) {
* @param dataType data type
*/
public static boolean VerifyIndexType(IndexType indexType, DataType dataType) {
if (dataType == DataType.FloatVector) {
// if user not specify the indexType, auto select by kernal
if (indexType == IndexType.None) {
return true;
} else if (dataType == DataType.FloatVector) {
return (IsVectorIndex(indexType) && (indexType != IndexType.BIN_FLAT) && (indexType != IndexType.BIN_IVF_FLAT));
} else if (dataType == DataType.BinaryVector) {
return indexType == IndexType.BIN_FLAT || indexType == IndexType.BIN_IVF_FLAT;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/milvus/param/index/CreateIndexParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private CreateIndexParam(@NonNull Builder builder) {
this.fieldName = builder.fieldName;
this.indexName = builder.indexName;
this.indexType = builder.indexType;
if (builder.indexType != IndexType.INVALID) {
if (builder.indexType != IndexType.INVALID && builder.indexType != IndexType.None) {
this.extraParam.put(Constant.INDEX_TYPE, builder.indexType.getName());
}
if (builder.metricType != MetricType.INVALID) {
Expand All @@ -80,7 +80,7 @@ public static final class Builder {
private String databaseName;
private String collectionName;
private String fieldName;
private IndexType indexType = IndexType.INVALID;
private IndexType indexType = IndexType.None;
private String indexName = Constant.DEFAULT_INDEX_NAME;
private MetricType metricType = MetricType.INVALID;
private String extraParam;
Expand Down

0 comments on commit 0d3e68f

Please sign in to comment.