Skip to content

Commit 9f6ed70

Browse files
author
Paula Gearon
committed
Partial impl. Not resolving
1 parent 130225f commit 9f6ed70

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/naga/storage/store_util.clj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(ns ^{:doc "Some common utilities for storage functions"
2+
:author "Paula Gearon"}
3+
naga.storage.store-util
4+
(:require [schema.core :as s]
5+
[naga.schema.structs :as st :refer [EPVPattern Value]]
6+
[naga.store :as store]))
7+
8+
(s/defn project-row :- [s/Any]
9+
"Creates a new EPVPattern from an existing one, based on existing bindings.
10+
Uses the mapping to copy from columns in 'row' to overwrite variables in 'pattern'.
11+
'pattern' must be a vector.
12+
The index mappings have already been found and are in the 'mapping' argument"
13+
[storage
14+
patterns :- [EPVPattern]
15+
mapping :- {s/Num s/Num}
16+
row :- [Value]]
17+
(let [wide-pattern (vec (apply concat patterns))
18+
get-node (memoize (fn [n] (store/new-node storage)))
19+
update-pattern (fn [p [t f]]
20+
(let [v (if (< f 0) (get-node f) (nth row f))]
21+
(assoc p t v)))]
22+
(partition 3
23+
(reduce update-pattern wide-pattern mapping))))

0 commit comments

Comments
 (0)