added descriptive javadoc comments

This commit is contained in:
Mark Wolters 2023-05-24 16:28:52 +00:00
parent 562129f8c5
commit 39166522ec
6 changed files with 104 additions and 0 deletions

View File

@ -58,6 +58,15 @@ public class PineconeDeleteOpDispenser extends PineconeOpDispenser {
deleteRequestFunc.apply(value)); deleteRequestFunc.apply(value));
} }
/**
* @param op The ParsedOp used to build the Request
* @return A function that will take a long (the current cycle) and return a Pinecone DeleteRequest
*
* The pattern used here is to accommodate the way Request types are constructed for Pinecone.
* Requests use a Builder pattern, so at time of instantiation the methods should be chained together.
* For each method in the chain a function is created here and added to the chain of functions
* called at time of instantiation.
*/
private LongFunction<DeleteRequest> createDeleteRequestFunction(ParsedOp op) { private LongFunction<DeleteRequest> createDeleteRequestFunction(ParsedOp op) {
LongFunction<DeleteRequest.Builder> rFunc = l -> DeleteRequest.newBuilder(); LongFunction<DeleteRequest.Builder> rFunc = l -> DeleteRequest.newBuilder();

View File

@ -50,6 +50,17 @@ public class PineconeDescribeIndexStatsOpDispenser extends PineconeOpDispenser {
indexStatsRequestFunc = createDescribeIndexStatsRequestFunction(op); indexStatsRequestFunc = createDescribeIndexStatsRequestFunction(op);
} }
/**
* @param op The ParsedOp used to build the Request
* @return A function that will take a long (the current cycle) and return a Pinecone DescribeIndexStatsRequest
*
* The pattern used here is to accommodate the way Request types are constructed for Pinecone.
* Requests use a Builder pattern, so at time of instantiation the methods should be chained together.
* For each method in the chain a function is created here and added to the chain of functions
* called at time of instantiation. Additionally some of the arguments to the builder methods require
* creation through their own builder process. In these cases the pattern adopted includes multiple layers of
* functions in order to build all objects in the correct manner and ordering.
*/
private LongFunction<DescribeIndexStatsRequest> createDescribeIndexStatsRequestFunction(ParsedOp op) { private LongFunction<DescribeIndexStatsRequest> createDescribeIndexStatsRequestFunction(ParsedOp op) {
LongFunction<DescribeIndexStatsRequest.Builder> rFunc = l -> DescribeIndexStatsRequest.newBuilder(); LongFunction<DescribeIndexStatsRequest.Builder> rFunc = l -> DescribeIndexStatsRequest.newBuilder();
Optional<LongFunction<String>> filterFunction = op.getAsOptionalFunction("filter", String.class); Optional<LongFunction<String>> filterFunction = op.getAsOptionalFunction("filter", String.class);

View File

@ -50,6 +50,15 @@ public class PineconeFetchOpDispenser extends PineconeOpDispenser {
fetchRequestFunc = createFetchRequestFunction(op); fetchRequestFunc = createFetchRequestFunction(op);
} }
/**
* @param op The ParsedOp used to build the Request
* @return A function that will take a long (the current cycle) and return a Pinecone FetchRequest
*
* The pattern used here is to accommodate the way Request types are constructed for Pinecone.
* Requests use a Builder pattern, so at time of instantiation the methods should be chained together.
* For each method in the chain a function is created here and added to the chain of functions
* called at time of instantiation.
*/
private LongFunction<FetchRequest> createFetchRequestFunction(ParsedOp op) { private LongFunction<FetchRequest> createFetchRequestFunction(ParsedOp op) {
LongFunction<FetchRequest.Builder> rFunc = l -> FetchRequest.newBuilder(); LongFunction<FetchRequest.Builder> rFunc = l -> FetchRequest.newBuilder();

View File

@ -55,6 +55,19 @@ public class PineconeQueryOpDispenser extends PineconeOpDispenser {
queryVectorFunc = createQueryVectorFunc(op); queryVectorFunc = createQueryVectorFunc(op);
} }
/**
* @param op The ParsedOp used to build the Request
* @return A function that will take a long (the current cycle) and return a Pinecone QueryRequest Builder
*
* The pattern used here is to accommodate the way Request types are constructed for Pinecone.
* Requests use a Builder pattern, so at time of instantiation the methods should be chained together.
* For each method in the chain a function is created here and added to the chain of functions
* called at time of instantiation.
*
* The QueryVector objects used by the QueryRequest as sufficiently sophisticated in their own building process
* that it has been broken out into a separate method. At runtime they are built separately and then added
* to the build chain by the builder returned by this method.
*/
private LongFunction<QueryRequest.Builder> createQueryRequestFunc(ParsedOp op) { private LongFunction<QueryRequest.Builder> createQueryRequestFunc(ParsedOp op) {
LongFunction<QueryRequest.Builder> rFunc = l -> QueryRequest.newBuilder(); LongFunction<QueryRequest.Builder> rFunc = l -> QueryRequest.newBuilder();
@ -117,6 +130,15 @@ public class PineconeQueryOpDispenser extends PineconeOpDispenser {
return rFunc; return rFunc;
} }
/**
* @param op the ParsedOp from which the Query Vector objects will be built
* @return an Iterable Collection of QueryVector objects to be added to a Pinecone QueryRequest
*
* This method interrogates the subsection of the ParsedOp defined for QueryVector parameters and constructs
* a list of QueryVectors based on the included values, or returns null if this section is not populated. The
* base function returns either the List of vectors or null, while the interior function builds the vectors
* with a Builder pattern based on the values contained in the source ParsedOp.
*/
private LongFunction<Collection<QueryVector>> createQueryVectorFunc(ParsedOp op) { private LongFunction<Collection<QueryVector>> createQueryVectorFunc(ParsedOp op) {
Optional<LongFunction<List>> baseFunc = Optional<LongFunction<List>> baseFunc =
op.getAsOptionalFunction("query_vectors", List.class); op.getAsOptionalFunction("query_vectors", List.class);

View File

@ -56,6 +56,15 @@ public class PineconeUpdateOpDispenser extends PineconeOpDispenser {
sparseValuesFunc = createSparseValuesFunction(op); sparseValuesFunc = createSparseValuesFunction(op);
} }
/**
* @param op the ParsedOp from which the SparseValues object will be built
* @return a SparseValues Object to be added to a Pinecone UpdateRequest
*
* This method interrogates the subsection of the ParsedOp defined for SparseValues parameters and constructs
* a SparseValues Object based on the included values, or returns null if this section is not populated. The
* base function returns either the SparseValues Object or null, while the interior function builds the SparseValues
* with a Builder pattern based on the values contained in the source ParsedOp.
*/
private LongFunction<SparseValues> createSparseValuesFunction(ParsedOp op) { private LongFunction<SparseValues> createSparseValuesFunction(ParsedOp op) {
Optional<LongFunction<Map>> mFunc = op.getAsOptionalFunction("sparse_values", Map.class); Optional<LongFunction<Map>> mFunc = op.getAsOptionalFunction("sparse_values", Map.class);
return mFunc.<LongFunction<SparseValues>>map(mapLongFunction -> l -> { return mFunc.<LongFunction<SparseValues>>map(mapLongFunction -> l -> {
@ -77,6 +86,15 @@ public class PineconeUpdateOpDispenser extends PineconeOpDispenser {
}).orElse(null); }).orElse(null);
} }
/**
* @param op the ParsedOp from which the Metadata objects will be built
* @return an Metadata Struct to be added to a Pinecone UpdateRequest
*
* This method interrogates the subsection of the ParsedOp defined for metadata parameters and constructs
* a Metadata Struct based on the included values, or returns null if this section is not populated. The
* base function returns either the Metadata Struct or null, while the interior function builds the Metadata
* with a Builder pattern based on the values contained in the source ParsedOp.
*/
private LongFunction<Struct> createUpdateMetadataFunction(ParsedOp op) { private LongFunction<Struct> createUpdateMetadataFunction(ParsedOp op) {
Optional<LongFunction<Map>> mFunc = op.getAsOptionalFunction("metadata", Map.class); Optional<LongFunction<Map>> mFunc = op.getAsOptionalFunction("metadata", Map.class);
return mFunc.<LongFunction<Struct>>map(mapLongFunction -> l -> { return mFunc.<LongFunction<Struct>>map(mapLongFunction -> l -> {
@ -93,6 +111,19 @@ public class PineconeUpdateOpDispenser extends PineconeOpDispenser {
}).orElse(null); }).orElse(null);
} }
/**
* @param op The ParsedOp used to build the Request
* @return A function that will take a long (the current cycle) and return a Pinecone UpdateRequest Builder
*
* The pattern used here is to accommodate the way Request types are constructed for Pinecone.
* Requests use a Builder pattern, so at time of instantiation the methods should be chained together.
* For each method in the chain a function is created here and added to the chain of functions
* called at time of instantiation.
*
* The Metadata and SparseValues objects used by the UpdateRequest are sufficiently sophisticated in their own
* building process that they have been broken out into separate methods. At runtime they are built separately
* and then added to the build chain by the builder returned by this method.
*/
private LongFunction<UpdateRequest.Builder> createUpdateRequestFunction(ParsedOp op) { private LongFunction<UpdateRequest.Builder> createUpdateRequestFunction(ParsedOp op) {
LongFunction<UpdateRequest.Builder> rFunc = l -> UpdateRequest.newBuilder(); LongFunction<UpdateRequest.Builder> rFunc = l -> UpdateRequest.newBuilder();

View File

@ -55,6 +55,15 @@ public class PineconeUpsertOpDispenser extends PineconeOpDispenser {
upsertVectorFunc = createUpsertRequestVectorsFunc(op); upsertVectorFunc = createUpsertRequestVectorsFunc(op);
} }
/**
* @param op the ParsedOp from which the Vector objects will be built
* @return an Iterable Collection of Vector objects to be added to a Pinecone UpsertRequest
*
* This method interrogates the subsection of the ParsedOp defined for Vector parameters and constructs
* a list of Vectors based on the included values, or returns null if this section is not populated. The
* base function returns either the List of vectors or null, while the interior function builds the vectors
* with a Builder pattern based on the values contained in the source ParsedOp.
*/
private LongFunction<Collection<Vector>> createUpsertRequestVectorsFunc(ParsedOp op) { private LongFunction<Collection<Vector>> createUpsertRequestVectorsFunc(ParsedOp op) {
Optional<LongFunction<List>> baseFunc = Optional<LongFunction<List>> baseFunc =
op.getAsOptionalFunction("upsert_vectors", List.class); op.getAsOptionalFunction("upsert_vectors", List.class);
@ -104,6 +113,19 @@ public class PineconeUpsertOpDispenser extends PineconeOpDispenser {
}).orElse(null); }).orElse(null);
} }
/**
* @param op The ParsedOp used to build the Request
* @return A function that will take a long (the current cycle) and return a Pinecone UpsertRequest Builder
*
* The pattern used here is to accommodate the way Request types are constructed for Pinecone.
* Requests use a Builder pattern, so at time of instantiation the methods should be chained together.
* For each method in the chain a function is created here and added to the chain of functions
* called at time of instantiation.
*
* The Vector objects used by the UpsertRequest are sufficiently sophisticated in their own
* building process that they have been broken out into a separate method. At runtime they are built separately
* and then added to the build chain by the builder returned by this method.
*/
private LongFunction<UpsertRequest.Builder> createUpsertRequestFunc(ParsedOp op) { private LongFunction<UpsertRequest.Builder> createUpsertRequestFunc(ParsedOp op) {
LongFunction<UpsertRequest.Builder> rFunc = l -> UpsertRequest.newBuilder(); LongFunction<UpsertRequest.Builder> rFunc = l -> UpsertRequest.newBuilder();