File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,19 @@ user> (ds-reduce/group-by-column-agg
134134 hamf-proto/Finalize
135135 (finalize [this v] (deref v))))
136136
137+ (defn maximum-rf
138+ ([]
139+ Double/NaN)
140+ ([eax v]
141+ (if (Double/isNaN eax)
142+ v
143+ (max (double v) (double eax))))
144+ ([eax]
145+ eax))
146+
147+ (defn maximum
148+ [colname]
149+ (reducer->column-reducer maximum-rf colname))
137150
138151(deftype BitmapConsumer [^RoaringBitmap bitmap]
139152 LongConsumer
@@ -494,7 +507,7 @@ _unnamed [4 5]:
494507 k v
495508 (let [vv (finalize-fn v)]
496509 (.lock ll)
497- (try
510+ (try
498511 (.accept ^Consumer c vv)
499512 (finally
500513 (.unlock ll))))))
Original file line number Diff line number Diff line change 370370
371371 ))
372372
373+ (deftest maximum-test
374+ (let [ds (ds/->dataset {:x (repeatedly 100 rand)})
375+ ev (last (:x (ds/sort-by-column ds :x )))
376+ out-ds (ds-reduce/aggregate {:max-x (ds-reduce/maximum :x )} ds)]
377+ (is (= 1 (ds/row-count out-ds)))
378+ (is (= (first (:max-x out-ds))
379+ ev))))
380+
373381(comment
374382
375383 (do
435443
436444
437445 (dotimes [idx 100 ]
438- (time
446+ (time
439447 (ds-reduce/group-by-column-agg
440448 :a
441449 (into {} (for [col (-> one-hot :one-hot-table vals)
You can’t perform that action at this time.
0 commit comments