@@ -179,10 +179,10 @@ class ARROW_EXPORT TDigestOptions : public FunctionOptions {
179179
180180 explicit TDigestOptions (double q = 0.5 , uint32_t delta = 100 ,
181181 uint32_t buffer_size = 500 , bool skip_nulls = true ,
182- uint32_t min_count = 0 , enum Scaler scaler = K0 );
182+ uint32_t min_count = 0 , enum Scaler scaler = K1 );
183183 explicit TDigestOptions (std::vector<double > q, uint32_t delta = 100 ,
184184 uint32_t buffer_size = 500 , bool skip_nulls = true ,
185- uint32_t min_count = 0 , enum Scaler scaler = K0 );
185+ uint32_t min_count = 0 , enum Scaler scaler = K1 );
186186 static constexpr char const kTypeName [] = " TDigestOptions" ;
187187 static TDigestOptions Defaults () { return TDigestOptions{}; }
188188
@@ -201,6 +201,66 @@ class ARROW_EXPORT TDigestOptions : public FunctionOptions {
201201 enum Scaler scaler;
202202};
203203
204+ // / \brief Control TDigest controid calculation
205+ // /
206+ // / By default, returns the median value.
207+ class ARROW_EXPORT TDigestMapOptions : public FunctionOptions {
208+ public:
209+ using Scaler = TDigestOptions::Scaler;
210+
211+ explicit TDigestMapOptions (uint32_t delta = 100 , uint32_t buffer_size = 500 ,
212+ bool skip_nulls = true , Scaler scaler = Scaler::K1);
213+ static constexpr char const kTypeName [] = " TDigestMapOptions" ;
214+ static TDigestMapOptions Defaults () { return TDigestMapOptions{}; }
215+
216+ // / compression parameter, default 100
217+ uint32_t delta;
218+ // / input buffer size, default 500
219+ uint32_t buffer_size;
220+ // / If true (the default), null values are ignored. Otherwise, if any value is null,
221+ // / emit null.
222+ bool skip_nulls;
223+ // / select scaler implementation
224+ Scaler scaler;
225+ };
226+
227+ // / \brief Control TDigest reduce behavior
228+ // /
229+ // / By default, returns the median value.
230+ class ARROW_EXPORT TDigestReduceOptions : public FunctionOptions {
231+ public:
232+ using Scaler = TDigestOptions::Scaler;
233+
234+ explicit TDigestReduceOptions (Scaler scaler = Scaler::K1);
235+ static constexpr char const kTypeName [] = " TDigestReduceOptions" ;
236+ static TDigestReduceOptions Defaults () { return TDigestReduceOptions{}; }
237+
238+ // / select scaler implementation
239+ Scaler scaler;
240+ };
241+
242+ // / \brief Control TDigest approximate quantile kernel behavior
243+ // /
244+ // / By default, returns the median value.
245+ class ARROW_EXPORT TDigestQuantileOptions : public FunctionOptions {
246+ public:
247+ using Scaler = TDigestOptions::Scaler;
248+
249+ explicit TDigestQuantileOptions (double q = 0.5 , uint32_t min_count = 0 ,
250+ Scaler scaler = Scaler::K1);
251+ explicit TDigestQuantileOptions (std::vector<double > q, uint32_t min_count = 0 ,
252+ Scaler scaler = Scaler::K1);
253+ static constexpr char const kTypeName [] = " TDigestQuantileOptions" ;
254+ static TDigestQuantileOptions Defaults () { return TDigestQuantileOptions{}; }
255+
256+ // / probability level of quantile must be between 0 and 1 inclusive
257+ std::vector<double > q;
258+ // / If less than this many non-null values are observed, emit null.
259+ uint32_t min_count;
260+ // / select scaler implementation
261+ Scaler scaler;
262+ };
263+
204264// / \brief Control Pivot kernel behavior
205265// /
206266// / These options apply to the "pivot_wider" and "hash_pivot_wider" functions.
@@ -586,6 +646,50 @@ Result<Datum> TDigest(const Datum& value,
586646 const TDigestOptions& options = TDigestOptions::Defaults(),
587647 ExecContext* ctx = NULLPTR);
588648
649+ // / \brief Calculate centroids of a numeric array with T-Digest algorithm
650+ // /
651+ // / \param[in] value input datum, expecting Array or ChunkedArray
652+ // / \param[in] options see TDigestMapOptions for more information
653+ // / \param[in] ctx the function execution context, optional
654+ // / \return resulting struct of mean and weight arrays
655+ // /
656+ // / \since 22.0.0
657+ // / \note API not yet finalized
658+ ARROW_EXPORT
659+ Result<Datum> TDigestMap (const Datum& value,
660+ const TDigestMapOptions& options = TDigestMapOptions::Defaults(),
661+ ExecContext* ctx = NULLPTR);
662+
663+ // / \brief Merge multiple centroid sets into one
664+ // /
665+ // / \param[in] value input centroid sets, expecting Scalar, Array or ChunkedArray of
666+ // / centroid structs \param[in] options see TDigestReduceOptions for more information
667+ // / \param[in] ctx the function execution context, optional
668+ // / \return resulting struct of mean and weight arrays
669+ // /
670+ // / \since 22.0.0
671+ // / \note API not yet finalized
672+ ARROW_EXPORT
673+ Result<Datum> TDigestReduce (
674+ const Datum& value,
675+ const TDigestReduceOptions& options = TDigestReduceOptions::Defaults(),
676+ ExecContext* ctx = NULLPTR);
677+
678+ // / \brief Calculate the approximate quantiles using centroids with T-Digest algorithm
679+ // /
680+ // / \param[in] value input centroid sets, expecting Scalar, Array or ChunkedArray of
681+ // / centroid structs \param[in] options see TDigestQuantileOptions for more information
682+ // / \param[in] ctx the function execution context, optional
683+ // / \return resulting struct of mean and weight arrays
684+ // /
685+ // / \since 22.0.0
686+ // / \note API not yet finalized
687+ ARROW_EXPORT
688+ Result<Datum> TDigestQuantile (
689+ const Datum& value,
690+ const TDigestQuantileOptions& options = TDigestQuantileOptions::Defaults(),
691+ ExecContext* ctx = NULLPTR);
692+
589693// / \brief Find the first index of a value in an array.
590694// /
591695// / \param[in] value The array to search.
0 commit comments