create view. See also mk:view and property application forms.
get structure of the VIEW
(mk:row VIEW ROWINDEX)
(set! (mk:row VIEW ROWINDEX) ROW/ROWREF)
get/set the row of the VIEW (view will grow if required).
(mk:item VIEW ROWINDEX COLINDEX)
(set! (mk:item VIEW ROWINDEX COLINDEX) NEWDATA)
get/set the value of the COLINDEX-th property in the ROWINDEX row as a byte-vector.
(mk:item VIEW ROWINDEX PROPERTY)
(set! (mk:item VIEW ROWINDEX PROPERTY) NEWDATA)
get/set the value of the PROPERTY in the ROWINDEX row (actually, it is a shorthand for the mk:value and mk:row combination).
(set! (mk:size VIEW) NEWSIZE)
manage the size of the VIEW.
(mk:insert! VIEW ROW/ROWREF)
append a row.
(mk:insert! VIEW POSITION ROW/ROWREF [COUNT = 1])
insert COUNT instances if the row at POSITION.
(mk:insert! VIEW POSITION VIEW1)
insert contents of the VIEW1 into VIEW at POSITION.
(mk:remove! VIEW [POSITION [COUNT = 1]])
remove COUNT rows at POSITION. When no POSITION was given, remove all rows.
(mk:relocate! VIEW FROMPOS COUNT DESTVIEW POS)
move VIEW's rows to the DESTVIEW in same storage.
return the number of properties present in this view.
(mk:prop VIEW NAME)
index of the property with NAME in the VIEW.
(mk:prop VIEW N)
returns the N-th property (using zero-based indexing).
(mk:add-prop! VIEW PROPERTY)
adds a property column to a view if not already present.
(mk:index-of VIEW ROWREF)
return the index of the specified row in this view.
(mk:compare VIEW VIEW1)
compare two views lexicographically.
(mk:find VIEW ROW/ROWREF [START])
(mk:find VIEW PRED [START])
find index of the the next entry matching the specified key or predicate.
(mk:find VIEW 'restrict POSITION COUNT)
restrict the search range for rows. Return three values: success flag, POSITION and COUNT.
(mk:find VIEW 'sorted ROW/ROWREF)
search for a key, using the native sort order of the view (gives unpredictable results on the unsorted view!).
(mk:find VIEW 'count POS)
return two values: number of matching keys and pos of first one.
(mk:find* VIEW ARGS ...)
the same as mk:find, but return a rowref rather than index. Return #f if the row cannot found.
(mk:transform VIEW OPERATION ARGS)
return view with some combination of the VIEW data (several derived views are able to mirror changes to the base view).
(mk:transform VIEW (list OPERATION1 ...) (list OPARGS1 ...))
combinator to perform several mk:transform operations at once
Valid transformations are:
- duplicate - construct a new view with a copy of the data.
- clone - construct a new view with the same structure but no data.
- sort - create view with all rows in natural (property-wise) order.
- unique - create view with all duplicate rows omitted.
- read-only - create an identity view which only allows reading.
blocked - create mapped view which blocks its rows in two levels. This view acts like a large flat view, even though the actual rows are stored in blocks, which are rebalanced automatically to maintain a good trade-off between block size and number of blocks. The underlying view must be defined with a single view property named _B, with the structure of the subview being as needed. See also define-blocked-view and Blocked views.  An example of a blocked view definition which will act like a single one containing 2 properties:(define raw (mk:view storage "people[_B[name:S,age:I]]")) (define flat (mk:transform raw 'blocked)) ... (display (mk:size flat)) ... (mk:insert! flat ...)
sort-on VIEW1 - create view sorted according to the specified properties. E.g. (mk:transform v1 'sort-on (ip)) will create the new view from the v1 data, sorted by ip.
project VIEW1 - create view with the specified property arrangement.  E.g. (mk:transfrom v1 'project (sp ip)) will return the view with rearranged properties (sp will be the firts and ip the second).
project-without VIEW1 - create derived view with some properties omitted.  E.g., (mk:tranform v1 'project-without (ip)) will return the view without the ip property.
product VIEW1 - create view which is the cartesian product with given view.
remap-with VIEW - create view which remaps another given view. 
pair VIEW1 - create view which pairs each row with corresponding row. 
concat VIEW1 - create view with rows from another view appended. 
union VIEW1 - create view which is the set union (assumes no duplicate rows).
intersect VIEW1 - create view with all rows also in the given view (no dups).
different VIEW1 - create view with all rows not in both views (no dups).
minus VIEW1 - create view with all rows not in the given view (no dups).
select ROW/ROWREF - create view with rows matching the specified value.
sort-on-reverse VIEW1 VIEW2 - create sorted view, with some properties sorted in reverse. E.g., (mk:transform v1 'sort-on-reverse (ip) (sp)) will create the view with the data from v1, but sorted by ip and reverse sorted by sp.
select-range ROW/ROWREF1 ROW/ROWREF2 - create view with row values within the specified range.
rename PROP1 PROP2 - create view with one property renamed (must be of same type). 
group-by VIEW1 VIEW-PROP - create view with a subview, grouped by the specified properties. This operation is similar to the SQL GROUP BY, but it takes advantage of the fact that Metakit supports nested views. The view returned from this member has one row per distinct group, with an extra view property holding the remaining properties. If there are N rows in the original view matching key X, then the result is a row for key X, with a subview of N rows. The properties of the subview are all the properties not in the key. E.g., (mk:transform v1 'group-by (ip) vp) will group by ip.
counts VIEW1 INT-PROP - create view with count of duplicates, when grouped by key. This is similar to group-by, but it determines only the number of rows in each group and does not create a nested view.
hash VIEW1 [COUNT] - create mapped view which adds a hash lookup layer.  This view creates and manages a special hash map view, to implement a fast find on the key. The key is defined to consist of the first COUNT properties of the underlying view. The VIEW1 view must be empty the first time this hash view is used, so that Metakit can fill it based on whatever rows are already present in the underlying view. After that, neither the underlying view nor the map view may be modified other than through this hash mapping layer. The defined structure of the map VIEW1 must be _H:I,_R:I. See also define-hashed-view and Hashed views.  Example:(define raw (mk:view storage "people[name:S,age:I]")) (define datah (mk:view storage "people_H[_H:I,_R:I]")) (define hash (mk:transform raw 'hash datah 1)) ... (display (mk:size hash)) ... (mk:insert! hash)
join KEYS-VIEW VIEW2 [OUTER? = #f] - create view which is the relational join on the given keys (as defined by KEYS-VIEW).
join-prop VIEW-PROP [OUTER? = #f] - create view with a specific subview expanded, like a join.
filter PRED - create brand new view, that contains rows from original VIEW, satisfying predicate PRED. 
filter-map PROC - create view from rows, that satisfy predicate PROC (which is a procedure of a ROWREF argument). It must return either #f (don't use this row) or the row to insert into derived view. 
map PROC - create view with rows, that are result of the application PROC procedure to the rows of the original view. 
|||The resulting view is updatable.|
|||Slice operation may be useful to apply other transformation only to the some part of the view.|