[Q] Any simple magma example for text/tags combination?

Miguel Enrique Cobá Martinez miguel.coba at gmail.com
Tue Jan 19 02:07:07 UTC 2010


El mar, 19-01-2010 a las 11:01 +0900, Sungjin Chun escribió:
> Thank you for your kind reply.
> 
> Does this code scale well to tons of items, eg., 100,000? it seems
> that it has to enumerate all the items to find with the specificied
> tag.

Depends, if you use a dictionary for storing the tags then is fast. It
uses a has to find the key and then you get the list that contains every
item that has the given tag. This list then, can have thousands items.
But, hey, you have *every* item with that tag. You don't need a second
search. You already have them.

If you start by the item list, and do a select: or collect: testing for
a given tag match against the tags list (I refer to the first class I
mentioned) then yes, is slow, but you are scanning all the items list.

And, in the end, you can test it. Make the classes, store in them a few
millions of items and measure the time it takes to find a given test.

BTW, magma has a index feature that you can also use.

Cheers


> 
> Are there any index like facility in magma for this?
> 
> Thank you again.
> 
> 2010/1/19 Miguel Enrique Cobá Martinez <miguel.coba at gmail.com>:
> > El lun, 18-01-2010 a las 17:19 +0900, Sungjin Chun escribió:
> >> Hi,
> >>
> >> I'd like to test magma with following data;
> >>
> >> 1. it contains text (string) as main data
> >> 2. it contains title (string)
> >> 3. it contains tags (a tag is string)
> >>
> >> I like to acess/order the data by title and want to access data by
> >> specifying a tag.
> >
> > Very easy, make a class, with three inst vars: title, text, tags.
> > Store the title, the text and your required tags in them. Tags can be a
> > comma-separated string or a collection of strings, each representing a
> > tag. As you wish.
> >
> > Then in other class, maybe called Storage, or DB or whatever add two
> > inst vars: items, tags. items will hold objects of the previous class,
> > is your list of objects.
> > The tags can be:
> >
> > - just a list of tags, that enumerates all the tags existing in your app
> > and that can be used to form a tag-cloud and then the selected tag
> > searched. Really "collect:"-ed form the items list:
> >  items collect: [ :each | each tags includes: 'your-tag']
> >
> > - a dictionary of lists where the key is  the tag and the value is a
> > list of elements of items that have the tag used as key:
> >
> >  'tag1' -> an OrderedCollection( item1, item15)
> >  'tag2' -> an OrderedCollection( item5, item15)
> >
> > supposing that item1 has tag1 and item15 has tags: tag1 and tag2.
> >
> > Of course your code must be handling the adding and removing of tags and
> > updating the appropriate elements in order to be consistent.
> >
> >
> > Or some variation of that.
> >
> > Of course this works with or without magma, as magma is only a storage
> > of object and supports cyclic references as this solutions uses.
> >
> > Cheers
> >
> >
> >>
> >> Sorry for poor description and thanks in advance.
> >> _______________________________________________
> >> Magma mailing list
> >> Magma at lists.squeakfoundation.org
> >> http://lists.squeakfoundation.org/mailman/listinfo/magma
> >
> > --
> > Miguel Cobá
> > http://miguel.leugim.com.mx
> >
> >
> >

-- 
Miguel Cobá
http://miguel.leugim.com.mx



More information about the Magma mailing list