Re: [Neo] python binding data import problem

2009-11-14 Thread Tobias Ivarsson
I would suggest using the indexing capabilities to solve this:

name_index = neo.index("name", create=True)
def get_node(id):
node = name_index[id]
if node is None:
node = neo.node(name=id)
name_index[id] = node
return node

Cheers,
Tobias

On Sat, Nov 14, 2009 at 6:51 PM, Yin Chen  wrote:

> Hi:
>I was playing with the Neo4j and its python binding. I want to import
> the user relationship data to Neo4j.
>Say id is the unique id for the user, I found no easy way to prevent the
> same id from generating different Nodes.
>The code below may works, but the data may be too big for memory.
>
>id_node_mapping = {}
>def get_node(id):
>if id in id_node_mapping:
>return id_node_mapping.get(id)
>else:
>node = neo.node(name=id)
>id_node_mapping[id] = node
>return node
>
>Any solution to this problem? Thanks.
> ___
> Neo mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Tobias Ivarsson 
Hacker, Neo Technology
www.neotechnology.com
Cellphone: +46 706 534857
___
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo] python binding data import problem

2009-11-14 Thread Yin Chen
Hi:
I was playing with the Neo4j and its python binding. I want to import
the user relationship data to Neo4j.
Say id is the unique id for the user, I found no easy way to prevent the
same id from generating different Nodes.
The code below may works, but the data may be too big for memory.

id_node_mapping = {}
def get_node(id):
if id in id_node_mapping:
return id_node_mapping.get(id)
else:
node = neo.node(name=id)
id_node_mapping[id] = node
return node

Any solution to this problem? Thanks.
___
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo] trouble installing jpype, alternate installation sought

2009-11-14 Thread Tobias Ivarsson
According to Steve Ménard (The developer of JPype) this is typically what
happens when you are trying to use a JRE instead of a JDK as the source for
the Java/JNI header files when compiling.[1]

I hope this is enough for you to work out these problems.

Cheers,
Tobias

[1]
http://sourceforge.net/mailarchive/forum.php?thread_name=1afed6d30907300541v74a722c0nbf9155832affd101%40mail.gmail.com&forum_name=jpype-users

On Sat, Nov 14, 2009 at 6:11 PM, Gregg Lind  wrote:

> I'm working on installing neo4j.py, using the instructions at
> http://components.neo4j.org/neo4j.py/.
>
> Jpype doesn't seem to build for me.  (Centos5.4, x64, Python2.4.3).  Is
> this
> usual (if you know) and if not, is there any way around this?
>
> [final message from python setup.py build
>
> src/native/common/jp_javaenv_autogen.cpp:1754: error: ‘class _Jv_JNIEnv’
> has
> no member named ‘functions’
> error: command 'gcc' failed with exit status 1
> ]
>
> Cheers,
>
> Gregg Lind
> ___
> Neo mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Tobias Ivarsson 
Hacker, Neo Technology
www.neotechnology.com
Cellphone: +46 706 534857
___
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo] trouble installing jpype, alternate installation sought

2009-11-14 Thread Gregg Lind
I'm working on installing neo4j.py, using the instructions at
http://components.neo4j.org/neo4j.py/.

Jpype doesn't seem to build for me.  (Centos5.4, x64, Python2.4.3).  Is this
usual (if you know) and if not, is there any way around this?

[final message from python setup.py build

src/native/common/jp_javaenv_autogen.cpp:1754: error: ‘class _Jv_JNIEnv’ has
no member named ‘functions’
error: command 'gcc' failed with exit status 1
]

Cheers,

Gregg Lind
___
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo] [neo4j.py] A Few Questions

2009-11-14 Thread Tobias Ivarsson
Hi,

Welcome to the mailing list.

On Thu, Nov 12, 2009 at 9:28 PM, Andrew Nelder  wrote:

> Hi,
>
> I would like to try playing around with and expanding upon the neo4j.py
> wrapper; however, I've run into a few issues.
>
> (1) I can't seem to find a way to return helpful information about a node
> (ie. it's depth).  Does anyone have a working example or even an
> explanation
> of how to obtain the depth (and perhaps other node information) during a
> traversal?  I've been playing with the examples and documention on the
> neo4j.py website, but it's not been extremely helpful.
>

The depth is available under the depth attribute in the nodes yielded from
traversals. Just as it is in the traversal predicate methods[1]. The depth
attribute is the only traversal attribute that is available on yielded
nodes, inside the predicate methods the attributes last_relationship,
is_start, previous_node, and returned_count are also available.


> (2) Is there a better way to initialize the traversal?  It uses lazy
> imports, so Python seems to crap out when the code is run because neo4j
> doesn't have properties like (Traversal) until NeoService is called.
>

Yes, this is a problem. I have not gotten around to fixing it yet, but it is
on my TODO list for the next release. My plan is to have these available
before NeoService is started, but until then the way you've done it is a
pretty good work around.

Over all I am not very satisfied with how traversals are defined for the
python bindings. The current API is good enough to not be removed in the
next version. But if anyone has any better suggestions on how to write
traversals I would very much like to hear about it.

Cheers,
Tobias

[1] See the Traversals section of
http://components.neo4j.org/neo4j.py/index.html

-- 
Tobias Ivarsson 
Hacker, Neo Technology
www.neotechnology.com
Cellphone: +46 706 534857
___
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user