Skip to content

Commit

Permalink
col -> series, formatting + organization
Browse files Browse the repository at this point in the history
  • Loading branch information
taehyounpark committed Mar 30, 2024
1 parent 097cec3 commit 8af03b6
Show file tree
Hide file tree
Showing 15 changed files with 400 additions and 266 deletions.
12 changes: 4 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ target_compile_options(
$<$<CONFIG:Debug>:-O0> $<$<CONFIG:Debug>:-ggdb3>
)

find_package(Threads REQUIRED)
target_link_libraries(queryosity INTERFACE Threads::Threads)

if (QUERYOSITY_INSTALL)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
Expand Down Expand Up @@ -88,14 +91,7 @@ if (QUERYOSITY_INSTALL)

endif()

if (QUERYOSITY_TESTS OR QUERYOSITY_EXAMPLES)

# boost
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})


if (QUERYOSITY_EXTENSIONS OR QUERYOSITY_TESTS OR QUERYOSITY_EXAMPLES)
add_subdirectory("extensions")
endif()

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace query = qty::query;

using json = qty::json;
using h1d = qty::hist::hist<double>;
using linax = qty::hist::axis::linear;
using linax = qty::hist::axis::regular;

int main() {

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace query = qty::query;

using json = qty::json;
using h1d = qty::hist::hist<double>;
using linax = qty::hist::axis::linear;
using linax = qty::hist::axis::regular;

int main() {

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Subsequently, the plan can be filled with input columns and booked at a selectio
@cpp
using h1d = qty::hist::hist<double>;
using h2d = qty::hist::hist<double,double>;
using linax = qty::hist::axis::linear;
using linax = qty::hist::axis::regular;

// instantiate a 1d histogram query filled with x over all entries
auto q = df.make(query::plan<h1d>(linax(100,0.0,1.0))).fill(x).book(inclusive);
Expand Down
8 changes: 8 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if (QUERYOSITY_EXAMPLES)

add_executable(example-hello_world ./example-hello_world.cxx)
target_compile_features(example-hello_world PUBLIC cxx_std_17)
target_link_libraries(example-hello_world queryosity::extensions pthread ${Boost_LIBRARIES})
add_test(NAME example-hello_world COMMAND example-hello_world)

endif()
47 changes: 47 additions & 0 deletions examples/example-hello_world.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "queryosity/json.h"
#include "queryosity/hist.h"

#include "queryosity.h"

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

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

using json = qty::json;
using h1d = qty::hist::hist<double>;
using linax = qty::hist::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_nom"),
dataset::column<double>("w_nom"));

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.make(
query::plan<h1d>(linax(100, 0.0, 1.0)))
.fill(x0)
.book(sel)
.result();

// std::ostringstream os; os << *h_x0_w;
// std::cout << os.str() << std::endl;
}
6 changes: 5 additions & 1 deletion extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ target_compile_options(
$<$<CONFIG:Debug>:-O0> $<$<CONFIG:Debug>:-ggdb3>
)

# boost::histogram
find_package(Boost REQUIRED)

# nlohmann::json
include(FetchContent)
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
FetchContent_MakeAvailable(json)
Expand All @@ -26,7 +30,7 @@ FetchContent_MakeAvailable(csv)

target_include_directories(
queryosity_extensions
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${Boost_INCLUDE_DIRS}
)
include(ExternalProject)

Expand Down
45 changes: 0 additions & 45 deletions extensions/queryosity/col.h

This file was deleted.

1 change: 1 addition & 0 deletions include/queryosity.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "queryosity/query_aggregation.h"
#include "queryosity/query_definition.h"
#include "queryosity/query_series.h"

#include "queryosity/dataflow.h"

