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>
- 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
Modifier and TypeFieldDescriptionprotected static final org.apache.avro.Schema
protected static final String
protected static final org.apache.avro.Schema
protected static final String
protected static final org.apache.avro.Schema
protected static final String
protected final org.apache.avro.Schema
protected final int
protected static final String
protected static final Map<Map<String,
Object>, SchemaAndToString> protected final String
protected final AvroGenericReadComputeStoreClient
-
Constructor Summary
ConstructorDescriptionAbstractAvroComputeRequestBuilder
(AvroGenericReadComputeStoreClient storeClient, SchemaReader schemaReader) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkComputeFieldValidity
(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 ComputeRequestWrapper
generateComputeRequest
(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 SchemaAndToString
hadamardProduct
(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.void
streamingExecute
(Set<K> keys, StreamingCallback<K, ComputeGenericRecord> callback) Streaming interface forComputeRequestBuilder.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, wait
Methods 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 final int latestValueSchemaId -
latestValueSchema
protected final 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:ComputeRequestBuilder
Setup project fields, and right now only top-level fields are supported.- Specified by:
project
in interfaceComputeRequestBuilder<K>
- Returns:
- Throws:
VeniceClientException
-
project
Description copied from interface:ComputeRequestBuilder
Setup project fields, and right now only top-level fields are supported.- Specified by:
project
in interfaceComputeRequestBuilder<K>
- Returns:
- Throws:
VeniceClientException
-
dotProduct
public ComputeRequestBuilder<K> dotProduct(String inputFieldName, List<Float> dotProductParam, String resultFieldName) throws VeniceClientException Description copied from interface:ComputeRequestBuilder
Setup dot-product operation.- Specified by:
dotProduct
in 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:ComputeRequestBuilder
Setup cosine-similarity operation.- Specified by:
cosineSimilarity
in 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:ComputeRequestBuilder
Send compute request to Venice, and this should be the last step of the compute specification.- Specified by:
execute
in interfaceComputeRequestBuilder<K>
- Parameters:
keys
- : keys for the candidate records- Returns:
- Throws:
VeniceClientException
-
streamingExecute
Description copied from interface:ComputeRequestBuilder
Send compute request to Venice, and this should be the last step of the compute specification. The difference between this function and the previousComputeRequestBuilder.execute(Set)
is that this function will return the available response instead of throwing aTimeoutException
when timeout happens: streamingExecute(keys).get(timeout, units);- Specified by:
streamingExecute
in interfaceComputeRequestBuilder<K>
- Returns:
-
streamingExecute
public void streamingExecute(Set<K> keys, StreamingCallback<K, ComputeGenericRecord> callback) throws VeniceClientExceptionDescription copied from interface:ComputeRequestBuilder
Streaming interface forComputeRequestBuilder.execute(Set)
, and you could find more info inStreamingCallback
.- Specified by:
streamingExecute
in 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:ComputeRequestBuilder
Setup hadamard-product operation; if this api is invoked, use version 2 in the compute request version header.- Specified by:
hadamardProduct
in 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)
-