Package com.linkedin.venice.client.store
Class FacetCountingUtils
java.lang.Object
com.linkedin.venice.client.store.FacetCountingUtils
This class provides shared implementation for processing values and counting field occurrences
that can be used by thin-client, fast-client, and server components.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
convertToType
(Object value, Class<T> targetType) Generic method to convert value to the target type for predicate evaluation.getBucketNameToCount
(Iterable<? extends org.apache.avro.generic.GenericRecord> records, String fieldName, Map<String, Predicate> buckets) Get bucket counts for a single field with predicate-based bucketing.getValueToCount
(Iterable<? extends org.apache.avro.generic.GenericRecord> records, String field, int topK) Get value counts for a single field with TopK filtering.static void
validateFieldNames
(String[] fieldNames, org.apache.avro.Schema valueSchema) Validate field names exist in schema (generic version for both clients).
-
Constructor Details
-
FacetCountingUtils
public FacetCountingUtils()
-
-
Method Details
-
getValueToCount
public static <T> Map<T,Integer> getValueToCount(Iterable<? extends org.apache.avro.generic.GenericRecord> records, String field, int topK) Get value counts for a single field with TopK filtering. This is the original logic from AvroComputeAggregationResponse.getValueToCount() moved to Utils.- Parameters:
records
- Collection of GenericRecord results (supports both ComputeGenericRecord and server GenericRecord)field
- The field name to counttopK
- Maximum number of top values to return- Returns:
- Map of values to their counts, limited to topK entries
-
getBucketNameToCount
public static Map<String,Integer> getBucketNameToCount(Iterable<? extends org.apache.avro.generic.GenericRecord> records, String fieldName, Map<String, Predicate> buckets) Get bucket counts for a single field with predicate-based bucketing. This is the original logic from AvroComputeAggregationResponse.getBucketNameToCount() moved to Utils.- Parameters:
records
- Collection of GenericRecord results (supports both ComputeGenericRecord and server GenericRecord)fieldName
- The field name to countbuckets
- Map of bucket names to their predicates- Returns:
- Map of bucket names to their counts
-
convertToType
Generic method to convert value to the target type for predicate evaluation. Supports Integer, Long, Float, and Double conversions. -
validateFieldNames
Validate field names exist in schema (generic version for both clients).- Parameters:
fieldNames
- Array of field names to validatevalueSchema
- The schema to validate against- Throws:
IllegalArgumentException
- if validation fails
-