-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: ShardKeyFactory * feat: ShardKeySelectorFactory * feat: shard key ops * feat: shard key ops overloads * feat: discover ops * refactor: upade discoverBatchAsync * feat: targetVectorFactory, VectorFactory * test: discover searches * refactor: VectorsFactory to use vector() * Apply suggestions from code review Co-authored-by: Russ Cam <russ.cam@forloop.co.uk> * chore: review changes * docs: Update README.md version --------- Co-authored-by: Anush <anush@Anushs-Air-M2.local> Co-authored-by: Russ Cam <russ.cam@forloop.co.uk>
- Loading branch information
1 parent
dc75e03
commit 8d37efd
Showing
10 changed files
with
393 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,4 +228,4 @@ publishing { | |
repositories { | ||
mavenLocal() | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.qdrant.client; | ||
|
||
import io.qdrant.client.grpc.Collections.ShardKey; | ||
|
||
/** | ||
* Convenience methods for constructing {@link ShardKey} | ||
*/ | ||
public final class ShardKeyFactory { | ||
private ShardKeyFactory() { | ||
} | ||
|
||
/** | ||
* Creates a {@link ShardKey} based on a keyword. | ||
* | ||
* @param keyword The keyword to create the shard key from | ||
* @return The {@link ShardKey} object | ||
*/ | ||
public static ShardKey shardKey(String keyword) { | ||
return ShardKey.newBuilder().setKeyword(keyword).build(); | ||
} | ||
|
||
/** | ||
* Creates a {@link ShardKey} based on a number. | ||
* | ||
* @param number The number to create the shard key from | ||
* @return The {@link ShardKey} object | ||
*/ | ||
public static ShardKey shardKey(long number) { | ||
return ShardKey.newBuilder().setNumber(number).build(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/io/qdrant/client/ShardKeySelectorFactory.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,54 @@ | ||
package io.qdrant.client; | ||
|
||
import io.qdrant.client.grpc.Collections.ShardKey; | ||
import io.qdrant.client.grpc.Points.ShardKeySelector; | ||
|
||
import static io.qdrant.client.ShardKeyFactory.shardKey; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Convenience methods for constructing {@link ShardKeySelector} | ||
*/ | ||
public class ShardKeySelectorFactory { | ||
private ShardKeySelectorFactory() { | ||
} | ||
|
||
/** | ||
* Creates a {@link ShardKeySelector} with the given shard keys. | ||
* | ||
* @param shardKeys The shard keys to include in the selector. | ||
* @return The created {@link ShardKeySelector} object. | ||
*/ | ||
public static ShardKeySelector shardKeySelector(ShardKey... shardKeys) { | ||
return ShardKeySelector.newBuilder().addAllShardKeys(Arrays.asList(shardKeys)).build(); | ||
} | ||
|
||
/** | ||
* Creates a {@link ShardKeySelector} with the given shard key keywords. | ||
* | ||
* @param keywords The shard key keywords to include in the selector. | ||
* @return The created {@link ShardKeySelector} object. | ||
*/ | ||
public static ShardKeySelector shardKeySelector(String... keywords) { | ||
ShardKeySelector.Builder builder = ShardKeySelector.newBuilder(); | ||
for (String keyword : keywords) { | ||
builder.addShardKeys(shardKey(keyword)); | ||
} | ||
return builder.build(); | ||
} | ||
|
||
/** | ||
* Creates a {@link ShardKeySelector} with the given shard key numbers. | ||
* | ||
* @param numbers The shard key numbers to include in the selector. | ||
* @return The created {@link ShardKeySelector} object. | ||
*/ | ||
public static ShardKeySelector shardKeySelector(long... numbers) { | ||
ShardKeySelector.Builder builder = ShardKeySelector.newBuilder(); | ||
for (long number : numbers) { | ||
builder.addShardKeys(shardKey(number)); | ||
} | ||
return builder.build(); | ||
} | ||
} |
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,32 @@ | ||
package io.qdrant.client; | ||
|
||
import io.qdrant.client.grpc.Points.PointId; | ||
import io.qdrant.client.grpc.Points.TargetVector; | ||
import io.qdrant.client.grpc.Points.Vector; | ||
import io.qdrant.client.grpc.Points.VectorExample; | ||
|
||
/** | ||
* Convenience methods for constructing {@link TargetVector} | ||
*/ | ||
public class TargetVectorFactory { | ||
private TargetVectorFactory() { | ||
} | ||
|
||
/** | ||
* Creates a TargetVector from a point ID | ||
* @param id The point ID to use | ||
* @return A new instance of {@link TargetVector} | ||
*/ | ||
public static TargetVector targetVector(PointId id) { | ||
return TargetVector.newBuilder().setSingle(VectorExample.newBuilder().setId(id)).build(); | ||
} | ||
|
||
/** | ||
* Creates a TargetVector from a Vector | ||
* @param vector The Vector value to use | ||
* @return A new instance of {@link TargetVector} | ||
*/ | ||
public static TargetVector targetVector(Vector vector) { | ||
return TargetVector.newBuilder().setSingle(VectorExample.newBuilder().setVector(vector)).build(); | ||
} | ||
} |
Oops, something went wrong.