Expand Down
35 changes: 20 additions & 15 deletions include/queryosity/dataflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ class dataflow {
* @return Varied lazy column.
*/
template <typename Fn, typename... Cols>
auto define(column::expression<Fn> const &expr, Cols const &...cols)
-> typename lazy<column::equation_t<Fn>>::varied;
auto define(column::expression<Fn> const &expr, Cols const &...cols) ->
typename lazy<column::equation_t<Fn>>::varied;

/**
* @brief Define a custom column.
Expand All @@ -158,8 +158,8 @@ class dataflow {
* @return Varied lazy column.
*/
template <typename Def, typename... Cols>
auto define(column::definition<Def> const &defn, Cols const &...cols)
-> typename lazy<Def>::varied;
auto define(column::definition<Def> const &defn, Cols const &...cols) ->
typename lazy<Def>::varied;

/**
* @brief Initiate a cutflow.
Expand Down Expand Up @@ -245,10 +245,14 @@ class dataflow {
-> lazy<column::conversion<To, column::value_t<Col>>>;

template <typename Def, typename... Args> auto _define(Args &&...args);
template <typename Def> auto _define(column::definition<Def> const &defn) -> todo<column::evaluator<Def>>;
template <typename Def>
auto _define(column::definition<Def> const &defn)
-> todo<column::evaluator<Def>>;

template <typename Fn> auto _equate(Fn fn);
template <typename Fn> auto _equate(column::expression<Fn> const &expr) -> todo<column::evaluator<column::equation_t<Fn>>> ;
template <typename Fn>
auto _equate(column::expression<Fn> const &expr)
-> todo<column::evaluator<column::equation_t<Fn>>>;

template <typename Sel, typename Col>
auto _select(lazy<Col> const &col) -> lazy<selection::node>;
Expand Down Expand Up @@ -416,8 +420,8 @@ auto queryosity::dataflow::define(

template <typename Def, typename... Cols>
auto queryosity::dataflow::define(
queryosity::column::definition<Def> const &defn, Cols const &...cols)
-> typename lazy<Def>::varied {
queryosity::column::definition<Def> const &defn, Cols const &...cols) ->
typename lazy<Def>::varied {
return this->_define(defn).template evaluate(cols...);
}

Expand All @@ -430,8 +434,8 @@ auto queryosity::dataflow::define(

template <typename Fn, typename... Cols>
auto queryosity::dataflow::define(
queryosity::column::expression<Fn> const &expr, Cols const &...cols)
-> typename lazy<column::equation_t<Fn>>::varied {
queryosity::column::expression<Fn> const &expr, Cols const &...cols) ->
typename lazy<column::equation_t<Fn>>::varied {
return this->_equate(expr).template evaluate(cols...);
}

Expand Down Expand Up @@ -609,13 +613,13 @@ auto queryosity::dataflow::_define(Args &&...args) {

template <typename Def>
auto queryosity::dataflow::_define(
queryosity::column::definition<Def> const &defn) -> todo<column::evaluator<Def>> {
queryosity::column::definition<Def> const &defn)
-> todo<column::evaluator<Def>> {
return defn._define(*this);
}

template <typename Fn> auto queryosity::dataflow::_equate(Fn fn){
return todo<column::evaluator<
typename column::equation_t<Fn>>>(
template <typename Fn> auto queryosity::dataflow::_equate(Fn fn) {
return todo<column::evaluator<typename column::equation_t<Fn>>>(
*this,
ensemble::invoke(
[fn](dataset::player *plyr) { return plyr->template equate(fn); },
Expand All @@ -624,7 +628,8 @@ template <typename Fn> auto queryosity::dataflow::_equate(Fn fn){

template <typename Fn>
auto queryosity::dataflow::_equate(
queryosity::column::expression<Fn> const &expr) -> todo<column::evaluator<column::equation_t<Fn>>> {
queryosity::column::expression<Fn> const &expr)
-> todo<column::evaluator<column::equation_t<Fn>>> {
return expr._equate(*this);
}

Expand Down
Loading

0 comments on commit 8af03b6

Please sign in to comment.