Interface RandomAccessReader

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable
    All Known Subinterfaces:
    CachedView
    All Known Implementing Classes:
    JdbcOnlineAttributeReader, LocalCachedPartitionedView, RandomHBaseReader, TransactionalCachedView

    @Stable
    public interface RandomAccessReader
    extends java.io.Closeable
    Reader of data stored in random access storage. Every class that implements both AbstractAttributeWriter and RandomAccessReader can be used to access data stored at that attribute family by random access. The data can be either get by pair (key, attribute) or scanned through by a mask (key, attributePrefix) for attributes that are wildcard attributes.
    • Method Detail

      • fetchOffset

        RandomOffset fetchOffset​(RandomAccessReader.Listing type,
                                 java.lang.String key)
        Construct Offset from string (representing either key of the entity or attribute). The returned offset represents the first element that is following the given key, in case of equality.
        Parameters:
        type - the type of the key
        key - the key of entity or attribute
        Returns:
        offset representation of the key
      • get

        default <T> java.util.Optional<KeyValue<T>> get​(java.lang.String key,
                                                        AttributeDescriptor<T> desc)
        Retrieve data stored under given (key, attribute) pair (if any).
        Type Parameters:
        T - value type
        Parameters:
        key - key of the entity
        desc - the attribute to search for (not wildcard)
        Returns:
        optional KeyValue if present
      • get

        default <T> java.util.Optional<KeyValue<T>> get​(java.lang.String key,
                                                        AttributeDescriptor<T> desc,
                                                        long stamp)
        Retrieve data stored under given (key, attribute) pair (if any).
        Type Parameters:
        T - value type
        Parameters:
        key - key of the entity
        desc - the attribute to search for (not wildcard)
        stamp - timestamp to relatively to which retrieve the data
        Returns:
        optional KeyValue if present
      • get

        default <T> java.util.Optional<KeyValue<T>> get​(java.lang.String key,
                                                        java.lang.String attribute,
                                                        AttributeDescriptor<T> desc)
        Retrieve data stored under given (key, attribute) pair (if any).
        Type Parameters:
        T - value type
        Parameters:
        key - key of the entity
        attribute - name of the attribute
        desc - the attribute to search for
        Returns:
        optional KeyValue if present
      • get

        <T> java.util.Optional<KeyValue<T>> get​(java.lang.String key,
                                                java.lang.String attribute,
                                                AttributeDescriptor<T> desc,
                                                long stamp)
        Retrieve data stored under given (key, attribute) pair (if any).
        Type Parameters:
        T - value type
        Parameters:
        key - key of the entity
        attribute - name of the attribute
        desc - the attribute to search for
        stamp - timestamp to relatively to which retrieve the data
        Returns:
        optional KeyValue if present
      • scanWildcardAll

        default void scanWildcardAll​(java.lang.String key,
                                     Consumer<KeyValue<?>> consumer)
        Scan all data stored per given key.
        Parameters:
        key - the key whose KeyValues to scan
        consumer - consumer to use for scanning
      • scanWildcardAll

        default void scanWildcardAll​(java.lang.String key,
                                     long stamp,
                                     Consumer<KeyValue<?>> consumer)
        Scan all data stored per given key.
        Parameters:
        key - the key whose KeyValues to scan
        stamp - timestamp to relatively to which retrieve the data
        consumer - consumer to use for scanning
      • scanWildcardAll

        default void scanWildcardAll​(java.lang.String key,
                                     @Nullable
                                     RandomOffset offset,
                                     int limit,
                                     Consumer<KeyValue<?>> consumer)
        Scan all data stored per given key.
        Parameters:
        key - the key whose KeyValues to scan
        offset - offset to start from (next key value will be returned)
        limit - how many elements to process at most
        consumer - consumer to use for scanning
      • scanWildcardAll

        void scanWildcardAll​(java.lang.String key,
                             @Nullable
                             RandomOffset offset,
                             long stamp,
                             int limit,
                             Consumer<KeyValue<?>> consumer)
        Scan all data stored per given key.
        Parameters:
        key - the key whose KeyValues to scan
        offset - offset to start from (next key value will be returned)
        stamp - timestamp to relatively to which retrieve the data
        limit - how many elements to process at most
        consumer - consumer to use for scanning
      • scanWildcard

        default <T> void scanWildcard​(java.lang.String key,
                                      AttributeDescriptor<T> wildcard,
                                      Consumer<KeyValue<T>> consumer)
        List data stored for a particular wildcard attribute.
        Type Parameters:
        T - value type
        Parameters:
        key - key of the entity
        wildcard - wildcard attribute to scan
        consumer - the consumer to stream data to
      • scanWildcard

        default <T> void scanWildcard​(java.lang.String key,
                                      AttributeDescriptor<T> wildcard,
                                      long stamp,
                                      Consumer<KeyValue<T>> consumer)
        List data stored for a particular wildcard attribute.
        Type Parameters:
        T - value type
        Parameters:
        key - key of the entity
        wildcard - wildcard attribute to scan
        stamp - timestamp to relatively to which retrieve the data
        consumer - the consumer to stream data to
      • scanWildcard

        default <T> void scanWildcard​(java.lang.String key,
                                      AttributeDescriptor<T> wildcard,
                                      @Nullable
                                      RandomOffset offset,
                                      int limit,
                                      Consumer<KeyValue<T>> consumer)
        List data stored for a particular wildcard attribute.
        Type Parameters:
        T - value type
        Parameters:
        key - key of the entity
        wildcard - wildcard attribute to scan
        offset - name of attribute (including the prefix) to start from
        limit - maximal number of items to consume
        consumer - the consumer to stream data to
      • scanWildcard

        <T> void scanWildcard​(java.lang.String key,
                              AttributeDescriptor<T> wildcard,
                              @Nullable
                              RandomOffset offset,
                              long stamp,
                              int limit,
                              Consumer<KeyValue<T>> consumer)
        List data stored for a particular wildcard attribute.
        Type Parameters:
        T - value type
        Parameters:
        key - key of the entity
        wildcard - wildcard attribute to scan
        offset - name of attribute (including the prefix) to start from
        stamp - timestamp to relatively to which retrieve the data
        limit - maximal number of items to consume *
        consumer - the consumer to stream data to
      • listEntities

        default void listEntities​(Consumer<Pair<RandomOffset,​java.lang.String>> consumer)
        List all entity keys.
        Parameters:
        consumer - consumer that will receive keys of entities in the random access storage
      • listEntities

        void listEntities​(@Nullable
                          RandomOffset offset,
                          int limit,
                          Consumer<Pair<RandomOffset,​java.lang.String>> consumer)
        List all entity keys with offset and limit.
        Parameters:
        offset - offset of the entities
        limit - limit for number of results
        consumer - consumer of results
      • getEntityDescriptor

        EntityDescriptor getEntityDescriptor()
        Retrieve entity associated with this reader.
        Returns:
        entity associated with this reader