本文整理了Java中org.neo4j.graphdb.Node.getPropertyKeys()
方法的一些代码示例,展示了Node.getPropertyKeys()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getPropertyKeys()
方法的具体详情如下:
包路径:org.neo4j.graphdb.Node
类名称:Node
方法名:getPropertyKeys
暂无
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeAbleToRemoveNodeProperties() throws Exception
{
Map<String, Object> properties = new HashMap<>();
properties.put( "foo", "bar" );
properties.put( "number", 15 );
long nodeId = createNode( properties );
actions.removeAllNodeProperties( nodeId );
try ( Transaction tx = database.getGraph().beginTx() )
{
Node node = database.getGraph().getNodeById( nodeId );
assertFalse( node.getPropertyKeys().iterator().hasNext() );
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testNodeGetProperties()
{
Node node1 = getGraphDb().getNodeById( node1Id );
assertTrue( !node1.hasProperty( null ) );
Iterator<String> keys = node1.getPropertyKeys().iterator();
keys.next();
keys.next();
assertTrue( node1.hasProperty( key1 ) );
assertTrue( node1.hasProperty( key2 ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void removingPropertyDoesNotBreakPreviouslyCreatedNodePropertyKeysIterator()
{
// GIVEN
GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try ( Transaction tx = db.beginTx() )
{
Node node = db.createNode();
node.setProperty( "name", "Horst" );
node.setProperty( "age", "72" );
Iterator<String> iterator = node.getPropertyKeys().iterator();
while ( iterator.hasNext() )
{
node.removeProperty( iterator.next() );
}
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
for ( String key : node.getPropertyKeys() )
代码示例来源:origin: neo4j/neo4j
for ( String key : node.getPropertyKeys() )
代码示例来源:origin: neo4j/neo4j
for ( String key : node.getPropertyKeys() )
代码示例来源:origin: neo4j/neo4j
for ( Node node : db.getAllNodes() )
for ( String key : node.getPropertyKeys() )
代码示例来源:origin: neo4j/neo4j
for ( String key : node.getPropertyKeys() )
代码示例来源:origin: neo4j/neo4j
for ( String key : node.getPropertyKeys() )
代码示例来源:origin: neo4j/neo4j
private void changeRandomNode( GraphDatabaseService db, int nodeCount, RandomValues random )
{
try ( Transaction tx = db.beginTx() )
{
long nodeId = random.nextInt( nodeCount );
Node node = db.getNodeById( nodeId );
Object[] keys = Iterables.asCollection( node.getPropertyKeys() ).toArray();
String key = (String) random.among( keys );
if ( random.nextFloat() < 0.1 )
{ // REMOVE
node.removeProperty( key );
}
else
{ // CHANGE
node.setProperty( key, random.nextValue().asObject() );
}
tx.success();
}
catch ( NotFoundException e )
{ // It's OK, it happens if some other thread deleted that property in between us reading it and
// removing or setting it
}
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
public static String filterCaption(Node n, Set<String> captions, BiPredicate<String, String> predicate) {
for (String caption : captions) {
for (String key : n.getPropertyKeys()) {
if (predicate.test(key, caption))
return n.getProperty(key).toString();
}
}
return null;
}
}
代码示例来源:origin: neo4j/neo4j
node1.setProperty( key2, int2 );
node1.setProperty( key3, string );
Iterator<String> keys = node1.getPropertyKeys().iterator();
keys.next();
keys.next();
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Override
public String statementForNode(Node node, Map<String, String> uniqueConstraints, Set<String> indexedProperties, Set<String> indexNames) {
StringBuilder result = new StringBuilder(100);
result.append("CREATE (");
String labels = CypherFormatterUtils.formatAllLabels(node, uniqueConstraints, indexNames);
if (!labels.isEmpty()) {
result.append(labels);
}
if (node.getPropertyKeys().iterator().hasNext()) {
result.append(" {");
result.append(CypherFormatterUtils.formatNodeProperties("", node, uniqueConstraints, indexNames, true));
result.append("}");
}
result.append(");");
return result.toString();
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
protected String mergeStatementForNode(CypherFormat cypherFormat, Node node, Map<String, String> uniqueConstraints, Set<String> indexedProperties, Set<String> indexNames) {
StringBuilder result = new StringBuilder(1000);
result.append("MERGE ");
result.append(CypherFormatterUtils.formatNodeLookup("n", node, uniqueConstraints, indexNames));
if (node.getPropertyKeys().iterator().hasNext()) {
String notUniqueProperties = CypherFormatterUtils.formatNotUniqueProperties("n", node, uniqueConstraints, indexedProperties, false);
String notUniqueLabels = CypherFormatterUtils.formatNotUniqueLabels("n", node, uniqueConstraints);
if (!"".equals(notUniqueProperties) || !"".equals(notUniqueLabels)) {
result.append(cypherFormat.equals(CypherFormat.ADD_STRUCTURE) ? " ON CREATE SET " : " SET ");
result.append(notUniqueProperties);
result.append(!"".equals(notUniqueProperties) && !"".equals(notUniqueLabels) ? ", " : "");
result.append(notUniqueLabels);
}
}
result.append(";");
return result.toString();
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
private void add(Node node) {
count++;
int degree = node.getDegree();
sumDegree += degree;
if (degree > maxDegree) maxDegree = degree;
if (degree < minDegree) minDegree = degree;
for (Label label : node.getLabels()) labels.add(label.name());
for (String key : node.getPropertyKeys()) properties.add(key);
}
Map<String,Object> toMap() {
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
public static String getCaption(Node n, Set<String> captions) {
for (String caption : captions) { //first do one loop with the exact names
if (n.hasProperty(caption))
return n.getProperty(caption).toString();
}
String result = filterCaption(n, captions, (key, caption) -> key.equalsIgnoreCase(caption)); //2nd loop with lowercase
if (result == null) {
result = filterCaption(n, captions, (key, caption) -> key.toLowerCase().contains(caption) || key.toLowerCase().endsWith(caption)); //3rd loop with contains or endsWith
if (result == null) {
Iterator<String> iterator = n.getPropertyKeys().iterator();
if (iterator.hasNext()) {
result = n.getProperty(iterator.next()).toString(); // get the first property
}
}
}
return result == null ? String.valueOf(n.getId()) : result; // if the node has no property return the ID
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
private String caption(Node n) {
for (String caption : CAPTIONS) {
if (n.hasProperty(caption)) return n.getProperty(caption).toString();
}
String first=null;
for (String caption : CAPTIONS) {
for (String key : n.getPropertyKeys()) {
if (first==null) first = key;
if (key.toLowerCase().contains(caption)) return n.getProperty(key).toString();
}
}
return first == null ? idStr(n) : n.getProperty(first).toString();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void lazyLoadWithinWriteTransaction() throws Exception
{
// Given
FileSystemAbstraction fileSystem = fs.get();
BatchInserter inserter = BatchInserters.inserter( testDirectory.databaseDir(), fileSystem );
int count = 3000;
long nodeId = inserter.createNode( mapWithManyProperties( count /* larger than initial property index load threshold */ ) );
inserter.shutdown();
GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem( fileSystem ).newImpermanentDatabase( testDirectory.databaseDir() );
// When
try ( Transaction tx = db.beginTx() )
{
db.createNode();
Node node = db.getNodeById( nodeId );
// Then
assertEquals( count, Iterables.count( node.getPropertyKeys() ) );
tx.success();
}
finally
{
db.shutdown();
}
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
private void iterateLabelChanges(Stream<LabelEntry> stream, IndexFunction<Index<Node>, Node, String, Object, Void> function) {
stream.forEach(labelEntry -> {
final String labelName = labelEntry.label().name();
final Map<String, Collection<Index<Node>>> propertyIndicesMap = indexesByLabelAndProperty.get(labelName);
if (propertyIndicesMap != null) {
final Node entity = labelEntry.node();
for (String key : entity.getPropertyKeys()) {
Collection<Index<Node>> indices = propertyIndicesMap.get(key);
if (indices != null) {
for (Index<Node> index : indices) {
Object value = entity.getProperty(key);
String indexKey = labelName + "." + key;
function.apply(index, entity, indexKey, value, null);
}
}
}
}
});
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
private void appendNode(PrintWriter out, Node node, Reporter reporter) {
artificialUniques += countArtificialUniques(node);
String cypher = this.cypherFormat.statementForNode(node, uniqueConstraints, indexedProperties, indexNames);
if (Util.isNotNullOrEmpty(cypher)) {
out.println(cypher);
reporter.update(1, 0, Iterables.count(node.getPropertyKeys()));
}
}
内容来源于网络,如有侵权,请联系作者删除!