Re: [Neo4j] Relationships stored order

2011-11-03 Thread Dmitriy Shabanov
Hello,

Storing order required because it's fundamental structure property.

If I do type "get (title) (book)" that always should be "title from book" &
never "book from title" because meaning are different (but second
expression is also valid). As you can see both expressions are valid but
have different evaluation results.

Graph created for that expressions is this (simplified): node(get) -> link
-> node(title) &   node(get) -> link -> node(book) , note that node(get) is
same node.

Now, if query node(get) for children order should be counted: 1
relationship to node(title), 2 relationship to node(book)

This is "down order" requirement, but there also "up order" one. The graph
is compressing on fly, so that mean that "get (title) (book)" & "get
(author) (book)" sharing node(book). Same time from node(book) it should be
possible to go back to node(get). Remember that there are two node(get) and
"up order" procedure must find correct one.

For now we using lucene and preparing berkeley db index, but interesting to
search for better performance too.

On Fri, Nov 4, 2011 at 4:56 AM, David Montag  wrote:

> Do they need to be sorted because of some arbitrary reason, or because
> you're storing data structures like lists that you want to preserve the
> order of?
>
> David
>
> On Thu, Nov 3, 2011 at 4:44 PM, Evgeny Gazdovsky  >wrote:
>
> > 2011/11/4 David Montag 
> >
> > > Hi Evgeny,
> > >
> > > Could you maybe describe the use case behind this requirement a bit
> more?
> > >
> > >
> > We use the neo as persistent memory in the new age programming
> > language. Every expression on this language is compiled into
> > graph structure. So we need a graph with sorted relationships.
> > And sort order is equal to the order in which relationships
> > are created (stored).
>  >
>

-- 
Dmitriy Shabanov
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Relationships stored order

2011-11-03 Thread David Montag
Do they need to be sorted because of some arbitrary reason, or because
you're storing data structures like lists that you want to preserve the
order of?

David

On Thu, Nov 3, 2011 at 4:44 PM, Evgeny Gazdovsky wrote:

> 2011/11/4 David Montag 
>
> > Hi Evgeny,
> >
> > Could you maybe describe the use case behind this requirement a bit more?
> >
> >
> We use the neo as persistent memory in the new age programming
> language. Every expression on this language is compiled into
> graph structure. So we need a graph with sorted relationships.
> And sort order is equal to the order in which relationships
> are created (stored).
>
> --
> Evgeny
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
David Montag 
Neo Technology, www.neotechnology.com
Cell: 650.556.4411
Skype: ddmontag
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Relationships stored order

2011-11-03 Thread Evgeny Gazdovsky
2011/11/4 David Montag 

> Hi Evgeny,
>
> Could you maybe describe the use case behind this requirement a bit more?
>
>
We use the neo as persistent memory in the new age programming
language. Every expression on this language is compiled into
graph structure. So we need a graph with sorted relationships.
And sort order is equal to the order in which relationships
are created (stored).

--
Evgeny
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Relationships stored order

2011-11-03 Thread David Montag
Hi Evgeny,

Could you maybe describe the use case behind this requirement a bit more?

Thanks,
David

On Sun, Oct 30, 2011 at 4:01 PM, Evgeny Gazdovsky wrote:

> PS
> We don't need a traverse through relationships
> in stored order, only iterations for start or end node.
>
> --
> Evgeny
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
David Montag 
Neo Technology, www.neotechnology.com
Cell: 650.556.4411
Skype: ddmontag
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Relationships stored order

2011-11-03 Thread Mattias Persson
2011/10/31 Dmitriy Shabanov 

> Hi,
>
> Berkeley Db index looks better for that. It was updated to serve our needs,
> but better performance required.
>
> Mattias, do you know low storage structure? Maybe, it'll possible to use
> some structural conditions to restore relationships order. At current
> design we have two writes for one relationship, that always 2 times slow
> than one =)
>

Neo4j doesn't have this type of ordering on the store level, and my best
guess would be some kind of index. If the index is just used for ordering
and there's a performance problem maybe you could stack up relationships
and batch index them at a later time?

