forked from milvus-io/milvus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MrPresent-Han
committed
Nov 11, 2024
1 parent
64e961b
commit 8c41b0f
Showing
14 changed files
with
270 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the LF AI & Data foundation under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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. | ||
#pragma once | ||
|
||
namespace milvus { | ||
namespace exec { | ||
// The result of aggregation function registration. | ||
struct AggregateRegistrationResult { | ||
bool mainFunction{false}; | ||
bool partialFunction{false}; | ||
bool mergeFunction{false}; | ||
bool extractFunction{false}; | ||
bool mergeExtractFunction{false}; | ||
|
||
bool operator==(const AggregateRegistrationResult& other) const { | ||
return mainFunction == other.mainFunction && | ||
partialFunction == other.partialFunction && | ||
mergeFunction == other.mergeFunction && | ||
extractFunction == other.extractFunction && | ||
mergeExtractFunction == other.mergeExtractFunction; | ||
} | ||
}; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
internal/core/src/exec/operator/query-agg/RegisterAggregateFunctions.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Licensed to the LF AI & Data foundation under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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 "RegisterAggregateFunctions.h" | ||
|
||
namespace milvus { | ||
namespace exec { | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
internal/core/src/exec/operator/query-agg/RegisterAggregateFunctions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the LF AI & Data foundation under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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. | ||
|
||
#pragma once | ||
#include <memory> | ||
#include <string> | ||
|
||
namespace milvus{ | ||
namespace exec { | ||
void registerAllFunctions(const std::string& prefix = "", | ||
bool withCompanionFunctions = true, | ||
bool overwrite = true); | ||
|
||
|
||
extern void registerSumAggregate(const std::string& prefix, | ||
bool withCompanionFunctions, | ||
bool overwrite); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
internal/core/src/exec/operator/query-agg/SimpleNumericAggregate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (C) 2019-2020 Zilliz. All rights reserved. | ||
// | ||
// 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 | ||
#pragma once | ||
|
||
#include "Aggregate.h" | ||
namespace milvus{ | ||
namespace exec { | ||
template <typename TInput, typename TAccumulator, typename TResult> | ||
class SimpleNumericAggregate : public exec::Aggregate { | ||
protected: | ||
explicit SimpleNumericAggregate(DataType resultType) : Aggregate(resultType){} | ||
|
||
// TData is either TAccumulator or TResult, which in most cases are the same, | ||
// but for sum(real) can differ. | ||
template <typename TData = TResult, typename ExtractOneValue> | ||
void doExtractValues( | ||
char** groups, | ||
int32_t numGroups, | ||
VectorPtr* result, | ||
ExtractOneValue extractOneValue) { | ||
AssertInfo((*result)->elementSize()==sizeof(TData), "Incorrect type size of input result vector"); | ||
ColumnVectorPtr result_column = std::dynamic_pointer_cast<ColumnVector>(*result); | ||
AssertInfo(result_column != nullptr, "input vector for extracting aggregation must be of Type ColumnVector"); | ||
result_column->resize(numGroups); | ||
TData* rawValues = static_cast<TData*>(result_column->GetRawData()); | ||
for(auto i = 0; i < numGroups; i++) { | ||
char* group = groups[i]; | ||
if (isNull(group)) { | ||
result_column->nullAt(i); | ||
} else { | ||
result_column->clearNullAt(i); | ||
rawValues[i] = extractOneValue(group); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
internal/core/src/exec/operator/query-agg/SumAggregate.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Licensed to the LF AI & Data foundation under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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 "SumAggregateBase.h" | ||
#include "RegisterAggregateFunctions.h" | ||
|
||
namespace milvus { | ||
namespace exec { | ||
|
||
template <typename TInput, typename TAccumulator, typename ResultType> | ||
using SumAggregate = SumAggregateBase<TInput, TAccumulator, ResultType, false>; | ||
|
||
template <typename <typename U, typename V, typename W> class T> | ||
|
||
|
||
void registerSumAggregate(const std::string& prefix, | ||
bool withCompanionFunctions, | ||
bool overwrite) { | ||
regis | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
internal/core/src/exec/operator/query-agg/SumAggregateBase.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (C) 2019-2020 Zilliz. All rights reserved. | ||
// | ||
// 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 | ||
#pragma once | ||
#include "SimpleNumericAggregate.h" | ||
|
||
namespace milvus{ | ||
namespace exec { | ||
template <typename TInput, | ||
typename TAccumulator, | ||
typename ResultType, | ||
bool Overflow> | ||
class SumAggregateBase: public SimpleNumericAggregate<TInput, TAccumulator, ResultType> { | ||
using BaseAggregate = SimpleNumericAggregate<TInput, TAccumulator, ResultType>; | ||
|
||
public: | ||
explicit SumAggregateBase(DataType resultType): BaseAggregate(resultType){}; | ||
|
||
constexpr int32_t accumulatorFixedWidthSize() const override { | ||
return sizeof(TAccumulator); | ||
} | ||
|
||
constexpr int32_t accumulatorAlignmentSize() const override { | ||
return 1; | ||
} | ||
|
||
void extractValues(char** groups, int32_t numGroups, VectorPtr* result) { | ||
BaseAggregate::template doExtractValues<TAccumulator>( | ||
groups, numGroups, result, [&](char* group) { | ||
return (ResultType)(*BaseAggregate::Aggregate::template value<TAccumulator>(group)); | ||
}); | ||
} | ||
}; | ||
} | ||
} |