[prev in list] [next in list] [prev in thread] [next in thread]
List: avro-commits
Subject: svn commit: r947299 - in /avro/trunk/lang/c: examples/ src/ tests/
From: brucem () apache ! org
Date: 2010-05-22 14:15:55
Message-ID: 20100522141556.3BB1923889E0 () eris ! apache ! org
[Download RAW message or body]
Author: brucem
Date: Sat May 22 14:15:55 2010
New Revision: 947299
URL: http://svn.apache.org/viewvc?rev=947299&view=rev
Log:
AVRO-464: Work in progress on performance enhancements, including atom-based API, \
changing structure of records and arrays to not use hash tables as much. This changes \
the API incompatibly!
Added:
avro/trunk/lang/c/src/atom_table.c
avro/trunk/lang/c/src/avro.c
Modified:
avro/trunk/lang/c/examples/quickstop.c
avro/trunk/lang/c/src/CMakeLists.txt
avro/trunk/lang/c/src/Makefile.am
avro/trunk/lang/c/src/avro.h
avro/trunk/lang/c/src/datum.c
avro/trunk/lang/c/src/datum.h
avro/trunk/lang/c/src/datum_equal.c
avro/trunk/lang/c/src/datum_size.c
avro/trunk/lang/c/src/datum_validate.c
avro/trunk/lang/c/src/datum_write.c
avro/trunk/lang/c/src/schema.c
avro/trunk/lang/c/src/schema.h
avro/trunk/lang/c/src/schema_equal.c
avro/trunk/lang/c/tests/generate_interop_data.c
avro/trunk/lang/c/tests/test_avro_data.c
avro/trunk/lang/c/tests/test_avro_schema.c
avro/trunk/lang/c/tests/test_interop_data.c
Modified: avro/trunk/lang/c/examples/quickstop.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/examples/quickstop.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/examples/quickstop.c (original)
+++ avro/trunk/lang/c/examples/quickstop.c Sat May 22 14:15:55 2010
@@ -24,6 +24,15 @@
avro_schema_t person_schema;
int64_t id = 0;
+struct atom_holder {
+ avro_atom_t id;
+ avro_atom_t first;
+ avro_atom_t last;
+ avro_atom_t phone;
+ avro_atom_t age;
+};
+struct atom_holder atoms;
+
/* A simple schema for our tutorial */
#define PERSON_SCHEMA \
"{\"type\":\"record\",\
@@ -46,6 +55,24 @@ void init_schema(void)
}
}
+void init_atoms(void)
+{
+ atoms.id = avro_atom_add("ID");
+ atoms.first = avro_atom_add("First");
+ atoms.last = avro_atom_add("Last");
+ atoms.phone = avro_atom_add("Phone");
+ atoms.age = avro_atom_add("Age");
+}
+
+void cleanup_atoms(void)
+{
+ avro_atom_decref(atoms.id);
+ avro_atom_decref(atoms.first);
+ avro_atom_decref(atoms.last);
+ avro_atom_decref(atoms.phone);
+ avro_atom_decref(atoms.age);
+}
+
/* Create a datum to match the person schema and save it */
void
add_person(avro_file_writer_t db, const char *first, const char *last,
@@ -59,11 +86,11 @@ add_person(avro_file_writer_t db, const
avro_datum_t age_datum = avro_int32(age);
avro_datum_t phone_datum = avro_string(phone);
- if (avro_record_set(person, "ID", id_datum)
- || avro_record_set(person, "First", first_datum)
- || avro_record_set(person, "Last", last_datum)
- || avro_record_set(person, "Age", age_datum)
- || avro_record_set(person, "Phone", phone_datum)) {
+ if (avro_record_set(person, atoms.id, id_datum)
+ || avro_record_set(person, atoms.first, first_datum)
+ || avro_record_set(person, atoms.last, last_datum)
+ || avro_record_set(person, atoms.age, age_datum)
+ || avro_record_set(person, atoms.phone, phone_datum)) {
fprintf(stderr, "Unable to create Person datum structure");
exit(EXIT_FAILURE);
}
@@ -98,23 +125,23 @@ int print_person(avro_file_reader_t db,
avro_datum_t id_datum, first_datum, last_datum, phone_datum,
age_datum;
- if (avro_record_get(person, "ID", &id_datum) == 0) {
+ if (avro_record_get(person, atoms.id, &id_datum) == 0) {
avro_int64_get(id_datum, &i64);
fprintf(stdout, "%"PRId64" | ", i64);
}
- if (avro_record_get(person, "First", &first_datum) == 0) {
+ if (avro_record_get(person, atoms.first, &first_datum) == 0) {
avro_string_get(first_datum, &p);
fprintf(stdout, "%15s | ", p);
}
- if (avro_record_get(person, "Last", &last_datum) == 0) {
+ if (avro_record_get(person, atoms.last, &last_datum) == 0) {
avro_string_get(last_datum, &p);
fprintf(stdout, "%15s | ", p);
}
- if (avro_record_get(person, "Phone", &phone_datum) == 0) {
+ if (avro_record_get(person, atoms.phone, &phone_datum) == 0) {
avro_string_get(phone_datum, &p);
fprintf(stdout, "%15s | ", p);
}
- if (avro_record_get(person, "Age", &age_datum) == 0) {
+ if (avro_record_get(person, atoms.age, &age_datum) == 0) {
avro_int32_get(age_datum, &i32);
fprintf(stdout, "%d", i32);
}
@@ -135,9 +162,16 @@ int main(void)
int64_t i;
const char *dbname = "quickstop.db";
+ avro_init();
+
+ /* Initialize our atoms */
+ init_atoms();
+
/* Initialize the schema structure from JSON */
init_schema();
+ fprintf(stdout, "Let's create our initial database\n");
+
/* Delete the database if it exists */
unlink(dbname);
/* Create a new database */
@@ -196,5 +230,8 @@ int main(void)
/* We don't need this schema anymore */
avro_schema_decref(person_schema);
+
+ cleanup_atoms();
+ avro_shutdown();
return 0;
}
Modified: avro/trunk/lang/c/src/CMakeLists.txt
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/CMakeLists.txt?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/CMakeLists.txt (original)
+++ avro/trunk/lang/c/src/CMakeLists.txt Sat May 22 14:15:55 2010
@@ -18,6 +18,8 @@
#
set(AVRO_SRC
+ atom_table.c
+ avro.c
avro.h
avro_private.h
datafile.c
Modified: avro/trunk/lang/c/src/Makefile.am
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/Makefile.am?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/Makefile.am (original)
+++ avro/trunk/lang/c/src/Makefile.am Sat May 22 14:15:55 2010
@@ -9,7 +9,7 @@ lib_LTLIBRARIES = libavro.la
libavro_la_SOURCES = st.c st.h schema.c schema.h schema_equal.c \
datum.c datum_equal.c datum_validate.c datum_read.c datum_skip.c datum_write.c \
datum_size.c datum.h \ io.c dump.c dump.h encoding_binary.c \
-avro_private.h encoding.h datafile.c
+avro_private.h encoding.h datafile.c atom_table.c avro.c
libavro_la_LIBADD = $(top_builddir)/jansson/src/.libs/libjansson.a
libavro_la_LDFLAGS = \
-version-info $(LIBAVRO_VERSION) \
Added: avro/trunk/lang/c/src/atom_table.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/atom_table.c?rev=947299&view=auto
==============================================================================
--- avro/trunk/lang/c/src/atom_table.c (added)
+++ avro/trunk/lang/c/src/atom_table.c Sat May 22 14:15:55 2010
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+#include "avro_private.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct avro_atom_entry_t
+{
+ char *str;
+ int64_t hash_value;
+ int32_t length;
+ int32_t next;
+ int32_t refcount;
+} avro_atom_entry_t;
+
+struct avro_atom_table_t_
+{
+ avro_atom_entry_t *entries;
+ int32_t *hashtab;
+ int32_t size;
+ int32_t count;
+ int32_t freelist;
+};
+
+avro_atom_table_t g_avro_atom_table = NULL;
+
+// ELF hash
+static int32_t _atom_string_hash(const char *string)
+{
+ register int c;
+ register unsigned int h = 0, g;
+
+ while ((c = *string++) != '\0') {
+ h = (h << 4) + c;
+ if ((g = (h & 0xF0000000))) {
+ h ^= g >> 24;
+ }
+ h &= ~g;
+ }
+ return h;
+}
+
+avro_atom_table_t avro_atom_table_create(int32_t size)
+{
+ avro_atom_table_t table;
+ int32_t i;
+
+ table = (avro_atom_table_t)malloc(sizeof(struct avro_atom_table_t_));
+ table->size = size;
+ table->count = 0;
+ table->entries = malloc(sizeof(avro_atom_entry_t) * table->size);
+ table->hashtab = malloc(sizeof(int32_t) * table->size);
+ table->freelist = 0;
+
+ memset(table->entries, 0, sizeof(avro_atom_entry_t) * table->size);
+ memset(table->hashtab, -1, sizeof(int32_t) * table->size);
+
+ for (i = 0; i < table->size; i++) {
+ table->entries[i].next = i + 1;
+ }
+
+ table->entries[table->size - 1].next = -1;
+
+ return table;
+}
+
+void avro_atom_table_destroy(avro_atom_table_t table)
+{
+ int32_t i;
+ for (i = 0; i < table->size; i++) {
+ if (table->entries[i].str) {
+ free(table->entries[i].str);
+ }
+ }
+ free(table->entries);
+ free(table->hashtab);
+ free(table);
+}
+
+void avro_atom_table_dump(avro_atom_table_t table)
+{
+ int32_t atom;
+ printf("Atom table dump:\n");
+ for (atom = 0; atom < table->size; atom++) {
+ avro_atom_entry_t *entry = &(table->entries[atom]);
+ if (entry->str) {
+ printf(" %d - %s - %d refs\n", atom, entry->str, entry->refcount);
+ }
+ }
+ printf("--\n");
+}
+
+avro_atom_t avro_atom_table_add(avro_atom_table_t table, const char *str)
+{
+ return avro_atom_table_add_length(table, str, strlen(str));
+}
+
+avro_atom_t avro_atom_table_add_length(avro_atom_table_t table, const char *str, \
int32_t length) +{
+ int32_t hash_value = _atom_string_hash(str);
+ int32_t ind, new_size, old_size;
+ avro_atom_t atom;
+ avro_atom_entry_t *entry;
+
+ /* Look for an existing identifier. */
+ atom = table->hashtab[hash_value % table->size];
+ while (atom != -1) {
+ if (table->entries[atom].hash_value == hash_value &&
+ table->entries[atom].length == length &&
+ strcmp(table->entries[atom].str, str) == 0) {
+ table->entries[atom].refcount++;
+ return atom;
+ }
+ atom = table->entries[atom].next;
+ }
+
+ /* Check if we have to resize the table. */
+ if (table->freelist == -1) {
+ int32_t i;
+
+ /* Allocate new space for table. */
+ if (table->size > 4096) {
+ new_size = table->size + 4096;
+ } else {
+ new_size = table->size * 2;
+ }
+
+ table->entries = realloc(table->entries, sizeof(avro_atom_entry_t) * new_size);
+ table->hashtab = realloc(table->hashtab, sizeof(int32_t) * new_size);
+
+ /* Make new string of freelist. */
+ memset(&(table->entries[table->size]), 0, sizeof(avro_atom_entry_t) * \
(new_size-table->size)); + for (ind = table->size; ind < new_size - 1; ind++) {
+ table->entries[ind].next = ind + 1;
+ }
+ table->entries[ind].next = -1;
+ table->freelist = table->size;
+
+ old_size = table->size;
+ table->size = new_size;
+
+ memset(table->hashtab, -1, sizeof(int64_t) * new_size);
+ for (i = 0; i < old_size; i++) {
+ if (table->entries[i].str) {
+ int32_t bucket = table->entries[i].hash_value % table->size;
+ table->entries[i].next = table->hashtab[bucket];
+ table->hashtab[bucket] = i;
+ }
+ }
+ }
+
+ /* Use one off of the free list */
+ atom = table->freelist;
+ entry = &(table->entries[atom]);
+ table->freelist = entry->next;
+ entry->str = strdup(str);
+ entry->length = length;
+ entry->refcount = 1;
+ entry->hash_value = hash_value;
+ /* Link into the hash chain */
+ entry->next = table->hashtab[hash_value % table->size];
+ table->hashtab[hash_value % table->size] = atom;
+
+ table->count++;
+
+ return atom;
+}
+
+avro_atom_t avro_atom_table_lookup(avro_atom_table_t table, const char *str, int32_t \
length) +{
+ int32_t hash_value = _atom_string_hash(str);
+ avro_atom_t atom;
+
+ /* Look for an existing identifier. */
+ atom = table->hashtab[hash_value % table->size];
+ while (atom != -1) {
+ if (table->entries[atom].hash_value == hash_value &&
+ table->entries[atom].length == length &&
+ strcmp(table->entries[atom].str, str) == 0) {
+ table->entries[atom].refcount++;
+ return atom;
+ }
+ atom = table->entries[atom].next;
+ }
+ return -1;
+}
+
+int avro_atom_table_describe(avro_atom_table_t table, avro_atom_t atom, const char \
**s, int32_t *length) +{
+ if (NULL != table->entries[atom].str) {
+ *s = table->entries[atom].str;
+ *length = table->entries[atom].length;
+ }
+ return -1;
+}
+
+const char *avro_atom_table_to_string(avro_atom_table_t table, avro_atom_t atom)
+{
+ if (NULL != table->entries[atom].str) {
+ return table->entries[atom].str;
+ }
+ return "(invalid atom)";
+}
+
+avro_atom_t avro_atom_table_incref(avro_atom_table_t table, avro_atom_t atom)
+{
+ table->entries[atom].refcount++;
+ return atom;
+}
+
+void avro_atom_table_decref(avro_atom_table_t table, avro_atom_t atom)
+{
+ int32_t bucket, *p;
+
+ table->entries[atom].refcount--;
+
+ if (0 == table->entries[atom].refcount) {
+ /* Get the hash table thread for this entry. */
+ bucket = _atom_string_hash(table->entries[atom].str) % table->size;
+
+ /* Free the string. */
+ free(table->entries[atom].str);
+ table->entries[atom].str = NULL;
+ table->entries[atom].length = 0;
+ table->entries[atom].hash_value = 0;
+
+ /* Find the pointer to this entry. */
+ for (p = &table->hashtab[bucket]; p && *p != atom; p = &table->entries[*p].next);
+
+ /* Remove this entry and add it to freelist. */
+ *p = table->entries[atom].next;
+ table->entries[atom].next = table->freelist;
+ table->freelist = atom;
+ table->count--;
+ }
+}
+
Added: avro/trunk/lang/c/src/avro.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro.c?rev=947299&view=auto
==============================================================================
--- avro/trunk/lang/c/src/avro.c (added)
+++ avro/trunk/lang/c/src/avro.c Sat May 22 14:15:55 2010
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+#include "avro_private.h"
+
+// TODO: Make these configurable in the future somehow
+#define INITIAL_ATOM_TABLE_SIZE 512
+
+void avro_init(void)
+{
+ if (NULL == g_avro_atom_table) {
+ g_avro_atom_table = avro_atom_table_create(INITIAL_ATOM_TABLE_SIZE);
+ }
+}
+
+void avro_shutdown(void)
+{
+ if (NULL != g_avro_atom_table) {
+ avro_atom_table_destroy(g_avro_atom_table);
+ g_avro_atom_table = NULL;
+ }
+}
+
Modified: avro/trunk/lang/c/src/avro.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro.h?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro.h (original)
+++ avro/trunk/lang/c/src/avro.h Sat May 22 14:15:55 2010
@@ -26,6 +26,8 @@ extern "C" {
#include <stdio.h>
#include <stdint.h>
+typedef int32_t avro_atom_t;
+
enum avro_type_t {
AVRO_STRING,
AVRO_BYTES,
@@ -94,6 +96,12 @@ typedef struct avro_reader_t_ *avro_read
typedef struct avro_writer_t_ *avro_writer_t;
/*
+ * Initialize the underlying library and properly close things down
+ */
+void avro_init(void);
+void avro_shutdown(void);
+
+/*
* schema
*/
typedef struct avro_obj_t *avro_schema_t;
@@ -109,7 +117,7 @@ avro_schema_t avro_schema_null(void);
avro_schema_t avro_schema_record(const char *name, const char *space);
avro_schema_t avro_schema_record_field_get(const avro_schema_t
- record, const char *field_name);
+ record, avro_atom_t field_name);
int avro_schema_record_field_append(const avro_schema_t record,
const char *field_name,
const avro_schema_t type);
@@ -205,7 +213,7 @@ int avro_double_get(avro_datum_t datum,
int avro_boolean_get(avro_datum_t datum, int8_t * i);
int avro_fixed_get(avro_datum_t datum, char **bytes, int64_t * size);
-int avro_record_get(const avro_datum_t record, const char *field_name,
+int avro_record_get(const avro_datum_t record, avro_atom_t field_name,
avro_datum_t * value);
int avro_map_get(const avro_datum_t datum, const char *key,
avro_datum_t * value);
@@ -234,7 +242,7 @@ int avro_givefixed_set(avro_datum_t datu
int avro_wrapfixed_set(avro_datum_t datum, const char *bytes,
const int64_t size);
-int avro_record_set(const avro_datum_t record, const char *field_name,
+int avro_record_set(const avro_datum_t record, avro_atom_t field_name,
const avro_datum_t value);
int avro_map_set(const avro_datum_t map, const char *key,
const avro_datum_t value);
@@ -282,5 +290,30 @@ int avro_file_reader_read(avro_file_read
avro_schema_t readers_schema, avro_datum_t * datum);
int avro_file_reader_close(avro_file_reader_t reader);
+/* Atom handling */
+typedef struct avro_atom_table_t_ *avro_atom_table_t;
+extern avro_atom_table_t g_avro_atom_table;
+
+avro_atom_table_t avro_atom_table_create(int32_t);
+void avro_atom_table_destroy(avro_atom_table_t table);
+void avro_atom_table_dump(avro_atom_table_t table);
+
+avro_atom_t avro_atom_table_add(avro_atom_table_t table, const char *s);
+avro_atom_t avro_atom_table_add_length(avro_atom_table_t table, const char *s, \
int32_t length); +avro_atom_t avro_atom_table_lookup(avro_atom_table_t table, const \
char *s, int32_t length); +int avro_atom_table_describe(avro_atom_table_t table, \
avro_atom_t atom, const char **s, int32_t *length); +const char \
*avro_atom_table_to_string(avro_atom_table_t table, avro_atom_t atom); +
+avro_atom_t avro_atom_table_incref(avro_atom_table_t table, avro_atom_t atom);
+void avro_atom_table_decref(avro_atom_table_t table, avro_atom_t atom);
+
+#define avro_atom_add(s) avro_atom_table_add(g_avro_atom_table, s)
+#define avro_atom_add_length(s, length) \
avro_atom_table_add_length(g_avro_atom_table, s, length) +#define avro_atom_lookup(s, \
length) avro_atom_table_lookup(g_avro_atom_table, s, length) +#define \
avro_atom_describe(atom, s, length) avro_atom_table_describe(g_avro_atom_table, atom, \
s, length) +#define avro_atom_to_string(atom) \
avro_atom_table_to_string(g_avro_atom_table, atom) +#define avro_atom_incref(atom) \
avro_atom_table_incref(g_avro_atom_table, atom) +#define avro_atom_decref(atom) \
avro_atom_table_decref(g_avro_atom_table, atom) +
CLOSE_EXTERN
#endif
Modified: avro/trunk/lang/c/src/datum.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum.c (original)
+++ avro/trunk/lang/c/src/datum.c Sat May 22 14:15:55 2010
@@ -22,6 +22,8 @@
#include "datum.h"
#include "encoding.h"
+#define DEFAULT_ARRAY_SIZE 10
+#define DEFAULT_FIELD_COUNT 10
#define DEFAULT_TABLE_SIZE 32
static void avro_datum_init(avro_datum_t datum, avro_type_t type)
@@ -415,7 +417,8 @@ avro_datum_t avro_record(const char *nam
free((void *)datum);
return NULL;
}
- datum->field_order = st_init_numtable_with_size(DEFAULT_TABLE_SIZE);
+ datum->alloc_fields = DEFAULT_FIELD_COUNT;
+ datum->field_order = (avro_atom_t*)malloc(datum->alloc_fields * \
sizeof(avro_atom_t)); if (!datum->field_order) {
if (space) {
free((void *)datum->space);
@@ -424,9 +427,9 @@ avro_datum_t avro_record(const char *nam
free(datum);
return NULL;
}
- datum->fields_byname = st_init_strtable_with_size(DEFAULT_TABLE_SIZE);
+ datum->fields_byname = st_init_numtable_with_size(DEFAULT_TABLE_SIZE);
if (!datum->fields_byname) {
- st_free_table(datum->field_order);
+ free(datum->field_order);
if (space) {
free((void *)datum->space);
}
@@ -434,20 +437,21 @@ avro_datum_t avro_record(const char *nam
free(datum);
return NULL;
}
+ datum->num_fields = 0;
avro_datum_init(&datum->obj, AVRO_RECORD);
return &datum->obj;
}
int
-avro_record_get(const avro_datum_t datum, const char *field_name,
+avro_record_get(const avro_datum_t datum, avro_atom_t field_name,
avro_datum_t * field)
{
union {
avro_datum_t field;
st_data_t data;
} val;
- if (is_avro_datum(datum) && is_avro_record(datum) && field_name) {
+ if (is_avro_datum(datum) && is_avro_record(datum)) {
if (st_lookup
(avro_datum_to_record(datum)->fields_byname,
(st_data_t) field_name, &(val.data))) {
@@ -459,13 +463,11 @@ avro_record_get(const avro_datum_t datum
}
int
-avro_record_set(const avro_datum_t datum, const char *field_name,
+avro_record_set(const avro_datum_t datum, avro_atom_t field_name,
const avro_datum_t field_value)
{
- char *key = (char *)field_name;
avro_datum_t old_field;
-
- if (is_avro_datum(datum) && is_avro_record(datum) && field_name) {
+ if (is_avro_datum(datum) && is_avro_record(datum)) {
if (avro_record_get(datum, field_name, &old_field) == 0) {
/* Overriding old value */
avro_datum_decref(old_field);
@@ -473,17 +475,18 @@ avro_record_set(const avro_datum_t datum
/* Inserting new value */
struct avro_record_datum_t *record =
avro_datum_to_record(datum);
- key = strdup(field_name);
- if (!key) {
- return ENOMEM;
- }
- st_insert(record->field_order,
- record->field_order->num_entries,
- (st_data_t) key);
+ if ((record->num_fields + 1) > record->alloc_fields) {
+ record->alloc_fields *= 2;
+ record->field_order = (avro_atom_t*)realloc(record->field_order,
+ (record->alloc_fields) * sizeof(avro_atom_t));
+ }
+ avro_atom_incref(field_name);
+ record->field_order[record->num_fields++] = field_name;
}
avro_datum_incref(field_value);
+ avro_atom_incref(field_name);
st_insert(avro_datum_to_record(datum)->fields_byname,
- (st_data_t) key, (st_data_t) field_value);
+ (st_data_t) field_name, (st_data_t) field_value);
return 0;
}
return EINVAL;
@@ -675,11 +678,13 @@ avro_datum_t avro_array(void)
if (!datum) {
return NULL;
}
- datum->els = st_init_numtable_with_size(DEFAULT_TABLE_SIZE);
+ datum->alloc_els = DEFAULT_ARRAY_SIZE;
+ datum->els = malloc(datum->alloc_els * sizeof(avro_datum_t));
if (!datum->els) {
free(datum);
return NULL;
}
+ datum->num_els = 0;
avro_datum_init(&datum->obj, AVRO_ARRAY);
return &datum->obj;
@@ -688,18 +693,14 @@ avro_datum_t avro_array(void)
int
avro_array_get(const avro_datum_t array_datum, int64_t index, avro_datum_t * value)
{
- union {
- st_data_t data;
- avro_datum_t datum;
- } val;
- if (is_avro_datum(array_datum) && is_avro_array(array_datum)) {
- const struct avro_array_datum_t * array = avro_datum_to_array(array_datum);
- if (st_lookup(array->els, index, &val.data)) {
- *value = val.datum;
- return 0;
- }
- }
- return EINVAL;
+ if (is_avro_datum(array_datum) && is_avro_array(array_datum) && (index >= 0)) {
+ const struct avro_array_datum_t * array = avro_datum_to_array(array_datum);
+ if ((index >= 0) && (index < array->num_els)) {
+ *value = array->els[index];
+ return 0;
+ }
+ }
+ return EINVAL;
}
int
@@ -712,26 +713,30 @@ avro_array_append_datum(const avro_datum
return EINVAL;
}
array = avro_datum_to_array(array_datum);
- st_insert(array->els, array->els->num_entries,
- (st_data_t) avro_datum_incref(datum));
+ if ((array->num_els + 1) > array->alloc_els) {
+ array->alloc_els *= 2;
+ array->els = (avro_datum_t *)realloc(array->els,
+ (array->alloc_els) * sizeof(avro_datum_t));
+ }
+ array->els[array->num_els++] = avro_datum_incref(datum);
return 0;
}
-static int char_datum_free_foreach(char *key, avro_datum_t datum, void *arg)
+static int atom_datum_free_foreach(avro_atom_t key, avro_datum_t datum, void *arg)
{
AVRO_UNUSED(arg);
avro_datum_decref(datum);
- free(key);
+ avro_atom_decref(key);
return ST_DELETE;
}
-static int array_free_foreach(int i, avro_datum_t datum, void *arg)
+static int char_datum_free_foreach(char *key, avro_datum_t datum, void *arg)
{
- AVRO_UNUSED(i);
AVRO_UNUSED(arg);
avro_datum_decref(datum);
+ free(key);
return ST_DELETE;
}
@@ -792,6 +797,7 @@ static void avro_datum_free(avro_datum_t
break;
case AVRO_RECORD:{
+ int i;
struct avro_record_datum_t *record;
record = avro_datum_to_record(datum);
free((void *)record->name);
@@ -799,8 +805,11 @@ static void avro_datum_free(avro_datum_t
free((void *)record->space);
}
st_foreach(record->fields_byname,
- char_datum_free_foreach, 0);
- st_free_table(record->field_order);
+ atom_datum_free_foreach, 0);
+ for (i = 0; i < record->num_fields; i++) {
+ avro_atom_decref(record->field_order[i]);
+ }
+ free(record->field_order);
st_free_table(record->fields_byname);
free(record);
}
@@ -832,10 +841,13 @@ static void avro_datum_free(avro_datum_t
}
break;
case AVRO_ARRAY:{
+ int i;
struct avro_array_datum_t *array;
array = avro_datum_to_array(datum);
- st_foreach(array->els, array_free_foreach, 0);
- st_free_table(array->els);
+ for (i = 0; i < array->num_els; i++) {
+ avro_datum_decref(array->els[i]);
+ }
+ free(array->els);
free(array);
}
break;
Modified: avro/trunk/lang/c/src/datum.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum.h?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum.h (original)
+++ avro/trunk/lang/c/src/datum.h Sat May 22 14:15:55 2010
@@ -76,8 +76,10 @@ struct avro_record_datum_t {
struct avro_obj_t obj;
const char *name;
const char *space;
- st_table *field_order;
+ avro_atom_t *field_order;
st_table *fields_byname;
+ int32_t num_fields;
+ int32_t alloc_fields;
};
struct avro_enum_datum_t {
@@ -88,7 +90,9 @@ struct avro_enum_datum_t {
struct avro_array_datum_t {
struct avro_obj_t obj;
- st_table *els;
+ int32_t num_els;
+ int32_t alloc_els;
+ avro_datum_t *els;
};
struct avro_union_datum_t {
Modified: avro/trunk/lang/c/src/datum_equal.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum_equal.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum_equal.c (original)
+++ avro/trunk/lang/c/src/datum_equal.c Sat May 22 14:15:55 2010
@@ -24,17 +24,11 @@ array_equal(struct avro_array_datum_t *a
{
long i;
- if (a->els->num_entries != b->els->num_entries) {
+ if (a->num_els != b->num_els) {
return 0;
}
- for (i = 0; i < a->els->num_entries; i++) {
- union {
- st_data_t data;
- avro_datum_t datum;
- } ael, bel;
- st_lookup(a->els, i, &ael.data);
- st_lookup(b->els, i, &bel.data);
- if (!avro_datum_equal(ael.datum, bel.datum)) {
+ for (i = 0; i < a->num_els; i++) {
+ if (!avro_datum_equal(a->els[i], b->els[i])) {
return 0;
}
}
@@ -47,7 +41,25 @@ struct st_equal_args {
};
static int
-st_equal_foreach(char *key, avro_datum_t datum, struct st_equal_args *args)
+st_equal_map_foreach(char *key, avro_datum_t datum, struct st_equal_args *args)
+{
+ union {
+ avro_datum_t datum_other;
+ st_data_t data;
+ } val;
+ if (!st_lookup(args->st, (st_data_t) key, &(val.data))) {
+ args->rval = 0;
+ return ST_STOP;
+ }
+ if (!avro_datum_equal(datum, val.datum_other)) {
+ args->rval = 0;
+ return ST_STOP;
+ }
+ return ST_CONTINUE;
+}
+
+static int
+st_equal_record_foreach(avro_atom_t key, avro_datum_t datum, struct st_equal_args \
*args) {
union {
avro_datum_t datum_other;
@@ -70,7 +82,7 @@ static int map_equal(struct avro_map_dat
if (a->map->num_entries != b->map->num_entries) {
return 0;
}
- st_foreach(a->map, st_equal_foreach, (st_data_t) & args);
+ st_foreach(a->map, st_equal_map_foreach, (st_data_t) & args);
return args.rval;
}
@@ -94,7 +106,7 @@ static int record_equal(struct avro_reco
if (a->fields_byname->num_entries != b->fields_byname->num_entries) {
return 0;
}
- st_foreach(a->fields_byname, st_equal_foreach, (st_data_t) & args);
+ st_foreach(a->fields_byname, st_equal_record_foreach, (st_data_t) & args);
return args.rval;
}
Modified: avro/trunk/lang/c/src/datum_size.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum_size.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum_size.c (original)
+++ avro/trunk/lang/c/src/datum_size.c Sat May 22 14:15:55 2010
@@ -57,15 +57,10 @@ size_record(avro_writer_t writer, const
/* No schema. Just write the record datum */
struct avro_record_datum_t *record =
avro_datum_to_record(datum);
- for (i = 0; i < record->field_order->num_entries; i++) {
- union {
- st_data_t data;
- char *name;
- } val;
- st_lookup(record->field_order, i, &val.data);
+ for (i = 0; i < record->num_fields; i++) {
+ avro_atom_t name = record->field_order[i];
size_check(rval,
- avro_record_get(datum, val.name,
- &field_datum));
+ avro_record_get(datum, name, &field_datum));
size_accum(rval, size,
size_datum(writer, enc, NULL, field_datum));
}
@@ -143,19 +138,14 @@ size_array(avro_writer_t writer, const a
int64_t size;
size = 0;
- if (array->els->num_entries) {
+ if (array->num_els) {
size_accum(rval, size,
- enc->size_long(writer, array->els->num_entries));
- for (i = 0; i < array->els->num_entries; i++) {
- union {
- st_data_t data;
- avro_datum_t datum;
- } val;
- st_lookup(array->els, i, &val.data);
+ enc->size_long(writer, array->num_els));
+ for (i = 0; i < array->num_els; i++) {
size_accum(rval, size,
size_datum(writer, enc,
schema ? schema->items : NULL,
- val.datum));
+ array->els[i]));
}
}
size_accum(rval, size, enc->size_long(writer, 0));
Modified: avro/trunk/lang/c/src/datum_validate.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum_validate.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum_validate.c (original)
+++ avro/trunk/lang/c/src/datum_validate.c Sat May 22 14:15:55 2010
@@ -101,15 +101,10 @@ avro_schema_datum_validate(avro_schema_t
struct avro_array_datum_t *array =
avro_datum_to_array(datum);
- for (i = 0; i < array->els->num_entries; i++) {
- union {
- st_data_t data;
- avro_datum_t datum;
- } val;
- st_lookup(array->els, i, &val.data);
+ for (i = 0; i < array->num_els; i++) {
if (!avro_schema_datum_validate
((avro_schema_to_array
- (expected_schema))->items, val.datum)) {
+ (expected_schema))->items, array->els[i])) {
return 0;
}
}
Modified: avro/trunk/lang/c/src/datum_write.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum_write.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum_write.c (original)
+++ avro/trunk/lang/c/src/datum_write.c Sat May 22 14:15:55 2010
@@ -52,14 +52,10 @@ write_record(avro_writer_t writer, const
/* No schema. Just write the record datum */
struct avro_record_datum_t *record =
avro_datum_to_record(datum);
- for (i = 0; i < record->field_order->num_entries; i++) {
- union {
- st_data_t data;
- char *name;
- } val;
- st_lookup(record->field_order, i, &val.data);
+ for (i = 0; i < record->num_fields; i++) {
+ avro_atom_t name = record->field_order[i];
check(rval,
- avro_record_get(datum, val.name, &field_datum));
+ avro_record_get(datum, name, &field_datum));
check(rval,
write_datum(writer, enc, NULL, field_datum));
}
@@ -133,21 +129,16 @@ write_array(avro_writer_t writer, const
int rval;
long i;
- if (array->els->num_entries) {
- rval = enc->write_long(writer, array->els->num_entries);
+ if (array->num_els) {
+ rval = enc->write_long(writer, array->num_els);
if (rval) {
return rval;
}
- for (i = 0; i < array->els->num_entries; i++) {
- union {
- st_data_t data;
- avro_datum_t datum;
- } val;
- st_lookup(array->els, i, &val.data);
+ for (i = 0; i < array->num_els; i++) {
check(rval,
write_datum(writer, enc,
schema ? schema->items : NULL,
- val.datum));
+ array->els[i]));
}
}
return enc->write_long(writer, 0);
Modified: avro/trunk/lang/c/src/schema.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/schema.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/schema.c (original)
+++ avro/trunk/lang/c/src/schema.c Sat May 22 14:15:55 2010
@@ -68,7 +68,7 @@ static int record_free_foreach(int i, st
AVRO_UNUSED(i);
AVRO_UNUSED(arg);
- free(field->name);
+ avro_atom_decref(field->name);
avro_schema_decref(field->type);
free(field);
return ST_DELETE;
@@ -417,7 +417,7 @@ avro_schema_record_field_append(const av
if (!new_field) {
return ENOMEM;
}
- new_field->name = strdup(field_name);
+ new_field->name = avro_atom_add(field_name);
new_field->type = avro_schema_incref(field_schema);
st_insert(record->fields, record->fields->num_entries,
(st_data_t) new_field);
@@ -456,13 +456,14 @@ avro_schema_t avro_schema_record(const c
free(record);
return NULL;
}
- record->fields_byname = st_init_strtable_with_size(DEFAULT_TABLE_SIZE);
+ record->fields_byname = st_init_numtable_with_size(DEFAULT_TABLE_SIZE);
if (!record->fields_byname) {
st_free_table(record->fields);
free(record->name);
free(record);
return NULL;
}
+ record->num_fields = 0;
avro_schema_init(&record->obj, AVRO_RECORD);
return &record->obj;
@@ -922,8 +923,9 @@ avro_schema_t avro_schema_copy(avro_sche
st_lookup(record_schema->fields, i, &val.data);
avro_schema_t type_copy =
avro_schema_copy(val.field->type);
+ // FIXME: Remove avro_atom_to_string() here.
avro_schema_record_field_append(new_schema,
- val.field->name,
+ avro_atom_to_string(val.field->name),
type_copy);
}
}
@@ -1047,7 +1049,7 @@ static int write_field(avro_writer_t out
{
int rval;
check(rval, avro_write_str(out, "{\"name\":\""));
- check(rval, avro_write_str(out, field->name));
+ check(rval, avro_write_str(out, avro_atom_to_string(field->name)));
check(rval, avro_write_str(out, "\",\"type\":"));
check(rval, avro_schema_to_json(field->type, out));
return avro_write_str(out, "}");
Modified: avro/trunk/lang/c/src/schema.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/schema.h?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/schema.h (original)
+++ avro/trunk/lang/c/src/schema.h Sat May 22 14:15:55 2010
@@ -22,7 +22,7 @@
#include "st.h"
struct avro_record_field_t {
- char *name;
+ avro_atom_t name;
avro_schema_t type;
/*
* TODO: default values
@@ -35,6 +35,7 @@ struct avro_record_schema_t {
char *space;
st_table *fields;
st_table *fields_byname;
+ int32_t num_fields;
};
struct avro_enum_schema_t {
Modified: avro/trunk/lang/c/src/schema_equal.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/schema_equal.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/src/schema_equal.c (original)
+++ avro/trunk/lang/c/src/schema_equal.c Sat May 22 14:15:55 2010
@@ -48,7 +48,7 @@ schema_record_equal(struct avro_record_s
if (!st_lookup(b->fields, i, &fb.data)) {
return 0;
}
- if (strcmp(fa.f->name, fb.f->name)) {
+ if (fa.f->name != fb.f->name) {
/*
* They have fields with different names
*/
Modified: avro/trunk/lang/c/tests/generate_interop_data.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/tests/generate_interop_data.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/tests/generate_interop_data.c (original)
+++ avro/trunk/lang/c/tests/generate_interop_data.c Sat May 22 14:15:55 2010
@@ -20,6 +20,66 @@
#include <stdlib.h>
#include <unistd.h>
+struct atom_holder {
+ avro_atom_t arrayField;
+ avro_atom_t boolField;
+ avro_atom_t bytesField;
+ avro_atom_t doubleField;
+ avro_atom_t enumField;
+ avro_atom_t fixedField;
+ avro_atom_t floatField;
+ avro_atom_t intField;
+ avro_atom_t longField;
+ avro_atom_t mapField;
+ avro_atom_t nullField;
+ avro_atom_t recordField;
+ avro_atom_t stringField;
+ avro_atom_t unionField;
+
+ avro_atom_t children;
+ avro_atom_t label;
+} atoms;
+
+void init_atoms(void)
+{
+ atoms.arrayField = avro_atom_add("arrayField");
+ atoms.boolField = avro_atom_add("boolField");
+ atoms.bytesField = avro_atom_add("bytesField");
+ atoms.doubleField = avro_atom_add("doubleField");
+ atoms.enumField = avro_atom_add("enumField");
+ atoms.fixedField = avro_atom_add("fixedField");
+ atoms.floatField = avro_atom_add("floatField");
+ atoms.intField = avro_atom_add("intField");
+ atoms.longField = avro_atom_add("longField");
+ atoms.mapField = avro_atom_add("mapField");
+ atoms.nullField = avro_atom_add("nullField");
+ atoms.recordField = avro_atom_add("recordField");
+ atoms.stringField = avro_atom_add("stringField");
+ atoms.unionField = avro_atom_add("unionField");
+ atoms.children = avro_atom_add("children");
+ atoms.label = avro_atom_add("label");
+}
+
+void cleanup_atoms(void)
+{
+ avro_atom_decref(atoms.arrayField);
+ avro_atom_decref(atoms.boolField);
+ avro_atom_decref(atoms.bytesField);
+ avro_atom_decref(atoms.doubleField);
+ avro_atom_decref(atoms.enumField);
+ avro_atom_decref(atoms.fixedField);
+ avro_atom_decref(atoms.floatField);
+ avro_atom_decref(atoms.intField);
+ avro_atom_decref(atoms.longField);
+ avro_atom_decref(atoms.mapField);
+ avro_atom_decref(atoms.nullField);
+ avro_atom_decref(atoms.recordField);
+ avro_atom_decref(atoms.stringField);
+ avro_atom_decref(atoms.unionField);
+ avro_atom_decref(atoms.children);
+ avro_atom_decref(atoms.label);
+}
+
int main(int argc, char *argv[])
{
int rval;
@@ -41,6 +101,9 @@ int main(int argc, char *argv[])
KIND_C
};
+ avro_init();
+ init_atoms();
+
if (argc != 3) {
exit(EXIT_FAILURE);
}
@@ -57,34 +120,34 @@ int main(int argc, char *argv[])
/* TODO: create a method for generating random data from schema */
interop = avro_record("Interop", "org.apache.avro");
- avro_record_set(interop, "intField", avro_int32(42));
- avro_record_set(interop, "longField", avro_int64(4242));
- avro_record_set(interop, "stringField",
+ avro_record_set(interop, atoms.intField, avro_int32(42));
+ avro_record_set(interop, atoms.longField, avro_int64(4242));
+ avro_record_set(interop, atoms.stringField,
avro_wrapstring("Follow your bliss."));
- avro_record_set(interop, "boolField", avro_boolean(1));
- avro_record_set(interop, "floatField", avro_float(3.14159265));
- avro_record_set(interop, "doubleField", avro_double(2.71828183));
- avro_record_set(interop, "bytesField", avro_bytes("abcd", 4));
- avro_record_set(interop, "nullField", avro_null());
+ avro_record_set(interop, atoms.boolField, avro_boolean(1));
+ avro_record_set(interop, atoms.floatField, avro_float(3.14159265));
+ avro_record_set(interop, atoms.doubleField, avro_double(2.71828183));
+ avro_record_set(interop, atoms.bytesField, avro_bytes("abcd", 4));
+ avro_record_set(interop, atoms.nullField, avro_null());
array_datum = avro_array();
avro_array_append_datum(array_datum, avro_double(1.0));
avro_array_append_datum(array_datum, avro_double(2.0));
avro_array_append_datum(array_datum, avro_double(3.0));
- avro_record_set(interop, "arrayField", array_datum);
+ avro_record_set(interop, atoms.arrayField, array_datum);
- avro_record_set(interop, "mapField", avro_map());
+ avro_record_set(interop, atoms.mapField, avro_map());
union_datum = avro_union(1, avro_double(1.61803399));
- avro_record_set(interop, "unionField", union_datum);
- avro_record_set(interop, "enumField", avro_enum("Kind", KIND_A));
- avro_record_set(interop, "fixedField",
+ avro_record_set(interop, atoms.unionField, union_datum);
+ avro_record_set(interop, atoms.enumField, avro_enum("Kind", KIND_A));
+ avro_record_set(interop, atoms.fixedField,
avro_fixed("MD5", "1234567890123456", 16));
node_datum = avro_record("Node", NULL);
- avro_record_set(node_datum, "label",
+ avro_record_set(node_datum, atoms.label,
avro_wrapstring("If you label me, you negate me."));
- avro_record_set(node_datum, "children", avro_array());
- avro_record_set(interop, "recordField", node_datum);
+ avro_record_set(node_datum, atoms.children, avro_array());
+ avro_record_set(interop, atoms.recordField, node_datum);
rval = avro_file_writer_append(file_writer, interop);
if (rval) {
@@ -108,5 +171,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "ok\n");
check(rval, avro_file_reader_close(file_reader));
fprintf(stderr, "Closed reader.\n");
+ cleanup_atoms();
+ avro_shutdown();
return 0;
}
Modified: avro/trunk/lang/c/tests/test_avro_data.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/tests/test_avro_data.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/tests/test_avro_data.c (original)
+++ avro/trunk/lang/c/tests/test_avro_data.c Sat May 22 14:15:55 2010
@@ -205,16 +205,20 @@ static int test_record(void)
{
avro_schema_t schema = avro_schema_record("person", NULL);
avro_datum_t datum = avro_record("person", NULL);
+ avro_atom_t name_atom, age_atom;
avro_datum_t name_datum, age_datum;
+ name_atom = avro_atom_add("name");
+ age_atom = avro_atom_add("age");
+
avro_schema_record_field_append(schema, "name", avro_schema_string());
avro_schema_record_field_append(schema, "age", avro_schema_int());
name_datum = avro_wrapstring("Joseph Campbell");
age_datum = avro_int32(83);
- avro_record_set(datum, "name", name_datum);
- avro_record_set(datum, "age", age_datum);
+ avro_record_set(datum, name_atom, name_datum);
+ avro_record_set(datum, age_atom, age_datum);
write_read_check(schema, NULL, datum, "record");
@@ -222,6 +226,8 @@ static int test_record(void)
avro_datum_decref(age_datum);
avro_datum_decref(datum);
avro_schema_decref(schema);
+ avro_atom_decref(name_atom);
+ avro_atom_decref(age_atom);
return 0;
}
@@ -344,6 +350,8 @@ int main(void)
"union", test_union}
};
+ avro_init();
+
init_rand();
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
struct avro_tests *test = tests + i;
@@ -352,5 +360,8 @@ int main(void)
return EXIT_FAILURE;
}
}
+
+ avro_shutdown();
+
return EXIT_SUCCESS;
}
Modified: avro/trunk/lang/c/tests/test_avro_schema.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/tests/test_avro_schema.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/tests/test_avro_schema.c (original)
+++ avro/trunk/lang/c/tests/test_avro_schema.c Sat May 22 14:15:55 2010
@@ -105,6 +105,8 @@ int main(int argc, char *argv[])
AVRO_UNUSED(argc);
AVRO_UNUSED(argv);
+ avro_init();
+
if (!srcdir) {
srcdir = ".";
}
@@ -128,5 +130,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "==================================================\n");
avro_writer_free(avro_stderr);
+
+ avro_shutdown();
+
return EXIT_SUCCESS;
}
Modified: avro/trunk/lang/c/tests/test_interop_data.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/tests/test_interop_data.c?rev=947299&r1=947298&r2=947299&view=diff
==============================================================================
--- avro/trunk/lang/c/tests/test_interop_data.c (original)
+++ avro/trunk/lang/c/tests/test_interop_data.c Sat May 22 14:15:55 2010
@@ -1,8 +1,8 @@
#include "avro_private.h"
-#include <stdio.h>
-#include <unistd.h>
int main(void)
{
+ avro_init();
+ avro_shutdown();
return 0;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic