C programming help required ....

Roger Oberholtzer roger
Fri Aug 26 02:10:06 PDT 2005


On Fri, 2005-08-26 at 03:49, Ben Duncan wrote:
> 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:


These are very easy in C. 

Can you be more clear about what 7001 means? Is all of that number only
indicating attribute 7? Or only part of it? What all should be stored in
the 32 bits? How many attributes are to be supported in this integer?


> 
> 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 ...
+????????????????????????????+???????????????????????????????+
? Roger Oberholtzer          ?   E-mail: roger at opq.se        ?
? OPQ Systems AB             ?      WWW: http://www.opq.se/  ?
? Kapellgr?nd 7              ?                               ?
? P. O. Box 4205             ?    Phone: Int + 46 8   314223 ?
? 102 65 Stockholm           ?   Mobile: Int + 46 733 621657 ?
? Sweden                     ?      Fax: Int + 46 8   314223 ?
+????????????????????????????+???????????????????????????????+



More information about the Linux-users mailing list