Newer
Older
nkindlon
committed
/*
* KeyListOps.h
*
* Created on: Feb 24, 2014
* Author: nek3d
*/
#ifndef KEYLISTOPS_H_
#define KEYLISTOPS_H_
#include "KeyListOpsMethods.h"
nkindlon
committed
class FileRecordMgr;
//print help message
void KeyListOpsHelp();
nkindlon
committed
class KeyListOps {
public:
KeyListOps();
void setColumns(const QuickString &columns) { _columns = columns; }
void addColumns(const QuickString &newCols) {
if (!_columns.empty()) _columns += ",";
_columns += newCols;
}
nkindlon
committed
void setOperations(const QuickString & operation) { _operations = operation; }
void addOperations(const QuickString &newOps) {
if (!_operations.empty()) _operations += ",";
_operations += newOps;
}
nkindlon
committed
void setNullValue(const QuickString & nullValue) { _methods.setNullValue(nullValue); }
void setDelimStr(const QuickString & delimStr) { _methods.setDelimStr(delimStr); }
const QuickString &getColumns() { return _columns; }
const QuickString &getOperations() { return _operations; }
const QuickString &getNullValue() { return _methods.getNullValue(); }
const QuickString &getDelimStr() { return _methods.getDelimStr(); }
void setKeyList(RecordKeyVector *keyList) { _methods.setKeyList(keyList); }
nkindlon
committed
typedef enum { SUM, MEAN, STDDEV, SAMPLE_STDDEV, MEDIAN, MODE, ANTIMODE, MIN, MAX, ABSMIN, ABSMAX, COUNT, DISTINCT, COUNT_DISTINCT,
DISTINCT_ONLY, COLLAPSE, CONCAT, FREQ_ASC, FREQ_DESC, FIRST, LAST, INVALID } OP_TYPES;
void setDBfileType(FileRecordTypeChecker::FILE_TYPE type) { _dbFileType = type; }
nkindlon
committed
bool isValidColumnOps(FileRecordMgr *dbFile);
const QuickString &getOpVals(RecordKeyVector &hits);
Neil Kindlon
committed
void setPrecision(int val) { _precision = val; }
nkindlon
committed
private:
void init();
FileRecordTypeChecker::FILE_TYPE _dbFileType;
nkindlon
committed
QuickString _operations;
QuickString _columns;
KeyListOpsMethods _methods;
map<QuickString, OP_TYPES> _opCodes;
map<OP_TYPES, bool> _isNumericOp;
typedef vector<pair<int, OP_TYPES> > colOpsType;
colOpsType _colOps;
QuickString _outVals;
Neil Kindlon
committed
QuickString _formatStr;
int _precision;
static const int DEFAULT_PRECISION = 10;
nkindlon
committed
OP_TYPES getOpCode(const QuickString &operation) const;
bool isNumericOp(OP_TYPES op) const;
bool isNumericOp(const QuickString &op) const;
Neil Kindlon
committed
const QuickString &format(double val);