Class SegmentId

  • All Implemented Interfaces:
    Comparable<SegmentId>

    public class SegmentId
    extends Object
    implements Comparable<SegmentId>
    Segment identifier. There are two types of segments: data segments, and bulk segments. Data segments have a header and may reference other segments; bulk segments do not.
    • Field Detail

      • NULL

        public static final SegmentId NULL
        A null segment id not representing any segment.
    • Constructor Detail

      • SegmentId

        public SegmentId​(@NotNull
                         @NotNull SegmentStore store,
                         long msb,
                         long lsb,
                         @NotNull
                         @NotNull Runnable onAccess)
        Create a new segment id with access tracking.
        Parameters:
        store - store this is belongs to
        msb - most significant bits of this id
        lsb - least significant bits of this id
        onAccess - callback called whenever an underlying and locally memoised segment is accessed.
      • SegmentId

        public SegmentId​(@NotNull
                         @NotNull SegmentStore store,
                         long msb,
                         long lsb)
        Create a new segment id without access tracking.
        Parameters:
        store - store this is belongs to
        msb - most significant bits of this id
        lsb - least significant bits of this id
    • Method Detail

      • isDataSegmentId

        public static boolean isDataSegmentId​(long lsb)
        Checks whether this is a data segment identifier.
        Returns:
        true for a data segment, false otherwise
      • isDataSegmentId

        public boolean isDataSegmentId()
        Checks whether this is a data segment identifier.
        Returns:
        true for a data segment, false otherwise
      • isBulkSegmentId

        public boolean isBulkSegmentId()
        Checks whether this is a bulk segment identifier.
        Returns:
        true for a bulk segment, false otherwise
      • getMostSignificantBits

        public long getMostSignificantBits()
      • getLeastSignificantBits

        public long getLeastSignificantBits()
      • getSegment

        @NotNull
        public @NotNull Segment getSegment()
        Get the segment identified by this instance. The segment is memoised in this instance's segment field.
        Returns:
        the segment identified by this instance.
        See Also:
        loaded(Segment), unloaded()
      • reclaimed

        public void reclaimed​(@NotNull
                              @NotNull String gcInfo)
        Notify this id about the reclamation of its segment (e.g. by the garbage collector).
        Parameters:
        gcInfo - details about the reclamation. This information is logged along with the SegmentNotFoundException when attempting to resolve the segment of this id.
      • sameStore

        public boolean sameStore​(@NotNull
                                 @NotNull SegmentStore store)
        Determine whether this instance belongs to the passed store
        Parameters:
        store -
        Returns:
        true iff this instance belongs to store
      • getCreationTime

        public long getCreationTime()
      • asUUID

        public UUID asUUID()
        Returns:
        this segment id as UUID
      • getGcGeneration

        @NotNull
        public @NotNull GCGeneration getGcGeneration()
        Get the underlying segment's gc generation. Might cause the segment to get loaded if the generation info is missing
        Returns:
        the segment's gc generation
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • estimateMemoryUsage

        public int estimateMemoryUsage()