Skip to content

Commit

Permalink
Fixes #90: Hold DSS_HUGE's (i.e. 64-bit values) as plain variables,…
Browse files Browse the repository at this point in the history
… not pointers to possible arrays of smaller types - as we don't ever need this complication for holding 64-bit values
  • Loading branch information
eyalroz committed Jan 3, 2025
1 parent cf92412 commit 181abe9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 33 deletions.
16 changes: 8 additions & 8 deletions src/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,24 @@ mk_cust(long n_cust, customer_t *c)
* generate the numbered order and its associated lineitems
*/
void
mk_sparse (long i, DSS_HUGE *ok, long seq)
mk_sparse (long i, DSS_HUGE ok, long seq)
{
ez_sparse(i, ok, seq);
return;
}

void
ez_sparse(long i, DSS_HUGE *ok, long seq)
ez_sparse(long i, DSS_HUGE ok, long seq)
{
long low_bits;

LONG2HUGE(i, ok);
low_bits = (long)(i & ((1 << SPARSE_KEEP) - 1));
*ok = *ok >> SPARSE_KEEP;
*ok = *ok << SPARSE_BITS;
*ok += seq;
*ok = *ok << SPARSE_KEEP;
*ok += low_bits;
ok = ok >> SPARSE_KEEP;
ok = ok << SPARSE_BITS;
ok += seq;
ok = ok << SPARSE_KEEP;
ok += low_bits;


return;
Expand Down Expand Up @@ -199,7 +199,7 @@ mk_order(long index, order_t *o, long upd_num)
for (lcnt = 0; lcnt < o->lines; lcnt++)
{

HUGE_SET(o->okey, o->lineorders[lcnt].okey);
o->okey = o->lineorders[lcnt].okey;
o->lineorders[lcnt].linenumber = lcnt + 1;
o->lineorders[lcnt].custkey = o->custkey;
RANDOM(o->lineorders[lcnt].partkey, L_PKEY_MIN, L_PKEY_MAX, L_PKEY_SD);
Expand Down
13 changes: 0 additions & 13 deletions src/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ gen_tbl (int tnum, DSS_HUGE start, DSS_HUGE count, long upd_num)
code_t code;
#endif
static int completed = 0;
static int init = 0;
DSS_HUGE i;

int rows_per_segment=0;
Expand All @@ -426,18 +425,6 @@ gen_tbl (int tnum, DSS_HUGE start, DSS_HUGE count, long upd_num)
residual_rows = count - (rows_per_segment * insert_segments);
}

if (init == 0)
{
INIT_HUGE(o.okey);
for (i=0; i < O_LCNT_MAX; i++)
#ifdef SSB
INIT_HUGE(o.lineorders[i].okey);
#else
INIT_HUGE(o.l[i].okey);
#endif
init = 1;
}

for (i = start; count; count--, i++)
{
LIFENOISE (1000, i);
Expand Down
11 changes: 3 additions & 8 deletions src/dss.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,7 @@ extern tdef tdefs[];
* beyond this point we need to allow for BCD calculations
*/
#define MAX_32B_SCALE 1000.0
#define INIT_HUGE(v) { \
v = (DSS_HUGE *)malloc(sizeof(DSS_HUGE)); \
MALLOC_CHECK(v); \
}
#define FREE_HUGE(v) free(v)
#define LONG2HUGE(src, dst) *dst = (DSS_HUGE)src
#define LONG2HUGE(src, dst) dst = (DSS_HUGE)src
#define HUGE2LONG(src, dst) *dst = (long)src
#define HUGE_SET(src, dst) *dst = *src
#define HUGE_MUL(op1, op2) *op1 *= op2
Expand Down Expand Up @@ -492,7 +487,7 @@ int dbg_print(int dt, FILE *tgt, void *data, int len, int eol);
#define PR_VSTR(f, str, len) dbg_print(DT_VSTR, f, (void *)str, len, 1)
#define PR_VSTR_LAST(f, str, len) dbg_print(DT_VSTR, f, (void *)str, len, 0)
#define PR_INT(f, val) { long tmp = val; dbg_print(DT_INT, f, &tmp, 0, 1); }
#define PR_HUGE(f, val) dbg_print(DT_HUGE, f, (void *)val, 0, 1)
#define PR_HUGE(f, val) dbg_print(DT_HUGE, f, &val, 0, 1)
#define PR_KEY(f, val) { long tmp = val; dbg_print(DT_KEY, f, &tmp, 0, -1); }
#define PR_MONEY(f, val) { long tmp = val; dbg_print(DT_MONEY, f, &tmp, 0, 1); }
#define PR_CHR(f, val) { char tmp = val; dbg_print(DT_CHR, f, &tmp, 0, 1); }
Expand Down Expand Up @@ -530,7 +525,7 @@ int dbg_print(int dt, FILE *tgt, void *data, int len, int eol);
*/
#define VRF_STR(t, d) {char *xx = d; while (*xx) tdefs[t].vtotal += *xx++;}
#define VRF_INT(t,d) tdefs[t].vtotal += d
#define VRF_HUGE(t,d) tdefs[t].vtotal += *d
#define VRF_HUGE(t,d) tdefs[t].vtotal += d
/* assume float is a 64 bit quantity */
#define VRF_MONEY(t,d) tdefs[t].vtotal = *((long *)&d) + *((long *)(&d + 1))
#define VRF_CHR(t,d) tdefs[t].vtotal += d
Expand Down
6 changes: 3 additions & 3 deletions src/dsstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int ld_cust PROTO((customer_t * c, int mode));

typedef struct
{
DSS_HUGE *okey; /*for clustering line items*/
DSS_HUGE okey; /*for clustering line items*/
int linenumber; /*integer, constrain to max of 7*/
long custkey;
long partkey;
Expand Down Expand Up @@ -94,7 +94,7 @@ typedef struct
#ifdef SSB
typedef struct
{
DSS_HUGE *okey;
DSS_HUGE okey;
long custkey;
int totalprice;
char odate[DATE_LEN];
Expand Down Expand Up @@ -126,7 +126,7 @@ typedef struct
long mk_order PROTO((long index, order_t * o, long upd_num));
int pr_order PROTO((order_t * o, int mode));
int ld_order PROTO((order_t * o, int mode));
void ez_sparse PROTO((long index, DSS_HUGE *ok, long seq));
void ez_sparse PROTO((long index, DSS_HUGE ok, long seq));

#ifdef SSB
/*SSB removes the part supplier table*/
Expand Down
2 changes: 1 addition & 1 deletion src/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ dbg_print(int format, FILE *target, void *data, int len, int sep)
fprintf(target, "%ld", *(long *)data);
break;
case DT_HUGE:
fprintf(target, HUGE_FORMAT, *(DSS_HUGE *)data);
fprintf(target, HUGE_FORMAT, *(DSS_HUGE*)data);
break;
case DT_KEY:
fprintf(target, "%ld", *(long *)data);
Expand Down

0 comments on commit 181abe9

Please sign in to comment.