Skip to content

Commit 8e5d12c

Browse files
committed
processor_tda: Extract structs into a header
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent d1898b0 commit 8e5d12c

File tree

2 files changed

+77
-51
lines changed

2 files changed

+77
-51
lines changed

plugins/processor_tda/tda.c

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919

2020
#include <fluent-bit/flb_processor_plugin.h>
2121
#include <fluent-bit/flb_hash_table.h>
22-
#include <fluent-bit/ripser/flb_ripser_wrapper.h>
23-
#include <cmetrics/cmetrics.h>
24-
#include <cmetrics/cmt_map.h>
25-
#include <cfl/cfl_sds.h>
2622

2723
/* lwrb header */
2824
#include <lwrb/lwrb.h>
@@ -31,53 +27,7 @@
3127
#include <string.h>
3228
#include <stdlib.h>
3329

34-
struct tda_window;
35-
struct tda_proc_ctx;
36-
37-
/* time-series samples (aggregated metrics snapshot) */
38-
struct tda_sample {
39-
uint64_t ts;
40-
double values[];
41-
};
42-
43-
struct tda_group {
44-
cfl_sds_t ns;
45-
cfl_sds_t subsystem;
46-
int index; /* 0 .. feature_dim-1 */
47-
};
48-
49-
struct tda_window {
50-
lwrb_t rb;
51-
uint8_t *buf;
52-
size_t sample_size; /* sizeof(uint64_t) + feature_dim * sizeof(double) */
53-
int feature_dim;
54-
};
55-
56-
/* processor context */
57-
struct tda_proc_ctx {
58-
struct tda_window *window;
59-
int window_size; /* max number of samples in window */
60-
int min_points; /* minimum samples before running ripser */
61-
62-
int feature_dim; /* # of (ns,subsystem) groups */
63-
struct flb_hash_table *groups; /* key="ns.subsystem" -> struct tda_group* */
64-
struct tda_group **group_list; /* for safe free() */
65-
66-
/* delay embedding parameters */
67-
int embed_dim; /* m: number of delays (1 = no embedding) */
68-
int embed_delay; /* tau: delay in samples */
69-
70-
/* exposed betti-number gauges (created lazily) */
71-
struct cmt_gauge *g_betti0;
72-
struct cmt_gauge *g_betti1;
73-
struct cmt_gauge *g_betti2;
74-
75-
/* for counter → rate conversion */
76-
double *last_vec; /* last raw snapshot for each feature_dim */
77-
uint64_t last_ts; /* last snapshot timestamp (nanoseconds) */
78-
79-
struct flb_processor_instance *ins;
80-
};
30+
#include "tda.h"
8131

8232
/* Choose a distance threshold from a dense (n x n) distance matrix.
8333
* We collect all off-diagonal distances (i > j), sort them, and

plugins/processor_tda/tda.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
3+
/* Fluent Bit
4+
* ==========
5+
* Copyright (C) 2025 The Fluent Bit Authors
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#ifndef FLB_TDA_H
21+
#define FLB_TDA_H
22+
23+
#include <fluent-bit/ripser/flb_ripser_wrapper.h>
24+
#include <cmetrics/cmetrics.h>
25+
#include <cmetrics/cmt_map.h>
26+
#include <cfl/cfl_sds.h>
27+
28+
struct tda_window;
29+
struct tda_proc_ctx;
30+
31+
/* time-series samples (aggregated metrics snapshot) */
32+
struct tda_sample {
33+
uint64_t ts;
34+
double values[];
35+
};
36+
37+
struct tda_group {
38+
cfl_sds_t ns;
39+
cfl_sds_t subsystem;
40+
int index; /* 0 .. feature_dim-1 */
41+
};
42+
43+
struct tda_window {
44+
lwrb_t rb;
45+
uint8_t *buf;
46+
size_t sample_size; /* sizeof(uint64_t) + feature_dim * sizeof(double) */
47+
int feature_dim;
48+
};
49+
50+
/* processor context */
51+
struct tda_proc_ctx {
52+
struct tda_window *window;
53+
int window_size; /* max number of samples in window */
54+
int min_points; /* minimum samples before running ripser */
55+
56+
int feature_dim; /* # of (ns,subsystem) groups */
57+
struct flb_hash_table *groups; /* key="ns.subsystem" -> struct tda_group* */
58+
struct tda_group **group_list; /* for safe free() */
59+
60+
/* delay embedding parameters */
61+
int embed_dim; /* m: number of delays (1 = no embedding) */
62+
int embed_delay; /* tau: delay in samples */
63+
64+
/* exposed betti-number gauges (created lazily) */
65+
struct cmt_gauge *g_betti0;
66+
struct cmt_gauge *g_betti1;
67+
struct cmt_gauge *g_betti2;
68+
69+
/* for counter → rate conversion */
70+
double *last_vec; /* last raw snapshot for each feature_dim */
71+
uint64_t last_ts; /* last snapshot timestamp (nanoseconds) */
72+
73+
struct flb_processor_instance *ins;
74+
};
75+
76+
#endif /* FLB_TDA_H */

0 commit comments

Comments
 (0)