>
> On Mon, Oct 31, 2011 at 6:45 PM, Mattias Persson
> wrote:
>
> > You can use what you wrote and then use lucene numeric range query to do
> > the trick:
> >
> >   Index index = ...
> >   index.add( rel2, "ORDER", ValueContext.numeric(2) );
> >   index.add( rel3, "ORDER", ValueContext.numeric(3) );
> >   index.add( rel1, "ORDER", ValueContext.numeric(1) );
> >   
> >   // For all relationships
> >   index.query( new QueryContext( NumericRangeQuery.newIntRange(
> > "ORDER",null,null,true,true ) ).sortNumeric( "ORDER", false ) );
> >   // For a range
> >   index.query( new QueryContext( NumericRangeQuery.newIntRange(
> > "ORDER",2,10,true,true ) ).sortNumeric( "ORDER", false ) );
> >
>
> --
> Dmitriy Shabanov
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Relationships stored order

2011-10-31 Thread Dmitriy Shabanov
Hi,

Berkeley Db index looks better for that. It was updated to serve our needs,
but better performance required.

Mattias, do you know low storage structure? Maybe, it'll possible to use
some structural conditions to restore relationships order. At current
design we have two writes for one relationship, that always 2 times slow
than one =)

On Mon, Oct 31, 2011 at 6:45 PM, Mattias Persson
wrote:

> You can use what you wrote and then use lucene numeric range query to do
> the trick:
>
>   Index index = ...
>   index.add( rel2, "ORDER", ValueContext.numeric(2) );
>   index.add( rel3, "ORDER", ValueContext.numeric(3) );
>   index.add( rel1, "ORDER", ValueContext.numeric(1) );
>   
>   // For all relationships
>   index.query( new QueryContext( NumericRangeQuery.newIntRange(
> "ORDER",null,null,true,true ) ).sortNumeric( "ORDER", false ) );
>   // For a range
>   index.query( new QueryContext( NumericRangeQuery.newIntRange(
> "ORDER",2,10,true,true ) ).sortNumeric( "ORDER", false ) );
>

-- 
Dmitriy Shabanov
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Relationships stored order

2011-10-31 Thread Mattias Persson
You can use what you wrote and then use lucene numeric range query to do
the trick:

   Index index = ...
   index.add( rel2, "ORDER", ValueContext.numeric(2) );
   index.add( rel3, "ORDER", ValueContext.numeric(3) );
   index.add( rel1, "ORDER", ValueContext.numeric(1) );
   
   // For all relationships
   index.query( new QueryContext( NumericRangeQuery.newIntRange(
"ORDER",null,null,true,true ) ).sortNumeric( "ORDER", false ) );
   // For a range
   index.query( new QueryContext( NumericRangeQuery.newIntRange(
"ORDER",2,10,true,true ) ).sortNumeric( "ORDER", false ) );

2011/10/31 Evgeny Gazdovsky 

> PS
> We don't need a traverse through relationships
> in stored order, only iterations for start or end node.
>
> --
> Evgeny
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Relationships stored order

2011-10-30 Thread Evgeny Gazdovsky
PS
We don't need a traverse through relationships
in stored order, only iterations for start or end node.

--
Evgeny
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Relationships stored order

2011-10-30 Thread Evgeny Gazdovsky
2011/10/31 Mattias Persson 

> No, are you thinking about ordering them after property value or by type or
> something else?
>
>  Just we use a special relationships index for storing the order of
relationships.
Like:
r = node.creareRelationship(parent, type);
index.add(r, "ORDER", 1);
r = node.creareRelationship(parent, type);
index.add(r, "ORDER", 2);

And the query via sort() to get relationships in right order.
This way have a very bad performance.
So, I have a question, is there a way get the relationships
in stored sorted order in neo?
If no, I suggest to create optional index (db) on the existing
neo's low level storage for this. We can use an external storage
(just we use bdb-index for the our key-value cache), but think
this like on existing neo's data files, isn't it?

--
Evgeny
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Relationships stored order

2011-10-30 Thread Mattias Persson
No, are you thinking about ordering them after property value or by type or
something else?

2011/10/30 Evgeny Gazdovsky 

> Hello!
>
> Is there way to get relationships in the stored order in the neo?
>
> --
> Evgeny
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] Relationships stored order

2011-10-30 Thread Evgeny Gazdovsky
Hello!

Is there way to get relationships in the stored order in the neo?

--
Evgeny
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user