Class LocalCachedPartitionedView

    • Method Detail

      • onCache

        protected void onCache​(StreamElement element,
                               boolean overwrite)
      • assign

        public void assign​(java.util.Collection<Partition> partitions,
                           BiConsumer<StreamElement,​Pair<java.lang.Long,​java.lang.Object>> updateCallback,
                           @Nullable
                           java.time.Duration ttl)
        Description copied from interface: CachedView
        Assign and make given partitions accessible by random reads. If the view contains any partitions not listed in the collection, these partitions are dropped.
        Specified by:
        assign in interface CachedView
        Parameters:
        partitions - the partitions to cache locally
        updateCallback - function that is called when cache gets updated the function takes the new ingest element and pair of the most recent object that was associated with the key and it's currently associated stamp
        ttl - maximaul Duration that an update should be kept in the cache NOTE: this is not a hard limit, it is only a signal, that after this time the element can be removed to free up memory
      • getAssigned

        public java.util.Collection<Partition> getAssigned()
        Description copied from interface: CachedView
        Retrieve currently assigned partitions.
        Specified by:
        getAssigned in interface CachedView
        Returns:
        currently assigned partitions
      • fetchOffset

        public RandomOffset fetchOffset​(RandomAccessReader.Listing type,
                                        java.lang.String key)
        Description copied from interface: RandomAccessReader
        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.
        Specified by:
        fetchOffset in interface RandomAccessReader
        Parameters:
        type - the type of the key
        key - the key of entity or attribute
        Returns:
        offset representation of the key
      • get

        public <T> java.util.Optional<KeyValue<T>> get​(java.lang.String key,
                                                       java.lang.String attribute,
                                                       AttributeDescriptor<T> desc,
                                                       long stamp)
        Description copied from interface: RandomAccessReader
        Retrieve data stored under given (key, attribute) pair (if any).
        Specified by:
        get in interface RandomAccessReader
        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

        public void scanWildcardAll​(java.lang.String key,
                                    RandomOffset offset,
                                    long stamp,
                                    int limit,
                                    Consumer<KeyValue<?>> consumer)
        Description copied from interface: RandomAccessReader
        Scan all data stored per given key.
        Specified by:
        scanWildcardAll in interface RandomAccessReader
        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

        public <T> void scanWildcard​(java.lang.String key,
                                     AttributeDescriptor<T> wildcard,
                                     RandomOffset offset,
                                     long stamp,
                                     int limit,
                                     Consumer<KeyValue<T>> consumer)
        Description copied from interface: RandomAccessReader
        List data stored for a particular wildcard attribute.
        Specified by:
        scanWildcard in interface RandomAccessReader
        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
      • close

        public void close()
        Description copied from interface: AttributeWriterBase
        Close allocated resources of this writer. This is supposed to be idempotent.
        Specified by:
        close in interface AttributeWriterBase
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface CachedView
        Specified by:
        close in interface java.io.Closeable
      • cache

        public void cache​(StreamElement element)
        Description copied from interface: CachedView
        Cache given StreamElement into local cache without writing it to the underlying writer. This is used in conjunction with attribute family proxy.
        Specified by:
        cache in interface CachedView
        Parameters:
        element - the data to cache