Record Class Monomial
java.lang.Object
java.lang.Record
com.darkcollective.relix.provenance.Monomial
- Record Components:
exponents- canonical variable → positive-exponent map; nevernull
- All Implemented Interfaces:
Comparable<Monomial>
public record Monomial(SortedMap<ProvenanceVariable,Integer> exponents)
extends Record
implements Comparable<Monomial>
A monomial in the polynomial-lineage semiring
ℕ[X] — a
product of provenance variables with positive integer
exponents (a multiset of variables). It records one joint derivation:
the set of base tuples that were combined (by ⊗/join), with an exponent
counting how many times each was used.
The empty monomial is the multiplicative constant 1 (a derivation that
uses no input — the semiring's one). Monomials are
held in canonical form (a sorted map of variable → positive exponent), so equal
products compare equal regardless of construction order.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMonomial(SortedMap<ProvenanceVariable, Integer> exponents) Canonicalisesexponents: defensively copies into aTreeMapand rejects non-positive exponents (a zero/negative exponent is not representable — absent variables are simply not keys). -
Method Summary
Modifier and TypeMethodDescriptionintOrders monomials deterministically — by ascending total degree, then lexicographically by their(variable, exponent)entries.intdegree()Returns the total degree (sum of exponents); 0 for the constant monomial.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexponentsrecord component.final inthashCode()Returns a hash code value for this object.booleanReturns whether this is the constant monomial1.static Monomialof(ProvenanceVariable variable) Returns the single-variable monomialx.render(boolean detailed) Returns the rendered product, with each variable optionally enriched by its captured source columns.Multiplies this monomial byother: the exponents of shared variables add (the⊗on the variable level).toString()Returns the rendered product, e.g.Orders#1·Customers#1^2;1when constant.
-
Field Details
-
CONSTANT
The constant monomial1(no variables).
-
-
Constructor Details
-
Monomial
Canonicalisesexponents: defensively copies into aTreeMapand rejects non-positive exponents (a zero/negative exponent is not representable — absent variables are simply not keys).- Parameters:
exponents- variable → exponent map; nevernull, all exponents > 0
-
-
Method Details
-
of
Returns the single-variable monomialx.- Returns:
- the single-variable monomial
x
-
times
Multiplies this monomial byother: the exponents of shared variables add (the⊗on the variable level).- Parameters:
other- the monomial to multiply by; nevernull- Returns:
- the product monomial
-
degree
public int degree()Returns the total degree (sum of exponents); 0 for the constant monomial.- Returns:
- the total degree (sum of exponents); 0 for the constant monomial
-
isConstant
public boolean isConstant()Returns whether this is the constant monomial1.- Returns:
- whether this is the constant monomial
1
-
compareTo
Orders monomials deterministically — by ascending total degree, then lexicographically by their(variable, exponent)entries. This is the stable order used to render a polynomial and to choose which terms survive aPolynomialSemiringtruncation.- Specified by:
compareToin interfaceComparable<Monomial>
-
toString
Returns the rendered product, e.g.Orders#1·Customers#1^2;1when constant. -
render
Returns the rendered product, with each variable optionally enriched by its captured source columns.render(false)renders each variable by its barename(thetoString()default);render(true)uses itsdetailed label, e.g.Orders#1{id: 42}·Customers#1{id: 7}.- Parameters:
detailed- whether to append captured source columns to each variable- Returns:
- the rendered product, with each variable optionally enriched by its captured source columns
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
exponents
Returns the value of theexponentsrecord component.- Returns:
- the value of the
exponentsrecord component
-