/** * @see NodeRecord * * @param labelField label field value from a node record * @return the id of the dynamic record this label field points to or null if it is an inline label field */ public static long firstDynamicLabelRecordId( long labelField ) { assert fieldPointsToDynamicRecordOfLabels( labelField ); return parseLabelsBody( labelField ); }
private static boolean mayResultInIndexUpdates( NodeCommand command ) { long before = command.getBefore().getLabelField(); long after = command.getAfter().getLabelField(); return before != after || // Because we don't know here, there may have been changes to a dynamic label record // even though it still points to the same one fieldPointsToDynamicRecordOfLabels( before ) || fieldPointsToDynamicRecordOfLabels( after ); }
public static NodeLabels parseLabelsField( NodeRecord node ) { long labelField = node.getLabelField(); return fieldPointsToDynamicRecordOfLabels( labelField ) ? new DynamicNodeLabels( node ) : new InlineNodeLabels( node ); }
public static long[] get( NodeRecord node, NodeStore nodeStore ) { return fieldPointsToDynamicRecordOfLabels( node.getLabelField() ) ? DynamicNodeLabels.get( node, nodeStore ) : InlineNodeLabels.get( node ); }
@Override public void ensureHeavy( NodeRecord node ) { if ( NodeLabelsField.fieldPointsToDynamicRecordOfLabels( node.getLabelField() ) ) { ensureHeavy( node, NodeLabelsField.firstDynamicLabelRecordId( node.getLabelField() ) ); } }
public static long[] getListOfLabels( NodeRecord nodeRecord, RecordStore<DynamicRecord> labels ) { long field = nodeRecord.getLabelField(); if ( NodeLabelsField.fieldPointsToDynamicRecordOfLabels( field ) ) { List<DynamicRecord> recordList = new ArrayList<>(); final MutableLongSet alreadySeen = new LongHashSet(); long id = NodeLabelsField.firstDynamicLabelRecordId( field ); while ( !Record.NULL_REFERENCE.is( id ) ) { DynamicRecord record = labels.getRecord( id, labels.newRecord(), FORCE ); if ( !record.inUse() || !alreadySeen.add( id ) ) { return PrimitiveLongCollections.EMPTY_LONG_ARRAY; } recordList.add( record ); } return LabelChainWalker.labelIds( recordList ); } return InlineNodeLabels.get( nodeRecord ); }
static Collection<DynamicRecord> putSorted( NodeRecord node, long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator ) { long existingLabelsField = node.getLabelField(); long existingLabelsBits = parseLabelsBody( existingLabelsField ); Collection<DynamicRecord> changedDynamicRecords = node.getDynamicLabelRecords(); long labelField = node.getLabelField(); if ( fieldPointsToDynamicRecordOfLabels( labelField ) ) { // There are existing dynamic label records, get them nodeStore.ensureHeavy( node, existingLabelsBits ); changedDynamicRecords = node.getDynamicLabelRecords(); setNotInUse( changedDynamicRecords ); } if ( !InlineNodeLabels.tryInlineInNodeRecord( node, labelIds, changedDynamicRecords ) ) { Iterator<DynamicRecord> recycledRecords = changedDynamicRecords.iterator(); Collection<DynamicRecord> allocatedRecords = allocateRecordsForDynamicLabels( node.getId(), labelIds, new ReusableRecordsCompositeAllocator( recycledRecords, allocator ) ); // Set the rest of the previously set dynamic records as !inUse while ( recycledRecords.hasNext() ) { DynamicRecord removedRecord = recycledRecords.next(); removedRecord.setInUse( false ); allocatedRecords.add( removedRecord ); } node.setLabelField( dynamicPointer( allocatedRecords ), allocatedRecords ); changedDynamicRecords = allocatedRecords; } return changedDynamicRecords; }
@Test public void shouldReadNullDynamicRecordFromInlineLabelsField() { // GIVEN NodeRecord node = nodeRecordWithInlinedLabels( 23L ); // WHEN boolean isDynamicReference = NodeLabelsField.fieldPointsToDynamicRecordOfLabels( node.getLabelField() ); // THEN assertFalse( isDynamicReference ); }
Set<Long> secondNodeLabels; long firstLabelsField = cacheAccess.getFromCache( record.getFirstNode(), SLOT_LABEL_FIELD ); if ( NodeLabelsField.fieldPointsToDynamicRecordOfLabels( firstLabelsField ) ) if ( NodeLabelsField.fieldPointsToDynamicRecordOfLabels( secondLabelsField ) )
/** * @see NodeRecord * * @param labelField label field value from a node record * @return the id of the dynamic record this label field points to or null if it is an inline label field */ public static long firstDynamicLabelRecordId( long labelField ) { assert fieldPointsToDynamicRecordOfLabels( labelField ); return parseLabelsBody( labelField ); }
private static boolean mayResultInIndexUpdates( NodeCommand command ) { long before = command.getBefore().getLabelField(); long after = command.getAfter().getLabelField(); return before != after || // Because we don't know here, there may have been changes to a dynamic label record // even though it still points to the same one fieldPointsToDynamicRecordOfLabels( before ) || fieldPointsToDynamicRecordOfLabels( after ); }
public static NodeLabels parseLabelsField( NodeRecord node ) { long labelField = node.getLabelField(); return fieldPointsToDynamicRecordOfLabels( labelField ) ? new DynamicNodeLabels( node ) : new InlineNodeLabels( node ); }
public static long[] get( NodeRecord node, NodeStore nodeStore ) { return fieldPointsToDynamicRecordOfLabels( node.getLabelField() ) ? DynamicNodeLabels.get( node, nodeStore ) : InlineNodeLabels.get( node ); }
@Override public void ensureHeavy( NodeRecord node ) { if ( NodeLabelsField.fieldPointsToDynamicRecordOfLabels( node.getLabelField() ) ) { ensureHeavy( node, NodeLabelsField.firstDynamicLabelRecordId( node.getLabelField() ) ); } }
static Collection<DynamicRecord> putSorted( NodeRecord node, long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator ) { long existingLabelsField = node.getLabelField(); long existingLabelsBits = parseLabelsBody( existingLabelsField ); Collection<DynamicRecord> changedDynamicRecords = node.getDynamicLabelRecords(); long labelField = node.getLabelField(); if ( fieldPointsToDynamicRecordOfLabels( labelField ) ) { // There are existing dynamic label records, get them nodeStore.ensureHeavy( node, existingLabelsBits ); changedDynamicRecords = node.getDynamicLabelRecords(); setNotInUse( changedDynamicRecords ); } if ( !InlineNodeLabels.tryInlineInNodeRecord( node, labelIds, changedDynamicRecords ) ) { Iterator<DynamicRecord> recycledRecords = changedDynamicRecords.iterator(); Collection<DynamicRecord> allocatedRecords = allocateRecordsForDynamicLabels( node.getId(), labelIds, new ReusableRecordsCompositeAllocator( recycledRecords, allocator ) ); // Set the rest of the previously set dynamic records as !inUse while ( recycledRecords.hasNext() ) { DynamicRecord removedRecord = recycledRecords.next(); removedRecord.setInUse( false ); allocatedRecords.add( removedRecord ); } node.setLabelField( dynamicPointer( allocatedRecords ), allocatedRecords ); changedDynamicRecords = allocatedRecords; } return changedDynamicRecords; }