当前位置: 首页>>代码示例>>Java>>正文


Java ResourceIterator类代码示例

本文整理汇总了Java中org.neo4j.graphdb.ResourceIterator的典型用法代码示例。如果您正苦于以下问题:Java ResourceIterator类的具体用法?Java ResourceIterator怎么用?Java ResourceIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResourceIterator类属于org.neo4j.graphdb包,在下文中一共展示了ResourceIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runQueryMultipleResult

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
public List<Object> runQueryMultipleResult(NeoProfiler parent, String query, String columnReturn) {
	ExecutionEngine engine = new ExecutionEngine(parent.getDB());
	List<Object> retvals = new ArrayList<Object>();
	
	try ( Transaction tx = parent.getDB().beginTx() ) {
		// log.info(query);
		ExecutionResult result = engine.execute(query);
		ResourceIterator<Object> rit = result.columnAs(columnReturn);
				
		while(rit.hasNext()) {				
			retvals.add(rit.next());
		}					
	}
	
	return retvals;
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:17,代码来源:QueryRunner.java

示例2: scoreDRMutations

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
/**
 * Scores the amount of drug resistance mutations.
 * @param service	the graph service
 */
private void scoreDRMutations(GraphDatabaseService service) {
	Map<String, Object> params = new HashMap<>(1);
	service.findNodes(NodeLabels.DRMUTATION).forEachRemaining(drannotations ->
		drannotations.getRelationships(RelTypes.ANNOTATED).forEach(node -> {
			// From the startref of the annotation
			// subtract the startref of the annotated node
			// and add the base distance of the annotated node
			int basedist = (int) drannotations.getProperty(AnnotationProperties.STARTREF.name())
				- (int) node.getStartNode().getProperty(SequenceProperties.STARTREF.name())
				+ (int) node.getStartNode().getProperty(SequenceProperties.BASE_DIST.name());

			params.put("dist", basedist);
			ResourceIterator<Node> mutations = service.execute(GET_NODES_BASEDIST, params)
								.columnAs(LABEL);
			mutations.forEachRemaining(m -> {
				int score = (int) m.getProperty(Scores.DR_MUT.name(), 0);
				m.setProperty(Scores.DR_MUT.name(), score + 1);
			});
		})
	);
}
 
开发者ID:ProgrammingLife2015,项目名称:dnainator,代码行数:26,代码来源:AnalyzeCommand.java

示例3: addAnnotation

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
@Override
public void addAnnotation(Annotation a) {
	Map<String, Object> parameters = new HashMap<>(2);
	parameters.put("from", a.getStart());
	parameters.put("to", a.getEnd());
	execute(e -> {
		Node annotation = e.createNode(NodeLabels.ANNOTATION);
		annotation.setProperty(AnnotationProperties.ID.name(), a.getGeneName());
		annotation.setProperty(AnnotationProperties.STARTREF.name(), a.getStart());
		annotation.setProperty(AnnotationProperties.ENDREF.name(), a.getEnd());
		annotation.setProperty(AnnotationProperties.SENSE.name(), a.isSense());

		ResourceIterator<Node> nodes = service.execute(GET_REF_RANGE, parameters).columnAs("n");
		nodes.forEachRemaining(n -> n.createRelationshipTo(annotation, RelTypes.ANNOTATED));
	});
}
 
开发者ID:ProgrammingLife2015,项目名称:dnainator,代码行数:17,代码来源:Neo4jGraph.java

示例4: snapshot

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
ResourceIterator<File> snapshot( File indexDir, LuceneIndexWriter writer ) throws IOException
{
    SnapshotDeletionPolicy deletionPolicy = (SnapshotDeletionPolicy) writer.getIndexDeletionPolicy();

    try
    {
        return new LuceneSnapshotIterator( indexDir, deletionPolicy.snapshot(), deletionPolicy );
    }
    catch(IllegalStateException e)
    {
        if(e.getMessage().equals( NO_INDEX_COMMIT_TO_SNAPSHOT ))
        {
            return emptyIterator();
        }
        throw e;
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:18,代码来源:LuceneSnapshotter.java

示例5: shouldReturnRealSnapshotIfIndexAllowsIt

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
@Test
public void shouldReturnRealSnapshotIfIndexAllowsIt() throws Exception
{
    // Given
    LuceneSnapshotter snapshotter = new LuceneSnapshotter();

    when(luceneSnapshot.getFileNames()).thenReturn( asList("a", "b") );

    // When
    ResourceIterator<File> snapshot = snapshotter.snapshot( indexDir, writer );

    // Then
    assertEquals( new File(indexDir, "a"), snapshot.next() );
    assertEquals( new File(indexDir, "b"), snapshot.next() );
    assertFalse( snapshot.hasNext() );
    snapshot.close();

    verify( snapshotPolicy ).release( any(IndexCommit.class) );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:20,代码来源:LuceneSnapshotterTest.java

示例6: shouldReturnEmptyIteratorWhenNoCommitsHaveBeenMade

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
@Test
public void shouldReturnEmptyIteratorWhenNoCommitsHaveBeenMade() throws Exception
{
    // Given
    LuceneSnapshotter snapshotter = new LuceneSnapshotter();

    when(luceneSnapshot.getFileNames()).thenThrow( new IllegalStateException( "No index commit to snapshot" ));

    // When
    ResourceIterator<File> snapshot = snapshotter.snapshot( indexDir, writer );

    // Then
    assertFalse( snapshot.hasNext() );
    snapshot.close();

    verify( snapshotPolicy ).snapshot();
    verifyNoMoreInteractions( snapshotPolicy );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:19,代码来源:LuceneSnapshotterTest.java

示例7: getNode

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
private Node getNode(Label label, String key, Object value) {
	Node node = null;
	try (Transaction tx = graphDb.beginTx()) {
		ResourceIterator<Node> nodes = null;
		if (label != null){
			nodes = graphDb.findNodesByLabelAndProperty(
				label, key, value).iterator();
		}
		else {
			String validValue = StringEscapeUtils.escapeJavaScript((String) value);
			ExecutionEngine engine = new ExecutionEngine(graphDb);
			nodes = engine.execute(
					"START n=node(*)"
					+ " WHERE n." + key + "=\"" + validValue + "\""
					+ " RETURN n").columnAs("n");
			
		}
		if (nodes.hasNext()) {
			node = nodes.next();
		}
		nodes.close();
	}
	return node;
}
 
开发者ID:5agado,项目名称:knowledge-extraction,代码行数:25,代码来源:Neo4JDb.java

示例8: runQueryComplexResult

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
public Map<String,List<Object>> runQueryComplexResult(NeoProfiler parent, String query, String...columns) {
	HashMap<String,List<Object>> all = new HashMap<String,List<Object>>();
	
	ExecutionEngine engine = new ExecutionEngine(parent.getDB());
	List<Object> retvals = new ArrayList<Object>();
	
	try ( Transaction tx = parent.getDB().beginTx() ) {
		// log.info(query);
		ExecutionResult result = engine.execute(query);
		
		ResourceIterator<Map<String,Object>> rows = result.iterator();
		
		while(rows.hasNext()) {
			Map<String,Object> row = rows.next();
			
			for(String col : columns) { 
				if(!all.containsKey(col)) all.put(col, new ArrayList<Object>());
				all.get(col).add(row.get(col));
			}
		}
		
		rows.close();
	} // End try
	
	return all;
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:27,代码来源:QueryRunner.java

示例9: runQuerySingleResult

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
public Object runQuerySingleResult(NeoProfiler parent, String query, String columnReturn) {		
	ExecutionEngine engine = new ExecutionEngine(parent.getDB());
	
	try ( Transaction tx = parent.getDB().beginTx() ) {
		// log.info(query);
		ExecutionResult result = engine.execute(query);
		ResourceIterator<Object> vals = result.columnAs(columnReturn);
					
		if(vals.hasNext()) {
			Object retval = vals.next();
			vals.close();
			return retval;
		} 
		
		return null;
	}		
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:18,代码来源:QueryRunner.java

示例10: findOrMakeNode

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
/**
 * This version of the findOrMakeNode method only uses the index (or
 * cache) to find the nodes, because they are roots of their own trees.
 */
protected Node findOrMakeNode(String propertyValue, Map<String, String> record) {
	// First look in the cache
	Node node = cachedRoots.get(propertyValue);
	if (node == null) {
		// Then use the schema index to find the node
		parameters.put(this.column.property, propertyValue);
		ResourceIterator<Object> resultIterator = engine.execute(queryString, parameters).columnAs("n");
		node = (Node) resultIterator.next();
		if (node == null) {
			// Finally make a new node if none found
			node = super.findOrMakeNode(propertyValue, record);
		}
		cachedRoots.put(propertyValue, node);
	}
	return node;
}
 
开发者ID:craigtaverner,项目名称:csvtreeloader,代码行数:21,代码来源:CSVTreeBuilder.java

示例11: find

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
@Override
protected <T> ResultIterable<T> find(EmbeddedLabel label, PropertyMetadata datastoreMetadata, Object datastoreValue) {
    String propertyName = datastoreMetadata.getName();
    ResourceIterator<Node> iterator = graphDatabaseService.findNodes(label.getDelegate(), propertyName, datastoreValue);
    return xoSession.toResult(new ResultIterator<EmbeddedNode>() {

        @Override
        public boolean hasNext() {
            return iterator.hasNext();
        }

        @Override
        public EmbeddedNode next() {
            return new EmbeddedNode(iterator.next());
        }

        @Override
        public void close() {
            iterator.close();
        }
    });
}
 
开发者ID:buschmais,项目名称:extended-objects,代码行数:23,代码来源:EmbeddedNeo4jRepository.java

示例12: bootstrap

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
@Test
public void bootstrap() throws URISyntaxException {
    GraphDatabaseService graphDatabaseService = new TestGraphDatabaseFactory().newImpermanentDatabase();
    XOUnit xoUnit = XOUnitBuilder.create("graphDb:///", Neo4jXOProvider.class, A.class).property(GraphDatabaseService.class.getName(), graphDatabaseService).create();
    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();
    }
}
 
开发者ID:buschmais,项目名称:extended-objects,代码行数:22,代码来源:GraphDbBootstrapTest.java

示例13: getOrCreate

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
public Node getOrCreate(String nodeId)
{
    Node result = null;

    try(final Transaction tx = ((GraphDatabaseAPI) neo4jGraph).tx().unforced().begin())
    {
        try
        {
            String queryString = "MERGE (n:Node {nodeId: {nodeId}}) RETURN n";
            Map<String, Object> parameters = new HashMap<String, Object>();
            parameters.put("nodeId", nodeId);
            ResourceIterator<Node> resultIterator = engine.execute(queryString, parameters).columnAs("n");
            result = resultIterator.next();
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get or create node " + nodeId, e);
        }
    }

    return result;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:25,代码来源:Neo4jSingleInsertion.java

示例14: run

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
@Override
	public void run() {
		try (Transaction tx = database.beginTx())
        {
			writer.write(HumanReadableFormatter.humanReadableTimeElapsed(System.currentTimeMillis() - start)+" - Warming up "+nodeLabel.toString()+" index...\n");
			writer.flush();
			int d = 0;
			
			ResourceIterator<Node> it = database.findNodes(nodeLabel);
			
            while (it.hasNext()) {
            	Node node = it.next();
//            	Boolean has_token_count = false;
            	for (String prop : node.getPropertyKeys()) {
            		node.getProperty(prop);
            	}
            	
            	for (Relationship in : node.getRelationships(Direction.INCOMING)) {
            		@SuppressWarnings("unused")
					Node other = in.getOtherNode(node);
//                	for (String prop : other.getPropertyKeys()) {
//                		other.getProperty(prop);
//                	}
            	}
            	d++;
            	if (d % 50000 == 0) {
            		writer.write(HumanReadableFormatter.humanReadableTimeElapsed(System.currentTimeMillis() - start)+" - "+nodeLabel.toString()+": read "+String.valueOf(d)+" nodes so far...\n");
    				writer.flush();
            	}
            }
			
			writer.write(HumanReadableFormatter.humanReadableTimeElapsed(System.currentTimeMillis() - start)+" - Finished warming up "+nodeLabel.toString()+" index.\n");
			writer.flush();
			
            tx.success();
        } catch (IOException e) {
			e.printStackTrace();
		}
	}
 
开发者ID:Taalmonsters,项目名称:WhiteLab2.0-Neo4J-Plugin,代码行数:40,代码来源:IndexWarmUp.java

示例15: getTotalTokenCount

import org.neo4j.graphdb.ResourceIterator; //导入依赖的package包/类
public Long getTotalTokenCount() {
	Long frequency = (long) 0;

	try ( Transaction ignored = database.beginTx(); ) {
		ResourceIterator<Node> it = database.findNodes(NodeLabel.NodeCounter);
		Node nodeCounter = it.next();
		Object count = nodeCounter.getProperty("word_token_count");
		if (count instanceof Integer)
			frequency = frequency + new Long((Integer) count);
		else if (count instanceof Long)
			frequency = frequency + (Long) count;
	}
	
	return frequency;
}
 
开发者ID:Taalmonsters,项目名称:WhiteLab2.0-Neo4J-Plugin,代码行数:16,代码来源:CypherExecutor.java


注:本文中的org.neo4j.graphdb.ResourceIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。