Interface SemiringLibrary
- All Known Implementing Classes:
BuiltinSemiringLibrary
public interface SemiringLibrary
A provider of semirings — the extension point through which an
annotation algebra the engine has never heard of becomes something a query can ask for
by name.
Implementations are discovered with ServiceLoader, so a library is
declared both in a module-info provides clause and in a
META-INF/services file: a module path reads the first and a class path the
second, and a provider missing either is invisible in one of the two packagings without
failing anything a compiler can see.
What a semiring has to supply
Four operations and, if the annotation depends on the data,Semiring.base(com.darkcollective.relix.provenance.BaseTuple).
Everything the engine does with an annotation is expressed in those five, which is what
makes an installed semiring the equal of a built-in one: weighted transitive closure,
the positive operators and the provenance surfacing path all go through exactly this
interface and recognise nothing by name.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionname()A short identifier for this library, used in diagnostics — including the one that reports two libraries offering the same semiring name.default intpriority()Which library wins when two offer a semiring of the same name: the higher priority.The semirings this library offers.
-
Method Details
-
name
String name()A short identifier for this library, used in diagnostics — including the one that reports two libraries offering the same semiring name.- Returns:
- the library's name; never
nullor blank
-
priority
default int priority()Which library wins when two offer a semiring of the same name: the higher priority.The bundled library ships at
0, so a library declaring a higher priority replaces built-in semirings it re-declares, and one declaring a lower priority fills gaps without disturbing them. Either way the engine reports the clash rather than resolving it silently.Ties are broken by discovery order, which is not something to rely on: two libraries that both want to own a name should differ in priority.
- Returns:
- this library's priority; higher wins
-
semirings
List<NamedSemiring> semirings()The semirings this library offers.- Returns:
- the semirings, each with the names it answers to; never
null
-