Commit c0ccfe4f authored by Paul Asmuth's avatar Paul Asmuth
Browse files

GroupOverTimewindow stub

parent 2a3e1692
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ set(FNORDMETRIC_SOURCES
    stage/src/fnordmetric/sql/runtime/compile.cc
    stage/src/fnordmetric/sql/runtime/defaultruntime.cc
    stage/src/fnordmetric/sql/runtime/execute.cc
    stage/src/fnordmetric/sql/runtime/groupovertimewindow.cc
    stage/src/fnordmetric/sql/runtime/orderby.cc
    stage/src/fnordmetric/sql/runtime/importstatement.cc
    stage/src/fnordmetric/sql/runtime/queryplan.cc
+3 −4
Original line number Diff line number Diff line
/**
 * This file is part of the "FnordMetric" project
 *   Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
 *   Copyright (c) 2014 Paul Asmuth, Google Inc.
 *
 * FnordMetric is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */

#ifndef _FNORDMETRIC_QUERY_GROUPBY_H
#define _FNORDMETRIC_QUERY_GROUPBY_H
#ifndef _FNORDMETRIC_SQL_GROUPBY_H
#define _FNORDMETRIC_SQL_GROUPBY_H
#include <stdlib.h>
#include <string>
#include <string.h>
+54 −0
Original line number Diff line number Diff line
/**
 * This file is part of the "FnordMetric" project
 *   Copyright (c) 2014 Paul Asmuth, Google Inc.
 *
 * FnordMetric is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#include <fnordmetric/sql/runtime/groupovertimewindow.h>

namespace fnordmetric {
namespace query {

GroupOverTimewindow::GroupOverTimewindow(
    std::vector<std::string>&& columns,
    CompiledExpression* time_expr,
    fnordmetric::IntegerType window,
    fnordmetric::IntegerType step,
    CompiledExpression* select_expr,
    CompiledExpression* group_expr,
    size_t scratchpad_size,
    QueryPlanNode* child) :
    time_expr_(time_expr),
    window_(window),
    step_(step),
    columns_(std::move(columns)),
    select_expr_(select_expr),
    group_expr_(group_expr),
    scratchpad_size_(scratchpad_size),
    child_(child) {
  printf("new group over clause with %i, %i\n", window, step);
  child->setTarget(this);
}

void GroupOverTimewindow::execute() {
  RAISE(kNotYetImplementedError, "NYI");
}

bool GroupOverTimewindow::nextRow(SValue* row, int row_len) {
  RAISE(kNotYetImplementedError, "NYI");
}

size_t GroupOverTimewindow::getNumCols() const {
  return columns_.size();
}

const std::vector<std::string>& GroupOverTimewindow::getColumns() const {
  return columns_;
}

}
}
+65 −0
Original line number Diff line number Diff line
/**
 * This file is part of the "FnordMetric" project
 *   Copyright (c) 2014 Paul Asmuth, Google Inc.
 *
 * FnordMetric is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#ifndef _FNORDMETRIC_SQL_GROUPOVERTIMEWINDOW_H
#define _FNORDMETRIC_SQL_GROUPOVERTIMEWINDOW_H
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <assert.h>
#include <fnordmetric/sql/parser/astnode.h>
#include <fnordmetric/sql/parser/token.h>
#include <fnordmetric/sql/runtime/queryplannode.h>
#include <fnordmetric/sql/runtime/symboltable.h>
#include <fnordmetric/sql/runtime/compile.h>

namespace fnordmetric {
namespace query {

class GroupOverTimewindow : public QueryPlanNode {
public:

  GroupOverTimewindow(
      std::vector<std::string>&& columns,
      CompiledExpression* time_expr,
      fnordmetric::IntegerType window,
      fnordmetric::IntegerType step,
      CompiledExpression* select_expr,
      CompiledExpression* group_expr,
      size_t scratchpad_size,
      QueryPlanNode* child);

  void execute() override;
  bool nextRow(SValue* row, int row_len) override;

  size_t getNumCols() const override;
  const std::vector<std::string>& getColumns() const override;

protected:

  struct Group {
    std::vector<SValue> row;
    void* scratchpad;
  };

  std::vector<std::string> columns_;
  CompiledExpression* time_expr_;
  fnordmetric::IntegerType window_;
  fnordmetric::IntegerType step_;
  CompiledExpression* select_expr_;
  CompiledExpression* group_expr_;
  size_t scratchpad_size_;
  QueryPlanNode* child_;
  std::unordered_map<std::string, Group> groups_;
};

}
}
#endif
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <fnordmetric/sql/runtime/limitclause.h>
#include <fnordmetric/sql/runtime/orderby.h>
#include <fnordmetric/sql/runtime/groupby.h>
#include <fnordmetric/sql/runtime/groupovertimewindow.h>
#include <fnordmetric/sql/runtime/runtime.h>
#include <fnordmetric/sql/runtime/symboltable.h>
#include <fnordmetric/sql/runtime/importstatement.h>