Fixed LDBC test index creation for Neo4j.
Reviewers: teon.banek Reviewed By: teon.banek Differential Revision: https://phabricator.memgraph.io/D824
This commit is contained in:
parent
acb102de65
commit
e224199b36
@ -1,26 +1,41 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from neo4j.v1 import GraphDatabase, basic_auth
|
from neo4j.v1 import GraphDatabase, basic_auth
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
argp = argparse.ArgumentParser(
|
||||||
|
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||||
|
argp.add_argument('indexfile', help='File with indexes that should be created.')
|
||||||
|
argp.add_argument('--host', default='127.0.0.1', help='Database host.')
|
||||||
|
argp.add_argument('--port', default='7687', help='Database port.')
|
||||||
|
argp.add_argument('--username', default='', help='Database username.')
|
||||||
|
argp.add_argument('--password', default='', help='Database password.')
|
||||||
|
argp.add_argument('--database', default='memgraph',
|
||||||
|
choices=('memgraph', 'neo4j'), help='Database used.')
|
||||||
|
return argp.parse_args()
|
||||||
|
|
||||||
|
# Parse args
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
# Initialize driver and create session.
|
# Initialize driver and create session.
|
||||||
port = sys.argv[2] if len(sys.argv) > 2 else '7687'
|
driver = GraphDatabase.driver('bolt://{}:{}'.format(args.host, args.port),
|
||||||
driver = GraphDatabase.driver('bolt://localhost:%s' % port,
|
auth=basic_auth(args.username, args.password),
|
||||||
auth=basic_auth('', ''),
|
|
||||||
encrypted=False)
|
encrypted=False)
|
||||||
session = driver.session()
|
session = driver.session()
|
||||||
|
|
||||||
# The fist program argument is path to a file with indexes.
|
# The fist program argument is path to a file with indexes.
|
||||||
try:
|
with open(args.indexfile, "r") as f:
|
||||||
with open(sys.argv[1], "r") as f:
|
for line in f.readlines():
|
||||||
for line in f.readlines():
|
session.run(line.strip()).consume()
|
||||||
session.run(line.strip()).consume()
|
print("%s -> DONE" % line.strip())
|
||||||
print("%s -> DONE" % line.strip())
|
if args.database == "neo4j":
|
||||||
print("All indexes were created.")
|
print("Waiting for indexes to be fully created...")
|
||||||
except:
|
session.run("CALL db.awaitIndexes(14400);").consume()
|
||||||
print("Frist argument is path to a file with indexes.")
|
print("All indexes were created.")
|
||||||
|
|
||||||
# Do the cleanup.
|
# Do the cleanup.
|
||||||
session.close()
|
session.close()
|
||||||
|
@ -71,15 +71,15 @@ class Neo:
|
|||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
# create home directory
|
# create home directory
|
||||||
self.home_dir = tempfile.mkdtemp(dir="/dev/shm")
|
self.home_dir = tempfile.mkdtemp(dir=self.dataset)
|
||||||
|
|
||||||
neo4j_dir = os.path.join(BASE_DIR, "libs", "neo4j")
|
neo4j_dir = os.path.join(BASE_DIR, "libs", "neo4j")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.symlink(os.path.join(neo4j_dir, "lib"),
|
os.symlink(os.path.join(neo4j_dir, "lib"),
|
||||||
os.path.join(self.home_dir, "lib"))
|
os.path.join(self.home_dir, "lib"))
|
||||||
os.symlink(os.path.join(self.dataset, "neo4j"),
|
shutil.copytree(os.path.join(self.dataset, "neo4j"),
|
||||||
os.path.join(self.home_dir, "data"))
|
os.path.join(self.home_dir, "data"))
|
||||||
conf_dir = os.path.join(self.home_dir, "conf")
|
conf_dir = os.path.join(self.home_dir, "conf")
|
||||||
conf_file = os.path.join(conf_dir, "neo4j.conf")
|
conf_file = os.path.join(conf_dir, "neo4j.conf")
|
||||||
os.mkdir(conf_dir)
|
os.mkdir(conf_dir)
|
||||||
@ -156,10 +156,11 @@ LDBC_DEFAULT_PROPERTIES = \
|
|||||||
'ldbc_driver_default.properties')
|
'ldbc_driver_default.properties')
|
||||||
|
|
||||||
|
|
||||||
def create_index(port):
|
def create_index(port, database):
|
||||||
index_file = os.path.join(SCRIPT_DIR, 'ldbc-snb-impls',
|
index_file = os.path.join(SCRIPT_DIR, 'ldbc-snb-impls',
|
||||||
'snb-interactive-neo4j', 'scripts', 'indexCreation.neo4j')
|
'snb-interactive-neo4j', 'scripts', 'indexCreation.neo4j')
|
||||||
subprocess.check_call(('ve3/bin/python3', 'index_creation.py', index_file, port),
|
subprocess.check_call(('ve3/bin/python3', 'index_creation.py', '--port',
|
||||||
|
port, '--database', database, index_file),
|
||||||
cwd=SCRIPT_DIR)
|
cwd=SCRIPT_DIR)
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
|
|
||||||
@ -181,8 +182,11 @@ def main():
|
|||||||
try:
|
try:
|
||||||
if db:
|
if db:
|
||||||
db.start()
|
db.start()
|
||||||
|
time.sleep(10.0)
|
||||||
|
|
||||||
if args.create_index:
|
if args.create_index:
|
||||||
create_index(args.port)
|
create_index(args.port, args.run_db.lower())
|
||||||
|
time.sleep(10.0)
|
||||||
|
|
||||||
# Run LDBC driver.
|
# Run LDBC driver.
|
||||||
cp = 'target/jeeves-0.3-SNAPSHOT.jar:{}'.format(LDBC_INTERACTIVE_NEO4J)
|
cp = 'target/jeeves-0.3-SNAPSHOT.jar:{}'.format(LDBC_INTERACTIVE_NEO4J)
|
||||||
|
Loading…
Reference in New Issue
Block a user