• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

akregator

c4_View Class Reference

#include <mk4.h>

Inheritance diagram for c4_View:

Inheritance graph
[legend]

List of all members.


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  ) 

Construct a view based on a sequence.

Definition at line 170 of file view.cpp.

c4_View::c4_View ( c4_CustomViewer *  viewer_  ) 

Construct a view based on a custom viewer.

Definition at line 178 of file view.cpp.

c4_View::c4_View ( c4_Stream *  stream_  ) 

Construct a view based on an input stream.

Definition at line 187 of file view.cpp.

c4_View::c4_View ( const c4_Property &  property_  ) 

Construct an empty view with one property.

Definition at line 195 of file view.cpp.

c4_View::c4_View ( const c4_View &  view_  ) 

Copy constructor.

Definition at line 202 of file view.cpp.

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_  ) 

Add a new entry, same as "SetAtGrow(GetSize(), ...)".

Returns:
the index of the newly added row

Definition at line 244 of file view.cpp.

int c4_View::AddProperty ( const c4_Property &  prop_  ) 

Adds a property column to a view if not already present.

Returns:
0-based column position of the property

Definition at line 278 of file view.cpp.

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.

Definition at line 755 of file view.cpp.

c4_View c4_View::Clone (  )  const

Constructs a new view with the same structure but no data.

Structural information can only be maintain for the top level, subviews will be included but without any properties themselves.

Definition at line 266 of file view.cpp.

int c4_View::Compare ( const c4_View &  view_  )  const

Compare two views lexicographically (rows 0..N-1).

Definition at line 927 of file view.cpp.

c4_View c4_View::Concat ( 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.

Definition at line 562 of file view.cpp.

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

Definition at line 600 of file view.cpp.

const char* c4_View::Description (  )  const

c4_View c4_View::Different ( const c4_View &  view_  )  const

Create view with all rows not in both views (no dups).

Calculates the "XOR" of two sets. This 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.

Definition at line 649 of file view.cpp.

c4_View c4_View::Duplicate (  )  const

Construct a new view with a copy of the data.

The copy is a deep copy, because subviews are always copied in full.

Definition at line 254 of file view.cpp.

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

Definition at line 821 of file view.cpp.

int c4_View::FindProperty ( int   ) 

int c4_View::FindPropIndexByName ( const char *  name_  )  const

Find the index of a property, given its name.

Returns:
0-based column index
Return values:
-1 property not present in this view
Parameters:
name_  property name (case insensitive)

Definition at line 295 of file view.cpp.

c4_RowRef c4_View::GetAt ( int   )  const

int c4_View::GetIndexOf ( const c4_RowRef &  row_  )  const

Return the index of the specified row in this view (or -1).

This function can be used to "unmap" an index of a derived view back to the original underlying view.

Definition at line 802 of file view.cpp.

bool c4_View::GetItem ( int  row_,
int  col_,
c4_Bytes &  buf_ 
) const

Get a single data item in a generic way.

This can be used to access view data in a generalized way. Useful for c4_CustomViewers which are based on other views.

Returns:
true if the item is non-empty

Definition at line 222 of file view.cpp.

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

Definition at line 586 of file view.cpp.

c4_View c4_View::Hash ( const c4_View &  map_,
int  numKeys_ = 1 
) const

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 data = storage.GetAs("people[name:S,age:I]");
  c4_View datah = storage.GetAs("people_H[_H:I,_R:I]");
  c4_View hash = raw.Hash(datah, 1);
  ... hash.GetSize() ...
  hash.Add(...)

Definition at line 733 of file view.cpp.

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.

Definition at line 792 of file view.cpp.

void c4_View::InsertAt ( int  index_,
const c4_View &  view_ 
)

Insert copies of all rows of the specified view.

Definition at line 325 of file view.cpp.

void c4_View::InsertAt ( int  ,
const c4_RowRef &  ,
int  = 1 
)

c4_View c4_View::Intersect ( const c4_View &  view_  )  const

Create view with all rows also in the given view (no dups).

Calculates the set intersection. This 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.

Definition at line 634 of file view.cpp.

bool c4_View::IsCompatibleWith ( const c4_View &  dest_  )  const

Definition at line 337 of file view.cpp.

c4_View c4_View::Join ( const c4_View &  keys_,
const c4_View &  view_,
bool  outer_ = false 
) 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

Definition at line 690 of file view.cpp.

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

Definition at line 679 of file view.cpp.

int c4_View::Locate ( const c4_RowRef &  crit_,
int *  pos_ = 0 
) const

Return number of matching keys, and pos of first one as arg.

Definition at line 877 of file view.cpp.

c4_View c4_View::Minus ( const c4_View &  view_  )  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

Definition at line 665 of file view.cpp.

const c4_Property & c4_View::NthProperty ( int  index_  )  const

Returns the N-th property (using zero-based indexing).

Returns:
reference to the specified property
Parameters:
index_  the zero-based property index

Definition at line 285 of file view.cpp.

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

Definition at line 318 of file view.cpp.

c4_View & c4_View::operator= ( const c4_View &  view_  ) 

Makes this view the same as another one.

Definition at line 207 of file view.cpp.

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.

Definition at line 775 of file view.cpp.

c4_View c4_View::Pair ( const c4_View &  view_  )  const

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.

Definition at line 548 of file view.cpp.

c4_Persist* c4_View::Persist (  )  const

c4_View c4_View::Product ( const c4_View &  view_  )  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.

Definition at line 522 of file view.cpp.

c4_View c4_View::Project ( const c4_View &  in_  )  const

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).

