Skip to content

Commit

Permalink
Implementing chunking broke an odd raw copy test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuernber committed Jan 29, 2024
1 parent 7967844 commit f4e593c
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/tech/v3/datatype/copy_raw_to_item.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@
[tech.v3.datatype.casting :as casting]
[tech.v3.datatype.argtypes :as argtypes]
[tech.v3.datatype.copy :as dtype-cp]
[tech.v3.parallel.for :as pfor]))
[tech.v3.parallel.for :as pfor])
(:import [ham_fisted Reductions]))



(defn copy-raw-seq->item!
[raw-data-seq ary-target target-offset options]
(let [writer (dtype-base/->writer ary-target)]
(reduce (fn [[ary-target target-offset] new-raw-data]
;;Fastpath for sequences of numbers. Avoids more protocol pathways.
(if (= :scalar (argtypes/arg-type new-raw-data))
(do
(.set writer target-offset new-raw-data)
[ary-target (inc target-offset)])
;;slow path if we didn't recognize the thing.
(dtype-proto/copy-raw->item! new-raw-data ary-target
target-offset options)))
[ary-target target-offset]
raw-data-seq)))
(let [writer (dtype-base/->writer ary-target)
rfn (fn [[ary-target target-offset] new-raw-data]
;;Fastpath for sequences of numbers. Avoids more protocol pathways.
(if (= :scalar (argtypes/arg-type new-raw-data))
(do
(.set writer target-offset new-raw-data)
[ary-target (inc target-offset)])
;;slow path if we didn't recognize the thing.
(dtype-proto/copy-raw->item! new-raw-data ary-target
target-offset options)))
init [ary-target target-offset]]
(if (instance? Iterable raw-data-seq)
(Reductions/iterReduce raw-data-seq init rfn)
(reduce rfn init raw-data-seq))))


(defn raw-dtype-copy!
Expand Down Expand Up @@ -77,7 +80,7 @@
(raw-dtype-copy! src-reader ary-target target-offset options)
(copy-raw-seq->item! (seq raw-data) ary-target target-offset options)))
(instance? java.lang.Iterable raw-data)
(copy-raw-seq->item! (seq raw-data) ary-target
(copy-raw-seq->item! raw-data ary-target
target-offset options)

:else
Expand Down

0 comments on commit f4e593c

Please sign in to comment.