init research
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
(ns tech.v3.dataset.main
|
||||
(:require [tech.v3.dataset :as ds]
|
||||
[tech.v3.datatype.functional :as dfn]
|
||||
[tech.v3.libs.arrow :as arrow]
|
||||
[clojure.tools.logging :as log])
|
||||
(:gen-class))
|
||||
|
||||
|
||||
(defn -main
|
||||
[& args]
|
||||
;;Load larray. Note this implies a pre-build step -- unpack-larray
|
||||
(let [libname (format "%s/resources/%s"
|
||||
(System/getProperty "user.dir")
|
||||
(System/mapLibraryName "larray"))]
|
||||
(log/infof "Loading shared library: %s" libname)
|
||||
(System/load libname))
|
||||
(let [test-ds (ds/->dataset "test/data/stocks.csv")]
|
||||
(println test-ds)
|
||||
(println (dfn/mean (test-ds "price")))
|
||||
(arrow/write-dataset-to-stream! test-ds "stocks.arrow")
|
||||
(println (dfn/mean ((arrow/read-stream-dataset-inplace "stocks.arrow") "price")))
|
||||
0))
|
||||
@@ -0,0 +1,37 @@
|
||||
(ns tech.v3.dataset.unpack-larray
|
||||
(:require [clojure.java.classpath :as cp]
|
||||
[tech.v3.io :as io]
|
||||
[clojure.tools.logging :as log])
|
||||
(:import [xerial.larray.impl OSInfo]
|
||||
[java.util.jar JarFile JarEntry]
|
||||
[java.nio.file Files Paths]
|
||||
[java.nio.file.attribute PosixFilePermissions])
|
||||
(:gen-class))
|
||||
|
||||
|
||||
(def larray-os-folder (OSInfo/getNativeLibFolderPathForCurrentOS))
|
||||
|
||||
(def larray-libname (System/mapLibraryName "larray"))
|
||||
|
||||
|
||||
(defn copy-jar-resource
|
||||
[os-folder libname]
|
||||
(if-let [[^JarFile jf ^JarEntry entry]
|
||||
(->> (cp/classpath-jarfiles)
|
||||
(mapcat #(map vector (repeat %) (iterator-seq (.entries ^JarFile %))))
|
||||
(filter (fn [[^JarFile _jf ^JarEntry entry]]
|
||||
(and
|
||||
(.endsWith (.getName entry) libname)
|
||||
(.contains (.getName entry) os-folder))))
|
||||
(first))]
|
||||
(let [fname (format "resources/%s" libname)]
|
||||
(log/infof "Copying shared library - os-path: %s, libname: %s output: %s"
|
||||
os-folder libname fname)
|
||||
(io/copy (.getInputStream jf entry) (str "file://" fname))
|
||||
(Files/setPosixFilePermissions (Paths/get fname (into-array String []))
|
||||
(PosixFilePermissions/fromString "rwxr-x---")))))
|
||||
|
||||
|
||||
(defn -main
|
||||
[& args]
|
||||
(copy-jar-resource larray-os-folder larray-libname))
|
||||
Reference in New Issue
Block a user