-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FSTORE-1314] Support defining similar function in embedding index (#…
…1783) * use sim function * add license * update license * refactor getOpensearchFunction (cherry picked from commit 5bf8980)
- Loading branch information
1 parent
96cfe19
commit 83ec6f6
Showing
8 changed files
with
135 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...o/hops/hopsworks/persistence/entity/featurestore/featuregroup/SimilarityFunctionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* This file is part of Hopsworks | ||
* Copyright (C) 2024, Hopsworks AB. All rights reserved | ||
* | ||
* Hopsworks is free software: you can redistribute it and/or modify it under the terms of | ||
* the GNU Affero General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* Hopsworks is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
* PURPOSE. See the GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along with this program. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.hops.hopsworks.persistence.entity.featurestore.featuregroup; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public enum SimilarityFunctionType { | ||
|
||
@JsonProperty(value = "l2_norm") | ||
L2_NORM("l2"), | ||
@JsonProperty(value = "cosine") | ||
COSINE("cosinesimil"), | ||
@JsonProperty(value = "dot_product") | ||
DOT_PRODUCT("innerproduct"); | ||
|
||
private final String opensearchFunction; | ||
|
||
SimilarityFunctionType(String opensearchFunction) { | ||
this.opensearchFunction = opensearchFunction; | ||
} | ||
|
||
public String getOpensearchFunction() { | ||
return opensearchFunction; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...psworks/persistence/entity/featurestore/featuregroup/SimilarityFunctionTypeConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* This file is part of Hopsworks | ||
* Copyright (C) 2024, Hopsworks AB. All rights reserved | ||
* | ||
* Hopsworks is free software: you can redistribute it and/or modify it under the terms of | ||
* the GNU Affero General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* Hopsworks is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
* PURPOSE. See the GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along with this program. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.hops.hopsworks.persistence.entity.featurestore.featuregroup; | ||
|
||
import javax.persistence.AttributeConverter; | ||
import javax.persistence.Converter; | ||
|
||
@Converter(autoApply = true) | ||
public class SimilarityFunctionTypeConverter implements AttributeConverter<SimilarityFunctionType, String> { | ||
@Override | ||
public String convertToDatabaseColumn(SimilarityFunctionType attribute) { | ||
return attribute.name().toLowerCase(); // Convert enum value to lowercase string | ||
} | ||
|
||
@Override | ||
public SimilarityFunctionType convertToEntityAttribute(String dbData) { | ||
return SimilarityFunctionType.valueOf(dbData.toUpperCase()); // Convert lowercase string to uppercase enum value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters