Hi,
In the manual Programming Guide for GemStone/S 64 Bit explain how to create index and in the mail list there's a lot information. But i can not find if it possible what i want. The class FormInstance is where all rows from a DB are mapped to this GS class. There are a lot of different kinds of forms, so FormInstance has a variable named <fields> which is a dictionary holding the pair (fieldName, value). So different instance of FormInstance has different set of keys depending the form they are representing. For example a sub set of instances of FormInstance will have (name surname phone fields) as keys in <fields> inst var. How to create an index over a dictionary that represent inst vars (fields of the form) ? Or i should subclass (dynamically) each kind of form and then add the index to these subclasses ? Regards, Bruno |
On 12/09/2013 04:36 PM, BrunoBB wrote:
> Hi, > > In the manual Programming Guide for GemStone/S 64 Bit explain how to create > index and in the mail list there's a lot information. > > But i can not find if it possible what i want. > > The class FormInstance is where all rows from a DB are mapped to this GS > class. > There are a lot of different kinds of forms, so FormInstance has a variable > named <fields> which is a dictionary holding the pair (fieldName, value). > > So different instance of FormInstance has different set of keys depending > the form they are representing. > > For example a sub set of instances of FormInstance will have (name surname > phone fields) as keys in <fields> inst var. Bruno, What kind of criteria will you be using in queries on this collection? Regards, -Martin _______________________________________________ Glass mailing list [hidden email] http://lists.gemtalksystems.com/mailman/listinfo/glass |
Hi,
A subset of instances of FormInstance could have keys named 'name' and 'surname'. So for that particular subset i wanna create a index by 'name' and 'surname'. Where name and surname are keys in the Dictonary <fields> of the class FormInstance. (name and surname only exists for these particular instances) For another particular subset i wanna create a index by 'form_number'. Where 'form_number' is a keys in <fields> Dictionary of FormInstance. The criteria it will be the values of the some keys in <fields> Dictionary of FormInstance. Do you understand what i mean ? Regards, Bruno |
On 12/09/2013 04:56 PM, BrunoBB wrote:
> Hi, > > A subset of instances of FormInstance could have keys named 'name' and > 'surname'. > > So for that particular subset i wanna create a index by 'name' and > 'surname'. Where name and surname are keys in the Dictonary <fields> of the > class FormInstance. (name and surname only exists for these particular > instances) > > For another particular subset i wanna create a index by 'form_number'. Where > 'form_number' is a keys in <fields> Dictionary of FormInstance. > > The criteria it will be the values of the some keys in <fields> Dictionary > of FormInstance. > > Do you understand what i mean ? Perhaps. So when you have a query like name = 'abc' surname = 'def' then you want the result set to contain only FormInstances that have those fields? And when you query by form_number you want to get only those instances? If that's right, I would think you would put the name-and-surname ones in one collection, and the form_number ones in a different collection. If you need to have all instances of FormInstance in the same collection for some reason, you can have that collection as well. Regards, -Martin _______________________________________________ Glass mailing list [hidden email] http://lists.gemtalksystems.com/mailman/listinfo/glass |
Hi Martin,
>> then you want the result set to contain only FormInstances that have those fields? Yes. >>And when you query by form_number you want to get only those instances? Yes. >>If that's right, I would think you would put the name-and-surname ones in one collection, and the form_number ones in a different collection. These instance are already in different collection. A FormDefinition hold the instances (FormInstance) of a particular subset of keys. For each type of form you have an instance of FormDefinition then the actual instances of the form (FormInstance) are hold by it's form definition. The question is how to add an index to these subset. Index by the key of the dictionary. thanks Regards, Bruno |
On 12/09/2013 05:31 PM, BrunoBB wrote:
> These instance are already in different collection. A FormDefinition hold > the instances (FormInstance) of a particular subset of keys. For each type > of form you have an instance of FormDefinition then the actual instances of > the form (FormInstance) are hold by it's form definition. > > The question is how to add an index to these subset. Index by the key of the > dictionary. Hi Bruno, OK, I'm getting a clearer image. :-) So you have a FormDefinition, which contains a collection of FormInstances, each of which should have known fields in its <fields> instvar. And you want to query by the values of one (or more) of those fields. I don't think it's possible to do that directly with traditional GemStone indexing, though we've talked about adding this kind of capability, and there will be some new abilities in 3.2. But there are indirect ways of doing this, by making the FormDefinition do some of the indexing work. There are a number of ways to do this. Examples: If you don't need inequality comparisons in queries ('form_number' < 9999), only equality ('form_number' = 4321), you could store the FormInstances as values in a KeyValueDictionary whose key is the field being indexed. If you do need inequality comparisons, you could add an <indexValue> instvar to FormInstance and have the FormDefinition set that instvar from the fields as the FormInstance is being added to the FormDefinition's collection. That collection would be indexed on the <indexValue> instvar. Regards, -Martin _______________________________________________ Glass mailing list [hidden email] http://lists.gemtalksystems.com/mailman/listinfo/glass |
Hi Martin,
Thanks for the fast answer. >>there will be some new abilities in 3.2 Very good, i will read about it in the release notes of 3.2. Your solution it seem to be good to me. The FormInstance can have a couple of slots to hold indexes. But the values of these slots (inst vars) depend on the type of the form (FormDefinition). For Exmaple: FormInstance inst var (stringIndexValue integerIndexValue dateIndexValue and so on). For each instance of FormInstance stringIndexValue it will hold a value. This value (stringIndexValue) for some FormInstance it will be the key 'name' for others it will be other key 'form_code'. But since these collection are already separated it will be no performance problem (i think) creating the index. Thanks very much Martin ! Regards, Bruno |
Administrator
|
In reply to this post by BrunoBB
Bruno,
Marten has provided you with some very good answers. However, there is also the possibility that a small change in the model might also provide you with what you seek. This is based on the "scent" of a Dictionary with primitive key and value types. Not a "smell", per se, but definitely something to be aware of. I have found such dictionaries often reflect under modelling. For example, if you had form field objects, comprising a field name, a field value, and a back reference to the form which holds these fields, you could have a single collection of form field objects for all your forms. This could easily be indexed and queried. Richard |
Hi Richard,
Let say i create the class FormFieldValue (name,value). name a string and value a string/integer/date/time (a basic value) Now FormInstance has collection of FormFieldValue. If two forms has the same subset of names then they are the same type of form. We have a back reference to the form which holds these fields, [xmlString] holds a XML that represent the form. The only way i see to create an index on values is to have a collection of these FormFieldValue that represent all forms of this type and then create the index over this collection. collectionOfFormFieldValues createEqualityIndexOn: 'name'. "all forms of type 1" collectionOfFormFieldValues createEqualityIndexOn: 'form_code'. "all forms of type 2" and so on... Is this your suggestion ? Thanks very much... Do you see any problem in holding an XML string representing the form inside GemStone ? or it will be better to write down the xmlString to disk ? Regards, Bruno |
Administrator
|
Bruno,
This image shows a subset of what I was trying to describe. You might have a hierarchy of form field classes, with each subclass providing a different class of the value property. In that case, you would probably have a separate collection for each class of form field value (String, Date, Integer, ...). This shows that each Form Instance has XML for its layout, a name, and some number of Form Field Values. Each Form Field Value has a name, a value, and a back pointer to the Form Instance. The indexes facilitate querying for forms with certain fields and values, and possibly even restricting by form name. Does that look like what you need? |
Richard,
>> Does that look like what you need? This Exactly what i need. This solve the problem !!! I will go this way. Because the number of form can be big and this way of indexing can do the job. One last question: IndexableFormFieldsCollection is a subclass of UnorderedCollection ? right ? Thanks very much ! Regards, Bruno |
Administrator
|
Excellent! It isn't meant to be a class you need to create. Rather, it is the concept of a named collection that you can hold. But, you would use one of the UnorderedCollection subclasses, such as IdentitySet, for example. |
Free forum by Nabble | Edit this page |