Changeset: 3030bcfab5f7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3030bcfab5f7
Modified Files:
        clients/Tests/exports.stable.out
        common/stream/ChangeLog
        common/stream/stream.c
        common/stream/stream.h
        sql/backends/monet5/vaults/bam/bam_globals.c
Branch: default
Log Message:

Removed function wbstream.
There is no need for to add this stream type on top of a file stream:
that is already buffered by standard I/O.


diffs (212 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -2686,7 +2686,6 @@ stream *socket_wastream(SOCKET socket, c
 stream *socket_wstream(SOCKET socket, const char *name);
 stream *stream_blackhole_create(void);
 stream *stream_fwf_create(stream *s, size_t num_fields, size_t *widths, char 
filler);
-stream *wbstream(stream *s, size_t buflen);
 
 
 # 21:41:06 >  
diff --git a/common/stream/ChangeLog b/common/stream/ChangeLog
--- a/common/stream/ChangeLog
+++ b/common/stream/ChangeLog
@@ -1,6 +1,9 @@
 # ChangeLog file for stream
 # This file is updated with Maddlog
 
+* Tue Aug  8 2017 Sjoerd Mullender <sjo...@acm.org>
+- Removed function wbstream.
+
 * Mon Aug  7 2017 Sjoerd Mullender <sjo...@acm.org>
 - Removed functions udp_rastream and udp_wastream.
 - Removed functions socket_rstream and socket_wstream.
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -4880,151 +4880,6 @@ bstream_destroy(bstream *s)
 
 /* ------------------------------------------------------------------ */
 
-/*
- * Buffered write stream batches subsequent write requests in order to
- * optimize write bandwidth
- */
-typedef struct {
-       stream *s;
-       size_t len, pos;
-       char buf[FLEXIBLE_ARRAY_MEMBER];        /* NOTE: buf extends beyond 
array for wbs->len bytes */
-} wbs_stream;
-
-static int
-wbs_flush(stream *s)
-{
-       wbs_stream *wbs;
-       size_t len;
-
-       wbs = (wbs_stream *) s->stream_data.p;
-       if (wbs == NULL)
-               return -1;
-       len = wbs->pos;
-       wbs->pos = 0;
-       if (wbs->s == NULL ||
-           wbs->s->write(wbs->s, wbs->buf, 1, len) != (ssize_t) len)
-               return -1;
-       if (wbs->s->flush)
-               return wbs->s->flush(wbs->s);
-       return 0;
-}
-
-static ssize_t
-wbs_write(stream *s, const void *buf, size_t elmsize, size_t cnt)
-{
-       wbs_stream *wbs;
-       size_t nbytes, reqsize = cnt * elmsize, todo = reqsize;
-
-       wbs = (wbs_stream *) s->stream_data.p;
-       if (wbs == NULL)
-               return -1;
-       while (todo > 0) {
-               int flush = 1;
-               nbytes = wbs->len - wbs->pos;
-               if (nbytes > todo) {
-                       nbytes = todo;
-                       flush = 0;
-               }
-               memcpy(wbs->buf + wbs->pos, buf, nbytes);
-               todo -= nbytes;
-               buf = (((const char *) buf) + nbytes);
-               wbs->pos += nbytes;
-               if (flush && wbs_flush(s) < 0)
-                       return -1;
-       }
-       return (ssize_t) cnt;
-}
-
-static void
-wbs_close(stream *s)
-{
-       wbs_stream *wbs = (wbs_stream *) s->stream_data.p;
-
-       wbs_flush(s);
-       if (wbs && wbs->s)
-               wbs->s->close(wbs->s);
-}
-
-static void
-wbs_destroy(stream *s)
-{
-       wbs_stream *wbs = (wbs_stream *) s->stream_data.p;
-
-       if (wbs) {
-               if (wbs->s)
-                       wbs->s->destroy(wbs->s);
-               free(wbs);
-       }
-       destroy(s);
-}
-
-static void
-wbs_update_timeout(stream *s)
-{
-       wbs_stream *wbs = (wbs_stream *) s->stream_data.p;
-
-       if (wbs && wbs->s) {
-               wbs->s->timeout = s->timeout;
-               wbs->s->timeout_func = s->timeout_func;
-               if (wbs->s->update_timeout)
-                       wbs->s->update_timeout(wbs->s);
-       }
-}
-
-static int
-wbs_isalive(stream *s)
-{
-       wbs_stream *wbs = (wbs_stream *) s->stream_data.p;
-
-       if (wbs && wbs->s) {
-               if (wbs->s->isalive)
-                       return wbs->s->isalive(wbs->s);
-               return 1;
-       }
-       return 0;
-}
-
-static void
-wbs_clrerr(stream *s)
-{
-       if (s && s->stream_data.p)
-               mnstr_clearerr(((wbs_stream *) s->stream_data.p)->s);
-}
-
-stream *
-wbstream(stream *s, size_t buflen)
-{
-       stream *ns;
-       wbs_stream *wbs;
-
-       if (s == NULL)
-               return NULL;
-       ns = create_stream(s->name);
-       if (ns == NULL)
-               return NULL;
-       wbs = (wbs_stream *) malloc(offsetof(wbs_stream, buf) + buflen);
-       if (wbs == NULL) {
-               destroy(ns);
-               return NULL;
-       }
-       ns->type = s->type;
-       ns->access = s->access;
-       ns->close = wbs_close;
-       ns->clrerr = wbs_clrerr;
-       ns->destroy = wbs_destroy;
-       ns->flush = wbs_flush;
-       ns->update_timeout = wbs_update_timeout;
-       ns->isalive = wbs_isalive;
-       ns->write = wbs_write;
-       ns->stream_data.p = (void *) wbs;
-       wbs->s = s;
-       wbs->pos = 0;
-       wbs->len = buflen;
-       return ns;
-}
-
-/* ------------------------------------------------------------------ */
-
 struct cbstream {
        void *private;
        void (*destroy)(void *);
diff --git a/common/stream/stream.h b/common/stream/stream.h
--- a/common/stream/stream.h
+++ b/common/stream/stream.h
@@ -219,7 +219,6 @@ stream_export buffer *mnstr_get_buffer(s
  * number of bytes can be read the end of the major block is
  * found. The next read will then start with a new major block.
  */
-stream_export stream *wbstream(stream *s, size_t buflen);
 stream_export stream *block_stream(stream *s);
 stream_export int isa_block_stream(stream *s);
 stream_export int isa_fixed_block_stream(stream *s);
diff --git a/sql/backends/monet5/vaults/bam/bam_globals.c 
b/sql/backends/monet5/vaults/bam/bam_globals.c
--- a/sql/backends/monet5/vaults/bam/bam_globals.c
+++ b/sql/backends/monet5/vaults/bam/bam_globals.c
@@ -23,7 +23,6 @@ stream *
 bsopen(str filepath)
 {
        stream *s;
-       stream *wbs;
 
        if ((s = open_wastream(filepath)) == NULL) {
                return NULL;
@@ -32,9 +31,5 @@ bsopen(str filepath)
                close_stream(s);
                return NULL;
        }
-       if ((wbs = wbstream(s, BSTREAM_CHUNK_SIZE)) == NULL) {
-               close_stream(s);
-               return NULL;
-       }
-       return wbs;
+       return s;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to