Package com.linkedin.venice.client.store
Class AbstractAvroComputeRequestBuilder<K>
java.lang.Object
com.linkedin.venice.client.store.AbstractAvroComputeRequestBuilder<K>
- Type Parameters:
K-
- All Implemented Interfaces:
ComputeRequestBuilder<K>,ExecutableRequestBuilder<K,Map<K, ComputeGenericRecord>>
- Direct Known Subclasses:
AvroComputeRequestBuilderV3
public abstract class AbstractAvroComputeRequestBuilder<K>
extends Object
implements ComputeRequestBuilder<K>
This abstract class contains all the common field and APIs for compute request builder;
for each new compute request version, there will be a new builder class that extends
this class and the new builder will include customized fields and APIs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.apache.avro.Schemaprotected static final Stringprotected static final org.apache.avro.Schemaprotected static final Stringprotected static final org.apache.avro.Schemaprotected static final Stringprotected org.apache.avro.Schemaprotected intprotected static final Stringprotected static final Map<Map<String,Object>, SchemaAndToString> protected final Stringprotected final AvroGenericReadComputeStoreClient -
Constructor Summary
ConstructorsConstructorDescriptionAbstractAvroComputeRequestBuilder(AvroGenericReadComputeStoreClient storeClient, SchemaReader schemaReader) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckComputeFieldValidity(String computeFieldName, String resultFieldName, Set<String> resultFieldsSet, ComputeOperationType computeType) Compute operation validity check for projections, dot-product and cosine-similarity.cosineSimilarity(String inputFieldName, List<Float> cosSimilarityParam, String resultFieldName) Setup cosine-similarity operation.dotProduct(String inputFieldName, List<Float> dotProductParam, String resultFieldName) Setup dot-product operation.Send compute request to Venice, and this should be the last step of the compute specification.protected ComputeRequestWrappergenerateComputeRequest(SchemaAndToString resultSchema, boolean originallyStreaming) Generate compute spec for projections, dot-product and cosine-similarity.protected List<org.apache.avro.Schema.Field>Generate compute result schema fields for projections, dot-product and cosine-similarity.protected List<ComputeOperation>Generate compute operations for projections, dot-product and cosine-similarity.protected SchemaAndToStringhadamardProduct(String inputFieldName, List<Float> hadamardProductParam, String resultFieldName) Setup hadamard-product operation; if this api is invoked, use version 2 in the compute request version header.Setup project fields, and right now only top-level fields are supported.project(Collection<String> fieldNames) Setup project fields, and right now only top-level fields are supported.setStats(Optional<ClientStats> streamingStats) setTime(io.tehuti.utils.Time time) test-onlysetValidateProjectionFields(boolean projectionFieldValidation) streamingExecute(Set<K> keys) Send compute request to Venice, and this should be the last step of the compute specification.voidstreamingExecute(Set<K> keys, StreamingCallback<K, ComputeGenericRecord> callback) Streaming interface forExecutableRequestBuilder.execute(Set), and you could find more info inStreamingCallback.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linkedin.venice.client.store.ComputeRequestBuilder
count, executeWithFilter
-
Field Details
-
RESULT_SCHEMA_CACHE
-
PROJECTION_SPEC
- See Also:
-
DOT_PRODUCT_SPEC
- See Also:
-
COSINE_SIMILARITY_SPEC
- See Also:
-
HADAMARD_PRODUCT_SPEC
- See Also:
-
HADAMARD_PRODUCT_RESULT_SCHEMA
protected static final org.apache.avro.Schema HADAMARD_PRODUCT_RESULT_SCHEMA -
DOT_PRODUCT_RESULT_SCHEMA
protected static final org.apache.avro.Schema DOT_PRODUCT_RESULT_SCHEMA -
COSINE_SIMILARITY_RESULT_SCHEMA
protected static final org.apache.avro.Schema COSINE_SIMILARITY_RESULT_SCHEMA -
storeClient
-
latestValueSchemaId
protected int latestValueSchemaId -
latestValueSchema
protected org.apache.avro.Schema latestValueSchema -
resultSchemaName
-
-
Constructor Details
-
AbstractAvroComputeRequestBuilder
public AbstractAvroComputeRequestBuilder(AvroGenericReadComputeStoreClient storeClient, SchemaReader schemaReader)
-
-
Method Details
-
setTime
test-only -
setStats
-
setValidateProjectionFields
public AbstractAvroComputeRequestBuilder<K> setValidateProjectionFields(boolean projectionFieldValidation) -
project
Description copied from interface:ComputeRequestBuilderSetup project fields, and right now only top-level fields are supported.- Specified by:
projectin interfaceComputeRequestBuilder<K>- Returns:
- Throws:
VeniceClientException
-
project
Description copied from interface:ComputeRequestBuilderSetup project fields, and right now only top-level fields are supported.- Specified by:
projectin interfaceComputeRequestBuilder<K>- Returns:
- Throws:
VeniceClientException
-
dotProduct
public ComputeRequestBuilder<K> dotProduct(String inputFieldName, List<Float> dotProductParam, String resultFieldName) throws VeniceClientException Description copied from interface:ComputeRequestBuilderSetup dot-product operation.- Specified by:
dotProductin interfaceComputeRequestBuilder<K>- Parameters:
inputFieldName- : top-level field in the value record as the input of dot-product operationdotProductParam- : dot-product paramresultFieldName- : result field name in the response record- Returns:
- Throws:
VeniceClientException
-
cosineSimilarity
public ComputeRequestBuilder<K> cosineSimilarity(String inputFieldName, List<Float> cosSimilarityParam, String resultFieldName) throws VeniceClientException Description copied from interface:ComputeRequestBuilderSetup cosine-similarity operation.- Specified by:
cosineSimilarityin interfaceComputeRequestBuilder<K>- Parameters:
inputFieldName- : top-level field in the value record as the input of cosine-similarity operationcosSimilarityParam- : cosine-similarity paramresultFieldName- : result field name in the response record- Returns:
- Throws:
VeniceClientException
-
getCommonComputeSpec
Generate compute spec for projections, dot-product and cosine-similarity.- Returns:
- common compute spec
-
commonValidityCheck
Compute operation validity check for projections, dot-product and cosine-similarity.- Returns:
- a set of existing operations result field name
-
getCommonResultFields
Generate compute result schema fields for projections, dot-product and cosine-similarity.- Returns:
- a list of existing compute result schema fields
-
getComputeRequestOperations
Generate compute operations for projections, dot-product and cosine-similarity.- Returns:
- a list of existing compute operations
-
execute
public CompletableFuture<Map<K,ComputeGenericRecord>> execute(Set<K> keys) throws VeniceClientException Description copied from interface:ExecutableRequestBuilderSend compute request to Venice, and this should be the last step of the compute specification.- Specified by:
executein interfaceExecutableRequestBuilder<K,Map<K, ComputeGenericRecord>> - Parameters:
keys- : keys for the candidate records- Returns:
- Throws:
VeniceClientException
-
streamingExecute
Description copied from interface:ComputeRequestBuilderSend compute request to Venice, and this should be the last step of the compute specification. The difference between this function and the previousExecutableRequestBuilder.execute(Set)is that this function will return the available response instead of throwing aTimeoutExceptionwhen timeout happens: streamingExecute(keys).get(timeout, units);- Specified by:
streamingExecutein interfaceComputeRequestBuilder<K>- Returns:
-
streamingExecute
public void streamingExecute(Set<K> keys, StreamingCallback<K, ComputeGenericRecord> callback) throws VeniceClientExceptionDescription copied from interface:ComputeRequestBuilderStreaming interface forExecutableRequestBuilder.execute(Set), and you could find more info inStreamingCallback.- Specified by:
streamingExecutein interfaceComputeRequestBuilder<K>- Throws:
VeniceClientException
-
checkComputeFieldValidity
protected void checkComputeFieldValidity(String computeFieldName, String resultFieldName, Set<String> resultFieldsSet, ComputeOperationType computeType) -
getResultSchema
-
hadamardProduct
public ComputeRequestBuilder<K> hadamardProduct(String inputFieldName, List<Float> hadamardProductParam, String resultFieldName) throws VeniceClientException Description copied from interface:ComputeRequestBuilderSetup hadamard-product operation; if this api is invoked, use version 2 in the compute request version header.- Specified by:
hadamardProductin interfaceComputeRequestBuilder<K>- Parameters:
inputFieldName- : top-level field in the value record as the input of hadamard-product operationhadamardProductParam- : hadamard-product paramresultFieldName- : result field name in the response record- Returns:
- Throws:
VeniceClientException
-
generateComputeRequest
protected ComputeRequestWrapper generateComputeRequest(SchemaAndToString resultSchema, boolean originallyStreaming)
-