avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mas...@apache.org
Subject svn commit: r831615 - in /hadoop/avro/trunk: ./ src/c/
Date Sat, 31 Oct 2009 23:19:12 GMT
Author: massie
Date: Sat Oct 31 23:19:10 2009
New Revision: 831615

URL: http://svn.apache.org/viewvc?rev=831615&view=rev
Log:
AVRO-175. Split the avro_io interface into two interfaces: avro_reader and avro_writer

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/src/c/Makefile.am
    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_endian.c
    hadoop/avro/trunk/src/c/avro_enum.c
    hadoop/avro/trunk/src/c/avro_file_container.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_io_file.c
    hadoop/avro/trunk/src/c/avro_io_memory.c
    hadoop/avro/trunk/src/c/avro_io_socket.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_primitives.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_interop.c

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Sat Oct 31 23:19:10 2009
@@ -36,6 +36,8 @@
     AVRO-149. Add Java command-line executable, "avroj".
     (Philip Zeyliger via cutting)
 
+    AVRO-175. Split the avro_io interface into two interfaces: avro_reader and avro_writer
+
   OPTIMIZATIONS
 
     AVRO-172. More efficient schema processing (massie)

Modified: hadoop/avro/trunk/src/c/Makefile.am
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/Makefile.am?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/Makefile.am (original)
+++ hadoop/avro/trunk/src/c/Makefile.am Sat Oct 31 23:19:10 2009
@@ -1,5 +1,3 @@
-AUTOMAKE_OPTIONS=dist-bzip2 
-
 # -pedantic
 AM_CFLAGS=$(APR_CFLAGS) $(APR_INCLUDES) $(APU_INCLUDES) -Wall 
 C_DOCS_OUTPUT ?= "docs/dox"
@@ -16,30 +14,14 @@
 avro_float.c avro_int.c avro_long.c avro_map.c avro_null.c \
 avro_record.c avro_string.c avro_union.c container_of.h \
 avro_io_file.c avro_io_socket.c avro_io_memory.c \
-avro_file_container.c avro_endian.c avro_primitives.c
+avro_endian.c avro_primitives.c avro_file_container.c
 libavro_la_LDFLAGS = \
         -version-info $(LIBAVRO_VERSION) \
         -release $(VERSION) \
         -export-dynamic
 
 
-check_PROGRAMS=test_json_parser test_avro_schema 
-
-# We don't need to auto-generate the json parser code each time.  It makes
-# the build overly complicated and isn't required since the json parser
-# doesn't require frequent updates
-# 
-#lemon: $(top_srcdir)/lemon.c $(top_srcdir)/lempar.c
-#	$(CC) -o $@ $(top_srcdir)/lemon.c
-#	-cp $(top_srcdir)/lempar.c .
-#
-#json_parser.c json_parser.h: $(top_srcdir)/json_parser.y lemon
-#	-cp $(top_srcdir)/json_parser.y .
-#	./lemon json_parser.y
-#
-# Make sure to generate the json_parser in the source directory before distribution
-#dist-hook: json_parser.h json_parser.c
-#	@[ $(top_srcdir) = $(top_builddir) ] || rm -f json_parser.y lempar.c json_parser.c json_parser.h
+check_PROGRAMS=test_json_parser test_avro_schema
 
 dist-hook: docs
 
@@ -78,3 +60,20 @@
 .PHONY: docs 
 
 CLEANFILES=$(top_srcdir)/*~ trace.txt json_parser.out lemon
+
+
+# We don't need to auto-generate the json parser code each time.  It makes
+# the build overly complicated and isn't required since the json parser
+# doesn't require frequent updates
+# 
+#lemon: $(top_srcdir)/lemon.c $(top_srcdir)/lempar.c
+#	$(CC) -o $@ $(top_srcdir)/lemon.c
+#	-cp $(top_srcdir)/lempar.c .
+#
+#json_parser.c json_parser.h: $(top_srcdir)/json_parser.y lemon
+#	-cp $(top_srcdir)/json_parser.y .
+#	./lemon json_parser.y
+#
+# Make sure to generate the json_parser in the source directory before distribution
+#dist-hook: json_parser.h json_parser.c
+#	@[ $(top_srcdir) = $(top_builddir) ] || rm -f json_parser.y lempar.c json_parser.c json_parser.h

Modified: hadoop/avro/trunk/src/c/avro_array.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_array.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_array.c (original)
+++ hadoop/avro/trunk/src/c/avro_array.c Sat Oct 31 23:19:10 2009
@@ -46,28 +46,28 @@
 }
 
 static avro_status_t
-avro_array_read_skip (struct avro_value *value, struct avro_channel *channel,
+avro_array_read_skip (struct avro_value *value, struct avro_reader *reader,
 		      int skip)
 {
   avro_status_t status;
   avro_long_t i, count;
   struct avro_array_value *self =
     container_of (value, struct avro_array_value, base_value);
-  struct avro_io *io;
+  struct avro_io_reader *io;
 
   apr_pool_clear (self->pool);
 
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = reader->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
 
-  status = avro_getlong (io, &count);
+  status = avro_read_long (io, &count);
   if (status != AVRO_OK)
     {
       return status;
@@ -83,19 +83,19 @@
 }
 
 static avro_status_t
-avro_array_read (struct avro_value *value, struct avro_channel *channel)
+avro_array_read (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_array_read_skip (value, channel, 0);
+  return avro_array_read_skip (value, reader, 0);
 }
 
 static avro_status_t
-avro_array_skip (struct avro_value *value, struct avro_channel *channel)
+avro_array_skip (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_array_read_skip (value, channel, 1);
+  return avro_array_read_skip (value, reader, 1);
 }
 
 static avro_status_t
-avro_array_write (struct avro_value *value, struct avro_channel *channel)
+avro_array_write (struct avro_value *value, struct avro_writer *writer)
 {
 /* TODO
   struct avro_array_value *self =

Modified: hadoop/avro/trunk/src/c/avro_boolean.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_boolean.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_boolean.c (original)
+++ hadoop/avro/trunk/src/c/avro_boolean.c Sat Oct 31 23:19:10 2009
@@ -41,18 +41,18 @@
 
 static avro_status_t
 avro_boolean_read_skip (struct avro_value *value,
-			struct avro_channel *channel, int skip)
+			struct avro_reader *reader, int skip)
 {
   char b;
   avro_status_t status;
-  struct avro_io *io;
+  struct avro_io_reader *io;
   struct avro_boolean_value *self =
     container_of (value, struct avro_boolean_value, base_value);
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = reader->io;
   if (!io)
     {
       return AVRO_FAILURE;
@@ -79,29 +79,29 @@
 }
 
 static avro_status_t
-avro_boolean_read (struct avro_value *value, struct avro_channel *channel)
+avro_boolean_read (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_boolean_read_skip (value, channel, 0);
+  return avro_boolean_read_skip (value, reader, 0);
 }
 
 static avro_status_t
-avro_boolean_skip (struct avro_value *value, struct avro_channel *channel)
+avro_boolean_skip (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_boolean_read_skip (value, channel, 1);
+  return avro_boolean_read_skip (value, reader, 1);
 }
 
 static avro_status_t
-avro_boolean_write (struct avro_value *value, struct avro_channel *channel)
+avro_boolean_write (struct avro_value *value, struct avro_writer *writer)
 {
   char b;
   struct avro_boolean_value *self =
     container_of (value, struct avro_boolean_value, base_value);
-  struct avro_io *io;
-  if (!channel)
+  struct avro_io_writer *io;
+  if (!writer)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = writer->io;
   if (!io)
     {
       return AVRO_FAILURE;

Modified: hadoop/avro/trunk/src/c/avro_bytes.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_bytes.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_bytes.c (original)
+++ hadoop/avro/trunk/src/c/avro_bytes.c Sat Oct 31 23:19:10 2009
@@ -21,7 +21,7 @@
 
 struct avro_bytes_value
 {
-  char *value;
+  void *value;
   int value_set;
   avro_long_t size;
   avro_value base_value;
@@ -39,22 +39,22 @@
   if (self->value_set)
     {
       fprintf (fp, " size=%ld ", self->size);
-      dump (fp, self->value, self->size);
+      dump (fp, (char *) self->value, self->size);
     }
   fprintf (fp, "\n");
 }
 
 static avro_status_t
-avro_bytes_read (struct avro_value *value, struct avro_channel *channel)
+avro_bytes_read (struct avro_value *value, struct avro_reader *reader)
 {
-  struct avro_io *io;
+  struct avro_io_reader *io;
   struct avro_bytes_value *self =
     container_of (value, struct avro_bytes_value, base_value);
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = reader->io;
   if (!io)
     {
       return AVRO_FAILURE;
@@ -62,29 +62,29 @@
   /* Flush old data to make room for new */
   self->value_set = 1;
   apr_pool_clear (self->pool);
