Skip to content

taehyounpark/queryosity

Repository files navigation

Queryosity

Version C++ Standard Ubuntu macOS MIT License

Queryosity is a row-wise data analysis library for (semi-)structured data.

  • Dataflow interface.
  • Arbitrary data types.
  • Lazy, multithreaded actions.
  • Sensitivity analysis.

Documentation

Hello World

#include <fstream>
#include <sstream>
#include <vector>

#include <queryosity.hpp>
#include <queryosity/boost/histogram.hpp>
#include <queryosity/nlohmann/json.hpp>

using dataflow = qty::dataflow;
namespace multithread = qty::multithread;
namespace dataset = qty::dataset;
namespace column = qty::column;
namespace query = qty::query;

using json = qty::nlohmann::json;
using h1d = qty::boost::histogram::histogram<double>;
using linax = qty::boost::histogram::axis::regular;

int main() {
  dataflow df(multithread::enable(10));

  std::ifstream data("data.json");
  auto [x, w] = df.read(
      dataset::input<json>(data), dataset::column<std::vector<double>>("x"), dataset::column<double>("w"));

  auto zero = df.define(column::constant(0));
  auto x0 = x[zero];

  auto sel =
      df.weight(w)
          .filter(column::expression(
              [](std::vector<double> const &v) { return v.size(); }))(x);

  auto h_x0_w = df.get(query::output<h1d>(linax(20, 0.0, 200.0)))
                    .fill(x0)
                    .at(sel)
                    .result();

  std::ostringstream os;
  os << *h_x0_w;
  std::cout << os.str() << std::endl;
}

Installation

#include <queryosity.hpp>

CMake

git clone https://github.com/taehyounpark/queryosity.git

External

cd queryosity/ && mkdir build/ && cd build/
cmake -DQUERYOSITY_INSTALL=ON ../
cmake --build .
cmake --install .
find_package(queryosity 0.5.0 REQUIRED)
...
add_library(Analysis ...)
...
target_link_libraries(Analysis INTERFACE queryosity::queryosity)
#include <queryosity.hpp>

Integrated

add_subdirectory(queryosity)
...
add_library(Analysis ...)
...
target_link_libraries(Analysis INTERFACE queryosity::queryosity)