Skip to content

Commit

Permalink
Merge pull request #69 from apache/cpp-5.0.0
Browse files Browse the repository at this point in the history
use datasketches-cpp 5.0.0
  • Loading branch information
AlexanderSaydakov authored Nov 14, 2023
2 parents 785e875 + e292d88 commit a874cdb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ARG BASE_IMAGE_VERSION=latest

ARG DATASKETCHES_CPP_HASH=8135b65408947694e13bd131038889e439847aa2
ARG DATASKETCHES_CPP_VERSION=4.1.0
ARG DATASKETCHES_CPP_VERSION=5.0.0

FROM postgres:$BASE_IMAGE_VERSION

Expand Down
2 changes: 1 addition & 1 deletion package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if [ -z $2 ]; then
fi

# version of datasketches-cpp core library to include
CORETAG=4.1.0
CORETAG=5.0.0

DST=datasketches-$VER

Expand Down
16 changes: 7 additions & 9 deletions src/aod_sketch_c_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,22 @@
#include "kll_float_sketch_c_adapter.h"

#include <array_of_doubles_sketch.hpp>
#include <array_of_doubles_union.hpp>
#include <array_of_doubles_intersection.hpp>
#include <array_of_doubles_a_not_b.hpp>

#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/variance.hpp>
#include <boost/math/distributions/students_t.hpp>

using update_aod_sketch_pg = datasketches::update_array_of_doubles_sketch_alloc<palloc_allocator<double>>;
using compact_aod_sketch_pg = datasketches::compact_array_of_doubles_sketch_alloc<palloc_allocator<double>>;
using aod_union_pg = datasketches::array_of_doubles_union_alloc<palloc_allocator<double>>;
using aod = datasketches::array<double, palloc_allocator<double>>;
using update_aod_sketch_pg = datasketches::update_array_tuple_sketch<aod>;
using compact_aod_sketch_pg = datasketches::compact_array_tuple_sketch<aod>;
using aod_union_pg = datasketches::array_tuple_union<aod>;
// using the union policy in the intersection since this is how it is done in Druid
using aod_intersection_pg = datasketches::array_of_doubles_intersection<datasketches::array_of_doubles_union_policy_alloc<palloc_allocator<double>>, palloc_allocator<double>>;
using aod_a_not_b_pg = datasketches::array_of_doubles_a_not_b_alloc<palloc_allocator<double>>;
using aod_intersection_pg = datasketches::array_tuple_intersection<aod, datasketches::default_array_tuple_union_policy<aod>>;
using aod_a_not_b_pg = datasketches::array_tuple_a_not_b<aod>;

std::ostream& operator<<(std::ostream& os, const datasketches::aod<palloc_allocator<double>>& v) {
std::ostream& operator<<(std::ostream& os, const aod& v) {
os << "(";
for (size_t i = 0; i < v.size(); ++i) {
if (i != 0) os << ", ";
Expand Down
3 changes: 1 addition & 2 deletions src/kll_double_sketch_c_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ Datum* kll_double_sketch_get_pmf_or_cdf(const void* sketchptr, const double* spl

Datum* kll_double_sketch_get_quantiles(const void* sketchptr, const double* fractions, unsigned num_fractions) {
try {
auto array = static_cast<const kll_double_sketch*>(sketchptr)->get_quantiles(fractions, num_fractions);
Datum* quantiles = (Datum*) palloc(sizeof(Datum) * num_fractions);
for (unsigned i = 0; i < num_fractions; i++) {
quantiles[i] = pg_float8_get_datum(array[i]);
quantiles[i] = pg_float8_get_datum(static_cast<const kll_double_sketch*>(sketchptr)->get_quantile(fractions[i]));
}
return quantiles;
} catch (std::exception& e) {
Expand Down
3 changes: 1 addition & 2 deletions src/kll_float_sketch_c_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ Datum* kll_float_sketch_get_pmf_or_cdf(const void* sketchptr, const float* split

Datum* kll_float_sketch_get_quantiles(const void* sketchptr, const double* fractions, unsigned num_fractions) {
try {
auto array = static_cast<const kll_float_sketch*>(sketchptr)->get_quantiles(fractions, num_fractions);
Datum* quantiles = (Datum*) palloc(sizeof(Datum) * num_fractions);
for (unsigned i = 0; i < num_fractions; i++) {
quantiles[i] = pg_float4_get_datum(array[i]);
quantiles[i] = pg_float4_get_datum(static_cast<const kll_float_sketch*>(sketchptr)->get_quantile(fractions[i]));
}
return quantiles;
} catch (std::exception& e) {
Expand Down
3 changes: 1 addition & 2 deletions src/quantiles_double_sketch_c_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ Datum* quantiles_double_sketch_get_pmf_or_cdf(const void* sketchptr, const doubl

Datum* quantiles_double_sketch_get_quantiles(const void* sketchptr, const double* fractions, unsigned num_fractions) {
try {
auto array = static_cast<const quantiles_double_sketch*>(sketchptr)->get_quantiles(fractions, num_fractions);
Datum* quantiles = (Datum*) palloc(sizeof(Datum) * num_fractions);
for (unsigned i = 0; i < num_fractions; i++) {
quantiles[i] = pg_float8_get_datum(array[i]);
quantiles[i] = pg_float8_get_datum(static_cast<const quantiles_double_sketch*>(sketchptr)->get_quantile(fractions[i]));
}
return quantiles;
} catch (std::exception& e) {
Expand Down
3 changes: 1 addition & 2 deletions src/req_float_sketch_c_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ Datum* req_float_sketch_get_pmf_or_cdf(const void* sketchptr, const float* split

Datum* req_float_sketch_get_quantiles(const void* sketchptr, const double* fractions, unsigned num_fractions, bool inclusive) {
try {
auto array = static_cast<const req_float_sketch*>(sketchptr)->get_quantiles(fractions, num_fractions, inclusive);
Datum* quantiles = (Datum*) palloc(sizeof(Datum) * num_fractions);
for (unsigned i = 0; i < num_fractions; i++) {
quantiles[i] = pg_float4_get_datum(array[i]);
quantiles[i] = pg_float4_get_datum(static_cast<const req_float_sketch*>(sketchptr)->get_quantile(fractions[i]));
}
return quantiles;
} catch (std::exception& e) {
Expand Down

0 comments on commit a874cdb

Please sign in to comment.