-  return avro_getbytes (io, self->pool, &self->value, &self->size);
+  return avro_read_bytes (io, self->pool, &self->value, &self->size);
 }
 
 static avro_status_t
-avro_bytes_skip (struct avro_value *value, struct avro_channel *channel)
+avro_bytes_skip (struct avro_value *value, struct avro_reader *reader)
 {
   avro_status_t status;
-  struct avro_io *io;
+  struct avro_io_reader *io;
   avro_long_t len;
   struct avro_bytes_value *self =
     container_of (value, struct avro_bytes_value, base_value);
 
   self->value_set = 0;
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = reader->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
-  status = avro_getlong (io, &len);
+  status = avro_read_long (io, &len);
   if (status != AVRO_OK)
     {
       return AVRO_FAILURE;
@@ -93,7 +93,7 @@
 }
 
 static avro_status_t
-avro_bytes_write (struct avro_value *value, struct avro_channel *channel)
+avro_bytes_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_bytes_value *self =
     container_of (value, struct avro_bytes_value, base_value);

Modified: hadoop/avro/trunk/src/c/avro_double.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_double.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_double.c (original)
+++ hadoop/avro/trunk/src/c/avro_double.c Sat Oct 31 23:19:10 2009
@@ -40,45 +40,45 @@
 }
 
 static avro_status_t
-avro_double_read (struct avro_value *value, struct avro_channel *channel)
+avro_double_read (struct avro_value *value, struct avro_reader *reader)
 {
   double *dp;
   struct avro_double_value *self =
     container_of (value, struct avro_double_value, base_value);
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
   self->value_set = 1;
   dp = &self->value;
-  return avro_getint64_le (channel->io, (int64_t *) dp);
+  return avro_read_int64_le (reader->io, (int64_t *) dp);
 }
 
 static avro_status_t
-avro_double_skip (struct avro_value *value, struct avro_channel *channel)
+avro_double_skip (struct avro_value *value, struct avro_reader *reader)
 {
   double d;
   double *dp = &d;
   struct avro_double_value *self =
     container_of (value, struct avro_double_value, base_value);
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
   self->value_set = 0;
-  return avro_getint64_le (channel->io, (int64_t *) dp);
+  return avro_read_int64_le (reader->io, (int64_t *) dp);
 }
 
 static avro_status_t
-avro_double_write (struct avro_value *value, struct avro_channel *channel)
+avro_double_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_double_value *self =
     container_of (value, struct avro_double_value, base_value);
-  if (!channel)
+  if (!writer)
     {
       return AVRO_FAILURE;
     }
-  return avro_putint64_le (channel->io, (int64_t) self->value);;
+  return avro_write_int64_le (writer->io, (int64_t) self->value);;
 }
 
 static struct avro_value *

Modified: hadoop/avro/trunk/src/c/avro_endian.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_endian.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_endian.c (original)
+++ hadoop/avro/trunk/src/c/avro_endian.c Sat Oct 31 23:19:10 2009
@@ -19,7 +19,7 @@
 #include "avro_private.h"
 
 avro_status_t
-avro_getint32_le (struct avro_io *io, int32_t * value)
+avro_read_int32_le (struct avro_io_reader *io, int32_t * value)
 {
   avro_status_t status;
   uint8_t buf[4];
@@ -39,7 +39,7 @@
 }
 
 avro_status_t
-avro_putint32_le (struct avro_io * io, const int32_t value)
+avro_write_int32_le (struct avro_io_writer * io, const int32_t value)
 {
   uint8_t buf[4];
   buf[0] = (uint8_t) (value >> 0);
@@ -50,11 +50,11 @@
     {
       return AVRO_FAILURE;
     }
-  return io->write (io, (char *) buf, sizeof (buf));
+  return io->write (io, (void *) buf, sizeof (buf));
 }
 
 avro_status_t
-avro_getint32_be (struct avro_io *io, int32_t * value)
+avro_read_int32_be (struct avro_io_reader *io, int32_t * value)
 {
   avro_status_t status;
   uint8_t buf[4];
@@ -74,7 +74,7 @@
 }
 
 avro_status_t
-avro_putint32_be (struct avro_io * io, const int32_t value)
+avro_write_int32_be (struct avro_io_writer * io, const int32_t value)
 {
   uint8_t buf[4];
   buf[0] = (uint8_t) (value >> 24);
@@ -85,12 +85,12 @@
     {
       return AVRO_FAILURE;
     }
-  return io->write (io, (char *) buf, sizeof (buf));
+  return io->write (io, (void *) buf, sizeof (buf));
 }
 
 
 avro_status_t
-avro_getint64_le (struct avro_io *io, int64_t * value)
+avro_read_int64_le (struct avro_io_reader *io, int64_t * value)
 {
   avro_status_t status;
   uint8_t buf[8];
@@ -114,7 +114,7 @@
 }
 
 avro_status_t
-avro_putint64_le (struct avro_io * io, const int64_t value)
+avro_write_int64_le (struct avro_io_writer * io, const int64_t value)
 {
   uint8_t buf[8];
   buf[0] = (uint8_t) (value >> 0);
@@ -129,11 +129,11 @@
     {
       return AVRO_FAILURE;
     }
-  return io->write (io, (char *) buf, sizeof (buf));
+  return io->write (io, (void *) buf, sizeof (buf));
 }
 
 avro_status_t
-avro_getint64_be (struct avro_io *io, int64_t * value)
+avro_read_int64_be (struct avro_io_reader *io, int64_t * value)
 {
   avro_status_t status;
   uint8_t buf[8];
@@ -157,7 +157,7 @@
 }
 
 avro_status_t
-avro_putint64_be (struct avro_io * io, const int64_t value)
+avro_write_int64_be (struct avro_io_writer * io, const int64_t value)
 {
   uint8_t buf[8];
   buf[0] = (uint8_t) (value >> 56);
@@ -172,5 +172,5 @@
     {
       return AVRO_FAILURE;
     }
-  return io->write (io, (char *) buf, sizeof (buf));
+  return io->write (io, (void *) buf, sizeof (buf));
 }

Modified: hadoop/avro/trunk/src/c/avro_enum.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_enum.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_enum.c (original)
+++ hadoop/avro/trunk/src/c/avro_enum.c Sat Oct 31 23:19:10 2009
@@ -43,25 +43,25 @@
 }
 
 static avro_status_t
-avro_enum_read_skip (struct avro_value *value, struct avro_channel *channel,
+avro_enum_read_skip (struct avro_value *value, struct avro_reader *reader,
 		     int skip)
 {
   avro_status_t status;
-  struct avro_io *io;
+  struct avro_io_reader *io;
   struct avro_avro_enum *self =
     container_of (value, struct avro_avro_enum, base_value);
 
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = reader->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
   /* Read the offset */
-  status = avro_getlong (io, &self->offset);
+  status = avro_read_long (io, &self->offset);
   if (status != AVRO_OK)
     {
       return status;
@@ -76,19 +76,19 @@
 }
 
 static avro_status_t
-avro_enum_read (struct avro_value *value, struct avro_channel *channel)
+avro_enum_read (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_enum_read_skip (value, channel, 0);
+  return avro_enum_read_skip (value, reader, 0);
 }
 
 static avro_status_t
-avro_enum_skip (struct avro_value *value, struct avro_channel *channel)
+avro_enum_skip (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_enum_read_skip (value, channel, 1);
+  return avro_enum_read_skip (value, reader, 1);
 }
 
 static avro_status_t
-avro_enum_write (struct avro_value *value, struct avro_channel *channel)
+avro_enum_write (struct avro_value *value, struct avro_writer *writer)
 {
 /* TODO
   struct avro_avro_enum *self =

Modified: hadoop/avro/trunk/src/c/avro_file_container.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_file_container.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_file_container.c (original)
+++ hadoop/avro/trunk/src/c/avro_file_container.c Sat Oct 31 23:19:10 2009
@@ -6,7 +6,7 @@
 struct avro_metadata
 {
   avro_string_t key;
-  char *value;
+  void *value;
   avro_long_t len;
 };
 
@@ -16,20 +16,19 @@
   apr_hash_t *meta;
   JSON_value *schema;
   avro_long_t size;
-  struct avro_channel channel;
+  struct avro_reader reader;
 };
 
-struct avro_channel *
-avro_file_container_create_from_file (apr_file_t * file)
+struct avro_reader *
+avro_reader_file_container_from_file (apr_file_t * file)
 {
   apr_status_t apr_status;
   avro_status_t status;
   struct avro_file_container *container;
   struct apr_pool_t *pool;
-  struct avro_io *io;
+  struct avro_io_reader *io;
   char buf[4];
   int i;
-  int64_t type;
   apr_off_t offset, len;
   int32_t footersize;
   avro_long_t metalength;
@@ -47,14 +46,14 @@
     }
 
   container = apr_pcalloc (pool, sizeof (struct avro_file_container));
-  container->channel.format = AVRO_BINARY_FORMAT;
-  container->channel.io = io = avro_io_file_create (file);
+  container->reader.format = AVRO_BINARY_FORMAT;
+  container->reader.io = io = avro_io_reader_from_file (file);
   if (!io)
     {
       return NULL;
     }
 
-  status = io->read (io, buf, 4);
+  status = io->read (io, (void *) buf, 4);
   if (status != AVRO_OK)
     {
       return NULL;
@@ -88,7 +87,7 @@
       return NULL;
     }
   /* Read in the footersize */
-  status = avro_getint32_be (io, &footersize);
+  status = avro_read_int32_be (io, &footersize);
   if (status != AVRO_OK)
     {
       return NULL;
@@ -103,7 +102,7 @@
     }
 
   /* Read the metadata length */
-  status = avro_getlong (io, &metalength);
+  status = avro_read_long (io, &metalength);
   if (status != AVRO_OK)
     {
       return NULL;
@@ -112,7 +111,7 @@
   if (metalength < 0)
     {
       avro_long_t ignore;
-      avro_getlong (io, &ignore);
+      avro_read_long (io, &ignore);
     }
 
   /* Create a hash table for the meta data */
@@ -126,8 +125,8 @@
 	{
 	  return NULL;
 	}
-      avro_getstring (io, pool, &key);
-      avro_getbytes (io, pool, &metadata->value, &metadata->len);
+      avro_read_string (io, pool, &key);
+      avro_read_bytes (io, pool, &metadata->value, &metadata->len);
       apr_hash_set (container->meta, key, wcslen (key) * sizeof (wchar_t),
 		    metadata);
       DEBUG (fprintf (stderr, "%ls = ", key));
@@ -168,17 +167,17 @@
     }
 
   /* Read the size of the block */
-  status = avro_getlong (io, &container->size);
+  status = avro_read_long (io, &container->size);
   if (status != AVRO_OK)
     {
       return NULL;
     }
-  return &container->channel;
+  return &container->reader;
 }
 
-struct avro_channel *
-avro_file_container_create (apr_pool_t * pool, const char *fname,
-			    apr_int32_t flag, apr_fileperms_t perm)
+struct avro_reader *
+avro_reader_file_container_create (apr_pool_t * pool, const char *fname,
+				   apr_int32_t flag, apr_fileperms_t perm)
 {
   apr_status_t status;
   apr_file_t *file;
@@ -194,5 +193,5 @@
       return NULL;
     }
 
-  return avro_file_container_create_from_file (file);
+  return avro_reader_file_container_from_file (file);
 }

Modified: hadoop/avro/trunk/src/c/avro_fixed.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_fixed.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_fixed.c (original)
+++ hadoop/avro/trunk/src/c/avro_fixed.c Sat Oct 31 23:19:10 2009
@@ -37,7 +37,7 @@
 }
 
 static avro_status_t
-avro_fixed_read (struct avro_value *value, struct avro_channel *channel)
+avro_fixed_read (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_fixed_value *self =
     container_of (value, struct avro_fixed_value, base_value);
@@ -45,7 +45,7 @@
 }
 
 static avro_status_t
-avro_fixed_skip (struct avro_value *value, struct avro_channel *channel)
+avro_fixed_skip (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_fixed_value *self =
     container_of (value, struct avro_fixed_value, base_value);
@@ -53,7 +53,7 @@
 }
 
 static avro_status_t
-avro_fixed_write (struct avro_value *value, struct avro_channel *channel)
+avro_fixed_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_fixed_value *self =
     container_of (value, struct avro_fixed_value, base_value);

Modified: hadoop/avro/trunk/src/c/avro_float.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_float.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_float.c (original)
+++ hadoop/avro/trunk/src/c/avro_float.c Sat Oct 31 23:19:10 2009
@@ -40,45 +40,45 @@
 }
 
 static avro_status_t
-avro_float_read (struct avro_value *value, struct avro_channel *channel)
+avro_float_read (struct avro_value *value, struct avro_reader *reader)
 {
   float *fp;
   struct avro_float_value *self =
     container_of (value, struct avro_float_value, base_value);
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
   fp = &self->value;
   self->value_set = 1;
-  return avro_getint32_le (channel->io, (int32_t *) fp);
+  return avro_read_int32_le (reader->io, (int32_t *) fp);
 }
 
 static avro_status_t
-avro_float_skip (struct avro_value *value, struct avro_channel *channel)
+avro_float_skip (struct avro_value *value, struct avro_reader *reader)
 {
   float f;
   float *fp = &f;
   struct avro_float_value *self =
     container_of (value, struct avro_float_value, base_value);
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
   self->value_set = 0;
-  return avro_getint32_le (channel->io, (int32_t *) fp);
+  return avro_read_int32_le (reader->io, (int32_t *) fp);
 }
 
 static avro_status_t
-avro_float_write (struct avro_value *value, struct avro_channel *channel)
+avro_float_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_float_value *self =
     container_of (value, struct avro_float_value, base_value);
-  if (!channel)
+  if (!writer)
     {
       return AVRO_FAILURE;
     }
-  return avro_putint32_le (channel->io, (int32_t) self->value);
+  return avro_write_int32_le (writer->io, (int32_t) self->value);
 }
 
 static struct avro_value *

Modified: hadoop/avro/trunk/src/c/avro_int.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_int.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_int.c (original)
+++ hadoop/avro/trunk/src/c/avro_int.c Sat Oct 31 23:19:10 2009
@@ -40,53 +40,53 @@
 }
 
 static avro_status_t
