org.neo4j.graphdb.GraphDatabaseService Java Examples

The following examples show how to use org.neo4j.graphdb.GraphDatabaseService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LUBM.java    From neo4jena with Apache License 2.0 6 votes vote down vote up
public static void write(GraphDatabaseService njgraph) {
	Logger log= Logger.getLogger(Wine.class);
	InputStream in = FileManager.get().open( inputFileName );
	if (in == null) {
           throw new IllegalArgumentException( "File: " + inputFileName + " not found");
       }
       
	Model model = ModelFactory.createDefaultModel();
       model.read(in,"","RDF");
       double triples = model.size();
       log.info("Model loaded with " +  triples + " triples");
       System.out.println("Model loaded with " +  triples + " triples");
       
	NeoGraph graph = new NeoGraph(njgraph);
	graph.startBulkLoad();
	log.info("Connection created");
	Model njmodel = ModelFactory.createModelForGraph(graph);
	log.info("NeoGraph Model initiated");
	System.out.println("NeoGraph Model initiated");
	StopWatch watch = new StopWatch();
	//log.info(njmodel.add(model));
	njmodel.add(model);
	log.info("Storing completed (ms): " + watch.stop());
	graph.stopBulkLoad();
	System.out.println("Storing completed (ms): " + watch.stop());
}
 
Example #2
Source File: Neo4JApiQueryPosLengthInject.java    From trainbenchmark with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Collection<Neo4jPosLengthInjectMatch> evaluate() {
	final Collection<Neo4jPosLengthInjectMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		// (segment:Segment)
		final Iterable<Node> segments = () -> graphDb.findNodes(Neo4jConstants.labelSegment);
		for (final Node segment : segments) {
			final Map<String, Object> match = new HashMap<>();
			match.put(VAR_SEGMENT, segment);
			matches.add(new Neo4jPosLengthInjectMatch(match));
		}
	}

	return matches;
}
 
Example #3
Source File: GraphDbBootstrapTest.java    From extended-objects with Apache License 2.0 6 votes vote down vote up
@Test
public void bootstrap() throws URISyntaxException {
    GraphDatabaseService graphDatabaseService = new TestGraphDatabaseFactory().newImpermanentDatabase();
    Properties properties = new Properties();
    properties.put(GraphDatabaseService.class.getName(), graphDatabaseService);
    XOUnit xoUnit = XOUnit.builder().uri(new URI("graphDb:///")).provider(EmbeddedNeo4jXOProvider.class).types(singletonList(A.class))
            .properties(properties).build();
    XOManagerFactory xoManagerFactory = XO.createXOManagerFactory(xoUnit);
    XOManager xoManager = xoManagerFactory.createXOManager();
    xoManager.currentTransaction().begin();
    A a = xoManager.create(A.class);
    a.setName("Test");
    xoManager.currentTransaction().commit();
    xoManager.close();
    xoManagerFactory.close();
    try (Transaction transaction = graphDatabaseService.beginTx()) {
        ResourceIterator<Node> iterator = graphDatabaseService.findNodes(label("A"), "name", "Test");
        assertThat(iterator.hasNext(), equalTo(true));
        Node node = iterator.next();
        assertThat(node.hasLabel(label("A")), equalTo(true));
        assertThat(node.getProperty("name"), equalTo((Object) "Test"));
        transaction.success();
    }
}
 
Example #4
Source File: NodeManager.java    From graphify with Apache License 2.0 6 votes vote down vote up
public Object getNodeProperty(Long id, String key, GraphDatabaseService graphDb)
{
    boolean success;

    // Update the node's property in cache
    Map<String, Object> node = globalNodeCache.getIfPresent(id);

    if(node == null)
    {
        // The node isn't available in the cache, go to the database and retrieve it
        success = addNodeToCache((gdb, cache) -> getNodeHashMap(id, gdb, cache), graphDb);
        if(success) node = globalNodeCache.getIfPresent(id);
    }

    return node != null ? node.get(key) : null;
}
 
