Example #1
0
 @Override
 public Iterable<BatchRelationship> getRelationships(long nodeId) {
   NodeRecord nodeRecord = getNodeRecord(nodeId);
   long nextRel = nodeRecord.getNextRel();
   List<BatchRelationship> rels = new ArrayList<>();
   while (nextRel != Record.NO_NEXT_RELATIONSHIP.intValue()) {
     RelationshipRecord relRecord = getRelationshipRecord(nextRel);
     RelationshipType type =
         new RelationshipTypeImpl(relationshipTypeTokens.nameOf(relRecord.getType()));
     rels.add(
         new BatchRelationship(
             relRecord.getId(), relRecord.getFirstNode(), relRecord.getSecondNode(), type));
     long firstNode = relRecord.getFirstNode();
     long secondNode = relRecord.getSecondNode();
     if (firstNode == nodeId) {
       nextRel = relRecord.getFirstNextRel();
     } else if (secondNode == nodeId) {
       nextRel = relRecord.getSecondNextRel();
     } else {
       throw new InvalidRecordException(
           "Node["
               + nodeId
               + "] not part of firstNode["
               + firstNode
               + "] or secondNode["
               + secondNode
               + "]");
     }
   }
   return rels;
 }
Example #2
0
 @Override
 public BatchRelationship getRelationshipById(long relId) {
   RelationshipRecord record = getRelationshipRecord(relId).forReadingData();
   RelationshipType type =
       new RelationshipTypeImpl(relationshipTypeTokens.nameOf(record.getType()));
   return new BatchRelationship(
       record.getId(), record.getFirstNode(), record.getSecondNode(), type);
 }
Example #3
0
  private Map<String, Object> getPropertyChain(long nextProp) {
    PropertyStore propStore = getPropertyStore();
    Map<String, Object> properties = new HashMap<>();

    while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
      PropertyRecord propRecord = propStore.getRecord(nextProp);
      for (PropertyBlock propBlock : propRecord.getPropertyBlocks()) {
        String key = propertyKeyTokens.nameOf(propBlock.getKeyIndexId());
        DefinedProperty propertyData = propBlock.newPropertyData(propStore);
        Object value =
            propertyData.value() != null
                ? propertyData.value()
                : propBlock.getType().getValue(propBlock, getPropertyStore());
        properties.put(key, value);
      }
      nextProp = propRecord.getNextProp();
    }
    return properties;
  }
Example #4
0
 @Override
 public Label apply(long from) {
   return label(labelTokens.nameOf(safeCastLongToInt(from)));
 }