E q u i 4 MetaKit Tips and Tricks
December 1999

This page list some ideas and background information related to the use of MetaKit. If you have suggestions, please send them to jcw@equi4.com ...

Streaming Some details about streaming and on-demand loading
Faster What to do and what to avoid for maximum speed
Smaller How to manage data in the most compact format




Streaming - Some details about streaming and on-demand loading

When saving data, MetaKit uses different formats, depending on whether the data was saved with c4_Storage::Commit or with c4_Storage::SaveToStream. This has a number of consequences on how and when data is loaded back in:
  Saved using     Loaded as     Comments  
Commit
Commit
SaveToStream
SaveToStream
File
Stream
File
Stream
The normal case, loads data on-demand
This combination is not allowed!
Ok, will load all data during open
Loads all data serially right away
As you can see in this overview, random-access and streaming can be mixed in three out of four ways. Once loaded, you can again save using either c4_Storage::Commit or c4_Storage::SaveToStream.

When random-access and streaming are mixed on a storage object, the following will happen:

  • Files are only modified (conceptually) during a call to c4_Storage::Commit.
  • c4_Storage::SaveToStream makes a snapshot of the current (uncommitted) state.

It is therefore possible to open a file, apply a few changes, save the changed contents to a stream, and then close the file without committing those changes. Streaming does not interfere with the commit/rollback mechanism.




Faster - What to do and what to avoid for maximum speed

The data structures used in MetaKit can have surprising effects on performance, both positively and negatively. Here are a few suggestions which should help in most cases:

  • Preallocate rows - if the number or rows to add is known in advance, use c4_View::SetSize to set the view size accordingly. Fixed-size properties will need to do fewer internal reallocations if pre-allocated.

    When inserting several rows, consider inserting them all with a dummy value first, and then using a loop to adjust each of the inserted values.

  • Limit the use of c4_Rowebody bgcolor=white>

    App Icon MetaKit sample code - MkOptim


    This a generic utility for the MetaKit library.

    What it does: MkOptim is a utility program which copies data from one MetaKit file to another. This has the effect of optimizing the datafile (automatic integer sizing and compaction to remove all unused space) and of converting old datafile formats to the current one.

    What it illustrates: ***TBD***

    How to use it: ***TBD***.

    Known problems: None.

    Files in EXAMPLES\MKOPTIM:

    MKOPTIM.CPP - MkOptim main program
    MKOPTIM.MAK, MKOPTIM.DSP - MSVC 5.0 project makefiles for Win32


    ||   Roadmap   Class Index   Sample Index   ||   Introduction   Tips and Tricks   ||
    ./usr/share/doc/libmetakit1/doc/api/c4_BytesRef_info.html0100644000000000000000000000547207250221514022136 0ustar rootroot class c4_BytesRef - Used to get or set binary object values.
    operator c4_Bytes () const;
    Get the value as binary object

    c4_BytesRef (const c4_Reference&);
    Constructor

    c4_BytesRef& operator= (const c4_Bytes&);
    Set the value to the specified binary object

    bool c4_Reference::GetData (c4_Bytes&) const;
    Retrieve the value of the referenced data item

    int c4_Reference::GetSize () const;
    Return width of the referenced data item

    void c4_Reference::SetData (const c4_Bytes&) const;
    Store a value into the referenced data item

    c4_Cursor c4_Reference::_cursor;

    const c4_Property& c4_Reference::_property;

    c4_Reference& c4_Reference::operator= (const c4_Reference&);
    Assignment of one data item


    class c4_By