Example #5
Source File: DatabaseValidatorTest.java    From timbuctoo with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void checkCallsInitAndFinish() {
  TinkerPopGraphManager graph = makeGraph("1");
  DatabaseCheck databaseCheck1 = mock(DatabaseCheck.class);
  DatabaseCheck databaseCheck2 = mock(DatabaseCheck.class);

  DatabaseValidator instance =
    new DatabaseValidator(graph, databaseCheck1, databaseCheck2);

  instance.check();

  InOrder inOrder = inOrder(databaseCheck1, databaseCheck2);
  inOrder.verify(databaseCheck1).init(any(Graph.class), any(GraphDatabaseService.class));
  inOrder.verify(databaseCheck2).init(any(Graph.class), any(GraphDatabaseService.class));
  inOrder.verify(databaseCheck1).check(any(Vertex.class));
  inOrder.verify(databaseCheck2).check(any(Vertex.class));
  inOrder.verify(databaseCheck1).finish();
  inOrder.verify(databaseCheck2).finish();
}
 
Example #6
Source File: VectorUtilTest.java    From graphify with Apache License 2.0 6 votes vote down vote up
private static boolean testOnText(String text, String label, GraphDatabaseService db, GraphManager graphManager) {
    Map<String, List<LinkedHashMap<String, Object>>> hashMap = VectorUtil.similarDocumentMapForVector(db, graphManager,
            cleanText(text), graphManager.getDecisionTree(getRootPatternNode(db, graphManager).getId(), db));

    // Validate guess
    ArrayList classes = (ArrayList) hashMap.get("classes");

    if (classes.size() > 0) {
        LinkedHashMap className = (LinkedHashMap) classes.stream().findFirst().get();

        return className.get("class").equals(label);
    }
    else
    {
        return false;
    }
}
 
Example #7
Source File: Neo4jModule.java    From SciGraph with Apache License 2.0 6 votes vote down vote up
public static void setupSchemaIndexes(GraphDatabaseService graphDb, Neo4jConfiguration config) {
  Map<String, Set<String>> schemaIndexes = config.getSchemaIndexes();
  for (Map.Entry<String, Set<String>> entry : schemaIndexes.entrySet()) {
    Label label = Label.label(entry.getKey());
    for (String property : entry.getValue()) {
      try (Transaction tx = graphDb.beginTx()) {
        Schema schema = graphDb.schema();
        IndexDefinition indexDefinition = schema.indexFor(label).on(property).create();
        tx.success();
        tx.close();

        Transaction tx2 = graphDb.beginTx();
        schema.awaitIndexOnline(indexDefinition, 2, TimeUnit.MINUTES);
        tx2.success();
        tx2.close();
      }
    }
  }
}
 
Example #8
Source File: MailListExtractor.java    From SnowGraph with Apache License 2.0 6 votes vote down vote up
public void run(GraphDatabaseService db) {
    this.db = db;
    MboxHandler myHandler = new MboxHandler();
    myHandler.setDb(db);
    MimeConfig config=new MimeConfig();
    config.setMaxLineLen(-1);
    parser = new MimeStreamParser(config);
    parser.setContentHandler(myHandler);
    parse(new File(mboxPath));
    try (Transaction tx = db.beginTx()) {
        for (String address : myHandler.getMailUserNameMap().keySet()) {
            Node node = myHandler.getMailUserMap().get(address);
            node.setProperty(MAILUSER_NAMES, String.join(", ", myHandler.getMailUserNameMap().get(address)));
        }
        tx.success();
    }
    try (Transaction tx = db.beginTx()) {
        for (String mailId : myHandler.getMailReplyMap().keySet()) {
            Node mailNode = myHandler.getMailMap().get(mailId);
            Node replyNode = myHandler.getMailMap().get(myHandler.getMailReplyMap().get(mailId));
            if (mailNode != null & replyNode != null)
                mailNode.createRelationshipTo(replyNode, RelationshipType.withName(MailListExtractor.MAIL_IN_REPLY_TO));
        }
        tx.success();
    }
}
 