Definition at line 484 of file view.cpp.

c4_View c4_View::ProjectWithout ( const c4_View &  out_  )  const

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).

Definition at line 496 of file view.cpp.

c4_View c4_View::ReadOnly (  )  const

Create an identity view which only allows reading.

This view operation is based on a custom viewer.

Definition at line 703 of file view.cpp.

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.

Definition at line 373 of file view.cpp.

c4_View c4_View::RemapWith ( const c4_View &  view_  )  const

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.

Definition at line 536 of file view.cpp.

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

Create view with one property renamed (must be of same type).

This view operation is based on a custom viewer and is modifiable.

Definition at line 570 of file view.cpp.

int c4_View::RestrictSearch ( const c4_RowRef &  c_,
int &  pos_,
int &  count_ 
)

Restrict the search range for rows.

Definition at line 809 of file view.cpp.

int c4_View::Search ( const c4_RowRef &  crit_  )  const

Search for a key, using the native sort order of the view.

Returns:
position where found, or where it may be inserted, this position can also be just past the last row

Definition at line 862 of file view.cpp.

c4_View c4_View::Select ( 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).

Definition at line 457 of file view.cpp.

c4_View c4_View::SelectRange ( const c4_RowRef &  low_,
const c4_RowRef &  high_ 
) const

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)

Definition at line 469 of file view.cpp.

void c4_View::SetAt ( int  ,
const c4_RowRef &   
)

void c4_View::SetAtGrow ( int  index_,
const c4_RowRef &  newElem_ 
)

Set an entry, growing the view if needed.

Definition at line 234 of file view.cpp.

void c4_View::SetItem ( int  row_,
int  col_,
const c4_Bytes &  buf_ 
) const

Set a single data item in a generic way.

Definition at line 228 of file view.cpp.

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.

Definition at line 509 of file view.cpp.

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.

Definition at line 414 of file view.cpp.

c4_View c4_View::SortOn ( const c4_View &  up_  )  const

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.

Definition at line 426 of file view.cpp.

c4_View c4_View::SortOnReverse ( const c4_View &  up_,
const c4_View &  down_ 
) const

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

Definition at line 440 of file view.cpp.

c4_View c4_View::Union ( const c4_View &  view_  )  const

Create view which is the set union (assumes no duplicate rows).

Calculates the set union. This 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.

Definition at line 623 of file view.cpp.

c4_View c4_View::Unique (  )  const

Create view with all duplicate rows omitted.

This view operation is based on a read-only custom viewer.

Definition at line 611 of file view.cpp.


Friends And Related Function Documentation

bool operator!= ( const c4_View &  ,
const c4_View &   
) [friend]

bool operator< ( const c4_View &  ,
const c4_View &   
) [friend]

bool operator<= ( const c4_View &  ,
const c4_View &   
) [friend]

bool operator== ( const c4_View &  ,
const c4_View &   
) [friend]

bool operator> ( const c4_View &  ,
const c4_View &   
) [friend]

bool operator>= ( const c4_View &  ,
const c4_View &   
) [friend]


Member Data Documentation

c4_Sequence* c4_View::_seq [protected]

Definition at line 233 of file mk4.h.


The documentation for this class was generated from the following files:
  • mk4.h
  • view.cpp

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir