Skip to content

Commit 21324d2

Browse files
amitkduttafacebook-github-bot
authored andcommitted
refactor: Move minor map functions in MapFunctions.h
Summary: We have simple map functions (map_key_exists, map_remove_null_values), which does not required independent files. Moving into MapFunctions.h. Differential Revision: D70495645
1 parent bbaf9b8 commit 21324d2

File tree

3 files changed

+17
-41
lines changed

3 files changed

+17
-41
lines changed

velox/functions/prestosql/MapFunctions.h

+17
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,21 @@ struct MapKeyExists {
3232
}
3333
};
3434

35+
template <typename TExec>
36+
struct MapRemoveNullValues {
37+
VELOX_DEFINE_FUNCTION_TYPES(TExec);
38+
39+
void call(
40+
out_type<Map<Generic<T1>, Generic<T2>>>& out,
41+
const arg_type<Map<Generic<T1>, Generic<T2>>>& inputMap) {
42+
for (const auto& entry : inputMap) {
43+
if (entry.second.has_value()) {
44+
auto [keyWriter, valueWriter] = out.add_item();
45+
keyWriter.copy_from(entry.first);
46+
valueWriter.copy_from(entry.second.value());
47+
}
48+
}
49+
}
50+
};
51+
3552
} // namespace facebook::velox::functions

velox/functions/prestosql/MapRemoveNullValues.h

-40
This file was deleted.

velox/functions/prestosql/registration/MapFunctionsRegistration.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "velox/functions/prestosql/MapFunctions.h"
2222
#include "velox/functions/prestosql/MapKeysByTopNValues.h"
2323
#include "velox/functions/prestosql/MapNormalize.h"
24-
#include "velox/functions/prestosql/MapRemoveNullValues.h"
2524
#include "velox/functions/prestosql/MapSubset.h"
2625
#include "velox/functions/prestosql/MapTopN.h"
2726
#include "velox/functions/prestosql/MapTopNKeys.h"

0 commit comments

Comments
 (0)