Package com.apple.foundationdb.map
Interface SubspaceSplitter<T>
- Type Parameters:
T
- type of tag returned by the subspace splitter
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 TypeMethodDescriptionsubspaceOf
(byte[] keyBytes) Determine aSubspace
that the given key is contained within.default T
subspaceTag
(Subspace subspace) Compute and return some application-specific "tag" for a given subspace.
-
Method Details
-
subspaceOf
Determine aSubspace
that the given key is contained within. In theory, any prefix ofkeyBytes
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 containskeyBytes
-
subspaceTag
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. TheSubspace
passed in can be assumed to be the result of some call tosubspaceOf()
, 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 sameSubspace
, it should return the same value both times.By default, this function will just return
null
.- Parameters:
subspace
- theSubspace
to generate a tag from- Returns:
- some tag to associate with the provided subspace.
-