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
rh`{
  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
inp => {
  let tmp = {}
  tmp.t1 ??= {}
  tmp.t2 ??= 0
  for (let xB in inp.data) {
    tmp.t2 += inp.data[xB].population
  }
  tmp.t0 ??= {}
  for (let xA in inp.data) {
    let k = inp.data[xA].country
    tmp.t1[k] ??= 0
    tmp.t1[k] += inp.data[xA].population
    tmp.t0[k] = tmp.t1[k] / tmp.t2
  }
  return tmp.t0
}