BerkeleyDB::SecIndices::Accessor

Simply drive your BerkeleyDB database with secondary indices
Download

BerkeleyDB::SecIndices::Accessor Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Dongxu Ma
  • Publisher web site:
  • http://search.cpan.org/~dongxu/

BerkeleyDB::SecIndices::Accessor Tags


BerkeleyDB::SecIndices::Accessor Description

Simply drive your BerkeleyDB database with secondary indices BerkeleyDB is one of the most famous flat/non-relational databases widely used. Depending on the very strong features offerred, one can implement fast cache, in-memory/embedded database, queue, btree and vice versa. Smart guys from both sleepycat and open-source world are working very hard to bring new wonderful stuff.Here you are touching another great feature of BerkeleyDB - Secondary Indicies. One can create several secondary databases for index purpose.A typical scenario is showed in code example above. The primary database whose name here is 'STUDENT' is associated with several secondary indicies. The index database's name, for instance, is one of the keys in primary database hash record. The hash constructs a table logically, thus one index database catches and groups all values of a specific table column. Later one can directly fetch record(s) from primary database or in-directly perform a match action via querying secondary index database.SYNOPSIS use BerkeleyDB::SecIndices::Accessor qw(EGET ELCK EPUT EUPD); my $student = []; push @$student, { NAME => 'tom', CLASS => 'one', GRADE => 'two', SCORE => 80, }; push @$student, { NAME => 'jerry', CLASS => 'two', GRADE => 'two', SCORE => 75, }; my $stubs = BerkeleyDB::SecIndices::Accessor::->_stubs; foreach (@$student) { my $rc = $stubs->{STUDENT}->{PUT}->($_); die "cannot put record into database STUDENT" if $rc == EPUT or $rc == ELCK; } my $count = $stubs->{STUDENT}->{COUNT}->(); print "so far we have $count record(s)\n"; $student = $stubs->{STUDENT}->{GETS}->($count); foreach my $s (@$student) { print "recno: ", $s->{KEY}, "\n"; print "name : ", $s->{CONTENT}->{NAME}, "\n"; print "score: ", $s->{CONTENT}->{SCORE}, "\n"; } $student = $stubs->{STUDENT}->{FIELDS}->{grade}->('two', 1); foreach my $s (@$student) { $s->{CONTENT}->{GRADE} = 'three'; my $rc = $stubs->{STUDENT}->{UPD}->( $s->{KEY}, $s->{CONTENT}); die "cannot update record in database STUDENT" if $rc == EUPD or $rc == ELCK; } my $number = $stubs->{STUDENT_INDEX}->{COUNTDUP}->{class}->('one'); print "we have $number students in class one\n"; Requirements: · Perl


BerkeleyDB::SecIndices::Accessor Related Software