[prev in list] [next in list] [prev in thread] [next in thread] 

List:       avro-commits
Subject:    svn commit: r1352858 - in /avro/trunk: CHANGES.txt lang/c/src/avro/io.h lang/c/src/datafile.c
From:       dcreager () apache ! org
Date:       2012-06-22 11:59:33
Message-ID: 20120622115933.EC41F2388865 () eris ! apache ! org
[Download RAW message or body]

Author: dcreager
Date: Fri Jun 22 11:59:32 2012
New Revision: 1352858

URL: http://svn.apache.org/viewvc?rev=1352858&view=rev
Log:
AVRO-1117. C: Add should_close parameter to avro_file_writer_create{_with_codec}_fp

Contributed by Lucas Martin-King.

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=1352858&r1=1352857&r2=1352858&view=diff
 ==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Fri Jun 22 11:59:32 2012
@@ -16,7 +16,7 @@ Avro 1.7.1 (unreleased)
     AVRO-1104. C: avroappend utility. (Lucas Martin-King via dcreager)
 
     AVRO-1117. C: avro_file_writer_create_with_codec_fp and
-    avro_file_writer_create_with_fp functions.
+    avro_file_writer_create_with_fp functions, with should_close parameter.
     (Lucas Martin-King via dcreager)
 
   IMPROVEMENTS

Modified: avro/trunk/lang/c/src/avro/io.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/io.h?rev=1352858&r1=1352857&r2=1352858&view=diff
 ==============================================================================
--- avro/trunk/lang/c/src/avro/io.h (original)
+++ avro/trunk/lang/c/src/avro/io.h Fri Jun 22 11:59:32 2012
@@ -99,12 +99,12 @@ typedef struct avro_file_writer_t_ *avro
 
 int avro_file_writer_create(const char *path, avro_schema_t schema,
 			    avro_file_writer_t * writer);
-int avro_file_writer_create_fp(FILE *fp, const char *path, avro_schema_t schema,
-				avro_file_writer_t * writer);
+int avro_file_writer_create_fp(FILE *fp, const char *path, int should_close,
+				avro_schema_t schema, avro_file_writer_t * writer);
 int avro_file_writer_create_with_codec(const char *path,
 				avro_schema_t schema, avro_file_writer_t * writer,
 				const char *codec, size_t block_size);
-int avro_file_writer_create_with_codec_fp(FILE *fp, const char *path,
+int avro_file_writer_create_with_codec_fp(FILE *fp, const char *path, int \
should_close,  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);

Modified: avro/trunk/lang/c/src/datafile.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datafile.c?rev=1352858&r1=1352857&r2=1352858&view=diff
 ==============================================================================
--- avro/trunk/lang/c/src/datafile.c (original)
+++ avro/trunk/lang/c/src/datafile.c Fri Jun 22 11:59:32 2012
@@ -108,7 +108,7 @@ static int write_header(avro_file_writer
 }
 
 static int
-file_writer_init_fp(FILE *fp, const char *path, const char *mode, avro_file_writer_t \
w) +file_writer_init_fp(FILE *fp, const char *path, int should_close, const char \
*mode, avro_file_writer_t w)  {
 	if (!fp) {
 		fp = fopen(path, mode);
@@ -118,9 +118,11 @@ file_writer_init_fp(FILE *fp, const char
 		avro_set_error("Cannot open file for %s", path);
 		return ENOMEM;
 	}
-	w->writer = avro_writer_file(fp);
+	w->writer = avro_writer_file_fp(fp, should_close);
 	if (!w->writer) {
-		fclose(fp);
+		if (should_close) {
+			fclose(fp);
+		}
 		avro_set_error("Cannot create file writer for %s", path);
 		return ENOMEM;
 	}
@@ -138,14 +140,14 @@ file_writer_init_fp(FILE *fp, const char
 #endif
 
 static int
-file_writer_create(FILE *fp, const char *path, avro_schema_t schema, \
avro_file_writer_t w, size_t block_size) +file_writer_create(FILE *fp, const char \
*path, int should_close, avro_schema_t schema, avro_file_writer_t w, size_t \
block_size)  {
 	int rval;
 
 	w->block_count = 0;
-	rval = file_writer_init_fp(fp, path, EXCLUSIVE_WRITE_MODE, w);
+	rval = file_writer_init_fp(fp, path, should_close, EXCLUSIVE_WRITE_MODE, w);
 	if (rval) {
-		check(rval, file_writer_init_fp(fp, path, "wb", w));
+		check(rval, file_writer_init_fp(fp, path, should_close, "wb", w));
 	}
 
 	w->datum_buffer_size = block_size;
@@ -174,24 +176,24 @@ int
 avro_file_writer_create(const char *path, avro_schema_t schema,
 			avro_file_writer_t * writer)
 {
-	return avro_file_writer_create_with_codec_fp(NULL, path, schema, writer, "null", \
0); +	return avro_file_writer_create_with_codec_fp(NULL, path, 1, schema, writer, \
"null", 0);  }
 
 int
-avro_file_writer_create_fp(FILE *fp, const char *path, avro_schema_t schema,
+avro_file_writer_create_fp(FILE *fp, const char *path, int should_close, \
avro_schema_t schema,  avro_file_writer_t * writer)
 {
-	return avro_file_writer_create_with_codec_fp(fp, path, schema, writer, "null", 0);
+	return avro_file_writer_create_with_codec_fp(fp, path, should_close, schema, \
writer, "null", 0);  }
 
 int avro_file_writer_create_with_codec(const char *path,
 			avro_schema_t schema, avro_file_writer_t * writer,
 			const char *codec, size_t block_size)
 {
-	return avro_file_writer_create_with_codec_fp(NULL, path, schema, writer, codec, \
block_size); +	return avro_file_writer_create_with_codec_fp(NULL, path, 1, schema, \
writer, codec, block_size);  }
 
-int avro_file_writer_create_with_codec_fp(FILE *fp, const char *path,
+int avro_file_writer_create_with_codec_fp(FILE *fp, const char *path, int \
should_close,  avro_schema_t schema, avro_file_writer_t * writer,
 			const char *codec, size_t block_size)
 {
@@ -224,7 +226,7 @@ int avro_file_writer_create_with_codec_f
 		avro_freet(struct avro_file_writer_t_, w);
 		return rval;
 	}
-	rval = file_writer_create(fp, path, schema, w, block_size);
+	rval = file_writer_create(fp, path, should_close, schema, w, block_size);
 	if (rval) {
 		avro_codec_reset(w->codec);
 		avro_freet(struct avro_codec_t_, w->codec);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic