Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Places query system API

2 views
Skip to first unread message

Brett Wilson

unread,
Feb 28, 2006, 4:37:12 PM2/28/06
to
Hi everybody,

One of the things that still needs to be finalized for FF2 is the
parameters for querying the history system. I'm interested in what
parameters people think would be most useful so that I can make the
query system accomodate them.

You can see the current query object here:
http://lxr.mozilla.org/seamonkey/source/browser/components/places/public/nsINavHistoryService.idl#602

You can also specify some options (see nsINavHistoryQueryOptions in the
same file) which allows you to specify some more parameters.

To review, the overall structure of a query is that you pass in an array
of these query objects. Everything inside one query object is ANDed
together, and then each query object is ORed. This will likely not
change, as this is able to cover most cases (I vaguely remember some
theorem that states any boolean expression can be expanded this way as
long as you have a NOT operator).

The major things missing is the ability to specify visit counts, express
NOT operations, express < or > operations.

There was some talk about implementing the query as a property bag, with
some parsing rules for names, but from an API perspective I don't like
this. I was thinking something like:

SetQueryParameter(parameter, operator, value);

and then having constants in the query object defining each type of
parameter and operator we would have. Thus, you would say

query.SetQueryParameterStr(query.PARAMETER_HOST, query.OP_EQUALS,
"mozilla.org");
query.SetQueryParameterInt(query.PARAMETER_VISITCOUNT, query.OP_LESS,
5);

For all pages from host mozilla.org visited less than 5 times.

Then we would delete all the properties on the query object. You would
only be able to set each parameter once per query object, and subsequent
sets would overwrite the old ones. Not all parameters would support all
operators.

We would have to change the serialization of place: URIs (queries). Most
things could be kept the same, except for the things currently
accessible by flags (like "uriIsPrefix" would go away and we'd get a
separate URI_PREFIX parameter that would be mutually exclusive to the
URI parameter). This will not affect most things.

Are there important query cases that this can't handle? Are there any
special queries that you're particularly interested in writing a smart
query folder for?

Brett

Axel Hecht

unread,
Feb 28, 2006, 5:17:46 PM2/28/06
to
Brett,

what's the difference between
(foo.hasDomain) and (foo.domain != null)
?

Same for the other string properties.

Should the code be able to match http://www.bar.com/foo/baz.gif? Thus
having domainIsHost == false and uriIsPrefix == true?

Axel

Brett Wilson

unread,
Feb 28, 2006, 5:32:49 PM2/28/06
to

The point is that this old API will go away, so don't worry about it too
much. hasDomain just checks if the fomain is empty. Some of the other
items have more complex existance rules, they all have one for
consistency. uriIsPrefix does not matter in your example, since you
didn't specify a URI. URI is different than domain.

Ben Goodger

unread,
Feb 28, 2006, 9:30:32 PM2/28/06
to Brett Wilson
Brett Wilson wrote:
> Hi everybody,
>
> One of the things that still needs to be finalized for FF2 is the
> parameters for querying the history system. I'm interested in what
> parameters people think would be most useful so that I can make the
> query system accomodate them.

This might be a good "call for comment" thing to broadcast on MDN, too.

-Ben

Boris Zbarsky

unread,
Feb 28, 2006, 11:06:51 PM2/28/06
to
What does "uriIsPrefix" actually mean? Is "javascript:x" a prefix of
"javascript:xhtml" for example? Is "http://web.mit.edu/b" a prefix of
"http://web.mit.edu/bzbarsky"?

-Boris

Mike Beltzner

unread,
Mar 1, 2006, 3:55:01 AM3/1/06
to d...@mozilla.com
Ben Goodger wrote:
> This might be a good "call for comment" thing to broadcast on MDN, too.

Good idea, Ben. BTW, d o we have a reference page in place for Places on
MDC yet? If not, we should create one and make sure that final
documentation is placed there as we move forward.

cheers,
mike

--
mike beltzner, user experience lead, mozilla corporation

Brett Wilson

unread,
Mar 1, 2006, 11:49:39 AM3/1/06
to

Yes and yes.

Ben Goodger

unread,
Mar 1, 2006, 3:29:23 PM3/1/06
to Mike Beltzner, d...@mozilla.com
Mike Beltzner wrote:
> Ben Goodger wrote:
>> This might be a good "call for comment" thing to broadcast on MDN, too.
>
> Good idea, Ben. BTW, d o we have a reference page in place for Places
> on MDC yet? If not, we should create one and make sure that final
> documentation is placed there as we move forward.

I have created and stubbed out: http://developer.mozilla.org/en/docs/Places

-Ben

Boris Zbarsky

unread,
Mar 1, 2006, 6:58:45 PM3/1/06
to


Probably worth documenting that clearly; the examples made it look like prefix
was a "can be a base URI for" thing...

-Boris

Brett Wilson

unread,
Mar 1, 2006, 8:40:19 PM3/1/06
to
Boris Zbarsky wrote:
> Probably worth documenting that clearly; the examples made it look like
> prefix was a "can be a base URI for" thing...

The whole point of this thread is that this interface is getting redone.
I'll probably make two separate parameters called URI_PREFIX and
URI_MATCH or something. It just would not make sense to define them
both. I'll try to write good documentation for each parameter.

Brett

Axel Hecht

unread,
Mar 2, 2006, 8:24:32 AM3/2/06
to

I may have assumed too much of the context that i was reading right now.

The question I had was, can I query for:

subdomains of foo.com AND
path startswith "somedir/"

thus matching http://foo.com/somedir/hi and
http://www.foo.com/somedir/hello, but not matching http://www.foo.com/bar.

Axel

Brett Wilson

unread,
Mar 2, 2006, 11:30:04 AM3/2/06
to
> subdomains of foo.com AND
> path startswith "somedir/"
>
> thus matching http://foo.com/somedir/hi and
> http://www.foo.com/somedir/hello, but not matching http://www.foo.com/bar.

I see what you mean. No.

:) startsWith matches the whole beginning of the URL. This is efficient
because we have an index over the URL. We can also efficiently query for
hosts, so that query is efficient. With your query, we would have to
brute-force parse each URI, extract the path, and compare.

Just a note: there is some small possibility that I'll remove the
capability to efficiently match host names. Currently this is supported
by having an extra column in the database of host names written in
reverse with an index. However, it makes the file bigger (we store each
host name once in the URL and once separately), the extra index makes
inserts slower, and there's not out-of-the box uses of this query. If I
determine that the size/space this capability is using is not
insignificant, I will probably drop the host.

Brett

Axel Hecht

unread,
Mar 3, 2006, 3:47:57 AM3/3/06
to

Not sure how it fits the picture, but if you save host and path separately?

Axel

0 new messages