-avro_int_read_skip (struct avro_value *value, struct avro_channel *channel,
+avro_int_read_skip (struct avro_value *value, struct avro_reader *reader,
 		    int skip)
 {
   struct avro_int_value *self =
     container_of (value, struct avro_int_value, base_value);
-  struct avro_io *io;
-  if (!channel)
+  struct avro_io_reader *io;
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = reader->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
   self->value_set = !skip;
-  return avro_getint (io, &self->value);
+  return avro_read_int (io, &self->value);
 }
 
 static avro_status_t
-avro_int_read (struct avro_value *value, struct avro_channel *channel)
+avro_int_read (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_int_read_skip (value, channel, 0);
+  return avro_int_read_skip (value, reader, 0);
 }
 
 static avro_status_t
-avro_int_skip (struct avro_value *value, struct avro_channel *channel)
+avro_int_skip (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_int_read_skip (value, channel, 1);
+  return avro_int_read_skip (value, reader, 1);
 }
 
 static avro_status_t
-avro_int_write (struct avro_value *value, struct avro_channel *channel)
+avro_int_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_int_value *self =
     container_of (value, struct avro_int_value, base_value);
-  struct avro_io *io;
-  if (!value || !channel)
+  struct avro_io_writer *io;
+  if (!value || !writer)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = writer->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
-  return avro_putint (io, &self->value);
+  return avro_write_int (io, &self->value);
 }
 
 static struct avro_value *

Modified: hadoop/avro/trunk/src/c/avro_io_file.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_io_file.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_io_file.c (original)
+++ hadoop/avro/trunk/src/c/avro_io_file.c Sat Oct 31 23:19:10 2009
@@ -20,41 +20,82 @@
 #include "avro_private.h"
 #include "apr_file_io.h"
 
-struct avro_io_file
+struct avro_io_reader_file
 {
   apr_file_t *file;
-  struct avro_io io;
+  struct avro_io_reader io;
+};
+
+struct avro_io_writer_file
+{
+  apr_file_t *file;
+  struct avro_io_writer io;
 };
 
 static avro_status_t
-avro_io_file_read (struct avro_io *io, char *addr, uint64_t len)
+avro_io_file_read (struct avro_io_reader *io, void *addr, avro_long_t len)
 {
-  struct avro_io_file *self = container_of (io, struct avro_io_file, io);
+  struct avro_io_reader_file *self =
+    container_of (io, struct avro_io_reader_file, io);
+  if (len < 0 || !addr)
+    {
+      return AVRO_FAILURE;
+    }
   apr_status_t status =
     apr_file_read_full (self->file, addr, (apr_size_t) len, NULL);
   return status == APR_SUCCESS ? AVRO_OK : AVRO_FAILURE;
 }
 
 static avro_status_t
-avro_io_file_skip (struct avro_io *io, uint64_t len)
+avro_io_file_skip (struct avro_io_reader *io, avro_long_t len)
 {
   /* TODO: file seek */
   return AVRO_OK;
 }
 
 static avro_status_t
-avro_io_file_write (struct avro_io *io, char *addr, uint64_t len)
+avro_io_file_write (struct avro_io_writer *io, void *addr, avro_long_t len)
 {
-  struct avro_io_file *self = container_of (io, struct avro_io_file, io);
+  struct avro_io_writer_file *self =
+    container_of (io, struct avro_io_writer_file, io);
+  if (!addr || len < 0)
+    {
+      return AVRO_FAILURE;
+    }
   apr_status_t status =
     apr_file_write_full (self->file, addr, (apr_size_t) len, NULL);
   return status == APR_SUCCESS ? AVRO_OK : AVRO_FAILURE;
 }
 
-struct avro_io *
-avro_io_file_create (apr_file_t * file)
+struct avro_io_writer *
+avro_io_writer_from_file (apr_file_t * file)
+{
+  struct avro_io_writer_file *file_writer;
+  apr_pool_t *pool;
+
+  if (!file)
+    {
+      return NULL;
+    }
+  pool = apr_file_pool_get (file);
+  if (!pool)
+    {
+      return NULL;
+    }
+  file_writer = apr_pcalloc (pool, sizeof (struct avro_io_writer_file));
+  if (!file_writer)
+    {
+      return NULL;
+    }
+  file_writer->io.write = avro_io_file_write;
+  file_writer->file = file;
+  return &file_writer->io;
+}
+
+struct avro_io_reader *
+avro_io_reader_from_file (apr_file_t * file)
 {
-  struct avro_io_file *file_io;
+  struct avro_io_reader_file *file_reader;
   apr_pool_t *pool;
 
   if (!file)
@@ -66,14 +107,13 @@
     {
       return NULL;
     }
-  file_io = apr_pcalloc (pool, sizeof (struct avro_io_file));
-  if (!file_io)
+  file_reader = apr_pcalloc (pool, sizeof (struct avro_io_reader_file));
+  if (!file_reader)
     {
       return NULL;
     }
-  file_io->io.read = avro_io_file_read;
-  file_io->io.skip = avro_io_file_skip;
-  file_io->io.write = avro_io_file_write;
-  file_io->file = file;
-  return &file_io->io;
+  file_reader->io.read = avro_io_file_read;
+  file_reader->io.skip = avro_io_file_skip;
+  file_reader->file = file;
+  return &file_reader->io;
 }

Modified: hadoop/avro/trunk/src/c/avro_io_memory.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_io_memory.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_io_memory.c (original)
+++ hadoop/avro/trunk/src/c/avro_io_memory.c Sat Oct 31 23:19:10 2009
@@ -19,19 +19,28 @@
 
 #include "avro_private.h"
 
-struct avro_io_memory
+struct avro_io_memory_reader
 {
-  char *addr;
+  void *addr;
   uint64_t used;
   uint64_t len;
-  struct avro_io io;
+  struct avro_io_reader io;
+};
+
+struct avro_io_memory_writer
+{
+  void *addr;
+  uint64_t used;
+  uint64_t len;
+  struct avro_io_writer io;
 };
 
 static avro_status_t
-avro_io_memory_read (struct avro_io *io, char *addr, uint64_t len)
+avro_io_memory_read (struct avro_io_reader *io, void *addr, avro_long_t len)
 {
-  struct avro_io_memory *self = container_of (io, struct avro_io_memory, io);
-  if ((self->len - self->used) < len)
+  struct avro_io_memory_reader *self =
+    container_of (io, struct avro_io_memory_reader, io);
+  if (len < 0 || (self->len - self->used) < len)
     {
       return AVRO_FAILURE;
     }
@@ -41,10 +50,11 @@
 }
 
 static avro_status_t
-avro_io_memory_skip (struct avro_io *io, uint64_t len)
+avro_io_memory_skip (struct avro_io_reader *io, avro_long_t len)
 {
-  struct avro_io_memory *self = container_of (io, struct avro_io_memory, io);
-  if ((self->len - self->used) < len)
+  struct avro_io_memory_reader *self =
+    container_of (io, struct avro_io_memory_reader, io);
+  if (len < 0 || (self->len - self->used) < len)
     {
       return AVRO_FAILURE;
     }
@@ -53,9 +63,10 @@
 }
 
 static avro_status_t
