Interface SegmentSpecificCommand

  • All Known Subinterfaces:
    DataCommand
    All Known Implementing Classes:
    org.infinispan.commands.read.AbstractDataCommand, TouchCommand

    public interface SegmentSpecificCommand
    Interface to be implemented when the command can define a single segment for its operation. This is useful so that subsequent operations requiring a segment can retrieve it from the command and have it only computed once at creation time.

    If a command implements this interface, the command MUST ensure that it is initialized properly to always return a number 0 or greater when invoking getSegment().

    Since:
    9.3
    Author:
    wburns
    • Method Detail

      • getSegment

        int getSegment()
        Returns the segment that this key maps to. This must always return a number 0 or larger.
        Returns:
        the segment of the key
      • extractSegmentAwareKey

        static <K> SegmentAwareKey<K> extractSegmentAwareKey​(ReplicableCommand command,
                                                             K key,
                                                             KeyPartitioner keyPartitioner)
        Create an SegmentAwareKey instance with the key and its segment.

        If the command implements SegmentSpecificCommand, it will return the segment from getSegment() instead of computing it.

        Type Parameters:
        K - The key's type.
        Parameters:
        command - the command to extract the segment from
        key - the key the segment belongs to
        keyPartitioner - the partitioner to calculate the segment of the key
        Returns:
        The SegmentAwareKey instance.