Liking cljdoc? Tell your friends :D

std.timeseries.journal


+defaults+clj


add-bulkclj

(add-bulk {:keys [meta template] :as journal} entries)

adds multiple entries to the journal

adds multiple entries to the journal
raw docstring

add-entryclj

(add-entry {:keys [meta template] :as journal} entry)

adds an entry to the journal

(-> (journal {:meta {:head {:range [0 3]}}}) (add-entry {:start 1 :output {:value 1}}) journal-info) => (contains-in {:id string? :order :desc, :count 1, :duration "0ms", :template [:output.value :start], :head [{:start 1, :output.value 1, :s/time string?}]})

adds an entry to the journal

(-> (journal {:meta {:head {:range [0 3]}}})
    (add-entry {:start 1 :output {:value 1}})
    journal-info)
=> (contains-in {:id string?
                 :order :desc, :count 1,
                 :duration "0ms",
                 :template [:output.value :start],
                 :head [{:start 1, :output.value 1, :s/time string?}]})
raw docstring

add-timeclj

(add-time entry key unit)

adds time to entry if if doesn't exist

(add-time {} :t :s) => (contains {:t integer?})

adds time to entry if if doesn't exist

(add-time {} :t :s)
=> (contains {:t integer?})
raw docstring

create-templateclj

(create-template {:keys [template]} entry)

creates a template a puts in the cache

creates a template a puts in the cache
raw docstring

deriveclj

(derive {:keys [meta] :as journal} {:keys [range sample transform] :as params})

derives the journal given a select statement

(derive -jnl- {:range [:1m :15m] :sample 2000 :transform {:interval :0.1s :time {:aggregate :first} :default {:aggregate :mean :sample 3}}})

derives the journal given a select statement

(derive -jnl- {:range [:1m :15m]
               :sample 2000
              :transform {:interval :0.1s
                           :time    {:aggregate :first}
                           :default {:aggregate :mean :sample 3}}})
raw docstring

entries-seqclj

(entries-seq {:keys [limit entries previous]})

gets entries in time order

(-> (journal {:limit 2 :entries [{:a 2 :s/time 2}] :previous [{:a 1 :s/time 1} {:a 0 :s/time 0}]}) (entries-seq)) => [{:a 2, :s/time 2} {:a 1, :s/time 1}]

gets entries in time order

(-> (journal {:limit 2
              :entries  [{:a 2 :s/time 2}]
              :previous [{:a 1 :s/time 1} {:a 0 :s/time 0}]})
    (entries-seq))
=> [{:a 2, :s/time 2} {:a 1, :s/time 1}]
raw docstring

entries-vecclj

(entries-vec {:keys [limit entries previous]})

gets entries in time order

(-> (journal {:meta {:time {:order :asc}} :limit 2 :entries [{:a 2 :s/time 2}] :previous [{:a 0 :s/time 0} {:a 1 :s/time 1}]}) (entries-vec)) => [{:a 1, :s/time 1} {:a 2, :s/time 2}]

gets entries in time order

(-> (journal {:meta {:time {:order :asc}}
              :limit 2
              :entries  [{:a 2 :s/time 2}]
              :previous [{:a 0 :s/time 0} {:a 1 :s/time 1}]})
    (entries-vec))
=> [{:a 1, :s/time 1} {:a 2, :s/time 2}]
raw docstring

entry-displayclj

(entry-display entry {:keys [meta]})

displays entry, formatting time

