Changeset: f8f642f86db9 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f8f642f86db9
Modified Files:
monetdb5/modules/mal/tablet.c
Branch: resultset
Log Message:
Prettify.
diffs (truncated from 1355 to 300 lines):
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -122,7 +122,7 @@ TABLETadt_frStr(Column *c, int type, cha
int
TABLETadt_toStr(void *extra, char **buf, int *len, int type, ptr a)
{
- (void) extra; /* fool compiler */
+ (void) extra;
if (type == TYPE_str) {
char *dst, *src = a;
int l;
@@ -201,7 +201,7 @@ str
TABLETcreate_bats(Tablet *as, BUN est)
{
Column *fmt = as->format;
- BUN i,j;
+ BUN i, j;
for (i = 0; i < as->nr_attrs; i++) {
if (fmt[i].skip)
@@ -209,10 +209,10 @@ TABLETcreate_bats(Tablet *as, BUN est)
fmt[i].c = void_bat_create(fmt[i].adt, est);
fmt[i].ci = bat_iterator(fmt[i].c);
if (!fmt[i].c) {
- for(j=0; j<i; j++)
- if( !fmt[i].skip)
+ for (j = 0; j < i; j++)
+ if (!fmt[i].skip)
BBPdecref(fmt[j].c->batCacheid, FALSE);
- throw(SQL,"copy","Failed to create bat of size " BUNFMT
"\n", as->nr);
+ throw(SQL, "copy", "Failed to create bat of size "
BUNFMT "\n", as->nr);
}
}
return MAL_SUCCEED;
@@ -226,8 +226,8 @@ TABLETcollect(BAT **bats, Tablet *as)
BUN cnt = 0;
if (bats == NULL)
- throw(SQL,"copy","Missing container");
- for (i = 0; i < as->nr_attrs && !cnt; i++)
+ throw(SQL, "copy", "Missing container");
+ for (i = 0; i < as->nr_attrs && !cnt; i++)
if (!fmt[i].skip)
cnt = BATcount(fmt[i].c);
for (i = 0, j = 0; i < as->nr_attrs; i++) {
@@ -238,8 +238,8 @@ TABLETcollect(BAT **bats, Tablet *as)
BATsetaccess(fmt[i].c, BAT_READ);
BATderiveProps(fmt[i].c, 0);
- if (cnt != BATcount(fmt[i].c))
- throw(SQL,"copy", "Count " BUNFMT " differs from "
BUNFMT "\n", BATcount(fmt[i].c), cnt);
+ if (cnt != BATcount(fmt[i].c))
+ throw(SQL, "copy", "Count " BUNFMT " differs from "
BUNFMT "\n", BATcount(fmt[i].c), cnt);
j++;
}
return MAL_SUCCEED;
@@ -252,7 +252,7 @@ TABLETcollect_parts(BAT **bats, Tablet *
BUN i, j;
BUN cnt = 0;
- for (i = 0; i < as->nr_attrs && !cnt; i++)
+ for (i = 0; i < as->nr_attrs && !cnt; i++)
if (!fmt[i].skip)
cnt = BATcount(fmt[i].c);
for (i = 0, j = 0; i < as->nr_attrs; i++) {
@@ -261,11 +261,11 @@ TABLETcollect_parts(BAT **bats, Tablet *
continue;
b = fmt[i].c;
BATsetaccess(b, BAT_READ);
- bv = BATslice(b, (offset>0)?offset-1:0, BATcount(b));
+ bv = BATslice(b, (offset > 0) ? offset - 1 : 0, BATcount(b));
bats[j] = bv;
BATderiveProps(bv, 0);
- b->tkey = (offset>0)?FALSE:bv->tkey;
+ b->tkey = (offset > 0) ? FALSE : bv->tkey;
b->T->nonil &= bv->T->nonil;
b->tdense &= bv->tdense;
if (b->tsorted != bv->tsorted)
@@ -276,12 +276,12 @@ TABLETcollect_parts(BAT **bats, Tablet *
b->tkey = TRUE;
b->batDirty = TRUE;
- if (offset>0) {
+ if (offset > 0) {
BBPunfix(bv->batCacheid);
bats[j] = BATslice(b, offset, BATcount(b));
}
- if (cnt != BATcount(b))
- throw(SQL,"copy", "Count " BUNFMT " differs from "
BUNFMT "\n", BATcount(b), cnt);
+ if (cnt != BATcount(b))
+ throw(SQL, "copy", "Count " BUNFMT " differs from "
BUNFMT "\n", BATcount(b), cnt);
j++;
}
return MAL_SUCCEED;
@@ -524,9 +524,11 @@ output_file_default(Tablet *as, BAT *ord
BUN offset = BUNfirst(order) + as->offset;
BATiter orderi = bat_iterator(order);
- if (buf == NULL || localbuf == NULL){
- if( buf) GDKfree(buf);
- if( localbuf) GDKfree(localbuf);
+ if (buf == NULL || localbuf == NULL) {
+ if (buf)
+ GDKfree(buf);
+ if (localbuf)
+ GDKfree(localbuf);
return -1;
}
for (q = offset + as->nr, p = offset; p < q; p++) {
@@ -551,14 +553,16 @@ output_file_default(Tablet *as, BAT *ord
static int
output_file_dense(Tablet *as, stream *fd)
{
- int len = BUFSIZ, locallen= BUFSIZ, res = 0;
+ int len = BUFSIZ, locallen = BUFSIZ, res = 0;
char *buf = GDKmalloc(len);
char *localbuf = GDKmalloc(len);
BUN i = 0;
- if (buf == NULL || localbuf == NULL){
- if( buf) GDKfree(buf);
- if( localbuf) GDKfree(localbuf);
+ if (buf == NULL || localbuf == NULL) {
+ if (buf)
+ GDKfree(buf);
+ if (localbuf)
+ GDKfree(localbuf);
return -1;
}
for (i = 0; i < as->nr; i++) {
@@ -630,6 +634,7 @@ TABLEToutput_file(Tablet *as, BAT *order
}
return ret;
}
+
/*
* Niels Nes, Martin Kersten
*
@@ -684,7 +689,7 @@ typedef struct {
MT_Id tid;
MT_Sema producer; /* reader waits for call */
MT_Sema consumer; /* reader waits for call */
- MT_Sema sema; /* threads wait for work ,
negative next implies exit */
+ MT_Sema sema; /* threads wait for work , negative next implies exit */
MT_Sema reply; /* let reader continue */
Tablet *as;
char *errbuf;
@@ -693,10 +698,10 @@ typedef struct {
char quote;
char *base[MAXBUFFERS], *input[MAXBUFFERS]; /* buffers for line
splitter and tokenizer */
- size_t rowlimit[MAXBUFFERS]; /* determines
maximal record length buffer */
+ size_t rowlimit[MAXBUFFERS]; /* determines maximal record length buffer
*/
char **lines[MAXBUFFERS];
- int top[MAXBUFFERS]; /* number of lines in
this buffer */
- int cur; /* current buffer used
by splitter and update threads */
+ int top[MAXBUFFERS]; /* number of lines in this buffer */
+ int cur; /* current buffer used by splitter and update threads */
int *cols; /* columns to handle */
char ***fields;
@@ -708,7 +713,7 @@ typedef struct {
static void
tablet_error(READERtask *task, lng row, int col, str msg, str fcn)
{
- if( task->cntxt->error_row == NULL){
+ if (task->cntxt->error_row == NULL) {
MT_lock_set(&errorlock, "tablet_error");
BUNappend(task->cntxt->error_row, &row, FALSE);
BUNappend(task->cntxt->error_fld, &col, FALSE);
@@ -716,10 +721,11 @@ tablet_error(READERtask *task, lng row,
BUNappend(task->cntxt->error_input, fcn, FALSE);
if (task->as->error == NULL && (msg == NULL || (task->as->error
= GDKstrdup(msg)) == NULL))
task->as->error = M5OutOfMemory;
- if ( row != lng_nil)
- task->rowerror[row-1]++;
+ if (row != lng_nil)
+ task->rowerror[row - 1]++;
#ifdef _DEBUG_TABLET_
- mnstr_printf(GDKout,"#tablet_error: "LLFMT",%d:%s:%s\n",row,
col,msg,fcn);
+ mnstr_printf(GDKout, "#tablet_error: " LLFMT ",%d:%s:%s\n",
+ row, col, msg, fcn);
#endif
task->errorcnt++;
MT_lock_unset(&errorlock, "tablet_error");
@@ -747,7 +753,7 @@ SQLload_error(READERtask *task, lng idx)
line = (str) GDKmalloc(sz + task->rseplen + 1);
if (line == 0) {
- tablet_error(task, idx, int_nil, "SQLload malloc
error","SQLload_error");
+ tablet_error(task, idx, int_nil, "SQLload malloc error",
"SQLload_error");
return 0;
}
line[0] = 0;
@@ -770,40 +776,40 @@ SQLload_error(READERtask *task, lng idx)
static inline int
SQLinsert_val(READERtask *task, int col, int idx)
{
- Column *fmt = task->as->format+col;
+ Column *fmt = task->as->format + col;
const void *adt;
char buf[BUFSIZ];
char *s = task->fields[col][idx];
ptr key = 0;
char *err = NULL;
- int ret =0;
+ int ret = 0;
/* include testing on the terminating null byte !! */
- if ( s == 0 ){
+ if (s == 0) {
adt = fmt->nildata;
fmt->c->T->nonil = 0;
} else
adt = fmt->frstr(fmt, fmt->adt, s);
if (adt == NULL) {
- lng row = task->cnt + idx+1;
+ lng row = task->cnt + idx + 1;
snprintf(buf, BUFSIZ, "'%s' expected", fmt->type);
- err = SQLload_error(task,idx);
- if( task->rowerror){
+ err = SQLload_error(task, idx);
+ if (task->rowerror) {
MT_lock_set(&errorlock, "insert_val");
col++;
BUNappend(task->cntxt->error_row, &row, FALSE);
BUNappend(task->cntxt->error_fld, &col, FALSE);
BUNappend(task->cntxt->error_msg, buf, FALSE);
BUNappend(task->cntxt->error_input, err, FALSE);
- snprintf(buf, BUFSIZ, "line "LLFMT" field %d '%s'
expected in '%s'",row, col, fmt->type, s);
+ snprintf(buf, BUFSIZ, "line " LLFMT " field %d '%s'
expected in '%s'", row, col, fmt->type, s);
if (task->as->error == NULL && (task->as->error =
GDKstrdup(buf)) == NULL)
task->as->error = M5OutOfMemory;
task->rowerror[idx]++;
task->errorcnt++;
MT_lock_unset(&errorlock, "insert_val");
}
- ret = -1 * (task->besteffort ==0);
+ ret = -1 * (task->besteffort == 0);
GDKfree(err);
/* replace it with a nil */
adt = fmt->nildata;
@@ -813,16 +819,16 @@ SQLinsert_val(READERtask *task, int col,
bunfastins(fmt->c, key, adt);
return ret;
bunins_failed:
- if( task->rowerror){
+ if (task->rowerror) {
lng row = BATcount(fmt->c);
MT_lock_set(&errorlock, "insert_val");
BUNappend(task->cntxt->error_row, &row, FALSE);
BUNappend(task->cntxt->error_fld, &col, FALSE);
BUNappend(task->cntxt->error_msg, "insert failed", FALSE);
- err = SQLload_error(task,idx);
+ err = SQLload_error(task, idx);
BUNappend(task->cntxt->error_input, err, FALSE);
GDKfree(err);
- task->rowerror[row -1]++;
+ task->rowerror[row - 1]++;
task->errorcnt++;
MT_lock_unset(&errorlock, "insert_val");
}
@@ -839,16 +845,16 @@ SQLworker_column(READERtask *task, int c
MT_lock_set(&mal_copyLock, "tablet insert value");
if (!fmt[col].skip && BATcapacity(fmt[col].c) < BATcount(fmt[col].c) +
task->next) {
if (BATextend(fmt[col].c, BATgrows(fmt[col].c) + task->limit)
== GDK_FAIL) {
- tablet_error(task, lng_nil, col, "Failed to extend the
BAT, perhaps disk full\n","SQLworker_column");
+ tablet_error(task, lng_nil, col, "Failed to extend the
BAT, perhaps disk full\n", "SQLworker_column");
MT_lock_unset(&mal_copyLock, "tablet insert value");
return -1;
}
}
MT_lock_unset(&mal_copyLock, "tablet insert value");
- for (i = 0; i < task->top[task->cur]; i++){
- if( !fmt[col].skip && SQLinsert_val(task, col, i) < 0)
- return -1;
+ for (i = 0; i < task->top[task->cur]; i++) {
+ if (!fmt[col].skip && SQLinsert_val(task, col, i) < 0)
+ return -1;
}
return 0;
@@ -867,10 +873,10 @@ SQLload_parse_line(READERtask *task, int
BUN i;
char errmsg[BUFSIZ];
char ch = *task->csep;
- char *line = task->lines[task->cur][idx];
+ char *line = task->lines[task->cur][idx];
Tablet *as = task->as;
Column *fmt = as->format;
- int error =0, skip;
+ int error = 0, skip;
str errline = 0;
#ifdef _DEBUG_TABLET_
@@ -880,33 +886,34 @@ SQLload_parse_line(READERtask *task, int
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list