-avro_io_memory_write (struct avro_io *io, char *addr, uint64_t len)
+avro_io_memory_write (struct avro_io_writer *io, void *addr, avro_long_t len)
 {
-  struct avro_io_memory *self = container_of (io, struct avro_io_memory, io);
+  struct avro_io_memory_writer *self =
+    container_of (io, struct avro_io_memory_writer, io);
   if ((self->len - self->used) < len)
     {
       return AVRO_FAILURE;
@@ -65,29 +76,47 @@
   return AVRO_OK;
 }
 
-struct avro_io *
-avro_io_memory_create (apr_pool_t * pool, char *addr, int64_t len)
+struct avro_io_reader *
+avro_io_reader_from_memory (apr_pool_t * pool, void *addr, avro_long_t len)
 {
-  struct avro_io_memory *io_memory;
+  struct avro_io_memory_reader *io_memory;
 
-  if (!pool || !addr)
+  if (!pool || !addr || len < 0)
     {
       return NULL;
     }
 
-  io_memory = apr_pcalloc (pool, sizeof (struct avro_io));
+  io_memory = apr_pcalloc (pool, sizeof (struct avro_io_memory_reader));
   if (!io_memory)
     {
       return NULL;
     }
-
   io_memory->addr = addr;
   io_memory->used = 0;
   io_memory->len = len;
-
   io_memory->io.read = avro_io_memory_read;
   io_memory->io.skip = avro_io_memory_skip;
-  io_memory->io.write = avro_io_memory_write;
+  return &io_memory->io;
+}
+
+struct avro_io_writer *
+avro_io_writer_from_memory (apr_pool_t * pool, void *addr, avro_long_t len)
+{
+  struct avro_io_memory_writer *io_memory;
 
+  if (!pool || !addr || len < 0)
+    {
+      return NULL;
+    }
+
+  io_memory = apr_pcalloc (pool, sizeof (struct avro_io_memory_writer));
+  if (!io_memory)
+    {
+      return NULL;
+    }
+  io_memory->addr = addr;
+  io_memory->used = 0;
+  io_memory->len = len;
+  io_memory->io.write = avro_io_memory_write;
   return &io_memory->io;
 }

Modified: hadoop/avro/trunk/src/c/avro_io_socket.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_io_socket.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_io_socket.c (original)
+++ hadoop/avro/trunk/src/c/avro_io_socket.c Sat Oct 31 23:19:10 2009
@@ -20,19 +20,26 @@
 #include "avro_private.h"
 #include <apr_network_io.h>
 
-struct avro_io_socket
+struct avro_io_socket_reader
 {
   apr_socket_t *socket;
-  struct avro_io io;
+  struct avro_io_reader io;
+};
+
+struct avro_io_socket_writer
+{
+  apr_socket_t *socket;
+  struct avro_io_writer io;
 };
 
 static avro_status_t
-avro_io_socket_read (struct avro_io *io, char *addr, uint64_t len)
+avro_io_socket_read (struct avro_io_reader *io, void *addr, avro_long_t len)
 {
   apr_status_t status;
   apr_size_t bytes_wanted = len;
   apr_size_t bytes_recvd = 0;
-  struct avro_io_socket *self = container_of (io, struct avro_io_socket, io);
+  struct avro_io_socket_reader *self =
+    container_of (io, struct avro_io_socket_reader, io);
   while (bytes_recvd < bytes_wanted)
     {
       apr_size_t bytes_requested = bytes_wanted - bytes_recvd;
@@ -47,17 +54,18 @@
 }
 
 static avro_status_t
-avro_io_socket_skip (struct avro_io *io, uint64_t len)
+avro_io_socket_skip (struct avro_io_reader *io, avro_long_t len)
 {
   /* TODO */
   return AVRO_OK;
 }
 
 static avro_status_t
-avro_io_socket_write (struct avro_io *io, char *addr, uint64_t len)
+avro_io_socket_write (struct avro_io_writer *io, void *addr, avro_long_t len)
 {
   apr_status_t status;
-  struct avro_io_socket *self = container_of (io, struct avro_io_socket, io);
+  struct avro_io_socket_writer *self =
+    container_of (io, struct avro_io_socket_writer, io);
   apr_size_t bytes_wanted = len;
   apr_size_t bytes_sent = 0;
   while (bytes_sent < bytes_wanted)
@@ -73,10 +81,10 @@
   return AVRO_OK;
 }
 
-struct avro_io *
-avro_io_socket_create (apr_socket_t * socket)
+struct avro_io_reader *
+avro_io_reader_from_socket (apr_socket_t * socket)
 {
-  struct avro_io_socket *socket_io;
+  struct avro_io_socket_reader *socket_io;
   apr_pool_t *pool;
 
   if (!socket)
@@ -90,15 +98,40 @@
       return NULL;
     }
 
-  socket_io = apr_pcalloc (pool, sizeof (struct avro_io_socket));
+  socket_io = apr_pcalloc (pool, sizeof (struct avro_io_socket_reader));
   if (!socket_io)
     {
       return NULL;
     }
-
   socket_io->socket = socket;
   socket_io->io.read = avro_io_socket_read;
   socket_io->io.skip = avro_io_socket_skip;
+  return &socket_io->io;
+}
+
+struct avro_io_writer *
+avro_io_writer_from_socket (apr_socket_t * socket)
+{
+  struct avro_io_socket_writer *socket_io;
+  apr_pool_t *pool;
+
+  if (!socket)
+    {
+      return NULL;
+    }
+
+  pool = apr_socket_pool_get (socket);
+  if (!pool)
+    {
+      return NULL;
+    }
+
+  socket_io = apr_pcalloc (pool, sizeof (struct avro_io_socket_writer));
+  if (!socket_io)
+    {
+      return NULL;
+    }
+  socket_io->socket = socket;
   socket_io->io.write = avro_io_socket_write;
   return &socket_io->io;
 }

Modified: hadoop/avro/trunk/src/c/avro_long.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_long.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_long.c (original)
+++ hadoop/avro/trunk/src/c/avro_long.c Sat Oct 31 23:19:10 2009
@@ -40,53 +40,53 @@
 }
 
 static avro_status_t
-avro_long_read_skip (struct avro_value *value, struct avro_channel *channel,
+avro_long_read_skip (struct avro_value *value, struct avro_reader *reader,
 		     int skip)
 {
   struct avro_long_value *self =
     container_of (value, struct avro_long_value, base_value);
-  struct avro_io *io;
-  if (!channel)
+  struct avro_io_reader *io;
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = reader->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
   self->value_set = !skip;
-  return avro_getlong (io, &self->value);
+  return avro_read_long (io, &self->value);
 }
 
 static avro_status_t
-avro_long_read (struct avro_value *value, struct avro_channel *channel)
+avro_long_read (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_long_read_skip (value, channel, 0);
+  return avro_long_read_skip (value, reader, 0);
 }
 
 static avro_status_t
-avro_long_skip (struct avro_value *value, struct avro_channel *channel)
+avro_long_skip (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_long_read_skip (value, channel, 1);
+  return avro_long_read_skip (value, reader, 1);
 }
 
 static avro_status_t
-avro_long_write (struct avro_value *value, struct avro_channel *channel)
+avro_long_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_long_value *self =
     container_of (value, struct avro_long_value, base_value);
-  struct avro_io *io;
-  if (!value || !channel)
+  struct avro_io_writer *io;
+  if (!value || !writer)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = writer->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
-  return avro_putlong (io, &self->value);
+  return avro_write_long (io, &self->value);
 }
 
 static struct avro_value *

Modified: hadoop/avro/trunk/src/c/avro_map.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_map.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_map.c (original)
+++ hadoop/avro/trunk/src/c/avro_map.c Sat Oct 31 23:19:10 2009
@@ -38,7 +38,7 @@
 }
 
 static avro_status_t
-avro_map_read (struct avro_value *value, struct avro_channel *channel)
+avro_map_read (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_map_value *self =
     container_of (value, struct avro_map_value, base_value);
@@ -46,7 +46,7 @@
 }
 
 static avro_status_t
-avro_map_skip (struct avro_value *value, struct avro_channel *channel)
+avro_map_skip (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_map_value *self =
     container_of (value, struct avro_map_value, base_value);
@@ -54,7 +54,7 @@
 }
 
 static avro_status_t
-avro_map_write (struct avro_value *value, struct avro_channel *channel)
+avro_map_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_map_value *self =
     container_of (value, struct avro_map_value, base_value);

Modified: hadoop/avro/trunk/src/c/avro_null.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_null.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_null.c (original)
+++ hadoop/avro/trunk/src/c/avro_null.c Sat Oct 31 23:19:10 2009
@@ -19,7 +19,13 @@
 #include "avro_private.h"
 
 static avro_status_t
-avro_null_noop (struct avro_value *value, struct avro_channel *channel)
+avro_null_noop_reader (struct avro_value *value, struct avro_reader *reader)
+{
+  return AVRO_OK;
+}
+
+static avro_status_t
+avro_null_noop_writer (struct avro_value *value, struct avro_writer *writer)
 {
   return AVRO_OK;
 }
