Esempio n. 1
0
static enum interval_iter cb(struct interval_node *n, void *args)
{
        struct it_node *node = (struct it_node *)n;
        static int count = 1;

        if (node->hit == 1) {
                error("A duplicate node "__S" access found\n",
                       __F(&n->in_extent));
                return INTERVAL_ITER_CONT;
        }

        if (node->valid == 0) {
                error("A deleted node "__S" being accessed\n",
                       __F(&n->in_extent));
                return INTERVAL_ITER_STOP;
        }

        if (count++ == 8) {
                dprintf("\n");
                count = 1;
        }
        dprintf(""__S" ", __F(&n->in_extent));
        fflush(stdout);

        node->hit = 1;
        return INTERVAL_ITER_CONT;
}
void UserVarEvent::init() {
  rb_cBinlogUserVarEvent = rb_define_class_under(rb_mBinlog, "UserVarEvent", rb_cBinlogEvent);
  rb_define_alloc_func(rb_cBinlogUserVarEvent, &alloc);

  Event::init(rb_cBinlogUserVarEvent);

  rb_define_method(rb_cBinlogUserVarEvent, "name",     __F(&get_name),    0);
  rb_define_method(rb_cBinlogUserVarEvent, "is_null",  __F(&get_is_null), 0);
  rb_define_method(rb_cBinlogUserVarEvent, "var_type", __F(&get_type),    0);
  rb_define_method(rb_cBinlogUserVarEvent, "charset",  __F(&get_charset), 0);
  rb_define_method(rb_cBinlogUserVarEvent, "value",    __F(&get_value),   0);
}
Esempio n. 3
0
/* sanity test is tightly coupled with implementation, so when you changed
 * the interval tree implementation, change this code also. */
static enum interval_iter sanity_cb(struct interval_node *node, void *args)
{
        __u64 max_high = node->in_max_high;
        struct interval_node *tmp, *parent;
        int left = 1, has = 0, nr = 0;

        parent = node->in_parent;
        node->in_parent = NULL;
        interval_for_each(tmp, node) {
                if ((left && node_compare(tmp, node) > 0) ||
                    (!left && node_compare(tmp, node) < 0))
                        error("interval tree sanity test\n");

                if (tmp->in_max_high > max_high) {
                        dprintf("max high sanity check, max_high is %llu,"
                                "child max_high: %llu"__S"\n",
                                max_high, tmp->in_max_high,
                                __F(&tmp->in_extent));
                        goto err;
                } else if (tmp->in_max_high == max_high) {
                        has = 1;
                }

                if (tmp == node) {
                        left = 0;
                        continue;
                }
        }