(entry-display {:data {:in "" :out "ABC"} :time 100000} {:meta {:time {:key :time :unit :s :format "HH:mm:ss"}}}) => (contains {:data {:in "", :out "ABC"}, :time #(.endsWith ^String % ":46:40")})

displays entry, formatting time

(entry-display {:data {:in  ""
                       :out "ABC"}
                :time 100000}
               {:meta {:time {:key :time :unit :s :format "HH:mm:ss"}}})
=> (contains {:data {:in "", :out "ABC"}, :time #(.endsWith ^String % ":46:40")})
raw docstring

format-timeclj

(format-time val {:keys [unit format]})

output the time according to format and time unit

(format-time 10000 {:unit :s :format "HH:mm:ss"}) => #(.endsWith ^String % ":46:40")

output the time according to format and time unit

(format-time 10000 {:unit :s :format "HH:mm:ss"})
=> #(.endsWith ^String % ":46:40")
raw docstring

get-templateclj

(get-template {:keys [entries template] :as journal})

gets existing or creates a new template

(get-template (journal {:entries [{:a {:b 1} :s/time 0}]})) => map?

gets existing or creates a new template

(get-template (journal {:entries [{:a {:b 1}
                                   :s/time 0}]}))
=> map?
raw docstring

journalclj

(journal)
(journal {:keys [id meta entries previous] :as m :or {id (h/sid)}})

creates a new journal

(journal {:meta {:time {:unit :s :format "HH:mm:ss"} :entry {:flatten false} :head {:range [0 3]}}})

creates a new journal

(journal {:meta {:time {:unit :s :format "HH:mm:ss"}
                 :entry {:flatten false}
                :head {:range [0 3]}}})
raw docstring

journal-entriesclj

(journal-entries journal)

gets entries from the journal

(-> (journal {:meta {:time {:order :asc} :entry {:flatten true :pre-flattened true}} :limit 2 :entries [{:a 2 :s/time 2}] :previous [{:a 0 :s/time 0} {:a 1 :s/time 1}]}) (add-entry {:a 3 :s/time 3}) (add-entry {:a 4 :s/time 4}) ((juxt :entries journal-entries))) => [[{:a 4, :s/time 4}] [{:a 3, :s/time 3} {:a 4, :s/time 4}]]

gets entries from the journal

 (-> (journal {:meta {:time {:order :asc}
                      :entry {:flatten true :pre-flattened true}}
               :limit 2
               :entries  [{:a 2 :s/time 2}]
               :previous [{:a 0 :s/time 0} {:a 1 :s/time 1}]})
     (add-entry  {:a 3 :s/time 3})
     (add-entry  {:a 4 :s/time 4})
     ((juxt :entries journal-entries)))
=> [[{:a 4, :s/time 4}]
     [{:a 3, :s/time 3} {:a 4, :s/time 4}]]
raw docstring

journal-infoclj

(journal-info {:keys [id meta] :as journal})

returns info for the journal

(-> (journal {:meta {:time {:key :start :order :desc} :head {:range [0 3]} :hide #{:meta :template :id}}}) journal-info) => {:order :desc, :count 0, :head []}

returns info for the journal

(-> (journal {:meta {:time   {:key :start :order :desc}
                     :head   {:range [0 3]}
                     :hide   #{:meta :template :id}}})
    journal-info)
=> {:order :desc, :count 0, :head []}
raw docstring

journal-invokeclj

(journal-invoke journal)
(journal-invoke journal arg)
(journal-invoke journal k v & more)

invoke function for the journal

invoke function for the journal
raw docstring

mergeclj

(merge)
(merge j0)
(merge j0 j1)

merges two journals of the same type together ^:hiddene

(-> ((merge (derive -jnl- {:range [:1m :3m] :transform {:interval 1 :time {:aggregate :middle} :default {:aggregate :mean :sample 3}}}) (derive -jnl- {:range [:10m -1] :transform {:interval :5s :time {:aggregate :first} :default {:aggregate :mean}}})) {:sample :0.1s :transform {:interval :1s :time {:aggregate :first :fn #(long (/ % 100))} :custom [{:keys [:output.value] :aggregate :random :fn #(long (* % 100))}]} :series [{:data '(:start :output.value) :s/meta {:title "Output 1" :with :lines}}]}))

merges two journals of the same type together ^:hiddene

(-> ((merge (derive -jnl- {:range [:1m :3m]
                           :transform {:interval 1
                                       :time     {:aggregate :middle}
                                       :default {:aggregate :mean :sample 3}}})
            (derive -jnl- {:range [:10m -1]
                           :transform {:interval :5s
                                       :time    {:aggregate :first}
                                       :default {:aggregate :mean}}}))
     {:sample :0.1s
      :transform {:interval :1s
                  :time {:aggregate :first
                         :fn #(long (/ % 100))}
                  :custom [{:keys [:output.value]
                            :aggregate :random
                            :fn #(long (* % 100))}]}
      :series [{:data '(:start :output.value)
                :s/meta {:title "Output 1" :with :lines}}]}))
raw docstring

merge-sortedclj

(merge-sorted coll)
(merge-sorted coll key-fn)
(merge-sorted coll key-fn comp-fn)

merges a series of arrays together

(merge-sorted [[1 3 4 6 9 10 15] [2 3 6 7 8 9 10] [1 3 6 7 8 9 10] [1 2 3 4 8 9 10]]) => [1 1 1 2 2 3 3 3 3 4 4 6 6 6 7 7 8 8 8 9 9 9 9 10 10 10 10 15]

merges a series of arrays together

(merge-sorted [[1 3 4 6 9 10 15]
               [2 3 6 7 8 9 10]
               [1 3 6 7 8 9 10]
               [1 2 3 4 8 9 10]])
=> [1 1 1 2 2 3 3 3 3 4 4 6 6 6 7 7 8 8 8 9 9 9 9 10 10 10 10 15]
raw docstring

selectclj

(select journal)
(select {:keys [meta] :as journal}
        {:keys [range sample transform series template compute]
         :or {range :all}})

selects data ferom the journal

(def -jnl- (->> [0 (journal {:meta {:time {:key :start :order :desc} :head {:range [0 3]} :hide #{:meta :template :id}}})] (iterate (fn [[t journal]] (let [t (+ t 1000000000 (rand-int 100000000))] [t (add-entry journal {:start t :output {:value (Math/sin (+ (/ t 100000000000) (rand)))}})]))) (map second) (take 1000) (last)))

(select -jnl- {:range [:1m :5m] :sample 10}) => (fn [entries] (= 10 (count entries)))

(first (select -jnl- {:range [:1m :5m] :sample 10})) => (contains {:start integer? :output.value number?})

selects data ferom the journal

(def -jnl- (->> [0 (journal {:meta {:time   {:key :start :order :desc}
                                    :head   {:range [0 3]}
                                    :hide   #{:meta :template :id}}})]
                (iterate (fn [[t journal]]
                           (let [t (+ t 1000000000 (rand-int 100000000))]
                             [t (add-entry journal {:start t
                                                    :output {:value (Math/sin
                                                                     (+ (/ t 100000000000)
                                                                        (rand)))}})])))
                (map second)
                (take 1000)
                (last)))

(select -jnl- {:range [:1m :5m] :sample 10})
=> (fn [entries]
     (= 10 (count entries)))

(first (select -jnl- {:range [:1m :5m] :sample 10}))
=> (contains {:start integer? :output.value number?})
raw docstring

select-seriesclj

(select-series entries series)

select data from the series

select data from the series
raw docstring

template-keysclj

(template-keys template)

get keys for the template

(template-keys (common/create-template {:data {:in "" :out "ABC"}})) => [:data.in :data.out]

get keys for the template

(template-keys (common/create-template {:data {:in  ""
                                               :out "ABC"}}))
=> [:data.in :data.out]
raw docstring

update-journal-bulkclj

(update-journal-bulk {:keys [limit entries] :as journal} new-entries)

adds multiple entries to the journal

adds multiple entries to the journal
raw docstring

update-journal-singleclj

(update-journal-single {:keys [limit entries] :as journal} entry)

adds a single entry to the journal

adds a single entry to the journal
raw docstring

update-metaclj

(update-meta journal meta)

updates journal meta. used for display

updates journal meta. used for display
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close