The key change is to revamp how we parse/store/match a log event, especially how we match repeated field and attribution nodes, and how we construct dimensions and compare them. + We use a integer to encode the field of a log element. And also encode the FieldMatcher into an integer and a bit mask. The log matching becomes 2 integer operations. + Dimension is stored as encoded field and value pair. Checking if 2 dimensions are equal is then becoming checking if the underlying integers are equal. The integers are stored contiguously in memory, so it's much faster than previous tree structure. Start review from FieldValue.h Test: statsd_test + new unit tests Bug: 72659059 Change-Id: Iec8daeacdd3f39ab297c10ab9cd7b710a9c42e86
46 lines
1.7 KiB
C++
46 lines
1.7 KiB
C++
/*
|
|
* Copyright (C) 2017 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
#include "ConditionWizard.h"
|
|
#include <unordered_set>
|
|
|
|
namespace android {
|
|
namespace os {
|
|
namespace statsd {
|
|
|
|
using std::map;
|
|
using std::string;
|
|
using std::vector;
|
|
|
|
ConditionState ConditionWizard::query(const int index, const ConditionKey& parameters,
|
|
const vector<Matcher>& dimensionFields,
|
|
std::unordered_set<HashableDimensionKey>* dimensionKeySet) {
|
|
vector<ConditionState> cache(mAllConditions.size(), ConditionState::kNotEvaluated);
|
|
|
|
mAllConditions[index]->isConditionMet(
|
|
parameters, mAllConditions, dimensionFields, cache, *dimensionKeySet);
|
|
return cache[index];
|
|
}
|
|
|
|
ConditionState ConditionWizard::getMetConditionDimension(
|
|
const int index, const vector<Matcher>& dimensionFields,
|
|
std::unordered_set<HashableDimensionKey>* dimensionsKeySet) const {
|
|
return mAllConditions[index]->getMetConditionDimension(mAllConditions, dimensionFields,
|
|
*dimensionsKeySet);
|
|
}
|
|
|
|
} // namespace statsd
|
|
} // namespace os
|
|
} // namespace android
|