API Documentation: Interface KeyObjectTransaction

Name KeyObjectTransaction
Package com.mckoi.data

KeyObjectTransaction is an isolated snapshot of a database that can be modified locally and the changes published in a commit operation. Any changes made to a data structure that implements KeyObjectTransaction must be immediately reflected in view. Any change must also be isolated to this transaction implementation within the system as a whole.

NOTE: Objects that implement KeyObjectTransaction are NOT intended to be thread safe, nor are the DataFile objects that are created either exclusive or inclusive of other DataFile objects created by this object. For example, one DataFile object may not be changed while another is being written to at the same time by a different thread.

Methods Summary

boolean dataFileExists(Key key)
DataFile getDataFile(Key key, char mode)
void prefetchKeys(Key[] keys)

Method Details

boolean dataFileExists(Key key)

Returns true if a DataFile with the given key exists. This is the same as (getDataFile(key, 'r').size() > 0).

DataFile getDataFile(Key key, char mode)

Returns a DataFile for the given key. This method can be called multiple times to create multiple DataFile objects with their own positional state. If a DataFile is modified, the behavior of accessing or modifying other data files previously created with the same key as the data file being modified is undefined.

If mode is 'r', the DataFile is read-only and generates an exception if it is written to.

The returned object must provide efficient implementations for all the operations specified in DataFile, including the resize, shift and copy operations.

void prefetchKeys(Key[] keys)

Provides a hint that DataFile objects with the given keys may be accessed shortly and their content or meta-data should be prefetched in preparation. Prefetch is intended to reduce latency when it's known the likelyhood of the order of objects being accessed.

How this implementation decides to preload the data is up to the implementation specifics. It may decide to ignore the hint altogether.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Sun Microsystems, Inc.
Mckoi is Copyright © 2000 - 2012 Diehl and Associates, Inc. All rights reserved.