@@ -54,13 +60,13 @@
   .private = 0,
   .create = avro_null_create,
   .formats = {{
-	       .read_data = avro_null_noop,
-	       .skip_data = avro_null_noop,
-	       .write_data = avro_null_noop},
+	       .read_data = avro_null_noop_reader,
+	       .skip_data = avro_null_noop_reader,
+	       .write_data = avro_null_noop_writer},
 	      {
 	       /* TODO: import/export */
-	       .read_data = avro_null_noop,
-	       .skip_data = avro_null_noop,
-	       .write_data = avro_null_noop}},
+	       .read_data = avro_null_noop_reader,
+	       .skip_data = avro_null_noop_reader,
+	       .write_data = avro_null_noop_writer}},
   .print_info = avro_null_print
 };

Modified: hadoop/avro/trunk/src/c/avro_primitives.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_primitives.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_primitives.c (original)
+++ hadoop/avro/trunk/src/c/avro_primitives.c Sat Oct 31 23:19:10 2009
@@ -21,7 +21,8 @@
 #include <stdlib.h>
 
 avro_status_t
-avro_putstring (struct avro_io *io, apr_pool_t * pool, avro_string_t string)
+avro_write_string (struct avro_io_writer *io, apr_pool_t * pool,
+		   avro_string_t string)
 {
   avro_status_t status;
   size_t wc_len, converted;
@@ -47,7 +48,7 @@
       return AVRO_FAILURE;
     }
   len = converted;
-  status = avro_putlong (io, &len);
+  status = avro_write_long (io, &len);
   if (status != AVRO_OK)
     {
       return status;
@@ -56,8 +57,8 @@
 }
 
 avro_status_t
-avro_getstring (struct avro_io * io, apr_pool_t * pool,
-		avro_string_t * string)
+avro_read_string (struct avro_io_reader * io, apr_pool_t * pool,
+		  avro_string_t * string)
 {
   avro_status_t status;
   avro_long_t len;
@@ -68,7 +69,7 @@
     {
       return AVRO_FAILURE;
     }
-  status = avro_getlong (io, &len);
+  status = avro_read_long (io, &len);
   if (status != AVRO_OK)
     {
       return status;
@@ -82,7 +83,7 @@
     {
       return AVRO_FAILURE;
     }
-  status = io->read (io, s, len);
+  status = io->read (io, (void *) s, len);
   if (status != AVRO_OK)
     {
       return status;
@@ -105,14 +106,14 @@
 }
 
 avro_status_t
-avro_putbytes (struct avro_io * io, char *data, avro_long_t len)
+avro_write_bytes (struct avro_io_writer * io, void *data, avro_long_t len)
 {
   avro_status_t status;
   if (!io || !data || len < 0)
     {
       return AVRO_FAILURE;
     }
-  status = avro_putlong (io, &len);
+  status = avro_write_long (io, &len);
   if (status != AVRO_OK)
     {
       return status;
@@ -121,20 +122,20 @@
 }
 
 avro_status_t
-avro_getbytes (struct avro_io * io, apr_pool_t * pool, char **data,
-	       avro_long_t * len)
+avro_read_bytes (struct avro_io_reader * io, apr_pool_t * pool, void **data,
+		 avro_long_t * len)
 {
   avro_status_t status;
   if (!io || !pool || !data || !len)
     {
       return AVRO_FAILURE;
     }
-  status = avro_getlong (io, len);
+  status = avro_read_long (io, len);
   if (status != AVRO_OK)
     {
       return status;
     }
-  *data = (char *) apr_pcalloc (pool, *len);
+  *data = apr_pcalloc (pool, *len);
   if (!*data)
     {
       return AVRO_FAILURE;
@@ -143,7 +144,7 @@
 }
 
 avro_status_t
-avro_putbool (struct avro_io * io, int boolean)
+avro_write_bool (struct avro_io_writer * io, int boolean)
 {
   char b;
   if (!io)
@@ -155,7 +156,7 @@
 }
 
 avro_status_t
-avro_getbool (struct avro_io * io, int *boolean)
+avro_read_bool (struct avro_io_reader * io, int *boolean)
 {
   avro_status_t status;
   char b;
@@ -173,7 +174,7 @@
 }
 
 avro_status_t
-avro_putint (struct avro_io * io, avro_int_t * ip)
+avro_write_int (struct avro_io_writer * io, avro_int_t * ip)
 {
   avro_status_t status;
   int32_t n = *ip;
@@ -201,7 +202,7 @@
 }
 
 avro_status_t
-avro_putlong (struct avro_io *io, avro_long_t * lp)
+avro_write_long (struct avro_io_writer *io, avro_long_t * lp)
 {
   avro_status_t status;
   int64_t n = *lp;
@@ -229,7 +230,7 @@
 }
 
 avro_status_t
-avro_getint (struct avro_io *io, avro_int_t * ip)
+avro_read_int (struct avro_io_reader *io, avro_int_t * ip)
 {
   avro_status_t status;
   int64_t value = 0;
@@ -263,7 +264,7 @@
 }
 
 avro_status_t
-avro_getlong (struct avro_io * io, avro_long_t * lp)
+avro_read_long (struct avro_io_reader * io, avro_long_t * lp)
 {
   avro_status_t status;
   int64_t value = 0;

Modified: hadoop/avro/trunk/src/c/avro_private.h
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_private.h?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_private.h (original)
+++ hadoop/avro/trunk/src/c/avro_private.h Sat Oct 31 23:19:10 2009
@@ -42,13 +42,20 @@
 typedef int64_t avro_long_t;
 
 /* functions for reading and writing bytes */
-struct avro_io
+struct avro_io_reader
 {
-  avro_status_t (*read) (struct avro_io * io, char *addr, uint64_t len);
-  avro_status_t (*skip) (struct avro_io * io, uint64_t len);
-  avro_status_t (*write) (struct avro_io * io, char *addr, uint64_t len);
+  avro_status_t (*read) (struct avro_io_reader * reader, void *addr,
+			 avro_long_t len);
+  avro_status_t (*skip) (struct avro_io_reader * reader, avro_long_t len);
 };
-typedef struct avro_io avro_io;
+typedef struct avro_io_reader avro_io_reader;
+
+struct avro_io_writer
+{
+  avro_status_t (*write) (struct avro_io_writer * writer, void *addr,
+			  avro_long_t len);
+};
+typedef struct avro_io_writer avro_io_writer;
 
 /* list of avro formats */
 enum avro_format
@@ -60,13 +67,21 @@
 };
 typedef enum avro_format avro_format;
 
-/* generic communication channel for sending/receiving avro data */
-struct avro_channel
+/* generic communication channel for reading avro data */
+struct avro_reader
+{
+  avro_format format;
+  avro_io_reader *io;
+};
+typedef struct avro_reader avro_reader;
+
+/* generic communication channel for writing avro data */
+struct avro_writer
 {
   avro_format format;
-  avro_io *io;
+  avro_io_writer *io;
 };
-typedef struct avro_channel avro_channel;
+typedef struct avro_writer avro_writer;
 
 /* information that all values have */
 struct avro_value
@@ -81,11 +96,11 @@
 struct avro_value_methods
 {
   avro_status_t (*read_data) (struct avro_value * value,
-			      struct avro_channel * channel);
+			      struct avro_reader * reader);
   avro_status_t (*skip_data) (struct avro_value * value,
-			      struct avro_channel * channel);
+			      struct avro_reader * reader);
   avro_status_t (*write_data) (struct avro_value * value,
-			       struct avro_channel * channel);
+			       struct avro_writer * writer);
 };
 
 /* Globals used during schema creation */
@@ -109,11 +124,11 @@
 extern const struct avro_value_info *avro_value_registry[];
 
 avro_status_t avro_value_read_data (struct avro_value *value,
-				    struct avro_channel *channel);
+				    struct avro_reader *channel);
 avro_status_t avro_value_skip_data (struct avro_value *value,
-				    struct avro_channel *channel);
+				    struct avro_reader *channel);
 avro_status_t avro_value_write_data (struct avro_value *value,
-				     struct avro_channel *channel);
+				     struct avro_writer *channel);
 void avro_value_print_info (struct avro_value *value, FILE * fp);
 
 
