├── .gitignore ├── fnordmetric-core ├── build │ ├── tests │ │ └── .gitignore │ ├── cmake │ │ ├── .gitignore │ │ ├── config.h.in │ │ └── Makefile │ └── .gitignore ├── src │ ├── metricdb │ │ ├── metriccursor.h │ │ ├── backends │ │ │ ├── inmemory │ │ │ │ ├── metricrepository.cc │ │ │ │ └── metricrepository.h │ │ │ └── disk │ │ │ │ ├── labelindexwriter.cc │ │ │ │ ├── tokenindexwriter.cc │ │ │ │ ├── compactionpolicy.h │ │ │ │ ├── labelindexreader.cc │ │ │ │ ├── tableheaderwriter.cc │ │ │ │ ├── labelindexwriter.h │ │ │ │ ├── tokenindexwriter.h │ │ │ │ ├── samplereader_impl.h │ │ │ │ ├── compactiontask.h │ │ │ │ ├── tableheaderwriter.h │ │ │ │ ├── tokenindexreader.cc │ │ │ │ ├── labelindexreader.h │ │ │ │ ├── tokenindexreader.h │ │ │ │ ├── labelindex.cc │ │ │ │ ├── labelindex.h │ │ │ │ ├── samplewriter.h │ │ │ │ ├── tableheaderreader.h │ │ │ │ ├── metricrepository.h │ │ │ │ ├── tableheaderreader.cc │ │ │ │ └── tokenindex.h │ │ ├── sample.cc │ │ ├── metrictablerepository.h │ │ ├── sample.h │ │ ├── adminui.h │ │ ├── metricrepository.h │ │ ├── metrictableref.h │ │ ├── metrictablerepository.cc │ │ ├── statsd.h │ │ └── metric.cc │ ├── ffs │ │ ├── cowblob.cc │ │ ├── object.cc │ │ ├── object.h │ │ ├── cowblob.h │ │ ├── volume_test.cc │ │ ├── schema.cc │ │ ├── agent.cc │ │ ├── snapshot.h │ │ ├── record_impl.h │ │ ├── agent_impl.h │ │ ├── idsequence.h │ │ ├── schema_impl.h │ │ ├── documentref.cc │ │ ├── documentkey.h │ │ ├── volume_impl.h │ │ ├── stream.cc │ │ ├── btree.cc │ │ ├── btree_test.cc │ │ └── cursor.h │ ├── sstable │ │ ├── index.cc │ │ ├── indexprovider.cc │ │ ├── sstablerepair.h │ │ ├── rowoffsetindex.cc │ │ ├── cursor.cc │ │ ├── sstablewriter_impl.h │ │ ├── rowoffsetindex.h │ │ ├── index.h │ │ ├── cursor.h │ │ ├── indexprovider.h │ │ └── fileheaderwriter.h │ ├── util │ │ ├── signalhandler.h │ │ ├── signalhandler.cc │ │ ├── htmlutil.h │ │ ├── ieee754.h │ │ ├── random.h │ │ ├── fnv_test.cc │ │ ├── wallclock.h │ │ ├── inspect.h │ │ ├── freeondestroy.h │ │ ├── stringutil.h │ │ ├── logoutputstream.h │ │ ├── random.cc │ │ ├── assets.h │ │ ├── buffer.h │ │ ├── fnv.cc │ │ ├── format.h │ │ ├── inspect_impl.h │ │ ├── wallclock.cc │ │ ├── binarymessagereader.h │ │ ├── inputstream_test.cc │ │ ├── jsonoutputstream.h │ │ └── exceptionhandler.h │ ├── sql │ │ ├── runtime │ │ │ ├── defaultruntime.h │ │ │ ├── execute.h │ │ │ ├── queryplan.cc │ │ │ ├── rowsink.h │ │ │ ├── importstatement.h │ │ │ ├── queryplan.h │ │ │ ├── runtime.cc │ │ │ └── queryplannode.h │ │ ├── expressions │ │ │ ├── datetime.h │ │ │ ├── math.h │ │ │ ├── datetime.cc │ │ │ └── boolean.h │ │ ├── parser │ │ │ ├── astutil.h │ │ │ └── tokenize.h │ │ ├── backends │ │ │ ├── backend.h │ │ │ ├── tableref.h │ │ │ ├── csv │ │ │ │ └── csvbackend.h │ │ │ ├── mysql │ │ │ │ ├── mysqlbackend.h │ │ │ │ └── mysqltableref.h │ │ │ └── postgres │ │ │ │ └── postgresbackend.h │ │ └── bnf.txt │ ├── ui │ │ ├── series.cc │ │ ├── domainprovider_impl.h │ │ ├── pointchart.cc │ │ ├── areachart.cc │ │ ├── barchart.cc │ │ ├── linechart.cc │ │ ├── griddefinition.cc │ │ ├── timedomain.h │ │ ├── timedomain.cc │ │ ├── griddefinition.h │ │ ├── colorpalette.h │ │ └── domainprovider.h │ ├── types.h │ ├── http │ │ ├── httphandler.h │ │ ├── status.h │ │ ├── httpresponse.h │ │ ├── httpserver.h │ │ ├── httpoutputstream.h │ │ ├── httpoutputstream.cc │ │ └── httprequest.h │ ├── msgpack │ │ └── messagepackreader.h │ ├── environment.cc │ ├── sql_extensions │ │ ├── areachartbuilder.h │ │ ├── linechartbuilder.h │ │ ├── pointchartbuilder.h │ │ ├── barchartbuilder.h │ │ └── domainconfig.h │ ├── io │ │ ├── filerepository.h │ │ ├── eventloop.h │ │ ├── mmappedfile.cc │ │ └── acceptor.h │ ├── environment.h │ ├── thread │ │ ├── taskscheduler.h │ │ └── task.h │ ├── net │ │ ├── udpserver.h │ │ ├── eventloop.h │ │ └── acceptor.h │ ├── cli.cc │ └── cli │ │ └── cli.h ├── autogen.sh ├── test │ └── fixtures │ │ ├── gdp_bar_chart.sql │ │ ├── city_temperatures.sql │ │ ├── queries │ │ └── gdpfourselects.sql │ │ └── city_temperatures.csv └── Makefile ├── fnordmetric-doc ├── examples │ ├── queries │ │ ├── mysql_backend.svg.html │ │ └── mysql_backend.sql │ ├── data │ │ ├── log_example.csv │ │ ├── irregular_data.csv │ │ ├── point_example.csv │ │ ├── areadata.csv │ │ ├── areadata2.csv │ │ └── city_temperatures.csv │ ├── pointcharts │ │ ├── simple_bubbles.sql │ │ ├── simple_scatter.sql │ │ └── pointchart_with_labels.sql │ ├── linecharts │ │ ├── irregular_data.sql │ │ ├── simple_lines.sql │ │ ├── logarithmic_domain.sql │ │ ├── inverted_axis.sql │ │ ├── explicit_domain.sql │ │ ├── lines_with_labels.sql │ │ ├── lines_with_points.sql │ │ └── multiple_y_axes.sql │ ├── barcharts │ │ ├── negative_values.sql │ │ ├── vertical_ranges.sql │ │ ├── horizontal_ranges.sql │ │ ├── horizontal_bars.sql │ │ ├── stacked_bars.sql │ │ └── vertical_bars.sql │ ├── areacharts │ │ ├── simple_area.sql │ │ ├── area_ranges.sql │ │ └── area_with_points.sql │ ├── dashboards │ │ └── simple_dashboard.html │ └── combined │ │ ├── barsandlines.sql │ │ └── arearange_and_line.sql ├── web │ ├── .gitignore │ ├── assets │ │ ├── img │ │ │ ├── bg.png │ │ │ ├── arrow.png │ │ │ ├── bgtile.png │ │ │ ├── screenshot_1.png │ │ │ ├── screenshot_2.png │ │ │ ├── screenshot_3.png │ │ │ ├── widget_bars.png │ │ │ ├── widget_numbers.png │ │ │ ├── widget_toplist.png │ │ │ ├── leadexample-chart.png │ │ │ ├── leadexample-code.png │ │ │ ├── simple_line_chart.png │ │ │ ├── simple_linechart.png │ │ │ ├── widget_timeseries.png │ │ │ ├── examples_area_ranges.png │ │ │ ├── examples_barsandlines.png │ │ │ ├── examples_inverted_axis.png │ │ │ ├── examples_simple_area.png │ │ │ ├── examples_simple_lines.png │ │ │ ├── examples_stacked_bars.png │ │ │ ├── examples_vertical_bars.png │ │ │ ├── simple_example_screen.png │ │ │ ├── examples_explicit_domain.png │ │ │ ├── examples_horizontal_bars.png │ │ │ ├── examples_irregular_data.png │ │ │ ├── examples_multiple_y_axes.png │ │ │ ├── examples_negative_values.png │ │ │ ├── examples_simple_bubbles.png │ │ │ ├── examples_simple_scatter.png │ │ │ ├── examples_vertical_ranges.png │ │ │ ├── examples_area_with_points.png │ │ │ ├── examples_arearange_and_line.png │ │ │ ├── examples_horizontal_ranges.png │ │ │ ├── examples_lines_with_labels.png │ │ │ ├── examples_lines_with_points.png │ │ │ ├── examples_logarithmic_domain.png │ │ │ ├── fnordmetric_server_screen.png │ │ │ ├── fnordmetric_server_screen1.png │ │ │ ├── fnordmetric_server_screen2.png │ │ │ ├── plugin_active_users_screen.png │ │ │ ├── fnordmetric_ui_example_screen.png │ │ │ ├── plugin_gauge_explorer_screen.png │ │ │ ├── examples_pointchart_with_labels.png │ │ │ └── fnordmetric_ui_example_screen_noborder.png │ │ ├── fnordmetric-server.mp4 │ │ ├── fnordmetric-server.webm │ │ ├── .htaccess │ │ └── vendor │ │ │ └── prettify.css │ ├── Gemfile │ └── Gemfile.lock ├── documentation │ ├── support.md │ ├── license.md │ ├── installation.md │ └── metricdb_storage_backends.md └── Makefile ├── fnordmetric-webui ├── .gitignore ├── fontawesome.woff ├── fnordmetric-favicon.ico ├── Makefile └── fnordmetric-webui-singlemetricview.js ├── .travis.yml ├── Makefile └── Dockerfile /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /fnordmetric-core/build/tests/.gitignore: -------------------------------------------------------------------------------- 1 | tmp 2 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/metriccursor.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/queries/mysql_backend.svg.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fnordmetric-doc/web/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | downloads/* 3 | -------------------------------------------------------------------------------- /fnordmetric-core/build/cmake/.gitignore: -------------------------------------------------------------------------------- 1 | stage 2 | target 3 | -------------------------------------------------------------------------------- /fnordmetric-webui/.gitignore: -------------------------------------------------------------------------------- 1 | fnordmetric-webui.js 2 | tests/ 3 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/data/log_example.csv: -------------------------------------------------------------------------------- 1 | x,y 2 | 1,0 3 | 2,10 4 | 3,100 5 | 4,1000 6 | 5,10000 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | rvm: 1.9.3 2 | script: ./fnordmetric-core/run_specs.sh 3 | services: 4 | - redis-server 5 | -------------------------------------------------------------------------------- /fnordmetric-core/build/cmake/config.h.in: -------------------------------------------------------------------------------- 1 | #cmakedefine FNORD_ENABLE_MYSQL 2 | #cmakedefine FNORD_ENABLE_POSTGRES 3 | -------------------------------------------------------------------------------- /fnordmetric-webui/fontawesome.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-webui/fontawesome.woff -------------------------------------------------------------------------------- /fnordmetric-core/build/.gitignore: -------------------------------------------------------------------------------- 1 | fnordmetric 2 | libfnordmetric-static.a 3 | libfnordmetric.dylib 4 | libfnordmetric.so 5 | -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/bg.png -------------------------------------------------------------------------------- /fnordmetric-core/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ "$1" == "clean" ]]; then 3 | make clean 4 | exit 0 5 | fi 6 | 7 | make all 8 | -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/arrow.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/bgtile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/bgtile.png -------------------------------------------------------------------------------- /fnordmetric-webui/fnordmetric-favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-webui/fnordmetric-favicon.ico -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/screenshot_1.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/screenshot_2.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/screenshot_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/screenshot_3.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/widget_bars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/widget_bars.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/fnordmetric-server.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/fnordmetric-server.mp4 -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/widget_numbers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/widget_numbers.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/widget_toplist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/widget_toplist.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/fnordmetric-server.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/fnordmetric-server.webm -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/leadexample-chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/leadexample-chart.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/leadexample-code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/leadexample-code.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/simple_line_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/simple_line_chart.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/simple_linechart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/simple_linechart.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/widget_timeseries.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/widget_timeseries.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_area_ranges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_area_ranges.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_barsandlines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_barsandlines.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_inverted_axis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_inverted_axis.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_simple_area.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_simple_area.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_simple_lines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_simple_lines.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_stacked_bars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_stacked_bars.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_vertical_bars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_vertical_bars.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/simple_example_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/simple_example_screen.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem "sinatra", "1.3.3" 4 | gem "sinatra-static", "0.1.1" 5 | gem "redcarpet", "2.2.2" 6 | gem "rake" 7 | -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | RewriteCond %{HTTP_HOST} !^fnordmetric\.io$ [NC] 3 | RewriteRule / http://fnordmetric.io/ [R=permanent] 4 | 5 | -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_explicit_domain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_explicit_domain.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_horizontal_bars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_horizontal_bars.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_irregular_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_irregular_data.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_multiple_y_axes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_multiple_y_axes.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_negative_values.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_negative_values.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_simple_bubbles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_simple_bubbles.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_simple_scatter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_simple_scatter.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_vertical_ranges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_vertical_ranges.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_area_with_points.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_area_with_points.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_arearange_and_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_arearange_and_line.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_horizontal_ranges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_horizontal_ranges.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_lines_with_labels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_lines_with_labels.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_lines_with_points.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_lines_with_points.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_logarithmic_domain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_logarithmic_domain.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/fnordmetric_server_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/fnordmetric_server_screen.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/fnordmetric_server_screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/fnordmetric_server_screen1.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/fnordmetric_server_screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/fnordmetric_server_screen2.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/plugin_active_users_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/plugin_active_users_screen.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/fnordmetric_ui_example_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/fnordmetric_ui_example_screen.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/plugin_gauge_explorer_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/plugin_gauge_explorer_screen.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/examples_pointchart_with_labels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/examples_pointchart_with_labels.png -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/img/fnordmetric_ui_example_screen_noborder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RDFS/fnordmetric/master/fnordmetric-doc/web/assets/img/fnordmetric_ui_example_screen_noborder.png -------------------------------------------------------------------------------- /fnordmetric-doc/documentation/support.md: -------------------------------------------------------------------------------- 1 | Support 2 | ======= 3 | 4 | There are various ways to get support for FnordMetric: 5 | 6 | + [Github Issues](http://github.com/paulasmuth/fnordmetric/issues) 7 | + [The FnordMetric Google Group](http://groups.google.com/group/fnordmetric) 8 | 9 | 10 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/data/irregular_data.csv: -------------------------------------------------------------------------------- 1 | series,x,y,z 2 | series1,-8,34,5 3 | series1,2,-18,23 4 | series1,12,43,11 5 | series1,14,-19,9 6 | series1,17,25,14 7 | series1,20,33,8 8 | series2,-10,34,5 9 | series2,-8,18,8 10 | series2,2,-4,23 11 | series2,9,19,2 12 | series2,10,-25,4 13 | series2,12,-23,17 14 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/data/point_example.csv: -------------------------------------------------------------------------------- 1 | series,x,y,z 2 | series1,10,34,5 3 | series1,15,-18,23 4 | series1,20,43,11 5 | series1,30,-19,9 6 | series1,40,25,14 7 | series1,50,33,8 8 | series2,-10,34,5 9 | series2,-15,18,8 10 | series2,-20,-4,23 11 | series2,-30,19,2 12 | series2,-40,-25,4 13 | series2,-50,-23,17 14 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/pointcharts/simple_bubbles.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/point_example.csv?headers=true'; 3 | 4 | DRAW POINTCHART WITH 5 | AXIS BOTTOM 6 | AXIS LEFT 7 | AXIS TOP 8 | AXIS RIGHT; 9 | 10 | SELECT series AS series, x AS x, y AS y, z AS z 11 | FROM example_data; 12 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/data/areadata.csv: -------------------------------------------------------------------------------- 1 | series,x,y,z,w 2 | series1,10,34,43,A 3 | series1,15,38,65,B 4 | series1,20,43,46,C 5 | series1,30,33,38,D 6 | series1,40,21,38,E 7 | series1,50,33,55,F 8 | series2,10,-34,34,A 9 | series2,15,-30,38,B 10 | series2,20,-20,43,C 11 | series2,30,-24,33,D 12 | series2,40,-18,21,E 13 | series2,50,-32,33,F 14 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/queries/mysql_backend.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE test_table 2 | FROM 'mysql://localhost/test_database?user=root'; 3 | 4 | DRAW BARCHART WITH 5 | ORIENTATION VERTICAL 6 | AXIS BOTTOM 7 | GRID HORIZONTAL 8 | LEGEND TOP RIGHT INSIDE; 9 | 10 | SELECT series, x, y FROM test_table WHERE series = "fnord"; 11 | 12 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/linecharts/irregular_data.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/irregular_data.csv?headers=true'; 3 | 4 | DRAW LINECHART WITH 5 | AXIS BOTTOM 6 | AXIS LEFT 7 | AXIS TOP 8 | AXIS RIGHT; 9 | 10 | SELECT series AS series, x AS x, y AS y, 'circle' as pointstyle 11 | FROM example_data; 12 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/barcharts/negative_values.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE city_temperatures 2 | FROM 'csv:examples/data/city_temperatures.csv?headers=true'; 3 | 4 | DRAW BARCHART WITH 5 | ORIENTATION VERTICAL 6 | LEGEND TOP LEFT INSIDE 7 | AXIS BOTTOM; 8 | 9 | SELECT city AS series, month AS x, temperature AS y 10 | FROM city_temperatures; 11 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/linecharts/simple_lines.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/measurement.csv?headers=true'; 3 | 4 | DRAW LINECHART WITH 5 | AXIS BOTTOM 6 | AXIS LEFT; 7 | 8 | SELECT 'data' AS series, FROM_TIMESTAMP(time) AS x, value2 * 1000 AS y 9 | FROM example_data 10 | WHERE series = "measurement2"; 11 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/pointcharts/simple_scatter.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/point_example.csv?headers=true'; 3 | 4 | DRAW POINTCHART WITH 5 | AXIS BOTTOM 6 | AXIS LEFT 7 | AXIS TOP 8 | AXIS RIGHT 9 | GRID HORIZONTAL VERTICAL; 10 | 11 | SELECT series AS series, x AS x, y AS y 12 | FROM example_data; 13 | -------------------------------------------------------------------------------- /fnordmetric-core/test/fixtures/gdp_bar_chart.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE gdp_per_country 2 | FROM 'csv:test/fixtures/gbp_per_country_simple.csv?headers=true'; 3 | 4 | DRAW BARCHART 5 | AXIS BOTTOM 6 | AXIS LEFT; 7 | 8 | SELECT 9 | 'gross domestic product per country' AS series, 10 | country AS x, 11 | gbp AS y 12 | FROM 13 | gdp_per_country 14 | LIMIT 30; 15 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/linecharts/logarithmic_domain.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/log_example.csv?headers=true'; 3 | 4 | DRAW LINECHART WITH 5 | XDOMAIN 0, 5 LOGARITHMIC 6 | YDOMAIN 0, 10000 LOGARITHMIC 7 | AXIS BOTTOM 8 | AXIS LEFT; 9 | 10 | SELECT "log example" as series, x AS x, y AS y, "circle" as pointstyle 11 | FROM example_data; 12 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/areacharts/simple_area.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/measurement.csv?headers=true'; 3 | 4 | DRAW AREACHART WITH 5 | AXIS BOTTOM 6 | AXIS LEFT 7 | GRID HORIZONTAL; 8 | 9 | SELECT 'data' AS series, FROM_TIMESTAMP(time) AS x, value2 * 1000 AS y, 'solid' as linestyle 10 | FROM example_data 11 | WHERE series = "measurement2"; 12 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/pointcharts/pointchart_with_labels.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/point_example.csv?headers=true'; 3 | 4 | DRAW POINTCHART WITH 5 | AXIS BOTTOM 6 | AXIS LEFT 7 | AXIS TOP 8 | AXIS RIGHT 9 | YDOMAIN -40, 60 10 | LABELS; 11 | 12 | SELECT series AS series, x AS x, y AS y, z as z, z as label 13 | FROM example_data; 14 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/linecharts/inverted_axis.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE city_temperatures 2 | FROM 'csv:examples/data/city_temperatures.csv?headers=true'; 3 | 4 | DRAW LINECHART WITH 5 | XDOMAIN INVERT 6 | YDOMAIN INVERT 7 | AXIS BOTTOM 8 | AXIS LEFT 9 | LEGEND BOTTOM RIGHT INSIDE; 10 | 11 | SELECT city AS series, month AS x, temperature AS y, "circle" as pointstyle 12 | FROM city_temperatures; 13 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/areacharts/area_ranges.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/areadata2.csv?headers=true'; 3 | 4 | DRAW AREACHART WITH 5 | AXIS TOP 6 | AXIS BOTTOM 7 | AXIS RIGHT 8 | AXIS LEFT; 9 | 10 | SELECT 11 | series AS series, 12 | x AS x, 13 | y AS y, 14 | z AS z 15 | FROM example_data 16 | WHERE series = "series2" or series = "series1"; 17 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/linecharts/explicit_domain.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE city_temperatures 2 | FROM 'csv:examples/data/city_temperatures.csv?headers=true'; 3 | 4 | DRAW LINECHART WITH 5 | AXIS BOTTOM 6 | AXIS LEFT 7 | LEGEND BOTTOM LEFT INSIDE TITLE "Average Temperature" 8 | YDOMAIN -30.0, 30.0; 9 | 10 | SELECT city AS series, month AS x, temperature AS y, "circle" as pointstyle 11 | FROM city_temperatures; 12 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/barcharts/vertical_ranges.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/areadata.csv?headers=true'; 3 | 4 | DRAW BARCHART 5 | ORIENTATION VERTICAL 6 | AXIS BOTTOM 7 | AXIS LEFT; 8 | 9 | SELECT series as series, w as x, y as y, z as z from example_data WHERE series = "series1"; 10 | SELECT series as series, w as x, y + 20 as y, z + 20 as z from example_data WHERE series = "series2"; 11 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/barcharts/horizontal_ranges.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/areadata.csv?headers=true'; 3 | 4 | DRAW BARCHART 5 | ORIENTATION HORIZONTAL 6 | AXIS BOTTOM 7 | AXIS LEFT; 8 | 9 | SELECT series as series, w as x, y as y, z as z from example_data WHERE series = "series1"; 10 | SELECT series as series, w as x, y + 20 as y, z + 20 as z from example_data WHERE series = "series2"; 11 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/data/areadata2.csv: -------------------------------------------------------------------------------- 1 | series,x,y,z 2 | series1,10,-34,34 3 | series1,15,-30,38 4 | series1,20,-20,43 5 | series1,30,-24,33 6 | series1,40,-18,21 7 | series1,50,-32,33 8 | series2,10,-24,31 9 | series2,15,-20,33 10 | series2,20,-15,38 11 | series2,30,-20,27 12 | series2,40,-7,13 13 | series2,50,-18,30 14 | series3,10,4,0 15 | series3,15,8,0 16 | series3,20,13,0 17 | series3,30,2,0 18 | series3,40,1,0 19 | series3,50,9,0 20 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/barcharts/horizontal_bars.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE gdp_per_country 2 | FROM 'csv:examples/data/gbp_per_country_simple.csv?headers=true'; 3 | 4 | DRAW BARCHART WITH 5 | ORIENTATION HORIZONTAL 6 | LABELS 7 | AXIS LEFT 8 | AXIS BOTTOM 9 | YDOMAIN 0, 20; 10 | 11 | SELECT 'gdp per country' AS series, country AS x, gbp / 1000000 AS y, gbp / 1000 + " Billion $" as label 12 | FROM gdp_per_country 13 | LIMIT 10; 14 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/barcharts/stacked_bars.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE gdp_per_capita 2 | FROM 'csv:examples/data/gdp_per_capita.csv?headers=true'; 3 | 4 | DRAW BARCHART WITH 5 | ORIENTATION HORIZONTAL 6 | STACKED 7 | AXIS LEFT 8 | AXIS BOTTOM 9 | LEGEND BOTTOM RIGHT INSIDE; 10 | 11 | SELECT year AS series, isocode AS x, gdp AS y 12 | FROM gdp_per_capita 13 | WHERE year = "2010" OR year = '2009' or year = '2008' 14 | LIMIT 20 OFFSET 40; 15 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/linecharts/lines_with_labels.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE city_temperatures 2 | FROM 'csv:examples/data/city_temperatures.csv?headers=true'; 3 | 4 | DRAW LINECHART WITH 5 | AXIS LEFT 6 | AXIS BOTTOM 7 | LABELS 8 | YDOMAIN -10, 40 9 | LEGEND TOP LEFT INSIDE; 10 | 11 | SELECT city AS series, month AS x, temperature AS y, temperature + "°C" as label, "circle" as pointstyle 12 | FROM city_temperatures 13 | WHERE city = "Berlin"; 14 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/barcharts/vertical_bars.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE gdp_per_capita 2 | FROM 'csv:examples/data/gdp_per_capita.csv?headers=true'; 3 | 4 | DRAW BARCHART WITH 5 | ORIENTATION VERTICAL 6 | AXIS BOTTOM 7 | GRID HORIZONTAL 8 | LEGEND TOP RIGHT INSIDE; 9 | 10 | SELECT year AS series, isocode AS x, gdp AS y 11 | FROM gdp_per_capita 12 | WHERE year = "2010" OR year = '2009' or year = '2008' 13 | ORDER BY gdp DESC 14 | LIMIT 9; 15 | 16 | -------------------------------------------------------------------------------- /fnordmetric-doc/Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of the "FnordMetric" project 2 | # Copyright (c) 2014 Paul Asmuth, Google Inc. 3 | # 4 | # Licensed under the MIT license (see LICENSE). 5 | 6 | all: build 7 | 8 | build: 9 | find examples -name "*.sql" | while read file; do fnordmetric-cli -f svg -o $${file/.sql/.svg}.html $$file; done 10 | (cd web && rake build) 11 | 12 | web: build 13 | (cd web/target && python -m SimpleHTTPServer 9090) 14 | 15 | .PHONY: all clean build web 16 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/linecharts/lines_with_points.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE city_temperatures 2 | FROM 'csv:examples/data/city_temperatures.csv?headers=true'; 3 | 4 | DRAW LINECHART WITH 5 | AXIS LEFT 6 | AXIS BOTTOM 7 | LEGEND TOP LEFT INSIDE; 8 | 9 | SELECT 10 | city AS series, 11 | month AS x, 12 | temperature AS y, 13 | "Avg. Temperatures in " + month + " in " + city + ": " + temperature as label, 14 | "circle" as pointstyle 15 | FROM city_temperatures; 16 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/dashboards/simple_dashboard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My Dashboard 5 | 6 | 7 | 8 | 9 | DRAW LINECHART 10 | AXIS BOTTOM; 11 | 12 | SELECT time AS x, value AS y 13 | FROM myshop_sales; 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /fnordmetric-core/test/fixtures/city_temperatures.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE city_temperatures 2 | FROM 'csv:doc/examples/data/city_temperatures.csv?headers=true'; 3 | 4 | DRAW LINECHART AXIS BOTTOM; 5 | 6 | SELECT 7 | 'Berlin' AS series, 8 | temperature AS x, 9 | temperature AS y 10 | FROM 11 | city_temperatures 12 | WHERE city = "Berlin"; 13 | 14 | SELECT 15 | 'Tokyo' AS series, 16 | temperature AS x, 17 | temperature AS y 18 | FROM 19 | city_temperatures 20 | WHERE city = "Tokyo"; 21 | -------------------------------------------------------------------------------- /fnordmetric-doc/web/assets/vendor/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}} 2 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/areacharts/area_with_points.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/areadata.csv?headers=true'; 3 | 4 | DRAW AREACHART WITH 5 | AXIS TOP 6 | AXIS BOTTOM 7 | AXIS RIGHT 8 | AXIS LEFT 9 | YDOMAIN 0, 50; 10 | 11 | SELECT 12 | 'data' AS series, 13 | x AS x, 14 | y AS y, 15 | 'circle' as pointstyle, 16 | 'solid' as linestyle, 17 | 3 as pointsize, 18 | 2 as linewidth 19 | FROM example_data 20 | WHERE series = "series1"; 21 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/cowblob.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include "cowblob.h" 11 | 12 | namespace fnordmetric { 13 | namespace ffs { 14 | 15 | COWBlob::COWBlob(std::shared_ptr page_manager) { 16 | } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/object.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include "object.h" 11 | 12 | namespace fnordmetric { 13 | namespace ffs { 14 | 15 | void Object::incrRefcount() { 16 | } 17 | 18 | void Object::decrRefcount() { 19 | } 20 | 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/linecharts/multiple_y_axes.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE city_temperatures 2 | FROM 'csv:examples/data/city_temperatures.csv?headers=true'; 3 | 4 | DRAW LINECHART WITH 5 | AXIS BOTTOM 6 | AXIS LEFT TITLE "New York" 7 | LEGEND TOP LEFT INSIDE; 8 | 9 | SELECT city AS series, month AS x, temperature AS y, "circle" AS pointstyle 10 | FROM city_temperatures 11 | WHERE city = "New York"; 12 | 13 | DRAW LINECHART WITH 14 | AXIS RIGHT TITLE "Berlin"; 15 | 16 | SELECT city AS series, month AS x, temperature AS y, "circle" as pointstyle, "color2" as color 17 | FROM city_temperatures 18 | WHERE city = "Berlin"; 19 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/combined/barsandlines.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE city_temperatures 2 | FROM 'csv:examples/data/city_temperatures.csv?headers=true'; 3 | 4 | DRAW BARCHART WITH 5 | ORIENTATION VERTICAL 6 | YDOMAIN 0, 50 7 | AXIS RIGHT 8 | AXIS TOP; 9 | 10 | SELECT city AS series, month AS x, temperature AS y 11 | FROM city_temperatures 12 | WHERE city = "London"; 13 | 14 | DRAW LINECHART WITH 15 | YDOMAIN 0, 70 16 | AXIS BOTTOM 17 | AXIS LEFT; 18 | 19 | SELECT city AS series, month AS x, temperature * 2 AS y, "circle" as pointstyle, "color2" as color 20 | FROM city_temperatures 21 | WHERE city = "Tokyo"; 22 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sstable/index.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnord { 13 | namespace sstable { 14 | 15 | Index::Index(uint32_t type) : type_(type) {} 16 | 17 | uint32_t Index::type() const { 18 | return type_; 19 | } 20 | 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/combined/arearange_and_line.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE example_data 2 | FROM 'csv:examples/data/areadata2.csv?headers=true'; 3 | 4 | DRAW AREACHART WITH 5 | AXIS LEFT 6 | AXIS BOTTOM 7 | YDOMAIN -50, 50; 8 | 9 | SELECT 10 | series AS series, 11 | x AS x, 12 | y AS y, 13 | z AS z 14 | FROM example_data 15 | WHERE series = "series2" or series = "series1"; 16 | 17 | DRAW LINECHART 18 | AXIS TOP 19 | AXIS RIGHT 20 | YDOMAIN -50, 50; 21 | 22 | SELECT 23 | series AS series, 24 | x AS x, 25 | y AS y, 26 | "black" as color, 27 | "circle" as pointstyle 28 | FROM example_data 29 | WHERE series = "series3"; 30 | -------------------------------------------------------------------------------- /fnordmetric-core/Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of the "FnordMetric" project 2 | # Copyright (c) 2014 Paul Asmuth, Google Inc. 3 | # 4 | # Licensed under the MIT license (see LICENSE). 5 | 6 | all: build 7 | 8 | build: 9 | (cd ../fnordmetric-webui && make) 10 | (cd build/cmake && make) 11 | 12 | install: build 13 | (cd build/cmake && make install) 14 | 15 | devserver: build 16 | mkdir -p /tmp/fnordmetric-data 17 | DEV_ASSET_PATH=../ ./build/cmake/target/fnordmetric-server --datadir /tmp/fnordmetric-data --verbose 18 | 19 | test: 20 | (cd build/cmake && make test) 21 | 22 | clean: 23 | (cd build/cmake && make clean) 24 | rm -rf build/test/tmp* 25 | 26 | .PHONY: all test clean build devserver 27 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of the "FnordMetric" project 2 | # Copyright (c) 2014 Paul Asmuth, Google Inc. 3 | # 4 | # Licensed under the MIT license (see LICENSE). 5 | 6 | all: build 7 | 8 | build: 9 | (cd fnordmetric-webui && make build) 10 | (cd fnordmetric-core && make build) 11 | 12 | install: 13 | (cd fnordmetric-core && make install) 14 | 15 | test: 16 | (cd fnordmetric-core && make test) 17 | 18 | clean: 19 | (cd fnordmetric-webui && make clean) 20 | (cd fnordmetric-core && make clean) 21 | 22 | doc: 23 | find doc/examples -name "*.sql" | while read file; do PATH=./build:$$PATH fnordmetric -f svg -o $${file/.sql/.svg}.html $$file; done 24 | (cd doc/web && rake build) 25 | 26 | .PHONY: all test clean doc build 27 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/object.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_FFS_OBJECT_H 11 | #define _FNORDMETRIC_FFS_OBJECT_H 12 | 13 | namespace fnordmetric { 14 | namespace ffs { 15 | 16 | class Object { 17 | friend class Volume; 18 | public: 19 | void incrRefcount(); 20 | void decrRefcount(); 21 | }; 22 | 23 | } 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/signalhandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_UTIL_SIGNALHANDLER_H 11 | #define _FNORDMETRIC_UTIL_SIGNALHANDLER_H 12 | 13 | namespace fnordmetric { 14 | namespace util { 15 | 16 | class SignalHandler { 17 | public: 18 | 19 | static void ignoreSIGHUP(); 20 | static void ignoreSIGPIPE(); 21 | 22 | }; 23 | 24 | } 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/signalhandler.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include 12 | 13 | namespace fnordmetric { 14 | namespace util{ 15 | 16 | void SignalHandler::ignoreSIGHUP() { 17 | signal(SIGHUP, SIG_IGN); 18 | } 19 | 20 | void SignalHandler::ignoreSIGPIPE() { 21 | signal(SIGPIPE, SIG_IGN); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /fnordmetric-doc/documentation/license.md: -------------------------------------------------------------------------------- 1 | License 2 | ======= 3 | 4 | Copyright (c) 2011-2014 Paul Asmuth et al. 5 | 6 | FnordMetric is free software: you can redistribute it and/or modify it under 7 | the terms of the GNU General Public License as published by the Free Software 8 | Foundation, either version 3 of the License, or (at your option) any later 9 | version. 10 | 11 | FnordMetric is distributed in the hope that it will be useful,but WITHOUT ANY 12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | FnordMetric. If not, see . 17 | 18 | 19 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/runtime/defaultruntime.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQL_DEFAULTRUNTIME_H 11 | #define _FNORDMETRIC_SQL_DEFAULTRUNTIME_H 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace query { 16 | 17 | class DefaultRuntime : public Runtime { 18 | public: 19 | DefaultRuntime(); 20 | }; 21 | 22 | } 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/series.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include "series.h" 11 | 12 | namespace fnordmetric { 13 | 14 | template <> 15 | Series::Coord::Coord(std::nullptr_t) : value_(0.0) {} 16 | 17 | template <> 18 | Series::Coord::Coord(std::nullptr_t) : value_(0) {} 19 | 20 | template <> 21 | Series::Coord::Coord(std::nullptr_t) : value_("") {} 22 | 23 | } 24 | -------------------------------------------------------------------------------- /fnordmetric-core/src/types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_TYPES_H 11 | #define _FNORDMETRIC_TYPES_H 12 | #include 13 | 14 | namespace fnordmetric { 15 | 16 | typedef std::string StringType; 17 | typedef double FloatType; 18 | typedef int64_t IntegerType; 19 | typedef bool BoolType; 20 | typedef fnord::util::DateTime TimeType; 21 | 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/inmemory/metricrepository.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace metricdb { 14 | namespace inmemory_backend { 15 | 16 | Metric* MetricRepository::createMetric(const std::string& key) { 17 | return new inmemory_backend::Metric(key); 18 | } 19 | 20 | } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/cowblob.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_FFS_COWBLOB_H 11 | #define _FNORDMETRIC_FFS_COWBLOB_H 12 | #include "object.h" 13 | #include 14 | 15 | namespace fnordmetric { 16 | namespace ffs { 17 | 18 | class COWBlob : public Object { 19 | public: 20 | COWBlob(std::shared_ptr page_manager); 21 | }; 22 | 23 | } 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/expressions/datetime.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQL_EXPRESSIONS_DATETIME_H 11 | #define _FNORDMETRIC_SQL_EXPRESSIONS_DATETIME_H 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace query { 16 | namespace expressions { 17 | 18 | void fromTimestamp(void* scratchpad, int argc, SValue* argv, SValue* out); 19 | 20 | } 21 | } 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/htmlutil.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_UTIL_STRINGUTIL_H_ 11 | #define _FNORDMETRIC_UTIL_STRINGUTIL_H_ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnord { 18 | namespace util { 19 | 20 | class HTMLUtil { 21 | public: 22 | 23 | static std::string urlDecode(const std::string& str); 24 | 25 | }; 26 | 27 | } 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/ieee754.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_UTIL_IEEE754_H_ 11 | #define _FNORDMETRIC_UTIL_IEEE754_H_ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnord { 18 | namespace util { 19 | 20 | class IEEE754 { 21 | public: 22 | 23 | static uint64_t toBytes(double value); 24 | static double fromBytes(uint64_t bytes); 25 | 26 | }; 27 | 28 | } 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y curl \ 5 | && rm -rf /var/lib/apt/lists/* 6 | 7 | RUN buildDeps='unzip git gcc make clang++-3.4 cmake libmysqlclient-dev'; \ 8 | set -x \ 9 | && apt-get update && apt-get install -y $buildDeps --no-install-recommends \ 10 | && rm -rf /var/lib/apt/lists/* 11 | 12 | RUN mkdir -p /usr/src/ \ 13 | && cd /usr/src \ 14 | && curl -R -O https://codeload.github.com/dolfly/fnordmetric/zip/master \ 15 | && unzip master \ 16 | && cd fnordmetric-master/fnordmetric-core \ 17 | && make \ 18 | && cp build/cmake/target/fnordmetric-server /usr/local/bin 19 | 20 | VOLUME /data/fnordmetric 21 | EXPOSE 8080 8125/udp 22 | CMD [ "/usr/local/bin/fnordmetric-server", "--http_port", "8080", "--statsd_port", "8125", "--storage_backend", "disk", "--datadir", "/data/fnordmetric"] 23 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sstable/indexprovider.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnord { 13 | namespace sstable { 14 | 15 | IndexProvider::IndexProvider() {} 16 | 17 | IndexProvider::IndexProvider( 18 | IndexProvider&& other) : 19 | indexes_(std::move(other.indexes_)) {} 20 | 21 | std::vector&& IndexProvider::popIndexes() { 22 | return std::move(indexes_); 23 | } 24 | 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /fnordmetric-core/test/fixtures/queries/gdpfourselects.sql: -------------------------------------------------------------------------------- 1 | IMPORT TABLE gdp_per_country 2 | FROM 'csv:test/fixtures/gbp_per_country_simple.csv?headers=true'; 3 | 4 | SELECT 5 | 'gross domestic product per country' AS series, 6 | country AS x, 7 | 0 as y, 8 | gbp AS z 9 | FROM 10 | gdp_per_country 11 | LIMIT 10; 12 | 13 | SELECT 14 | 'gross domestic product per country series2' AS series, 15 | country AS x, 16 | 383700 as y, 17 | gbp AS z 18 | FROM 19 | gdp_per_country 20 | LIMIT 10; 21 | 22 | SELECT 23 | 'gross domestic product per country series3' AS series, 24 | country AS x, 25 | 183700 as y, 26 | gbp AS z 27 | FROM 28 | gdp_per_country 29 | LIMIT 10; 30 | 31 | SELECT 32 | 'gross domestic product per country series4' AS series, 33 | country AS x, 34 | 283700 as y, 35 | gbp AS z 36 | FROM 37 | gdp_per_country 38 | LIMIT 10; 39 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/labelindexwriter.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace metricdb { 14 | namespace disk_backend { 15 | 16 | LabelIndexWriter::LabelIndexWriter(LabelIndex* index) { 17 | auto labels = index->labels(); 18 | 19 | for (const auto& label : labels) { 20 | appendUInt32(label.size()); 21 | appendString(label); 22 | } 23 | } 24 | 25 | } 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/parser/astutil.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQL_ASTUTIL_H 11 | #define _FNORDMETRIC_SQL_ASTUTIL_H 12 | #include 13 | #include 14 | 15 | namespace fnordmetric { 16 | namespace query { 17 | class ASTNode; 18 | class TableRef; 19 | 20 | class ASTUtil { 21 | public: 22 | 23 | static std::vector columnNamesFromSelectList( 24 | ASTNode* select_list, 25 | TableRef* tbl_ref = nullptr); 26 | 27 | }; 28 | 29 | } 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/domainprovider_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_DOMAINPROVIDER_IMPL_H 11 | #define _FNORDMETRIC_DOMAINPROVIDER_IMPL_H 12 | 13 | namespace fnordmetric { 14 | namespace ui { 15 | 16 | template 17 | T* DomainProvider::getAs() const { 18 | T* domain = dynamic_cast(domain_); 19 | 20 | if (domain == nullptr) { 21 | RAISE(kRuntimeError, "can't convert domain to requested type"); 22 | } 23 | 24 | return domain; 25 | } 26 | 27 | } 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/volume_test.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace fnordmetric::ffs; 15 | 16 | UNIT_TEST(VolumeTest); 17 | 18 | TEST_CASE(VolumeTest, TestCowBlob, [] () { 19 | auto volume = Volume::openFile( 20 | "/tmp/__ffs_test_volume", 21 | Volume::FILE_TRUNCATE || Volume::FILE_AUTODELETE); 22 | 23 | auto blob = volume->insert("myblob"); 24 | }); 25 | 26 | -------------------------------------------------------------------------------- /fnordmetric-core/src/http/httphandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_HTTPHANDLER_H 11 | #define _FNORDMETRIC_HTTPHANDLER_H 12 | #include 13 | #include 14 | 15 | namespace fnord { 16 | namespace http { 17 | 18 | class HTTPHandler { 19 | public: 20 | 21 | virtual ~HTTPHandler() {} 22 | 23 | virtual bool handleHTTPRequest( 24 | HTTPRequest* request, 25 | HTTPResponse* response) = 0; 26 | 27 | }; 28 | 29 | } 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/parser/tokenize.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef _FNORDMETRIC_QUERY_TOKENIZE_H 12 | #define _FNORDMETRIC_QUERY_TOKENIZE_H 13 | #include 14 | #include "token.h" 15 | 16 | namespace fnordmetric { 17 | namespace query { 18 | 19 | void tokenizeQuery( 20 | const char** cur, 21 | const char* end, 22 | std::vector* token_list); 23 | 24 | void tokenizeQuery( 25 | const std::string& query, 26 | std::vector* token_list); 27 | 28 | } 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /fnordmetric-core/build/cmake/Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of the "FnordMetric" project 2 | # Copyright (c) 2014 Paul Asmuth, Google Inc. 3 | # 4 | # Licensed under the MIT license (see LICENSE). 5 | 6 | all: assets 7 | mkdir -p target/tests 8 | mkdir -p stage/src 9 | test -e stage/src/fnordmetric || ln -s ../../../../src stage/src/fnordmetric || true 10 | (cd target && cmake .. -DCMAKE_BUILD_TYPE=Release && make) 11 | rm -f ../fnordmetric 12 | rm -f ../libfnordmetric-static.a 13 | rm -f ../libfnordmetric.dylib 14 | rm -f ../libfnordmetric.so 15 | ln -s cmake/target/fnordmetric ../fnordmetric 16 | 17 | install: 18 | (cd target && cmake .. && make install) 19 | 20 | assets: 21 | ./assets.sh 22 | 23 | test: all 24 | @find target/tests -iname "test-*" | while read t; do (cd ../../ && build/cmake/$$t) || exit 1; done 25 | 26 | clean: 27 | rm -rf target stage 28 | 29 | .PHONY: all test clean assets install 30 | -------------------------------------------------------------------------------- /fnordmetric-core/src/msgpack/messagepackreader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORD_STORAGE_MSGPACK_H 11 | #define _FNORD_STORAGE_MSGPACK_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace fnord { 21 | namespace msgpack { 22 | 23 | class MessagePackReader { 24 | 25 | 26 | }; 27 | 28 | 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sstable/sstablerepair.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORD_SSTABLE_SSTABLEREPAIR_H 11 | #define _FNORD_SSTABLE_SSTABLEREPAIR_H 12 | #include 13 | 14 | namespace fnord { 15 | namespace sstable { 16 | 17 | class SSTableRepair { 18 | public: 19 | 20 | SSTableRepair(const std::string& filename); 21 | 22 | bool checkAndRepair(bool repair = false); 23 | 24 | protected: 25 | bool checkAndRepairUnfinishedTable(bool repair); 26 | const std::string filename_; 27 | }; 28 | 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/random.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNOR_UTIL_RANDOM_H_ 11 | #define _FNOR_UTIL_RANDOM_H_ 12 | #include 13 | #include 14 | #include 15 | 16 | namespace fnord { 17 | namespace util { 18 | 19 | class Random { 20 | public: 21 | 22 | /** 23 | * Call srand() 24 | */ 25 | static void init(); 26 | 27 | /** 28 | * Create a new random alphanumeric string 29 | */ 30 | static std::string alphanumericString(int nchars); 31 | 32 | }; 33 | 34 | } 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/fnv_test.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | UNIT_TEST(FNVTest); 17 | 18 | TEST_CASE(FNVTest, TestFNV64, [] () { 19 | fnord::util::FNV fnv64; 20 | EXPECT_EQ(fnv64.hash("fnord"), 0xE4D8CB6A3646310); 21 | }); 22 | 23 | TEST_CASE(FNVTest, TestFNV32, [] () { 24 | fnord::util::FNV fnv32; 25 | EXPECT_EQ(fnv32.hash("fnord"), 0x6D964EB0); 26 | }); 27 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/wallclock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_UTIL_WALLCLOCK_H 11 | #define _FNORDMETRIC_UTIL_WALLCLOCK_H 12 | #include 13 | #include 14 | #include 15 | 16 | namespace fnord { 17 | namespace util { 18 | 19 | class WallClock { 20 | public: 21 | static DateTime now(); 22 | static uint64_t getUnixMillis(); 23 | static uint64_t unixMillis(); 24 | static uint64_t getUnixMicros(); 25 | static uint64_t unixMicros(); 26 | }; 27 | 28 | } 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/schema.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #include 12 | #include 13 | #include "record.h" 14 | 15 | namespace fnordmetric { 16 | 17 | Schema::Schema(const std::vector& fields) : fields_(fields) {} 18 | 19 | Field::Field(schema::kFieldType type, const std::string& name) : 20 | type_(type), 21 | name_(name) {} 22 | 23 | const std::string& Field::getName() const { 24 | return name_; 25 | } 26 | 27 | schema::kFieldType Field::getTypeId() const { 28 | return type_; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/tokenindexwriter.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace metricdb { 14 | namespace disk_backend { 15 | 16 | TokenIndexWriter::TokenIndexWriter(TokenIndex* index) { 17 | auto token_ids = index->tokenIDs(); 18 | 19 | for (const auto& pair : token_ids) { 20 | appendUInt32(pair.second); 21 | appendUInt32(pair.first.size()); 22 | appendString(pair.first); 23 | } 24 | } 25 | 26 | } 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sstable/rowoffsetindex.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnord { 13 | namespace sstable { 14 | 15 | RowOffsetIndex* RowOffsetIndex::makeIndex() { 16 | return new RowOffsetIndex(); 17 | } 18 | 19 | RowOffsetIndex::RowOffsetIndex() : Index(RowOffsetIndex::kIndexType) {} 20 | 21 | void RowOffsetIndex::addRow( 22 | size_t body_offset, 23 | void const* key, 24 | size_t key_size, 25 | void const* data, 26 | size_t data_size) const { 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/inspect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_UTIL_INSPECT_H_ 11 | #define _FNORDMETRIC_UTIL_INSPECT_H_ 12 | #include 13 | #include 14 | 15 | namespace fnord { 16 | namespace util { 17 | 18 | template 19 | std::string inspect(const T& value); 20 | 21 | template 22 | std::string inspect(const std::pair& value); 23 | 24 | template 25 | std::string inspect(const std::vector& value); 26 | 27 | } 28 | } 29 | 30 | #include "inspect_impl.h" 31 | #endif 32 | -------------------------------------------------------------------------------- /fnordmetric-core/src/environment.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include 12 | #include 13 | 14 | using fnord::util::LogOutputStream; 15 | 16 | namespace fnordmetric { 17 | 18 | Environment* env() { 19 | static Environment global_env; 20 | return &global_env; 21 | } 22 | 23 | Environment::Environment() : 24 | logger_(new LogOutputStream(util::OutputStream::getStderr())) {} 25 | 26 | void Environment::setVerbose(bool verbose) { 27 | verbose_ = verbose; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/pointchart.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include "pointchart.h" 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace ui { 16 | 17 | char PointChart::kDefaultPointStyle[] = "circle"; 18 | char PointChart::kDefaultPointSize[] = "3"; 19 | 20 | PointChart::PointChart( 21 | ui::Canvas* canvas) : 22 | Drawable(canvas), 23 | show_labels_(false) {} 24 | 25 | void PointChart::setLabels(bool show_labels) { 26 | show_labels_ = show_labels; 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/freeondestroy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORD_UTIL_FREEONDESTROY_H 11 | #define _FNORD_UTIL_FREEONDESTROY_H 12 | #include 13 | 14 | namespace fnord { 15 | namespace util { 16 | 17 | class FreeOnDestroy { 18 | public: 19 | 20 | FreeOnDestroy(void* ptr) : ptr_(ptr) {} 21 | FreeOnDestroy(const FreeOnDestroy& other) = delete; 22 | FreeOnDestroy& operator=(const FreeOnDestroy& other) = delete; 23 | ~FreeOnDestroy() { free(ptr_); } 24 | 25 | protected: 26 | void* ptr_; 27 | }; 28 | 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/agent.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #include 12 | #include "agent.h" 13 | #include "query/query.h" 14 | 15 | namespace fnordmetric { 16 | 17 | std::unique_ptr Agent::executeQuery( 18 | const std::string& query_string) const { 19 | std::unique_ptr query(new query::Query(query_string, *this)); 20 | 21 | return query; 22 | } 23 | 24 | std::shared_ptr Agent::findStreamByName( 25 | const std::string& stream_name) const { 26 | //return std::shared_ptr(nullptr); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sstable/cursor.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnord { 13 | namespace sstable { 14 | 15 | Cursor::Cursor() {} 16 | 17 | Cursor::~Cursor() {} 18 | 19 | std::string Cursor::getKeyString() { 20 | void* data; 21 | size_t size; 22 | getKey(&data, &size); 23 | return std::string((char *) data, size); 24 | } 25 | 26 | std::string Cursor::getDataString() { 27 | void* data; 28 | size_t size; 29 | getData(&data, &size); 30 | return std::string((char *) data, size); 31 | } 32 | 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/snapshot.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef _FNORDMETRIC_SNAPSHOT_H 12 | #define _FNORDMETRIC_SNAPSHOT_H 13 | 14 | namespace fnordmetric { 15 | class Cursor; 16 | class DocumentKey; 17 | 18 | /** 19 | * All methods on a collection instance are threadsafe. 20 | */ 21 | class Snapshot { 22 | 23 | /** 24 | * Return a cursor for this snapshot and seek to the first document with a 25 | * key larger than or equal to the specified key. 26 | */ 27 | std::unique_ptr getCursor(const DocumentKey& key) {} 28 | 29 | }; 30 | 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/compactionpolicy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_COMPACTIONPOLICY_H_ 11 | #define _FNORDMETRIC_METRICDB_COMPACTIONPOLICY_H_ 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace metricdb { 16 | namespace disk_backend { 17 | 18 | class CompactionPolicy { 19 | public: 20 | CompactionPolicy() {} 21 | virtual ~CompactionPolicy() {} 22 | 23 | virtual void compact(std::vector>* tables) = 0; 24 | 25 | }; 26 | 27 | } 28 | } 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/runtime/execute.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_QUERY_EXECUTE_H 11 | #define _FNORDMETRIC_QUERY_EXECUTE_H 12 | #include 13 | #include 14 | 15 | namespace fnordmetric { 16 | namespace query { 17 | class SValue; 18 | class Compiler; 19 | 20 | bool executeExpression( 21 | CompiledExpression* expr, 22 | void* scratchpad, 23 | int argc, 24 | const SValue* argv, 25 | int* outc, 26 | SValue* outv); 27 | 28 | SValue executeSimpleConstExpression(Compiler* compiler, ASTNode* expr); 29 | 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/areachart.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #include 12 | #include "canvas.h" 13 | #include "areachart.h" 14 | #include "rendertarget.h" 15 | 16 | namespace fnordmetric { 17 | namespace ui { 18 | 19 | char AreaChart::kDefaultLineStyle[] = "none"; 20 | char AreaChart::kDefaultLineWidth[] = "1"; 21 | char AreaChart::kDefaultPointStyle[] = "none"; 22 | char AreaChart::kDefaultPointSize[] = "2"; 23 | 24 | AreaChart::AreaChart( 25 | ui::Canvas* canvas, 26 | bool stacked) : 27 | Drawable(canvas), 28 | stacked_(stacked) {} 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/stringutil.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_UTIL_STRINGUTIL_H_ 11 | #define _FNORDMETRIC_UTIL_STRINGUTIL_H_ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnord { 18 | namespace util { 19 | 20 | class StringUtil { 21 | public: 22 | 23 | static void stripTrailingSlashes(std::string* str); 24 | 25 | static std::string hexPrint( 26 | const void* data, 27 | size_t size, 28 | bool separate_bytes = true, 29 | bool reverse_byte_order = false); 30 | 31 | }; 32 | 33 | } 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql_extensions/areachartbuilder.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQLEXTENSIONS_AREACHARTBUILDER_H 11 | #define _FNORDMETRIC_SQLEXTENSIONS_AREACHARTBUILDER_H 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace query { 16 | class DrawStatement; 17 | 18 | class AreaChartBuilder : public ChartBuilder { 19 | public: 20 | AreaChartBuilder(ui::Canvas* canvas, DrawStatement const* draw_stmt); 21 | ui::Drawable* getChart() const override; 22 | std::string chartName() const override; 23 | }; 24 | 25 | } 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/logoutputstream.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_UTIL_LOGOUTPUTSTREAM_H 11 | #define _FNORDMETRIC_UTIL_LOGOUTPUTSTREAM_H 12 | #include 13 | #include 14 | 15 | namespace fnord { 16 | namespace util { 17 | 18 | class LogOutputStream : public Logger { 19 | public: 20 | LogOutputStream(std::unique_ptr target); 21 | void log(const LogEntry& log_entry) override; 22 | protected: 23 | std::unique_ptr target_; 24 | }; 25 | 26 | } 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sstable/sstablewriter_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | namespace fnord { 11 | namespace sstable { 12 | 13 | template 14 | IndexType* SSTableWriter::getIndex() const { 15 | for (const auto& idx : indexes_) { 16 | if (idx->type() == IndexType::kIndexType) { 17 | auto idx_cast = dynamic_cast(idx.get()); 18 | 19 | if (idx_cast == nullptr) { 20 | RAISE(kIndexError, "index type collision"); 21 | } 22 | 23 | return idx_cast; 24 | } 25 | } 26 | 27 | RAISE(kIndexError, "sstable has no such index"); 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/runtime/queryplan.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace query { 14 | 15 | QueryPlan::QueryPlan(TableRepository* table_repo) : table_repo_(table_repo) {} 16 | 17 | void QueryPlan::addQuery(std::unique_ptr query) { 18 | queries_.emplace_back(std::move(query)); 19 | } 20 | 21 | const std::vector>& QueryPlan::queries() { 22 | return queries_; 23 | } 24 | 25 | TableRepository* QueryPlan::tableRepository() { 26 | return table_repo_; 27 | } 28 | 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/random.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnord { 13 | namespace util { 14 | 15 | void Random::init() { 16 | srand(time(NULL)); 17 | } 18 | 19 | std::string Random::alphanumericString(int nchars) { 20 | static const char kAlphanumericChars[] = 21 | "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 22 | 23 | std::string str; 24 | for (int i = 0; i < nchars; ++i) { 25 | // FIXPAUL too many rand() calls! 26 | str += kAlphanumericChars[rand() % (sizeof(kAlphanumericChars) - 1)]; 27 | } 28 | 29 | return str; 30 | } 31 | 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/runtime/rowsink.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef _FNORDMETRIC_SQL_ROWSINK_H 12 | #define _FNORDMETRIC_SQL_ROWSINK_H 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | namespace fnordmetric { 22 | namespace query { 23 | 24 | class RowSink { 25 | public: 26 | virtual ~RowSink() {} 27 | virtual bool nextRow(SValue* row, int row_len) = 0; 28 | virtual void finish() {} 29 | }; 30 | 31 | } 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/backends/backend.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQL_BACKEND_H 11 | #define _FNORDMETRIC_SQL_BACKEND_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnordmetric { 18 | namespace query { 19 | 20 | class Backend { 21 | public: 22 | virtual ~Backend() {} 23 | 24 | virtual bool openTables( 25 | const std::vector& table_names, 26 | const util::URI& source_uri, 27 | std::vector>* target) = 0; 28 | 29 | }; 30 | 31 | } 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /fnordmetric-doc/web/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | backports (2.7.1) 5 | monkey-lib (0.5.4) 6 | backports 7 | rack (1.5.2) 8 | rack-protection (1.3.2) 9 | rack 10 | rack-test (0.6.2) 11 | rack (>= 1.0) 12 | rake (10.0.3) 13 | redcarpet (2.2.2) 14 | sinatra (1.3.3) 15 | rack (~> 1.3, >= 1.3.6) 16 | rack-protection (~> 1.2) 17 | tilt (~> 1.3, >= 1.3.3) 18 | sinatra-advanced-routes (0.5.1) 19 | monkey-lib (~> 0.5.0) 20 | sinatra (~> 1.0) 21 | sinatra-sugar (~> 0.5.0) 22 | sinatra-static (0.1.1) 23 | rack 24 | rack-test 25 | sinatra 26 | sinatra-advanced-routes 27 | term-ansicolor 28 | sinatra-sugar (0.5.1) 29 | monkey-lib (~> 0.5.0) 30 | sinatra (~> 1.0) 31 | term-ansicolor (1.0.7) 32 | tilt (1.3.3) 33 | 34 | PLATFORMS 35 | ruby 36 | 37 | DEPENDENCIES 38 | rake 39 | redcarpet (= 2.2.2) 40 | sinatra (= 1.3.3) 41 | sinatra-static (= 0.1.1) 42 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/inmemory/metricrepository.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_INMEMORY_BACKEND_METRICREPOSITORY_H_ 11 | #define _FNORDMETRIC_METRICDB_INMEMORY_BACKEND_METRICREPOSITORY_H_ 12 | #include 13 | #include 14 | 15 | namespace fnordmetric { 16 | namespace metricdb { 17 | namespace inmemory_backend { 18 | 19 | class MetricRepository : public fnordmetric::metricdb::IMetricRepository { 20 | protected: 21 | Metric* createMetric(const std::string& key) override; 22 | }; 23 | 24 | } 25 | } 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/backends/tableref.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_QUERY_TABLEREF_H 11 | #define _FNORDMETRIC_QUERY_TABLEREF_H 12 | #include 13 | #include 14 | #include 15 | 16 | namespace fnordmetric { 17 | namespace query { 18 | class TableScan; 19 | 20 | class TableRef { 21 | public: 22 | virtual ~TableRef() {} 23 | virtual std::vector columns() = 0; 24 | virtual int getColumnIndex(const std::string& name) = 0; 25 | virtual std::string getColumnName(int index) = 0; 26 | virtual void executeScan(TableScan* scan) = 0; 27 | protected: 28 | }; 29 | 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/barchart.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace ui { 14 | 15 | BarChart::BarChart( 16 | ui::Canvas* canvas, 17 | kBarChartOrientation orient /* = O_VERTICAL */, 18 | bool stacked /* = false */) : 19 | Drawable(canvas), 20 | orientation_(orient), 21 | stacked_(stacked), 22 | show_labels_(false) {} 23 | 24 | void BarChart::setOrientation(kBarChartOrientation orientation) { 25 | orientation_ = orientation; 26 | } 27 | 28 | void BarChart::setLabels(bool show_labels) { 29 | show_labels_ = show_labels; 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/labelindexreader.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace metricdb { 14 | namespace disk_backend { 15 | 16 | LabelIndexReader::LabelIndexReader( 17 | void* data, 18 | size_t size) : 19 | fnord::util::BinaryMessageReader(data, size) {} 20 | 21 | void LabelIndexReader::readIndex(LabelIndex* index) { 22 | while (pos_ < size_) { 23 | auto str_size = *readUInt32(); 24 | auto str = std::string(readString(str_size), str_size); 25 | index->addLabel(str); 26 | } 27 | } 28 | 29 | } 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /fnordmetric-core/test/fixtures/city_temperatures.csv: -------------------------------------------------------------------------------- 1 | city,month,temperature 2 | Tokyo,Dec,9.6 3 | Tokyo,Nov,13.9 4 | Tokyo,Oct,18.3 5 | Tokyo,Sep,23.3 6 | Tokyo,Aug,26.5 7 | Tokyo,Jul,25.2 8 | Tokyo,Jun,21.5 9 | Tokyo,May,18.2 10 | Tokyo,Apr,14.5 11 | Tokyo,Mar,9.5 12 | Tokyo,Feb,6.9 13 | Tokyo,Jan,7.0 14 | New York,Dec,2.5 15 | New York,Nov,8.6 16 | New York,Oct,14.1 17 | New York,Sep,20.1 18 | New York,Aug,24.1 19 | New York,Jul,24.8 20 | New York,Jun,22.0 21 | New York,May,17.0 22 | New York,Apr,11.3 23 | New York,Mar,5.7 24 | New York,Feb,0.8 25 | New York,Jan,-0.2 26 | Berlin,Jan,-0.9 27 | Berlin,Feb,0.6 28 | Berlin,Mar,3.5 29 | Berlin,Apr,8.4 30 | Berlin,May,13.5 31 | Berlin,Jun,17.0 32 | Berlin,Jul,18.6 33 | Berlin,Aug,17.9 34 | Berlin,Sep,14.3 35 | Berlin,Oct,9.0 36 | Berlin,Nov,3.9 37 | Berlin,Dec,1.0 38 | London,Jan,3.9 39 | London,Feb,4.2 40 | London,Mar,5.7 41 | London,Apr,8.5 42 | London,May,11.9 43 | London,Jun,15.2 44 | London,Jul,17.0 45 | London,Aug,16.6 46 | London,Sep,14.2 47 | London,Oct,10.3 48 | London,Nov,6.6 49 | London,Dec,4.8 50 | -------------------------------------------------------------------------------- /fnordmetric-doc/examples/data/city_temperatures.csv: -------------------------------------------------------------------------------- 1 | city,month,temperature 2 | Tokyo,Dec,9.6 3 | Tokyo,Nov,13.9 4 | Tokyo,Oct,18.3 5 | Tokyo,Sep,23.3 6 | Tokyo,Aug,26.5 7 | Tokyo,Jul,25.2 8 | Tokyo,Jun,21.5 9 | Tokyo,May,18.2 10 | Tokyo,Apr,14.5 11 | Tokyo,Mar,9.5 12 | Tokyo,Feb,6.9 13 | Tokyo,Jan,7.0 14 | New York,Dec,2.5 15 | New York,Nov,8.6 16 | New York,Oct,14.1 17 | New York,Sep,20.1 18 | New York,Aug,24.1 19 | New York,Jul,24.8 20 | New York,Jun,22.0 21 | New York,May,17.0 22 | New York,Apr,11.3 23 | New York,Mar,5.7 24 | New York,Feb,0.8 25 | New York,Jan,-0.2 26 | Berlin,Jan,-0.9 27 | Berlin,Feb,0.6 28 | Berlin,Mar,3.5 29 | Berlin,Apr,8.4 30 | Berlin,May,13.5 31 | Berlin,Jun,17.0 32 | Berlin,Jul,18.6 33 | Berlin,Aug,17.9 34 | Berlin,Sep,14.3 35 | Berlin,Oct,9.0 36 | Berlin,Nov,3.9 37 | Berlin,Dec,1.0 38 | London,Jan,3.9 39 | London,Feb,4.2 40 | London,Mar,5.7 41 | London,Apr,8.5 42 | London,May,11.9 43 | London,Jun,15.2 44 | London,Jul,17.0 45 | London,Aug,16.6 46 | London,Sep,14.2 47 | London,Oct,10.3 48 | London,Nov,6.6 49 | London,Dec,4.8 50 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/tableheaderwriter.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace metricdb { 14 | namespace disk_backend { 15 | 16 | TableHeaderWriter::TableHeaderWriter( 17 | const std::string& metric_key, 18 | uint64_t generation, 19 | const std::vector& parents) { 20 | appendUInt32(metric_key.size()); 21 | appendString(metric_key); 22 | appendUInt64(generation); 23 | appendUInt32(parents.size()); 24 | for (const auto parent : parents) { 25 | appendUInt64(parent); 26 | } 27 | } 28 | 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/labelindexwriter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_LABELINDEXWRITER_H 11 | #define _FNORDMETRIC_METRICDB_LABELINDEXWRITER_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace fnordmetric { 20 | namespace metricdb { 21 | namespace disk_backend { 22 | 23 | class LabelIndexWriter : public fnord::util::BinaryMessageWriter { 24 | public: 25 | LabelIndexWriter(LabelIndex* index); 26 | }; 27 | 28 | } 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/tokenindexwriter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_TOKENINDEXWRITER_H 11 | #define _FNORDMETRIC_METRICDB_TOKENINDEXWRITER_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace fnordmetric { 20 | namespace metricdb { 21 | namespace disk_backend { 22 | 23 | class TokenIndexWriter : public fnord::util::BinaryMessageWriter { 24 | public: 25 | TokenIndexWriter(TokenIndex* index); 26 | }; 27 | 28 | } 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/linechart.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include "canvas.h" 12 | #include "linechart.h" 13 | #include 14 | 15 | namespace fnordmetric { 16 | namespace ui { 17 | 18 | char LineChart::kDefaultLineStyle[] = "solid"; 19 | char LineChart::kDefaultLineWidth[] = "2"; 20 | char LineChart::kDefaultPointStyle[] = "none"; 21 | char LineChart::kDefaultPointSize[] = "3"; 22 | 23 | LineChart::LineChart( 24 | ui::Canvas* canvas) : 25 | Drawable(canvas), 26 | show_labels_(false) {} 27 | 28 | void LineChart::setLabels(bool show_labels) { 29 | show_labels_ = show_labels; 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/samplereader_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_SAMPLEREADER_IMPL_H 11 | #define _FNORDMETRIC_METRICDB_SAMPLEREADER_IMPL_H 12 | 13 | namespace fnordmetric { 14 | namespace metricdb { 15 | namespace disk_backend { 16 | 17 | template 18 | SampleReader::SampleReader( 19 | void* data, 20 | size_t size, 21 | TokenIndex* token_index) : 22 | AbstractSampleReader(data, size, token_index) { 23 | value_ = readValue(); 24 | label_offset_ = pos_; 25 | } 26 | 27 | template 28 | const T& SampleReader::value() { 29 | return value_; 30 | } 31 | 32 | 33 | } 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/runtime/importstatement.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_QUERY_IMPORTSTATEMENT_H 11 | #define _FNORDMETRIC_QUERY_IMPORTSTATEMENT_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnordmetric { 18 | namespace query { 19 | 20 | class ImportStatement { 21 | public: 22 | ImportStatement(ASTNode* ast, Compiler* compiler); 23 | const std::string& source_uri() const; 24 | const std::vector& tables() const; 25 | protected: 26 | std::string source_uri_; 27 | std::vector tables_; 28 | }; 29 | 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/compactiontask.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_COMPACTIONTASK_H_ 11 | #define _FNORDMETRIC_METRICDB_COMPACTIONTASK_H_ 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace metricdb { 16 | namespace disk_backend { 17 | class MetricRepository; 18 | 19 | class CompactionTask { 20 | public: 21 | static const uint64_t kRunEveryMicrosDefault = 30 * 1000000; 22 | 23 | CompactionTask(MetricRepository* metric_repo); 24 | std::function runnable() const; 25 | protected: 26 | void run() const; 27 | MetricRepository* metric_repo_; 28 | uint64_t run_every_micros_; 29 | }; 30 | 31 | 32 | } 33 | } 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/sample.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | using fnord::util::DateTime; 13 | 14 | namespace fnordmetric { 15 | namespace metricdb { 16 | 17 | Sample::Sample( 18 | const DateTime& time, 19 | double value, 20 | const std::vector>& labels) : 21 | time_(time), 22 | value_(value), 23 | labels_(labels) {} 24 | 25 | const DateTime& Sample::time() { 26 | return time_; 27 | } 28 | 29 | double Sample::value() { 30 | return value_; 31 | } 32 | 33 | const std::vector>& Sample::labels() { 34 | return labels_; 35 | } 36 | 37 | 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/tableheaderwriter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_TABLEHEADERWRITER_H 11 | #define _FNORDMETRIC_METRICDB_TABLEHEADERWRITER_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace fnordmetric { 19 | namespace metricdb { 20 | namespace disk_backend { 21 | 22 | class TableHeaderWriter : public fnord::util::BinaryMessageWriter { 23 | public: 24 | TableHeaderWriter( 25 | const std::string& metric_key, 26 | uint64_t generation, 27 | const std::vector& parents); 28 | }; 29 | 30 | } 31 | } 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/assets.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_WEB_ASSETS_H 11 | #define _FNORDMETRIC_WEB_ASSETS_H 12 | #include 13 | #include 14 | #include 15 | 16 | namespace fnordmetric { 17 | namespace util { 18 | 19 | class Assets { 20 | public: 21 | class AssetFile { 22 | public: 23 | AssetFile( 24 | const std::string& name, 25 | const unsigned char* data, 26 | size_t size); 27 | }; 28 | 29 | static std::string getAsset(const std::string& filename); 30 | 31 | protected: 32 | static std::unordered_map< 33 | std::string, std::pair>* global_map(); 34 | }; 35 | 36 | } 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/buffer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORD_UTIL_BUFFER_H_ 11 | #define _FNORD_UTIL_BUFFER_H_ 12 | #include 13 | #include 14 | #include 15 | 16 | namespace fnord { 17 | namespace util { 18 | 19 | class Buffer { 20 | public: 21 | 22 | Buffer(const void* initial_data, size_t initial_size); 23 | Buffer(size_t initial_size); 24 | Buffer(const Buffer& copy); 25 | Buffer(Buffer&& move); 26 | Buffer& operator=(const Buffer& copy) = delete; 27 | ~Buffer(); 28 | 29 | void* data() const; 30 | size_t size() const; 31 | std::string toString() const; 32 | 33 | protected: 34 | void* data_; 35 | size_t size_; 36 | }; 37 | 38 | } 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/tokenindexreader.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace metricdb { 14 | namespace disk_backend { 15 | 16 | TokenIndexReader::TokenIndexReader( 17 | void* data, 18 | size_t size) : 19 | fnord::util::BinaryMessageReader(data, size) {} 20 | 21 | void TokenIndexReader::readIndex(TokenIndex* token_index) { 22 | while (pos_ < size_) { 23 | auto token_id = *readUInt32(); 24 | auto str_size = *readUInt32(); 25 | auto str = std::string(readString(str_size), str_size); 26 | token_index->addToken(str, token_id); 27 | } 28 | } 29 | 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/griddefinition.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace ui { 14 | 15 | GridDefinition::GridDefinition( 16 | kPlacement placement) : 17 | placement_(placement), 18 | domain_(nullptr) {} 19 | 20 | void GridDefinition::setDomain(DomainProvider* domain) { 21 | domain_ = domain; 22 | } 23 | 24 | GridDefinition::kPlacement GridDefinition::placement() const { 25 | return placement_; 26 | } 27 | 28 | const std::vector GridDefinition::ticks() const { 29 | if (domain_->empty()) { 30 | return std::vector(); 31 | } else { 32 | return domain_->get()->getTicks(); 33 | } 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/record_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef _FNORDMETRIC_RECORD_IMPL_H 12 | #define _FNORDMETRIC_RECORD_IMPL_H 13 | 14 | namespace fnordmetric { 15 | 16 | template 17 | TypedRecordWriter::TypedRecordWriter( 18 | const typename T::ValueType&... values) { 19 | appendFields(values...); 20 | } 21 | 22 | template 23 | template 24 | void TypedRecordWriter::appendFields(T1 head) { 25 | appendField(head); 26 | } 27 | 28 | template 29 | template 30 | void TypedRecordWriter::appendFields(T1 head, T2... tail) { 31 | appendField(head); 32 | appendFields(tail...); 33 | } 34 | 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/backends/csv/csvbackend.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_CSVBACKEND_H 11 | #define _FNORDMETRIC_CSVBACKEND_H 12 | #include 13 | #include 14 | #include 15 | 16 | namespace fnordmetric { 17 | namespace query { 18 | class ASTNode; 19 | namespace csv_backend { 20 | 21 | class CSVBackend : public fnordmetric::query::Backend { 22 | public: 23 | 24 | static CSVBackend* singleton(); 25 | 26 | bool openTables( 27 | const std::vector& table_names, 28 | const util::URI& source_uri, 29 | std::vector>* target) override; 30 | 31 | }; 32 | 33 | } 34 | } 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/fnv.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #include 12 | #include 13 | #include "fnv.h" 14 | 15 | namespace fnord { 16 | namespace util { 17 | 18 | /** 19 | * Parameters for the 32bit version of the FNV hash function 20 | * 21 | * basis: 2166136261 22 | * prime: 16777619 23 | * 24 | */ 25 | template<> FNV::FNV() : 26 | basis_(2166136261llu), 27 | prime_(16777619llu) {} 28 | 29 | 30 | /** 31 | * Parameters for the 64bit version of the FNV hash function 32 | * 33 | * basis: 14695981039346656037 34 | * prime: 1099511628211 35 | * 36 | */ 37 | template<> FNV::FNV() : 38 | basis_(14695981039346656037llu), 39 | prime_(1099511628211llu) {} 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/format.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef _FNORDMETRIC_FORMAT_H 12 | #define _FNORDMETRIC_FORMAT_H 13 | #include 14 | #include 15 | 16 | namespace fnordmetric { 17 | namespace util { 18 | namespace format { 19 | 20 | std::string numberToHuman(double value); 21 | std::string svalueToHuman(const query::SValue& value); 22 | std::string formatTime(fnordmetric::TimeType time, const char* fmt = nullptr); 23 | std::string formatTimeWithRange(fnordmetric::TimeType time, int range); 24 | 25 | // FIXPAUL clean up... 26 | template 27 | std::string toHuman(T value) { 28 | query::SValue sval(value); 29 | return sval.toString(); 30 | } 31 | 32 | } 33 | } 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/inspect_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | namespace fnord { 11 | namespace util { 12 | 13 | template 14 | std::string inspect(const std::pair& value) { 15 | std::string str = "<"; 16 | str += inspect(value.first); 17 | str += ", "; 18 | str += inspect(value.second); 19 | str += '>'; 20 | return str; 21 | } 22 | 23 | template 24 | std::string inspect(const std::vector& value) { 25 | std::string str = "["; 26 | for (auto iter = value.begin(); iter != value.end(); ++iter) { 27 | if (iter != value.begin()) { 28 | str += ", "; 29 | } 30 | 31 | str += inspect(*iter); 32 | } 33 | str += ']'; 34 | return str; 35 | } 36 | 37 | 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/labelindexreader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_LABELINDEXREADER_H 11 | #define _FNORDMETRIC_METRICDB_LABELINDEXREADER_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace fnordmetric { 20 | namespace metricdb { 21 | namespace disk_backend { 22 | 23 | class LabelIndexReader : public fnord::util::BinaryMessageReader { 24 | public: 25 | LabelIndexReader( 26 | void* data, 27 | size_t size); 28 | 29 | void readIndex(LabelIndex* token_index); 30 | 31 | }; 32 | 33 | } 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/tokenindexreader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_TOKENINDEXREADER_H 11 | #define _FNORDMETRIC_METRICDB_TOKENINDEXREADER_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace fnordmetric { 20 | namespace metricdb { 21 | namespace disk_backend { 22 | 23 | class TokenIndexReader : public fnord::util::BinaryMessageReader { 24 | public: 25 | TokenIndexReader( 26 | void* data, 27 | size_t size); 28 | 29 | void readIndex(TokenIndex* token_index); 30 | 31 | }; 32 | 33 | } 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/expressions/math.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQL_EXPRESSIONS_MATH_H 11 | #define _FNORDMETRIC_SQL_EXPRESSIONS_MATH_H 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace query { 16 | namespace expressions { 17 | 18 | void addExpr(void* scratchpad, int argc, SValue* argv, SValue* out); 19 | void subExpr(void* scratchpad, int argc, SValue* argv, SValue* out); 20 | void mulExpr(void* scratchpad, int argc, SValue* argv, SValue* out); 21 | void divExpr(void* scratchpad, int argc, SValue* argv, SValue* out); 22 | void modExpr(void* scratchpad, int argc, SValue* argv, SValue* out); 23 | void powExpr(void* scratchpad, int argc, SValue* argv, SValue* out); 24 | 25 | } 26 | } 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/metrictablerepository.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_METRICTABLEREPOSITORY_H 11 | #define _FNORDMETRIC_METRICDB_METRICTABLEREPOSITORY_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace fnordmetric { 19 | namespace metricdb { 20 | 21 | class MetricTableRepository : public fnordmetric::query::TableRepository { 22 | public: 23 | 24 | MetricTableRepository(IMetricRepository* metric_repo); 25 | query::TableRef* getTableRef(const std::string& table_name) const override; 26 | 27 | protected: 28 | IMetricRepository* metric_repo_; 29 | }; 30 | 31 | } 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql_extensions/linechartbuilder.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQLEXTENSIONS_LINECHARTBUILDER_H 11 | #define _FNORDMETRIC_SQLEXTENSIONS_LINECHARTBUILDER_H 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace ui { 16 | class LineChart; 17 | } 18 | 19 | namespace query { 20 | class DrawStatement; 21 | 22 | class LineChartBuilder : public ChartBuilder { 23 | public: 24 | LineChartBuilder(ui::Canvas* canvas, DrawStatement const* draw_stmt); 25 | ui::Drawable* getChart() const override; 26 | std::string chartName() const override; 27 | protected: 28 | ui::Drawable* findChartType() const; 29 | void setLabels(ui::LineChart* chart) const; 30 | }; 31 | 32 | } 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sstable/rowoffsetindex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORD_SSTABLE_ROWOFFSETINDEX_H 11 | #define _FNORD_SSTABLE_ROWOFFSETINDEX_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace fnord { 19 | namespace sstable { 20 | 21 | class RowOffsetIndex : public Index { 22 | public: 23 | static const uint32_t kIndexType = 0xa0a0; 24 | 25 | static RowOffsetIndex* makeIndex(); 26 | 27 | RowOffsetIndex(); 28 | 29 | void addRow( 30 | size_t body_offset, 31 | void const* key, 32 | size_t key_size, 33 | void const* data, 34 | size_t data_size) const override; 35 | 36 | }; 37 | 38 | 39 | } 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /fnordmetric-webui/Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of the "FnordMetric" project 2 | # Copyright (c) 2014 Paul Asmuth, Google Inc. 3 | # 4 | # Licensed under the MIT license (see LICENSE). 5 | 6 | all: build 7 | 8 | clean: 9 | -rm fnordmetric-webui.js 10 | 11 | build: 12 | @( \ 13 | echo "/* THIS IS AN AUTOMATICALLY GENEREATED FILE --- DO NOT EDIT */"; \ 14 | cat fnordmetric-webui-layout.js \ 15 | fnordmetric-webui-util.js \ 16 | fnordmetric-webui-tableview.js \ 17 | fnordmetric-webui-metriclist.js \ 18 | fnordmetric-webui-queryeditor.js \ 19 | fnordmetric-webui-sqleditorview.js \ 20 | fnordmetric-webui-visualeditorview.js \ 21 | fnordmetric-webui-queryresultview.js \ 22 | fnordmetric-webui-singlemetricview.js \ 23 | fnordmetric-webui-metricpreviewwidget.js \ 24 | fnordmetric-webui-embedpopup.js \ 25 | fnordmetric-webui-autocomplete.js \ 26 | fnordmetric-webui-datepicker.js \ 27 | codemirror.js \ 28 | codemirror-sql.js \ 29 | ) > fnordmetric-webui.js 30 | 31 | watch: 32 | -while sleep 1; do fswatch -1 * && make; done 33 | 34 | .PHONY: all clean build wtach 35 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/agent_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordStream" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * Licensed under the MIT license (see LICENSE). 6 | */ 7 | #ifndef _FNORDMETRIC_AGENT_IMPL_H 8 | #define _FNORDMETRIC_AGENT_IMPL_H 9 | 10 | namespace fnordmetric { 11 | 12 | Agent::Agent( 13 | const std::string& name, 14 | std::unique_ptr&& database) : 15 | name_(name), 16 | database_(std::move(database)) {} 17 | 18 | template 19 | std::shared_ptr> Agent::openStream( 20 | const std::string& name, 21 | //const StreamDescription& description, 22 | const T... fields) { 23 | TypedSchema schema(fields...); 24 | TypedStreamKey key(name, fields...); 25 | 26 | streams_mutex_.lock(); 27 | auto stream_ref = database_->openStream(key.getKeyString()); 28 | auto stream = std::make_shared>( 29 | key, 30 | schema, 31 | std::move(stream_ref)); 32 | 33 | streams_.push_back(stream); 34 | streams_mutex_.unlock(); 35 | 36 | return stream; 37 | } 38 | 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/labelindex.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | 12 | namespace fnordmetric { 13 | namespace metricdb { 14 | namespace disk_backend { 15 | 16 | LabelIndex::LabelIndex() {} 17 | 18 | void LabelIndex::addLabel(const std::string& label) { 19 | std::lock_guard lock_holder(mutex_); 20 | labels_.emplace(label); 21 | } 22 | 23 | bool LabelIndex::hasLabel(const std::string& label) const { 24 | std::lock_guard lock_holder(mutex_); 25 | return labels_.find(label) != labels_.end(); 26 | } 27 | 28 | std::set LabelIndex::labels() const { 29 | std::lock_guard lock_holder(mutex_); 30 | return labels_; 31 | } 32 | 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql_extensions/pointchartbuilder.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQLEXTENSIONS_POINTCHARTBUILDER_H 11 | #define _FNORDMETRIC_SQLEXTENSIONS_POINTCHARTBUILDER_H 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace ui { 16 | class PointChart; 17 | } 18 | 19 | namespace query { 20 | class DrawStatement; 21 | 22 | class PointChartBuilder : public ChartBuilder { 23 | public: 24 | PointChartBuilder(ui::Canvas* canvas, DrawStatement const* draw_stmt); 25 | ui::Drawable* getChart() const override; 26 | std::string chartName() const override; 27 | protected: 28 | ui::Drawable* findChartType() const; 29 | void setLabels(ui::PointChart* chart) const; 30 | }; 31 | 32 | } 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/idsequence.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef _FNORDMETRIC_IDSEQUENCE_H 12 | #define _FNORDMETRIC_IDSEQUENCE_H 13 | #include 14 | #include 15 | #include "clock.h" 16 | 17 | namespace fnordmetric { 18 | 19 | /** 20 | */ 21 | class IDSequence { 22 | public: 23 | IDSequence() {} 24 | IDSequence(const IDSequence& copy) = delete; 25 | IDSequence& operator==(const IDSequence& copy) = delete; 26 | virtual ~IDSequence() {} 27 | virtual uint64_t getNext(uint64_t last) = 0; 28 | }; 29 | 30 | class UnixMillisecondIDSequence : public IDSequence { 31 | public: 32 | UnixMillisecondIDSequence() {} 33 | uint64_t getNext(uint64_t last) override { 34 | return WallClock::getUnixMillis(); 35 | } 36 | }; 37 | 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/labelindex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_LABELINDEX_H 11 | #define _FNORDMETRIC_METRICDB_LABELINDEX_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace fnordmetric { 19 | namespace metricdb { 20 | namespace disk_backend { 21 | 22 | class LabelIndex { 23 | public: 24 | static const uint32_t kIndexType = 0xa0f2; 25 | 26 | LabelIndex(); 27 | 28 | void addLabel(const std::string& label); 29 | bool hasLabel(const std::string& label) const; 30 | std::set labels() const; 31 | 32 | protected: 33 | std::set labels_; 34 | mutable std::mutex mutex_; 35 | }; 36 | 37 | 38 | } 39 | } 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /fnordmetric-core/src/http/status.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_HTTP_STATUSES_H 11 | #define _FNORDMETRIC_HTTP_STATUSES_H 12 | 13 | namespace fnord { 14 | namespace http { 15 | 16 | struct HTTPStatus { 17 | HTTPStatus(int code_, const char* name_) : code(code_), name(name_) {} 18 | int code; 19 | const char* name; 20 | }; 21 | 22 | const HTTPStatus kStatusOK(200, "OK"); 23 | const HTTPStatus kStatusCreated(201, "Created"); 24 | const HTTPStatus kStatusBadRequest(404, "Bad request"); 25 | const HTTPStatus kStatusNotFound(404, "Not found"); 26 | const HTTPStatus kStatusMovedPermanently(301, "Moved permanently"); 27 | const HTTPStatus kStatusFound(302, "Found"); 28 | const HTTPStatus kStatusInternalServerError(500, "InternalServerError"); 29 | 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/timedomain.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_TIMEDOMAIN_H 11 | #define _FNORDMETRIC_TIMEDOMAIN_H 12 | #include 13 | #include 14 | 15 | namespace fnordmetric { 16 | namespace ui { 17 | 18 | class TimeDomain : public ContinuousDomain { 19 | public: 20 | 21 | TimeDomain( 22 | fnord::util::DateTime min_value = 23 | std::numeric_limits::max(), 24 | fnord::util::DateTime max_value = 25 | std::numeric_limits::min(), 26 | bool is_logarithmic = false, 27 | bool is_inverted = false); 28 | 29 | std::string label(fnord::util::DateTime value) const; 30 | 31 | }; 32 | 33 | } 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/wallclock.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include 12 | 13 | namespace fnord { 14 | namespace util { 15 | 16 | DateTime WallClock::now() { 17 | return DateTime(WallClock::getUnixMicros()); 18 | } 19 | 20 | uint64_t WallClock::getUnixMillis() { 21 | return unixMillis(); 22 | } 23 | 24 | uint64_t WallClock::unixMillis() { 25 | struct timeval tv; 26 | 27 | gettimeofday(&tv, NULL); 28 | return tv.tv_sec * 1000u + tv.tv_usec / 1000u; 29 | } 30 | 31 | uint64_t WallClock::getUnixMicros() { 32 | return unixMicros(); 33 | } 34 | 35 | uint64_t WallClock::unixMicros() { 36 | struct timeval tv; 37 | 38 | gettimeofday(&tv, NULL); 39 | return tv.tv_sec * 1000000u + tv.tv_usec; 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /fnordmetric-core/src/io/filerepository.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORD_IO_FILEREPOSITORY_H_ 11 | #define _FNORD_IO_FILEREPOSITORY_H_ 12 | #include 13 | #include 14 | #include 15 | 16 | namespace fnord { 17 | namespace io { 18 | 19 | class FileRepository { 20 | public: 21 | struct FileRef { 22 | std::string logical_filename; 23 | std::string absolute_path; 24 | }; 25 | 26 | FileRepository(const std::string& basedir); 27 | 28 | /** 29 | * Create and return a new file 30 | */ 31 | FileRef createFile() const; 32 | 33 | void listFiles( 34 | std::function callback) const; 35 | 36 | void deleteAllFiles(); 37 | 38 | protected: 39 | std::string basedir_; 40 | }; 41 | 42 | } 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/timedomain.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include 12 | 13 | namespace fnordmetric { 14 | namespace ui { 15 | 16 | TimeDomain::TimeDomain( 17 | fnord::util::DateTime min_value, 18 | fnord::util::DateTime max_value, 19 | bool is_logarithmic, 20 | bool is_inverted) : 21 | ContinuousDomain( 22 | min_value, 23 | max_value, 24 | is_logarithmic, 25 | is_inverted) {} 26 | 27 | std::string TimeDomain::label(fnord::util::DateTime value) const { 28 | return fnordmetric::util::format::formatTimeWithRange( 29 | value, 30 | static_cast( 31 | ContinuousDomain::getRange())); 32 | } 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql_extensions/barchartbuilder.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQLEXTENSIONS_BARCHARTBUILDER_H 11 | #define _FNORDMETRIC_SQLEXTENSIONS_BARCHARTBUILDER_H 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace query { 16 | class DrawStatement; 17 | 18 | class BarChartBuilder : public ChartBuilder { 19 | public: 20 | BarChartBuilder(ui::Canvas* canvas, DrawStatement const* draw_stmt); 21 | ui::Drawable* getChart() const override; 22 | std::string chartName() const override; 23 | protected: 24 | ui::Drawable* findChartType() const; 25 | void setOrientation(ui::BarChart* chart) const; 26 | void setStacked(ui::BarChart* chart) const; 27 | void setLabels(ui::BarChart* chart) const; 28 | }; 29 | 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/binarymessagereader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORD_UTIL_BINARYMESSAGEREADER_H 11 | #define _FNORD_UTIL_BINARYMESSAGEREADER_H 12 | #include 13 | #include 14 | #include 15 | 16 | namespace fnord { 17 | namespace util { 18 | 19 | class BinaryMessageReader { 20 | public: 21 | BinaryMessageReader(void const* buf, size_t buf_len); 22 | virtual ~BinaryMessageReader() {}; 23 | 24 | uint16_t const* readUInt16(); 25 | uint32_t const* readUInt32(); 26 | uint64_t const* readUInt64(); 27 | char const* readString(size_t size); 28 | void const* read(size_t size); 29 | 30 | void rewind(); 31 | void seekTo(size_t pos); 32 | 33 | protected: 34 | void const* ptr_; 35 | size_t size_; 36 | size_t pos_; 37 | }; 38 | 39 | } 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/schema_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef _FNORDMETRIC_SCHEMA_IMPL_H 12 | #define _FNORDMETRIC_SCHEMA_IMPL_H 13 | 14 | #include 15 | #include 16 | 17 | namespace fnordmetric { 18 | 19 | template 20 | TypedSchema::TypedSchema(const T... fields) : 21 | Schema(unpackFields(fields...)) {} 22 | 23 | // FIXPAUL there must be some better way to do this... 24 | template 25 | std::vector TypedSchema::unpackFields(T... fields) { 26 | std::vector unpacked; 27 | const Field packed[] = {fields...}; 28 | int num_fields = sizeof(packed) / sizeof(Field); 29 | 30 | for (int i = 0; i < num_fields; ++i) { 31 | unpacked.push_back(packed[i]); 32 | } 33 | 34 | return unpacked; 35 | }; 36 | 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sstable/index.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORD_SSTABLE_INDEX_H 11 | #define _FNORD_SSTABLE_INDEX_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnord { 18 | namespace sstable { 19 | 20 | class Index { 21 | public: 22 | typedef std::unique_ptr IndexRef; 23 | 24 | Index(uint32_t type); 25 | Index(const Index& copy) = delete; 26 | Index& operator=(const Index& copy) = delete; 27 | virtual ~Index() {} 28 | 29 | uint32_t type() const; 30 | 31 | virtual void addRow( 32 | size_t body_offset, 33 | void const* key, 34 | size_t key_size, 35 | void const* data, 36 | size_t data_size) const = 0; 37 | 38 | protected: 39 | uint32_t type_; 40 | }; 41 | 42 | 43 | } 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/documentref.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #include 12 | #include 13 | #include "documentref.h" 14 | 15 | namespace fnordmetric { 16 | 17 | DocumentRef::DocumentRef( 18 | const DocumentKey& key) : 19 | key_(key), 20 | dirty_(1) {} 21 | 22 | void DocumentRef::revert() { 23 | // FIXPAUL free pages if alloced 24 | } 25 | 26 | bool DocumentRef::isDirty() { 27 | return dirty_ == 1; 28 | } 29 | 30 | void DocumentRef::setDocumentKey(const DocumentKey& key) { 31 | key_ = key; 32 | } 33 | 34 | const DocumentKey& DocumentRef::getDocumentKey() const { 35 | return key_; 36 | } 37 | 38 | void DocumentRef::getScratchpad(char** data, size_t* size) const { 39 | static char scratch[] = "fnord"; 40 | *data = scratch; 41 | *size = sizeof(scratch); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/sample.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_SAMPLE_H_ 11 | #define _FNORDMETRIC_METRICDB_SAMPLE_H_ 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using fnord::util::DateTime; 18 | 19 | namespace fnordmetric { 20 | namespace metricdb { 21 | 22 | class Sample { 23 | public: 24 | Sample( 25 | const DateTime& time, 26 | double value, 27 | const std::vector>& labels); 28 | 29 | const DateTime& time(); 30 | double value(); 31 | const std::vector>& labels(); 32 | 33 | protected: 34 | const DateTime& time_; 35 | double value_; 36 | const std::vector>& labels_; 37 | }; 38 | 39 | } 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/runtime/queryplan.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_SQL_RUNTIME_QUERYPLAN_H 11 | #define _FNORDMETRIC_SQL_RUNTIME_QUERYPLAN_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace fnordmetric { 20 | namespace query { 21 | 22 | class QueryPlan { 23 | public: 24 | 25 | QueryPlan(TableRepository* table_repo); 26 | 27 | void addQuery(std::unique_ptr query); 28 | const std::vector>& queries(); 29 | 30 | TableRepository* tableRepository(); 31 | 32 | protected: 33 | TableRepository* table_repo_; 34 | std::vector> queries_; 35 | }; 36 | 37 | } 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /fnordmetric-core/src/environment.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_ENVIRONMENT_H 11 | #define _FNORDMETRIC_ENVIRONMENT_H 12 | #include 13 | #include 14 | #include 15 | #include "config.h" 16 | 17 | using fnord::util::Logger; 18 | 19 | namespace fnordmetric { 20 | 21 | class Environment { 22 | public: 23 | Environment(); 24 | 25 | inline cli::FlagParser* flags() { 26 | return &flag_parser_; 27 | } 28 | 29 | inline Logger* logger() { 30 | return logger_.get(); 31 | } 32 | 33 | inline bool verbose() { 34 | return verbose_; 35 | } 36 | 37 | void setVerbose(bool verbose); 38 | 39 | protected: 40 | bool verbose_; 41 | cli::FlagParser flag_parser_; 42 | std::unique_ptr logger_; 43 | }; 44 | 45 | Environment* env(); 46 | 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/documentkey.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef _FNORDMETRIC_DOCUMENTKEY_H 12 | #define _FNORDMETRIC_DOCUMENTKEY_H 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace fnordmetric { 19 | 20 | /** 21 | */ 22 | class DocumentKey { 23 | public: 24 | explicit DocumentKey(const std::string& key); 25 | explicit DocumentKey(uint64_t key); 26 | DocumentKey(const DocumentKey& copy); 27 | DocumentKey& operator==(const DocumentKey& copy) = delete; 28 | ~DocumentKey(); 29 | bool isIntKey() const; 30 | bool isStringKey() const; 31 | uint64_t getIntKey() const; 32 | const std::string* getStringKey() const; 33 | protected: 34 | bool is_string_; 35 | union { 36 | uint64_t int_key; 37 | std::string* string_key; 38 | } key_; 39 | }; 40 | 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/samplewriter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_SAMPLEWRITER_H 11 | #define _FNORDMETRIC_METRICDB_SAMPLEWRITER_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnordmetric { 18 | namespace metricdb { 19 | namespace disk_backend { 20 | class TokenIndex; 21 | 22 | class SampleWriter : public fnord::util::BinaryMessageWriter { 23 | public: 24 | SampleWriter(TokenIndex* label_index); 25 | 26 | template 27 | void writeValue(T value); 28 | 29 | void writeLabel(const std::string& key, const std::string& value); 30 | 31 | protected: 32 | void writeToken(const std::string& token, bool force_indexing); 33 | TokenIndex* token_index_; 34 | }; 35 | 36 | } 37 | } 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/griddefinition.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_UI_GRIDDEFINITION_H 11 | #define _FNORDMETRIC_UI_GRIDDEFINITION_H 12 | #include 13 | #include 14 | 15 | namespace fnordmetric { 16 | namespace ui { 17 | 18 | class GridDefinition { 19 | public: 20 | 21 | enum kPlacement { 22 | GRID_HORIZONTAL = 0, 23 | GRID_VERTICAL = 1 24 | }; 25 | 26 | /** 27 | * Create a new grid definition 28 | */ 29 | GridDefinition(kPlacement placement); 30 | 31 | /** 32 | * Set the domain for this grid 33 | */ 34 | void setDomain(DomainProvider* domain); 35 | 36 | kPlacement placement() const; 37 | const std::vector ticks() const; 38 | 39 | protected: 40 | kPlacement placement_; 41 | DomainProvider* domain_; 42 | }; 43 | 44 | } 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/adminui.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_WEBINTERFACE_H 11 | #define _FNORDMETRIC_WEBINTERFACE_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace fnord; 18 | namespace fnordmetric { 19 | namespace metricdb { 20 | 21 | class AdminUI : public http::HTTPHandler { 22 | public: 23 | 24 | static std::unique_ptr getHandler(); 25 | 26 | bool handleHTTPRequest( 27 | http::HTTPRequest* request, 28 | http::HTTPResponse* response) override; 29 | 30 | private: 31 | 32 | void sendAsset( 33 | http::HTTPResponse* response, 34 | const std::string& asset_path, 35 | const std::string& content_type) const; 36 | 37 | }; 38 | 39 | } 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /fnordmetric-core/src/util/inputstream_test.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordStream" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * Licensed under the MIT license (see LICENSE). 6 | */ 7 | #include 8 | #include 9 | #include "inputstream.h" 10 | #include "runtimeexception.h" 11 | #include "unittest.h" 12 | 13 | using namespace fnordmetric::util; 14 | 15 | UNIT_TEST(FileInputStreamTest); 16 | 17 | TEST_CASE(FileInputStreamTest, TestOpenFile, [] () { 18 | auto file = FileInputStream::openFile( 19 | "test/fixtures/gbp_per_country.csv"); 20 | 21 | EXPECT(file.get() != nullptr); 22 | }); 23 | 24 | TEST_CASE(FileInputStreamTest, TestInvalidFileName, [] () { 25 | auto errmsg = "error opening file 'test/fixtures/invalid.csv': " 26 | "No such file or directory"; 27 | 28 | EXPECT_EXCEPTION(errmsg, [] () { 29 | auto file = FileInputStream::openFile("test/fixtures/invalid.csv"); 30 | }); 31 | }); 32 | 33 | TEST_CASE(FileInputStreamTest, TestReadUTF8ByteOrderMark, [] () { 34 | auto file = FileInputStream::openFile( 35 | "test/fixtures/gbp_per_country.csv"); 36 | 37 | EXPECT(file.get() != nullptr); 38 | EXPECT(file->readByteOrderMark() == FileInputStream::BOM_UTF8); 39 | }); 40 | -------------------------------------------------------------------------------- /fnordmetric-core/src/thread/taskscheduler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_THREAD_TASKSCHEDULER_H 11 | #define _FNORDMETRIC_THREAD_TASKSCHEDULER_H 12 | #include 13 | 14 | namespace fnord { 15 | namespace thread { 16 | 17 | class TaskScheduler { 18 | public: 19 | virtual ~TaskScheduler() {} 20 | 21 | /** 22 | * Run the provided task as soon as possible 23 | */ 24 | virtual void run(std::shared_ptr task) = 0; 25 | 26 | /** 27 | * Run the provided task when the provided filedescriptor becomes readable 28 | */ 29 | virtual void runOnReadable(std::shared_ptr task, int fd) = 0; 30 | 31 | /** 32 | * Run the provided task when the provided filedescriptor becomes writable 33 | */ 34 | virtual void runOnWritable(std::shared_ptr task, int fd) = 0; 35 | 36 | }; 37 | 38 | } 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sstable/cursor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORD_SSTABLE_CURSOR_H 11 | #define _FNORD_SSTABLE_CURSOR_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnord { 18 | namespace sstable { 19 | 20 | class Cursor { 21 | public: 22 | Cursor(); 23 | Cursor(const Cursor& copy) = delete; 24 | Cursor& operator=(const Cursor& copy) = delete; 25 | virtual ~Cursor(); 26 | 27 | virtual void seekTo(size_t body_offset) = 0; 28 | virtual bool next() = 0; 29 | virtual bool valid() = 0; 30 | 31 | virtual void getKey(void** data, size_t* size) = 0; 32 | virtual std::string getKeyString(); 33 | virtual void getData(void** data, size_t* size) = 0; 34 | virtual std::string getDataString(); 35 | 36 | virtual size_t position() const = 0; 37 | 38 | }; 39 | 40 | 41 | } 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /fnordmetric-core/src/http/httpresponse.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_WEB_HTTPRESPONSE_H 11 | #define _FNORDMETRIC_WEB_HTTPRESPONSE_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnord { 18 | namespace http { 19 | class HTTPOutputStream; 20 | 21 | class HTTPResponse : public HTTPMessage { 22 | public: 23 | HTTPResponse(); 24 | 25 | void setStatus(int status_code, const std::string& status); 26 | void setStatus(const HTTPStatus& status); 27 | 28 | void writeToOutputStream(HTTPOutputStream* output); 29 | void populateFromRequest(const HTTPRequest& request); 30 | 31 | int statusCode() const { return status_code_; } 32 | 33 | protected: 34 | int status_code_; 35 | std::string status_; 36 | }; 37 | 38 | } 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /fnordmetric-core/src/net/udpserver.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_NET_UDPSERVER_H 11 | #define _FNORDMETRIC_NET_UDPSERVER_H 12 | #include 13 | #include 14 | #include 15 | 16 | namespace fnord { 17 | namespace net { 18 | 19 | class UDPServer { 20 | public: 21 | UDPServer( 22 | thread::TaskScheduler* server_scheduler, 23 | thread::TaskScheduler* callback_scheduler); 24 | 25 | ~UDPServer(); 26 | 27 | void onMessage(std::function callback); 28 | void listen(int port); 29 | 30 | protected: 31 | void messageReceived(); 32 | 33 | thread::TaskScheduler* server_scheduler_; 34 | thread::TaskScheduler* callback_scheduler_; 35 | int ssock_; 36 | std::function callback_; 37 | }; 38 | 39 | 40 | } 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/runtime/runtime.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace query { 16 | 17 | Runtime::Runtime() : 18 | compiler_(&symbol_table_), 19 | query_plan_builder_(&compiler_, backends_) {} 20 | 21 | QueryPlanBuilder* Runtime::queryPlanBuilder() { 22 | return &query_plan_builder_; 23 | } 24 | 25 | void Runtime::addBackend(std::unique_ptr backend) { 26 | backends_.emplace_back(std::move(backend)); 27 | } 28 | 29 | const std::vector>& Runtime::backends() { 30 | return backends_; 31 | } 32 | 33 | Compiler* Runtime::compiler() { 34 | return &compiler_; 35 | } 36 | 37 | Parser* Runtime::parser() { 38 | return &parser_; 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/colorpalette.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_UI_COLORPALETTE_H 11 | #define _FNORDMETRIC_UI_COLORPALETTE_H 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace ui { 16 | 17 | class ColorPalette { 18 | public: 19 | 20 | ColorPalette( 21 | const std::vector& colors = std::vector{ 22 | "color1", 23 | "color2", 24 | "color3", 25 | "color4", 26 | "color5", 27 | "color6"}) : 28 | colors_(colors), 29 | color_index_(0) {} 30 | 31 | void setNextColor(Series* series) { 32 | series->setDefaultProperty( 33 | Series::P_COLOR, 34 | colors_[color_index_++ % colors_.size()]); 35 | } 36 | 37 | protected: 38 | std::vector colors_; 39 | size_t color_index_; 40 | }; 41 | 42 | } 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/volume_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_FFS_VOLUME_IMPL_H_ 11 | #define _FNORDMETRIC_FFS_VOLUME_IMPL_H_ 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace ffs { 16 | 17 | template 18 | ObjectRef Volume::insert(const std::string& object_key) { 19 | std::lock_guard lock(live_objects_mutex_); 20 | 21 | /* FIXPAUL ensure it doesn't contain the elem */ 22 | 23 | if (live_objects_.find(object_key) != live_objects_.end()) { 24 | RAISE( 25 | kIllegalStateError, 26 | "can't insert object because it already exists and is currently " 27 | "opened"); 28 | } 29 | 30 | auto obj = new ObjectType(page_manager_); 31 | live_objects_.emplace(object_key, obj); 32 | return ObjectRef(obj); 33 | } 34 | 35 | } 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ui/domainprovider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_DOMAINPROVIDER_H 11 | #define _FNORDMETRIC_DOMAINPROVIDER_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace fnordmetric { 18 | namespace ui { 19 | 20 | class DomainProvider { 21 | public: 22 | DomainProvider(AnyDomain* domain = nullptr); 23 | ~DomainProvider(); 24 | 25 | AnyDomain* get() const; 26 | template T* getAs() const; 27 | bool empty() const; 28 | void reset(AnyDomain* domain, bool free_on_destroy = false); 29 | 30 | const std::vector getTicks() const; 31 | const std::vector> getLabels() const; 32 | 33 | protected: 34 | AnyDomain* domain_; 35 | bool free_on_destroy_; 36 | }; 37 | 38 | } 39 | } 40 | 41 | #include "domainprovider_impl.h" 42 | #endif 43 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/backends/disk/tableheaderreader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_TABLEHEADERREADER_H 11 | #define _FNORDMETRIC_METRICDB_TABLEHEADERREADER_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace fnordmetric { 19 | namespace metricdb { 20 | namespace disk_backend { 21 | 22 | class TableHeaderReader : public fnord::util::BinaryMessageReader { 23 | public: 24 | TableHeaderReader( 25 | void* data, 26 | size_t size); 27 | 28 | const std::string& metricKey() const; 29 | 30 | const uint64_t generation() const; 31 | const std::vector& parents() const; 32 | 33 | protected: 34 | std::string metric_key_; 35 | uint64_t generation_; 36 | std::vector parents_; 37 | }; 38 | 39 | } 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/metricrepository.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_METRICREPOSITORY_H_ 11 | #define _FNORDMETRIC_METRICDB_METRICREPOSITORY_H_ 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | using namespace fnord; 20 | namespace fnordmetric { 21 | namespace metricdb { 22 | 23 | class IMetricRepository { 24 | public: 25 | virtual ~IMetricRepository() {} 26 | IMetric* findMetric(const std::string& key) const; 27 | IMetric* findOrCreateMetric(const std::string& key); 28 | std::vector listMetrics() const; 29 | protected: 30 | virtual IMetric* createMetric(const std::string& key) = 0; 31 | std::unordered_map> metrics_; 32 | mutable std::mutex metrics_mutex_; 33 | }; 34 | 35 | } 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /fnordmetric-core/src/io/eventloop.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef FNORDMETRIC_EV_EVENTLOOP_H 12 | #define FNORDMETRIC_EV_EVENTLOOP_H 13 | #include 14 | 15 | namespace fnordmetric { 16 | namespace ev { 17 | 18 | class EventLoop { 19 | public: 20 | enum kInterestType { 21 | EV_READABLE = 1, 22 | EV_WRITEABLE = 2 23 | }; 24 | 25 | class CallbackInterface { 26 | public: 27 | virtual void onEvent( 28 | EventLoop* loop, 29 | int fd, 30 | kInterestType interest) = 0; 31 | }; 32 | 33 | EventLoop(); 34 | void watch(int fd, kInterestType interest, CallbackInterface* callback); 35 | void unwatch(int fd, int flags); 36 | int poll(); 37 | void loop(); 38 | 39 | protected: 40 | fd_set op_read_; 41 | fd_set op_write_; 42 | int max_fd_; 43 | CallbackInterface** callbacks_; 44 | volatile bool running_; 45 | }; 46 | 47 | } 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/metrictableref.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_METRICDB_METRICTABLEREF_H 11 | #define _FNORDMETRIC_METRICDB_METRICTABLEREF_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace fnordmetric { 19 | namespace query { 20 | class TableScan; 21 | } 22 | 23 | namespace metricdb { 24 | 25 | class MetricTableRef : public query::TableRef { 26 | public: 27 | MetricTableRef(IMetric* metric); 28 | 29 | int getColumnIndex(const std::string& name) override; 30 | std::string getColumnName(int index) override; 31 | void executeScan(query::TableScan* scan) override; 32 | std::vector columns() override; 33 | 34 | protected: 35 | IMetric* metric_; 36 | std::vector fields_; 37 | }; 38 | 39 | } 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /fnordmetric-core/src/net/eventloop.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #ifndef FNORDMETRIC_EV_EVENTLOOP_H 12 | #define FNORDMETRIC_EV_EVENTLOOP_H 13 | #include 14 | 15 | namespace fnordmetric { 16 | namespace ev { 17 | 18 | class EventLoop { 19 | public: 20 | enum kInterestType { 21 | EV_READABLE = 1, 22 | EV_WRITEABLE = 2 23 | }; 24 | 25 | class CallbackInterface { 26 | public: 27 | virtual void onEvent( 28 | EventLoop* loop, 29 | int fd, 30 | kInterestType interest) = 0; 31 | }; 32 | 33 | EventLoop(); 34 | void watch(int fd, kInterestType interest, CallbackInterface* callback); 35 | void unwatch(int fd, int flags); 36 | int poll(); 37 | void loop(); 38 | 39 | protected: 40 | fd_set op_read_; 41 | fd_set op_write_; 42 | int max_fd_; 43 | CallbackInterface** callbacks_; 44 | volatile bool running_; 45 | }; 46 | 47 | } 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/stream.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2011-2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "stream.h" 16 | 17 | namespace fnordmetric { 18 | 19 | const std::string& StreamKey::getKeyString() const { 20 | return key_str_; 21 | } 22 | 23 | Stream::Stream( 24 | const StreamKey& key, 25 | const Schema& schema, 26 | //const MetricDescription& description, 27 | std::shared_ptr stream_ref) : 28 | key_(key), 29 | schema_(schema), 30 | //description_(description), 31 | stream_ref_(std::move(stream_ref)) {} 32 | 33 | const Schema& Stream::getSchema() const { 34 | return schema_; 35 | } 36 | 37 | const StreamKey& Stream::getKey() const { 38 | return key_; 39 | } 40 | 41 | void Stream::appendRecord(const RecordWriter& record) const { 42 | stream_ref_->appendRow(record); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /fnordmetric-core/src/metricdb/metrictablerepository.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #include 11 | #include 12 | #include 13 | 14 | namespace fnordmetric { 15 | namespace metricdb { 16 | 17 | MetricTableRepository::MetricTableRepository( 18 | IMetricRepository* metric_repo) : 19 | metric_repo_(metric_repo) {} 20 | 21 | query::TableRef* MetricTableRepository::getTableRef( 22 | const std::string& table_name) const { 23 | auto metric = metric_repo_->findMetric(table_name); 24 | 25 | if (metric == nullptr) { 26 | auto tbl_ref = query::TableRepository::getTableRef(table_name); 27 | 28 | if (tbl_ref == nullptr) { 29 | RAISE(kRuntimeError, "unknown table"); 30 | } 31 | 32 | return tbl_ref; 33 | } 34 | 35 | return new MetricTableRef(metric); 36 | } 37 | 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /fnordmetric-core/src/ffs/btree.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordStream" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * Licensed under the MIT license (see LICENSE). 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "btree.h" 13 | 14 | namespace fnordmetric { 15 | 16 | BTree::BTree(uint16_t branch_factor) : 17 | branch_factor_(branch_factor), 18 | root_is_leaf_(true) { 19 | root_ = allocNode(getLeafNodeSize()); 20 | } 21 | 22 | void BTree::insert(uint64_t key) { 23 | if (root_is_leaf_) { 24 | if (root_->used < branch_factor_) { 25 | return insertIntoNode(root_, key); 26 | } else { 27 | /* split root node */ 28 | assert(0); 29 | } 30 | } 31 | } 32 | 33 | BTree::LeafNodeEntry* BTree::lookup(uint64_t key) const { 34 | if (root_is_leaf_) { 35 | return (LeafNodeEntry*) root_->leaf; 36 | } 37 | } 38 | 39 | BTree::Node* BTree::allocNode(size_t size) { 40 | Node* node = (Node *) malloc(size); // FIXPAUL 41 | memset(node, 0, size); 42 | return node; 43 | } 44 | 45 | void BTree::insertIntoNode(Node* leaf_node, uint64_t key) { 46 | auto slot = leaf_node->leaf + leaf_node->used; 47 | slot->key = key; 48 | leaf_node->used++; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/backends/mysql/mysqlbackend.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the "FnordMetric" project 3 | * Copyright (c) 2014 Paul Asmuth, Google Inc. 4 | * 5 | * FnordMetric is free software: you can redistribute it and/or modify it under 6 | * the terms of the GNU General Public License v3.0. You should have received a 7 | * copy of the GNU General Public License along with this program. If not, see 8 | * . 9 | */ 10 | #ifndef _FNORDMETRIC_MYSQLBACKEND_H 11 | #define _FNORDMETRIC_MYSQLBACKEND_H 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace fnordmetric { 19 | namespace query { 20 | namespace mysql_backend { 21 | 22 | class MySQLBackend : public fnordmetric::query::Backend { 23 | public: 24 | 25 | static MySQLBackend* singleton(); 26 | 27 | MySQLBackend(); 28 | 29 | bool openTables( 30 | const std::vector& table_names, 31 | const util::URI& source_uri, 32 | std::vector>* target) override; 33 | 34 | protected: 35 | std::vector> connections_; 36 | std::mutex connections_mutex_; 37 | }; 38 | 39 | } 40 | } 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /fnordmetric-core/src/sql/bnf.txt: -------------------------------------------------------------------------------- 1 | ::= 2 | ::= 6 | SELECT 7 | ::= 16 | 17 | | }... ] 18 | 19 |