Aggregate

March 13, 2014 ยท View on GitHub

Aggregate is a small persistance framework with a clean API and full ACID features that uses OmniBase as backend and supports BTree-based indexing.

##Motivation The motivation for this is to have a clean API to use in persistent models. The trade off is biased towards having something less general but easier to use.

##Applicability Whatever you need to save with almost zero configuration and yet, with ACID features. It uses OmniBase so I say it should be good for small repositories (by small I mean way below <<2TB)

###Loading

Use this snippet to load it into your Pharo* image:

Gofer it 
	smalltalkhubUser: 'Pharo'
	project: 'MetaRepoForPharo30'; 
	package: 'ConfigurationOfAggregate';
	load.

(Smalltalk at: #ConfigurationOfAggregate) load

###Examples

Make a session to the odb (it will create one if needed):

pool := ARODBPool onPath: ('aha' / 'mhm') asFileReference path.

Saving a new dummy person aggregate

pool commit:[
	ARDummyUser new
		firstName: 'Chewbacca';
		save].

Fetching all dummy person aggregates (and read-only-ish make them sing)

pool readOnly:[
	ARDummyUser findAll do:[:wookie| 
		wookie sayGrroooouuugggaaaghhh]].

Fetching Chewbaccas that ...

pool readOnly:[
	ARDummyUser withFirstName: 'Chewbacca' ].
	

are being...

ARDummyPerson class>>withFirstName: aName
 	^ self storage find: self where: #firstName is: aName

...indexed because they have this class side method:

ARDummyPerson class>>indices
	"Answers the indices for this aggregate
	so it performs well for the application using it.
	Note: a repository index rebuild is needed when this definition changes"


	^ super indices
	add: (ARAttributeIndex new 
			aggregateClass: self; 
			selector: #firstName;
			keySize: self nameKeySize;
			yourself);
	yourself

Garbage collect the database

pool purify

###Performance

Well is filebased BTrees so...

Go ahed and take a look here:

ARIndexingTest>>benchmarksBasic

###Contributions

...are welcomed, send that push request and hopefully we can review it together

###*Pharo Smalltalk Getting a fresh Pharo Smalltalk image and its virtual machine is as easy as running in your terminal:

wget -O- get.pharo.org/30+vm | bash

MIT - License

2014 - sebastian

o/