@@ -133,41 +148,60 @@
 /* Helper utility for printing the indent */
 void avro_value_indent (struct avro_value *value, FILE * fp);
 
-struct avro_io *avro_io_file_create (apr_file_t * file);
-struct avro_io *avro_io_socket_create (apr_socket_t * socket);
-struct avro_io *avro_io_memory_create (apr_pool_t * pool, char *addr,
-				       int64_t len);
-
-struct avro_channel *avro_file_container_create_from_file (apr_file_t * file);
-struct avro_channel *avro_file_container_create (apr_pool_t * pool,
-						 const char *fname,
-						 apr_int32_t flag,
-						 apr_fileperms_t perm);
+struct avro_io_reader *avro_io_reader_from_file (apr_file_t * file);
+struct avro_io_writer *avro_io_writer_from_file (apr_file_t * file);
+struct avro_io_reader *avro_io_reader_from_socket (apr_socket_t * socket);
+struct avro_io_writer *avro_io_writer_from_socket (apr_socket_t * socket);
+struct avro_io_reader *avro_io_reader_from_memory (apr_pool_t * pool,
+						   void *addr,
+						   avro_long_t len);
+struct avro_io_writer *avro_io_writer_from_memory (apr_pool_t * pool,
+						   void *addr,
+						   avro_long_t len);
+
+/* File container */
+struct avro_reader *avro_reader_file_container_from_file (apr_file_t * file);
+struct avro_reader *avro_reader_file_container_create (apr_pool_t * pool,
+						       const char *fname,
+						       apr_int32_t flag,
+						       apr_fileperms_t perm);
 
 /* Endian helpers */
-avro_status_t avro_getint32_le (struct avro_io *io, int32_t * value);
-avro_status_t avro_putint32_le (struct avro_io *io, const int32_t value);
-avro_status_t avro_getint32_be (struct avro_io *io, int32_t * value);
-avro_status_t avro_putint32_be (struct avro_io *io, const int32_t value);
-avro_status_t avro_getint64_le (struct avro_io *io, int64_t * value);
-avro_status_t avro_putint64_le (struct avro_io *io, const int64_t value);
-avro_status_t avro_getint64_be (struct avro_io *io, int64_t * value);
-avro_status_t avro_putint64_be (struct avro_io *io, const int64_t value);
+avro_status_t avro_read_int32_le (struct avro_io_reader *reader,
+				  int32_t * value);
+avro_status_t avro_write_int32_le (struct avro_io_writer *writer,
+				   const int32_t value);
+avro_status_t avro_read_int32_be (struct avro_io_reader *reader,
+				  int32_t * value);
+avro_status_t avro_write_int32_be (struct avro_io_writer *writer,
+				   const int32_t value);
+avro_status_t avro_read_int64_le (struct avro_io_reader *reader,
+				  int64_t * value);
+avro_status_t avro_write_int64_le (struct avro_io_writer *writer,
+				   const int64_t value);
+avro_status_t avro_read_int64_be (struct avro_io_reader *reader,
+				  int64_t * value);
+avro_status_t avro_write_int64_be (struct avro_io_writer *writer,
+				   const int64_t value);
 
 /* Primitive IO Functions */
-avro_status_t avro_putstring (struct avro_io *io, apr_pool_t * pool,
-			      avro_string_t string);
-avro_status_t avro_getstring (struct avro_io *io, apr_pool_t * pool,
-			      avro_string_t * string);
-avro_status_t avro_putbytes (struct avro_io *io, char *data, int64_t len);
-avro_status_t avro_getbytes (struct avro_io *io, apr_pool_t * pool,
-			     char **data, int64_t * len);
-avro_status_t avro_putbool (struct avro_io *io, int boolean);
-avro_status_t avro_getbool (struct avro_io *io, int *boolean);
-avro_status_t avro_putint (struct avro_io *io, avro_int_t * ip);
-avro_status_t avro_putlong (struct avro_io *io, avro_long_t * lp);
-avro_status_t avro_getint (struct avro_io *io, avro_int_t * ip);
-avro_status_t avro_getlong (struct avro_io *io, avro_long_t * lp);
+avro_status_t avro_write_string (struct avro_io_writer *writer,
+				 apr_pool_t * pool, avro_string_t string);
+avro_status_t avro_read_string (struct avro_io_reader *reader,
+				apr_pool_t * pool, avro_string_t * string);
+avro_status_t avro_write_bytes (struct avro_io_writer *writer, void *data,
+				avro_long_t len);
+avro_status_t avro_read_bytes (struct avro_io_reader *reader,
+			       apr_pool_t * pool, void **data,
+			       avro_long_t * len);
+avro_status_t avro_write_bool (struct avro_io_writer *writer, int boolean);
+avro_status_t avro_read_bool (struct avro_io_reader *reader, int *boolean);
+avro_status_t avro_write_int (struct avro_io_writer *writer, avro_int_t * ip);
+avro_status_t avro_write_long (struct avro_io_writer *writer,
+			       avro_long_t * lp);
+avro_status_t avro_read_int (struct avro_io_reader *reader, avro_int_t * ip);
+avro_status_t avro_read_long (struct avro_io_reader *reader,
+			      avro_long_t * lp);
 
 #define DEBUGGING 0
 

Modified: hadoop/avro/trunk/src/c/avro_record.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_record.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_record.c (original)
+++ hadoop/avro/trunk/src/c/avro_record.c Sat Oct 31 23:19:10 2009
@@ -64,27 +64,27 @@
 
 /* FIELDS */
 static avro_status_t
-avro_field_read (struct avro_value *value, struct avro_channel *channel)
+avro_field_read (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_field_value *self =
     container_of (value, struct avro_field_value, base_value);
-  return avro_value_read_data (self->value, channel);
+  return avro_value_read_data (self->value, reader);
 }
 
 static avro_status_t
-avro_field_skip (struct avro_value *value, struct avro_channel *channel)
+avro_field_skip (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_field_value *self =
     container_of (value, struct avro_field_value, base_value);
-  return avro_value_skip_data (self->value, channel);
+  return avro_value_skip_data (self->value, reader);
 }
 
 static avro_status_t
-avro_field_write (struct avro_value *value, struct avro_channel *channel)
+avro_field_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_field_value *self =
     container_of (value, struct avro_field_value, base_value);
-  return avro_value_write_data (self->value, channel);
+  return avro_value_write_data (self->value, writer);
 }
 
 /* The field constructor is private so we register a noop */
@@ -143,7 +143,7 @@
 }
 
 static avro_status_t
