Beispiel #1
0
  @Override
  public Collection<DynamicRecord> put(long[] labelIds, NodeStore nodeStore) {
    long existingLabelsField = node.getLabelField();
    long existingLabelsBits = parseLabelsBody(existingLabelsField);

    Collection<DynamicRecord> changedDynamicRecords = node.getDynamicLabelRecords();

    if (labelField != 0) {
      // There are existing dynamic label records, get them
      nodeStore.ensureHeavy(node, existingLabelsBits);
      changedDynamicRecords = node.getDynamicLabelRecords();
      setNotInUse(changedDynamicRecords);
    }

    if (!new InlineNodeLabels(labelField, node)
        .tryInlineInNodeRecord(labelIds, changedDynamicRecords)) {
      Set<DynamicRecord> allRecords = new HashSet<>(changedDynamicRecords);
      Collection<DynamicRecord> allocatedRecords =
          nodeStore.allocateRecordsForDynamicLabels(
              node.getId(), labelIds, changedDynamicRecords.iterator());
      allRecords.addAll(allocatedRecords);
      node.setLabelField(dynamicPointer(allocatedRecords), allocatedRecords);
      changedDynamicRecords = allRecords;
    }

    return changedDynamicRecords;
  }