Add bt_ctf_iter_create_intersect to CTF iterator API
authorAntoine Busque <abusque@efficios.com>
Wed, 6 Apr 2016 19:19:02 +0000 (15:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 2 May 2016 16:46:13 +0000 (12:46 -0400)
This new method allows direct creation of a `bt_ctf_iter`
corresponding to the intersection of streams in a given trace
collection. Adding it to the CTF iterator API allows reuse by both the
converter and (eventually) bindings.

Signed-off-by: Antoine Busque <abusque@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
converter/babeltrace.c
formats/ctf/iterator.c
include/babeltrace/ctf/iterator.h

index e5aaab6bddece0ba8b4ee62e093beeecfd961a0e..f437f4f4692ca269442cc04241d7a3a0efd4ef8a 100644 (file)
@@ -638,42 +638,6 @@ end:
        return ret;
 }
 
-static
-struct bt_ctf_iter *iter_create_intersect(struct bt_context *ctx,
-               struct bt_iter_pos **inter_begin_pos,
-               struct bt_iter_pos **inter_end_pos)
-{
-       uint64_t begin = 0, end = ULLONG_MAX;
-       int ret;
-
-       ret = ctf_find_packets_intersection(ctx, &begin, &end);
-       if (ret == 1) {
-               fprintf(stderr, "[error] No intersection found between trace files.\n");
-               ret = -1;
-               goto error;
-       } else if (ret != 0) {
-               goto error;
-       }
-       *inter_begin_pos = bt_iter_create_time_pos(NULL, begin);
-       if (!(*inter_begin_pos)) {
-               goto error;
-       }
-       *inter_end_pos = bt_iter_create_time_pos(NULL, end);
-       if (!(*inter_end_pos)) {
-               goto error;
-       }
-
-       /*
-        * bt_ctf_iter does not take ownership of begin and end positions,
-        * so we return them to the caller who must still assume their ownership
-        * until the iterator is destroyed.
-        */
-       return bt_ctf_iter_create(ctx, *inter_begin_pos,
-                       *inter_end_pos);
-error:
-       return NULL;
-}
-
 static
 int convert_trace(struct bt_trace_descriptor *td_write,
                  struct bt_context *ctx)
@@ -692,7 +656,7 @@ int convert_trace(struct bt_trace_descriptor *td_write,
        }
 
        if (opt_stream_intersection) {
-               iter = iter_create_intersect(ctx, &begin_pos, &end_pos);
+               iter = bt_ctf_iter_create_intersect(ctx, &begin_pos, &end_pos);
        } else {
                begin_pos = bt_iter_create_time_pos(NULL, 0);
                begin_pos->type = BT_SEEK_BEGIN;
index e5d32a890b503220a9ecefde2c31ae8464b12030..6f8eb88a9de7b769817de518a1abf56db9e7f115 100644 (file)
@@ -63,6 +63,41 @@ struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
        return iter;
 }
 
+struct bt_ctf_iter *bt_ctf_iter_create_intersect(struct bt_context *ctx,
+               struct bt_iter_pos **inter_begin_pos,
+               struct bt_iter_pos **inter_end_pos)
+{
+       uint64_t begin = 0, end = ULLONG_MAX;
+       int ret;
+
+       ret = ctf_find_packets_intersection(ctx, &begin, &end);
+       if (ret == 1) {
+               fprintf(stderr, "[error] No intersection found between trace files.\n");
+               goto error;
+       } else if (ret != 0) {
+               goto error;
+       }
+       *inter_begin_pos = bt_iter_create_time_pos(NULL, begin);
+       if (!(*inter_begin_pos)) {
+               goto error;
+       }
+       *inter_end_pos = bt_iter_create_time_pos(NULL, end);
+       if (!(*inter_end_pos)) {
+               goto error;
+       }
+
+       /*
+        * bt_ctf_iter does not take ownership of begin and end positions,
+        * so we return them to the caller who must still assume their ownership
+        * until the iterator is destroyed.
+        */
+       return bt_ctf_iter_create(ctx, *inter_begin_pos,
+                       *inter_end_pos);
+error:
+       return NULL;
+}
+
+
 void bt_ctf_iter_destroy(struct bt_ctf_iter *iter)
 {
        struct bt_stream_callbacks *bt_stream_cb;
index ec6aac776e99e80cdb25cbe97463872ab722fe3f..5b2a281d127ddbd2ba60a9b7ac4cf692971ee16d 100644 (file)
@@ -63,6 +63,22 @@ struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
                const struct bt_iter_pos *begin_pos,
                const struct bt_iter_pos *end_pos);
 
+ /*
+ * bt_ctf_iter_create_intersect - Allocate a CTF trace collection
+ * iterator corresponding to the timerange when all streams are active
+ * simultaneously.
+ *
+ * On success, return a pointer to the newly allocated iterator. The
+ * out parameters inter_begin_pos and inter_end_pos are also set to
+ * correspond to the beginning and end of the intersection,
+ * respectively.
+ *
+ * On failure, return NULL.
+ */
+struct bt_ctf_iter *bt_ctf_iter_create_intersect(struct bt_context *ctx,
+               struct bt_iter_pos **inter_begin_pos,
+               struct bt_iter_pos **inter_end_pos);
+
 /*
  * bt_ctf_get_iter - get iterator from ctf iterator.
  */
This page took 0.039055 seconds and 4 git commands to generate.