Example #9
Source File: NodeManagerTest.java    From graphify with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetNodeProperty() throws Exception {
    GraphDatabaseService db = setUpDb();
    NodeManager nodeManager = new NodeManager();
    NodeManager.globalNodeCache.invalidateAll();
    DataNodeManager.dataCache.invalidateAll();
    DataNodeManager dataNodeManager = new DataNodeManager();

    // Write some nodes to the database
    Transaction tx1 = db.beginTx();
    Node a = nodeManager.getOrCreateNode(dataNodeManager, "a", db);
    tx1.success();
    Assert.assertNotNull(a);

    String expected = "success";
    nodeManager.setNodeProperty(a.getId(), "test", expected, db);
    Transaction tx = db.beginTx();
    String actual = (String)NodeManager.getNodeFromGlobalCache(a.getId()).get("test");
    tx.success();

    Assert.assertEquals(expected, actual);
}
 
Example #10
Source File: Course.java    From neo4jena with Apache License 2.0 5 votes vote down vote up
public static void write(GraphDatabaseService njgraph) {
	InputStream in = FileManager.get().open( inputFileName );
	if (in == null) {
           throw new IllegalArgumentException( "File: " + inputFileName + " not found");
       }
       
	Model model = ModelFactory.createDefaultModel();
       model.read(in,"","TTL");
       double triples = model.size();
       log.info("Model loaded with " +  triples + " triples");
       System.out.println("Model loaded with " +  triples + " triples");
       Map<String, String> prefixMap = model.getNsPrefixMap();
      // System.out.println("Prefix Mapping: " + prefixMap);
       
	NeoGraph graph = new NeoGraph(njgraph);
	graph.getPrefixMapping().setNsPrefixes(prefixMap);
	graph.startBulkLoad();
	log.info("Connection created");
	Model njmodel = ModelFactory.createModelForGraph(graph);
	log.info("NeoGraph Model initiated");
	System.out.println("NeoGraph Model initiated");
	
	//log.info(njmodel.add(model));
	//njmodel.add(model);
	StmtIterator iterator = model.listStatements();
	StopWatch watch = new StopWatch();
	int count = 0;
	while(iterator.hasNext()){
		njmodel.add(iterator.next());
		count++;
	}
	System.out.println("Total triples loaded are:"+ count);
	graph.stopBulkLoad();
	//log.info("Storing completed (ms): " + watch.stop());
	System.out.println("Storing completed (ms): " + watch.stop());
}
 
Example #11
Source File: Neo4jConfig.java    From Project with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod="shutdown")
public GraphDatabaseService graphDatabaseService() {	
	/*
	 * 配置嵌入式数据库
	 * 在Neo4j中,嵌入式数据库不要与内存数据库相混淆。
	 * 在这里,“嵌入式”指的是数据库引擎与应用运行在同一个JVM中,作为应用的一部分,
	 * 而不是独立的服务器。数据依然会持久化到文件系统中(在本例中,也就是“/tmp/graphdb”中)。
	 */
	return new GraphDatabaseFactory()
			.newEmbeddedDatabase("/tmp/graphdb");
}
 
Example #12
Source File: GraphDump.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
public static void dumpGraph(GraphDatabaseService graphDb) {
  for (Node node: graphDb.getAllNodes()) {
    dumpNode(node);
  }
  for (Relationship relationship: graphDb.getAllRelationships()) {
    dumpRelationship(relationship);
  }
}
 
Example #13
Source File: LabelPropagationTest.java    From graph_processing with MIT License 5 votes vote down vote up
private void populateDb(GraphDatabaseService db) {
    try ( Transaction tx = db.beginTx()) {
        db.execute(TestObjects.MOVIES_QUERY);
        db.execute(TestObjects.KNOWS_QUERY);
        tx.success();
    }
}
 
Example #14
Source File: SnowGraphBuilder.java    From SnowGraph with Apache License 2.0 5 votes vote down vote up
private void run(){
    GraphDatabaseService graph=new GraphDatabaseFactory().newEmbeddedDatabase( new File(config.getGraphPath()) );
    for (int i=0;i<extractors.size();i++) {
        System.out.println(extractors.get(i).getClass().getName()+" started.");
        extractors.get(i).run(graph);
        extractors.set(i, new DefaultExtractor());
        System.gc();
    }
}
 