        if (!has) {
                int count;
err:
                count = 1;
                dprintf("node"__S":%llu Child list:\n",
                        node->in_extent.start,
                        node->in_extent.end,
                        node->in_max_high);

                interval_for_each(tmp, node) {
                        dprintf(""__S":%llu ",
                                __F(&tmp->in_extent),
                                tmp->in_max_high);
                        if (count++ == 8) {
                                dprintf("\n");
                                count = 1;
                        }
                }
Esempio n. 4
0
static int it_test_find(struct interval_node *root)
{
        int idx;
        struct interval_node_extent *ext;

        dprintf("\ninterval_find testing start ..\n");
        for (idx = 0; idx < it_count; idx++) {
                if (it_array[idx].valid == 0)
                        continue;

                ext = &it_array[idx].node.in_extent;
                dprintf("Try to find "__S"\n", __F(ext));
                if (!interval_find(root, ext))
                        error("interval_find, try to find "__S"\n", __F(ext));
        }
        return 0;
}
Esempio n. 5
0
static int it_test_search(struct interval_node *root)
{
        struct it_node *n;
        struct interval_node_extent ext;
        int times = 10, i, err = 0;

        while (times--) {
                it_test_clear();
                ext.start = (random() % max_count) & ALIGN_MASK;
                ext.end = random() % (max_count - ext.start + 2) + ext.start;
                ext.end &= ALIGN_MASK;
                if (ext.end > max_count)
                        ext.end = max_count;

                dprintf("\n\nSearching the node overlapped "__S" ..\n",
                        __F(&ext));

                interval_search(root, &ext, cb, NULL);

                dprintf("\nverifing ...");

                /* verify */
                for (i = 0; i < it_count; i++) {
                        n = &it_array[i];
                        if (n->valid == 0)
                                continue;

                        if (extent_overlapped(&ext, &n->node.in_extent) &&
                            n->hit == 0)
                                error("node "__S" overlaps" __S","
                                      "but never to be hit.\n",
                                      __F(&n->node.in_extent),
                                      __F(&ext));

                        if (!extent_overlapped(&ext, &n->node.in_extent) &&
                            n->hit)
                                error("node "__S" overlaps" __S", but hit.\n",
                                      __F(&n->node.in_extent),
                                      __F(&ext));
                }
                if (err) error("search error\n");
                dprintf("ok.\n");
        }

        return 0;
}
void Event::init(VALUE clazz) {
  rb_define_method(clazz, "marker",        __F(&get_marker),        0);
  rb_define_method(clazz, "timestamp",     __F(&get_timestamp),     0);
  rb_define_method(clazz, "type_code",     __F(&get_type_code),     0);
  rb_define_method(clazz, "server_id",     __F(&get_server_id),     0);
  rb_define_method(clazz, "event_length",  __F(&get_event_length),  0);
  rb_define_method(clazz, "next_position", __F(&get_next_position), 0);
  rb_define_method(clazz, "flags",         __F(&get_flags),         0);
  rb_define_method(clazz, "event_type",    __F(&get_event_type),    0);
}
void QueryEvent::init() {
  rb_cBinlogQueryEvent = rb_define_class_under(rb_mBinlog, "QueryEvent", rb_cBinlogEvent);
  rb_define_alloc_func(rb_cBinlogQueryEvent, &alloc);

  Event::init(rb_cBinlogQueryEvent);

  rb_define_method(rb_cBinlogQueryEvent, "thread_id",  __F(&get_thread_id),  0);
  rb_define_method(rb_cBinlogQueryEvent, "exec_time",  __F(&get_exec_time),  0);
  rb_define_method(rb_cBinlogQueryEvent, "error_code", __F(&get_error_code), 0);
  rb_define_method(rb_cBinlogQueryEvent, "variables", __F(&get_variables), 0);
  rb_define_method(rb_cBinlogQueryEvent, "db_name",    __F(&get_db_name),    0);
  rb_define_method(rb_cBinlogQueryEvent, "query",      __F(&get_query),      0);
}
Esempio n. 8
0
static int it_test_iterate(struct interval_node *root)
{
        int i;

        dprintf("\n\nIterate testing start..\n");

        it_test_clear();
        interval_iterate(root, cb, NULL);

        /* verify */
        for (i = 0; i < it_count; i++) {
                if (it_array[i].valid == 0)
                        continue;
                if (it_array[i].hit == 0)
                        error("Node "__S" is not accessed\n",
                              __F(&it_array[i].node.in_extent));
        }

        return 0;
}
void RowEvent::init() {
  rb_cBinlogRowEvent = rb_define_class_under(rb_mBinlog, "RowEvent", rb_cBinlogEvent);
  rb_define_alloc_func(rb_cBinlogRowEvent, &alloc);

  Event::init(rb_cBinlogRowEvent);

  rb_define_method(rb_cBinlogRowEvent, "table_id",                 __F(&get_table_id),             0);
  rb_define_method(rb_cBinlogRowEvent, "db_name",                  __F(&get_db_name),              0);
  rb_define_method(rb_cBinlogRowEvent, "table_name",               __F(&get_table_name),           0);
  rb_define_method(rb_cBinlogRowEvent, "columns",                  __F(&get_column_types),         0);
  rb_define_method(rb_cBinlogRowEvent, "flags",                    __F(&get_flags),                0);
  rb_define_method(rb_cBinlogRowEvent, "columns_len",              __F(&get_columns_len),          0);
  rb_define_method(rb_cBinlogRowEvent, "null_bits_len",            __F(&get_null_bits_len),        0);
  rb_define_method(rb_cBinlogRowEvent, "raw_columns_before_image", __F(&get_columns_before_image), 0);
  rb_define_method(rb_cBinlogRowEvent, "raw_used_columns",         __F(&get_used_columns),         0);
  rb_define_method(rb_cBinlogRowEvent, "raw_row",                  __F(&get_row),                  0);
  rb_define_method(rb_cBinlogRowEvent, "rows",                     __F(&get_rows),                 0);
}