Unified · Split
| @@ -123,8 +123,8 @@ void DataRow::SetStringValue(int32_t index, const Nullable<string>& value) · 122 unmodified lines | ||
| 123 | 123 | if (value.HasValue()) |
| 124 | 124 | { |
| 125 | 125 | const string& strval = value.GetValueOrDefault(); |
| 126 | − const int32_t length = strval.size(); | |
| 127 | − char* copy = static_cast<char*>(malloc(length + 1)); | |
| 126 | + const int32_t length = strval.size() + 1; | |
| 127 | + char* copy = static_cast<char*>(malloc(length * sizeof(char))); | |
| 128 | 128 | strcpy_s(copy, length, strval.c_str()); |
| 129 | 129 | m_values[index] = copy; |
| 130 | 130 | } |
| @@ -213,8 +213,8 @@ void DataRow::SetDecimalValue(int32_t index, const Nullable<decimal_t>& value) · 82 unmodified lines | ||
| 213 | 213 | // The boost decimal type has a very complex internal representation, |
| 214 | 214 | // although slower, it's safer just to store this as a string for now |
| 215 | 215 | const string& strval = value.GetValueOrDefault().str(); |
| 216 | − const int32_t length = strval.size(); | |
| 217 | − char* copy = static_cast<char*>(malloc(length + 1)); | |
| 216 | + const int32_t length = strval.size() + 1; | |
| 217 | + char* copy = static_cast<char*>(malloc(length * sizeof(char))); | |
| 218 | 218 | strcpy_s(copy, length, strval.c_str()); |
| 219 | 219 | m_values[index] = copy; |
| 220 | 220 | } |
| @@ -55,10 +55,10 @@ void DataSet::IterateTables(TableIteratorHandlerFunction iteratorHandler, void* · 54 unmodified lines | ||
| 55 | 55 | iteratorHandler(item.second, userData); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | −bool DataSet::AddOrUpdateTable(const DataTablePtr& table) | |
| 58 | +bool DataSet::AddOrUpdateTable(DataTablePtr table) | |
| 59 | 59 | { |
| 60 | 60 | // Returns true on insert, false on update |
| 61 | − return m_tables.insert_or_assign(table->Name(), table).second; | |
| 61 | + return m_tables.insert_or_assign(table->Name(), std::move(table)).second; | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | bool DataSet::RemoveTable(const std::string& tableName) |
| @@ -50,7 +50,7 @@ public: · 49 unmodified lines | ||
| 50 | 50 | |
| 51 | 51 | void IterateTables(TableIteratorHandlerFunction iteratorHandler, void* userData); |
| 52 | 52 | |
| 53 | − bool AddOrUpdateTable(const DataTablePtr& table); | |
| 53 | + bool AddOrUpdateTable(DataTablePtr table); | |
| 54 | 54 | |
| 55 | 55 | bool RemoveTable(const std::string& tableName); |
| 56 | 56 | }; |
| @@ -2248,12 +2248,17 @@ ValueExpressionPtr ExpressionTree::EvaluateRegEx(const string& functionName, con · 2247 unmodified lines | ||
| 2248 | 2248 | return result ? ExpressionTree::True : ExpressionTree::False; |
| 2249 | 2249 | } |
| 2250 | 2250 | |
| 2251 | −ExpressionTree::ExpressionTree(const DataTablePtr& measurements) : | |
| 2252 | − Measurements(measurements), | |
| 2251 | +ExpressionTree::ExpressionTree(DataTablePtr measurements) : | |
| 2252 | + m_measurements(std::move(measurements)), | |
| 2253 | 2253 | TopLimit(-1) |
| 2254 | 2254 | { |
| 2255 | 2255 | } |
| 2256 | 2256 | |
| 2257 | +const DataTablePtr& ExpressionTree::Measurements() const | |
| 2258 | +{ | |
| 2259 | + return m_measurements; | |
| 2260 | +} | |
| 2261 | + | |
| 2257 | 2262 | ValueExpressionPtr ExpressionTree::Evaluate(const DataRowPtr& row) |
| 2258 | 2263 | { |
| 2259 | 2264 | m_currentRow = row; |
| @@ -244,6 +244,7 @@ class ExpressionTree · 243 unmodified lines | ||
| 244 | 244 | { |
| 245 | 245 | private: |
| 246 | 246 | Data::DataRowPtr m_currentRow; |
| 247 | + Data::DataTablePtr m_measurements; | |
| 247 | 248 | |
| 248 | 249 | ValueExpressionPtr Evaluate(const ExpressionPtr& expression, ExpressionValueType targetValueType = ExpressionValueType::Boolean) const; |
| 249 | 250 | ValueExpressionPtr EvaluateUnary(const ExpressionPtr& expression) const; |
| @@ -346,9 +347,9 @@ private: · 96 unmodified lines | ||
| 346 | 347 | ValueExpressionPtr Convert(const ValueExpressionPtr& sourceValue, ExpressionValueType targetValueType) const; |
| 347 | 348 | ValueExpressionPtr EvaluateRegEx(const std::string& functionName, const ValueExpressionPtr& regexValue, const ValueExpressionPtr& testValue, bool returnMatchedValue) const; |
| 348 | 349 | public: |
| 349 | − ExpressionTree(const Data::DataTablePtr& measurements); | |
| 350 | + ExpressionTree(Data::DataTablePtr measurements); | |
| 350 | 351 | |
| 351 | − const Data::DataTablePtr& Measurements; | |
| 352 | + const Data::DataTablePtr& Measurements() const; | |
| 352 | 353 | int32_t TopLimit; |
| 353 | 354 | std::vector<std::pair<Data::DataColumnPtr, bool>> OrderByTerms; |
| 354 | 355 | |
| @@ -214,7 +214,7 @@ void FilterExpressionParser::Evaluate() · 213 unmodified lines | ||
| 214 | 214 | for (size_t x = 0; x < m_expressionTrees.size(); x++) |
| 215 | 215 | { |
| 216 | 216 | const ExpressionTreePtr& expressionTree = m_expressionTrees[x]; |
| 217 | − const DataTablePtr& measurements = expressionTree->Measurements; | |
| 217 | + const DataTablePtr& measurements = expressionTree->Measurements(); | |
| 218 | 218 | const MeasurementTableIDFieldsPtr& measurementTableIDFields = GetMeasurementTableIDFields(measurements->Name()); |
| 219 | 219 | |
| 220 | 220 | if (measurementTableIDFields == nullptr) |
| @@ -821,10 +821,10 @@ void FilterExpressionParser::exitLiteralValue(FilterExpressionSyntaxParser::Lite · 600 unmodified lines | ||
| 821 | 821 | void FilterExpressionParser::exitColumnName(FilterExpressionSyntaxParser::ColumnNameContext* context) |
| 822 | 822 | { |
| 823 | 823 | const string& columnName = context->IDENTIFIER()->getText(); |
| 824 | − const DataColumnPtr& dataColumn = m_activeExpressionTree->Measurements->Column(columnName); | |
| 824 | + const DataColumnPtr& dataColumn = m_activeExpressionTree->Measurements()->Column(columnName); | |
| 825 | 825 | |
| 826 | 826 | if (dataColumn == nullptr) |
| 827 | − throw FilterExpressionException("Failed to find column \"" + columnName + "\" in table \"" + m_activeExpressionTree->Measurements->Name() + "\""); | |
| 827 | + throw FilterExpressionException("Failed to find column \"" + columnName + "\" in table \"" + m_activeExpressionTree->Measurements()->Name() + "\""); | |
| 828 | 828 | |
| 829 | 829 | AddExpr(context, NewSharedPtr<ColumnExpression>(dataColumn)); |
| 830 | 830 | } |