Skip to content

Commit

Permalink
Support other primitive types
Browse files Browse the repository at this point in the history
  • Loading branch information
athos committed Oct 5, 2023
1 parent 57495da commit b37e6c7
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/cljam/io/util/dataframe.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
(let [t (aget types j)
arr (aget data j)]
(case t
:boolean (aset ^booleans arr i (boolean val))
:byte (aset ^bytes arr i (byte val))
:char (aset ^chars arr i (char val))
:short (aset ^shorts arr i (short val))
:int (aset ^ints arr i (int val))
:long (aset ^longs arr i (long val))
:float (aset ^floats arr i (float val))
:double (aset ^doubles arr i (double val))
(aset ^objects arr i val))
(set! j (inc j))
Expand All @@ -30,7 +36,13 @@
data (->> columns
(map (fn [[_ t]]
(case t
:boolean (boolean-array m)
:byte (byte-array m)
:char (char-array m)
:short (short-array m)
:int (int-array m)
:long (long-array m)
:float (float-array m)
:double (double-array m)
(object-array m))))
(into-array Object))]
Expand Down Expand Up @@ -178,9 +190,27 @@
col (int (.get columns key))
t (aget ^objects (.-types frame) col)]
(case t
:boolean (thunk [^DataFrameRow row]
(aget ^booleans (aget ^objects (.-data ^DataFrame (.-frame row)) col)
(.-row row)))
:byte (thunk [^DataFrameRow row]
(aget ^bytes (aget ^objects (.-data ^DataFrame (.-frame row)) col)
(.-row row)))
:char (thunk [^DataFrameRow row]
(aget ^chars (aget ^objects (.-data ^DataFrame (.-frame row)) col)
(.-row row)))
:int (thunk [^DataFrameRow row]
(aget ^ints (aget ^objects (.-data ^DataFrame (.-frame row)) col)
(.-row row)))
:short (thunk [^DataFrameRow row]
(aget ^shorts (aget ^objects (.-data ^DataFrame (.-frame row)) col)
(.-row row)))
:long (thunk [^DataFrameRow row]
(aget ^longs (aget ^objects (.-data ^DataFrame (.-frame row)) col)
(.-row row)))
:float (thunk [^DataFrameRow row]
(aget ^floats (aget ^objects (.-data ^DataFrame (.-frame row)) col)
(.-row row)))
:double (thunk [^DataFrameRow row]
(aget ^doubles (aget ^objects (.-data ^DataFrame (.-frame row)) col)
(.-row row)))
Expand Down

0 comments on commit b37e6c7

Please sign in to comment.