-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up list function implementations
- Loading branch information
1 parent
1b64173
commit ac08521
Showing
35 changed files
with
473 additions
and
742 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "common/exception/binder.h" | ||
#include "common/exception/message.h" | ||
#include "common/type_utils.h" | ||
#include "function/list/vector_list_functions.h" | ||
#include "function/scalar_function.h" | ||
|
||
using namespace kuzu::common; | ||
|
||
namespace kuzu { | ||
namespace function { | ||
|
||
struct ListAppend { | ||
template<typename T> | ||
static void operation(common::list_entry_t& listEntry, T& value, common::list_entry_t& result, | ||
common::ValueVector& listVector, common::ValueVector& valueVector, | ||
common::ValueVector& resultVector) { | ||
result = common::ListVector::addList(&resultVector, listEntry.size + 1); | ||
auto listDataVector = common::ListVector::getDataVector(&listVector); | ||
auto listPos = listEntry.offset; | ||
auto resultDataVector = common::ListVector::getDataVector(&resultVector); | ||
auto resultPos = result.offset; | ||
for (auto i = 0u; i < listEntry.size; i++) { | ||
resultDataVector->copyFromVectorData(resultPos++, listDataVector, listPos++); | ||
} | ||
resultDataVector->copyFromVectorData( | ||
resultDataVector->getData() + resultPos * resultDataVector->getNumBytesPerValue(), | ||
&valueVector, reinterpret_cast<uint8_t*>(&value)); | ||
} | ||
}; | ||
|
||
static void validateArgumentType(const binder::expression_vector& arguments) { | ||
if (*ListType::getChildType(&arguments[0]->dataType) != arguments[1]->getDataType()) { | ||
throw BinderException( | ||
ExceptionMessage::listFunctionIncompatibleChildrenType(ListAppendFunction::name, | ||
arguments[0]->getDataType().toString(), arguments[1]->getDataType().toString())); | ||
} | ||
} | ||
|
||
static std::unique_ptr<FunctionBindData> bindFunc(const binder::expression_vector& arguments, | ||
Function* function) { | ||
validateArgumentType(arguments); | ||
auto scalarFunction = function->ptrCast<ScalarFunction>(); | ||
TypeUtils::visit(arguments[1]->getDataType().getPhysicalType(), [&scalarFunction]<typename T>( | ||
T) { | ||
scalarFunction->execFunc = | ||
ScalarFunction::BinaryExecListStructFunction<list_entry_t, T, list_entry_t, ListAppend>; | ||
}); | ||
return FunctionBindData::getSimpleBindData(arguments, arguments[0]->getDataType()); | ||
} | ||
|
||
function_set ListAppendFunction::getFunctionSet() { | ||
function_set result; | ||
result.push_back(std::make_unique<ScalarFunction>(name, | ||
std::vector<LogicalTypeID>{LogicalTypeID::LIST, LogicalTypeID::ANY}, LogicalTypeID::LIST, | ||
nullptr /* execFunc */, nullptr /* selectFunc */, bindFunc)); | ||
return result; | ||
} | ||
|
||
} // namespace function | ||
} // namespace kuzu |
Oops, something went wrong.