akregator
c4_View Class Reference
#include <mk4.h>

Detailed Description
A collection of data rows.This is the central public data structure of Metakit (often called "table", "array", or "relation" in other systems).
Views are smart pointers to the actual collections, setting a view to a new value does not alter the collection to which this view pointed previously.
The elements of views can be referred to by their 0-based index, which produces a row-reference of type c4_RowRef. These row references can be copied, used to get or set properties, or dereferenced (in which case an object of class c4_Row is returned). Taking the address of a row reference produces a c4_Cursor, which acts very much like a pointer.
The following code creates a view with 1 row and 2 properties:
c4_StringProp pName ("name"); c4_IntProp pAge ("age"); c4_Row data; pName (data) = "John Williams"; pAge (data) = 43; c4_View myView; myView.Add(row);
Definition at line 230 of file mk4.h.
Public Member Functions | |
| int | Add (const c4_RowRef &) |
| int | AddProperty (const c4_Property &) |
| c4_View | Blocked () const |
| c4_View (const c4_View &) | |
| c4_View (const c4_Property &property_) | |
| c4_View (c4_Stream *) | |
| c4_View (c4_CustomViewer *) | |
| c4_View (c4_Sequence *=0) | |
| c4_View | Clone () const |
| int | Compare (const c4_View &) const |
| c4_View | Concat (const c4_View &) const |
| c4_View | Counts (const c4_View &, const c4_IntProp &) const |
| const char * | Description () const |
| c4_View | Different (const c4_View &) const |
| c4_View | Duplicate () const |
| c4_RowRef | ElementAt (int) |
| int | Find (const c4_RowRef &, int=0) const |
| int | FindProperty (int) |
| int | FindPropIndexByName (const char *) const |
| c4_RowRef | GetAt (int) const |
| int | GetIndexOf (const c4_RowRef &) const |
| bool | GetItem (int, int, c4_Bytes &) const |
| int | GetSize () const |
| c4_View | GroupBy (const c4_View &, const c4_ViewProp &) const |
| c4_View | Hash (const c4_View &, int=1) const |
| c4_View | Indexed (const c4_View &, const c4_View &, bool=false) const |
| void | InsertAt (int, const c4_View &) |
| void | InsertAt (int, const c4_RowRef &, int=1) |
| c4_View | Intersect (const c4_View &) const |
| bool | IsCompatibleWith (const c4_View &) const |
| c4_View | Join (const c4_View &, const c4_View &, bool=false) const |
| c4_View | JoinProp (const c4_ViewProp &, bool=false) const |
| int | Locate (const c4_RowRef &, int *=0) const |
| c4_View | Minus (const c4_View &) const |
| const c4_Property & | NthProperty (int) const |
| int | NumProperties () const |
| c4_View | operator, (const c4_Property &) const |
| c4_View & | operator= (const c4_View &) |
| c4_RowRef | operator[] (int) const |
| c4_View | Ordered (int=1) const |
| c4_View | Pair (const c4_View &) const |
| c4_Persist * | Persist () const |
| c4_View | Product (const c4_View &) const |
| c4_View | Project (const c4_View &) const |
| c4_View | ProjectWithout (const c4_View &) const |
| c4_View | ReadOnly () const |
| void | RelocateRows (int, int, c4_View &, int) |
| c4_View | RemapWith (const c4_View &) const |
| void | RemoveAll () |
| void | RemoveAt (int, int=1) |
| c4_View | Rename (const c4_Property &, const c4_Property &) const |
| int | RestrictSearch (const c4_RowRef &, int &, int &) |
| int | Search (const c4_RowRef &) const |
| c4_View | Select (const c4_RowRef &) const |
| c4_View | SelectRange (const c4_RowRef &, const c4_RowRef &) const |
| void | SetAt (int, const c4_RowRef &) |
| void | SetAtGrow (int, const c4_RowRef &) |
| void | SetItem (int, int, const c4_Bytes &) const |
| void | SetSize (int, int=-1) |
| c4_View | Slice (int, int=-1, int=1) const |
| c4_View | Sort () const |
| c4_View | SortOn (const c4_View &) const |
| c4_View | SortOnReverse (const c4_View &, const c4_View &) const |
| c4_View | Union (const c4_View &) const |
| c4_View | Unique () const |
| ~c4_View () | |
Protected Member Functions | |
| void | _DecSeqRef () |
| void | _IncSeqRef () |
Protected Attributes | |
| c4_Sequence * | _seq |
Friends | |
| bool | operator!= (const c4_View &, const c4_View &) |
| bool | operator< (const c4_View &, const c4_View &) |
| bool | operator<= (const c4_View &, const c4_View &) |
| bool | operator== (const c4_View &, const c4_View &) |
| bool | operator> (const c4_View &, const c4_View &) |
| bool | operator>= (const c4_View &, const c4_View &) |
Constructor & Destructor Documentation
| c4_View::c4_View | ( | c4_Sequence * | seq_ = 0 |
) |
| c4_View::c4_View | ( | c4_CustomViewer * | viewer_ | ) |
| c4_View::c4_View | ( | c4_Stream * | stream_ | ) |
| c4_View::c4_View | ( | const c4_Property & | property_ | ) |
| c4_View::c4_View | ( | const c4_View & | view_ | ) |
| c4_View::~c4_View | ( | ) |
Member Function Documentation
| void c4_View::_DecSeqRef | ( | ) | [protected] |
| void c4_View::_IncSeqRef | ( | ) | [protected] |
| int c4_View::Add | ( | const c4_RowRef & | newElem_ | ) |
| int c4_View::AddProperty | ( | const c4_Property & | prop_ | ) |
| c4_View c4_View::Blocked | ( | ) | const |
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, with the structure of the subview being as needed. An example of a blocked view definition which will act like a single one containing 2 properties:
c4_View raw = storage.GetAs("people[_B[name:S,age:I]]"); c4_View flat = raw.Blocked(); ... flat.GetSize() ... flat.InsertAt(...)
This view operation is based on a custom viewer and is modifiable.
| c4_View c4_View::Clone | ( | ) | const |
| int c4_View::Compare | ( | const c4_View & | view_ | ) | const |
Create view with rows from another view appended.
Constructs a view which has all rows of this view, and all rows of the second view appended. The structure of the second view is assumed to be identical to this one. This operation is a bit similar to appending all rows from the second view, but it does not actually store the result anywhere, it just looks like it.
This view operation is based on a custom viewer and is modifiable.
| c4_View c4_View::Counts | ( | const c4_View & | keys_, | |
| const c4_IntProp & | result_ | |||
| ) | const |
Create view with count of duplicates, when grouped by key.
This is similar to c4_View::GroupBy, but it determines only the number of rows in each group and does not create a nested view.
This view operation is based on a read-only custom viewer.
- Parameters:
-
keys_ properties in this view determine grouping result_ new count property defined in result
| const char* c4_View::Description | ( | ) | const |
| c4_View c4_View::Duplicate | ( | ) | const |
| c4_RowRef c4_View::ElementAt | ( | int | ) |
| int c4_View::Find | ( | const c4_RowRef & | crit_, | |
| int | start_ = 0 | |||
| ) | const |
Find index of the the next entry matching the specified key.
Defaults to linear search, but hash- and ordered-views will use a better algorithm if possible. Only the properties present in the search key are used to determine whether a row matches the key.
- Returns:
- position where match occurred
- Return values:
-
-1 if not found
- Parameters:
-
crit_ the value to look for start_ the index to start with
| int c4_View::FindProperty | ( | int | ) |
| int c4_View::FindPropIndexByName | ( | const char * | name_ | ) | const |
| c4_RowRef c4_View::GetAt | ( | int | ) | const |
| int c4_View::GetIndexOf | ( | const c4_RowRef & | row_ | ) | const |
| bool c4_View::GetItem | ( | int | row_, | |
| int | col_, | |||
| c4_Bytes & | buf_ | |||
| ) | const |
| int c4_View::GetSize | ( | ) | const |
| c4_View c4_View::GroupBy | ( | const c4_View & | keys_, | |
| const c4_ViewProp & | result_ | |||
| ) | const |
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.
This view operation is based on a read-only custom viewer.
- Parameters:
-
keys_ properties in this view determine grouping result_ name of new subview defined in result
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 numKeys_ properties of the underlying view.
The map_ 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 view must be "_H:I,_R:I".
This view is modifiable. Insertions and changes to key field properties can cause rows to be repositioned to maintain hash uniqueness. Careful: when a row is changed in such a way that its key is the same as in another row, that other row will be deleted from the view.
Example of use:
| c4_View c4_View::Indexed | ( | const c4_View & | map_, | |
| const c4_View & | props_, | |||
| bool | unique_ = false | |||
| ) | const |
Create mapped view which maintains an index permutation.
This is an identity view which somewhat resembles the ordered view, it maintains a secondary "map" view to contain the permutation to act as an index. The indexed view presents the same order of rows as the underlying view, but the index map is set up in such a way that binary search is possible on the keys specified. When the "unique" parameter is true, insertions which would create a duplicate key are ignored.
This view is modifiable. Careful: when a row is changed in such a way that its key is the same as in another row, that other row will be deleted from the view.
| void c4_View::InsertAt | ( | int | index_, | |
| const c4_View & | view_ | |||
| ) |
| void c4_View::InsertAt | ( | int | , | |
| const c4_RowRef & | , | |||
| int | = 1 | |||
| ) |
| bool c4_View::IsCompatibleWith | ( | const c4_View & | dest_ | ) | const |
Create view which is the relational join on the given keys.
This view operation is based on a read-only custom viewer.
- Parameters:
-
keys_ properties in this view determine the join view_ second view participating in the join outer_ true: keep rows with no match in second view
| c4_View c4_View::JoinProp | ( | const c4_ViewProp & | sub_, | |
| bool | outer_ = false | |||
| ) | const |
Create view with a specific subview expanded, like a join.
This operation is the inverse of c4_View::GroupBy, expanding all rows in specified subview and returning a view which looks as if the rows in each subview were "expanded in place".
This view operation is based on a read-only custom viewer.
- Parameters:
-
sub_ name of the subview to expand outer_ true: keep rows with empty subviews
| int c4_View::Locate | ( | const c4_RowRef & | crit_, | |
| int * | pos_ = 0 | |||
| ) | const |
Create view with all rows not in the given view (no dups).
Calculates set-difference of this view minus arg view. Result is a subset, unlike c4_View::Different. Will only work if both input views are sets, i.e. they have no duplicate rows in them.
This view operation is based on a read-only custom viewer.
- Parameters:
-
view_ the second view
| const c4_Property & c4_View::NthProperty | ( | int | index_ | ) | const |
| int c4_View::NumProperties | ( | ) | const |
| c4_View c4_View::operator, | ( | const c4_Property & | prop_ | ) | const |
Defines a column for a property.
The following code defines an empty view with three properties:
c4_IntProp p1, p2, p3; c4_View myView = (p1, p2, p3);
- Returns:
- the new view object (without any data rows)
- See also:
- c4_Property
| c4_RowRef c4_View::operator[] | ( | int | ) | const |
| c4_View c4_View::Ordered | ( | int | numKeys_ = 1 |
) | const |
Create mapped view which keeps its rows ordered.
This is an identity view, which has as only use to inform Metakit that the underlying view can be considered to be sorted on its first numKeys_ properties. The effect is that c4_View::Find will try to use binary search when the search includes key properties (results will be identical to unordered views, the find will just be more efficient).
This view is modifiable. Insertions and changes to key field properties can cause rows to be repositioned to maintain the sort order. Careful: when a row is changed in such a way that its key is the same as in another row, that other row will be deleted from the view.
This view can be combined with c4_View::Blocked, to create a 2-level btree structure.
Create view which pairs each row with corresponding row.
This is like a row-by-row concatenation. Both views must have the same number of rows, the result has all properties from this view plus any other properties from the other view.
This view operation is based on a custom viewer and is modifiable.
| c4_Persist* c4_View::Persist | ( | ) | const |
Create view which is the cartesian product with given view.
The cartesian product is defined as every combination of rows in both views. The number of entries is the product of the number of entries in the two views, properties which are present in both views will use the values defined in this view.
This view operation is based on a read-only custom viewer.
Create view with the specified property arrangement.
The result is virtual, it merely maintains a permutation to access the underlying view. This "derived" view uses change notification to track changes to the underlying view, but this only works when based on views which properly generate change notifications (.e. raw views, selections, and other projections).
Create derived view with some properties omitted.
The result is virtual, it merely maintains a permutation to access the underlying view. This "derived" view uses change notification to track changes to the underlying view, but this only works when based on views which properly generate change notifications (.e. raw views, selections, and other projections).
| c4_View c4_View::ReadOnly | ( | ) | const |
| void c4_View::RelocateRows | ( | int | from_, | |
| int | count_, | |||
| c4_View & | dest_, | |||
| int | pos_ | |||
| ) |
Move attached rows to somewhere else in same storage.
There is a lot of trickery going on here. The whole point of this code is that moving rows between (compatible!) subviews should not use copying when potentially large memo's and subviews are involved. In that case, the best solution is really to move pointers, not data.
Create view which remaps another given view.
Remapping constructs a view with the rows indicated by another view. The first property in the order_ view must be an int property with index values referring to this one. The size of the resulting view is determined by the order_ view and can differ, for example to act as a subset selection (if smaller).
This view operation is based on a custom viewer and is modifiable.
| void c4_View::RemoveAll | ( | ) |
| void c4_View::RemoveAt | ( | int | , | |
| int | = 1 | |||
| ) |
| c4_View c4_View::Rename | ( | const c4_Property & | old_, | |
| const c4_Property & | new_ | |||
| ) | const |
| int c4_View::RestrictSearch | ( | const c4_RowRef & | c_, | |
| int & | pos_, | |||
| int & | count_ | |||
| ) |
| int c4_View::Search | ( | const c4_RowRef & | crit_ | ) | const |
Create view with rows matching the specified value.
The result is virtual, it merely maintains a permutation to access the underlying view. This "derived" view uses change notification to track changes to the underlying view, but this only works when based on views which properly generate change notifications (.e. raw views, other selections, and projections).
Create view with row values within the specified range.
The result is virtual, it merely maintains a permutation to access the underlying view. This "derived" view uses change notification to track changes to the underlying view, but this only works when based on views which properly generate change notifications (.e. raw views, other selections, and projections).
- Parameters:
-
low_ values of the lower bounds (inclusive) high_ values of the upper bounds (inclusive)
| void c4_View::SetAt | ( | int | , | |
| const c4_RowRef & | ||||
| ) |
| void c4_View::SetAtGrow | ( | int | index_, | |
| const c4_RowRef & | newElem_ | |||
| ) |
| void c4_View::SetItem | ( | int | row_, | |
| int | col_, | |||
| const c4_Bytes & | buf_ | |||
| ) | const |
| void c4_View::SetSize | ( | int | , | |
| int | = -1 | |||
| ) |
| c4_View c4_View::Slice | ( | int | first_, | |
| int | limit_ = -1, |
|||
| int | step_ = 1 | |||
| ) | const |
Create view which is a segment/slice (default is up to end).
Returns a view which is a subset, either a contiguous range, or a "slice" with element taken from every step_ entries. If the step is negative, the same entries are returned, but in reverse order (start_ is still lower index, it'll then be returned last).
This view operation is based on a custom viewer and is modifiable.
| c4_View c4_View::Sort | ( | ) | const |
Create view with all rows in natural (property-wise) order.
The result is virtual, it merely maintains a permutation to access the underlying view. This "derived" view uses change notification to track changes to the underlying view, but unfortunately there are some major limitations with this scheme - one of them being that deriving another view from this sorted one will not properly track changes.
Create view sorted according to the specified properties.
The result is virtual, it merely maintains a permutation to access the underlying view. This "derived" view uses change notification to track changes to the underlying view, but unfortunately there are some major limitations with this scheme - one of them being that deriving another view from this sorted one will not properly track changes.
Create sorted view, with some properties sorted in reverse.
The result is virtual, it merely maintains a permutation to access the underlying view. This "derived" view uses change notification to track changes to the underlying view, but unfortunately there are some major limitations with this scheme - one of them being that deriving another view from this sorted one will not properly track changes.
- Parameters:
-
up_ the view which defines the sort order down_ subset of up_, defines reverse order
| c4_View c4_View::Unique | ( | ) | const |
Friends And Related Function Documentation
Member Data Documentation
c4_Sequence* c4_View::_seq [protected] |
The documentation for this class was generated from the following files:
KDE 4.2 API Reference