-avro_record_read_skip (struct avro_value *value, struct avro_channel *channel,
+avro_record_read_skip (struct avro_value *value, struct avro_reader *reader,
 		       int skip)
 {
   int i;
@@ -156,11 +156,11 @@
 	((struct avro_value **) self->fields->elts)[i];
       if (skip)
 	{
-	  avro_value_skip_data (field, channel);
+	  avro_value_skip_data (field, reader);
 	}
       else
 	{
-	  avro_value_read_data (field, channel);
+	  avro_value_read_data (field, reader);
 	}
     }
   return AVRO_OK;
@@ -168,19 +168,19 @@
 
 /* RECORD */
 static avro_status_t
-avro_record_read (struct avro_value *value, struct avro_channel *channel)
+avro_record_read (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_record_read_skip (value, channel, 0);
+  return avro_record_read_skip (value, reader, 0);
 }
 
 static avro_status_t
-avro_record_skip (struct avro_value *value, struct avro_channel *channel)
+avro_record_skip (struct avro_value *value, struct avro_reader *reader)
 {
-  return avro_record_read_skip (value, channel, 1);
+  return avro_record_read_skip (value, reader, 1);
 }
 
 static avro_status_t
-avro_record_write (struct avro_value *value, struct avro_channel *channel)
+avro_record_write (struct avro_value *value, struct avro_writer *writer)
 {
 /* TODO:
   struct avro_record_value *record =

Modified: hadoop/avro/trunk/src/c/avro_string.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_string.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_string.c (original)
+++ hadoop/avro/trunk/src/c/avro_string.c Sat Oct 31 23:19:10 2009
@@ -41,45 +41,45 @@
 }
 
 static avro_status_t
-avro_string_read (struct avro_value *value, struct avro_channel *channel)
+avro_string_read (struct avro_value *value, struct avro_reader *reader)
 {
-  struct avro_io *io;
+  struct avro_io_reader *io;
   struct avro_string_value *self =
     container_of (value, struct avro_string_value, base_value);
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = reader->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
   apr_pool_clear (self->pool);
   self->value_set = 1;
-  return avro_getstring (io, self->pool, &self->value);
+  return avro_read_string (io, self->pool, &self->value);
 }
 
 static avro_status_t
-avro_string_skip (struct avro_value *value, struct avro_channel *channel)
+avro_string_skip (struct avro_value *value, struct avro_reader *reader)
 {
   avro_status_t status;
   avro_long_t len;
-  struct avro_io *io;
+  struct avro_io_reader *io;
   struct avro_string_value *self =
     container_of (value, struct avro_string_value, base_value);
 
   self->value_set = 0;
-  if (!channel)
+  if (!reader)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = reader->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
-  status = avro_getlong (io, &len);
+  status = avro_read_long (io, &len);
   if (status != AVRO_OK)
     {
       return status;
@@ -92,21 +92,21 @@
 }
 
 static avro_status_t
-avro_string_write (struct avro_value *value, struct avro_channel *channel)
+avro_string_write (struct avro_value *value, struct avro_writer *writer)
 {
-  struct avro_io *io;
+  struct avro_io_writer *io;
   struct avro_string_value *self =
     container_of (value, struct avro_string_value, base_value);
-  if (!channel)
+  if (!writer)
     {
       return AVRO_FAILURE;
     }
-  io = channel->io;
+  io = writer->io;
   if (!io)
     {
       return AVRO_FAILURE;
     }
-  return avro_putstring (io, self->pool, self->value);
+  return avro_write_string (io, self->pool, self->value);
 }
 
 static struct avro_value *

Modified: hadoop/avro/trunk/src/c/avro_union.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_union.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_union.c (original)
+++ hadoop/avro/trunk/src/c/avro_union.c Sat Oct 31 23:19:10 2009
@@ -34,7 +34,7 @@
 }
 
 static avro_status_t
-avro_union_read (struct avro_value *value, struct avro_channel *channel)
+avro_union_read (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_union_value *self =
     container_of (value, struct avro_union_value, base_value);
@@ -42,7 +42,7 @@
 }
 
 static avro_status_t
-avro_union_skip (struct avro_value *value, struct avro_channel *channel)
+avro_union_skip (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_union_value *self =
     container_of (value, struct avro_union_value, base_value);
@@ -50,7 +50,7 @@
 }
 
 static avro_status_t
-avro_union_write (struct avro_value *value, struct avro_channel *channel)
+avro_union_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_union_value *self =
     container_of (value, struct avro_union_value, base_value);

Modified: hadoop/avro/trunk/src/c/avro_value.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/avro_value.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/avro_value.c (original)
+++ hadoop/avro/trunk/src/c/avro_value.c Sat Oct 31 23:19:10 2009
@@ -120,27 +120,27 @@
 }
 
 static avro_status_t
-avro_decorator_read (struct avro_value *value, struct avro_channel *channel)
+avro_decorator_read (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_decorator_value *self =
     container_of (value, struct avro_decorator_value, base_value);
-  return avro_value_read_data (self->decoratee, channel);
+  return avro_value_read_data (self->decoratee, reader);
 }
 
 static avro_status_t
-avro_decorator_skip (struct avro_value *value, struct avro_channel *channel)
+avro_decorator_skip (struct avro_value *value, struct avro_reader *reader)
 {
   struct avro_decorator_value *self =
     container_of (value, struct avro_decorator_value, base_value);
-  return avro_value_skip_data (self->decoratee, channel);
+  return avro_value_skip_data (self->decoratee, reader);
 }
 
 static avro_status_t
-avro_decorator_write (struct avro_value *value, struct avro_channel *channel)
+avro_decorator_write (struct avro_value *value, struct avro_writer *writer)
 {
   struct avro_decorator_value *self =
     container_of (value, struct avro_decorator_value, base_value);
-  return avro_value_write_data (self->decoratee, channel);
+  return avro_value_write_data (self->decoratee, writer);
 }
 
 /* Used for recursive schemas */
@@ -222,7 +222,7 @@
       return NULL;
     }
 
-  return avro_value_registry[avro_type]->private ? NULL:
+  return avro_value_registry[avro_type]->private ? NULL :
     avro_value_registry[avro_type]->create (ctx, parent, subpool, json);
 }
 
@@ -255,39 +255,36 @@
 }
 
 avro_status_t
-avro_value_read_data (struct avro_value * value,
-		      struct avro_channel * channel)
+avro_value_read_data (struct avro_value * value, struct avro_reader * reader)
 {
-  if (!value || !channel)
+  if (!value || !reader)
     {
       return AVRO_FAILURE;
     }
-  return avro_value_registry[value->type]->formats[channel->format].
-    read_data (value, channel);
+  return avro_value_registry[value->type]->formats[reader->format].
+    read_data (value, reader);
 }
 
 avro_status_t
-avro_value_skip_data (struct avro_value * value,
-		      struct avro_channel * channel)
+avro_value_skip_data (struct avro_value * value, struct avro_reader * reader)
 {
-  if (!value || !channel)
+  if (!value || !reader)
     {
       return AVRO_FAILURE;
     }
-  return avro_value_registry[value->type]->formats[channel->format].
-    skip_data (value, channel);
+  return avro_value_registry[value->type]->formats[reader->format].
+    skip_data (value, reader);
 }
 
 avro_status_t
-avro_value_write_data (struct avro_value * value,
-		       struct avro_channel * channel)
+avro_value_write_data (struct avro_value * value, struct avro_writer * writer)
 {
-  if (!value || !channel)
+  if (!value || !writer)
     {
       return AVRO_FAILURE;
     }
-  return avro_value_registry[value->type]->formats[channel->format].
-    write_data (value, channel);
+  return avro_value_registry[value->type]->formats[writer->format].
+    write_data (value, writer);
 }
 
 void

Modified: hadoop/avro/trunk/src/c/test_avro_interop.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c/test_avro_interop.c?rev=831615&r1=831614&r2=831615&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c/test_avro_interop.c (original)
+++ hadoop/avro/trunk/src/c/test_avro_interop.c Sat Oct 31 23:19:10 2009
@@ -24,7 +24,7 @@
   char *jsontext;
   apr_size_t jsonlen;
   struct avro_value *value;
-  struct avro_channel *channel;
+  struct avro_reader *reader;
 
   if (!srcdir)
     {
@@ -60,16 +60,16 @@
     {
       return EXIT_FAILURE;
     }
-  channel = avro_file_container_create (pool, path, APR_READ, APR_OS_DEFAULT);
-  if (!channel)
+  reader =
+    avro_reader_file_container_create (pool, path, APR_READ, APR_OS_DEFAULT);
+  if (!reader)
     {
       fprintf (stderr, "Failed to open data file %s\n", path);
       return EXIT_FAILURE;
     }
 
-  value->read_data (value, channel);
-  value->print_info (value, stderr);
-
+  avro_value_read_data (value, reader);
+  avro_value_print_info (value, stderr);
   apr_pool_destroy (pool);
   return EXIT_SUCCESS;
 }



Mime
View raw message