Author: massie
Date: Tue Oct 27 17:47:55 2009
New Revision: 830265
URL: http://svn.apache.org/viewvc?rev=830265&view=rev
Log:
AVRO-172. Don't include value class data/methods in each instance of a value
when processing schemas.
Modified:
hadoop/avro/trunk/CHANGES.txt
hadoop/avro/trunk/src/c/avro.c
hadoop/avro/trunk/src/c/avro.h
hadoop/avro/trunk/src/c/avro_array.c
hadoop/avro/trunk/src/c/avro_boolean.c
hadoop/avro/trunk/src/c/avro_bytes.c
hadoop/avro/trunk/src/c/avro_double.c
hadoop/avro/trunk/src/c/avro_enum.c
hadoop/avro/trunk/src/c/avro_fixed.c
hadoop/avro/trunk/src/c/avro_float.c
hadoop/avro/trunk/src/c/avro_int.c
hadoop/avro/trunk/src/c/avro_long.c
hadoop/avro/trunk/src/c/avro_map.c
hadoop/avro/trunk/src/c/avro_null.c
hadoop/avro/trunk/src/c/avro_private.h
hadoop/avro/trunk/src/c/avro_record.c
hadoop/avro/trunk/src/c/avro_string.c
hadoop/avro/trunk/src/c/avro_union.c
hadoop/avro/trunk/src/c/avro_value.c
hadoop/avro/trunk/src/c/test_avro_schema.c
Modified: hadoop/avro/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Tue Oct 27 17:47:55 2009
@@ -33,6 +33,8 @@
OPTIMIZATIONS
+ AVRO-172. More efficient schema processing (massie)
+
BUG FIXES
AVRO-141. Fix a NullPointerException in ReflectData#isRecord().
Modified: hadoop/avro/trunk/src/c/avro.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro.c (original)
+++ hadoop/avro/trunk/src/c/avro.c Tue Oct 27 17:47:55 2009
@@ -24,96 +24,6 @@
#include "apr_file_io.h"
#include "apr_file_info.h"
-static struct avro_type_entry
-{
- const avro_string_t name;
- const avro_type_t type;
-} avro_type_lookup_table[] =
-{
- {
- L"string", AVRO_STRING},
- {
- L"bytes", AVRO_BYTES},
- {
- L"int", AVRO_INT},
- {
- L"long", AVRO_LONG},
- {
- L"float", AVRO_FLOAT},
- {
- L"double", AVRO_DOUBLE},
- {
- L"boolean", AVRO_BOOLEAN},
- {
- L"null", AVRO_NULL},
- {
- L"record", AVRO_RECORD},
- {
- L"enum", AVRO_ENUM},
- {
- L"fixed", AVRO_FIXED},
- {
- L"map", AVRO_MAP},
- {
- L"array", AVRO_ARRAY},
- {
- L"union", AVRO_UNION}
-};
-
-#define NUM_AVRO_NODE_TYPES
(sizeof(avro_type_lookup_table)/sizeof(avro_type_lookup_table[0]))
-
-/* TODO: gperf this */
-const avro_type_t *
-avro_type_lookup (const avro_string_t name)
-{
- int i;
- if (name)
- {
- for (i = 0; i < NUM_AVRO_NODE_TYPES; i++)
- {
- const struct avro_type_entry *entry = avro_type_lookup_table + i;
- if (wcscmp (entry->name, name) == 0)
- {
- return &entry->type;
- }
- }
- }
- return NULL;
-}
-
-const avro_type_t *
-avro_type_from_json (const JSON_value * json)
-{
- const avro_type_t *avro_type = NULL;
- const static avro_type_t union_type = AVRO_UNION;
- const JSON_value *type_attr;
-
- if (!json)
- {
- return NULL;
- }
-
- if (json->type == JSON_STRING)
- {
- avro_type = avro_type_lookup (json->json_string);
- }
- else if (json->type == JSON_ARRAY)
- {
- avro_type = &union_type;
- }
- else if (json->type == JSON_OBJECT)
- {
- type_attr = json_attr_get_check_type (json, L"type", JSON_STRING);
- if (!type_attr)
- {
- return NULL;
- }
- avro_type = avro_type_lookup (type_attr->json_string);
- }
-
- return avro_type;
-}
-
char *
avro_util_file_read_full (apr_pool_t * pool, const char *fname,
apr_size_t * len)
Modified: hadoop/avro/trunk/src/c/avro.h
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro.h?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro.h (original)
+++ hadoop/avro/trunk/src/c/avro.h Tue Oct 27 17:47:55 2009
@@ -84,12 +84,17 @@
AVRO_BOOLEAN,/**< boolean primitive */
AVRO_NULL, /**< null primitive */
AVRO_RECORD, /**< complex record */
- AVRO_FIELD, /**< complex record field */
AVRO_ENUM, /**< complex enum */
AVRO_FIXED, /**< complex fixed value */
AVRO_MAP, /**< complex map */
AVRO_ARRAY, /**< complex array */
- AVRO_UNION /**< complex union */
+ AVRO_UNION, /**< complex union */
+
+ AVRO_FIELD, /**< complex record field */
+ AVRO_DECORATOR, /**< resursive schema decorator */
+
+ /* NOTE: AVRO_NUM_TYPES must always be last */
+ AVRO_NUM_TYPES /**< number of avro types */
};
typedef enum avro_type avro_type_t;
Modified: hadoop/avro/trunk/src/c/avro_array.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_array.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_array.c (original)
+++ hadoop/avro/trunk/src/c/avro_array.c Tue Oct 27 17:47:55 2009
@@ -41,8 +41,8 @@
container_of (value, struct avro_array_value, base_value);
avro_value_indent (value, fp);
- fprintf (fp, "array value items\n");
- self->items->print_info (self->items, fp);
+ fprintf (fp, "array(%p) value items\n", self);
+ avro_value_print_info (self->items, fp);
}
static avro_status_t
@@ -104,7 +104,7 @@
return AVRO_OK;
}
-struct avro_value *
+static struct avro_value *
avro_array_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -120,10 +120,6 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_array_read;
- self->base_value.skip_data = avro_array_skip;
- self->base_value.write_data = avro_array_write;
- self->base_value.print_info = avro_array_print;
/* collect and save required items */
items = json_attr_get (json, L"items");
@@ -145,3 +141,20 @@
self->ctx = ctx;
return &self->base_value;
}
+
+const struct avro_value_info avro_array_info = {
+ .name = L"array",
+ .type = AVRO_ARRAY,
+ .private = 0,
+ .create = avro_array_create,
+ .formats = {{
+ .read_data = avro_array_read,
+ .skip_data = avro_array_skip,
+ .write_data = avro_array_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_array_read,
+ .skip_data = avro_array_skip,
+ .write_data = avro_array_write}},
+ .print_info = avro_array_print
+};
Modified: hadoop/avro/trunk/src/c/avro_boolean.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_boolean.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_boolean.c (original)
+++ hadoop/avro/trunk/src/c/avro_boolean.c Tue Oct 27 17:47:55 2009
@@ -110,7 +110,7 @@
return io->write (io, &b, 1);
}
-struct avro_value *
+static struct avro_value *
avro_boolean_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -124,10 +124,23 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_boolean_read;
- self->base_value.skip_data = avro_boolean_skip;
- self->base_value.write_data = avro_boolean_write;
- self->base_value.print_info = avro_boolean_print;
self->value_set = 0;
return &self->base_value;
}
+
+const struct avro_value_info avro_boolean_info = {
+ .name = L"boolean",
+ .type = AVRO_BOOLEAN,
+ .private = 0,
+ .create = avro_boolean_create,
+ .formats = {{
+ .read_data = avro_boolean_read,
+ .skip_data = avro_boolean_skip,
+ .write_data = avro_boolean_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_boolean_read,
+ .skip_data = avro_boolean_skip,
+ .write_data = avro_boolean_write}},
+ .print_info = avro_boolean_print
+};
Modified: hadoop/avro/trunk/src/c/avro_bytes.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_bytes.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_bytes.c (original)
+++ hadoop/avro/trunk/src/c/avro_bytes.c Tue Oct 27 17:47:55 2009
@@ -100,7 +100,7 @@
return AVRO_OK;
}
-struct avro_value *
+static struct avro_value *
avro_bytes_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -115,10 +115,6 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_bytes_read;
- self->base_value.skip_data = avro_bytes_skip;
- self->base_value.write_data = avro_bytes_write;
- self->base_value.print_info = avro_bytes_print;
self->value_set = 0;
if (apr_pool_create (&self->pool, pool) != APR_SUCCESS)
{
@@ -126,3 +122,20 @@
}
return &self->base_value;
}
+
+const struct avro_value_info avro_bytes_info = {
+ .name = L"bytes",
+ .type = AVRO_BYTES,
+ .private = 0,
+ .create = avro_bytes_create,
+ .formats = {{
+ .read_data = avro_bytes_read,
+ .skip_data = avro_bytes_skip,
+ .write_data = avro_bytes_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_bytes_read,
+ .skip_data = avro_bytes_skip,
+ .write_data = avro_bytes_write}},
+ .print_info = avro_bytes_print
+};
Modified: hadoop/avro/trunk/src/c/avro_double.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_double.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_double.c (original)
+++ hadoop/avro/trunk/src/c/avro_double.c Tue Oct 27 17:47:55 2009
@@ -81,7 +81,7 @@
return avro_putint64_le (channel->io, (int64_t) self->value);;
}
-struct avro_value *
+static struct avro_value *
avro_double_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -96,10 +96,23 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_double_read;
- self->base_value.skip_data = avro_double_skip;
- self->base_value.write_data = avro_double_write;
- self->base_value.print_info = avro_double_print;
self->value_set = 0;
return &self->base_value;
}
+
+const struct avro_value_info avro_double_info = {
+ .name = L"double",
+ .type = AVRO_DOUBLE,
+ .private = 0,
+ .create = avro_double_create,
+ .formats = {{
+ .read_data = avro_double_read,
+ .skip_data = avro_double_skip,
+ .write_data = avro_double_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_double_read,
+ .skip_data = avro_double_skip,
+ .write_data = avro_double_write}},
+ .print_info = avro_double_print
+};
Modified: hadoop/avro/trunk/src/c/avro_enum.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_enum.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_enum.c (original)
+++ hadoop/avro/trunk/src/c/avro_enum.c Tue Oct 27 17:47:55 2009
@@ -97,7 +97,7 @@
return AVRO_OK;
}
-struct avro_value *
+static struct avro_value *
avro_enum_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -116,10 +116,6 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_enum_read;
- self->base_value.skip_data = avro_enum_skip;
- self->base_value.write_data = avro_enum_write;
- self->base_value.print_info = avro_enum_print;
/* collect and save required name */
name = json_attr_get_check_type (json, L"name", JSON_STRING);
@@ -153,3 +149,20 @@
self->value_set = 0;
return &self->base_value;
}
+
+const struct avro_value_info avro_enum_info = {
+ .name = L"enum",
+ .type = AVRO_ENUM,
+ .private = 0,
+ .create = avro_enum_create,
+ .formats = {{
+ .read_data = avro_enum_read,
+ .skip_data = avro_enum_skip,
+ .write_data = avro_enum_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_enum_read,
+ .skip_data = avro_enum_skip,
+ .write_data = avro_enum_write}},
+ .print_info = avro_enum_print
+};
Modified: hadoop/avro/trunk/src/c/avro_fixed.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_fixed.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_fixed.c (original)
+++ hadoop/avro/trunk/src/c/avro_fixed.c Tue Oct 27 17:47:55 2009
@@ -28,7 +28,7 @@
};
static void
-fixed_print (struct avro_value *value, FILE * fp)
+avro_fixed_print (struct avro_value *value, FILE * fp)
{
struct avro_fixed_value *self =
container_of (value, struct avro_fixed_value, base_value);
@@ -37,7 +37,7 @@
}
static avro_status_t
-fixed_read (struct avro_value *value, struct avro_channel *channel)
+avro_fixed_read (struct avro_value *value, struct avro_channel *channel)
{
struct avro_fixed_value *self =
container_of (value, struct avro_fixed_value, base_value);
@@ -45,7 +45,7 @@
}
static avro_status_t
-fixed_skip (struct avro_value *value, struct avro_channel *channel)
+avro_fixed_skip (struct avro_value *value, struct avro_channel *channel)
{
struct avro_fixed_value *self =
container_of (value, struct avro_fixed_value, base_value);
@@ -53,14 +53,14 @@
}
static avro_status_t
-fixed_write (struct avro_value *value, struct avro_channel *channel)
+avro_fixed_write (struct avro_value *value, struct avro_channel *channel)
{
struct avro_fixed_value *self =
container_of (value, struct avro_fixed_value, base_value);
return AVRO_OK;
}
-struct avro_value *
+static struct avro_value *
avro_fixed_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -78,10 +78,6 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = fixed_read;
- self->base_value.skip_data = fixed_skip;
- self->base_value.write_data = fixed_write;
- self->base_value.print_info = fixed_print;
/* collect and save required size */
size = json_attr_get_check_type (json, L"size", JSON_NUMBER);
@@ -111,3 +107,20 @@
return &self->base_value;
}
+
+const struct avro_value_info avro_fixed_info = {
+ .name = L"fixed",
+ .type = AVRO_FIXED,
+ .private = 0,
+ .create = avro_fixed_create,
+ .formats = {{
+ .read_data = avro_fixed_read,
+ .skip_data = avro_fixed_skip,
+ .write_data = avro_fixed_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_fixed_read,
+ .skip_data = avro_fixed_skip,
+ .write_data = avro_fixed_write}},
+ .print_info = avro_fixed_print
+};
Modified: hadoop/avro/trunk/src/c/avro_float.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_float.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_float.c (original)
+++ hadoop/avro/trunk/src/c/avro_float.c Tue Oct 27 17:47:55 2009
@@ -81,7 +81,7 @@
return avro_putint32_le (channel->io, (int32_t) self->value);
}
-struct avro_value *
+static struct avro_value *
avro_float_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -96,10 +96,23 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_float_read;
- self->base_value.skip_data = avro_float_skip;
- self->base_value.write_data = avro_float_write;
- self->base_value.print_info = avro_float_print;
self->value_set = 0;
return &self->base_value;
}
+
+const struct avro_value_info avro_float_info = {
+ .name = L"float",
+ .type = AVRO_FLOAT,
+ .private = 0,
+ .create = avro_float_create,
+ .formats = {{
+ .read_data = avro_float_read,
+ .skip_data = avro_float_skip,
+ .write_data = avro_float_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_float_read,
+ .skip_data = avro_float_skip,
+ .write_data = avro_float_write}},
+ .print_info = avro_float_print
+};
Modified: hadoop/avro/trunk/src/c/avro_int.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_int.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_int.c (original)
+++ hadoop/avro/trunk/src/c/avro_int.c Tue Oct 27 17:47:55 2009
@@ -89,7 +89,7 @@
return avro_putint (io, &self->value);
}
-struct avro_value *
+static struct avro_value *
avro_int_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -104,10 +104,23 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_int_read;
- self->base_value.skip_data = avro_int_skip;
- self->base_value.write_data = avro_int_write;
- self->base_value.print_info = avro_int_print;
self->value_set = 0;
return &self->base_value;
}
+
+const struct avro_value_info avro_int_info = {
+ .name = L"int",
+ .type = AVRO_INT,
+ .private = 0,
+ .create = avro_int_create,
+ .formats = {{
+ .read_data = avro_int_read,
+ .skip_data = avro_int_skip,
+ .write_data = avro_int_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_int_read,
+ .skip_data = avro_int_skip,
+ .write_data = avro_int_write}},
+ .print_info = avro_int_print
+};
Modified: hadoop/avro/trunk/src/c/avro_long.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_long.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_long.c (original)
+++ hadoop/avro/trunk/src/c/avro_long.c Tue Oct 27 17:47:55 2009
@@ -89,7 +89,7 @@
return avro_putlong (io, &self->value);
}
-struct avro_value *
+static struct avro_value *
avro_long_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -104,10 +104,23 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_long_read;
- self->base_value.skip_data = avro_long_skip;
- self->base_value.write_data = avro_long_write;
- self->base_value.print_info = avro_long_print;
self->value_set = 0;
return &self->base_value;
}
+
+const struct avro_value_info avro_long_info = {
+ .name = L"long",
+ .type = AVRO_LONG,
+ .private = 0,
+ .create = avro_long_create,
+ .formats = {{
+ .read_data = avro_long_read,
+ .skip_data = avro_long_skip,
+ .write_data = avro_long_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_long_read,
+ .skip_data = avro_long_skip,
+ .write_data = avro_long_write}},
+ .print_info = avro_long_print
+};
Modified: hadoop/avro/trunk/src/c/avro_map.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_map.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_map.c (original)
+++ hadoop/avro/trunk/src/c/avro_map.c Tue Oct 27 17:47:55 2009
@@ -32,9 +32,9 @@
struct avro_map_value *self =
container_of (value, struct avro_map_value, base_value);
avro_value_indent (value, fp);
- fprintf (fp, "map key/value\n");
- self->keys->print_info (self->keys, fp);
- self->values->print_info (self->values, fp);
+ fprintf (fp, "map(%p) key/value\n", self);
+ avro_value_print_info (self->keys, fp);
+ avro_value_print_info (self->values, fp);
}
static avro_status_t
@@ -61,7 +61,7 @@
return AVRO_OK;
}
-struct avro_value *
+static struct avro_value *
avro_map_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -79,10 +79,6 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_map_read;
- self->base_value.skip_data = avro_map_skip;
- self->base_value.write_data = avro_map_write;
- self->base_value.print_info = avro_map_print;
/* collect and save required keys */
keys = json_attr_get (json, L"keys");
@@ -97,7 +93,9 @@
else
{
/* TODO: should keys default to string? */
- self->keys = avro_string_create (ctx, &self->base_value, pool, NULL);
+ self->keys =
+ avro_value_registry[AVRO_STRING]->create (ctx, &self->base_value,
+ pool, NULL);
}
/* collect and save required values */
@@ -113,3 +111,20 @@
}
return &self->base_value;
}
+
+const struct avro_value_info avro_map_info = {
+ .name = L"map",
+ .type = AVRO_MAP,
+ .private = 0,
+ .create = avro_map_create,
+ .formats = {{
+ .read_data = avro_map_read,
+ .skip_data = avro_map_skip,
+ .write_data = avro_map_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_map_read,
+ .skip_data = avro_map_skip,
+ .write_data = avro_map_write}},
+ .print_info = avro_map_print
+};
Modified: hadoop/avro/trunk/src/c/avro_null.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_null.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_null.c (original)
+++ hadoop/avro/trunk/src/c/avro_null.c Tue Oct 27 17:47:55 2009
@@ -31,7 +31,7 @@
fprintf (fp, "null\n");
}
-struct avro_value *
+static struct avro_value *
avro_null_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -45,9 +45,22 @@
self->pool = pool;
self->parent = parent;
self->schema = json;
- self->read_data = avro_null_noop;
- self->skip_data = avro_null_noop;
- self->write_data = avro_null_noop;
- self->print_info = avro_null_print;
return self;
}
+
+const struct avro_value_info avro_null_info = {
+ .name = L"null",
+ .type = AVRO_NULL,
+ .private = 0,
+ .create = avro_null_create,
+ .formats = {{
+ .read_data = avro_null_noop,
+ .skip_data = avro_null_noop,
+ .write_data = avro_null_noop},
+ {
+ /* TODO: import/export */
+ .read_data = avro_null_noop,
+ .skip_data = avro_null_noop,
+ .write_data = avro_null_noop}},
+ .print_info = avro_null_print
+};
Modified: hadoop/avro/trunk/src/c/avro_private.h
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_private.h?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_private.h (original)
+++ hadoop/avro/trunk/src/c/avro_private.h Tue Oct 27 17:47:55 2009
@@ -54,7 +54,9 @@
enum avro_format
{
AVRO_BINARY_FORMAT,
- AVRO_JSON_IMPORT_EXPORT_FORMAT
+ AVRO_JSON_IMPORT_EXPORT_FORMAT,
+ /* NOTE: the following must always be last */
+ AVRO_NUM_DATA_FORMATS
};
typedef enum avro_format avro_format;
@@ -66,30 +68,55 @@
};
typedef struct avro_channel avro_channel;
-/* General struct that all values implement */
+/* information that all values have */
struct avro_value
{
avro_type_t type;
apr_pool_t *pool;
const JSON_value *schema;
struct avro_value *parent;
-
- avro_status_t (*read_data) (struct avro_value * value,
- struct avro_channel * channel);
- avro_status_t (*skip_data) (struct avro_value * value,
- struct avro_channel * channel);
- avro_status_t (*write_data) (struct avro_value * value,
- struct avro_channel * channel);
- void (*print_info) (struct avro_value * value, FILE * fp);
};
typedef struct avro_value avro_value;
+struct avro_value_methods
+{
+ avro_status_t (*read_data) (struct avro_value * value,
+ struct avro_channel * channel);
+ avro_status_t (*skip_data) (struct avro_value * value,
+ struct avro_channel * channel);
+ avro_status_t (*write_data) (struct avro_value * value,
+ struct avro_channel * channel);
+};
+
/* Globals used during schema creation */
struct avro_value_ctx
{
apr_hash_t *named_objects;
};
+struct avro_value_info
+{
+ avro_string_t name;
+ avro_type_t type;
+ int private;
+ struct avro_value *(*create) (struct avro_value_ctx * ctx,
+ struct avro_value * parent, apr_pool_t * pool,
+ const JSON_value * json);
+ void (*print_info) (struct avro_value * value, FILE * fp);
+ struct avro_value_methods formats[AVRO_NUM_DATA_FORMATS];
+};
+
+extern const struct avro_value_info *avro_value_registry[];
+
+avro_status_t avro_value_read_data (struct avro_value *value,
+ struct avro_channel *channel);
+avro_status_t avro_value_skip_data (struct avro_value *value,
+ struct avro_channel *channel);
+avro_status_t avro_value_write_data (struct avro_value *value,
+ struct avro_channel *channel);
+void avro_value_print_info (struct avro_value *value, FILE * fp);
+
+
/* Create a new avro value from json */
struct avro_value *avro_value_create (apr_pool_t * pool, char *jsontext,
apr_size_t textlen);
@@ -97,66 +124,6 @@
struct avro_value *parent,
const JSON_value * json);
-struct avro_value *avro_record_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_string_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_boolean_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_bytes_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_int_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_long_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_float_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_double_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_null_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_enum_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_fixed_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_map_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_array_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-struct avro_value *avro_union_create (struct avro_value_ctx *ctx,
- struct avro_value *parent,
- apr_pool_t * pool,
- const JSON_value * schema);
-
-const avro_type_t *avro_type_lookup (const avro_string_t name);
-const avro_type_t *avro_type_from_json (const JSON_value * json);
-
/* Helper utility for reading an attribute from a JSON object */
const JSON_value *json_attr_get (const JSON_value * obj, const wchar_t * key);
/* Helper utility for reading an attribute from JSON w/type checking */
Modified: hadoop/avro/trunk/src/c/avro_record.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_record.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_record.c (original)
+++ hadoop/avro/trunk/src/c/avro_record.c Tue Oct 27 17:47:55 2009
@@ -37,17 +37,17 @@
};
static void
-field_print (struct avro_value *value, FILE * fp)
+avro_field_print (struct avro_value *value, FILE * fp)
{
struct avro_field_value *self =
container_of (value, struct avro_field_value, base_value);
avro_value_indent (value, fp);
- fprintf (fp, "field name=%ls\n", self->name);
- self->value->print_info (self->value, fp);
+ fprintf (fp, "field(%p) name=%ls\n", self, self->name);
+ avro_value_print_info (self->value, fp);
}
static void
-record_print (struct avro_value *value, FILE * fp)
+avro_record_print (struct avro_value *value, FILE * fp)
{
int i;
struct avro_record_value *self =
@@ -58,36 +58,44 @@
{
struct avro_value *field =
((struct avro_value **) self->fields->elts)[i];
- field->print_info (field, fp);
+ avro_value_print_info (field, fp);
}
}
/* FIELDS */
static avro_status_t
-field_read (struct avro_value *value, struct avro_channel *channel)
+avro_field_read (struct avro_value *value, struct avro_channel *channel)
{
struct avro_field_value *self =
container_of (value, struct avro_field_value, base_value);
- return self->value->read_data (self->value, channel);
+ return avro_value_read_data (self->value, channel);
}
static avro_status_t
-field_skip (struct avro_value *value, struct avro_channel *channel)
+avro_field_skip (struct avro_value *value, struct avro_channel *channel)
{
struct avro_field_value *self =
container_of (value, struct avro_field_value, base_value);
- return self->value->skip_data (self->value, channel);
+ return avro_value_skip_data (self->value, channel);
}
static avro_status_t
-field_write (struct avro_value *value, struct avro_channel *channel)
+avro_field_write (struct avro_value *value, struct avro_channel *channel)
{
struct avro_field_value *self =
container_of (value, struct avro_field_value, base_value);
- return self->value->write_data (self->value, channel);
+ return avro_value_write_data (self->value, channel);
}
-/* Private */
+/* The field constructor is private so we register a noop */
+static struct avro_value *
+avro_field_create_noop (struct avro_value_ctx *ctx, struct avro_value *parent,
+ apr_pool_t * pool, const JSON_value * json)
+{
+ return NULL;
+}
+
+/* Should only be called by record functions */
static struct avro_value *
avro_field_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
@@ -105,10 +113,6 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = field_read;
- self->base_value.skip_data = field_skip;
- self->base_value.write_data = field_write;
- self->base_value.print_info = field_print;
/* collect and save required name */
name = json_attr_get_check_type (json, L"name", JSON_STRING);
@@ -139,8 +143,8 @@
}
static avro_status_t
-record_read_skip (struct avro_value *value, struct avro_channel *channel,
- int skip)
+avro_record_read_skip (struct avro_value *value, struct avro_channel *channel,
+ int skip)
{
int i;
struct avro_record_value *self =
@@ -152,11 +156,11 @@
((struct avro_value **) self->fields->elts)[i];
if (skip)
{
- field->skip_data (field, channel);
+ avro_value_skip_data (field, channel);
}
else
{
- field->read_data (field, channel);
+ avro_value_read_data (field, channel);
}
}
return AVRO_OK;
@@ -164,19 +168,19 @@
/* RECORD */
static avro_status_t
-record_read (struct avro_value *value, struct avro_channel *channel)
+avro_record_read (struct avro_value *value, struct avro_channel *channel)
{
- return record_read_skip (value, channel, 0);
+ return avro_record_read_skip (value, channel, 0);
}
static avro_status_t
-record_skip (struct avro_value *value, struct avro_channel *channel)
+avro_record_skip (struct avro_value *value, struct avro_channel *channel)
{
- return record_read_skip (value, channel, 1);
+ return avro_record_read_skip (value, channel, 1);
}
static avro_status_t
-record_write (struct avro_value *value, struct avro_channel *channel)
+avro_record_write (struct avro_value *value, struct avro_channel *channel)
{
/* TODO:
struct avro_record_value *record =
@@ -185,7 +189,7 @@
return AVRO_OK;
}
-struct avro_value *
+static struct avro_value *
avro_record_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -208,10 +212,6 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = record_read;
- self->base_value.skip_data = record_skip;
- self->base_value.write_data = record_write;
- self->base_value.print_info = record_print;
/* collect and save required name */
name = json_attr_get_check_type (json, L"name", JSON_STRING);
@@ -270,3 +270,37 @@
return &self->base_value;
}
+
+const struct avro_value_info avro_field_info = {
+ .name = L"field",
+ .type = AVRO_FIELD,
+ .private = 1,
+ .create = avro_field_create_noop,
+ .formats = {{
+ .read_data = avro_field_read,
+ .skip_data = avro_field_skip,
+ .write_data = avro_field_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_field_read,
+ .skip_data = avro_field_skip,
+ .write_data = avro_field_write}},
+ .print_info = avro_field_print
+};
+
+const struct avro_value_info avro_record_info = {
+ .name = L"record",
+ .type = AVRO_RECORD,
+ .private = 0,
+ .create = avro_record_create,
+ .formats = {{
+ .read_data = avro_record_read,
+ .skip_data = avro_record_skip,
+ .write_data = avro_record_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_record_read,
+ .skip_data = avro_record_skip,
+ .write_data = avro_record_write}},
+ .print_info = avro_record_print
+};
Modified: hadoop/avro/trunk/src/c/avro_string.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_string.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_string.c (original)
+++ hadoop/avro/trunk/src/c/avro_string.c Tue Oct 27 17:47:55 2009
@@ -109,7 +109,7 @@
return avro_putstring (io, self->pool, self->value);
}
-struct avro_value *
+static struct avro_value *
avro_string_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -124,10 +124,6 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_string_read;
- self->base_value.skip_data = avro_string_skip;
- self->base_value.write_data = avro_string_write;
- self->base_value.print_info = avro_string_print;
self->value_set = 0;
if (apr_pool_create (&self->pool, pool) != APR_SUCCESS)
{
@@ -135,3 +131,20 @@
}
return &self->base_value;
}
+
+const struct avro_value_info avro_string_info = {
+ .name = L"string",
+ .type = AVRO_STRING,
+ .private = 0,
+ .create = avro_string_create,
+ .formats = {{
+ .read_data = avro_string_read,
+ .skip_data = avro_string_skip,
+ .write_data = avro_string_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_string_read,
+ .skip_data = avro_string_skip,
+ .write_data = avro_string_write}},
+ .print_info = avro_string_print
+};
Modified: hadoop/avro/trunk/src/c/avro_union.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_union.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_union.c (original)
+++ hadoop/avro/trunk/src/c/avro_union.c Tue Oct 27 17:47:55 2009
@@ -24,14 +24,13 @@
struct avro_value base_value;
};
-static avro_status_t
+void
avro_union_print (struct avro_value *value, FILE * fp)
{
struct avro_union_value *self =
container_of (value, struct avro_union_value, base_value);
avro_value_indent (value, fp);
- fprintf (fp, "union\n");
- return AVRO_OK;
+ fprintf (fp, "union(%p)\n", self);
}
static avro_status_t
@@ -58,7 +57,7 @@
return AVRO_OK;
}
-struct avro_value *
+static struct avro_value *
avro_union_create (struct avro_value_ctx *ctx, struct avro_value *parent,
apr_pool_t * pool, const JSON_value * json)
{
@@ -78,11 +77,23 @@
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = json;
- self->base_value.read_data = avro_union_read;
- self->base_value.skip_data = avro_union_skip;
- self->base_value.write_data = avro_union_write;
- self->base_value.print_info = avro_union_print;
-
/* TODO: check the schemas ... and save them */
return &self->base_value;
}
+
+const struct avro_value_info avro_union_info = {
+ .name = L"union",
+ .type = AVRO_UNION,
+ .private = 0,
+ .create = avro_union_create,
+ .formats = {{
+ .read_data = avro_union_read,
+ .skip_data = avro_union_skip,
+ .write_data = avro_union_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_union_read,
+ .skip_data = avro_union_skip,
+ .write_data = avro_union_write}},
+ .print_info = avro_union_print
+};
Modified: hadoop/avro/trunk/src/c/avro_value.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_value.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_value.c (original)
+++ hadoop/avro/trunk/src/c/avro_value.c Tue Oct 27 17:47:55 2009
@@ -18,6 +18,92 @@
*/
#include "avro_private.h"
+extern const struct avro_value_info avro_string_info;
+extern const struct avro_value_info avro_bytes_info;
+extern const struct avro_value_info avro_int_info;
+extern const struct avro_value_info avro_long_info;
+extern const struct avro_value_info avro_float_info;
+extern const struct avro_value_info avro_double_info;
+extern const struct avro_value_info avro_boolean_info;
+extern const struct avro_value_info avro_null_info;
+extern const struct avro_value_info avro_record_info;
+extern const struct avro_value_info avro_field_info;
+extern const struct avro_value_info avro_enum_info;
+extern const struct avro_value_info avro_fixed_info;
+extern const struct avro_value_info avro_map_info;
+extern const struct avro_value_info avro_array_info;
+extern const struct avro_value_info avro_union_info;
+extern const struct avro_value_info avro_decorator_info;
+/* WARNING: This registry must match the avro_value_t enum! */
+const struct avro_value_info *avro_value_registry[AVRO_NUM_TYPES] = {
+ &avro_string_info,
+ &avro_bytes_info,
+ &avro_int_info,
+ &avro_long_info,
+ &avro_float_info,
+ &avro_double_info,
+ &avro_boolean_info,
+ &avro_null_info,
+ &avro_record_info,
+ &avro_enum_info,
+ &avro_fixed_info,
+ &avro_map_info,
+ &avro_array_info,
+ &avro_union_info,
+ &avro_field_info,
+ &avro_decorator_info
+};
+
+/* TODO: gperf this? */
+static avro_status_t
+avro_type_lookup (const avro_string_t name, avro_type_t * type)
+{
+ int i;
+ if (name)
+ {
+ for (i = 0; i < AVRO_NUM_TYPES; i++)
+ {
+ const struct avro_value_info *info = avro_value_registry[i];
+ if (!info->private && wcscmp (info->name, name) == 0)
+ {
+ *type = info->type;
+ return AVRO_OK;
+ }
+ }
+ }
+ return AVRO_FAILURE;
+}
+
+static avro_status_t
+avro_type_from_json (const JSON_value * json, avro_type_t * type)
+{
+ if (!json)
+ {
+ return AVRO_FAILURE;
+ }
+
+ if (json->type == JSON_STRING)
+ {
+ return avro_type_lookup (json->json_string, type);
+ }
+ else if (json->type == JSON_ARRAY)
+ {
+ *type = AVRO_UNION;
+ return AVRO_OK;
+ }
+ else if (json->type == JSON_OBJECT)
+ {
+ const JSON_value *type_attr =
+ json_attr_get_check_type (json, L"type", JSON_STRING);
+ if (type_attr)
+ {
+ return avro_type_lookup (type_attr->json_string, type);
+ }
+ }
+
+ return AVRO_FAILURE;
+}
+
struct avro_decorator_value
{
struct avro_value *decoratee;
@@ -38,7 +124,7 @@
{
struct avro_decorator_value *self =
container_of (value, struct avro_decorator_value, base_value);
- return self->decoratee->read_data (self->decoratee, channel);
+ return avro_value_read_data (self->decoratee, channel);
}
static avro_status_t
@@ -46,7 +132,7 @@
{
struct avro_decorator_value *self =
container_of (value, struct avro_decorator_value, base_value);
- return self->decoratee->skip_data (self->decoratee, channel);
+ return avro_value_skip_data (self->decoratee, channel);
}
static avro_status_t
@@ -54,7 +140,7 @@
{
struct avro_decorator_value *self =
container_of (value, struct avro_decorator_value, base_value);
- return self->decoratee->write_data (self->decoratee, channel);
+ return avro_value_write_data (self->decoratee, channel);
}
/* Used for recursive schemas */
@@ -69,27 +155,48 @@
{
return NULL;
}
- self->base_value.type = 1000; /* TODO: ... */
+ self->base_value.type = AVRO_DECORATOR;
self->base_value.pool = pool;
self->base_value.parent = parent;
self->base_value.schema = decoratee->schema;
- self->base_value.read_data = avro_decorator_read;
- self->base_value.skip_data = avro_decorator_skip;
- self->base_value.write_data = avro_decorator_write;
- self->base_value.print_info = avro_decorator_print;
-
/* object we're decorating */
self->decoratee = decoratee;
return &self->base_value;
}
+static struct avro_value *
+avro_decorator_create_noop (struct avro_value_ctx *ctx,
+ struct avro_value *parent, apr_pool_t * pool,
+ const JSON_value * json)
+{
+ return NULL;
+}
+
+const struct avro_value_info avro_decorator_info = {
+ .name = L"decorator",
+ .type = AVRO_DECORATOR,
+ .private = 1,
+ .create = avro_decorator_create_noop,
+ .formats = {{
+ .read_data = avro_decorator_read,
+ .skip_data = avro_decorator_skip,
+ .write_data = avro_decorator_write},
+ {
+ /* TODO: import/export */
+ .read_data = avro_decorator_read,
+ .skip_data = avro_decorator_skip,
+ .write_data = avro_decorator_write}},
+ .print_info = avro_decorator_print
+};
+
+
struct avro_value *
avro_value_from_json (struct avro_value_ctx *ctx,
struct avro_value *parent, const JSON_value * json)
{
+ avro_status_t avro_status;
apr_status_t status;
- struct avro_value *value;
- const avro_type_t *avro_type;
+ avro_type_t avro_type;
apr_pool_t *subpool;
status = apr_pool_create (&subpool, parent ? parent->pool : NULL);
@@ -98,8 +205,8 @@
return NULL;
}
- avro_type = avro_type_from_json (json);
- if (!avro_type)
+ avro_status = avro_type_from_json (json, &avro_type);
+ if (avro_status != AVRO_OK)
{
if (json->type == JSON_STRING)
{
@@ -115,62 +222,13 @@
return NULL;
}
- value = NULL;
- switch (*avro_type)
- {
- case AVRO_STRING:
- value = avro_string_create (ctx, parent, subpool, json);
- break;
- case AVRO_BYTES:
- value = avro_bytes_create (ctx, parent, subpool, json);
- break;
- case AVRO_INT:
- value = avro_int_create (ctx, parent, subpool, json);
- break;
- case AVRO_LONG:
- value = avro_long_create (ctx, parent, subpool, json);
- break;
- case AVRO_FLOAT:
- value = avro_float_create (ctx, parent, subpool, json);
- break;
- case AVRO_DOUBLE:
- value = avro_double_create (ctx, parent, subpool, json);
- break;
- case AVRO_BOOLEAN:
- value = avro_boolean_create (ctx, parent, subpool, json);
- break;
- case AVRO_NULL:
- value = avro_null_create (ctx, parent, subpool, json);
- break;
- case AVRO_RECORD:
- value = avro_record_create (ctx, parent, subpool, json);
- break;
- case AVRO_ENUM:
- value = avro_enum_create (ctx, parent, subpool, json);
- break;
- case AVRO_FIXED:
- value = avro_fixed_create (ctx, parent, subpool, json);
- break;
- case AVRO_MAP:
- value = avro_map_create (ctx, parent, subpool, json);
- break;
- case AVRO_ARRAY:
- value = avro_array_create (ctx, parent, subpool, json);
- break;
- case AVRO_UNION:
- value = avro_union_create (ctx, parent, subpool, json);
- break;
- case AVRO_FIELD:
- /* fields are created by record_create */
- break;
- }
- return value;
+ return avro_value_registry[avro_type]->private ? NULL:
+ avro_value_registry[avro_type]->create (ctx, parent, subpool, json);
}
struct avro_value *
avro_value_create (apr_pool_t * pool, char *jsontext, apr_size_t textlen)
{
- apr_status_t status;
struct avro_value_ctx *ctx;
const JSON_value *json = JSON_parse (pool, jsontext, textlen);
@@ -195,3 +253,49 @@
return avro_value_from_json (ctx, NULL, json);
}
+
+avro_status_t
+avro_value_read_data (struct avro_value * value,
+ struct avro_channel * channel)
+{
+ if (!value || !channel)
+ {
+ return AVRO_FAILURE;
+ }
+ return avro_value_registry[value->type]->formats[channel->format].
+ read_data (value, channel);
+}
+
+avro_status_t
+avro_value_skip_data (struct avro_value * value,
+ struct avro_channel * channel)
+{
+ if (!value || !channel)
+ {
+ return AVRO_FAILURE;
+ }
+ return avro_value_registry[value->type]->formats[channel->format].
+ skip_data (value, channel);
+}
+
+avro_status_t
+avro_value_write_data (struct avro_value * value,
+ struct avro_channel * channel)
+{
+ if (!value || !channel)
+ {
+ return AVRO_FAILURE;
+ }
+ return avro_value_registry[value->type]->formats[channel->format].
+ write_data (value, channel);
+}
+
+void
+avro_value_print_info (struct avro_value *value, FILE * fp)
+{
+ if (!value || !fp)
+ {
+ return;
+ }
+ avro_value_registry[value->type]->print_info (value, fp);
+}
Modified: hadoop/avro/trunk/src/c/test_avro_schema.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/test_avro_schema.c?rev=830265&r1=830264&r2=830265&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/test_avro_schema.c (original)
+++ hadoop/avro/trunk/src/c/test_avro_schema.c Tue Oct 27 17:47:55 2009
@@ -60,7 +60,7 @@
value = avro_value_create (pool, jsontext, jsonlen);
if (value && should_pass)
{
- /*value->print_info (value, stderr); */
+ avro_value_print_info (value, stderr);
}
else if (!value && !should_pass)
{