Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Mar 17, 2022
1 parent aa391bf commit f619658
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
15 changes: 8 additions & 7 deletions src/aggregation/agg_req.rs
Expand Up @@ -61,20 +61,20 @@ pub type Aggregations = HashMap<String, Aggregation>;

/// Like Aggregations, but optimized to work with the aggregation result
#[derive(Clone, Debug)]
pub(crate) struct CollectorAggregations {
pub(crate) struct AggregationsInternal {
pub(crate) metrics: VecWithNames<MetricAggregation>,
pub(crate) buckets: VecWithNames<CollectorBucketAggregation>,
pub(crate) buckets: VecWithNames<BucketAggregationInternal>,
}

impl From<Aggregations> for CollectorAggregations {
impl From<Aggregations> for AggregationsInternal {
fn from(aggs: Aggregations) -> Self {
let mut metrics = vec![];
let mut buckets = vec![];
for (key, agg) in aggs {
match agg {
Aggregation::Bucket(bucket) => buckets.push((
key,
CollectorBucketAggregation {
BucketAggregationInternal {
bucket_agg: bucket.bucket_agg,
sub_aggregation: bucket.sub_aggregation.into(),
},
Expand All @@ -90,15 +90,16 @@ impl From<Aggregations> for CollectorAggregations {
}

#[derive(Clone, Debug)]
pub(crate) struct CollectorBucketAggregation {
// Like BucketAggregation, but optimized to work with the result
pub(crate) struct BucketAggregationInternal {
/// Bucket aggregation strategy to group documents.
pub bucket_agg: BucketAggregationType,
/// The sub_aggregations in the buckets. Each bucket will aggregate on the document set in the
/// bucket.
pub sub_aggregation: CollectorAggregations,
pub sub_aggregation: AggregationsInternal,
}

impl CollectorBucketAggregation {
impl BucketAggregationInternal {
pub(crate) fn as_histogram(&self) -> &HistogramAggregation {
match &self.bucket_agg {
BucketAggregationType::Range(_) => panic!("unexpected aggregation"),
Expand Down
10 changes: 5 additions & 5 deletions src/aggregation/agg_result.rs
Expand Up @@ -10,7 +10,7 @@ use std::collections::HashMap;
use itertools::Itertools;
use serde::{Deserialize, Serialize};

use super::agg_req::{Aggregations, CollectorAggregations, CollectorBucketAggregation};
use super::agg_req::{Aggregations, AggregationsInternal, BucketAggregationInternal};
use super::bucket::intermediate_buckets_to_final_buckets;
use super::intermediate_agg_result::{
IntermediateAggregationResults, IntermediateBucketResult, IntermediateHistogramBucketEntry,
Expand All @@ -37,7 +37,7 @@ impl AggregationResults {
/// for internal processing
fn from_intermediate_and_req_internal(
results: IntermediateAggregationResults,
req: &CollectorAggregations,
req: &AggregationsInternal,
) -> Self {
let mut result = HashMap::default();

Expand Down Expand Up @@ -145,7 +145,7 @@ pub enum BucketResult {
impl BucketResult {
fn from_intermediate_and_req(
bucket_result: IntermediateBucketResult,
req: &CollectorBucketAggregation,
req: &BucketAggregationInternal,
) -> Self {
match bucket_result {
IntermediateBucketResult::Range(range_map) => {
Expand Down Expand Up @@ -217,7 +217,7 @@ pub struct BucketEntry {
impl BucketEntry {
pub(crate) fn from_intermediate_and_req(
entry: IntermediateHistogramBucketEntry,
req: &CollectorAggregations,
req: &AggregationsInternal,
) -> Self {
BucketEntry {
key: Key::F64(entry.key),
Expand Down Expand Up @@ -280,7 +280,7 @@ pub struct RangeBucketEntry {
impl RangeBucketEntry {
fn from_intermediate_and_req(
entry: IntermediateRangeBucketEntry,
req: &CollectorAggregations,
req: &AggregationsInternal,
) -> Self {
RangeBucketEntry {
key: entry.key,
Expand Down
6 changes: 3 additions & 3 deletions src/aggregation/bucket/histogram/histogram.rs
Expand Up @@ -4,7 +4,7 @@ use std::fmt::Display;
use itertools::Itertools;
use serde::{Deserialize, Serialize};

use crate::aggregation::agg_req::CollectorAggregations;
use crate::aggregation::agg_req::AggregationsInternal;
use crate::aggregation::agg_req_with_accessor::{
AggregationsWithAccessor, BucketAggregationWithAccessor,
};
Expand Down Expand Up @@ -389,7 +389,7 @@ fn get_bucket_val(val: f64, interval: f64, offset: f64) -> f64 {
fn intermediate_buckets_to_final_buckets_fill_gaps(
buckets: Vec<IntermediateHistogramBucketEntry>,
histogram_req: &HistogramAggregation,
sub_aggregation: &CollectorAggregations,
sub_aggregation: &AggregationsInternal,
) -> Vec<BucketEntry> {
// Generate the the full list of buckets without gaps.
//
Expand Down Expand Up @@ -440,7 +440,7 @@ fn intermediate_buckets_to_final_buckets_fill_gaps(
pub(crate) fn intermediate_buckets_to_final_buckets(
buckets: Vec<IntermediateHistogramBucketEntry>,
histogram_req: &HistogramAggregation,
sub_aggregation: &CollectorAggregations,
sub_aggregation: &AggregationsInternal,
) -> Vec<BucketEntry> {
if histogram_req.min_doc_count() == 0 {
// With min_doc_count != 0, we may need to add buckets, so that there are no
Expand Down
4 changes: 2 additions & 2 deletions src/aggregation/intermediate_agg_result.rs
Expand Up @@ -8,7 +8,7 @@ use fnv::FnvHashMap;
use itertools::Itertools;
use serde::{Deserialize, Serialize};

use super::agg_req::{BucketAggregationType, CollectorAggregations, MetricAggregation};
use super::agg_req::{AggregationsInternal, BucketAggregationType, MetricAggregation};
use super::metric::{IntermediateAverage, IntermediateStats};
use super::segment_agg_result::{
SegmentAggregationResultsCollector, SegmentBucketResultCollector, SegmentHistogramBucketEntry,
Expand All @@ -34,7 +34,7 @@ impl From<SegmentAggregationResultsCollector> for IntermediateAggregationResults
}

impl IntermediateAggregationResults {
pub(crate) fn empty_from_req(req: &CollectorAggregations) -> Self {
pub(crate) fn empty_from_req(req: &AggregationsInternal) -> Self {
let metrics = if req.metrics.is_empty() {
None
} else {
Expand Down

0 comments on commit f619658

Please sign in to comment.