Re: Are there any databases that can store multidiimensional boolean arrays?




"Robert Klemme" <bob.news@xxxxxxx> wrote in message
news:4gvg5bF1p9mdbU1@xxxxxxxxxxxxxxxxx
Rhino wrote:
I'm helping someone on another newsgroup but I need to know something.
This person wants to store a four dimensional boolean array, i.e.
boolean[][][][], in a column of a database. There are 53,000 entries in a
single occurrence of this array and they wan to store over 200,000
instances of the array, one in each row of the table.

Ideally, that array could be stored as an Object of type boolean[][][][]:
then the user wouldn't have to turn it into something else for storage
and then convert it back when reading it. Are there any databases that
can do that? Or would I inevitably have to convert this array into a
simpler object like a String to store it? For example, it wouldn't be
hard to convert this boolean array:

boolean[] myArray = {true, false, true};

to a String like this:

String myString = "TFT"; //T=true; F=false

Unlikely to work good with your 53,000 entries. Usually VARCHAR columns
have a size restriction far below this margin.

No problem. I'd just use a CLOB then.

I know that JDBC has setObject() and getObject() methods but I'm really
not clear on how they are used, even after reading the API. It appears
that I still have to identify the object as one of the standard
java.sql.Type values and boolean[][][][] is NOT a standard java.sql.Type!

Can anyone shed some light on this for me?

If you don't need these booleans for querying (i.e. as selection criteria)
the simplest solution is probably to serialize these arrays into a BLOB
column. You could also convert them to a BitSet before insertion.

I'd never noticed the BitSet class before in several years of coding Java
but I just took a look at it in the API. Is there any particular reason why
it is better than just turning a boolean array into a String of T's and F's.
I assume it uses less space since bits are smaller than Strings but wouldn't
it get a bit cumbersome to have to have a Bitset within a Bitset within a
Bitset within a Bitset just to represent this array?

If you need to use boolean values from the array as select criteria it
gets more complicated. One thing you *could* do is to have a table with
idx_1, idx_2, idx_2, bool, i.e. store the indexes in the table. But this
will burn a lot of mem.

As I said, I'm helping someone else and I don't know if they want to use
these booleans as search criteria or not.

Just my 0.02EUR...

Okay, thanks for your input!

--
Rhino


.



Relevant Pages

  • Re: using BLOB objects and ...
    ... while saving the array object to the database which is ok but while ... convert it back to object of 4 dimention boolean array which will be ... will let you store your 4 dimensional boolean array in it. ... You may have to modify my suggestion ...
    (comp.lang.java.programmer)
  • Re: using BLOB objects and ...
    ... - You could use Memo if you converted your boolean array into a text string. ... boolean array when you fetch it from the database. ... You might be able to put the whole array in an OLE Object, ...
    (comp.lang.java.programmer)
  • Re: Are there any databases that can store multidiimensional boolean arrays?
    ... single occurrence of this array and they wan to store over 200,000 instances of the array, one in each row of the table. ... it wouldn't be hard to convert this boolean array: ... If you don't need these booleans for querying (i.e. as selection criteria) the simplest solution is probably to serialize these arrays into a BLOB column. ...
    (comp.lang.java.databases)
  • Are there any databases that can store multidiimensional boolean arrays?
    ... person wants to store a four dimensional boolean array, ... like a String to store it? ...
    (comp.lang.java.databases)
  • Re: This Formula does not work....
    ... You have to know the subtleties in how SUM works. ... boolean array. ... generates an array, you would have to use an array formula to get SUM ... >>> formula below but no joy. ...
    (microsoft.public.excel.misc)