Update of /cvsroot/monetdb/MonetDB5/src/modules/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv326/src/modules/mal
Modified Files:
tablet.mx
Log Message:
add support for line offsets (ie ignore the first N lines)
Index: tablet.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/tablet.mx,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- tablet.mx 10 Dec 2007 18:04:31 -0000 1.108
+++ tablet.mx 13 Dec 2007 14:57:20 -0000 1.109
@@ -1509,18 +1509,20 @@
TABLETload_file(Tablet * as, bstream *b, stream *out)
{
int res = 0, done = 0;
- size_t i = 0;
+ size_t i = 1;
char *sep = as->format[as->nr_attrs - 1].sep;
int seplen = as->format[as->nr_attrs - 1].seplen;
+ size_t nr = as->offset + as->nr;
+ size_t offset = as->offset;
if (tablet_debug)
stream_printf(GDKerr, "TABLETload_file\n");
- while ((b->pos < b->len || !b->eof) && res == 0 && (as->nr == ~(size_t)
0 || i < as->nr)) {
+ while ((b->pos < b->len || !b->eof) && res == 0 && (nr == ~(size_t) 0
|| i <= nr)) {
char *s, *end;
if (b->pos >= b->len && read_more(b, out, b->size - (b->len -
b->pos)) == EOF) {
- if (as->nr != ~(size_t)0 && i < as->nr) {
+ if (nr != ~(size_t)0 && i <= nr) {
res = 1;
if (b->len > b->pos) {
GDKerror("TABLETload_file: read error
(after loading %d records)\n", BATcount(as->format[0].c));
@@ -1538,7 +1540,7 @@
if (e) {
*e = '\0';
- if (insert_line(as, s, NULL) < 0) {
+ if (i>=offset && insert_line(as, s, NULL) < 0) {
s = e + seplen;
b->pos = (s - b->buf);
res = -1;
@@ -1558,6 +1560,7 @@
/* some data left? */
res = 1;
if (b->len > b->pos &&
+ i>=offset &&
insert_line(as, s, NULL) <
0) {
GDKerror(as->error);
as->error=0;
@@ -1579,11 +1582,11 @@
i++;
if (tablet_debug && (i % 100000) == 0)
stream_printf(GDKerr, "inserted " SZFMT "\n",
i);
- if (as->nr != ~(size_t) 0 && i >= as->nr)
+ if (nr != ~(size_t) 0 && i > nr)
break;
}
}
- as->nr = i;
+ as->nr = i-as->offset-1;
if (res < 0)
return res;
return (ssize_t) as->nr;
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins