C programming help required ....

Ben Duncan bns
Thu Aug 25 20:29:00 PDT 2005


Ok, I am working on my GDBM based multi value database engine for my SLAG project.
I will support a secondary key index file (like the old Xbase stuff).

In my record header I am declaring an array of 32 integers for up to 32 secondary
indices.

I want to store an integer that hashes to the attribute & sub value number.
Example:

A secondary index on attribute 3, sub value 2 would be an integer value of
003002. Another index might be attribute 7 subvalue 1 stored as 7001. The
MINIMUM integer would ALWAYS be 1001.

Is not there a way you can AND/OR/SHIFT or whatever that number rather than go
thru a convoluted math expression to split out the 2 parts?

ie:
where value in KEYLIST[5] = 7001:

int ATTRIBUTE, SUBVAL ;

SUBVAL = KEYLIST[5] (and'ed or "or"d or shifted ?!?!)
ATTRIBUTE = KEYLIST[5] (and'ed or "or"d or shifted ?!?!)

and now SUBVAL equals 1 and ATTRIBUTE equal 7 ...

As always, thanks ...


-- 
Ben Duncan   - VersAccounting Software LLC 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
        - Hanlon's Razor



More information about the Linux-users mailing list