avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcrea...@apache.org
Subject svn commit: r1384531 - in /avro/trunk: CHANGES.txt lang/c/src/avro/io.h lang/c/src/datafile.c
Date Thu, 13 Sep 2012 21:12:01 GMT
Author: dcreager
Date: Thu Sep 13 21:12:01 2012
New Revision: 1384531

URL: http://svn.apache.org/viewvc?rev=1384531&view=rev
Log:
AVRO-1138. C: Open data file with new block size

This obviously won't affect any blocks that are already in the file, but any new
blocks that are appended will use the new block size.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c/src/avro/io.h
    avro/trunk/lang/c/src/datafile.c

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1384531&r1=1384530&r2=1384531&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Thu Sep 13 21:12:01 2012
@@ -22,6 +22,9 @@ Avro 1.7.2 (unreleased)
     AVRO-1149. Java: Add a constructor to generated classes with all
     fields as parameters. (Gabriel Reid via cutting)
 
+    AVRO-1138. C: Add function for opening existing data file with non-default
+    block size.  (Maxim Pugachev via dcreager)
+
   BUG FIXES
 
     AVRO-1128. Java: Fix SpecificRecordBase#equals() to work for

Modified: avro/trunk/lang/c/src/avro/io.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/io.h?rev=1384531&r1=1384530&r2=1384531&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/io.h (original)
+++ avro/trunk/lang/c/src/avro/io.h Thu Sep 13 21:12:01 2012
@@ -108,6 +108,7 @@ int avro_file_writer_create_with_codec_f
 				avro_schema_t schema, avro_file_writer_t * writer,
 				const char *codec, size_t block_size);
 int avro_file_writer_open(const char *path, avro_file_writer_t * writer);
+int avro_file_writer_open_bs(const char *path, avro_file_writer_t * writer, size_t block_size);
 int avro_file_reader(const char *path, avro_file_reader_t * reader);
 int avro_file_reader_fp(FILE *fp, const char *path, int should_close,
 			avro_file_reader_t * reader);

Modified: avro/trunk/lang/c/src/datafile.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datafile.c?rev=1384531&r1=1384530&r2=1384531&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datafile.c (original)
+++ avro/trunk/lang/c/src/datafile.c Thu Sep 13 21:12:01 2012
@@ -323,7 +323,8 @@ static int file_read_header(avro_reader_
 	return avro_read(reader, sync, synclen);
 }
 
-static int file_writer_open(const char *path, avro_file_writer_t w)
+static int
+file_writer_open(const char *path, avro_file_writer_t w, size_t block_size)
 {
 	int rval;
 	FILE *fp;
@@ -367,7 +368,11 @@ static int file_writer_open(const char *
 		return ENOMEM;
 	}
 
-	w->datum_buffer_size = DEFAULT_BLOCK_SIZE;
+	if (block_size == 0) {
+		block_size = DEFAULT_BLOCK_SIZE;
+	}
+
+	w->datum_buffer_size = block_size;
 	w->datum_buffer = avro_malloc(w->datum_buffer_size);
 
 	if(!w->datum_buffer) {
@@ -388,7 +393,9 @@ static int file_writer_open(const char *
 	return 0;
 }
 
-int avro_file_writer_open(const char *path, avro_file_writer_t * writer)
+int
+avro_file_writer_open_bs(const char *path, avro_file_writer_t * writer,
+			 size_t block_size)
 {
 	avro_file_writer_t w;
 	int rval;
@@ -407,7 +414,7 @@ int avro_file_writer_open(const char *pa
 		return ENOMEM;
 	}
 	avro_codec(w->codec, NULL);
-	rval = file_writer_open(path, w);
+	rval = file_writer_open(path, w, block_size);
 	if (rval) {
 		avro_codec_reset(w->codec);
 		avro_freet(struct avro_codec_t_, w->codec);
@@ -419,6 +426,12 @@ int avro_file_writer_open(const char *pa
 	return 0;
 }
 
+int
+avro_file_writer_open(const char *path, avro_file_writer_t * writer)
+{
+	return avro_file_writer_open_bs(path, writer, 0);
+}
+
 static int file_read_block_count(avro_file_reader_t r)
 {
 	int rval;



Mime
View raw message