Re: [Virtuoso-users] Regex-based renaming of graphs

2011-05-29 Thread Ivan Mikhailov
Hello Alexandre,

On Thu, 2011-05-26 at 11:51 -0400, Alexandre Passant wrote:
> Hi,
> 
> Based on your two answers, I guess I have to run the following
> 
> UPDATE DB.DBA.RDF_QUAD 
> set g = iri_to_id(
>regexp_replace(id_to_iri(g), '/foo/', '/bar/')
> )
> where
>  g = iri_to_id(
>   regexp_match('/foo/', id_to_iri(g))
> );
>
> Right ?

You're right, except wrong "g = iri_to_id(" in WHERE, probably due to
copy+paste error.
That single update would be sufficient in the simplest case.
However it will be quite slow, because it will calculate WHERE condition
for every row and new G value for every matching row. It would be faster
if you could get list of graphs in some relatively fast way and then
update graph after graph.


> "For Virtuoso Graph Groups two tables need to be updated...[1]"

These updates are needed if renamed graphs can be members of graph
groups or if you want to rename graph groups as well as graphs.

In addition, you had to add new free-text rules for new graph names +
remove rules for old graph names, if there were per-graph rules at all.
And even if the whole storage is free-text indexed, not on per-graph
basis,
you should update free-text index, because the inverse index data of
each literal are enriched with list of graphs that contain this literal
in some quads, and renaming a graph make these data (partially)
obsolete.

Best Regards, 

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com


[1] http://ods.openlinksw.com/wiki/main/Main/VirtTipsAndTricksGuideRenameGraph





Re: [Virtuoso-users] Regex-based renaming of graphs

2011-05-26 Thread Alexandre Passant
Hi,

Based on your two answers, I guess I have to run the following

UPDATE DB.DBA.RDF_QUAD 
set g = iri_to_id(
   regexp_replace(id_to_iri(g), '/foo/', '/bar/')
)
where
 g = iri_to_id(
regexp_match('/foo/', id_to_iri(g))
);

Right ?

Yet, I'm not sure I understand the second part of [1]

"For Virtuoso Graph Groups two tables need to be updated: "

Do I have to run the previous query + the 2 ones in that part ? Or only the 
previous one ?

Thanks,

Alex.

[1] http://ods.openlinksw.com/wiki/main/Main/VirtTipsAndTricksGuideRenameGraph



On 26 May 2011, at 08:37, Ivan Mikhailov wrote:

> Alexandre,
> 
> I've posted a procedure to find all distinct predicates that start with
> some specified substring. It's trivial to turn it into a procedure to
> list all distinct graphs with same filtering and make an update based on
> th results.
> 
> Best Regards,
> 
> Ivan Mikhailov
> OpenLink Software
> http://virtuoso.openlinksw.com
> 
> On Tue, 2011-05-24 at 18:15 +0100, Tim Haynes wrote:
>> On 24/05/2011 16:55, Alexandre Passant wrote:
>>> I've seen doc at [1], but is there a way to do regex-based renaming of 
>>> graphs in Virtuoso ?
>>> 
>>> E.g. rename all graphs with URI scheme http://example.org/foo/* into 
>>> http://example.org/bar/*
>>> 
>>> Thanks
>>> 
>>> Alex.
>>> 
>>> [1] 
>>> http://ods.openlinksw.com/wiki/main/Main/VirtTipsAndTricksGuideRenameGraph
>> 
>> Hi,
>> 
>> Yes, it should be possible. Consider the following:
>> 
>> select distinct(
>>  iri_to_id(
>>regexp_replace(id_to_iri(g), 'openlink', 'localhost')
>>  )
>> )
>> from
>>  DB.DBA.RDF_QUAD
>> where
>>  regexp_match('openlink', id_to_iri(g))
>> 
>> Converting that to an update is left as an exercise :)
>> 
>> HTH,
>> 
>> ~Tim
> 
> 

--
Dr. Alexandre Passant, 
Social Software Unit Leader
Digital Enterprise Research Institute, 
National University of Ireland, Galway






Re: [Virtuoso-users] Regex-based renaming of graphs

2011-05-26 Thread Ivan Mikhailov
Alexandre,

I've posted a procedure to find all distinct predicates that start with
some specified substring. It's trivial to turn it into a procedure to
list all distinct graphs with same filtering and make an update based on
th results.

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com

On Tue, 2011-05-24 at 18:15 +0100, Tim Haynes wrote:
> On 24/05/2011 16:55, Alexandre Passant wrote:
> > I've seen doc at [1], but is there a way to do regex-based renaming of 
> > graphs in Virtuoso ?
> > 
> > E.g. rename all graphs with URI scheme http://example.org/foo/* into 
> > http://example.org/bar/*
> > 
> > Thanks
> > 
> > Alex.
> > 
> > [1] 
> > http://ods.openlinksw.com/wiki/main/Main/VirtTipsAndTricksGuideRenameGraph
> 
> Hi,
> 
> Yes, it should be possible. Consider the following:
> 
> select distinct(
>   iri_to_id(
> regexp_replace(id_to_iri(g), 'openlink', 'localhost')
>   )
> )
> from
>   DB.DBA.RDF_QUAD
> where
>   regexp_match('openlink', id_to_iri(g))
> 
> Converting that to an update is left as an exercise :)
> 
> HTH,
> 
> ~Tim





Re: [Virtuoso-users] Regex-based renaming of graphs

2011-05-24 Thread Tim Haynes
On 24/05/2011 16:55, Alexandre Passant wrote:
> I've seen doc at [1], but is there a way to do regex-based renaming of graphs 
> in Virtuoso ?
> 
> E.g. rename all graphs with URI scheme http://example.org/foo/* into 
> http://example.org/bar/*
> 
> Thanks
> 
> Alex.
> 
> [1] http://ods.openlinksw.com/wiki/main/Main/VirtTipsAndTricksGuideRenameGraph

Hi,

Yes, it should be possible. Consider the following:

select distinct(
  iri_to_id(
regexp_replace(id_to_iri(g), 'openlink', 'localhost')
  )
)
from
  DB.DBA.RDF_QUAD
where
  regexp_match('openlink', id_to_iri(g))

Converting that to an update is left as an exercise :)

HTH,

~Tim
-- 
Tim Haynes
Product Development Consultant
OpenLink Software





[Virtuoso-users] Regex-based renaming of graphs

2011-05-24 Thread Alexandre Passant
Hi,

I've seen doc at [1], but is there a way to do regex-based renaming of graphs 
in Virtuoso ?

E.g. rename all graphs with URI scheme http://example.org/foo/* into 
http://example.org/bar/*

Thanks

Alex.

[1] http://ods.openlinksw.com/wiki/main/Main/VirtTipsAndTricksGuideRenameGraph

--
Dr. Alexandre Passant, 
Social Software Unit Leader
Digital Enterprise Research Institute, 
National University of Ireland, Galway