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


Java DynamicLabel.label方法代码示例

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


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

示例1: computeLabels

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
protected Label[] computeLabels(Object incoming) throws IllegalAccessException {
    Label[] labels = new Label[0];

    if (StringUtils.isNotEmpty(this.labelsField)) {

        String labelList = (String) this.getObjectProperty(incoming, this.labelsField);

        if (StringUtils.isNotEmpty(labelList)) {
            String[] labelTab = labelList.split(";");
            labels = new Label[labelTab.length];
            for (int i = 0; i < labelTab.length; i++) {
                labels[i] = DynamicLabel.label(labelTab[i]);
            }
        }
    }

    return labels;
}
 
开发者ID:sim51,项目名称:neo4j-talend-component,代码行数:19,代码来源:Neo4jBatchInserterNode.java

示例2: add

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public final Node add(Map<String, Object> properties, String... types) {
	if (null == properties)
		throw new IllegalArgumentException("Illegal 'properties' argument in Problem.add(Map<String, Object>, String...): " + properties);
	if (null == types)
		throw new IllegalArgumentException("Illegal 'types' argument in Problem.add(Map<String, Object>, String...): " + types);
	Node result = null;
	try (Transaction tx = graph.beginTx()) {
		int i = 0;
		Label[] labels = new Label[types.length];
		for (String type : types) {
			labels[i++] = DynamicLabel.label(type);
		}
		result = graph.createNode(labels);
		for (String property : properties.keySet())
			result.setProperty(property, properties.get(property));
		tx.success();
	}
	return result;
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:20,代码来源:Problem.java

示例3: addLabel

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
private void addLabel(final Node node, final String labelString) {

		final Label label = DynamicLabel.label(labelString);
		boolean hit = false;
		final Iterable<Label> labels = node.getLabels();

		for (final Label lbl : labels) {

			if (label.equals(lbl)) {

				hit = true;
				break;
			}
		}

		if (!hit) {

			node.addLabel(label);
			addedLabels++;
		}
	}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:22,代码来源:Neo4jDeltaGDMHandler.java

示例4: PropertyEnrichGDMWorker

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public PropertyEnrichGDMWorker(final String prefixedResourceUriArg, final long resourceHashArg, final GraphDatabaseService databaseArg, final
NamespaceIndex namespaceIndexArg) throws DMPGraphException {

	prefixedResourceUri = prefixedResourceUriArg;
	resourceHash = resourceHashArg;
	database = databaseArg;
	namespaceIndex = namespaceIndexArg;
	nodeHandler = new CBDNodeHandler();
	startNodeHandler = new CBDStartNodeHandler();
	relationshipHandler = new CBDRelationshipHandler();

	final String prefixedRDFTypeURI = namespaceIndex.createPrefixedURI(RDF.type.getURI());
	final String prefixedRDFSClassURI = namespaceIndex.createPrefixedURI(RDFS.Class.getURI());

	prefixedRDFType = DynamicRelationshipType.withName(prefixedRDFTypeURI);
	prefixedRDFSClass = DynamicLabel.label(prefixedRDFSClassURI);
}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:18,代码来源:PropertyEnrichGDMWorker.java

示例5: createVertexBatchMode

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
/**
 * used when creating nodes in batch mode
 * 
 * @param id
 * @param name
 * @param columnNames
 * @param values
 * @return
 * @throws IOException
 */
private long createVertexBatchMode(double id, String name, List<String> columnNames, List<String> values) throws IOException {
	Label entityLabel = DynamicLabel.label(name);
	//getCurrentInserter().createDeferredSchemaIndex(entityLabel).on(_ID_PROPERTY).create();

	Map<String, Object> properties = new HashMap<String, Object>();
	properties.put(_ID_PROPERTY, id);

	// fill out the properties in the columns
	for (int i = 0; i < columnNames.size(); i++) {
		String value = EMPTY_STRING;
		if (values != null && values.size() > i) {
			value = values.get(i);
		}
		properties.put(columnNames.get(i), value);
	}

	return getCurrentInserter().createNode(properties, entityLabel);
}
 
开发者ID:tchico,项目名称:dgMaster-trunk,代码行数:29,代码来源:EntityEventNodeNeo4j.java

示例6: getAllNodes

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public static List<String> getAllNodes(final GraphDatabaseService graphDb,
                                       final String labelName) {

    List<String> nodeIds = new ArrayList<>();
    Label label = DynamicLabel.label(labelName);
    ResourceIterable<Node> nodes;

    try (Transaction tx = graphDb.beginTx()) {
        nodes = GlobalGraphOperations.at(graphDb).getAllNodesWithLabel(label);

        for (Node node : nodes) {
            try {
                nodeIds.add(node.getProperty("node_id").toString());
            } catch (Exception e) {
                LOGGER.warn("Can't find a given node... skipping");
            }
        }

        tx.success();
    }

    return nodeIds;

}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:25,代码来源:NeoHelpers.java

示例7: insertTriplet

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public void insertTriplet(TripletRelation triplet, boolean mergeSubject) {
	final Label label_sub = DynamicLabel.label(LAB_SUBJECT);
	final Label label_obj = DynamicLabel.label(LAB_OBJECT);

	Node arg1 = null;
	if (mergeSubject) {
		arg1 = getNode(null, PROP_NAME, triplet.getArg1()
				.toLowerCase());
	}

	try (Transaction tx = graphDb.beginTx()) {
		if (arg1 == null) {
			arg1 = graphDb.createNode(label_sub);
			arg1.setProperty(PROP_OCCURRENCES, 1);
			arg1.setProperty(PROP_NAME, triplet.getArg1().toLowerCase());
		} else {
			int occurences = (Integer) arg1.getProperty(PROP_OCCURRENCES) + 1;
			arg1.setProperty(PROP_OCCURRENCES, occurences);
		}
		Node arg2 = graphDb.createNode(label_obj);
		arg2.setProperty(PROP_OCCURRENCES, 1);
		arg2.setProperty(PROP_NAME, triplet.getArg2().toLowerCase());

		Relationship relationship = arg1.createRelationshipTo(arg2,
				RelTypes.RELATES);
		relationship.setProperty(PROP_NAME, triplet.getRelation()
				.toLowerCase());
		//confidence
		relationship.setProperty(PROP_CONFIDENCE, triplet.getConfidence());
		tx.success();
	}
}
 
开发者ID:5agado,项目名称:knowledge-extraction,代码行数:33,代码来源:Neo4JDb.java

示例8: getLabel

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
private Label getLabel(String name) {
    if (labelCache.containsKey(name)) {
        return labelCache.get(name);
    } else {
        Label label = DynamicLabel.label(name);
        labelCache.put(name, label);
        return label;
    }
}
 
开发者ID:technige,项目名称:zerograph,代码行数:10,代码来源:Database.java

示例9: GraphTest

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public GraphTest() {
		graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("./database/");
		Transaction tx = graphDb.beginTx();		
		Label label = DynamicLabel.label( "message" );
		
//		firstNode = graphDb.createNode();
//		firstNode.setProperty( "message", "Hello, " );
//		secondNode = graphDb.createNode();
//		secondNode.setProperty( "message", "World!" );
//
//		relationship = firstNode.createRelationshipTo( secondNode, RelTypes.KNOWS );
//		relationship.setProperty( "message", "brave Neo4j " );
//		
//		System.out.print( firstNode.getProperty( "message" ) );
//		System.out.print( relationship.getProperty( "message" ) );
//		System.out.print( secondNode.getProperty( "message" ) );
//				
//		firstNode.getSingleRelationship( RelTypes.KNOWS, Direction.OUTGOING ).delete();
//		firstNode.delete();
//		secondNode.delete();
		
		ResourceIterator<Node> users = graphDb
	            .findNodesByLabelAndProperty( label, "message", "Hello, " )
	            .iterator();
		
		Node firstUserNode;
	    if ( users.hasNext() )
	    {
	        firstUserNode = users.next();
	        System.out.println("test: " + firstUserNode.getProperty("message"));
	    }
	    users.close();
	    
		tx.success();
		graphDb.shutdown();
	}
 
开发者ID:drossner,项目名称:WikiN-G-ER,代码行数:37,代码来源:GraphTest.java

示例10: createLabel

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public Label createLabel(String label){
	Label l = null;
	try ( Transaction tx = db.beginTx(); ){
		l = DynamicLabel.label(label);
		tx.close();
	}
	
	return l;
	
}
 
开发者ID:PhenoImageShare,项目名称:PhenoImageShare,代码行数:11,代码来源:Neo4jAccessUtils.java

示例11: ColumnSpec

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public ColumnSpec(String columnSpec) throws UnsupportedEncodingException {
	String[] headerSpec = columnSpec.split("\\.");
	this.name = URLDecoder.decode(headerSpec[0],"US-ASCII");
	this.property = field(headerSpec, 1, this.name.toLowerCase().replaceAll("\\s+", "_"));
	String defaultLabelName = StringUtils.capitalize(this.name).replaceAll("\\s+", "");
	this.label = DynamicLabel.label(field(headerSpec, 2, defaultLabelName));
	this.properties = field(headerSpec, 3, null);
}
 
开发者ID:craigtaverner,项目名称:csvtreeloader,代码行数:9,代码来源:CSVTreeBuilder.java

示例12: importLabels

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public void importLabels(File dbPath, final File file) throws IOException {
        log.info("Importing {} ({} KiB) to {} ...", file, NUMBER.format(DefaultGroovyMethods.asType(file.length() / 1024, Long.class)), dbPath);
        long importeds = 0l;

        final BatchInserter inserter = BatchInserters.inserter(dbPath);
        try {
            final Label resourceLabel = DynamicLabel.label("Resource");
            final Label labelLabel = DynamicLabel.label("Label");
            inserter.createDeferredConstraint(resourceLabel).assertPropertyIsUnique("href").create();

            // PLEASE create the label indexes on last step, not now! to speed up imports on later stages
//            inserter.createDeferredSchemaIndex(resourceLabel).on('prefLabel').create()
//            inserter.createDeferredSchemaIndex(resourceLabel).on('isPreferredMeaningOf').create()
//            inserter.createDeferredSchemaIndex(labelLabel).on('v').create()

            final DynamicRelationshipType rdfsLabel = DynamicRelationshipType.withName("rdfs_label");

            try (final Scanner scanner = new Scanner(file, StandardCharsets.UTF_8.name())) {
                scanner.useDelimiter("\u0001");// Ctrl+A (SOH)
                while (true) {
                    final Object line;
                    try {
                        line = scanner.next();
                    } catch (NoSuchElementException ex) {
                        break;
                    }

                    final IndexedResource res = mapper.readValue((String) line, IndexedResource.class);
                    if (res.getPrefLabel() == null && res.getLabels() != null && !res.getLabels().isEmpty()) {
                        res.setPrefLabel(res.getLabels().get(0).getValue());
                        res.getLabels().remove(0);
                    }

                    final Map<String, Object> props = new HashMap<>();
                    if (res.getPrefLabel() != null) {
                        props.put("prefLabel", res.getPrefLabel());
                    }

                    if (res.getIsPreferredMeaningOf() != null) {
                        props.put("isPreferredMeaningOf", res.getIsPreferredMeaningOf());
                    }

                    final long resNode = inserter.createNode(props, resourceLabel);
                    for (IndexedResource.LocalizedLabel it : res.getLabels()) {
                        final Map<String, Object> labelProps = new HashMap<>();

                        if (it.getLanguage() != null) {
                            labelProps.put("l", it.getLanguage());
                        }

                        final long labelNode = inserter.createNode(labelProps, labelLabel);
                        inserter.createRelationship(resNode, labelNode, rdfsLabel, new LinkedHashMap());
                    }
                    importeds++;

                    if (importeds % 10000 == 0) {
                        log.info("Imported {} resource nodes +prefLabel +isPreferredMeaningOf +label relationships from {}", NUMBER.format(importeds), file);
                    }

                }

            }
        } catch (Exception e) {
            throw new RuntimeException("Cannot process", e);
        } finally {
            log.info("Shutting down batchInserter after importing {} resource nodes from {} ...", NUMBER.format(importeds), file);
            inserter.shutdown();
        }

        log.info("Completed importing {} resource nodes +prefLabel +isPreferredMeaningOf +label relationships from {}", NUMBER.format(importeds), file);
    }
 
开发者ID:lumenrobot,项目名称:lumen,代码行数:72,代码来源:LumenPersistenceImportLabelsApp.java

示例13: createLabel

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public static Label createLabel(final String s) {
	Label a = DynamicLabel.label(s);
	return a;
}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:5,代码来源:Neo4JBatchUtil.java

示例14: importDb

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
private void importDb(final GraphDatabaseService graphDb) {
        Label packageLabel = DynamicLabel.label("Package" );
        Label javaLabel = DynamicLabel.label("Java" );
        Label plantUmlLabel = DynamicLabel.label("PlantUml" );
        try ( Transaction tx = graphDb.beginTx() )
        {
            Node firstNode;
            Node secondNode;

            // create X Java dependencies
            for(int i = 0; i < 100000; i++) {
                firstNode = graphDb.createNode(packageLabel, javaLabel);
                firstNode.setProperty( "fqn", "p1_"+i );
                secondNode = graphDb.createNode(packageLabel, javaLabel);
                secondNode.setProperty( "fqn", "p2_"+i );
                firstNode.createRelationshipTo(secondNode, RelTypes.DEPENDS_ON);
            }

            // create X PlantUml dependencies correct direction
            for(int i = 0; i < 1000; i++) {
                firstNode = graphDb.createNode(packageLabel, plantUmlLabel);
                firstNode.setProperty( "fqn", "p1_"+i );
                secondNode = graphDb.createNode(packageLabel, plantUmlLabel);
                secondNode.setProperty( "fqn", "p2_"+i );
                firstNode.createRelationshipTo(secondNode, RelTypes.MAY_DEPEND_ON);
            }
            // create X PlantUml dependencies wrong direction
            for(int i = 0; i < 10; i++) {
                firstNode = graphDb.createNode(packageLabel, plantUmlLabel);
                firstNode.setProperty( "fqn", "p2_"+i );
                secondNode = graphDb.createNode(packageLabel, plantUmlLabel);
                secondNode.setProperty( "fqn", "p1_"+i );
                firstNode.createRelationshipTo(secondNode, RelTypes.MAY_DEPEND_ON);
            }
            tx.success();
        }

/*
        try ( Transaction tx = graphDb.beginTx() )
        {
            graphDb.schema().indexFor(packageLabel )
                    .on( "fqn" )
                    .create();
            tx.success();
        }
*/
    }
 
开发者ID:kontext-e,项目名称:jqassistant-plugins,代码行数:48,代码来源:PerformanceIT.java

示例15: run

import org.neo4j.graphdb.DynamicLabel; //导入方法依赖的package包/类
public static void run(final String neo4storage,
        final String redisQueueName, final String redisHost) {

    ObelixQueue redisQueueManager = new RedisObelixQueue(redisQueueName, redisHost);

    Label userLabel = DynamicLabel.label("User");
    Label itemLabel = DynamicLabel.label("Item");

    Map<String, Long> usersNodesMap = new HashMap<>();
    Map<String, Long> itemsNodesMap = new HashMap<>();
    Map<String, Long> relationshipsMap = new HashMap<>();

    Map<String, String> config = new HashMap<>();
    config.put("neostore.nodestore.db.mapped_memory", "2G");
    config.put("neostore.relationshipstore.db.mapped_memory", "9G");
    config.put("neostore.propertystore.db.mapped_memory", "800M");
    config.put("neostore.propertystore.db.strings.mapped_memory", "800M");
    config.put("neostore.propertystore.db.arrays.mapped_memory", "500M");

    BatchInserter inserter;

    inserter = BatchInserters.inserter(neo4storage, config);

    BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(inserter);

    registerShutdownHook(inserter, indexProvider);

    BatchInserterIndex usersIndex = indexProvider.nodeIndex("users",
            MapUtil.stringMap("type", "exact"));
    usersIndex.setCacheCapacity("node_id", NEO_CACHE_CAPACITY);

    BatchInserterIndex itemsIndex = indexProvider.nodeIndex("items",
            MapUtil.stringMap("type", "exact"));
    usersIndex.setCacheCapacity("node_id", NEO_CACHE_CAPACITY);

    BatchInserterIndex relationshipIndex = indexProvider.relationshipIndex("relationships",
            MapUtil.stringMap("type", "exact"));
    usersIndex.setCacheCapacity("timestamp", NEO_CACHE_CAPACITY);

    boolean notFinised = true;

    int c = 0;
    while (notFinised) {

        ObelixQueueElement result = redisQueueManager.pop();

        if (result == null) {
            notFinised = false;
        }

        if (result != null) {

            NeoEvent event = getEvent(result.toString());

            if (event == null) {
                continue;
            }

            long userid = getOrCreateUserNodeID(event.getUser(), usersNodesMap,
                    usersIndex, inserter, userLabel);

            long itemid = getOrCreateItemNodeID(event.getItem(), itemsNodesMap,
                    itemsIndex, inserter, itemLabel);


            getOrCreateRelatinshipID(event.getTimestamp(),
                    userid, itemid, relationshipsMap, relationshipIndex,
                    inserter, NeoHelpers.RelTypes.VIEWED);

        }

        c += 1;

        if (c % IMPORTS_BETWEEN_EACH_LOG_MESSAGE == 0) {
            LOGGER.info("Imported " + c);
        }
    }
}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:79,代码来源:ObelixBatchImport.java


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