-
Notifications
You must be signed in to change notification settings - Fork 5
/
DataStat.clj
49 lines (40 loc) · 1.02 KB
/
DataStat.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(ns clojask.DataStat
(:require [clojure.java.io :as io]))
(import '[com.clojask.exception TypeException]
'[com.clojask.exception OperationException])
(definterface DataIntf
(init [source file])
(initWithIO [io-func])
(getSize []))
(deftype DataStat
;; the column description about whether a change is made to this column
[^:unsynchronized-mutable file-size
^:unsynchronized-mutable num-rows]
;; method
DataIntf
(init
[this source file]
(if file
(do
(set! file-size (:size (file)))
(set! num-rows nil))
(if (fn? source)
(do
(set! file-size nil)
(set! num-rows nil))
(do
(set! file-size (.length (io/file source)))))))
(initWithIO
[this io-func]
(set! file-size (:size (io-func)))
(set! num-rows nil))
(getSize
[this]
file-size))
(defn compute-stat
[source & [io-func]]
(let [stat (DataStat. nil nil)]
(if io-func
(.initWithIO stat io-func)
(.init stat source nil))
stat))