cthriftglibflume

GLib-GObject-Warning when creating gobject


I am trying to create a flume-thrift client in c (c_glib) but have trouble creating the gobject that shall be sent to the server. I get the following error at the line in main.c:

`GLib-GObject-WARNING **: IA__g_object_new_valist: object class `ThriftFlumeEventType' has no property named `timestamp'`

The code in flume_types.h and flume_types.c is autogenerated from thrift. Tell me if you need to see more code. I am thankful for all the help I can get!

Parts of the code in flume_types.h:

struct _ThriftFlumeEvent
{ 
  ThriftStruct parent;

  /* public */
  gint64 timestamp;
  gboolean __isset_timestamp;
  Priority priority;
  gboolean __isset_priority;
  GByteArray * body;
  gboolean __isset_body;
  gint64 nanos;
  gboolean __isset_nanos;
  gchar * host;
  gboolean __isset_host;
  GHashTable * fields;
  gboolean __isset_fields;
};
typedef struct _ThriftFlumeEvent ThriftFlumeEvent;


GType thrift_flume_event_get_type (void);
#define TYPE_THRIFT_FLUME_EVENT (thrift_flume_event_get_type())

Parts of the code in flume_types.c:

void 
thrift_flume_event_instance_init (ThriftFlumeEvent * object)
{
  printf("thrift_flume_event_instance_init");

  /* satisfy -Wall */
  THRIFT_UNUSED_VAR (object);
  object->timestamp = 0;
  object->__isset_timestamp = FALSE;
  object->__isset_priority = FALSE;
  object->body = NULL;
  object->__isset_body = FALSE;
  object->nanos = 0;
  object->__isset_nanos = FALSE;
  object->host = NULL;
  object->__isset_host = FALSE;
  object->fields = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
  object->__isset_fields = FALSE;
}

GType
thrift_flume_event_get_type (void)
{
  static GType type = 0;

  if (type == 0)
  {
    static const GTypeInfo type_info =
    {
      sizeof (ThriftFlumeEventClass),
      NULL, /* base_init */
      NULL, /* base_finalize */
      (GClassInitFunc) thrift_flume_event_class_init,
      NULL, /* class_finalize */
      NULL, /* class_data */
      sizeof (ThriftFlumeEvent),
      0, /* n_preallocs */
      (GInstanceInitFunc) thrift_flume_event_instance_init,
      NULL, /* value_table */
    };

    type = g_type_register_static (THRIFT_TYPE_STRUCT,
                                   "ThriftFlumeEventType",
                                   &type_info, 0);
    type.timestamp;
  }

  return type;
}

Parts of the code in main.c:

  gpointer eventObj = g_object_new(TYPE_THRIFT_FLUME_EVENT,
                                     "timestamp", 0,
                                     "__isset_timestamp", 0,
                                     "priority", 0,
                                     "__isset_priority", 0,
                                     "body", 0,
                                     "__isset_body", 0,
                                     "nanos", 0,
                                     "__isset_nanos", 0,
                                     "fields", 0,
                                     "__isset_fields", 0,
                                     0);

Solution

  • This was the solution to the problem:

    ThriftFlumeEvent *event = g_object_new(TYPE_THRIFT_FLUME_EVENT, 0);
    event->timestamp = (gint64)t_stamp.tv_sec * 1000;
    event->__isset_timestamp = TRUE;
    event->priority = priority;
    event->__isset_priority = TRUE;
    ...