Re: Generic Collection



On May 8, 4:00 pm, Georg Bauhaus <rm.tsoh+bauh...@xxxxxxxxxxxxxxxxxx>
wrote:
On Tue, 2007-05-08 at 12:29 -0700, andrew wrote:
I cannot say for sure if the "is a" relations aren't entirely
artificial. It seems to me it would work either way. The difference
for me is that I cannot visualize the composition you mentioned.

As you noted, I meant that "a tuple is a collection of attributes"
doesn't necessarily imply inheritance relationship; TUPLE doesn't have
to inherit from a type COLLECTION_OF_ATTRIBUTES.

I think there are various possibilities; RDB2 (below RDB) shows
types that have components of other types (that is, are composed :-)
but are otherwise unrelated.
Package RDB desclares "is a" relations in the sense you describe
by making the DB types be "a collection of" objects of "smaller"
types.

So what you are saying is that the type Item in my example is the
parameter you are talking about?

Erh, I guess so.

with Ada.Containers.Hashed_Sets;
with Data;

package RDB is

use Ada;

type DP is access Data.T'class;
function compare(a, b: DP) return BOOLEAN;
function hash(element: DP) return Containers.HASH_TYPE;

subtype ATTRIBUTE is DP;

package Attributes is new Containers.Hashed_Sets
(ELEMENT_TYPE => ATTRIBUTE,
hash => hash,
equivalent_elements => compare);

subtype TUPLE is Attributes.SET;
function hash(element: TUPLE) return Containers.HASH_TYPE;

package Tuples is new Containers.Hashed_Sets
(ELEMENT_TYPE => TUPLE,
hash => hash,
equivalent_elements => Attributes."=",
"=" => Attributes."=");

subtype TABLE is Tuples.SET;
function hash(element: TABLE) return Containers.HASH_TYPE;

package Tables is new Containers.Hashed_Sets
(ELEMENT_TYPE => TABLE,
Hash => hash,
equivalent_elements => Tuples."=",
"=" => Tuples."=");

-- ...

end RDB;

with Ada.Containers.Hashed_Sets;
with Data;

package RDB2 is

use Ada;

type DP is access Data.T'class;
function compare(a, b: DP) return BOOLEAN;
function hash(element: DP) return Containers.HASH_TYPE;

subtype ATTRIBUTE is DP;

package Attributes is new Containers.Hashed_Sets
(ELEMENT_TYPE => ATTRIBUTE,
hash => hash,
equivalent_elements => compare);

type TUPLE is
record
-- ...
columns: Attributes.SET;
end record;
function compare(a, b: TUPLE) return BOOLEAN;
function hash(element: TUPLE) return Containers.HASH_TYPE;

package Tuples is new Containers.Hashed_Sets
(ELEMENT_TYPE => TUPLE,
hash => hash,
equivalent_elements => compare);

type TABLE is
record
-- ...
rows: Tuples.SET;
end record;
function compare(a, b: TABLE) return BOOLEAN;
function hash(element: TABLE) return Containers.HASH_TYPE;

package Tables is new Containers.Hashed_Sets
(ELEMENT_TYPE => TABLE,
Hash => hash,
equivalent_elements => compare);

type SCHEMA is
record
-- ...
relations: Tables.SET;
end record;

end RDB2;

RDB2 looks good to me and is pretty close to what I had in mind.

I think I finally get what you were saying about inheritance. Before
I posted the topic I was thinking about the design and I just wrote
down the "table is a collection" as part of sentence. In my mind I
was thinking of a variable declaration:

table: collection;
tuple: collection;
schema: collection;

and so I posted my question.

.



Relevant Pages

  • Faild to udate Distribution Point
    ... ~The Package Action is 2 and the Update Mask is 268435456. ... TreeRecurser failed at FindFirstFile ... ~Starting to new hash ... ~Used 0 out of 3 allowed processing threads. ...
    (microsoft.public.sms.swdist)
  • Re: looking for some size optimization
    ... the filenames from +4000 packages in order to recognize conflicts. ... To take up the amount of room you ... it builds a big hash through a loop that constructs ... Is $pkgname the name of the package declared in $file, ...
    (comp.lang.perl.misc)
  • Re: Generic Collection
    ... Package RDB desclares "is a" relations in the sense you describe ... function comparereturn BOOLEAN; ... hash => hash, ... subtype TUPLE is Attributes.SET; ...
    (comp.lang.ada)
  • Re: Clients not updated with new MSSecure data...
    ... the existing package source. ... (The hash calculations on the downloaded file ... > Command line specified folder to update as ... Software Updates Scan ...
    (microsoft.public.sms.swdist)
  • Re: Packages and returning errors
    ... >>of instance data. ... >>sub rtnError { ... its a reference to a hash. ... functions in the package to see it. ...
    (comp.lang.perl.misc)