From 93d248304a68de7a8f9daf4aa74f9ee4cd27410c Mon Sep 17 00:00:00 2001 From: vlad shkapenyuk Date: Fri, 13 Sep 2019 13:20:40 -0400 Subject: [PATCH] Add hfta-only FIRST udaf Signed-off-by: vlad shkapenyuk Change-Id: Ic26c0dcad938421135caa148ef8e7912327e5c3d --- include/hfta/hfta_udaf.h | 19 +++++++++++++ src/lib/gscphftaaux/hfta_udaf.cc | 59 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/include/hfta/hfta_udaf.h b/include/hfta/hfta_udaf.h index 67dd794..483e4e6 100644 --- a/include/hfta/hfta_udaf.h +++ b/include/hfta/hfta_udaf.h @@ -75,6 +75,25 @@ void avg_udaf_hfta_HFTA_AGGR_DESTROY_(gs_sp_t b); gs_float_t extr_avg_fcn(vstring *v); // first aggregate +// hfta only +void FIRST_HFTA_AGGR_INIT_(gs_uint32_t* scratch); +void FIRST_HFTA_AGGR_REINIT_(gs_uint32_t* scratch); +void FIRST_HFTA_AGGR_UPDATE_(gs_uint32_t* scratch, gs_uint32_t val); +void FIRST_HFTA_AGGR_OUTPUT_(gs_uint32_t* res, gs_uint32_t* scratch); +void FIRST_HFTA_AGGR_DESTROY_(gs_uint32_t* scratch); + +void FIRST_ULL_HFTA_AGGR_INIT_(gs_uint64_t* scratch); +void FIRST_ULL_HFTA_AGGR_REINIT_(gs_uint64_t* scratch); +void FIRST_ULL_HFTA_AGGR_UPDATE_(gs_uint64_t* scratch, gs_uint64_t val); +void FIRST_ULL_HFTA_AGGR_OUTPUT_(gs_uint64_t* res, gs_uint64_t* scratch); +void FIRST_ULL_HFTA_AGGR_DESTROY_(gs_uint64_t* scratch); + +void FIRST_STR_HFTA_AGGR_INIT_(vstring* scratch); +void FIRST_STR_HFTA_AGGR_REINIT_(vstring* scratch); +void FIRST_STR_HFTA_AGGR_UPDATE_(vstring* scratch, vstring* val); +void FIRST_STR_HFTA_AGGR_OUTPUT_(vstring* res, vstring* scratch); +void FIRST_STR_HFTA_AGGR_DESTROY_(vstring* scratch); +// hfts-lfta split void FIRST_hfta_HFTA_AGGR_INIT_(gs_uint32_t* scratch); void FIRST_hfta_HFTA_AGGR_REINIT_(gs_uint32_t* scratch); void FIRST_hfta_HFTA_AGGR_UPDATE_(gs_uint32_t* scratch, gs_uint32_t val); diff --git a/src/lib/gscphftaaux/hfta_udaf.cc b/src/lib/gscphftaaux/hfta_udaf.cc index ad26871..0660739 100644 --- a/src/lib/gscphftaaux/hfta_udaf.cc +++ b/src/lib/gscphftaaux/hfta_udaf.cc @@ -272,6 +272,64 @@ gs_float_t extr_avg_fcn(vstring *v){ ///////////////////////////////////////////////////////// // FIRST aggregate +// hfta only + +void FIRST_HFTA_AGGR_INIT_(gs_uint32_t* scratch) { + *scratch = UINT_MAX; // we will encode uninitialized value of UINT_MAX +} + +void FIRST_HFTA_AGGR_REINIT_(gs_uint32_t* scratch) { } + +void FIRST_HFTA_AGGR_UPDATE_(gs_uint32_t* scratch, gs_uint32_t val) { + if (*scratch == UINT_MAX) + *scratch = val; +} + +void FIRST_HFTA_AGGR_OUTPUT_(gs_uint32_t* res, gs_uint32_t* scratch) { + *res = *scratch; +} + +void FIRST_HFTA_AGGR_DESTROY_(gs_uint32_t* scratch) { } + +void FIRST_ULL_HFTA_AGGR_INIT_(gs_uint64_t* scratch) { + *scratch = UINT_MAX; // we will encode uninitialized value of UINT_MAX +} + +void FIRST_ULL_HFTA_AGGR_REINIT_(gs_uint64_t* scratch) { } + +void FIRST_ULL_HFTA_AGGR_UPDATE_(gs_uint64_t* scratch, gs_uint64_t val) { + if (*scratch == UINT_MAX) + *scratch = val; +} + +void FIRST_ULL_HFTA_AGGR_OUTPUT_(gs_uint64_t* res, gs_uint64_t* scratch) { + *res = *scratch; +} + +void FIRST_ULL_HFTA_AGGR_DESTROY_(gs_uint64_t* scratch) { } + + +void FIRST_STR_HFTA_AGGR_INIT_(vstring* scratch) { + scratch->offset= 0; +} + +void FIRST_STR_HFTA_AGGR_REINIT_(vstring* scratch) { } + +void FIRST_STR_HFTA_AGGR_UPDATE_(vstring* scratch, vstring* val) { + if (!scratch->offset) { + scratch->length = val->length; + scratch->offset = val->offset; + scratch->reserved = SHALLOW_COPY; + } +} + +void FIRST_STR_HFTA_AGGR_OUTPUT_(vstring* res, vstring* scratch) { + *res = *scratch; +} + +void FIRST_STR_HFTA_AGGR_DESTROY_(vstring* scratch) { } + +// hfta/lfta split void FIRST_hfta_HFTA_AGGR_INIT_(gs_uint32_t* scratch) { *scratch = UINT_MAX; // we will encode uninitialized value of UINT_MAX @@ -328,6 +386,7 @@ void FIRST_STR_hfta_HFTA_AGGR_OUTPUT_(vstring* res, vstring* scratch) { void FIRST_STR_hfta_HFTA_AGGR_DESTROY_(vstring* scratch) { } + ///////////////////////////////////////////////////////// // LAST aggregate -- 2.16.6