Author: massie
Date: Mon Jan 18 05:30:24 2010
New Revision: 900279
URL: http://svn.apache.org/viewvc?rev=900279&view=rev
Log:
AVRO-346. Add function to validate a datum against a schema
Modified:
hadoop/avro/trunk/lang/c/docs/ (props changed)
hadoop/avro/trunk/lang/c/docs/Makefile.am
hadoop/avro/trunk/lang/c/docs/index.txt
hadoop/avro/trunk/lang/c/jansson/ (props changed)
hadoop/avro/trunk/lang/c/jansson/doc/ (props changed)
hadoop/avro/trunk/lang/c/jansson/install-sh
hadoop/avro/trunk/lang/c/jansson/ltmain.sh
hadoop/avro/trunk/lang/c/jansson/src/ (props changed)
hadoop/avro/trunk/lang/c/jansson/test/ (props changed)
hadoop/avro/trunk/lang/c/jansson/test/testdata/ (props changed)
hadoop/avro/trunk/lang/c/jansson/test/testprogs/ (props changed)
hadoop/avro/trunk/lang/c/src/ (props changed)
hadoop/avro/trunk/lang/c/src/avro.h
hadoop/avro/trunk/lang/c/src/datum.c
hadoop/avro/trunk/lang/c/src/datum.h
hadoop/avro/trunk/lang/c/src/io.c
hadoop/avro/trunk/lang/c/src/schema.c
hadoop/avro/trunk/lang/c/src/schema.h
hadoop/avro/trunk/lang/c/src/schema_equal.c
hadoop/avro/trunk/lang/c/src/schema_printf.c
hadoop/avro/trunk/lang/c/tests/ (props changed)
hadoop/avro/trunk/lang/c/tests/test_avro_schema.c
hadoop/avro/trunk/lang/c/version.sh
Propchange: hadoop/avro/trunk/lang/c/docs/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 18 05:30:24 2010
@@ -0,0 +1 @@
+Makefile.in
Modified: hadoop/avro/trunk/lang/c/docs/Makefile.am
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/docs/Makefile.am?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/docs/Makefile.am (original)
+++ hadoop/avro/trunk/lang/c/docs/Makefile.am Mon Jan 18 05:30:24 2010
@@ -4,3 +4,5 @@
.txt.html:
asciidoc --attribute=avro_versi...@version@
--attribute=libavro_versi...@libavro_version@ --attribute=toc -n -o $@ $<
+
+docs: index.html
Modified: hadoop/avro/trunk/lang/c/docs/index.txt
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/docs/index.txt?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/docs/index.txt (original)
+++ hadoop/avro/trunk/lang/c/docs/index.txt Mon Jan 18 05:30:24 2010
@@ -29,19 +29,15 @@
....
+The C implementation is still *alpha* is not ready for
+production use. The current code is being tested on
++MacOS X+ and +Linux+.
+We're making rapid progress and the +avro.h+ header file
+can give you an idea of what the API will likely look like.
[source,c]
----
-#include <stdio.h>
-#include <stdlib.h>
-#include <avro.h>
-
-int
-main(void){
- schema_t schema = schema_string();
- fprintf(stderr,"Hello, world!\n");
- schema_decref(schema);
- return EXIT_SUCCESS;
-}
+include::../src/avro.h[]
----
+
Propchange: hadoop/avro/trunk/lang/c/jansson/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 18 05:30:24 2010
@@ -0,0 +1,5 @@
+Makefile.in
+config.h.in
+autom4te.cache
+aclocal.m4
+configure
Propchange: hadoop/avro/trunk/lang/c/jansson/doc/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 18 05:30:24 2010
@@ -0,0 +1 @@
+Makefile.in
Modified: hadoop/avro/trunk/lang/c/jansson/install-sh
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/jansson/install-sh?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/jansson/install-sh (original)
+++ hadoop/avro/trunk/lang/c/jansson/install-sh Mon Jan 18 05:30:24 2010
@@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
-scriptversion=2006-12-25.00
+scriptversion=2009-04-28.21; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@@ -515,5 +515,6 @@
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
# End:
Modified: hadoop/avro/trunk/lang/c/jansson/ltmain.sh
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/jansson/ltmain.sh?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/jansson/ltmain.sh (original)
+++ hadoop/avro/trunk/lang/c/jansson/ltmain.sh Mon Jan 18 05:30:24 2010
@@ -65,7 +65,7 @@
# compiler: $LTCC
# compiler flags: $LTCFLAGS
# linker: $LD (gnu? $with_gnu_ld)
-# $progname: (GNU libtool) 2.2.6 Debian-2.2.6a-4
+# $progname: (GNU libtool) 2.2.6
# automake: $automake_version
# autoconf: $autoconf_version
#
@@ -73,7 +73,7 @@
PROGRAM=ltmain.sh
PACKAGE=libtool
-VERSION="2.2.6 Debian-2.2.6a-4"
+VERSION=2.2.6
TIMESTAMP=""
package_revision=1.3012
@@ -116,15 +116,15 @@
: ${CP="cp -f"}
: ${ECHO="echo"}
-: ${EGREP="/bin/grep -E"}
-: ${FGREP="/bin/grep -F"}
-: ${GREP="/bin/grep"}
+: ${EGREP="/usr/bin/grep -E"}
+: ${FGREP="/usr/bin/grep -F"}
+: ${GREP="/usr/bin/grep"}
: ${LN_S="ln -s"}
: ${MAKE="make"}
: ${MKDIR="mkdir"}
: ${MV="mv -f"}
: ${RM="rm -f"}
-: ${SED="/bin/sed"}
+: ${SED="/opt/local/bin/gsed"}
: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
: ${Xsed="$SED -e 1s/^X//"}
@@ -5033,10 +5033,7 @@
case $pass in
dlopen) libs="$dlfiles" ;;
dlpreopen) libs="$dlprefiles" ;;
- link)
- libs="$deplibs %DEPLIBS%"
- test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
- ;;
+ link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
esac
fi
if test "$linkmode,$pass" = "lib,dlpreopen"; then
@@ -5347,19 +5344,19 @@
# It is a libtool convenience library, so add in its objects.
convenience="$convenience $ladir/$objdir/$old_library"
old_convenience="$old_convenience $ladir/$objdir/$old_library"
- tmp_libs=
- for deplib in $dependency_libs; do
- deplibs="$deplib $deplibs"
- if $opt_duplicate_deps ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done
elif test "$linkmode" != prog && test "$linkmode" != lib; then
func_fatal_error "\`$lib' is not a convenience library"
fi
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ deplibs="$deplib $deplibs"
+ if $opt_duplicate_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done
continue
fi # $pass = conv
@@ -5896,7 +5893,6 @@
if test "$link_all_deplibs" != no; then
# Add the search paths of all dependency libraries
for deplib in $dependency_libs; do
- path=
case $deplib in
-L*) path="$deplib" ;;
*.la)
@@ -6210,9 +6206,6 @@
revision="$number_minor"
lt_irix_increment=no
;;
- *)
- func_fatal_configuration "$modename: unknown library version type
\`$version_type'"
- ;;
esac
;;
no)
Propchange: hadoop/avro/trunk/lang/c/jansson/src/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 18 05:30:24 2010
@@ -0,0 +1 @@
+Makefile.in
Propchange: hadoop/avro/trunk/lang/c/jansson/test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 18 05:30:24 2010
@@ -0,0 +1 @@
+Makefile.in
Propchange: hadoop/avro/trunk/lang/c/jansson/test/testdata/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 18 05:30:24 2010
@@ -0,0 +1 @@
+Makefile.in
Propchange: hadoop/avro/trunk/lang/c/jansson/test/testprogs/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 18 05:30:24 2010
@@ -0,0 +1 @@
+Makefile.in
Propchange: hadoop/avro/trunk/lang/c/src/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 18 05:30:24 2010
@@ -0,0 +1 @@
+Makefile.in
Modified: hadoop/avro/trunk/lang/c/src/avro.h
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/avro.h?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/avro.h (original)
+++ hadoop/avro/trunk/lang/c/src/avro.h Mon Jan 18 05:30:24 2010
@@ -26,7 +26,6 @@
#include <stdio.h>
#include <stdint.h>
-#include <unistd.h>
enum avro_type_t
{
@@ -93,8 +92,8 @@
||is_avro_fixed(obj))
#define is_avro_map(obj) (obj && avro_typeof(obj) == AVRO_MAP)
#define is_avro_array(obj) (obj && avro_typeof(obj) == AVRO_ARRAY)
-#define is_avro_union(obj) (obj && avro_typeof(obj) == AVRO_UNION)
-#define is_avro_complex_type(obj) (!(is_avro_primitive(obj) ||
is_avro_link(obj)))
+#define is_avro_union(obj) (obj && avro_classof(obj) == AVRO_SCHEMA &&
avro_typeof(obj) == AVRO_UNION)
+#define is_avro_complex_type(obj) (!(is_avro_primitive(obj))
#define is_avro_link(obj) (obj && avro_typeof(obj) == AVRO_LINK)
/* schema */
@@ -120,7 +119,7 @@
int avro_schema_enum_symbol_append (const avro_schema_t enump,
const char *symbol);
- avro_schema_t avro_schema_fixed (const char *name, const size_t len);
+ avro_schema_t avro_schema_fixed (const char *name, const int64_t len);
avro_schema_t avro_schema_map (const avro_schema_t values);
avro_schema_t avro_schema_array (const avro_schema_t items);
@@ -131,7 +130,7 @@
avro_schema_t avro_schema_link (avro_schema_t schema);
typedef struct avro_schema_error_t *avro_schema_error_t;
- int avro_schema_from_json (const char *jsontext, size_t len,
+ int avro_schema_from_json (const char *jsontext, const int32_t len,
avro_schema_t * schema,
avro_schema_error_t * error);
@@ -143,7 +142,24 @@
void avro_schema_printf (avro_schema_t schema, FILE * fp);
- /* value */
+ /* io */
+ typedef struct avro_reader_t *avro_reader_t;
+ typedef struct avro_writer_t *avro_writer_t;
+
+ avro_reader_t avro_reader_file (FILE * fp);
+ avro_writer_t avro_writer_file (FILE * fp);
+ avro_reader_t avro_reader_memory (const char *buf, int64_t len);
+ avro_writer_t avro_writer_memory (const char *buf, int64_t len);
+
+ int avro_read (avro_reader_t reader, void *buf, int64_t len);
+ int avro_skip (avro_reader_t reader, int64_t len);
+ int avro_write (avro_writer_t writer, void *buf, int64_t len);
+ int avro_flush (avro_writer_t writer);
+
+ void avro_reader_free (avro_reader_t reader);
+ void avro_writer_free (avro_writer_t writer);
+
+ /* datum */
typedef struct avro_obj_t *avro_datum_t;
avro_datum_t avro_string (const char *str);
avro_datum_t avro_bytes (const char *buf, int64_t len);
@@ -157,13 +173,13 @@
avro_datum_t avro_record (const char *name);
avro_datum_t avro_record_field_get (const avro_datum_t record,
const char *field_name);
- int avro_record_field_append (const avro_datum_t record,
- const char *field_name,
- const avro_datum_t value);
+ int avro_record_field_set (const avro_datum_t record,
+ const char *field_name,
+ const avro_datum_t value);
avro_datum_t avro_enum (const char *name, const char *symbol);
- avro_datum_t avro_fixed (const char *name, const size_t len,
+ avro_datum_t avro_fixed (const char *name, const int64_t len,
const char *bytes);
avro_datum_t avro_map (const avro_datum_t values);
@@ -178,30 +194,17 @@
void avro_datum_print (avro_datum_t value, FILE * fp);
-/* IO */
- typedef struct avro_reader_t *avro_reader_t;
- typedef struct avro_writer_t *avro_writer_t;
+ int schema_match (avro_schema_t writers_schema,
+ avro_schema_t readers_schema);
- avro_reader_t avro_reader_file (FILE * fp);
- avro_writer_t avro_writer_file (FILE * fp);
- avro_reader_t avro_reader_memory (const char *buf, size_t len);
- avro_writer_t avro_writer_memory (const char *buf, size_t len);
+ int schema_datum_validate (avro_schema_t expected_schema,
+ avro_datum_t datum);
- int avro_read (avro_reader_t reader, void *buf, int64_t len);
- int avro_skip (avro_reader_t reader, int64_t len);
- int avro_write (avro_writer_t writer, void *buf, int64_t len);
- int avro_flush (avro_writer_t writer);
-
- void avro_reader_free (avro_reader_t reader);
- void avro_writer_free (avro_writer_t writer);
-
-/* Datum */
int avro_read_data (avro_reader_t reader, avro_schema_t writer_schema,
avro_schema_t reader_schema, avro_datum_t * datum);
int avro_write_data (avro_writer_t writer, avro_schema_t writer_schema,
avro_datum_t datum);
-
#ifdef __cplusplus
}
#endif
Modified: hadoop/avro/trunk/lang/c/src/datum.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/datum.c?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/datum.c (original)
+++ hadoop/avro/trunk/lang/c/src/datum.c Mon Jan 18 05:30:24 2010
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <limits.h>
#include "avro.h"
#include "schema.h"
#include "datum.h"
@@ -35,113 +36,111 @@
avro_datum_t
avro_string (const char *str)
{
- struct avro_string_datum_t *string_datum =
+ struct avro_string_datum_t *datum =
malloc (sizeof (struct avro_string_datum_t));
- if (!string_datum)
+ if (!datum)
{
return NULL;
}
- string_datum->s = strdup (str);
+ datum->s = strdup (str);
- avro_datum_init (&string_datum->obj, AVRO_STRING);
- return &string_datum->obj;
+ avro_datum_init (&datum->obj, AVRO_STRING);
+ return &datum->obj;
}
avro_datum_t
avro_bytes (const char *buf, int64_t len)
{
- struct avro_bytes_datum_t *bytes_datum =
+ struct avro_bytes_datum_t *datum =
malloc (sizeof (struct avro_bytes_datum_t));
- if (!bytes_datum)
+ if (!datum)
{
return NULL;
}
- bytes_datum->buf = malloc (len);
- if (!bytes_datum->buf)
+ datum->buf = malloc (len);
+ if (!datum->buf)
{
- free (bytes_datum);
+ free (datum);
return NULL;
}
- memcpy (bytes_datum->buf, buf, len);
- bytes_datum->len = len;
+ memcpy (datum->buf, buf, len);
+ datum->len = len;
- avro_datum_init (&bytes_datum->obj, AVRO_BYTES);
- return &bytes_datum->obj;
+ avro_datum_init (&datum->obj, AVRO_BYTES);
+ return &datum->obj;
}
avro_datum_t
avro_int (int32_t i)
{
- struct avro_int_datum_t *int_datum =
- malloc (sizeof (struct avro_int_datum_t));
- if (!int_datum)
+ struct avro_int_datum_t *datum = malloc (sizeof (struct avro_int_datum_t));
+ if (!datum)
{
return NULL;
}
- int_datum->i = i;
+ datum->i = i;
- avro_datum_init (&int_datum->obj, AVRO_INT);
- return &int_datum->obj;
+ avro_datum_init (&datum->obj, AVRO_INT);
+ return &datum->obj;
}
avro_datum_t
avro_long (int64_t l)
{
- struct avro_long_datum_t *long_datum =
+ struct avro_long_datum_t *datum =
malloc (sizeof (struct avro_long_datum_t));
- if (!long_datum)
+ if (!datum)
{
return NULL;
}
- long_datum->l = l;
+ datum->l = l;
- avro_datum_init (&long_datum->obj, AVRO_LONG);
- return &long_datum->obj;
+ avro_datum_init (&datum->obj, AVRO_LONG);
+ return &datum->obj;
}
avro_datum_t
avro_float (float f)
{
- struct avro_float_datum_t *float_datum =
+ struct avro_float_datum_t *datum =
malloc (sizeof (struct avro_float_datum_t));
- if (!float_datum)
+ if (!datum)
{
return NULL;
}
- float_datum->f = f;
+ datum->f = f;
- avro_datum_init (&float_datum->obj, AVRO_FLOAT);
- return &float_datum->obj;
+ avro_datum_init (&datum->obj, AVRO_FLOAT);
+ return &datum->obj;
}
avro_datum_t
avro_double (double d)
{
- struct avro_double_datum_t *double_datum =
+ struct avro_double_datum_t *datum =
malloc (sizeof (struct avro_double_datum_t));
- if (!double_datum)
+ if (!datum)
{
return NULL;
}
- double_datum->d = d;
+ datum->d = d;
- avro_datum_init (&double_datum->obj, AVRO_DOUBLE);
- return &double_datum->obj;
+ avro_datum_init (&datum->obj, AVRO_DOUBLE);
+ return &datum->obj;
}
avro_datum_t
avro_boolean (int8_t i)
{
- struct avro_boolean_datum_t *boolean_datum =
+ struct avro_boolean_datum_t *datum =
malloc (sizeof (struct avro_boolean_datum_t));
- if (!boolean_datum)
+ if (!datum)
{
return NULL;
}
- boolean_datum->i = i;
-
- avro_datum_init (&boolean_datum->obj, AVRO_BOOLEAN);
- return &boolean_datum->obj;
+ datum->i = i;
+ avro_datum_init (&datum->obj, AVRO_BOOLEAN);
+ return &datum->obj;
}
avro_datum_t
@@ -158,112 +157,116 @@
avro_datum_t
avro_record (const char *name)
{
- /* TODO */
- return NULL;
+ struct avro_record_datum_t *datum =
+ malloc (sizeof (struct avro_record_datum_t));
+ if (!datum)
+ {
+ return NULL;
+ }
+ datum->name = strdup (name);
+ datum->fields = st_init_strtable ();
+
+ avro_datum_init (&datum->obj, AVRO_RECORD);
+ return &datum->obj;
}
avro_datum_t
-avro_record_field_get (const avro_datum_t record, const char *field_name)
+avro_record_field_get (const avro_datum_t datum, const char *field_name)
{
- /* TODO */
- return NULL;
+ struct avro_record_datum_t *field = NULL;
+ if (is_avro_datum (datum) && is_avro_record (datum))
+ {
+ struct avro_record_datum_t *record = avro_datum_to_record (datum);
+ st_lookup (record->fields, (st_data_t) field_name,
+ (st_data_t *) & field);
+ }
+ return &field->obj;
}
int
-avro_record_field_append (const avro_datum_t record,
- const char *field_name, const avro_datum_t value)
+avro_record_field_set (const avro_datum_t datum,
+ const char *field_name, const avro_datum_t field_value)
{
- /* TODO */
- return 1;
+ if (is_avro_datum (datum) && is_avro_record (datum))
+ {
+ struct avro_record_datum_t *record = avro_datum_to_record (datum);
+ st_insert (record->fields, (st_data_t) field_name,
+ (st_data_t) field_value);
+ return 0;
+ }
+ return EINVAL;
}
avro_datum_t
avro_enum (const char *name, const char *symbol)
{
- /* TODO */
- return NULL;
-}
+ struct avro_enum_datum_t *datum =
+ malloc (sizeof (struct avro_enum_datum_t));
+ if (!datum)
+ {
+ return NULL;
+ }
+ datum->name = strdup (name);
+ datum->symbol = strdup (symbol);
-int
-avro_enum_symbol_append (const avro_datum_t enum_value, const char *symbol)
-{
- /* TODO */
- return 1;
+ avro_datum_init (&datum->obj, AVRO_ENUM);
+ return &datum->obj;
}
avro_datum_t
-avro_fixed_from_schema (struct schema_fixed_t * schema)
+avro_fixed (const char *name, const int64_t size, const char *bytes)
{
- struct avro_fixed_datum_t *datum;
- if (!schema)
+ struct avro_fixed_datum_t *datum =
+ malloc (sizeof (struct avro_fixed_datum_t));
+ if (!datum)
{
return NULL;
}
- datum = malloc (sizeof (struct avro_fixed_datum_t));
- if (!datum)
+ datum->name = strdup (name);
+ datum->size = size;
+ datum->bytes = malloc (size);
+ if (datum->bytes)
{
+ free (datum);
return NULL;
}
- avro_schema_incref (&schema->obj);
- datum->schema = schema;
+ memcpy (datum->bytes, bytes, size);
avro_datum_init (&datum->obj, AVRO_FIXED);
return &datum->obj;
}
avro_datum_t
-avro_fixed (const char *name, const size_t len, const char *bytes)
+avro_map (const avro_datum_t values)
{
- struct avro_fixed_datum_t *fixed;
- avro_datum_t datum;
- avro_schema_t schema = avro_schema_fixed (name, len);
- if (!schema)
- {
- return NULL;
- }
- datum = avro_fixed_from_schema (schema);
- avro_schema_decref (schema); /* only want one reference */
+ struct avro_map_datum_t *datum = malloc (sizeof (struct avro_map_datum_t));
if (!datum)
{
return NULL;
}
- fixed = avro_datum_to_fixed (datum);
- /* TODO */
- return datum;
-}
-
-avro_datum_t
-avro_map (const avro_datum_t values)
-{
- /* TODO */
- return NULL;
+ datum->map = st_init_strtable ();
+ avro_datum_init (&datum->obj, AVRO_MAP);
+ return &datum->obj;
}
avro_datum_t
avro_array (const avro_datum_t items)
{
- /* TODO */
- return NULL;
-}
-
-avro_datum_t
-avro_union (void)
-{
- /* TODO */
- return NULL;
-}
-
-int
-avro_union_append (const avro_datum_t union_value, const avro_datum_t value)
-{
- /* TODO */
- return 1;
+ struct avro_array_datum_t *datum =
+ malloc (sizeof (struct avro_array_datum_t));
+ if (!datum)
+ {
+ return NULL;
+ }
+ STAILQ_INIT (&datum->els);
+ avro_datum_init (&datum->obj, AVRO_ARRAY);
+ return &datum->obj;
}
avro_datum_t
avro_datum_incref (avro_datum_t value)
{
/* TODO */
- return NULL;
+ return value;
}
void
@@ -278,7 +281,7 @@
}
-static int
+int
schema_match (avro_schema_t writers_schema, avro_schema_t readers_schema)
{
if (is_avro_union (writers_schema) || is_avro_union (readers_schema))
@@ -413,16 +416,16 @@
/* schema resolution */
if (!is_avro_union (writers_schema) && is_avro_union (readers_schema))
{
- struct union_schema_t *s;
- struct schema_union_t *union_schema =
+ struct avro_union_branch_t *branch;
+ struct avro_union_schema_t *union_schema =
avro_schema_to_union (readers_schema);
- for (s = TAILQ_FIRST (&union_schema->schemas);
- s != NULL; s = TAILQ_NEXT (s, schemas))
+ for (branch = STAILQ_FIRST (&union_schema->branches);
+ branch != NULL; branch = STAILQ_NEXT (branch, branches))
{
- if (schema_match (writers_schema, s->schema))
+ if (schema_match (writers_schema, branch->schema))
{
- return avro_read_data (reader, writers_schema, s->schema,
+ return avro_read_data (reader, writers_schema, branch->schema,
datum);
}
}
@@ -524,6 +527,165 @@
return rval;
}
+struct validate_st
+{
+ avro_schema_t expected_schema;
+ int rval;
+};
+
+static int
+schema_map_validate_foreach (char *key, avro_datum_t datum,
+ struct validate_st *vst)
+{
+ if (!schema_datum_validate (vst->expected_schema, datum))
+ {
+ vst->rval = 0;
+ return ST_STOP;
+ }
+ return ST_CONTINUE;
+}
+
+int
+schema_datum_validate (avro_schema_t expected_schema, avro_datum_t datum)
+{
+ if (!is_avro_schema (expected_schema) || !is_avro_datum (datum))
+ {
+ return EINVAL;
+ }
+ /* null */
+ if (is_avro_null (expected_schema) && is_avro_null (datum))
+ {
+ return 1;
+ }
+ /* boolean */
+ else if (is_avro_boolean (expected_schema) && is_avro_boolean (datum))
+ {
+ return 1;
+ }
+ /* string */
+ else if (is_avro_string (expected_schema) && is_avro_boolean (datum))
+ {
+ return 1;
+ }
+ /* bytes */
+ else if (is_avro_bytes (expected_schema) && is_avro_bytes (datum))
+ {
+ return 1;
+ }
+ /* int */
+ else if (is_avro_int (expected_schema)
+ && (is_avro_int (datum)
+ || (is_avro_long (datum)
+ && (INT_MIN <= (avro_datum_to_long (datum))->l
+ && (avro_datum_to_long (datum))->l <= INT_MAX))))
+ {
+ return 1;
+ }
+ /* long */
+ else if (is_avro_long (expected_schema)
+ && (is_avro_int (datum) || is_avro_long (datum)))
+ {
+ return 1;
+ }
+ /* float or double */
+ else
+ if ((is_avro_float (expected_schema) || is_avro_double (expected_schema))
+ && (is_avro_int (datum) || is_avro_long (datum)
+ || is_avro_float (datum)))
+ {
+ return 1;
+ }
+ /* fixed */
+ else if (is_avro_fixed (expected_schema)
+ && (is_avro_fixed (datum)
+ && ((avro_schema_to_fixed (expected_schema))->size ==
+ (avro_datum_to_fixed (datum))->size)))
+ {
+ return 1;
+ }
+ /* enum */
+ else if (is_avro_enum (expected_schema))
+ {
+ struct avro_enum_schema_t *enump =
+ avro_schema_to_enum (expected_schema);
+ struct avro_enum_symbol_t *symbol = STAILQ_FIRST (&enump->symbols);
+ while (symbol)
+ {
+ if (!strcmp (symbol->symbol, (avro_datum_to_enum (datum))->symbol))
+ {
+ return 1;
+ }
+ symbol = STAILQ_NEXT (symbol, symbols);
+ }
+ return 0;
+ }
+ /* array */
+ else if (is_avro_array (expected_schema) && is_avro_array (datum))
+ {
+ struct avro_array_datum_t *array = avro_datum_to_array (datum);
+ struct avro_array_element_t *el = STAILQ_FIRST (&array->els);
+ while (el)
+ {
+ if (!schema_datum_validate
+ ((avro_schema_to_array (expected_schema))->items, el->datum))
+ {
+ return 0;
+ }
+ el = STAILQ_NEXT (el, els);
+ }
+ return 1;
+ }
+ /* map */
+ else if (is_avro_map (expected_schema) && is_avro_map (datum))
+ {
+ struct validate_st vst = { expected_schema, 1 };
+ st_foreach ((avro_datum_to_map (datum))->map,
+ schema_map_validate_foreach, (st_data_t) & vst);
+ return vst.rval;
+ }
+ /* union */
+ else if (is_avro_union (expected_schema))
+ {
+ struct avro_union_schema_t *union_schema =
+ avro_schema_to_union (expected_schema);
+ struct avro_union_branch_t *branch;
+
+ for (branch = STAILQ_FIRST (&union_schema->branches);
+ branch != NULL; branch = STAILQ_NEXT (branch, branches))
+ {
+ if (schema_datum_validate (branch->schema, datum))
+ {
+ return 1;
+ }
+ }
+ return 0;
+ }
+ /* record */
+ else if (is_avro_record (expected_schema) && is_avro_record (datum))
+ {
+ struct avro_record_schema_t *record_schema =
+ avro_schema_to_record (expected_schema);
+ struct avro_record_field_t *field;
+ for (field = STAILQ_FIRST (&record_schema->fields);
+ field != NULL; field = STAILQ_NEXT (field, fields))
+ {
+ avro_datum_t field_datum =
+ avro_record_field_get (datum, field->name);
+ if (!field_datum)
+ {
+ /* TODO: check for default values */
+ return 0;
+ }
+ if (!schema_datum_validate (field->type, field_datum))
+ {
+ return 0;
+ }
+ }
+ return 1;
+ }
+ return 0;
+}
+
int
avro_write_data (avro_writer_t writer, avro_schema_t writer_schema,
avro_datum_t datum)
Modified: hadoop/avro/trunk/lang/c/src/datum.h
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/datum.h?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/datum.h (original)
+++ hadoop/avro/trunk/lang/c/src/datum.h Mon Jan 18 05:30:24 2010
@@ -21,6 +21,8 @@
#define AVRO_DATUM_H
#include "avro.h" /* for avro_schema_t */
#include "container_of.h"
+#include "st.h"
+#include "queue.h"
struct avro_string_datum_t
{
@@ -68,8 +70,41 @@
struct avro_fixed_datum_t
{
struct avro_obj_t obj;
- struct schema_fixed_t *schema;
+ char *name;
char *bytes;
+ int64_t size;
+};
+
+struct avro_map_datum_t
+{
+ struct avro_obj_t obj;
+ st_table *map;
+};
+
+struct avro_record_datum_t
+{
+ struct avro_obj_t obj;
+ const char *name;
+ st_table *fields;
+};
+
+struct avro_enum_datum_t
+{
+ struct avro_obj_t obj;
+ const char *name;
+ const char *symbol;
+};
+
+struct avro_array_element_t
+{
+ avro_datum_t datum;
+ STAILQ_ENTRY (avro_array_element_t) els;
+};
+
+struct avro_array_datum_t
+{
+ struct avro_obj_t obj;
+ STAILQ_HEAD (els, avro_array_element_t) els;
};
#define avro_datum_to_string(datum_) container_of(datum_, struct
avro_string_datum_t, obj)
@@ -80,5 +115,9 @@
#define avro_datum_to_double(datum_) container_of(datum_, struct
avro_double_datum_t, obj)
#define avro_datum_to_boolean(datum_) container_of(datum_, struct
avro_boolean_datum_t, obj)
#define avro_datum_to_fixed(datum_) container_of(datum_, struct
avro_fixed_datum_t, obj)
+#define avro_datum_to_map(datum_) container_of(datum_, struct
avro_map_datum_t, obj)
+#define avro_datum_to_record(datum_) container_of(datum_, struct
avro_record_datum_t, obj)
+#define avro_datum_to_enum(datum_) container_of(datum_, struct
avro_enum_datum_t, obj)
+#define avro_datum_to_array(datum_) container_of(datum_, struct
avro_array_datum_t, obj)
#endif
Modified: hadoop/avro/trunk/lang/c/src/io.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/io.c?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/io.c (original)
+++ hadoop/avro/trunk/lang/c/src/io.c Mon Jan 18 05:30:24 2010
@@ -123,7 +123,7 @@
}
avro_reader_t
-avro_reader_memory (const char *buf, size_t len)
+avro_reader_memory (const char *buf, int64_t len)
{
struct avro_memory_reader_t *mem_reader =
malloc (sizeof (struct avro_memory_reader_t));
@@ -139,7 +139,7 @@
}
avro_writer_t
-avro_writer_memory (const char *buf, size_t len)
+avro_writer_memory (const char *buf, int64_t len)
{
struct avro_memory_writer_t *mem_writer =
malloc (sizeof (struct avro_memory_writer_t));
Modified: hadoop/avro/trunk/lang/c/src/schema.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/schema.c?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/schema.c (original)
+++ hadoop/avro/trunk/lang/c/src/schema.c Mon Jan 18 05:30:24 2010
@@ -162,9 +162,10 @@
}
avro_schema_t
-avro_schema_fixed (const char *name, const size_t size)
+avro_schema_fixed (const char *name, const int64_t size)
{
- struct schema_fixed_t *fixed = malloc (sizeof (struct schema_fixed_t));
+ struct avro_fixed_schema_t *fixed =
+ malloc (sizeof (struct avro_fixed_schema_t));
if (!fixed)
{
return NULL;
@@ -182,42 +183,44 @@
avro_schema_t
avro_schema_union (void)
{
- struct schema_union_t *unionp = malloc (sizeof (struct schema_union_t));
- if (!unionp)
+ struct avro_union_schema_t *schema =
+ malloc (sizeof (struct avro_union_schema_t));
+ if (!schema)
{
return NULL;
}
- TAILQ_INIT (&unionp->schemas);
- avro_schema_init (&unionp->obj, AVRO_UNION);
- return &unionp->obj;
+ STAILQ_INIT (&schema->branches);
+ avro_schema_init (&schema->obj, AVRO_UNION);
+ return &schema->obj;
}
int
avro_schema_union_append (const avro_schema_t union_schema,
const avro_schema_t schema)
{
- struct schema_union_t *unionp;
- struct union_schema_t *s;
+ struct avro_union_schema_t *unionp;
+ struct avro_union_branch_t *s;
if (!union_schema || !schema || !is_avro_union (union_schema))
{
return EINVAL;
}
unionp = avro_schema_to_union (union_schema);
- s = malloc (sizeof (struct union_schema_t));
+ s = malloc (sizeof (struct avro_union_branch_t));
if (!s)
{
return ENOMEM;
}
s->schema = schema;
- TAILQ_INSERT_TAIL (&unionp->schemas, s, schemas);
+ STAILQ_INSERT_TAIL (&unionp->branches, s, branches);
return 0;
}
avro_schema_t
avro_schema_array (const avro_schema_t items)
{
- struct schema_array_t *array = malloc (sizeof (struct schema_array_t));
+ struct avro_array_schema_t *array =
+ malloc (sizeof (struct avro_array_schema_t));
if (!array)
{
return NULL;
@@ -230,7 +233,7 @@
avro_schema_t
avro_schema_map (const avro_schema_t values)
{
- struct schema_map_t *map = malloc (sizeof (struct schema_map_t));
+ struct avro_map_schema_t *map = malloc (sizeof (struct avro_map_schema_t));
if (!map)
{
return NULL;
@@ -243,7 +246,8 @@
avro_schema_t
avro_schema_enum (const char *name)
{
- struct schema_enum_t *enump = malloc (sizeof (struct schema_enum_t));
+ struct avro_enum_schema_t *enump =
+ malloc (sizeof (struct avro_enum_schema_t));
if (!enump)
{
return NULL;
@@ -257,7 +261,7 @@
{
return NULL;
}
- TAILQ_INIT (&enump->symbols);
+ STAILQ_INIT (&enump->symbols);
avro_schema_init (&enump->obj, AVRO_ENUM);
return &enump->obj;
}
@@ -266,20 +270,20 @@
avro_schema_enum_symbol_append (const avro_schema_t enum_schema,
const char *symbol)
{
- struct schema_enum_t *enump;
- struct enum_symbol_t *enum_symbol;
+ struct avro_enum_schema_t *enump;
+ struct avro_enum_symbol_t *enum_symbol;
if (!enum_schema || !symbol || !is_avro_enum (enum_schema))
{
return EINVAL;
}
enump = avro_schema_to_enum (enum_schema);
- enum_symbol = malloc (sizeof (struct enum_symbol_t));
+ enum_symbol = malloc (sizeof (struct avro_enum_symbol_t));
if (!enum_symbol)
{
return ENOMEM;
}
enum_symbol->symbol = strdup (symbol);
- TAILQ_INSERT_TAIL (&enump->symbols, enum_symbol, symbols);
+ STAILQ_INSERT_TAIL (&enump->symbols, enum_symbol, symbols);
return 0;
}
@@ -288,8 +292,8 @@
const char *field_name,
const avro_schema_t field_schema)
{
- struct schema_record_t *record;
- struct record_field_t *new_field;
+ struct avro_record_schema_t *record;
+ struct avro_record_field_t *new_field;
if (!record_schema || !field_name || !field_schema
|| !is_avro_record (record_schema) || record_schema == field_schema
|| !is_avro_id (field_name))
@@ -297,21 +301,22 @@
return EINVAL;
}
record = avro_schema_to_record (record_schema);
- new_field = malloc (sizeof (struct record_field_t));
+ new_field = malloc (sizeof (struct avro_record_field_t));
if (!new_field)
{
return ENOMEM;
}
new_field->name = strdup (field_name);
new_field->type = avro_schema_incref (field_schema);
- TAILQ_INSERT_TAIL (&record->fields, new_field, fields);
+ STAILQ_INSERT_TAIL (&record->fields, new_field, fields);
return 0;
}
avro_schema_t
avro_schema_record (const char *name)
{
- struct schema_record_t *record = malloc (sizeof (struct schema_record_t));
+ struct avro_record_schema_t *record =
+ malloc (sizeof (struct avro_record_schema_t));
if (!record)
{
return NULL;
@@ -321,7 +326,7 @@
return NULL;
}
record->name = strdup (name);
- TAILQ_INIT (&record->fields);
+ STAILQ_INIT (&record->fields);
avro_schema_init (&record->obj, AVRO_RECORD);
return &record->obj;
}
@@ -349,12 +354,12 @@
avro_schema_t
avro_schema_link (avro_schema_t to)
{
- struct schema_link_t *link;
+ struct avro_link_schema_t *link;
if (!is_avro_named_type (to))
{
return NULL;
}
- link = malloc (sizeof (struct schema_link_t));
+ link = malloc (sizeof (struct avro_link_schema_t));
if (!link)
{
return NULL;
@@ -741,7 +746,7 @@
}
int
-avro_schema_from_json (const char *jsontext, size_t len,
+avro_schema_from_json (const char *jsontext, const int32_t len,
avro_schema_t * schema, avro_schema_error_t * e)
{
json_t *root;
@@ -802,12 +807,12 @@
break;
case AVRO_RECORD:
{
- struct schema_record_t *record_schema =
+ struct avro_record_schema_t *record_schema =
avro_schema_to_record (schema);
- struct record_field_t *field;
+ struct avro_record_field_t *field;
new_schema = avro_schema_record (record_schema->name);
- for (field = TAILQ_FIRST (&record_schema->fields);
- field != NULL; field = TAILQ_NEXT (field, fields))
+ for (field = STAILQ_FIRST (&record_schema->fields);
+ field != NULL; field = STAILQ_NEXT (field, fields))
{
avro_schema_t field_copy = avro_schema_copy (field->type);
if (!field_copy)
@@ -826,12 +831,12 @@
break;
case AVRO_ENUM:
{
- struct schema_enum_t *enum_schema = avro_schema_to_enum (schema);
+ struct avro_enum_schema_t *enum_schema = avro_schema_to_enum (schema);
new_schema = avro_schema_enum (enum_schema->name);
- struct enum_symbol_t *enum_symbol;
- for (enum_symbol = TAILQ_FIRST (&enum_schema->symbols);
+ struct avro_enum_symbol_t *enum_symbol;
+ for (enum_symbol = STAILQ_FIRST (&enum_schema->symbols);
enum_symbol != NULL;
- enum_symbol = TAILQ_NEXT (enum_symbol, symbols))
+ enum_symbol = STAILQ_NEXT (enum_symbol, symbols))
{
if (avro_schema_enum_symbol_append
(new_schema, enum_symbol->symbol))
@@ -844,14 +849,15 @@
break;
case AVRO_FIXED:
{
- struct schema_fixed_t *fixed_schema = avro_schema_to_fixed (schema);
+ struct avro_fixed_schema_t *fixed_schema =
+ avro_schema_to_fixed (schema);
new_schema =
avro_schema_fixed (fixed_schema->name, fixed_schema->size);
}
break;
case AVRO_MAP:
{
- struct schema_map_t *map_schema = avro_schema_to_map (schema);
+ struct avro_map_schema_t *map_schema = avro_schema_to_map (schema);
avro_schema_t values_copy = avro_schema_copy (map_schema->values);
if (!values_copy)
{
@@ -862,7 +868,8 @@
break;
case AVRO_ARRAY:
{
- struct schema_array_t *array_schema = avro_schema_to_array (schema);
+ struct avro_array_schema_t *array_schema =
+ avro_schema_to_array (schema);
avro_schema_t items_copy = avro_schema_copy (array_schema->items);
if (!items_copy)
{
@@ -873,13 +880,14 @@
break;
case AVRO_UNION:
{
- struct schema_union_t *union_schema = avro_schema_to_union (schema);
- struct union_schema_t *s;
+ struct avro_union_schema_t *union_schema =
+ avro_schema_to_union (schema);
+ struct avro_union_branch_t *s;
new_schema = avro_schema_union ();
- for (s = TAILQ_FIRST (&union_schema->schemas);
- s != NULL; s = TAILQ_NEXT (s, schemas))
+ for (s = STAILQ_FIRST (&union_schema->branches);
+ s != NULL; s = STAILQ_NEXT (s, branches))
{
avro_schema_t schema_copy = avro_schema_copy (s->schema);
if (avro_schema_union_append (new_schema, schema_copy))
@@ -893,7 +901,7 @@
case AVRO_LINK:
{
- struct schema_link_t *link_schema = avro_schema_to_link (schema);
+ struct avro_link_schema_t *link_schema = avro_schema_to_link (schema);
/* TODO: use an avro_schema_copy of to instead of pointing to the same
reference */
avro_schema_incref (link_schema->to);
new_schema = avro_schema_link (link_schema->to);
Modified: hadoop/avro/trunk/lang/c/src/schema.h
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/schema.h?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/schema.h (original)
+++ hadoop/avro/trunk/lang/c/src/schema.h Mon Jan 18 05:30:24 2010
@@ -23,78 +23,78 @@
#include "container_of.h"
#include "queue.h"
-struct record_field_t
+struct avro_record_field_t
{
char *name;
avro_schema_t type;
- /* TODO: default */
- TAILQ_ENTRY (record_field_t) fields;
+ /* TODO: default values */
+ STAILQ_ENTRY (avro_record_field_t) fields;
};
-struct schema_record_t
+struct avro_record_schema_t
{
struct avro_obj_t obj;
char *name;
- TAILQ_HEAD (fields, record_field_t) fields;
+ STAILQ_HEAD (fields, avro_record_field_t) fields;
};
-struct enum_symbol_t
+struct avro_enum_symbol_t
{
char *symbol;
- TAILQ_ENTRY (enum_symbol_t) symbols;
+ STAILQ_ENTRY (avro_enum_symbol_t) symbols;
};
-struct schema_enum_t
+struct avro_enum_schema_t
{
struct avro_obj_t obj;
char *name;
- TAILQ_HEAD (symbols, enum_symbol_t) symbols;
+ STAILQ_HEAD (symbols, avro_enum_symbol_t) symbols;
};
-struct schema_array_t
+struct avro_array_schema_t
{
struct avro_obj_t obj;
avro_schema_t items;
};
-struct schema_map_t
+struct avro_map_schema_t
{
struct avro_obj_t obj;
avro_schema_t values;
};
-struct union_schema_t
+struct avro_union_branch_t
{
avro_schema_t schema;
- TAILQ_ENTRY (union_schema_t) schemas;
+ STAILQ_ENTRY (avro_union_branch_t) branches;
};
-struct schema_union_t
+struct avro_union_schema_t
{
struct avro_obj_t obj;
- TAILQ_HEAD (schemas, union_schema_t) schemas;
+ STAILQ_HEAD (branch, avro_union_branch_t) branches;
};
-struct schema_fixed_t
+struct avro_fixed_schema_t
{
struct avro_obj_t obj;
const char *name;
size_t size;
};
-struct schema_link_t
+struct avro_link_schema_t
{
struct avro_obj_t obj;
avro_schema_t to;
};
-#define avro_schema_to_record(schema_) container_of(schema_, struct
schema_record_t, obj)
-#define avro_schema_to_enum(schema_) container_of(schema_, struct
schema_enum_t, obj)
-#define avro_schema_to_array(schema_) container_of(schema_, struct
schema_array_t, obj)
-#define avro_schema_to_map(schema_) container_of(schema_, struct
schema_map_t, obj)
-#define avro_schema_to_union(schema_) container_of(schema_, struct
schema_union_t, obj)
-#define avro_schema_to_fixed(schema_) container_of(schema_, struct
schema_fixed_t, obj)
-#define avro_schema_to_link(schema_) container_of(schema_, struct
schema_link_t, obj)
+#define avro_schema_to_record(schema_) container_of(schema_, struct
avro_record_schema_t, obj)
+#define avro_schema_to_enum(schema_) container_of(schema_, struct
avro_enum_schema_t, obj)
+#define avro_schema_to_array(schema_) container_of(schema_, struct
avro_array_schema_t, obj)
+#define avro_schema_to_map(schema_) container_of(schema_, struct
avro_map_schema_t, obj)
+#define avro_schema_to_union(schema_) container_of(schema_, struct
avro_union_schema_t, obj)
+#define avro_schema_to_fixed(schema_) container_of(schema_, struct
avro_fixed_schema_t, obj)
+#define avro_schema_to_link(schema_) container_of(schema_, struct
avro_link_schema_t, obj)
static inline avro_schema_t
avro_schema_incref (avro_schema_t schema)
@@ -118,5 +118,4 @@
}
}
-
#endif
Modified: hadoop/avro/trunk/lang/c/src/schema_equal.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/schema_equal.c?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/schema_equal.c (original)
+++ hadoop/avro/trunk/lang/c/src/schema_equal.c Mon Jan 18 05:30:24 2010
@@ -21,20 +21,21 @@
#include <string.h>
static int
-schema_record_equal (struct schema_record_t *a, struct schema_record_t *b)
+schema_record_equal (struct avro_record_schema_t *a,
+ struct avro_record_schema_t *b)
{
- struct record_field_t *field_a, *field_b;
+ struct avro_record_field_t *field_a, *field_b;
if (strcmp (a->name, b->name))
{
/* They have different names */
return 0;
}
- for (field_a = TAILQ_FIRST (&a->fields),
- field_b = TAILQ_FIRST (&b->fields);
+ for (field_a = STAILQ_FIRST (&a->fields),
+ field_b = STAILQ_FIRST (&b->fields);
!(field_a == NULL && field_b == NULL);
- field_a = TAILQ_NEXT (field_a, fields),
- field_b = TAILQ_NEXT (field_b, fields))
+ field_a = STAILQ_NEXT (field_a, fields),
+ field_b = STAILQ_NEXT (field_b, fields))
{
if (field_a == NULL || field_b == NULL)
{
@@ -55,20 +56,20 @@
}
static int
-schema_enum_equal (struct schema_enum_t *a, struct schema_enum_t *b)
+schema_enum_equal (struct avro_enum_schema_t *a, struct avro_enum_schema_t *b)
{
- struct enum_symbol_t *sym_a, *sym_b;
+ struct avro_enum_symbol_t *sym_a, *sym_b;
if (strcmp (a->name, b->name))
{
/* They have different names */
return 0;
}
- for (sym_a = TAILQ_FIRST (&a->symbols),
- sym_b = TAILQ_FIRST (&b->symbols);
+ for (sym_a = STAILQ_FIRST (&a->symbols),
+ sym_b = STAILQ_FIRST (&b->symbols);
!(sym_a == NULL && sym_b == NULL);
- sym_a = TAILQ_NEXT (sym_a, symbols),
- sym_b = TAILQ_NEXT (sym_b, symbols))
+ sym_a = STAILQ_NEXT (sym_a, symbols),
+ sym_b = STAILQ_NEXT (sym_b, symbols))
{
if (sym_a == NULL || sym_b == NULL)
{
@@ -84,7 +85,8 @@
}
static int
-schema_fixed_equal (struct schema_fixed_t *a, struct schema_fixed_t *b)
+schema_fixed_equal (struct avro_fixed_schema_t *a,
+ struct avro_fixed_schema_t *b)
{
if (strcmp (a->name, b->name))
{
@@ -95,33 +97,35 @@
}
static int
-schema_map_equal (struct schema_map_t *a, struct schema_map_t *b)
+schema_map_equal (struct avro_map_schema_t *a, struct avro_map_schema_t *b)
{
return avro_schema_equal (a->values, b->values);
}
static int
-schema_array_equal (struct schema_array_t *a, struct schema_array_t *b)
+schema_array_equal (struct avro_array_schema_t *a,
+ struct avro_array_schema_t *b)
{
return avro_schema_equal (a->items, b->items);
}
static int
-schema_union_equal (struct schema_union_t *a, struct schema_union_t *b)
+schema_union_equal (struct avro_union_schema_t *a,
+ struct avro_union_schema_t *b)
{
- struct union_schema_t *schema_a, *schema_b;
+ struct avro_union_branch_t *branch_a, *branch_b;
- for (schema_a = TAILQ_FIRST (&a->schemas),
- schema_b = TAILQ_FIRST (&b->schemas);
- !(schema_a == NULL && schema_b == NULL);
- schema_a = TAILQ_NEXT (schema_a, schemas),
- schema_b = TAILQ_NEXT (schema_b, schemas))
+ for (branch_a = STAILQ_FIRST (&a->branches),
+ branch_b = STAILQ_FIRST (&b->branches);
+ !(branch_a == NULL && branch_b == NULL);
+ branch_a = STAILQ_NEXT (branch_a, branches),
+ branch_b = STAILQ_NEXT (branch_b, branches))
{
- if (schema_a == NULL || schema_b == NULL)
+ if (branch_a == NULL || branch_b == NULL)
{
return 0; /* different num symbols */
}
- if (!avro_schema_equal (schema_a->schema, schema_b->schema))
+ if (!avro_schema_equal (branch_a->schema, branch_b->schema))
{
/* They don't have the same schema types */
return 0;
@@ -131,7 +135,7 @@
}
static int
-schema_link_equal (struct schema_link_t *a, struct schema_link_t *b)
+schema_link_equal (struct avro_link_schema_t *a, struct avro_link_schema_t *b)
{
/* NOTE: links can only be used for named types. They are used
in recursive schemas so we just check the name of the
Modified: hadoop/avro/trunk/lang/c/src/schema_printf.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/schema_printf.c?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/schema_printf.c (original)
+++ hadoop/avro/trunk/lang/c/src/schema_printf.c Mon Jan 18 05:30:24 2010
@@ -18,8 +18,8 @@
*/
#include "schema.h"
+#include "datum.h"
-/* print */
struct avro_schema_args_t
{
int depth;
@@ -41,14 +41,14 @@
}
static void
-avro_schema_union_print (struct schema_union_t *unionp,
+avro_schema_union_print (struct avro_union_schema_t *unionp,
struct avro_schema_args_t *args)
{
fprintf (args->fp, "union");
}
static void
-avro_schema_array_print (struct schema_array_t *array,
+avro_schema_array_print (struct avro_array_schema_t *array,
struct avro_schema_args_t *args)
{
avro_schema_printf_indent (args);
@@ -59,7 +59,7 @@
}
static void
-avro_schema_map_print (struct schema_map_t *map,
+avro_schema_map_print (struct avro_map_schema_t *map,
struct avro_schema_args_t *args)
{
avro_schema_printf_indent (args);
@@ -70,21 +70,21 @@
}
static void
-avro_schema_fixed_print (struct schema_fixed_t *fixed,
+avro_schema_fixed_print (struct avro_fixed_schema_t *fixed,
struct avro_schema_args_t *args)
{
fprintf (args->fp, "fixed \"%s\" size=%ld", fixed->name, fixed->size);
}
static void
-avro_schema_enum_print (struct schema_enum_t *enump,
+avro_schema_enum_print (struct avro_enum_schema_t *enump,
struct avro_schema_args_t *args)
{
fprintf (args->fp, "enum \"%s\"", enump->name);
}
static void
-avro_schema_record_field_print (struct record_field_t *field,
+avro_schema_record_field_print (struct avro_record_field_t *field,
struct avro_schema_args_t *args)
{
avro_schema_printf_indent (args);
@@ -95,16 +95,15 @@
}
static void
-avro_schema_record_print (struct schema_record_t *record,
+avro_schema_record_print (struct avro_record_schema_t *record,
struct avro_schema_args_t *args)
{
- size_t i;
- struct record_field_t *field;
+ struct avro_record_field_t *field;
avro_schema_printf_indent (args);
fprintf (args->fp, "record \"%s\"\n", record->name);
args->depth++;
- for (field = TAILQ_FIRST (&record->fields);
- field != NULL; field = TAILQ_NEXT (field, fields))
+ for (field = STAILQ_FIRST (&record->fields);
+ field != NULL; field = STAILQ_NEXT (field, fields))
{
avro_schema_record_field_print (field, args);
}
@@ -130,7 +129,7 @@
}
static void
-avro_schema_link_print (const struct schema_link_t *link,
+avro_schema_link_print (const struct avro_link_schema_t *link,
struct avro_schema_args_t *args)
{
avro_schema_printf_indent (args);
Propchange: hadoop/avro/trunk/lang/c/tests/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 18 05:30:24 2010
@@ -0,0 +1 @@
+Makefile.in
Modified: hadoop/avro/trunk/lang/c/tests/test_avro_schema.c
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/tests/test_avro_schema.c?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/tests/test_avro_schema.c (original)
+++ hadoop/avro/trunk/lang/c/tests/test_avro_schema.c Mon Jan 18 05:30:24 2010
@@ -107,7 +107,6 @@
int
main (int argc, char *argv[])
{
- int i, j;
char *srcdir = getenv ("srcdir");
char path[1024];
Modified: hadoop/avro/trunk/lang/c/version.sh
URL:
http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/version.sh?rev=900279&r1=900278&r2=900279&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/version.sh (original)
+++ hadoop/avro/trunk/lang/c/version.sh Mon Jan 18 05:30:24 2010
@@ -18,9 +18,9 @@
# libavro_binary_age = 0
# libavro_interface_age = 0
#
-libavro_micro_version=3
+libavro_micro_version=4
libavro_interface_age=0
-libavro_binary_age=0
+libavro_binary_age=1
# IGNORE EVERYTHING ELSE FROM HERE DOWN.........
if test $# != 1; then