Interface SegmentCacheIndex

  • All Known Implementing Classes:
    SegmentCacheIndexImpl

    public interface SegmentCacheIndex
    Data structure that identifies which segments contain cells.

    Not thread-safe.

    Author:
    Julian Hyde
    • Method Detail

      • locate

        List<SegmentHeader> locate​(String schemaName,
                                   ByteString schemaChecksum,
                                   String cubeName,
                                   String measureName,
                                   String rolapStarFactTableName,
                                   BitKey constrainedColsBitKey,
                                   Map<String,​Comparable> coordinates,
                                   List<String> compoundPredicates)
        Identifies the segment headers that contain a given cell.
        Parameters:
        schemaName - Schema name
        schemaChecksum - Schema checksum
        cubeName - Cube name
        measureName - Measure name
        rolapStarFactTableName - Fact table table
        constrainedColsBitKey - Bit key
        coordinates - Coordinates
        compoundPredicates - Compound predicates
        Returns:
        Empty list if not found; never null
      • findRollupCandidates

        List<List<SegmentHeader>> findRollupCandidates​(String schemaName,
                                                       ByteString schemaChecksum,
                                                       String cubeName,
                                                       String measureName,
                                                       String rolapStarFactTableName,
                                                       BitKey constrainedColsBitKey,
                                                       Map<String,​Comparable> coordinates,
                                                       List<String> compoundPredicates)
        Returns a list of segments that can be rolled up to satisfy a given cell request.
        Parameters:
        schemaName - Schema name
        schemaChecksum - Schema checksum
        cubeName - Cube name
        measureName - Measure name
        rolapStarFactTableName - Fact table table
        constrainedColsBitKey - Bit key
        coordinates - Coordinates
        compoundPredicates - Compound predicates
        Returns:
        List of candidates; each element is a list of headers that, when combined using union, are sufficient to answer the given cell request
      • intersectRegion

        List<SegmentHeader> intersectRegion​(String schemaName,
                                            ByteString schemaChecksum,
                                            String cubeName,
                                            String measureName,
                                            String rolapStarFactTableName,
                                            SegmentColumn[] region)
        Finds a list of headers that intersect a given region.

        This method is used to find out which headers need to be trimmed or removed during a flush.

        Parameters:
        schemaName - Schema name
        schemaChecksum - Schema checksum
        cubeName - Cube name
        measureName - Measure name
        rolapStarFactTableName - Fact table table
        region - Region
        Returns:
        List of intersecting headers
      • add

        void add​(SegmentHeader header,
                 SegmentBuilder.SegmentConverter converter,
                 boolean loading)
        Adds a header to the index.
        Parameters:
        header - Segment header
        loading - Whether segment is pending a load from SQL
        converter - Segment converter
      • update

        void update​(SegmentHeader oldHeader,
                    SegmentHeader newHeader)
        Updates a header in the index. This is required when some of the excluded regions have changed.
        Parameters:
        oldHeader - The old header to replace.
        newHeader - The new header to use instead.
      • remove

        void remove​(SegmentHeader header)
        Removes a header from the index.
        Parameters:
        header - Segment header
      • printCacheState

        void printCacheState​(PrintWriter pw)
        Prints the state of the cache to the given writer.
        Parameters:
        pw - Print writer
      • getFuture

        Future<SegmentBody> getFuture​(Execution exec,
                                      SegmentHeader header)
        Returns a future slot for a segment body, if a segment is currently loading, otherwise null. This is the method to use to get segments 'hot out of the oven'.

        When this method is invoked, the execution instance of the thread is automatically added to the list of clients for the given segment. The calling code is responsible for calling cancel(Execution) when it is done with the segments, or else this registration will prevent others from canceling the running SQL statements associated to this segment.

        Parameters:
        header - Segment header
        Returns:
        Slot, or null
      • cancel

        void cancel​(Execution exec)
        This method must remove all registrations as a client for the given execution. This must terminate all SQL activity for any orphaned segments.
        Parameters:
        exec - The execution to unregister.
      • contains

        boolean contains​(SegmentHeader header)
        Tells whether or not a given segment is known to this index.
      • linkSqlStatement

        void linkSqlStatement​(SegmentHeader header,
                              Statement stmt)
        Allows to link a Statement to a segment. This allows the index to cleanup when cancel(Execution) is invoked and orphaned segments are left.
        Parameters:
        header - The segment.
        stmt - The SQL statement.
      • getConverter

        SegmentBuilder.SegmentConverter getConverter​(String schemaName,
                                                     ByteString schemaChecksum,
                                                     String cubeName,
                                                     String rolapStarFactTableName,
                                                     String measureName,
                                                     List<String> compoundPredicates)
        Returns a converter that can convert the given header to internal format.
        Parameters:
        schemaName - Schema name
        schemaChecksum - Schema checksum
        cubeName - Cube name
        rolapStarFactTableName - Fact table
        measureName - Measure name
        compoundPredicates - Compound predicates
        Returns:
        Converter
      • setConverter

        void setConverter​(String schemaName,
                          ByteString schemaChecksum,
                          String cubeName,
                          String rolapStarFactTableName,
                          String measureName,
                          List<String> compoundPredicates,
                          SegmentBuilder.SegmentConverter converter)
        Sets a converter that can convert headers in for a given measure to internal format.
        Parameters:
        schemaName - Schema name
        schemaChecksum - Schema checksum
        cubeName - Cube name
        rolapStarFactTableName - Fact table
        measureName - Measure name
        compoundPredicates - Compound predicates
        converter - Converter to store