Interface DatasetWriterReader<K extends Comparable<K>>

Type Parameters:
K - key type
All Superinterfaces:
DatasetReader<K>

public interface DatasetWriterReader<K extends Comparable<K>> extends DatasetReader<K>
Accessor that provides read and write access on to a dataset.

Operations on a dataset fall in to two classes:

Computations are read-only operations but may perform mutations by using a suitable mutative terminal stream operation. For example a bulk deletion based on a predicate can be performed so:
  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 Details

    • add

      default boolean add(K key, Cell<?>... cells)
      Creates a record for the specified key.
      Parameters:
      key - key for the record
      cells - 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

      boolean add(K key, Iterable<Cell<?>> cells)
      Creates a record for the specified key.
      Parameters:
      key - key for the record
      cells - 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 - if cells is null
    • update

      boolean update(K key, UpdateOperation<? super K> transform)
      Updates a record for the specified key using the specified UpdateOperation.
      Parameters:
      key - key of the record to mutate
      transform - 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

      boolean delete(K key)
      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 interface DatasetReader<K extends Comparable<K>>
      Parameters:
      key - key for the record
      Returns:
      a ReadWriteRecordAccessor tied to the supplied key.
    • records

      Returns a Stream of the records in this dataset.
      Specified by:
      records in interface DatasetReader<K extends Comparable<K>>
      Returns:
      a stream of records
    • async

      default AsyncDatasetWriterReader<K> async()
      Returns an asynchronous version of this writer-reader using the ForkJoinPool.commonPool() as an executor.
      Specified by:
      async in interface DatasetReader<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 interface DatasetReader<K extends Comparable<K>>
      Parameters:
      executor - executor for asynchronous tasks
      Returns:
      an asynchronous dataset writer-reader