Skip to content

Commit

Permalink
Eng 11366 windowed count (#4099)
Browse files Browse the repository at this point in the history
Implement count(*) and count(EXPR) window functions.

https://issues.voltdb.com/browse/ENG-11366
  • Loading branch information
Bill White committed Dec 8, 2016
1 parent 8f12ce5 commit f45aa90
Show file tree
Hide file tree
Showing 29 changed files with 1,863 additions and 442 deletions.
3 changes: 2 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@
OptimizedProjectorTest
MergeReceiveExecutorTest
TestGeneratedPlans
TestRank
TestWindowedRank
TestWindowedCount
"""

if whichtests in ("${eetestsuite}", "expressions"):
Expand Down
22 changes: 22 additions & 0 deletions src/ee/common/TupleSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <cstdio>
#include "common/TupleSchema.h"
#include "common/NValue.hpp"
#include "expressions/abstractexpression.h"
#include "plannodes/abstractplannode.h"

namespace voltdb {

Expand Down Expand Up @@ -229,6 +231,26 @@ TupleSchema::createTupleSchema(const TupleSchema *first,
return schema;
}

TupleSchema* TupleSchema::createTupleSchema(
const std::vector<AbstractExpression *> &exprs) {
std::vector<ValueType> columnTypes;
std::vector<int32_t> columnSizes;
std::vector<bool> columnAllowNull;
std::vector<bool> columnInBytes;

for (auto b = exprs.begin(), e = exprs.end(); b != e; b++) {
const AbstractExpression *expr = *b;
columnTypes.push_back(expr->getValueType());
columnSizes.push_back(expr->getValueSize());
columnAllowNull.push_back(true);
columnInBytes.push_back(expr->getInBytes());
}
return TupleSchema::createTupleSchema(columnTypes,
columnSizes,
columnAllowNull,
columnInBytes);
}

void TupleSchema::freeTupleSchema(TupleSchema *schema) {
delete[] reinterpret_cast<char*>(schema);
}
Expand Down
3 changes: 3 additions & 0 deletions src/ee/common/TupleSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

namespace voltdb {

class AbstractExpression;
/**
* Represents the schema of a tuple or table row. Used to define table rows, as
* well as index keys. Note: due to arbitrary size embedded array data, this class
Expand Down Expand Up @@ -86,6 +87,8 @@ class TupleSchema {
const std::vector<int32_t> columnSizes,
const std::vector<bool> allowNull);

static TupleSchema* createTupleSchema(const std::vector<AbstractExpression *> &exprs);

/** Static factory method fakes a copy constructor (will also
* duplicate hidden columns) */
static TupleSchema* createTupleSchema(const TupleSchema *schema);
Expand Down
5 changes: 5 additions & 0 deletions src/ee/common/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ string expressionToString(ExpressionType type)
case EXPRESSION_TYPE_AGGREGATE_WINDOWED_DENSE_RANK: {
return "EXPRESSION_TYPE_AGGREGATE_WINDOWED_RANK";
}
case EXPRESSION_TYPE_AGGREGATE_WINDOWED_COUNT: {
return "EXPRESSION_TYPE_AGGREGATE_WINDOWED_COUNT";
}
case EXPRESSION_TYPE_AGGREGATE_SUM: {
return "AGGREGATE_SUM";
}
Expand Down Expand Up @@ -732,6 +735,8 @@ ExpressionType stringToExpression(string str )
return EXPRESSION_TYPE_AGGREGATE_WINDOWED_RANK;
} else if (str == "AGGREGATE_WINDOWED_DENSE_RANK") {
return EXPRESSION_TYPE_AGGREGATE_WINDOWED_DENSE_RANK;
} else if (str == "AGGREGATE_WINDOWED_COUNT") {
return EXPRESSION_TYPE_AGGREGATE_WINDOWED_COUNT;
} else if (str == "AGGREGATE_SUM") {
return EXPRESSION_TYPE_AGGREGATE_SUM;
} else if (str == "AGGREGATE_MIN") {
Expand Down
1 change: 1 addition & 0 deletions src/ee/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ enum ExpressionType {
// -----------------------------
EXPRESSION_TYPE_AGGREGATE_WINDOWED_RANK = 70,
EXPRESSION_TYPE_AGGREGATE_WINDOWED_DENSE_RANK = 71,
EXPRESSION_TYPE_AGGREGATE_WINDOWED_COUNT = 72,
// -----------------------------
// Functions
// -----------------------------
Expand Down
Loading

0 comments on commit f45aa90

Please sign in to comment.