Skip to content

Rhyme

An Expressive Data-Centric Query Language

Query nested data, produce nested data as result

Rhyme

From Query to Code

A Rhyme query is compiled through an intermediate representation (IR) that makes data dependencies explicit, optimized, and finally translated to efficient JavaScript (or C).

1 · Source Query
js
// share of total population, per country
{
  data.*A.country:
    sum(data.*A.population) /
    sum(data.*B.population)
}
2 · Intermediate Representation
IR graph: t2 accumulates the total population, t1 the per-country sum, t0 divides them
3 · Generated Code
js
t0 ??= {}
t1 ??= {}
t2 ??= 0
for (let xB in data) {
  t2 += data[xB].population
}
for (let xA in data) {
  t1[data[xA].country] ??= 0
  t1[data[xA].country] += data[xA].population
  t0[data[xA].country] = t1[data[xA].country] / t2
}
return t0