Example #15
Source File: InitBuilderTest.java    From neo4j-versioner-core with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldBuildCorrectProcedureInstance() {
    GraphDatabaseService db = mock(GraphDatabaseService.class);
    Log log = mock(Log.class);

    Optional<Init> result = new InitBuilder().withDb(db).withLog(log).build();

    assertThat(result.isPresent(), is(true));
    assertThat(result.get().db, is(db));
    assertThat(result.get().log, is(log));
}
 
Example #16
Source File: TestUtil.java    From ongdb-lab-apoc with Apache License 2.0 5 votes vote down vote up
public static void testCallCount(GraphDatabaseService db, String call, Map<String, Object> params, final int count) {
    testResult(db, call, params, (res) -> {
        int left = count;
        while (left > 0) {
            assertTrue("Expected " + count + " results, but got only " + (count - left), res.hasNext());
            res.next();
            left--;
        }
        assertFalse("Expected " + count + " results, but there are more ", res.hasNext());
    });
}
 
Example #17
Source File: VectorUtilTest.java    From graphify with Apache License 2.0 5 votes vote down vote up
private static Node getRootPatternNode(GraphDatabaseService db, GraphManager graphManager) {
    Node patternNode;
    patternNode = new NodeManager().getOrCreateNode(graphManager, GraphManager.ROOT_TEMPLATE, db);

    try(Transaction tx = db.beginTx()) {
        if (!patternNode.hasProperty("matches")) {
            patternNode.setProperty("matches", 0);
            patternNode.setProperty("threshold", GraphManager.MIN_THRESHOLD);
            patternNode.setProperty("root", 1);
            patternNode.setProperty("phrase", "{0} {1}");
        }
        tx.success();
    }
    return patternNode;
}
 
Example #18
Source File: WriterTest.java    From neo4j-mazerunner with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteToHadoop() throws Exception {
    GraphDatabaseService db = setUpDb();

    // Use test configurations
    ConfigurationLoader.testPropertyAccess = true;

    createSampleGraph(db);

    Writer.exportSubgraphToHDFS(db);
}
 
Example #19
Source File: Neo4jHelper.java    From timbuctoo with GNU General Public License v3.0 5 votes vote down vote up
public static void cleanDb( GraphDatabaseService graphDatabaseService, boolean includeReferenceNode ) {
  Transaction tx = graphDatabaseService.beginTx();
  try {
    clearIndex(graphDatabaseService);
    removeNodes(graphDatabaseService, includeReferenceNode);
    tx.success();
  } catch (Throwable t) {
    tx.failure();
    throw new RuntimeException("Error cleaning database ",t);
  } finally {
    tx.close();
  }
}
 
Example #20
Source File: VectorUtilTest.java    From graphify with Apache License 2.0 5 votes vote down vote up
@Ignore
public void sentimentAnalysisTest() throws IOException {
    GraphDatabaseService db = setUpDb();
    GraphManager graphManager = new GraphManager("Pattern");

    // Invalidate all caches
    NodeManager.globalNodeCache.invalidateAll();
    DataNodeManager.dataCache.invalidateAll();
    ClassNodeManager.classCache.invalidateAll();
    GraphManager.edgeCache.invalidateAll();
    GraphManager.inversePatternCache.invalidateAll();
    GraphManager.patternCache.invalidateAll();
    DataRelationshipManager.relationshipCache.invalidateAll();
    ClassRelationshipCache.relationshipCache.invalidateAll();
    PatternRelationshipCache.relationshipCache.invalidateAll();
    VectorUtil.vectorSpaceModelCache.invalidateAll();

    Node rootNode = getRootPatternNode(db, graphManager);
    DecisionTree decisionTree = new DecisionTree<>(rootNode.getId(), new scala.collection.mutable.HashMap<>(), db, graphManager);

    // Train the model on examples each of positive and negative reviews
    train(db, graphManager, decisionTree);

    // Test the model on the next examples of positive and negative reviews
    Map<String, Double> errorMap = test(db, graphManager, TEST_COUNT);

    // To ensure the validity of the classifier, assert success ratio is greater than 50%
    Assert.assertTrue(errorMap.get("positive") > .5 && errorMap.get("negative") > .5);

    System.out.println(errorMap);

    System.out.println(VectorUtil.getPhrasesForClass(db, "negative"));
    System.out.println(VectorUtil.getPhrasesForClass(db, "positive"));
}
 
