ube
What is this?
Simple implementation of an in-memory analytics cube.
How to use it?
const Qube = Qube; const qubeOptions = // options to initialize qube measures: // what kind of calcs do you want to store in the cube. type: 'sum' key: 'sales' name: 'sum_sales' type: 'count' key: 'sales' name: 'count_sales' type: 'max' key: 'sales' name: 'max_sales' type: 'min' key: 'sales' name: 'min_sales' type: 'average' key: 'sales' name: 'average_sales' dimensions: // what are the dimensions you would query on. type: 'string' key: 'year' type: 'string' key: 'location' type: 'string' key: 'product' const qube = qubeOptions; // Add some dataqube; const measureToCompute = 'sum_sales'; // try also with min, max, count // Total Sales.console; // Total Apple sales in Seattleconst sliceQuery = dimensions: product: 'Apple' location: 'Seattle' measure: measureToCompute ;console // Total Orange sales in Portland in 2018const diceQuery = dimensions: product: 'Orange' location: 'Portland' year: '2018' measure: measureToCompute;console // Total Orange sales across all yearsconst sliceToEnumerateQuery = dimensions: product: 'Orange' measure: measureToCompute; console;console; // All unique values for yearsconsole;console; /*Expected output Total sales: 411Apple sales in Seattle: 110Portland Orange sales in 2018: 17 Orange sales across all years┌─────────┬───────┬────────┐│ (index) │ value │ year │├─────────┼───────┼────────┤│ 0 │ 53 │ '2017' ││ 1 │ 47 │ '2018' ││ 2 │ 61 │ '2019' │└─────────┴───────┴────────┘ List values for dimension 'year'┌─────────┬────────┐│ (index) │ Values │├─────────┼────────┤│ 0 │ '2017' ││ 1 │ '2018' ││ 2 │ '2019' │└─────────┴────────┘*/
Limitations
- Only supports sum, count, min, max calculation types
- Only supports in-memory storage.
Future
- support first, last, average
- support plug & play storage
- parallelize slice, dice & one (i.e map reduce)
- hyper cube (more than 3 dimensions)
- high cardinality dimension cubes. (better way to deal with timestamp as a dimension)
Contribute
Contributions are welcome! Though I would suggest you discussing your change through issues first, so to avoid throw away work. Also contributions in terms of pure ideas are welcome too!