After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 172253 - [PATCH] Beagle should allow defining multi-valued properties/keywords.
[PATCH] Beagle should allow defining multi-valued properties/keywords.
Status: RESOLVED FIXED
Product: beagle
Classification: Other
Component: General
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Beagle Bugs
Beagle Bugs
Depends on:
Blocks: 304133
 
 
Reported: 2005-03-31 13:58 UTC by Veerapuram Varadhan
Modified: 2005-05-24 21:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to enable support for multi-valued properties. (47.02 KB, patch)
2005-03-31 14:00 UTC, Veerapuram Varadhan
none Details | Review
updated multi-valued-property patch (30.86 KB, patch)
2005-04-13 21:33 UTC, Veerapuram Varadhan
none Details | Review

Description Veerapuram Varadhan 2005-03-31 13:58:35 UTC
As of now, each property/keyword can hold only one value.  Beagle should provide
infrastructure to define multi-valued properties.
Comment 1 Veerapuram Varadhan 2005-03-31 14:00:07 UTC
Created attachment 39507 [details] [review]
Patch to enable support for multi-valued properties.
Comment 2 Joe Shaw 2005-04-08 18:35:19 UTC
Patch is shaping up.  Here are some comments:

* Throughout the code, there are still minor style issues, like spaces after
for, foreach, and if and before the open parenthesis.

* In Hit.cs, use ICollection everywhere instead of IList

* I know I said otherwise in an earlier review, but I am thinking now that
returning null from the Hit indexer might be better than the empty array.  A
large chunk of the patch is changing a ton of existing code from doing "if
(hit["Foo"] == null)" to "if (hit["Foo"].Count == 0)" for no real benefit.  It's
probably simpler to do null checks before foreach loops in the many fewer places
where that is used presently than changing all the null checks.  We can always
change it later if we have to, but I don't think we will.

* In both SetValue() functions if key is null or trims to "" we should probably
throw an exception rather than silently exiting.

* Also in SetValue(), there is no need to do properties.Contains(key).  Just do
the Remove(), it doesn't throw an exception if it isn't there.

* This is totally a nitpicky thing, but when dealing with a string "value" is a
good name, but when dealing with an ICollection I'd prefer if they were named
"values" for clarity.

* In ReplaceValue() you're doing a check that is essentially "if (this [key] ==
null)" but your implementation of the indexer never allows null to be returned.
 If you change the thing I suggested above that'll be fixed. :)  But as it is
now, it'll never work as long as it is previously unset.

* I don't like some of the naming.  I suggest renaming GetValuesAsString() as
GetValuesAsArray() and rely on the fact that they're always dealt with as
strings and that it returns string[] to get that idea across.

* Similarly, I'd rename GetValuesAsDelimitedString() to GetValuesAsString() and
have two versions: one in which you specify the delimiter and one which defaults
to a delimiter of ", ".  I guess this is sort of what
Beagle.Util.StringFu.GetValuesAsString() does?  This stuff seems kinda messy.

* Rename IsKeyContains() to just KeyContains().

* In Tiles/Template.cs, does it make sense to switch the Template over to using
ICollections instead of strings?

* I don't understand the use of Beagle.Util.StringFu.Escape() and UnEscape() in
Template.cs.  Why not just pass "," into UnEscape() and have it do the work of
whatever Escape() is doing?

* Almost everywhere I think you should probably use GetValuesAsDelimitedString()
instead of GetValuesAsString()[0].  Lets just try to get this as right the first
time so that we don't have to keep going back and cleaning up these things.  The
only thing that might give you trouble here are email addresses in the mail backend.

* You have a FIXME in TileContact.cs which says "a Hit cannot have two icons". 
I agree, but if you're going to enforce that I'd rather see it done with a
Debug.Assert() rather than just accessing the 0th element.  Maybe you could have
an overload of GetValuesAsDelimitedString() which enforces the number (or
maximum number) of elements allowed.

* I don't like the conversion from a char to a byte in StringFu.cs.  A char is
two bytes in .net and a byte is one, so you can overflow if you use a big enough
byte.  The conversion also uses single chars, which is kind of limiting. 
Normally you want a delimiter to be ", " and not just ','.  Or maybe you want it
to be "<br/>" for HTML.  So I think the escaping needs to be rethought here.

* Lose the static StringBuilder.

* I think SplitDelimitedString() will probably have null passed in very
infrequently.  It should probably either throw a ArgumentNullException or just
return "new string[0]".  Ie, lose the static emptyArray.

* Why is the code commented out in ExtractContent.cs?  Is that leftover from
something else?

* In GaimLogQueryable, it's probably good to enforce a single "fixme:file" element.

* The mail backend should be looked at, particularly because of the way it
parses email addresses.  That's the prime candidate to take advantage of the
multiple values per key thing right now.
Comment 3 Joe Shaw 2005-04-08 18:40:29 UTC
oops, some typos:

* Throughout the code, there are still minor style issues, like spaces after
for, foreach, and if and before the open parenthesis.

Of course I mean that you don't have these spaces and should add them.  Also
around mathematical operators (ie, "a + b" good, "a+b" bad)

And one other thing: I suggest renaming UnEscape() to Unescape().  Easier to
type and read, and is more consistent with other code, I think.
Comment 4 Veerapuram Varadhan 2005-04-11 10:09:02 UTC
"* Why is the code commented out in ExtractContent.cs?  Is that leftover from
something else?"

--- EEEEEK!! Sorry, actually was testing some .doc optimization.  Thanks for
your "(e)beagle-eyed" patch-review. ;-)
Comment 5 Veerapuram Varadhan 2005-04-11 11:57:48 UTC
"* In Tiles/Template.cs, does it make sense to switch the Template over to using
ICollections instead of strings?"

--  I just had a sneak-preview of the TilesXXX code that use Template[] stuff. 
In most cases we are just using Hit[] directly than Template[] stuff.  Moreover,
the indexer in Template is used to hold-beautified-or-other-forms-of-strings
only.  So, I feel its better to have strings than ICollection in Template.cs.

Joe: What do you say?
Comment 6 Veerapuram Varadhan 2005-04-11 12:11:38 UTC
Ok, more little thoughts...

If we use ICollection, we will have to update Tiles/templates-*.html accordingly.

And, we will have to provide all sort of conversion methods from ICollection to
String(s) just like Hit.cs, which is kind of replication, since, methods in
Hit.cs are directly accessible in Template class and also template class is
being used for just "presentation" purpose, I think its good to leave it as it
is to use strings.

If any one wants to have more control on the way multiple-values of a property
are rendered, he can directly use the indexer Hit[] and convert them the way he
wants and store it in the Template[] for rundering purposes.
Comment 7 Veerapuram Varadhan 2005-04-12 14:23:12 UTC
Hmm.. 

As we are providing GetValuesAsArray() that returns a string[], I think we can
avoid "Escaping" and "Unescaping" delimiter string in GetValuesAsString(), which
will be purely for "displaying" purpose and not for data manipulation.

Also, marking the current patch as obsolete.
Comment 8 Veerapuram Varadhan 2005-04-13 21:33:41 UTC
Created attachment 45230 [details] [review]
updated multi-valued-property patch
Comment 9 Jon Trowbridge 2005-05-24 21:58:50 UTC
This is now fixed in CVS.