org.neo4j.graphdb.Node.getPropertyKeys()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(259)

本文整理了Java中org.neo4j.graphdb.Node.getPropertyKeys()方法的一些代码示例,展示了Node.getPropertyKeys()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getPropertyKeys()方法的具体详情如下:
包路径:org.neo4j.graphdb.Node
类名称:Node
方法名:getPropertyKeys

Node.getPropertyKeys介绍

暂无

代码示例

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void shouldBeAbleToRemoveNodeProperties() throws Exception
  3. {
  4. Map<String, Object> properties = new HashMap<>();
  5. properties.put( "foo", "bar" );
  6. properties.put( "number", 15 );
  7. long nodeId = createNode( properties );
  8. actions.removeAllNodeProperties( nodeId );
  9. try ( Transaction tx = database.getGraph().beginTx() )
  10. {
  11. Node node = database.getGraph().getNodeById( nodeId );
  12. assertFalse( node.getPropertyKeys().iterator().hasNext() );
  13. tx.success();
  14. }
  15. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void testNodeGetProperties()
  3. {
  4. Node node1 = getGraphDb().getNodeById( node1Id );
  5. assertTrue( !node1.hasProperty( null ) );
  6. Iterator<String> keys = node1.getPropertyKeys().iterator();
  7. keys.next();
  8. keys.next();
  9. assertTrue( node1.hasProperty( key1 ) );
  10. assertTrue( node1.hasProperty( key2 ) );
  11. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void removingPropertyDoesNotBreakPreviouslyCreatedNodePropertyKeysIterator()
  3. {
  4. // GIVEN
  5. GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
  6. try ( Transaction tx = db.beginTx() )
  7. {
  8. Node node = db.createNode();
  9. node.setProperty( "name", "Horst" );
  10. node.setProperty( "age", "72" );
  11. Iterator<String> iterator = node.getPropertyKeys().iterator();
  12. while ( iterator.hasNext() )
  13. {
  14. node.removeProperty( iterator.next() );
  15. }
  16. tx.success();
  17. }
  18. }

代码示例来源:origin: neo4j/neo4j

  1. for ( String key : node.getPropertyKeys() )

代码示例来源:origin: neo4j/neo4j

  1. for ( String key : node.getPropertyKeys() )

代码示例来源:origin: neo4j/neo4j

  1. for ( String key : node.getPropertyKeys() )

代码示例来源:origin: neo4j/neo4j

  1. for ( Node node : db.getAllNodes() )
  2. for ( String key : node.getPropertyKeys() )

代码示例来源:origin: neo4j/neo4j

  1. for ( String key : node.getPropertyKeys() )

代码示例来源:origin: neo4j/neo4j

  1. for ( String key : node.getPropertyKeys() )

代码示例来源:origin: neo4j/neo4j

  1. private void changeRandomNode( GraphDatabaseService db, int nodeCount, RandomValues random )
  2. {
  3. try ( Transaction tx = db.beginTx() )
  4. {
  5. long nodeId = random.nextInt( nodeCount );
  6. Node node = db.getNodeById( nodeId );
  7. Object[] keys = Iterables.asCollection( node.getPropertyKeys() ).toArray();
  8. String key = (String) random.among( keys );
  9. if ( random.nextFloat() < 0.1 )
  10. { // REMOVE
  11. node.removeProperty( key );
  12. }
  13. else
  14. { // CHANGE
  15. node.setProperty( key, random.nextValue().asObject() );
  16. }
  17. tx.success();
  18. }
  19. catch ( NotFoundException e )
  20. { // It's OK, it happens if some other thread deleted that property in between us reading it and
  21. // removing or setting it
  22. }
  23. }

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

  1. public static String filterCaption(Node n, Set<String> captions, BiPredicate<String, String> predicate) {
  2. for (String caption : captions) {
  3. for (String key : n.getPropertyKeys()) {
  4. if (predicate.test(key, caption))
  5. return n.getProperty(key).toString();
  6. }
  7. }
  8. return null;
  9. }
  10. }

代码示例来源:origin: neo4j/neo4j

  1. node1.setProperty( key2, int2 );
  2. node1.setProperty( key3, string );
  3. Iterator<String> keys = node1.getPropertyKeys().iterator();
  4. keys.next();
  5. keys.next();

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

  1. @Override
  2. public String statementForNode(Node node, Map<String, String> uniqueConstraints, Set<String> indexedProperties, Set<String> indexNames) {
  3. StringBuilder result = new StringBuilder(100);
  4. result.append("CREATE (");
  5. String labels = CypherFormatterUtils.formatAllLabels(node, uniqueConstraints, indexNames);
  6. if (!labels.isEmpty()) {
  7. result.append(labels);
  8. }
  9. if (node.getPropertyKeys().iterator().hasNext()) {
  10. result.append(" {");
  11. result.append(CypherFormatterUtils.formatNodeProperties("", node, uniqueConstraints, indexNames, true));
  12. result.append("}");
  13. }
  14. result.append(");");
  15. return result.toString();
  16. }

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

  1. protected String mergeStatementForNode(CypherFormat cypherFormat, Node node, Map<String, String> uniqueConstraints, Set<String> indexedProperties, Set<String> indexNames) {
  2. StringBuilder result = new StringBuilder(1000);
  3. result.append("MERGE ");
  4. result.append(CypherFormatterUtils.formatNodeLookup("n", node, uniqueConstraints, indexNames));
  5. if (node.getPropertyKeys().iterator().hasNext()) {
  6. String notUniqueProperties = CypherFormatterUtils.formatNotUniqueProperties("n", node, uniqueConstraints, indexedProperties, false);
  7. String notUniqueLabels = CypherFormatterUtils.formatNotUniqueLabels("n", node, uniqueConstraints);
  8. if (!"".equals(notUniqueProperties) || !"".equals(notUniqueLabels)) {
  9. result.append(cypherFormat.equals(CypherFormat.ADD_STRUCTURE) ? " ON CREATE SET " : " SET ");
  10. result.append(notUniqueProperties);
  11. result.append(!"".equals(notUniqueProperties) && !"".equals(notUniqueLabels) ? ", " : "");
  12. result.append(notUniqueLabels);
  13. }
  14. }
  15. result.append(";");
  16. return result.toString();
  17. }

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

  1. private void add(Node node) {
  2. count++;
  3. int degree = node.getDegree();
  4. sumDegree += degree;
  5. if (degree > maxDegree) maxDegree = degree;
  6. if (degree < minDegree) minDegree = degree;
  7. for (Label label : node.getLabels()) labels.add(label.name());
  8. for (String key : node.getPropertyKeys()) properties.add(key);
  9. }
  10. Map<String,Object> toMap() {

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

  1. public static String getCaption(Node n, Set<String> captions) {
  2. for (String caption : captions) { //first do one loop with the exact names
  3. if (n.hasProperty(caption))
  4. return n.getProperty(caption).toString();
  5. }
  6. String result = filterCaption(n, captions, (key, caption) -> key.equalsIgnoreCase(caption)); //2nd loop with lowercase
  7. if (result == null) {
  8. result = filterCaption(n, captions, (key, caption) -> key.toLowerCase().contains(caption) || key.toLowerCase().endsWith(caption)); //3rd loop with contains or endsWith
  9. if (result == null) {
  10. Iterator<String> iterator = n.getPropertyKeys().iterator();
  11. if (iterator.hasNext()) {
  12. result = n.getProperty(iterator.next()).toString(); // get the first property
  13. }
  14. }
  15. }
  16. return result == null ? String.valueOf(n.getId()) : result; // if the node has no property return the ID
  17. }

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

  1. private String caption(Node n) {
  2. for (String caption : CAPTIONS) {
  3. if (n.hasProperty(caption)) return n.getProperty(caption).toString();
  4. }
  5. String first=null;
  6. for (String caption : CAPTIONS) {
  7. for (String key : n.getPropertyKeys()) {
  8. if (first==null) first = key;
  9. if (key.toLowerCase().contains(caption)) return n.getProperty(key).toString();
  10. }
  11. }
  12. return first == null ? idStr(n) : n.getProperty(first).toString();
  13. }
  14. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void lazyLoadWithinWriteTransaction() throws Exception
  3. {
  4. // Given
  5. FileSystemAbstraction fileSystem = fs.get();
  6. BatchInserter inserter = BatchInserters.inserter( testDirectory.databaseDir(), fileSystem );
  7. int count = 3000;
  8. long nodeId = inserter.createNode( mapWithManyProperties( count /* larger than initial property index load threshold */ ) );
  9. inserter.shutdown();
  10. GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem( fileSystem ).newImpermanentDatabase( testDirectory.databaseDir() );
  11. // When
  12. try ( Transaction tx = db.beginTx() )
  13. {
  14. db.createNode();
  15. Node node = db.getNodeById( nodeId );
  16. // Then
  17. assertEquals( count, Iterables.count( node.getPropertyKeys() ) );
  18. tx.success();
  19. }
  20. finally
  21. {
  22. db.shutdown();
  23. }
  24. }

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

  1. private void iterateLabelChanges(Stream<LabelEntry> stream, IndexFunction<Index<Node>, Node, String, Object, Void> function) {
  2. stream.forEach(labelEntry -> {
  3. final String labelName = labelEntry.label().name();
  4. final Map<String, Collection<Index<Node>>> propertyIndicesMap = indexesByLabelAndProperty.get(labelName);
  5. if (propertyIndicesMap != null) {
  6. final Node entity = labelEntry.node();
  7. for (String key : entity.getPropertyKeys()) {
  8. Collection<Index<Node>> indices = propertyIndicesMap.get(key);
  9. if (indices != null) {
  10. for (Index<Node> index : indices) {
  11. Object value = entity.getProperty(key);
  12. String indexKey = labelName + "." + key;
  13. function.apply(index, entity, indexKey, value, null);
  14. }
  15. }
  16. }
  17. }
  18. });
  19. }

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

  1. private void appendNode(PrintWriter out, Node node, Reporter reporter) {
  2. artificialUniques += countArtificialUniques(node);
  3. String cypher = this.cypherFormat.statementForNode(node, uniqueConstraints, indexedProperties, indexNames);
  4. if (Util.isNotNullOrEmpty(cypher)) {
  5. out.println(cypher);
  6. reporter.update(1, 0, Iterables.count(node.getPropertyKeys()));
  7. }
  8. }

相关文章