Re: [Neo4j] Traversing Neo4j using python binding
Hi Mattias, Thx for your prompt reply. Actually I already used indexes while inserting data to check if a particular node is already inserted or not. but what if I want to get all nodes starting with PEP or PEPSI as in the below example? thx. Francois. -- From: Mattias Persson matt...@neotechnology.com Sent: Tuesday, October 05, 2010 12:46 PM To: Neo4j user discussions user@lists.neo4j.org Subject: Re: [Neo4j] Traversing Neo4j using python binding Yep, your use case is a good fit for using indexes... looping through 300k nodes just to find one particular isn't very efficient. Take a look at http://components.neo4j.org/neo4j.py/ for how to use indexing in the neo4j python bindings. 2010/10/5 Francois Kassis francois_kas...@hotmail.com Hi all, I am trying to retrieve data from neo4j database using python version. I have over 30 nodes all joined to a master node by a OFTYPE relationships. I used the following to traverse it: #!/usr/bin/env python # -*- coding: UTF-8 -*- # Traversal import neo4j def get_OFTYPE(ar_node):#, ar_filter): return OFTYPE(ar_node) class OFTYPE(neo4j.Traversal): #my_pos_filter = # #def __init__(self, start, pos_filter=): ## set an internal variable #self.my_pos_filter = pos_filter #neo4j.Traversal.__init__(self, start) types = [ neo4j.Incoming.OFTYPE, ] order = neo4j.BREADTH_FIRST stop = neo4j.StopAtDepth(1) def isReturnable(self, position): return (not position.is_start #and position.label == self.my_pos_filter and position.last_relationship.type == 'OFTYPE') and call the above by: #!/usr/bin/env python # -*- coding: UTF-8 -*- import argparse import neo4j import ConfigParser import os, sys, datetime, string import neoentity_traverse_test from neo4j.util import Subreference def main(): ls_current_script_path = sys.path[0] # os.getcwd() ls_current_script_filename = sys.argv[0] config = ConfigParser.RawConfigParser() config.read(ls_current_script_path + '/' + 'neoentity.cfg') parser = argparse.ArgumentParser(description='Initialize neo4j database for mediasharks root enteties. NOTE: if the database '\ 'does not exists, it will simply be created.') parser.add_argument('--neodbpath', dest='neodbpath', metavar='NEODB-PATH', default=config.get('database', 'database_path'), help='a directory where neodb should be created or opened.') parser.add_argument('--classpath', dest='kernalclasspath', metavar='KERNAL-CLASSPATH', default=config.get('neo4j', 'kernalclasspath'), help='the path toneo4j kernal path.') parser.add_argument('--jvm', dest='jvmclasspath', metavar='JVM-CLASSPATH', default=config.get('jvm', 'jvmpath'), help='the path toneo4j kernal path.') args = parser.parse_args() pytest(args.neodbpath, args.kernalclasspath, args.jvmclasspath) def pytest(arg_neodb_path, arg_kernal_classpath, arg_jvm_classpath): print = print initializing neo4j db using parameters: print database-path = + arg_neodb_path print kernel-path = + arg_kernal_classpath print jvm-path = + arg_jvm_classpath print = #initialize variables ls_message = #create new neo database graphdb = neo4j.GraphDatabase(arg_neodb_path, classpath=arg_kernal_classpath, jvm=arg_jvm_classpath) #start new transaction try: tx = graphdb.transaction.begin() rootindex = graphdb.index(root_index, create=True) subbrandnode = rootindex[subbrand] referencenode = graphdb.node[0] li_index = 0 ls_filter = PEPSI for node in neoentity_traverse_test.get_OFTYPE(subbrandnode):#, ls_filter): ls_result = node[label] if ls_result.startswith(ls_filter): li_index = li_index + 1 print ls_result print li_index except: tx.failure() print Error occurred, exiting... raise else: tx.success() finally: tx.finish() #saving current transactions and closing current database graphdb.shutdown() if __name__ == '__main__': main() The problem is it's taking too much time. how can I improve performance and how can I use or call the lucene indexer from within python. THX in advance. Francois. ___ 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
Re: [Neo4j] Traversing Neo4j using python binding
There's fulltext index support in the indexing, but since I'm not by any means well travelled in the python bindings maybe someone can chip in about how this is done? 2010/10/5 Francois Kassis francois_kas...@hotmail.com Hi Mattias, Thx for your prompt reply. Actually I already used indexes while inserting data to check if a particular node is already inserted or not. but what if I want to get all nodes starting with PEP or PEPSI as in the below example? thx. Francois. -- From: Mattias Persson matt...@neotechnology.com Sent: Tuesday, October 05, 2010 12:46 PM To: Neo4j user discussions user@lists.neo4j.org Subject: Re: [Neo4j] Traversing Neo4j using python binding Yep, your use case is a good fit for using indexes... looping through 300k nodes just to find one particular isn't very efficient. Take a look at http://components.neo4j.org/neo4j.py/ for how to use indexing in the neo4j python bindings. 2010/10/5 Francois Kassis francois_kas...@hotmail.com Hi all, I am trying to retrieve data from neo4j database using python version. I have over 30 nodes all joined to a master node by a OFTYPE relationships. I used the following to traverse it: #!/usr/bin/env python # -*- coding: UTF-8 -*- # Traversal import neo4j def get_OFTYPE(ar_node):#, ar_filter): return OFTYPE(ar_node) class OFTYPE(neo4j.Traversal): #my_pos_filter = # #def __init__(self, start, pos_filter=): ## set an internal variable #self.my_pos_filter = pos_filter #neo4j.Traversal.__init__(self, start) types = [ neo4j.Incoming.OFTYPE, ] order = neo4j.BREADTH_FIRST stop = neo4j.StopAtDepth(1) def isReturnable(self, position): return (not position.is_start #and position.label == self.my_pos_filter and position.last_relationship.type == 'OFTYPE') and call the above by: #!/usr/bin/env python # -*- coding: UTF-8 -*- import argparse import neo4j import ConfigParser import os, sys, datetime, string import neoentity_traverse_test from neo4j.util import Subreference def main(): ls_current_script_path = sys.path[0] # os.getcwd() ls_current_script_filename = sys.argv[0] config = ConfigParser.RawConfigParser() config.read(ls_current_script_path + '/' + 'neoentity.cfg') parser = argparse.ArgumentParser(description='Initialize neo4j database for mediasharks root enteties. NOTE: if the database '\ 'does not exists, it will simply be created.') parser.add_argument('--neodbpath', dest='neodbpath', metavar='NEODB-PATH', default=config.get('database', 'database_path'), help='a directory where neodb should be created or opened.') parser.add_argument('--classpath', dest='kernalclasspath', metavar='KERNAL-CLASSPATH', default=config.get('neo4j', 'kernalclasspath'), help='the path toneo4j kernal path.') parser.add_argument('--jvm', dest='jvmclasspath', metavar='JVM-CLASSPATH', default=config.get('jvm', 'jvmpath'), help='the path toneo4j kernal path.') args = parser.parse_args() pytest(args.neodbpath, args.kernalclasspath, args.jvmclasspath) def pytest(arg_neodb_path, arg_kernal_classpath, arg_jvm_classpath): print = print initializing neo4j db using parameters: print database-path = + arg_neodb_path print kernel-path = + arg_kernal_classpath print jvm-path = + arg_jvm_classpath print = #initialize variables ls_message = #create new neo database graphdb = neo4j.GraphDatabase(arg_neodb_path, classpath=arg_kernal_classpath, jvm=arg_jvm_classpath) #start new transaction try: tx = graphdb.transaction.begin() rootindex = graphdb.index(root_index, create=True) subbrandnode = rootindex[subbrand] referencenode = graphdb.node[0] li_index = 0 ls_filter = PEPSI for node in neoentity_traverse_test.get_OFTYPE(subbrandnode):#, ls_filter): ls_result = node[label] if ls_result.startswith(ls_filter): li_index = li_index + 1 print ls_result print li_index except: tx.failure() print Error occurred, exiting... raise else: tx.success() finally: tx.finish() #saving current transactions and closing current database graphdb.shutdown() if __name__ == '__main__': main() The problem is it's taking too much time. how can I improve performance and how can I use
Re: [Neo4j] License Question Running Neo4j (AGPL) in Eclipse (EPL)
Thanks Peter. Option 1 and 2 could work and option 2 is clearly my personal favorite since is doesn't require me to write and maintain glue code between my EPL Code and Neo4j nor writing a custom installer to get around the license issue. In the case of a commercial license there are some details I just don't know, and thus have to discuss them with you and some Guys at Eclipse Foundation. For instance whether a software under a commercial license can be distributed over their servers or update pages resp. I will get back to you for a discussion of the details. Thanks, Marcel ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] License Question Running Neo4j (AGPL) in Eclipse (EPL)
Hello, I'm afraid I'm a bit confused in general with these licensing practices. I was reading this: http://turingmachine.org/~dmg/papers/dmg2009_icse_licenses_preliminary.pdf The relevant distinction seems to be whether an application is a collective work or a derivative work of its components. Using unmodified Neo4j instance through its API means so-called black-box reuse. Using it through the REST interface would constitute IPC type of interconnection. Using it by importing Neo4j classes to the application would probably constitute linking type of interconnection. Linking is likely to cause the application to be a derivative work of the components. I have understood that in the Linux/C context, linking to a GPL library automatically causes your application to fall under GPL. If importing Neo4j classes is considered linking to Neo4j, my application would fall under AGPL. A problem is introduced, when other components would be licensed under EPL. In this case, according to Wikipedia, the application can not be lawfully distributed. Does the first option mean, that an intermediate plugin would be under AGPL? Exactly what kind of plugin would it be? What kind of interconnection could it have to the rest of the (EPL'd) application, if not IPC only? It seems that importing plugin classes is out of the question? Have I misunderstood something? Cheers, m. Peter Neubauer [peter.neuba...@neotechnology.com] kirjoitti: Hi there, in principle, AGPL is not compatible with the EPL, in that you are right, Marcel. However, there are three ways to deal with this (possibly more), two of them doable right now: 1. Don't distribute Neo4j as part of the Eclipse-product distribution and let the user install the Neo4j plugin manually or semi-manually. Not a great way but doable. 2. Get back to me and Neo Technology will figure out a way to provide your project with a free commercial license to Neo4j. This has been done in a number of cases, even with Eclipse-based products. From a legal perspective that is the cleanest solution because then no AGPL is involved at all. 3. Potentially, the Neo4j licensing could be changed in a way similar to the Aptana License, explicitly making an exception to the AGPL for allowing usage with Eclipse based products and projects. This is not something that can be done immediately. For more information on the Aptana approach to things, see http://www.aptana.com/legal/aplgplex and http://www.aptana.com/legal So, would 1 or 2 work for you guys? Cheers, /peter neubauer VP Product Development, Neo Technology GTalk: neubauer.peter Skype peter.neubauer Phone +46 704 106975 LinkedIn http://www.linkedin.com/in/neubauer Twitter http://twitter.com/peterneubauer http://www.neo4j.org - Your high performance graph database. http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. On Mon, Oct 4, 2010 at 6:35 PM, mt...@nic.fi wrote: I've got the same problem. m. Marcel Bruch [br...@cs.tu-darmstadt.de] kirjoitti: Hi, I attended a talk about neo4j and decided to give neo4j a try. However, my code is running under EPL which is incompatible to GPLv3 (as far as I know) and thus also incompatible to AGPLv3. http://www.eclipse.org/legal/eplfaq.php#GPLCOMPATIBLE Thus, my question is: Is it possible/allowed to use Neo4j in EPL based projects, e.g, within the Eclipse Platform? Thanks for advice, Marcel -- Eclipse Code Recommenders http://www.stg.tu-darmstadt.de/research/core/ ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user