Interface SubspaceSplitter<T>

Type Parameters:
T - type of tag returned by the subspace splitter

@API(EXPERIMENTAL) public interface SubspaceSplitter<T>
An interface to split a raw FoundationDB key into a subspace and (possibly) a "tag". Because subspaces are really just prefixes that are applied to keys, the subspace that a key is actually in will be specific to a given application. This interface also provides a method that, if implemented, allows the user to associate a "tag" with the subspace. This allows the user to associate some application-meaningful value to the subspace. For example, the user might have several subspaces of data that all share a common prefix followed by a Tuple-encoded integer. The user might choose to implement subspaceOf() so that, given a key, it returns the full subspace (through the integer) and implements subspaceTag() so that it returns the integer that is the last part of the prefix.
  • Method Summary

    Modifier and Type
    Method
    Description
    subspaceOf(byte[] keyBytes)
    Determine a Subspace that the given key is contained within.
    default T
    Compute and return some application-specific "tag" for a given subspace.
  • Method Details

    • subspaceOf

      @Nonnull Subspace subspaceOf(@Nonnull byte[] keyBytes)
      Determine a Subspace that the given key is contained within. In theory, any prefix of keyBytes could be used as the raw-prefix of the subspace, but the implementation should choose a prefix that is useful for grouping keys in a way that is useful for that application.
      Parameters:
      keyBytes - the raw bytes of some FoundationDB key
      Returns:
      a Subspace that contains keyBytes
    • subspaceTag

      @Nullable default T subspaceTag(@Nonnull Subspace subspace)
      Compute and return some application-specific "tag" for a given subspace. This information can then be used by the application to associate data with the subspace it came from. The Subspace passed in can be assumed to be the result of some call to subspaceOf(), so implementations can make assumptions about the format of the prefix of the subspace based on what are legal return-values of the implementation of that function. In general, if this function is called twice with the same Subspace, it should return the same value both times.

      By default, this function will just return null.

      Parameters:
      subspace - the Subspace to generate a tag from
      Returns:
      some tag to associate with the provided subspace.