RegisterSign In

API Documentation: Interface 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 the view. All changes made to a transaction must also be fully isolated from the system as a whole (a change in one transaction will not change the content of any other transaction that is concurrently being used).

NOTE: Objects that implement KeyObjectTransaction are NOT intended to be thread safe, nor are the DataFile or DataRange objects that are created either exclusive or inclusive of other DataFile and DataRange 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 on the same transaction object. However, a transaction object is isolated from all other transaction objects in the system, so a multi-threaded system may implement concurrent access to the data source provided it ensures that multiple threads do not share the same transaction object instance.

KeyObjectTransaction implementations are intended to be lightweight and cheap to create and dispose.

Methods Summary

boolean dataFileExists(Key key)
AddressableDataFile getDataFile(Key key, char mode)
DataRange getDataRange(Key min_key, Key max_key)
DataRange getDataRange()
void prefetchKeys(Key[] keys)

Method Details

boolean dataFileExists(Key key)

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

AddressableDataFile 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. Modifying the contents of a DataFile will mirror the change over all the DataFiles created on the same key.

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.

DataRange getDataRange(Key min_key, Key max_key)

Returns a DataRange object that describes all the keys stored in the database between and including the minimum and maximum key range given. This method may be called multiple times to create multiple DataRange objects. If a DataFile that is part of the key range is modified, the change is reflected immediately in all the DataRange objects created that have coverage on that key.

The returned object must provide efficient implementations for all the operations in the interface.

DataRange getDataRange()

Returns a DataRange object that describes the entire set of keys stored in this database. If a DataFile that is part of the key range is modified, the change is reflected immediately in all the DataRange objects created that have coverage on that key.

The returned object must provide efficient implementations for all the operations in the interface.

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. The implementation can decide to ignore this hint altogether.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Oracle and/or its affiliates.
Mckoi is Copyright © 2000 - 2020 Diehl and Associates, Inc. All rights reserved.