Search in sources :

Example 1 with PrimitiveIntIterator

use of org.neo4j.collection.primitive.PrimitiveIntIterator in project neo4j by neo4j.

the class GraphPropertiesProxy method getPropertyKeys.

@Override
public Iterable<String> getPropertyKeys() {
    try (Statement statement = actions.statement()) {
        List<String> keys = new ArrayList<>();
        PrimitiveIntIterator properties = statement.readOperations().graphGetPropertyKeys();
        while (properties.hasNext()) {
            keys.add(statement.readOperations().propertyKeyGetName(properties.next()));
        }
        return keys;
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
}
Also used : Statement(org.neo4j.kernel.api.Statement) ArrayList(java.util.ArrayList) PrimitiveIntIterator(org.neo4j.collection.primitive.PrimitiveIntIterator) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 2 with PrimitiveIntIterator

use of org.neo4j.collection.primitive.PrimitiveIntIterator in project neo4j by neo4j.

the class ForsetiClient method describeWaitList.

public String describeWaitList() {
    StringBuilder sb = new StringBuilder(format("%nClient[%d] waits for [", id()));
    PrimitiveIntIterator iter = waitList.iterator();
    for (boolean first = true; iter.hasNext(); ) {
        int next = iter.next();
        if (next == clientId) {
            // Skip our own id from the wait list, that's an implementation detail
            continue;
        }
        sb.append((!first) ? "," : "").append(next);
        first = false;
    }
    sb.append("]");
    return sb.toString();
}
Also used : PrimitiveIntIterator(org.neo4j.collection.primitive.PrimitiveIntIterator)

Example 3 with PrimitiveIntIterator

use of org.neo4j.collection.primitive.PrimitiveIntIterator in project neo4j by neo4j.

the class GraphPropertiesProxy method getAllProperties.

@Override
public Map<String, Object> getAllProperties() {
    try (Statement statement = actions.statement()) {
        Map<String, Object> properties = new HashMap<>();
        ReadOperations readOperations = statement.readOperations();
        PrimitiveIntIterator propertyKeys = readOperations.graphGetPropertyKeys();
        while (propertyKeys.hasNext()) {
            int propertyKeyId = propertyKeys.next();
            properties.put(readOperations.propertyKeyGetName(propertyKeyId), readOperations.graphGetProperty(propertyKeyId));
        }
        return properties;
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) KeyReadOperations(org.neo4j.kernel.impl.api.operations.KeyReadOperations) HashMap(java.util.HashMap) Statement(org.neo4j.kernel.api.Statement) PrimitiveIntIterator(org.neo4j.collection.primitive.PrimitiveIntIterator) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 4 with PrimitiveIntIterator

use of org.neo4j.collection.primitive.PrimitiveIntIterator in project neo4j by neo4j.

the class NodeProxy method getPropertyKeys.

@Override
public Iterable<String> getPropertyKeys() {
    try (Statement statement = actions.statement()) {
        List<String> keys = new ArrayList<>();
        PrimitiveIntIterator properties = statement.readOperations().nodeGetPropertyKeys(getId());
        while (properties.hasNext()) {
            keys.add(statement.readOperations().propertyKeyGetName(properties.next()));
        }
        return keys;
    } catch (EntityNotFoundException e) {
        throw new NotFoundException("Node not found", e);
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
}
Also used : Statement(org.neo4j.kernel.api.Statement) ArrayList(java.util.ArrayList) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) PrimitiveIntIterator(org.neo4j.collection.primitive.PrimitiveIntIterator) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 5 with PrimitiveIntIterator

use of org.neo4j.collection.primitive.PrimitiveIntIterator in project neo4j by neo4j.

the class RelationshipProxy method getPropertyKeys.

@Override
public Iterable<String> getPropertyKeys() {
    try (Statement statement = actions.statement()) {
        List<String> keys = new ArrayList<>();
        PrimitiveIntIterator properties = statement.readOperations().relationshipGetPropertyKeys(getId());
        while (properties.hasNext()) {
            keys.add(statement.readOperations().propertyKeyGetName(properties.next()));
        }
        return keys;
    } catch (EntityNotFoundException e) {
        throw new NotFoundException("Relationship not found", e);
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.");
    }
}
Also used : Statement(org.neo4j.kernel.api.Statement) ArrayList(java.util.ArrayList) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) PrimitiveIntIterator(org.neo4j.collection.primitive.PrimitiveIntIterator) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Aggregations

PrimitiveIntIterator (org.neo4j.collection.primitive.PrimitiveIntIterator)5 Statement (org.neo4j.kernel.api.Statement)4 PropertyKeyIdNotFoundKernelException (org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)4 ArrayList (java.util.ArrayList)3 NotFoundException (org.neo4j.graphdb.NotFoundException)2 EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)2 PropertyNotFoundException (org.neo4j.kernel.api.exceptions.PropertyNotFoundException)2 HashMap (java.util.HashMap)1 ReadOperations (org.neo4j.kernel.api.ReadOperations)1 KeyReadOperations (org.neo4j.kernel.impl.api.operations.KeyReadOperations)1