Example #21
Source File: Neo4jModule.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Provides
@Singleton
GraphDatabaseService getGraphDatabaseService() throws IOException {
  try {
    GraphDatabaseBuilder graphDatabaseBuilder = new GraphDatabaseFactory()
        .newEmbeddedDatabaseBuilder(new File(configuration.getLocation()))
        .setConfig(configuration.getNeo4jConfig());
    if (readOnly) {
      graphDatabaseBuilder.setConfig(GraphDatabaseSettings.read_only, Settings.TRUE);
    }

    // #198 - do not keep transaction logs
    graphDatabaseBuilder.setConfig(GraphDatabaseSettings.keep_logical_logs, Settings.FALSE);

    final GraphDatabaseService graphDb = graphDatabaseBuilder.newGraphDatabase();
    Runtime.getRuntime().addShutdownHook(new Thread() {
      @Override
      public void run() {
        graphDb.shutdown();
      }
    });

    if (!readOnly) { // No need of auto-indexing in read-only mode
      setupAutoIndexing(graphDb, configuration);
    }

    setupSchemaIndexes(graphDb, configuration);

    return graphDb;
  } catch (Exception e) {
    if (Throwables.getRootCause(e).getMessage().contains("lock file")) {
      throw new IOException(format("The graph at \"%s\" is locked by another process",
          configuration.getLocation()));
    }
    throw e;
  }
}
 
Example #22
Source File: Neo4JApiQuerySwitchMonitored.java    From trainbenchmark with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Collection<Neo4jSwitchMonitoredMatch> evaluate() {
	final Collection<Neo4jSwitchMonitoredMatch> matches = new ArrayList<>();

	final GraphDatabaseService graphDb = driver.getGraphDb();
	try (Transaction tx = graphDb.beginTx()) {
		final Iterable<Node> sws = () -> graphDb.findNodes(Neo4jConstants.labelSwitch);
		// (sw:Switch)
		for (final Node sw : sws) {
			// (sw)-[:sensor]->(Sensor) NAC
			final Iterable<Relationship> relationshipSensors = sw.getRelationships(Direction.OUTGOING, Neo4jConstants.relationshipTypeMonitoredBy);

			boolean hasSensor = false;
			for (final Relationship relationshipSensor : relationshipSensors) {
				final Node sensor = relationshipSensor.getEndNode();
				if (sensor.hasLabel(Neo4jConstants.labelSensor)) {
					hasSensor = true;
					break;
				}
			}

			if (!hasSensor) {
				final Map<String, Object> match = new HashMap<>();
				match.put(VAR_SW, sw);
				matches.add(new Neo4jSwitchMonitoredMatch(match));
			}
		}
	}

	return matches;
}
 
Example #23
Source File: GraphBatchImplIT.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
GraphDatabaseService getGraphDB() {
  graph.shutdown();
  graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(path));
  graphDb.beginTx();
  nodeIndex = graphDb.index().getNodeAutoIndexer().getAutoIndex();
  return graphDb;
}
 
Example #24
Source File: Neo4jHelper.java    From timbuctoo with GNU General Public License v3.0 5 votes vote down vote up
public static void dumpDb(GraphDatabaseService gds) {
  for (Node node : gds.getAllNodes()) {
    System.out.println(dumpNode(node));
  }
  for (Relationship rel : gds.getAllRelationships()) {
    System.out.println(dumpEdge(rel));
  }
}
 
Example #25
Source File: ApocHelper.java    From trainbenchmark with Eclipse Public License 1.0 5 votes vote down vote up
public static void registerProcedure(GraphDatabaseService db, Class<?>...procedures) throws KernelException {
	Procedures proceduresService = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(Procedures.class);
	for (Class<?> procedure : procedures) {
		proceduresService.registerProcedure(procedure);
		proceduresService.registerFunction(procedure);
	}
}
 
