Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread Doug Currie
Thursday, March 31, 2005, 5:53:12 PM, you wrote: >> The actual test I'm doing is something like: >> WHERE ?1 >= (base + begin) AND ?1 < (base + end) >> where ?1, base, begin, and end are all 64-bit addresses. > This is a test with a well known optimization for unsigned values: > WHER

Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread Doug Currie
> The actual test I'm doing is something like: > WHERE ?1 >= (base + begin) AND ?1 < (base + end) > where ?1, base, begin, and end are all 64-bit addresses. This is a test with a well known optimization for unsigned values: WHERE (?1 - base - begin) < end To make the < test unsigned i

Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread Jan-Eric Duden
How about storing the 64 bit integers as binaries and write user functions (using sqlite3_create_function ) to do the computation and comparison? William Hachfeld wrote: On Thu, Mar 31, 2005 at 01:52:53PM -0800, Ted Unangst wrote: Store the length of the region, instead of the end. Or is that

Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread William Hachfeld
Thanks for the suggestions everyone! Using Base16, Base64, or even simple decimal-as-text would all be a possibility. But each requires more than eight bytes of storage. With tens to hundreds of thousands of addresses being stored, I just don't want to accept the larger file size. Each of these a

Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread William Hachfeld
On Thu, Mar 31, 2005 at 01:52:53PM -0800, Ted Unangst wrote: > Store the length of the region, instead of the end. Or is that impossible? > I'm not sure what physical property (begin + end) could refer to. Sorry Ted, the example I gave was misleading. It was meant purely as an illustration. The a

Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread Ted Unangst
William Hachfeld wrote: Heh Everyone, Have a question regarding storage of 64-bit unsigned values in SQLite... I'm working on a project where I want to store 64-bit addresses (unsigned values) as a column in an SQLite database. Currently I create the table using signed integers. For example: CREATE

Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread Doug Currie
> Before binding an address to a statement using sqlite3_bind_int64() I apply an > offset to the address to translate it to a signed value. And when reading out > an address using sqlite3_column_int64() I reverse the process. I.e. > dbase_value = addr_value - offset > addr_value = dbase_va

Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread D. Richard Hipp
On Thu, 2005-03-31 at 13:59 -0600, William Hachfeld wrote: > Does anyone have an idea how I can store a 64-bit unsigned integer > in an SQLite column and still perform useful arithmetic and conditional > operators on them? If you can restrict yourself to comparison operations, then you could sto

Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread Alex Chudnovsky
William Hachfeld wrote: On Thu, Mar 31, 2005 at 12:07:22PM -0800, Jay wrote: I suppose I could convert the unsigned address into a string. But UINT64_MAX (2^64 - 1) is: 18,446,744,073,709,551,615 which, without the commas, would require 20 bytes to store. Quite a bit more than the 8 bytes

Re: [sqlite] Storing 64-Bit Addresses

2005-03-31 Thread William Hachfeld
On Thu, Mar 31, 2005 at 12:07:22PM -0800, Jay wrote: > I thought sqlite stored the columns as text internally and converted when > appropriate. It should therefore be able to handle 64 bit numbers without > problem. Not according to the "Datatypes" document for version 3: http://www.sqlite.o

[sqlite] Storing 64-Bit Addresses

2005-03-31 Thread William Hachfeld
Heh Everyone, Have a question regarding storage of 64-bit unsigned values in SQLite... I'm working on a project where I want to store 64-bit addresses (unsigned values) as a column in an SQLite database. Currently I create the table using signed integers. For example: CREATE TABLE Example (