Skip to content

Commit db6d7a2

Browse files
refactor(core): Replace outcome_v2::std_result with ystdlib::error_handling::Result; Remove outcome dependency. (#969)
1 parent 8a94609 commit db6d7a2

33 files changed

+228
-257
lines changed

components/core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ add_executable(unitTest
668668
)
669669
target_include_directories(unitTest
670670
PRIVATE
671-
${CLP_OUTCOME_INCLUDE_DIRECTORY}
672671
${CLP_SQLITE3_INCLUDE_DIRECTORY}
673672
)
674673
target_link_libraries(unitTest

components/core/src/clp/clg/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ add_executable(clg ${CLG_SOURCES})
127127
target_compile_features(clg PRIVATE cxx_std_20)
128128
target_include_directories(clg
129129
PRIVATE
130-
"${CLP_OUTCOME_INCLUDE_DIRECTORY}"
131130
"${CLP_SQLITE3_INCLUDE_DIRECTORY}"
132131
)
133132
target_link_libraries(clg
@@ -144,6 +143,7 @@ target_link_libraries(clg
144143
clp::string_utils
145144
yaml-cpp
146145
ystdlib::containers
146+
ystdlib::error_handling
147147
ZStd::ZStd
148148
)
149149
# Put the built executable at the root of the build directory

components/core/src/clp/clo/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ add_executable(clo ${CLO_SOURCES} ${REDUCER_SOURCES})
155155
target_compile_features(clo PRIVATE cxx_std_20)
156156
target_include_directories(clo
157157
PRIVATE
158-
"${CLP_OUTCOME_INCLUDE_DIRECTORY}"
159158
"${CLP_SQLITE3_INCLUDE_DIRECTORY}"
160159
)
161160
target_link_libraries(clo
@@ -172,6 +171,7 @@ target_link_libraries(clo
172171
${STD_FS_LIBS}
173172
clp::string_utils
174173
ystdlib::containers
174+
ystdlib::error_handling
175175
ZStd::ZStd
176176
)
177177
# Put the built executable at the root of the build directory

components/core/src/clp/clp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ add_executable(clp ${CLP_SOURCES})
169169
target_compile_features(clp PRIVATE cxx_std_20)
170170
target_include_directories(clp
171171
PRIVATE
172-
"${CLP_OUTCOME_INCLUDE_DIRECTORY}"
173172
"${CLP_SQLITE3_INCLUDE_DIRECTORY}"
174173
)
175174
target_link_libraries(clp
@@ -186,6 +185,7 @@ target_link_libraries(clp
186185
${STD_FS_LIBS}
187186
clp::string_utils
188187
yaml-cpp
188+
ystdlib::error_handling
189189
ystdlib::containers
190190
ZStd::ZStd
191191
)

components/core/src/clp/ffi/KeyValuePairLogEvent.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <nlohmann/json.hpp>
1515
#include <nlohmann/json_fwd.hpp>
16-
#include <outcome/outcome.hpp>
16+
#include <ystdlib/error_handling/Result.hpp>
1717

1818
#include "../ir/EncodedTextAst.hpp"
1919
#include "../time_types.hpp"
@@ -166,7 +166,7 @@ class JsonSerializationIterator {
166166
[[nodiscard]] auto get_schema_subtree_bitmap(
167167
KeyValuePairLogEvent::NodeIdValuePairs const& node_id_value_pairs,
168168
SchemaTree const& schema_tree
169-
) -> OUTCOME_V2_NAMESPACE::std_result<vector<bool>>;
169+
) -> ystdlib::error_handling::Result<vector<bool>>;
170170

171171
/**
172172
* Inserts the given key-value pair into the JSON object (map).
@@ -203,7 +203,7 @@ class JsonSerializationIterator {
203203
SchemaTree const& schema_tree,
204204
KeyValuePairLogEvent::NodeIdValuePairs const& node_id_value_pairs,
205205
vector<bool> const& schema_subtree_bitmap
206-
) -> OUTCOME_V2_NAMESPACE::std_result<nlohmann::json>;
206+
) -> ystdlib::error_handling::Result<nlohmann::json>;
207207

208208
/**
209209
* @param node A non-root schema tree node.
@@ -334,7 +334,7 @@ auto is_leaf_node(
334334
auto get_schema_subtree_bitmap(
335335
KeyValuePairLogEvent::NodeIdValuePairs const& node_id_value_pairs,
336336
SchemaTree const& schema_tree
337-
) -> OUTCOME_V2_NAMESPACE::std_result<vector<bool>> {
337+
) -> ystdlib::error_handling::Result<vector<bool>> {
338338
vector<bool> schema_subtree_bitmap(schema_tree.get_size(), false);
339339
for (auto const& [node_id, val] : node_id_value_pairs) {
340340
if (node_id >= schema_subtree_bitmap.size()) {
@@ -431,7 +431,7 @@ auto serialize_node_id_value_pairs_to_json(
431431
SchemaTree const& schema_tree,
432432
KeyValuePairLogEvent::NodeIdValuePairs const& node_id_value_pairs,
433433
vector<bool> const& schema_subtree_bitmap
434-
) -> OUTCOME_V2_NAMESPACE::std_result<nlohmann::json> {
434+
) -> ystdlib::error_handling::Result<nlohmann::json> {
435435
if (node_id_value_pairs.empty()) {
436436
return nlohmann::json::object();
437437
}
@@ -531,7 +531,7 @@ auto KeyValuePairLogEvent::create(
531531
NodeIdValuePairs auto_gen_node_id_value_pairs,
532532
NodeIdValuePairs user_gen_node_id_value_pairs,
533533
UtcOffset utc_offset
534-
) -> OUTCOME_V2_NAMESPACE::std_result<KeyValuePairLogEvent> {
534+
) -> ystdlib::error_handling::Result<KeyValuePairLogEvent> {
535535
if (nullptr == auto_gen_keys_schema_tree || nullptr == user_gen_keys_schema_tree) {
536536
return std::errc::invalid_argument;
537537
}
@@ -564,17 +564,17 @@ auto KeyValuePairLogEvent::create(
564564
}
565565

566566
auto KeyValuePairLogEvent::get_auto_gen_keys_schema_subtree_bitmap() const
567-
-> OUTCOME_V2_NAMESPACE::std_result<std::vector<bool>> {
567+
-> ystdlib::error_handling::Result<std::vector<bool>> {
568568
return get_schema_subtree_bitmap(m_auto_gen_node_id_value_pairs, *m_auto_gen_keys_schema_tree);
569569
}
570570

571571
auto KeyValuePairLogEvent::get_user_gen_keys_schema_subtree_bitmap() const
572-
-> outcome_v2::std_result<std::vector<bool>> {
572+
-> ystdlib::error_handling::Result<std::vector<bool>> {
573573
return get_schema_subtree_bitmap(m_user_gen_node_id_value_pairs, *m_user_gen_keys_schema_tree);
574574
}
575575

576576
auto KeyValuePairLogEvent::serialize_to_json() const
577-
-> OUTCOME_V2_NAMESPACE::std_result<std::pair<nlohmann::json, nlohmann::json>> {
577+
-> ystdlib::error_handling::Result<std::pair<nlohmann::json, nlohmann::json>> {
578578
auto const auto_gen_keys_schema_subtree_bitmap_result{
579579
get_auto_gen_keys_schema_subtree_bitmap()
580580
};

components/core/src/clp/ffi/KeyValuePairLogEvent.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <vector>
99

1010
#include <nlohmann/json_fwd.hpp>
11-
#include <outcome/outcome.hpp>
11+
#include <ystdlib/error_handling/Result.hpp>
1212

1313
#include "../time_types.hpp"
1414
#include "SchemaTree.hpp"
@@ -48,7 +48,7 @@ class KeyValuePairLogEvent {
4848
NodeIdValuePairs auto_gen_node_id_value_pairs,
4949
NodeIdValuePairs user_gen_node_id_value_pairs,
5050
UtcOffset utc_offset
51-
) -> OUTCOME_V2_NAMESPACE::std_result<KeyValuePairLogEvent>;
51+
) -> ystdlib::error_handling::Result<KeyValuePairLogEvent>;
5252

5353
// Disable copy constructor and assignment operator
5454
KeyValuePairLogEvent(KeyValuePairLogEvent const&) = delete;
@@ -86,7 +86,7 @@ class KeyValuePairLogEvent {
8686
* - Forwards `get_schema_subtree_bitmap`'s return values.
8787
*/
8888
[[nodiscard]] auto get_auto_gen_keys_schema_subtree_bitmap() const
89-
-> OUTCOME_V2_NAMESPACE::std_result<std::vector<bool>>;
89+
-> ystdlib::error_handling::Result<std::vector<bool>>;
9090

9191
/**
9292
* @return A result containing a bitmap where every bit corresponds to the ID of a node in the
@@ -96,7 +96,7 @@ class KeyValuePairLogEvent {
9696
* - Forwards `get_schema_subtree_bitmap`'s return values.
9797
*/
9898
[[nodiscard]] auto get_user_gen_keys_schema_subtree_bitmap() const
99-
-> OUTCOME_V2_NAMESPACE::std_result<std::vector<bool>>;
99+
-> ystdlib::error_handling::Result<std::vector<bool>>;
100100

101101
[[nodiscard]] auto get_utc_offset() const -> UtcOffset { return m_utc_offset; }
102102

@@ -111,7 +111,7 @@ class KeyValuePairLogEvent {
111111
* - Forwards `serialize_node_id_value_pairs_to_json`'s return values on failure.
112112
*/
113113
[[nodiscard]] auto serialize_to_json() const
114-
-> OUTCOME_V2_NAMESPACE::std_result<std::pair<nlohmann::json, nlohmann::json>>;
114+
-> ystdlib::error_handling::Result<std::pair<nlohmann::json, nlohmann::json>>;
115115

116116
private:
117117
// Constructor

components/core/src/clp/ffi/ir_stream/Deserializer.hpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <nlohmann/json.hpp>
1212
#include <nlohmann/json_fwd.hpp>
13-
#include <outcome/outcome.hpp>
13+
#include <ystdlib/error_handling/Result.hpp>
1414

1515
#include "../../ReaderInterface.hpp"
1616
#include "../../time_types.hpp"
@@ -56,7 +56,7 @@ class Deserializer {
5656
* - Forwards `create_generic`'s return values.
5757
*/
5858
[[nodiscard]] static auto create(ReaderInterface& reader, IrUnitHandlerType ir_unit_handler)
59-
-> OUTCOME_V2_NAMESPACE::std_result<Deserializer>
59+
-> ystdlib::error_handling::Result<Deserializer>
6060
requires std::is_same_v<QueryHandlerType, search::EmptyQueryHandler>
6161
{
6262
return create_generic(reader, std::move(ir_unit_handler), {});
@@ -75,7 +75,7 @@ class Deserializer {
7575
[[nodiscard]] static auto
7676
create(ReaderInterface& reader,
7777
IrUnitHandlerType ir_unit_handler,
78-
QueryHandlerType query_handler) -> OUTCOME_V2_NAMESPACE::std_result<Deserializer>
78+
QueryHandlerType query_handler) -> ystdlib::error_handling::Result<Deserializer>
7979
requires search::IsNonEmptyQueryHandler<QueryHandlerType>::value
8080
{
8181
return create_generic(reader, std::move(ir_unit_handler), std::move(query_handler));
@@ -138,7 +138,7 @@ class Deserializer {
138138
* unit handling failure.
139139
*/
140140
[[nodiscard]] auto deserialize_next_ir_unit(ReaderInterface& reader)
141-
-> OUTCOME_V2_NAMESPACE::std_result<IrUnitType>;
141+
-> ystdlib::error_handling::Result<IrUnitType>;
142142

143143
/**
144144
* @return Whether the stream has completed. A stream is considered completed if an
@@ -176,7 +176,7 @@ class Deserializer {
176176
ReaderInterface& reader,
177177
IrUnitHandlerType ir_unit_handler,
178178
QueryHandlerType query_handler
179-
) -> OUTCOME_V2_NAMESPACE::std_result<Deserializer>;
179+
) -> ystdlib::error_handling::Result<Deserializer>;
180180

181181
// Constructor
182182
Deserializer(
@@ -206,7 +206,7 @@ class Deserializer {
206206
*/
207207
template <IrUnitHandlerReq IrUnitHandler>
208208
[[nodiscard]] auto make_deserializer(ReaderInterface& reader, IrUnitHandler ir_unit_handler)
209-
-> OUTCOME_V2_NAMESPACE::std_result<Deserializer<IrUnitHandler>>;
209+
-> ystdlib::error_handling::Result<Deserializer<IrUnitHandler>>;
210210

211211
/**
212212
* Wrapper for `Deserializer`'s factory function to enable automatic type deduction.
@@ -220,14 +220,14 @@ template <IrUnitHandlerReq IrUnitHandler, search::QueryHandlerReq QueryHandlerTy
220220
ReaderInterface& reader,
221221
IrUnitHandler ir_unit_handler,
222222
QueryHandlerType query_handler
223-
) -> OUTCOME_V2_NAMESPACE::std_result<Deserializer<IrUnitHandler, QueryHandlerType>>;
223+
) -> ystdlib::error_handling::Result<Deserializer<IrUnitHandler, QueryHandlerType>>;
224224

225225
template <IrUnitHandlerReq IrUnitHandlerType, search::QueryHandlerReq QueryHandlerType>
226226
auto Deserializer<IrUnitHandlerType, QueryHandlerType>::create_generic(
227227
ReaderInterface& reader,
228228
IrUnitHandlerType ir_unit_handler,
229229
QueryHandlerType query_handler
230-
) -> OUTCOME_V2_NAMESPACE::std_result<Deserializer> {
230+
) -> ystdlib::error_handling::Result<Deserializer> {
231231
bool is_four_byte_encoded{};
232232
if (auto const err{get_encoding_type(reader, is_four_byte_encoded)};
233233
IRErrorCode::IRErrorCode_Success != err)
@@ -278,7 +278,7 @@ auto Deserializer<IrUnitHandlerType, QueryHandlerType>::create_generic(
278278
template <IrUnitHandlerReq IrUnitHandler, search::QueryHandlerReq QueryHandlerType>
279279
auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
280280
ReaderInterface& reader
281-
) -> OUTCOME_V2_NAMESPACE::std_result<IrUnitType> {
281+
) -> ystdlib::error_handling::Result<IrUnitType> {
282282
if (is_stream_completed()) {
283283
return std::errc::operation_not_permitted;
284284
}
@@ -296,7 +296,7 @@ auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
296296
auto const ir_unit_type{optional_ir_unit_type.value()};
297297
switch (ir_unit_type) {
298298
case IrUnitType::LogEvent: {
299-
auto log_event{OUTCOME_TRYX(deserialize_ir_unit_kv_pair_log_event(
299+
auto log_event{YSTDLIB_ERROR_HANDLING_TRYX(deserialize_ir_unit_kv_pair_log_event(
300300
reader,
301301
tag,
302302
m_auto_gen_keys_schema_tree,
@@ -306,7 +306,9 @@ auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
306306

307307
if constexpr (search::IsNonEmptyQueryHandler<QueryHandlerType>::value) {
308308
if (search::AstEvaluationResult::True
309-
!= OUTCOME_TRYX(m_query_handler.evaluate_kv_pair_log_event(log_event)))
309+
!= YSTDLIB_ERROR_HANDLING_TRYX(
310+
m_query_handler.evaluate_kv_pair_log_event(log_event)
311+
))
310312
{
311313
break;
312314
}
@@ -322,7 +324,7 @@ auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
322324

323325
case IrUnitType::SchemaTreeNodeInsertion: {
324326
std::string key_name;
325-
auto const [is_auto_generated, node_locator]{OUTCOME_TRYX(
327+
auto const [is_auto_generated, node_locator]{YSTDLIB_ERROR_HANDLING_TRYX(
326328
deserialize_ir_unit_schema_tree_node_insertion(reader, tag, key_name)
327329
)};
328330
auto& schema_tree_to_insert{
@@ -336,7 +338,7 @@ auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
336338
auto const node_id{schema_tree_to_insert->insert_node(node_locator)};
337339

338340
if constexpr (search::IsNonEmptyQueryHandler<QueryHandlerType>::value) {
339-
OUTCOME_TRYV(m_query_handler.update_partially_resolved_columns(
341+
YSTDLIB_ERROR_HANDLING_TRYV(m_query_handler.update_partially_resolved_columns(
340342
is_auto_generated,
341343
node_locator,
342344
node_id
@@ -356,7 +358,9 @@ auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
356358
}
357359

358360
case IrUnitType::UtcOffsetChange: {
359-
auto const new_utc_offset{OUTCOME_TRYX(deserialize_ir_unit_utc_offset_change(reader))};
361+
auto const new_utc_offset{
362+
YSTDLIB_ERROR_HANDLING_TRYX(deserialize_ir_unit_utc_offset_change(reader))
363+
};
360364
if (auto const err{
361365
m_ir_unit_handler.handle_utc_offset_change(m_utc_offset, new_utc_offset)
362366
};
@@ -388,7 +392,7 @@ auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
388392

389393
template <IrUnitHandlerReq IrUnitHandlerType>
390394
[[nodiscard]] auto make_deserializer(ReaderInterface& reader, IrUnitHandlerType ir_unit_handler)
391-
-> OUTCOME_V2_NAMESPACE::std_result<Deserializer<IrUnitHandlerType>> {
395+
-> ystdlib::error_handling::Result<Deserializer<IrUnitHandlerType>> {
392396
return Deserializer<IrUnitHandlerType>::create(reader, std::move(ir_unit_handler));
393397
}
394398

@@ -397,7 +401,7 @@ template <IrUnitHandlerReq IrUnitHandlerType, search::QueryHandlerReq QueryHandl
397401
ReaderInterface& reader,
398402
IrUnitHandlerType ir_unit_handler,
399403
QueryHandlerType query_handler
400-
) -> OUTCOME_V2_NAMESPACE::std_result<Deserializer<IrUnitHandlerType, QueryHandlerType>> {
404+
) -> ystdlib::error_handling::Result<Deserializer<IrUnitHandlerType, QueryHandlerType>> {
401405
return Deserializer<IrUnitHandlerType, QueryHandlerType>::create(
402406
reader,
403407
std::move(ir_unit_handler),

components/core/src/clp/ffi/ir_stream/Serializer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <msgpack.hpp>
1515
#include <nlohmann/json.hpp>
16-
#include <outcome/outcome.hpp>
16+
#include <ystdlib/error_handling/Result.hpp>
1717

1818
#include "../../ir/types.hpp"
1919
#include "../../time_types.hpp"
@@ -524,7 +524,7 @@ template <
524524
template <typename encoded_variable_t>
525525
auto Serializer<encoded_variable_t>::create(
526526
std::optional<nlohmann::json> optional_user_defined_metadata
527-
) -> OUTCOME_V2_NAMESPACE::std_result<Serializer<encoded_variable_t>> {
527+
) -> ystdlib::error_handling::Result<Serializer<encoded_variable_t>> {
528528
static_assert(
529529
std::is_same_v<encoded_variable_t, eight_byte_encoded_variable_t>
530530
|| std::is_same_v<encoded_variable_t, four_byte_encoded_variable_t>
@@ -796,10 +796,10 @@ auto Serializer<encoded_variable_t>::serialize_schema_tree_node(
796796
// file
797797
template auto Serializer<eight_byte_encoded_variable_t>::create(
798798
std::optional<nlohmann::json> optional_user_defined_metadata
799-
) -> OUTCOME_V2_NAMESPACE::std_result<Serializer<eight_byte_encoded_variable_t>>;
799+
) -> ystdlib::error_handling::Result<Serializer<eight_byte_encoded_variable_t>>;
800800
template auto Serializer<four_byte_encoded_variable_t>::create(
801801
std::optional<nlohmann::json> optional_user_defined_metadata
802-
) -> OUTCOME_V2_NAMESPACE::std_result<Serializer<four_byte_encoded_variable_t>>;
802+
) -> ystdlib::error_handling::Result<Serializer<four_byte_encoded_variable_t>>;
803803

804804
template auto Serializer<eight_byte_encoded_variable_t>::change_utc_offset(UtcOffset utc_offset)
805805
-> void;

components/core/src/clp/ffi/ir_stream/Serializer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include <msgpack.hpp>
1111
#include <nlohmann/json.hpp>
12-
#include <outcome/outcome.hpp>
12+
#include <ystdlib/error_handling/Result.hpp>
1313

1414
#include "../../time_types.hpp"
1515
#include "../SchemaTree.hpp"
@@ -49,7 +49,7 @@ class Serializer {
4949
*/
5050
[[nodiscard]] static auto create(
5151
std::optional<nlohmann::json> optional_user_defined_metadata = std::nullopt
52-
) -> OUTCOME_V2_NAMESPACE::std_result<Serializer<encoded_variable_t>>;
52+
) -> ystdlib::error_handling::Result<Serializer<encoded_variable_t>>;
5353

5454
// Disable copy constructor/assignment operator
5555
Serializer(Serializer const&) = delete;

0 commit comments

Comments
 (0)