Example #26
Source File: CoderadarTestApplication.java    From coderadar with MIT License 5 votes vote down vote up
@Bean
public GraphDatabaseService graphDatabaseService() throws KernelException {
  GraphDatabaseService db =
      new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase();
  registerProcedure(
      db,
      apoc.path.RelationshipSequenceExpander.class,
      apoc.path.PathExplorer.class,
      apoc.cypher.Cypher.class,
      apoc.graph.Graphs.class,
      apoc.path.RelationshipTypeAndDirections.class);
  return db;
}
 
Example #27
Source File: PageRank.java    From Neo4jSNA with Apache License 2.0 5 votes vote down vote up
public PageRank(GraphDatabaseService g) {
	rankMap = new Long2DoubleOpenHashMap();
	try(Transaction tx = g.beginTx()) {
		for(@SuppressWarnings("unused") Node n : GlobalGraphOperations.at(g).getAllNodes())
			nodeCount += 1;
		tx.success();
	}
	this.firstMember = ( 1.0 - this.dampingFactor ) / this.nodeCount;
}
 
Example #28
Source File: PatternRecognitionResource.java    From graphify with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/extractfeatures")
@Produces(MediaType.APPLICATION_JSON)
public Response extract(String body, @Context GraphDatabaseService db) throws IOException {
    HashMap<String, Object> input;
    try {

        input = objectMapper.readValue(body, HashMap.class);

        String text;

        if(input.containsKey("text")) {
            text = ((String) input.get("text"));
        }
        else
        {
            throw new Exception("Error parsing JSON");
        }

        DecisionTree<Long> tree = new DecisionTree<>(getRootPatternNode(db).getId(), new scala.collection.mutable.HashMap<>(), db, GRAPH_MANAGER);
        List<LinkedHashMap<String, Object>> phrases = VectorUtil.getPhrases(db, cleanText(text), GRAPH_MANAGER, tree);


        return Response.ok()
                .entity(new Gson().toJson(phrases))
                .type(MediaType.APPLICATION_JSON)
                .build();

    } catch (Exception e) {
        return Response.status(400).entity(String.format("{\"error\":\"%s %s\"}", e.toString(), Arrays.toString(e.getStackTrace()))).build();
    }
}
 
Example #29
Source File: DataImporterSakilaTest.java    From neo4j-rdbms-import with GNU General Public License v3.0 5 votes vote down vote up
private static String importInfo() {
    GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(STORE_DIR);

    try (Transaction tx = db.beginTx()) {
        int nodes = IteratorUtil.count(db.getAllNodes());
        int rels = IteratorUtil.count(GlobalGraphOperations.at(db).getAllRelationships());
        return "Imported nodes " + nodes + " rels " + rels;
    } finally {
        db.shutdown();
    }
}
 
Example #30
Source File: Wine.java    From neo4jena with Apache License 2.0 5 votes vote down vote up
public static void search(GraphDatabaseService njgraph) {
	NeoGraph graph = new NeoGraph(njgraph);
	Model njmodel = ModelFactory.createModelForGraph(graph);
	      
	String s2 = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" +
				"PREFIX food: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#>"+
				"PREFIX wine: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>" +
				"PREFIX owl: <http://www.w3.org/2002/07/owl#>"+
				"SELECT ?X WHERE {"+
				"?X food:SweetFruit ?Z . }";

       Query query = QueryFactory.create(s2);
       QueryExecution qExe = QueryExecutionFactory.create(query, njmodel);
       StopWatch watch = new StopWatch();
       ResultSet results = qExe.execSelect();
       System.out.println("Query took (ms): "+ watch.stop());
       //ResultSetFormatter.out(System.out, results);
       
       int count=0;
       while(results.hasNext()){
       	//System.out.println("in while"+count);
       	QuerySolution sol = results.next();
       	System.out.print(sol.get("X"));
       	count++;
       }
      System.out.println("Record fetched:"+ count);
      
}