Package com.terracottatech.store
Interface DatasetReader<K extends Comparable<K>>
- Type Parameters:
K
- the key type for the record
- All Known Subinterfaces:
DatasetWriterReader<K>
public interface DatasetReader<K extends Comparable<K>>
Accessor that provides read only access on to a dataset.
-
Method Summary
Modifier and TypeMethodDescriptiondefault AsyncDatasetReader<K>
async()
Returns an asynchronous version of this reader using theForkJoinPool.commonPool()
as an executor.Returns an asynchronous version of this reader.void
deregisterChangeListener
(ChangeListener<K> listener) Deregisters a listener so that it no longer receives eventsRetrieves the record for the specified key.Return the key type of underlyingDataset
.Returns a ReadRecordAccessor which can be used to for fine-control of read operations on the record held against the specified key.records()
Returns aStream
of the records in this dataset.void
registerChangeListener
(ChangeListener<K> listener) Registers a listener that will receive an event for changes to a key.
-
Method Details
-
getKeyType
Return the key type of underlyingDataset
.- Returns:
- the key type
-
get
Retrieves the record for the specified key. If this dataset contains a record for the supplied key, then an Optional containing that record is returned. If there is no record for this key, then an empty Optional is returned.- Parameters:
key
- key for the record- Returns:
- an Optional containing the record for the given key, or an empty Optional if there is no record held against the key.
-
on
Returns a ReadRecordAccessor which can be used to for fine-control of read operations on the record held against the specified key.- Parameters:
key
- key for the record- Returns:
- a ReadRecordAccessor tied to the supplied key.
-
records
RecordStream<K> records()Returns aStream
of the records in this dataset.- Returns:
- a stream of records
-
async
Returns an asynchronous version of this reader using theForkJoinPool.commonPool()
as an executor.- Returns:
- an asynchronous dataset reader
-
async
Returns an asynchronous version of this reader.Any asynchronous tasks associated with operations run through the returned reader will be submitted to the given executor.
- Parameters:
executor
- executor for asynchronous tasks- Returns:
- an asynchronous dataset reader
-
registerChangeListener
Registers a listener that will receive an event for changes to a key. Changes that trigger events are: the addition of a key, and associated record; the mutation of a record; the deletion of a key, and associated record.The order of events that would be received for changes to a particular key will be same as the order in which the server has made those changes on that key. Note: This ordering of events is guaranteed only for changes to a key and not across the keys.
- Parameters:
listener
- the user provided object to which events will be sent
-
deregisterChangeListener
Deregisters a listener so that it no longer receives events- Parameters:
listener
- the listener to be deregistered
-