id
stringlengths
27
29
content
stringlengths
226
3.24k
codereview_new_cpp_data_4620
namespace std::array<int, maxVolume + 1> result{ 0 }; result[maxVolume] = MIX_MAX_VOLUME; for ( int i = 1; i < maxVolume; i++ ) - result[i] = round( a * std::pow( 10.0, i * b ) * MIX_MAX_VOLUME ); return result; } (); :warning: **cla...
codereview_new_cpp_data_4621
namespace return MIX_MAX_VOLUME; } - return ( std::exp( std::log( 10 + 1 ) * volumePercentage / 100 ) - 1 ) / 10 * MIX_MAX_VOLUME; } } :warning: **bugprone\-narrowing\-conversions** :warning: narrowing conversion from `` double `` to `` int `` namespace return MIX...
codereview_new_cpp_data_4622
namespace return MIX_MAX_VOLUME; } - return ( std::exp( std::log( 10 + 1 ) * volumePercentage / 100 ) - 1 ) / 10 * MIX_MAX_VOLUME; } } :warning: **clang\-diagnostic\-float\-conversion** :warning: implicit conversion turns floating\-point number into integer: `` double `` to `` i...
codereview_new_cpp_data_4623
bool System::Unlink( const std::string & path ) } #if !defined( _WIN32 ) && !defined( ANDROID ) -// TODO: Android filesystem is case-sensitive so it should use the code below. -// However, in Android an application has access only to a specific path on the system. - // based on: https://github.com/OneSadCoo...
codereview_new_cpp_data_4624
namespace bool fullScreen = true; uint32_t flags = SDL_GetWindowFlags( _window ); - static_assert( ( SDL_WINDOW_FULLSCREEN_DESKTOP & SDL_WINDOW_FULLSCREEN ) == SDL_WINDOW_FULLSCREEN && SDL_WINDOW_FULLSCREEN_DESKTOP > SDL_WINDOW_FULLSCREEN, - "SDL Enumera...
codereview_new_cpp_data_4625
Battle::Interface::Interface( Arena & a, int32_t center ) // hexagon sf_hexagon = DrawHexagon( fheroes2::GetColorId( 0x68, 0x8C, 0x04 ) ); - sf_cursor = DrawHexagonShadow( 4 ); sf_shadow = DrawHexagonShadow( 4 ); btn_auto.setICNInfo( ICN::TEXTBAR, 4, 5 ); Could you please explain this chang...
codereview_new_cpp_data_4626
void LocalEvent::setEventProcessingStates() // TODO: we don't process this event. Add the logic. setEventProcessingState( SDL_TEXTINPUT, false ); setEventProcessingState( SDL_KEYMAPCHANGED, false ); - setEventProcessingState( SDL_TEXTEDITING_EXT, false ); setEventProcessingState( SDL_MOUSEMOTION...
codereview_new_cpp_data_4627
namespace if ( tempCursor == nullptr ) { ERROR_LOG( "Failed to create a cursor. The error description: " << SDL_GetError() ) } - SDL_SetCursor( tempCursor ); const int returnCode = SDL_ShowCursor( _show ? SDL_ENABLE : SDL_DISABLE ); if (...
codereview_new_cpp_data_4628
namespace released[20].resize( 8 + offset * 2, 10 + offset * 2 ); released[20].reset(); fheroes2::DrawLine( released[20], { offset + 0, offset + 4 }, { offset + 4, offset + 0 }, buttonGoodReleasedColor ); - fheroes2::DrawLi19ne( released[20], { offset + 5, offset + 0 }, { offset + 5, ...
codereview_new_cpp_data_4629
namespace fheroes2 SupportedLanguage getCurrentLanguage() { - const Settings & conf = Settings::Get(); - - const fheroes2::SupportedLanguage currentLanguage = fheroes2::getLanguageFromAbbreviation( conf.getGameLanguage() ); - return currentLanguage; } } We can directly return th...
codereview_new_cpp_data_4630
void Troops::JoinTroops( Troops & troops2 ) } } -void Troops::MoveTroops( Troops & from, const int monsterIdToKeep, const bool moveAll ) { assert( this != &from ); // Combine troops of the same type in one slot to leave more room for new troops to join MergeSameMonsterTroops(); - if ...
codereview_new_cpp_data_4631
Castle::CastleDialogReturnValue Castle::OpenDialog( const bool readOnly, const b } // Move troops up. else if ( HotKeyPressEvent( Game::HotKeyEvent::MOVE_TOP ) ) { - GetArmy().MoveTroops( heroes.Guest()->GetArmy(), keep ? keep->GetID() : Monster::UN...
codereview_new_cpp_data_4632
bool Troops::JoinTroop( const Troop & troop ) return JoinTroop( troop.GetMonster(), troop.GetCount(), false ); } -} bool Troops::AllTroopsAreTheSame() const { :warning: **clang\-diagnostic\-error** :warning: extraneous closing brace \(`` } ``\) bool Troops::JoinTroop( const Troop & troop ) return J...
codereview_new_cpp_data_4633
namespace bool Game::AutoSaveAtTheBeginningOfTheDay() { - return Game::Save( System::ConcatPath( GetSaveDir(), autoSaveNameAtTheBeginningOfTheDay + GetSaveFileExtension() ), true ); } bool Game::AutoSaveAtTheEndOfTheDay() { - return Game::Save( System::ConcatPath( GetSaveDir(), autoSaveNameAtTheEndOfThe...
codereview_new_cpp_data_4634
namespace bool Game::AutoSaveAtTheBeginningOfTheDay() { - return Game::Save( System::ConcatPath( GetSaveDir(), autoSaveNameAtTheBeginningOfTheDay + GetSaveFileExtension() ), true ); } bool Game::AutoSaveAtTheEndOfTheDay() { - return Game::Save( System::ConcatPath( GetSaveDir(), autoSaveNameAtTheEndOfThe...
codereview_new_cpp_data_4635
namespace // The width of text area is only 16 pixels. void getCustomNormalButton( fheroes2::Sprite & released, fheroes2::Sprite & pressed, const bool isEvilInterface, int32_t width, fheroes2::Point & releasedOffset, - fheroes2::Point & pressedOffset) { assert( ...
codereview_new_cpp_data_4636
namespace } else { const int32_t middleWidth = originalWidth / 3; - const int32_t startMiddleX = middleWidth; const int32_t overallMiddleWidth = width - middleWidth * 2; const int32_t middleWidthCount = overallMiddleWidth / middleWidth; c...
codereview_new_cpp_data_4637
namespace int32_t offsetY = textInitialOffsetY; - TextBox title( _( "Support us at ), Font::BIG, textWidth ); TextBox name( _( "local-donation-platform|https://www.patreon.com/fheroes2" ), Font::YELLOW_BIG, textWidth ); title.Blit( ( textInitialOffsetX - title.w() ) / 2, offsetY, ...
codereview_new_cpp_data_4638
namespace int32_t offsetY = textInitialOffsetY; - TextBox title( _( "Support us at ), Font::BIG, textWidth ); TextBox name( _( "local-donation-platform|https://www.patreon.com/fheroes2" ), Font::YELLOW_BIG, textWidth ); title.Blit( ( textInitialOffsetX - title.w() ) / 2, offsetY, ...
codereview_new_cpp_data_4639
namespace int32_t offsetY = textInitialOffsetY; - TextBox title( _( "Support us at ), Font::BIG, textWidth ); TextBox name( _( "local-donation-platform|https://www.patreon.com/fheroes2" ), Font::YELLOW_BIG, textWidth ); title.Blit( ( textInitialOffsetX - title.w() ) / 2, offsetY, ...
codereview_new_cpp_data_4640
void Heroes::MeetingDialog( Heroes & otherHero ) display.render(); } - else if ( le.MouseClickLeft( moveArmyToHero1.area() ) HotKeyHoldEvent( Game::HotKeyEvent::MOVE_LEFT ) ) { const ArmyTroop * keep = nullptr; if ( selectArmy1.isSelected() ) { :warning: **cl...
codereview_new_cpp_data_4641
NeutralMonsterJoiningCondition Army::GetJoinSolution( const Heroes & hero, const } // Neutral monsters don't care about hero's stats. Ignoring hero's stats makes hero's army strength be smaller in eyes of neutrals and they won't join so often. - const double armyStrengthRatio = hero.GetArmy().getTroops(...
codereview_new_cpp_data_4642
namespace AI Troop * unitToSwap = heroArmy.GetSlowestTroop(); if ( unitToSwap ) { // We need to compare a strength of troops excluding hero's stats. - const double troopsStrength = Troops( heroArmy ).GetStrength(); const double significanceRa...
codereview_new_cpp_data_4643
NeutralMonsterJoiningCondition Army::GetJoinSolution( const Heroes & hero, const } // Neutral monsters don't care about hero's stats. Ignoring hero's stats makes hero's army strength be smaller in eyes of neutrals and they won't join so often. - const double armyStrengthRatio = Troops( hero.GetArmy() )....
codereview_new_cpp_data_4644
double Heroes::getAIMininumJoiningArmyStrength() const break; } - return strengthThreshold * Troops( GetArmy() ).GetStrength(); } StreamBase & operator<<( StreamBase & msg, const VecHeroes & heroes ) :warning: **cppcoreguidelines\-slicing** :warning: slicing object from type `` Army `` to `` Tr...
codereview_new_cpp_data_4645
int Castle::DialogBuyHero( const Heroes * hero ) const dst_pt.y = dst_pt.y + recruitHeroText.h() + spacer; fheroes2::Blit( portrait_frame, display, dst_pt.x, dst_pt.y ); - fheroes2::Rect heroPortraitArea( dst_pt.x, dst_pt.y, portrait_frame.width(), portrait_frame.height() ); dst_pt.x = dst_pt.x + 5...
codereview_new_cpp_data_4646
void Dialog::QuickInfo( const HeroBase & hero, const fheroes2::Point & position const Kingdom & kingdom = world.GetKingdom( conf.CurrentColor() ); const bool isFriend = ColorBase( hero.GetColor() ).isFriends( conf.CurrentColor() ); const bool isUnderIdentifyHeroSpell = kingdom.Modes( Kingdom::IDENTIFYHE...
codereview_new_cpp_data_4647
namespace std::vector<fheroes2::SupportedLanguage> temp = languages; items.SetListContent( temp ); - const fheroes2::Size currentResolution( display.width(), display.height() ); - - fheroes2::Size selectedResolution; for ( size_t i = 0; i < languages.size(); ++i ) { ...
codereview_new_cpp_data_4648
void Battle::Unit::SpellRestoreAction( const Spell & spell, uint32_t spoint, con SetPosition( GetPosition() ); if ( Arena::GetInterface() ) { - std::string str( _( "%{count} %{name} rise from the dead!" ) ); - str = _n( "%{count} %{name} rises from the dead!", "%{count} %{name...
codereview_new_cpp_data_4649
void Battle::Unit::SpellRestoreAction( const Spell & spell, uint32_t spoint, con SetPosition( GetPosition() ); if ( Arena::GetInterface() ) { - std::string str(_n( "%{count} %{name} rises from the dead!", "%{count} %{name} rise from the dead!", %{count} ) ); StringReplace( s...
codereview_new_cpp_data_4650
void Castle::ActionNewWeek() // population halved if ( world.GetWeekType().GetType() == WeekName::PLAGUE ) { - for ( size_t i = 0; i < CASTLEMAXMONSTER; ++i ) { - dwelling[i] /= 2; } } // Month Of :warning: **modernize\-loop\-convert** :warn...
codereview_new_cpp_data_4651
void Castle::ActionNewWeek() // population halved if ( world.GetWeekType().GetType() == WeekName::PLAGUE ) { - for ( size_t i = 0; i < CASTLEMAXMONSTER; ++i ) { - dwelling[i] /= 2; } } // Month Of :warning: **modernize\-loop\-convert** :warn...
codereview_new_cpp_data_4652
namespace fheroes2 icnVsSprite[75].setPosition( icnVsSprite[75].x(), icnVsSprite[75].y() ); updateSmallFontLetterShadow( icnVsSprite[75] ); } - return; } } :warning: **readability\-redundant\-control\-flow** :warning: redundant return statement at the end of a function ...
codereview_new_cpp_data_4653
namespace strengthLimit /= 2; } - // Do not even care about visiting this object as it brings no visible advantage. return objectArmyStrength > rawArmyStrength * strengthLimit; } :warning: **bugprone\-easily\-swappable\-parameters** :warning: 2 adjacent parameters of `` ...
codereview_new_cpp_data_4654
void Troops::addNewTroopsToFreeSlots( const Troop & troop, uint32_t maxSlots ) uint32_t remainingCount = troop.GetCount() % maxSlots; uint32_t remainingSlots = maxSlots; - auto TryCreateTroopChunk = [&remainingSlots, &remainingCount, chunk, troop]( Troop & newTroop ) { if ( remainingSlots <= 0 ...
codereview_new_cpp_data_4842
static bool elektraCheckForInvalidMetaKey (Key * parentKey, KeySet * ks) const KeySet * metaKeys = keyMeta (cur); for (elektraCursor jt = 0; jt < ksGetSize (metaKeys); ++jt) { - // We reach her iff we try to set a metakey. Therefore we should t const Key * meta = ksAtCursor (metaKeys, jt); const cha...
codereview_new_cpp_data_4843
static bool elektraCheckForInvalidMetaKey (Key * parentKey, KeySet * ks) const KeySet * metaKeys = keyMeta (cur); for (elektraCursor jt = 0; jt < ksGetSize (metaKeys); ++jt) { - // We reach her iff we try to set a metakey. Therefore we should t const Key * meta = ksAtCursor (metaKeys, jt); const cha...
codereview_new_cpp_data_4844
static void testwriteInvalidMetaMustFail (const char * file) PLUGIN_OPEN ("csvstorage"); succeed_if (plugin->kdbSet (plugin, ks, parentKey) == ELEKTRA_PLUGIN_STATUS_ERROR, "kdbSet did not error on invalid meta key insertion"); - ksDel (conf); ksDel (ks); keyDel (parentKey); PLUGIN_CLOSE (); Sorry, yo...
codereview_new_cpp_data_4845
void test_desktop (void) printf ("clear all variables to test \"no desktop\"\n"); clearenv (); keys = ksNew (0, KS_END); plugin->kdbGet (plugin, keys, parentKey); Key const * emptyResult = ksLookupByName (keys, "user:/tests/desktop", 0); You allocated a new `KeySet` without freeing the previously allocate...
codereview_new_cpp_data_5078
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { Py_XDECREF(self); #endif if (self_found) { - // PyCFunction_New will create and own method reference, no need to worry about it PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, meth...
codereview_new_cpp_data_5079
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { Py_XDECREF(self); #endif if (self_found) { - // New PyCFunction will own method reference PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method); - Py_DECREF(method); ...
codereview_new_cpp_data_5080
typedef struct { /////////////// UnpackUnboundCMethod /////////////// //@requires: PyObjectGetAttrStr -#define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) -#define __PYX_REINTERPRET_POINTER(pointer_type, pointer) ((pointer_type)(void *)(pointer)) -#define _...
codereview_new_cpp_data_5081
static int __Pyx_main(int argc, wchar_t **argv) PyConfig config; PyConfig_InitPythonConfig(&config); - /* Disable parsing command line arguments */ config.parse_argv = 0; if (argc && argv) { We generally exclude comments from the generated C files if they start with `//`...
codereview_new_cpp_data_5093
#undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC - #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900) #endif #elif defined(CYTHON_LIMITED_API) This is probably worth picking to 0.29.x. I'm inclined not to pick the rest on th...
codereview_new_cpp_data_5101
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { return __Pyx_PyFunction_FastCall(func, NULL, 0); } #endif -#ifdef __Pyx_CyFunction_USED && defined(NDEBUG) // TODO PyCFunction_GET_FLAGS has a type-check assert that breaks with a CyFunction // in debug mode. There is li...
codereview_new_cpp_data_5103
static double __Pyx_SoftComplexToDouble(__pyx_t_double_complex value) { // In Python the type would be determined right after the number is // created (usually '**'), while here it's determined when coerced // to a PyObject, which may be a few operations later. - if (__Pyx_CIMAG(value)) { Py...
codereview_new_cpp_data_5111
#endif #endif -#if CYTHON_USE_MODULE_STATE && CYTHON_PEP489_MULTI_PHASE_INIT -#error "Cannot combine CYTHON_USE_MODULE_STATE and CYTHON_PEP489_MULTI_PHASE_INIT" -/* since PyState_FindModule requires that each module-def is linked to 1 (or 0) modules -and multi-phase init allows the same module to be imported man...
codereview_new_cpp_data_5118
#undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 Since that you say this is a fork on Python 3.9, I assume ...
codereview_new_cpp_data_5121
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, // (most likely because alignof isn't available) alignment = size % alignment; } - itemsize = itemsize > (Py_ssize_t)alignment ? itemsize : (Py_ssize_t)alignment; } if ((size_t)(basicsiz...
codereview_new_cpp_data_5123
static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping) { #if CYTHON_METH_FASTCALL #define __Pyx_Arg_FASTCALL(args, i) args[i] #define __Pyx_NumKwargs_FASTCALL(kwds) PyTuple_GET_SIZE(kwds) - #define __Pyx_KwValues_FASTCALL(args, nargs) (args+nargs) static CYTHON_INLINE PyObject * ...
codereview_new_cpp_data_5127
static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN { va_list vargs; char msg[200]; - va_start(vargs, fmt); vsnprintf(msg, 200, fmt, vargs); va_end(vargs); Just clearing up an extra blank line ```suggestion ``` static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETUR...
codereview_new_cpp_data_5128
* \warning This program is a poor implementation and does not utilize any of * the C++ STL features. */ -#include <algorithm> -#include <iostream> -#include <queue> using node = struct node { int data; Explain why each header is required * \warning This program is a poor implementation and does not ...
codereview_new_cpp_data_5129
* x. All this should be done in linear time * * @author [David Leal](https://github.com/Panquesito7) - * @author Unknown author */ #include <algorithm> /// for std::is_sorted Non-blocking; I think you can figure it out if you check out the commit `f22baf19210b17c8567d461ad35259322543701c` in your loc...
codereview_new_cpp_data_5130
static void test() { int main() { test(); // run self-test implementations return 0; -} \ No newline at end of file Missing an endline. Without this endline, there could be issues with some IDEs and configurations. ```suggestion } ``` static void test() { int main() { test(); // run se...
codereview_new_cpp_data_5131
* Geeks For Geeks link [https://www.geeksforgeeks.org/maximum-contiguous-circular-sum/] */ -#include <cassert> -#include <iostream> using namespace std; int maxCircularSum(int a[], int n) This is discouraged. Please strictly use `std::` for each `std` member. * Geeks For Geeks link [https://www.geek...
codereview_new_cpp_data_5132
* Geeks For Geeks link [https://www.geeksforgeeks.org/maximum-contiguous-circular-sum/] */ -#include <cassert> -#include <iostream> using namespace std; int maxCircularSum(int a[], int n) Functions should be documented explaining the use of its parameters, a brief description, and what it returns. *...
codereview_new_cpp_data_5133
* Geeks For Geeks link [https://www.geeksforgeeks.org/maximum-contiguous-circular-sum/] */ -#include <cassert> -#include <iostream> using namespace std; int maxCircularSum(int a[], int n) Do not use C-style arrays. Instead, use `std::vector` or `std::array` accordingly. * Geeks For Geeks link [https...
codereview_new_cpp_data_5134
* [Geeks For Geeks](https://www.geeksforgeeks.org/maximum-contiguous-circular-sum/) */ -#include <cassert> // for assert -#include <iostream> // for IO operations -#include <vector> // for vectors -// using namespace std; /** ```suggestion #include <cassert> /// for assert #include <iostrea...
codereview_new_cpp_data_5135
* [Geeks For Geeks](https://www.geeksforgeeks.org/maximum-contiguous-circular-sum/) */ -#include <cassert> // for assert -#include <iostream> // for IO operations -#include <vector> // for vectors -// using namespace std; /** ```suggestion /** * @namespace dynamic_programming * @brief Dynami...
codereview_new_cpp_data_5136
static void test() { arr = {8, -8, 10, -9, 10, -11, 12}; assert(dynamic_programming::maxCircularSum(arr) == 23); } ```suggestion assert(dynamic_programming::maxCircularSum(arr) == 23); std::cout << "All tests have successfully passed!\n"; ``` static void test() { arr = {8, -8,...
codereview_new_cpp_data_5137
int main() std::cout << "\nEnter the size of the array [in range 1-30 ]: "; std::cin >> size; - while (size <= 0 || size > 30) - { - if (size <= 0) - { - std::cout << "Size cannot be less than zero. Please choose another value: "; - ...
codereview_new_cpp_data_5138
int main() std::cout << "\nEnter the size of the array [in range 1-30 ]: "; std::cin >> size; - while (size <= 0 || size > 30) - { - if (size <= 0) - { - std::cout << "Size cannot be less than zero. Please choose another value: "; - ...
codereview_new_cpp_data_5139
int main() std::cout << "\nEnter the size of the array [in range 1-30 ]: "; std::cin >> size; - while (size <= 0 || size > 30) - { - if (size <= 0) - { - std::cout << "Size cannot be less than zero. Please choose another value: "; - ...
codereview_new_cpp_data_5140
/** - * @file median_search2.cpp * * @details * Given a linked list L[0,....,n] of n numbers, find the middle node. No need to add the filename. It's best to let Doxygen automatically detect it, otherwise, you'd have to specify the whole directory as well. ```suggestion * @file ``` __ [![sema-logo](h...
codereview_new_cpp_data_5141
* print median(B) #should be 4 * * @author [Benjamin Weiss](https://github.com/weiss-ben) */ #include <cassert> /// for assert This will help in the Doxygen documentation. ```suggestion * @author [Benjamin Weiss](https://github.com/weiss-ben) * @see median_search.cpp ``` * print median(B) #sh...
codereview_new_cpp_data_5142
static void test() { assert(3 == median->val); // 3 is the value of the median node. std::cout << "test case:1 passed\n"; - // Clean up - while (head1) { - ListNode* t = head1; - head1 = head1->next; - delete t; - } - delete head1; - delete temp; // Test case # 2...
codereview_new_cpp_data_5143
/** * @file - * @brief A generic [binary search tree](https://en.wikipedia.org/wiki/Binary_search_tree) implementation. (https://www.scaler.com/topics/data-structures/binary-search-tree/) * @see binary_search_tree.cpp */ ```suggestion * @brief A generic [binary search tree](https://en.wikipedia.org/wiki/Bin...
codereview_new_cpp_data_5144
template <typename TensorDataType> bool hdf5_reader<TensorDataType>::fetch_datum(Mat& X, int data_id, int mb_idx) { prof_region_begin("fetch_datum", prof_colors[0], false); - assert_eq(sizeof(DataType) % sizeof(TensorDataType), 0ul); assert_eq((unsigned long) X.Height(), - m_num_features / dc::get...
codereview_new_cpp_data_5145
#include "lbann/utils/protobuf/impl.hpp" #include <google/protobuf/descriptor.h> -#include "lbann/proto/protobuf_utils_test_messages.pb.h" #include <string> ```suggestion #include "protobuf_utils_test_messages.pb.h" ``` This is private-to-the-testing, so it does not need the same treatment. #include "l...
codereview_new_cpp_data_5148
void model::setup_distconv() } } if (m_comm->am_world_master()) { - std::cout << "\nDistconv-enabled layers:\n\t" << dc_enabled.str() << std::endl << std::endl; - std::cout << "Distconv-disabled layers:\n\t" << dc_disabled.str() << std::endl; - std::stringstream ss; - print_parallel_strategy_hea...
codereview_new_cpp_data_5153
auto make_field_char_parser() { return parsers::alnum | chr{'_'} | chr{'-'} | chr{':'}; } auto make_extractor_parser() { using namespace parser_literals; // A field cannot start with: ```suggestion // Creates a parser that returns an operand containing either a type or field extractor. ``` auto mak...
codereview_new_cpp_data_5154
TEST(parseable - custom type extractor predicate) { REQUIRE(pred); auto extractor = caf::get_if<type_extractor>(&pred->lhs); REQUIRE(extractor); CHECK_EQUAL(pred->op, relational_operator::not_equal); CHECK_EQUAL(pred->rhs, predicate::operand{data{}}); } One more check please. ```suggestion REQUIRE...
codereview_new_cpp_data_5155
caf::error unpack(const fbs::Data& from, data& to) { } case fbs::data::Data::pattern: { auto options = pattern_options{}; - options.case_insensitive - = from.data_as_pattern()->options()->case_insensitive(); auto result = pattern::make(from.data_as_pattern()->value()->str(), ...
codereview_new_cpp_data_5156
exporter(exporter_actor::stateful_pointer<exporter_state> self, expression expr, : query_context::priority::normal; VAST_DEBUG("spawned exporter with {} pipelines", pipelines.size()); self->state.pipeline = pipeline_executor{std::move(pipelines)}; self->state.index = std::move(index); if (has_cont...
codereview_new_cpp_data_5157
class plugin final : public virtual pipeline_operator_plugin { for (const auto& [key, data] : parsed_assignments) { fields_record[key] = data; } - config_record["fields"] = fields_record; - auto config = configuration::make(config_record, false); if (!config) { return { std:...
codereview_new_cpp_data_5158
class plugin final : public virtual pipeline_operator_plugin { }; } auto config = configuration{}; - config.fields = parsed_extractors; for (const auto& [key, value] : parsed_options) { auto value_str = caf::get_if<std::string>(&value); if (!value_str) { we could move assign the...
codereview_new_cpp_data_5159
class plugin final : public virtual pipeline_operator_plugin { for (const auto& [key, data] : parsed_assignments) { fields_record[key] = data; } - config_record["fields"] = fields_record; - auto config = configuration::make(config_record); if (!config) { return { std::string...
codereview_new_cpp_data_5160
class plugin final : public virtual pipeline_operator_plugin { if (!p(f, l, parsed_aggregations)) { return { std::string_view{f, l}, - caf::make_error(ec::syntax_error, fmt::format("failed to parse select " "operator: '{}'", ...
codereview_new_cpp_data_5161
store_plugin::make_store(system::accountant_actor accountant, std::move(path), name()); } -// -- pipeline_operator_plugin ------------------------------------------------- - -std::pair<std::string_view, caf::expected<std::unique_ptr<pipeline_operator>>> -pipeline_op...
codereview_new_cpp_data_5162
caf::expected<pipeline> pipeline::parse(std::string name, std::string_view repr) { auto result = pipeline{std::move(name), {}}; // plugin name parser - using parsers::alnum, parsers::chr, parsers::space; - const auto optional_ws = ignore(*space); const auto plugin_name_char_parser = alnum | chr{'-'}; co...
codereview_new_cpp_data_5163
#include "vast/error.hpp" #include "vast/ids.hpp" #include "vast/logger.hpp" -#include "vast/pipeline_operator.hpp" #include "vast/plugin.hpp" #include "vast/query_context.hpp" #include "vast/store.hpp" Why do we need this include here? #include "vast/error.hpp" #include "vast/ids.hpp" #include "vast/logge...
codereview_new_cpp_data_5164
reader::read_impl(size_t max_events, size_t max_slice_size, consumer& f) { // record batch. if (read_result->batch->schema()->metadata()->FindKey("VAST:name:0") == -1) { - VAST_ERROR("{} skips record batch with {} rows: metadata is " "incomaptible with VAST", ...
codereview_new_cpp_data_5165
active_partition_actor::behavior_type active_partition( caf::get<record_type>(schema).leaves()) { column_idx++; // TODO: The qualified record field is a leftover from heterogeneous - // partitions, the indexers can be indexed by the column instead. const auto qf ...
codereview_new_cpp_data_5166
create_table_slice(const std::shared_ptr<arrow::RecordBatch>& record_batch, auto fbs_ipc_buffer = flatbuffers::Offset<flatbuffers::Vector<uint8_t>>{}; if (serialize == table_slice::serialize::yes) { auto ipc_ostream = arrow::io::BufferOutputStream::Create().ValueOrDie(); - auto opts = arrow::ipc::IpcWrit...
codereview_new_cpp_data_5169
caf::error index_state::load_from_disk() { caf::scoped_actor blocking{self->system()}; blocking->request(transformer, caf::infinite, atom::persist_v) .receive( - [&synopses, &stats, this](std::vector<partition_synopsis_pair> result) { VAST_INFO("recovered {} corrupted partitions on s...
codereview_new_cpp_data_5170
caf::message pivot_command(const invocation& inv, caf::actor_system& sys) { = spawn_or_connect_to_node(self, inv.options, content(sys.config())); if (auto err = std::get_if<caf::error>(&node_opt)) return caf::make_message(std::move(*err)); - auto local_node = !std::holds_alternative<node_actor>(node_opt)...
codereview_new_cpp_data_5171
int main(int argc, char** argv) { auto signal_monitoring_thread = std::thread([&] { int signum = 0; sigwait(&sigset, &signum); - VAST_WARN("received signal {}", signum); if (!stop) caf::anon_send<caf::message_priority::high>( reflector.get(), atom::internal_v, atom::signal_v, signu...
codereview_new_cpp_data_5172
index(index_actor::stateful_pointer<index_state> self, "partition transforms are not supported for the " "global archive"); std::erase_if(old_partitions_per_type, [&](const auto& entry) { - const auto& [id, type] = entry; if (self->...
codereview_new_cpp_data_5173
namespace { constexpr size_t num_partitions = 4; constexpr size_t num_events_per_parttion = 25; -constexpr size_t taste_count = 4; -constexpr size_t num_query_supervisors = 1; const vast::time epoch; These 2 variables should not be necessary any more. namespace { constexpr size_t num_partitions = 4; co...
codereview_new_cpp_data_5174
filter(const table_slice& slice, expression expr, const ids& hints) { VAST_ASSERT(ret); } } - VAST_ASSERT(builder->rows() != 0); - VAST_ASSERT(builder->rows() != slice.rows()); auto new_slice = builder->finish(); new_slice.import_time(slice.import_time()); VAST_ASSERT(new_slice.encoding() != ...
codereview_new_cpp_data_5175
namespace vast { namespace { inline uint32_t bitmask32(size_t bottom_bits) { return bottom_bits >= 32 ? 0xffffffff : ((uint32_t{1} << bottom_bits) - 1); } ```suggestion inline uint32_t bitmask32(size_t bottom_bits) { ``` namespace vast { namespace { + inline uint32_t bitmask32(size_t bottom_bits) ...
codereview_new_cpp_data_5176
class address_encryptor { private: static constexpr inline auto msb_of_byte_mask = 0b10000000; - EVP_CIPHER_CTX* ctx_; - const EVP_CIPHER* cipher_; - int block_size_; - std::vector<address::byte_type> pad_; std::vector<address::byte_type> generate_one_time_pad(std::span<address::byte_type> bytes_to_e...
codereview_new_cpp_data_5177
class pseudonymize_operator : public pipeline_operator { for (const auto& field_name : config_.fields) { for (const auto& index : caf::get<record_type>(layout).resolve_key_suffix( field_name, layout.name())) { - if (!caf::holds_alternative<address_type>( - caf::get<record_...
codereview_new_cpp_data_5178
void ship_results(exporter_actor::stateful_pointer<exporter_state> self) { return; } for (auto& t : *transformed) - self->anon_send(st.sink, std::move(t)); } } One of the receivers depends on knowin who the sender is. In CAF 0.17.6 the anon_send didn't work properly and the sender was avai...
codereview_new_cpp_data_5179
status_handler(status_handler_actor::stateful_pointer<status_handler_state> self return; } std::string result; - caf::message_handler{[&](std::string& str) { - result = std::move(str); - }}(e.context()); rsp->append(result); ...
codereview_new_cpp_data_5180
print_segment_contents(indentation&, const options&, vast::chunk_ptr chunk) { auto writer = vast::format::json::writer{ std::make_unique<std::stringstream>(), settings}; for (const auto& slice : *segment) - writer.write(slice); writer.flush(); auto& out = static_cast<std::stringstream&>(writer.out(...
codereview_new_cpp_data_5181
active_local_store(local_store_actor::stateful_pointer<active_store_state> self, if (!slices) return slices.error(); self->state.builder->reset(id); - for (auto&& slice : std::exchange(*slices, {})) - self->state.builder->add(std::move(slice)); return rank(self->state.builder-...
codereview_new_cpp_data_5182
TEST(token validation) { auto serialized_state = state.save(); REQUIRE_NOERROR(serialized_state); vast::plugins::web::authenticator_state recovered_state; - recovered_state.initialize_from(*serialized_state); CHECK_EQUAL(state.authenticate(*token), true); CHECK_EQUAL(state.authenticate("Yog-Sothoth"), ...
codereview_new_cpp_data_5183
inhale<format::json::reader>(const char* filename, caf::put(settings, "vast.import.json.selector", "event_type:suricata"); auto input = std::make_unique<std::ifstream>(filename); format::json::reader reader{settings, std::move(input)}; - reader.module(events::suricata_module); return extract(reader, slice...
codereview_new_cpp_data_5184
segment::copy_without(const vast::segment& segment, const vast::ids& xs) { if (!slices) return slices.error(); for (auto&& slice : std::exchange(*slices, {})) - builder.add(std::move(slice)); return builder.finish(); } If this fails we should return the error from the function. segment::copy_wit...