Map-backed lookup sessions — When you needa lookup OsidSession fast.
The core package provides concrete, in-memory
lookup sessions built on top of the abstract Lookup
Session Pattern. Instead of resolving each request against a live backend, these
sessions hold a fixed collection of already-constructed OsidObjects in a synchronized
HashMap and answer lookups directly from it. Populate
the collection with the protected put[OsidObject]
and remove[OsidObject] mutators; the map is
synchronized so the collection may be modified by the OSID
Provider while an OSID Consumer is reading.
The pattern comes in two layers. The Map session
keys the collection by Id — it serves get[OsidObject](Id) and
get[OsidObject]s() from that single map, and answers
every other query by scanning the collection through
a Filter. This is fine for
small fixed sets. The
Indexed Map OsidSession extends it and adds
secondary indices so the common typed and related-object queries
are answered by a hash lookup rather than a linear scan.
An AbstractIndexedMap[OsidObject]LookupSession
maintains a secondary map for each indexed dimension, kept in step
with the primary collection by the
same put/remove mutators. Each index is
built from the object's own accessor at insertion time:
| Index | Built from | Serves |
|---|---|---|
| genus type | getGenusType() |
get[OsidObject]sByGenusType(Type) |
| record types | getRecordTypes() |
get[OsidObject]sByRecordType(Type) |
| provider | getProviderId() |
get[OsidObject]sByProvider(Id) |
| related object | get[Related]Id() / get[Related]Ids() |
get[OsidObject]sBy[Related](Id) |
In other words, there is an index for every dimension called out in alookup OsidSession.
net.okapia.osid.jamocha.core.resource.spi
— representative; every OSID domain has a parallel core.[domain].spi package.
| Parameter | Type | Description |
|---|---|---|
| no parameters — the collection is populated through the protected mutators | ||
Each mutator updates the primary Id map and every
secondary index together, keeping the indices consistent with the collection.