Skip to content

Commit 7e3ca59

Browse files
committed
fdsdump: store output_limit in View
1 parent 63e4a35 commit 7e3ca59

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

src/tools/fdsdump/src/aggregator/view.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ View::find_field(const std::string &name)
7777
return nullptr;
7878
}
7979

80+
81+
void
82+
View::set_output_limit(size_t n)
83+
{
84+
m_output_limit = n;
85+
}
86+
8087
Value &
8188
View::access_field(const Field &field, uint8_t *record_ptr) const
8289
{

src/tools/fdsdump/src/aggregator/view.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ class View {
354354
*
355355
* @return true if key1 comes before key2 in an ordered sequence, else false
356356
*/
357+
void
358+
set_output_limit(size_t n);
359+
360+
size_t output_limit() const { return m_output_limit; }
361+
357362
bool
358363
ordered_before(uint8_t *key1, uint8_t *key2) const;
359364

@@ -402,6 +407,7 @@ class View {
402407
size_t m_value_count = 0;
403408
size_t m_key_size = 0;
404409
size_t m_value_size = 0;
410+
size_t m_output_limit = 0; // 0 = no limit
405411
std::vector<OrderField> m_order_fields;
406412
bool m_has_inout_fields = false;
407413
bool m_is_fixed_size = true;

src/tools/fdsdump/src/aggregator/viewFactory.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,11 @@ View
288288
ViewFactory::create_view(
289289
const std::string &key_def,
290290
const std::string &value_def,
291-
const std::string &order_def)
291+
const std::string &order_def,
292+
unsigned int output_limit)
292293
{
293294
View view;
294-
create_view(view, key_def, value_def, order_def);
295+
create_view(view, key_def, value_def, order_def, output_limit);
295296
return view;
296297
}
297298

@@ -300,7 +301,8 @@ ViewFactory::create_view(
300301
View &view,
301302
const std::string &key_def,
302303
const std::string &value_def,
303-
const std::string &order_def)
304+
const std::string &order_def,
305+
unsigned int output_limit)
304306
{
305307
for (auto def : split_args(key_def)) {
306308
string_trim(def);
@@ -368,6 +370,8 @@ ViewFactory::create_view(
368370
view.m_order_fields.push_back({field, dir});
369371
}
370372
}
373+
374+
view.m_output_limit = output_limit;
371375
}
372376

373377
} // namespace aggregator

src/tools/fdsdump/src/aggregator/viewFactory.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,15 @@ class ViewFactory {
4040
* @param key_def The definition of the key fields as specified on the command line
4141
* @param value_def The definition of the value fields as specified on the command line
4242
* @param order_def The definition of the order-by fields as specified on the command line
43+
* @param output_limit The number of items that will be outputted using this view (0 = no limit)
4344
*
4445
* @return The view
4546
*/
46-
static View create_view(const std::string &key_def, const std::string &value_def, const std::string &order_def);
47+
static View create_view(
48+
const std::string &key_def,
49+
const std::string &value_def,
50+
const std::string &order_def,
51+
unsigned int output_limit = 0);
4752

4853
private:
4954
static std::unique_ptr<Field> create_elem_or_alias(const std::string &def);
@@ -56,7 +61,7 @@ class ViewFactory {
5661

5762
static std::unique_ptr<Field> parse_dir_field(const std::string &def);
5863

59-
static void create_view(View &view, const std::string &key_def, const std::string &value_def, const std::string &order_def);
64+
static void create_view(View &view, const std::string &key_def, const std::string &value_def, const std::string &order_def, unsigned int output_limit);
6065
};
6166

6267
} // namespace aggregator

0 commit comments

Comments
 (0)