Package com.terracottatech.store
Interface DatasetWriterReader<K extends Comparable<K>>
- Type Parameters:
K
- key type
- All Superinterfaces:
DatasetReader<K>
Accessor that provides read and write access on to a dataset.
Operations on a dataset fall in to two classes:
- Single Key CRUD operations:
- Create -
add(Comparable, Cell[])
- Read -
DatasetReader.get(Comparable)
- Update -
update(Comparable, UpdateOperation)
- Delete -
delete(Comparable)
- Create -
- Computations -
DatasetReader.records()
datasetWriterReader.records() .filter(predicate) .delete();
Functional types passed to dataset methods can be expressed as either opaque
or transparent types. Lambda expressions and those utilizing user types are
opaque to the dataset. Functions expressed using the
functional DSL
are however
transparent. This means their behavior is well understood, and therefore a
much larger set of optimizations can be applied to the operation concerned.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Creates a record for the specified key.boolean
Creates a record for the specified key.default AsyncDatasetWriterReader<K>
async()
Returns an asynchronous version of this writer-reader using theForkJoinPool.commonPool()
as an executor.Returns an asynchronous version of this writer-reader.boolean
Deletes a record for the specified key.Returns a ReadWriteRecordAccessor which can be used to for fine-control of read and write operations on the record held against the specified key.records()
Returns aStream
of the records in this dataset.boolean
update
(K key, UpdateOperation<? super K> transform) Updates a record for the specified key using the specified UpdateOperation.Methods inherited from interface com.terracottatech.store.DatasetReader
deregisterChangeListener, get, getKeyType, registerChangeListener
-
Method Details
-
add
Creates a record for the specified key.- Parameters:
key
- key for the recordcells
- cells which form the record- Returns:
- true if this dataset did not already hold a record against this key and so a record was created, false if the dataset already held a record against this key and no record was created.
-
add
Creates a record for the specified key.- Parameters:
key
- key for the recordcells
- a non-null
Iterable
supplying the cells which form the record- Returns:
- true if this dataset did not already hold a record against this key and so a record was created, false if the dataset already held a record against this key and no record was created.
- Throws:
NullPointerException
- ifcells
isnull
-
update
Updates a record for the specified key using the specified UpdateOperation.- Parameters:
key
- key of the record to mutatetransform
- the mutating transformation to apply to the record- Returns:
- true if this dataset held a record against this key and so the record was updated, false if the dataset did not hold a record against this key and so no record was updated.
-
delete
Deletes a record for the specified key.- Parameters:
key
- key of the record to remove- Returns:
- true if this dataset held a record against this key and so the record was deleted, false if the dataset did not hold a record against this key and so no record was deleted.
-
on
Returns a ReadWriteRecordAccessor which can be used to for fine-control of read and write operations on the record held against the specified key.- Specified by:
on
in interfaceDatasetReader<K extends Comparable<K>>
- Parameters:
key
- key for the record- Returns:
- a ReadWriteRecordAccessor tied to the supplied key.
-
records
MutableRecordStream<K> records()Returns aStream
of the records in this dataset.- Specified by:
records
in interfaceDatasetReader<K extends Comparable<K>>
- Returns:
- a stream of records
-
async
Returns an asynchronous version of this writer-reader using theForkJoinPool.commonPool()
as an executor.- Specified by:
async
in interfaceDatasetReader<K extends Comparable<K>>
- Returns:
- an asynchronous writer-reader
-
async
Returns an asynchronous version of this writer-reader.Any asynchronous tasks associated with operations run through the returned writer-reader will be submitted to the given executor.
- Specified by:
async
in interfaceDatasetReader<K extends Comparable<K>>
- Parameters:
executor
- executor for asynchronous tasks- Returns:
- an asynchronous dataset writer-reader
-