xs/scan.xs

filter: Statementstmt 70.1% 54 / 77 Branchbran 52.2% 23 / 44 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 63.6% 77 / 121 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/punk_observe/po_attr.h ↑ Summary xs/contracts.xs »
1 MODULE = Punk::Observe PACKAGE = Punk::Observe::Scan PREFIX = posc_
2  
3 # What a query pushes down: the time range it proves, the term the bloom can
4 # probe, and the first equality a directory can answer.
5 void
6 posc_pushdown(SV *query)
7 PPCODE:
8 {
9 po_query q;
10 po_plan plan;
11 po_pushdown pd;
12 STRLEN qlen;
13 13 const char *qp = SvPV(query, qlen);
14 13 HV *r = newHV();
15  
16 13 ▶ if (!po_parse(&q, qp, (size_t)qlen)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!po_parse(&q, qp, (size_t)qlen)) { 0 13 13
17 0 hv_stores(r, "ok", newSViv(0));
18 0 hv_stores(r, "error", newSVpv(q.err, 0));
19 0 ▶ mXPUSHs(newRV_noinc((SV *)r));
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(newRV_noinc((SV *)r)); 0 0 0
20 0 XSRETURN(1);
21 }
22 13 ▶ if (!po_plan_build(&plan, &q, NULL)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!po_plan_build(&plan, &q, NULL)) { 0 13 13
23 0 hv_stores(r, "ok", newSViv(0));
24 0 hv_stores(r, "error", newSVpv(plan.err, 0));
25 0 po_query_free(&q);
26 0 ▶ mXPUSHs(newRV_noinc((SV *)r));
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(newRV_noinc((SV *)r)); 0 0 0
27 0 XSRETURN(1);
28 }
29 13 po_pushdown_build(&pd, &plan);
30  
31 13 hv_stores(r, "ok", newSViv(1));
32 13 hv_stores(r, "from", po_u64_to_sv(pd.from));
33 13 hv_stores(r, "to", po_u64_to_sv(pd.to));
34 13 hv_stores(r, "bounded", newSViv(pd.time_bounded));
35 13 hv_stores(r, "empty", newSViv(po_pushdown_empty(&pd)));
36 13 ▶ hv_stores(r, "search", pd.search_len
Branch: 1 branch
BranchTrueFalseTotal
hv_stores(r, "search", pd.search_len 1 12 13
37 ? newSVpvn(pd.search, pd.search_len) : newSVpvs(""));
38 13 ▶ hv_stores(r, "eq_field", pd.have_eq
Branch: 1 branch
BranchTrueFalseTotal
hv_stores(r, "eq_field", pd.have_eq 2 11 13
39 ? newSVpvn(pd.eq_field, pd.eq_field_len) : newSVpvs(""));
40 13 ▶ hv_stores(r, "eq_value", pd.have_eq
Branch: 1 branch
BranchTrueFalseTotal
hv_stores(r, "eq_value", pd.have_eq 2 11 13
41 ? newSVpvn(pd.eq_val, pd.eq_val_len) : newSVpvs(""));
42 13 ▶ hv_stores(r, "min_duration", pd.have_min_dur
Branch: 1 branch
BranchTrueFalseTotal
hv_stores(r, "min_duration", pd.have_min_dur 1 12 13
43 ? po_u64_to_sv(pd.min_dur) : newSViv(0));
44 13 po_query_free(&q);
45 13 ▶ mXPUSHs(newRV_noinc((SV *)r));
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(newRV_noinc((SV *)r)); 0 13 13
46 }
47  
48 # Prune a real segment with a real query, and report what was NOT read.
49 void
50 posc_prune(SV *path, SV *query, SV *opts)
51 PPCODE:
52 {
53 po_query q;
54 po_plan plan;
55 po_pushdown pd;
56 po_result res;
57 po_seg_r s;
58 po_prune_stats st;
59 STRLEN plen, qlen;
60 619 ▶ const char *pp = SvPV(path, plen);
Branch: 1 branch
BranchTrueFalseTotal
const char *pp = SvPV(path, plen); 619 0 619
61 619 const char *qp = SvPV(query, qlen);
62 619 HV *r = newHV();
63 619 HV *o = NULL;
64 619 int have_stream = 0;
65 619 po_u64 stream = 0;
66 619 int nm = 0, nl = 0, nt = 0, wanted;
67  
68 619 ▶ if (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) { 619 0 619
if (SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) { 619 0 619
69 SV **f;
70 619 o = (HV *)SvRV(opts);
71 619 ▶ if ((f = hv_fetchs(o, "stream", 0)) && SvOK(*f)) {
Branch: 2 branches
BranchTrueFalseTotal
if ((f = hv_fetchs(o, "stream", 0)) && SvOK(*f)) { 1 618 619
if ((f = hv_fetchs(o, "stream", 0)) && SvOK(*f)) { 1 0 1
72 1 have_stream = 1;
73 1 (void)po_sv_to_u64(aTHX_ *f, &stream);
74 }
75 }
76  
77 619 ▶ if (!po_parse(&q, qp, (size_t)qlen)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!po_parse(&q, qp, (size_t)qlen)) { 0 619 619
78 0 hv_stores(r, "ok", newSViv(0));
79 0 hv_stores(r, "error", newSVpv(q.err, 0));
80 0 ▶ mXPUSHs(newRV_noinc((SV *)r));
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(newRV_noinc((SV *)r)); 0 0 0
81 0 XSRETURN(1);
82 }
83 619 ▶ if (!po_plan_build(&plan, &q, NULL)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!po_plan_build(&plan, &q, NULL)) { 0 619 619
84 0 hv_stores(r, "ok", newSViv(0));
85 0 hv_stores(r, "error", newSVpv(plan.err, 0));
86 0 po_query_free(&q);
87 0 ▶ mXPUSHs(newRV_noinc((SV *)r));
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(newRV_noinc((SV *)r)); 0 0 0
88 0 XSRETURN(1);
89 }
90 619 po_pushdown_build(&pd, &plan);
91 619 po_result_init(&res);
92 619 memset(&st, 0, sizeof(st));
93  
94 619 ▶ if (!po_seg_open(&s, pp)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!po_seg_open(&s, pp)) { 0 619 619
95 0 hv_stores(r, "ok", newSViv(0));
96 0 hv_stores(r, "error", newSVpvs("cannot open segment"));
97 0 po_query_free(&q);
98 0 ▶ mXPUSHs(newRV_noinc((SV *)r));
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(newRV_noinc((SV *)r)); 0 0 0
99 0 XSRETURN(1);
100 }
101  
102 619 wanted = po_scan_segment_wanted(&s, &pd, &res);
103 619 ▶ if (wanted) {
Branch: 1 branch
BranchTrueFalseTotal
if (wanted) { 618 1 619
104 po_mchunk_ref mc[256];
105 po_lblock_ref lb[256];
106 const po_tsummary *ts[256];
107 618 nm = po_scan_metric_chunks(&s, &pd, mc, 256, &res);
108 618 nl = po_scan_log_blocks(&s, &pd, have_stream, stream,
109 lb, 256, &res, &st);
110 618 nt = po_scan_trace_summaries(&s, &pd, ts, 256, &res);
111 }
112  
113 619 hv_stores(r, "ok", newSViv(1));
114 619 hv_stores(r, "segment_wanted", newSViv(wanted));
115 619 hv_stores(r, "blocks", po_u64_to_sv(res.blocks));
116 619 hv_stores(r, "blocks_skipped", po_u64_to_sv(res.blocks_skipped));
117 619 hv_stores(r, "metric_chunks", newSViv(nm));
118 619 hv_stores(r, "log_blocks", newSViv(nl));
119 619 hv_stores(r, "traces", newSViv(nt));
120 619 hv_stores(r, "considered", newSVuv(st.considered));
121 619 hv_stores(r, "skipped_stream", newSVuv(st.skipped_stream));
122 619 hv_stores(r, "skipped_time", newSVuv(st.skipped_time));
123 619 hv_stores(r, "skipped_bloom", newSVuv(st.skipped_bloom));
124  
125 619 po_seg_close(&s);
126 619 po_result_free(&res);
127 619 po_query_free(&q);
128 619 ▶ mXPUSHs(newRV_noinc((SV *)r));
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(newRV_noinc((SV *)r)); 0 619 619
129 }
« include/punk_observe/po_attr.h ↑ Summary xs/contracts.xs »