Joshua Nathaniel Pritikin > ObjStore-1.59 > ObjStore::Table2

Download:
ObjStore-1.59.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.02   Source  

NAME ^

  ObjStore::Table2 - Simulated RDBMS Tables

SYNOPSIS ^

  # posh 1.21 (Perl 5.00454 ObjectStore Release 5.0.1.0)
  cd table-test ObjStore::Table2::Database

  my $a = $db->array; for (1..10) { $a->_Push({row => $_}) }

  $db->table->new_index('Field', 'row');
  $db->table->build_indices;

DESCRIPTION ^

 $at = TABLE ObjStore::Table2 {
  [10] of ObjStore::HV {
    row => 1,
  },
  indices: ROW;
 },

Unstructured perl databases are probably under-constrained for most applications. Tables standardize the interface for storing a bunch of records and their associated indices.

Raw Representation

 $at = ObjStore::Table2 {
  _array => ObjStore::AV [
    ObjStore::HV {
      row => 1,
    },
    ObjStore::HV {
      row => 2,
    },
    ObjStore::HV {
      row => 3,
    },
    ...
  ],
  _index_segments => 1,
  row => ObjStore::Table::Index::Field {
    _field => 'row',
    _name => 'row',
    _segment => 6,
    _table => ObjStore::Ref => ObjStore::Table2 ...
    ctime => 882030349,
    map => ObjStore::HV {
      1 => ObjStore::HV ...
      10 => ObjStore::HV ...
      2 => ObjStore::HV ...
      ...
    },
    row => ObjStore::HV ...
  },
 },

API

Representation Independent API

A database can essentially be a table or tables can be stored within a database. The implementation is only slightly different in either case. To smooth things over, a few accessor methods are provided that always work consistently.

ObjStore::Table::Index

Base class for indices.

ObjStore::Table::Index::Field - DEPRECIATED

  $table->new_index('Field', $name, $field)

A basic unique index over all records. $field is an access path into the records to be indexed. For example, if your records looks like this:

  { f1 => [1,2,3] }

The access path would be "f1->0" to index the zeroth element of the array at hash key f1.

ObjStore::Table::Index::GroupBy - DEPRECIATED

  $table->new_index('GroupBy', $name, $field);

Groups all records into arrays indexed by $field. $field is an access path into the records to be indexed.

MIGRATION ^

Both ObjStore::HV::Database and ObjStore::Table are bless-migratible to ObjStore::Table2.

The old ObjStore::Table stored all indices in a hash under the top-level. Table2 stores them directly in the top-level. This should make index lookups slightly more efficient.

BUGS ^

Usage is a bit more cumbersome than I would like. The interface will change slightly as perl supports more overload-type features.

TODO ^

syntax highlighting: