@Override public void clear() { initialize( false, Record.NO_NEXT_PROPERTY.intValue(), false, Record.NO_NEXT_RELATIONSHIP.intValue(), Record.NO_LABELS_FIELD.intValue() ); }
private NodeRecord getNodeRecord() { NodeRecord nodeRecord = new NodeRecord( 0L ); nodeRecord.initialize( true, 1L, false, 1L, 0L ); return nodeRecord; }
private NodeRecord node( long id, boolean dense, long nextRel, long nextProp ) { return new NodeRecord( id ).initialize( true, nextProp, dense, nextRel, 0 ); }
@Override public NodeRecord clone() { NodeRecord clone = new NodeRecord( getId() ).initialize( inUse(), nextProp, dense, nextRel, labels ); clone.isLight = isLight; if ( dynamicLabelRecords.size() > 0 ) { List<DynamicRecord> clonedLabelRecords = new ArrayList<>( dynamicLabelRecords.size() ); for ( DynamicRecord labelRecord : dynamicLabelRecords ) { clonedLabelRecords.add( labelRecord.clone() ); } clone.dynamicLabelRecords = clonedLabelRecords; } clone.setSecondaryUnitId( getSecondaryUnitId() ); return clone; } }
private NodeRecord getNodeRecord() { NodeRecord nodeRecord = new NodeRecord( 1L ); nodeRecord.initialize( true, 0, false, 1, 0x0000000001L ); InlineNodeLabels.putSorted( nodeRecord, new long[]{1}, null, null ); return nodeRecord; }
@Before public void setUp() { NodeRecord nodeRecord = getNodeRecord(); when( labelScanStore.allNodeLabelRanges()).thenReturn( nodeLabelRanges ); when( neoStores.getCounts() ).thenReturn( countStore ); when( neoStores.getNodeStore() ).thenReturn( nodeStore ); when( nodeStore.newRecord() ).thenReturn( nodeRecord ); doAnswer( invocation -> { NodeRecord record = invocation.getArgument( 1 ); record.initialize( true, 1L, false, 1L, 0L ); record.setId( invocation.getArgument( 0 ) ); return null; } ).when( nodeStore ).getRecordByCursor( anyLong(), any( NodeRecord.class ), any( RecordLoad.class ), any( PageCursor.class ) ); doAnswer( invocation -> { NodeRecord record = invocation.getArgument( 0 ); record.initialize( true, 1L, false, 1L, 0L ); record.setId( record.getId() + 1 ); return null; } ).when( nodeStore ).nextRecordByCursor( any( NodeRecord.class ), any( RecordLoad.class ), any( PageCursor.class ) ); }
public static NodeRecord node( long id, Consumer<NodeRecord>... modifiers ) { NodeRecord record = new NodeRecord( id ); record.initialize( true, Record.NO_NEXT_PROPERTY.intValue(), false, Record.NO_NEXT_RELATIONSHIP.intValue(), Record.NO_LABELS_FIELD.intValue() ); for ( Consumer<NodeRecord> modifier : modifiers ) { modifier.accept( record ); } return record; }
private TransactionRepresentation tx( int size ) { Collection<StorageCommand> commands = new ArrayList<>(); for ( int i = 0; i < size; i++ ) { // The type of command doesn't matter here commands.add( new Command.NodeCommand( new NodeRecord( i ), new NodeRecord( i ).initialize( true, i, false, i, NO_LABELS_FIELD.longValue() ) ) ); } PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation( commands ); tx.setHeader( new byte[0], 0, 0, 0, 0, 0, 0 ); return tx; }
@Test public void shouldReportCircularNodePropertyRecordChain() throws Exception { shouldReportCircularPropertyRecordChain( RecordType.NODE, ( tx, next, propertyRecordId ) -> tx.create( new NodeRecord( next.node() ).initialize( true, propertyRecordId, false, -1, Record.NO_LABELS_FIELD.longValue() ) ) ); }
@Override public Generator<NodeRecord> node() { return ( recordSize, format, recordId ) -> new NodeRecord( recordId ).initialize( random.nextBoolean(), randomLongOrOccasionallyNull( propertyBits ), random.nextBoolean(), randomLongOrOccasionallyNull( entityBits ), randomLongOrOccasionallyNull( nodeLabelBits, 0 ) ); }
private NodeRecord getNode( int nodeId, boolean inUse ) { NodeRecord nodeRecord = new NodeRecord( nodeId ); nodeRecord = nodeRecord.initialize( inUse, NO_NEXT_PROPERTY.longValue(), false, NO_NEXT_RELATIONSHIP.longValue(), NO_LABELS_FIELD.longValue() ); InlineNodeLabels labelFieldWriter = new InlineNodeLabels( nodeRecord ); labelFieldWriter.put( new long[]{ENTITY_TOKEN}, null, null ); return nodeRecord; }
@Override public void read( NodeRecord record, PageCursor cursor, RecordLoad mode, int recordSize ) { byte headerByte = cursor.getByte(); boolean inUse = isInUse( headerByte ); record.setInUse( inUse ); if ( mode.shouldLoad( inUse ) ) { long nextRel = cursor.getInt() & 0xFFFFFFFFL; long nextProp = cursor.getInt() & 0xFFFFFFFFL; long relModifier = (headerByte & 0xEL) << 31; long propModifier = (headerByte & 0xF0L) << 28; long lsbLabels = cursor.getInt() & 0xFFFFFFFFL; long hsbLabels = cursor.getByte() & 0xFF; // so that a negative byte won't fill the "extended" bits with ones. long labels = lsbLabels | (hsbLabels << 32); byte extra = cursor.getByte(); boolean dense = (extra & 0x1) > 0; record.initialize( inUse, BaseRecordFormat.longFromIntAndMod( nextProp, propModifier ), dense, BaseRecordFormat.longFromIntAndMod( nextRel, relModifier ), labels ); } else { int nextOffset = cursor.getOffset() + recordSize - HEADER_SIZE; cursor.setOffset( nextOffset ); } }
nodeRecord.initialize( true, -1, true, groupRecord.getId(), 0 ); nodeRecord.setId( nodeId ); nodeStore.updateRecord( nodeRecord );
@Test public void shouldReportCircularRelationshipPropertyRecordChain() throws Exception { int relType = createRelType(); shouldReportCircularPropertyRecordChain( RecordType.RELATIONSHIP, ( tx, next, propertyRecordId ) -> { long node = next.node(); long relationship = next.relationship(); tx.create( new NodeRecord( node ).initialize( true, -1, false, relationship, Record.NO_LABELS_FIELD.longValue() ) ); RelationshipRecord relationshipRecord = new RelationshipRecord( relationship ); relationshipRecord.setFirstNode( node ); relationshipRecord.setSecondNode( node ); relationshipRecord.setType( relType ); relationshipRecord.setNextProp( propertyRecordId ); tx.create( relationshipRecord ); } ); }
nodeRecord.initialize( true, -1, true, groupRecord.getId(), 0 ); nodeRecord.setId( nodeId ); nodeStore.updateRecord( nodeRecord );
HighIdTransactionApplier tracker = new HighIdTransactionApplier( neoStores ); NodeRecord node = new NodeRecord( 5 ).initialize( true, 123, true, 456, 0 ); node.setSecondaryUnitId( 6 ); node.setRequiresSecondaryUnit( true );
@Override public void clear() { initialize( false, Record.NO_NEXT_PROPERTY.intValue(), false, Record.NO_NEXT_RELATIONSHIP.intValue(), Record.NO_LABELS_FIELD.intValue() ); }
@Override protected void doReadInternal( NodeRecord record, PageCursor cursor, int recordSize, long headerByte, boolean inUse ) { // Interpret the header byte boolean dense = has( headerByte, DENSE_NODE_BIT ); // Now read the rest of the data. The adapter will take care of moving the cursor over to the // other unit when we've exhausted the first one. long nextRel = decodeCompressedReference( cursor, headerByte, HAS_RELATIONSHIP_BIT, NULL ); long nextProp = decodeCompressedReference( cursor, headerByte, HAS_PROPERTY_BIT, NULL ); long labelField = decodeCompressedReference( cursor, headerByte, HAS_LABELS_BIT, NULL_LABELS ); record.initialize( inUse, nextProp, dense, nextRel, labelField ); }
private void readFixedReferencesRecord( NodeRecord record, PageCursor cursor, boolean inUse, boolean dense ) { byte modifiers = cursor.getByte(); long relModifier = (modifiers & LOWER_NIBBLE_READ_MASK) << 32; long propModifier = (modifiers & HIGHER_NIBBLE_READ_MASK) << 28; long nextRel = cursor.getInt() & 0xFFFFFFFFL; long nextProp = cursor.getInt() & 0xFFFFFFFFL; long lsbLabels = cursor.getInt() & 0xFFFFFFFFL; long hsbLabels = cursor.getByte() & 0xFF; // so that a negative byte won't fill the "extended" bits with ones. long labels = lsbLabels | (hsbLabels << 32); record.initialize( inUse, BaseRecordFormat.longFromIntAndMod( nextProp, propModifier ), dense, BaseRecordFormat.longFromIntAndMod( nextRel, relModifier ), labels ); }
private void readFixedReferencesRecord( NodeRecord record, PageCursor cursor, boolean inUse, boolean dense ) { byte modifiers = cursor.getByte(); long relModifier = (modifiers & LOWER_NIBBLE_READ_MASK) << 32; long propModifier = (modifiers & HIGHER_NIBBLE_READ_MASK) << 28; long nextRel = cursor.getInt() & 0xFFFFFFFFL; long nextProp = cursor.getInt() & 0xFFFFFFFFL; long lsbLabels = cursor.getInt() & 0xFFFFFFFFL; long hsbLabels = cursor.getByte() & 0xFF; // so that a negative byte won't fill the "extended" bits with ones. long labels = lsbLabels | (hsbLabels << 32); record.initialize( inUse, BaseRecordFormat.longFromIntAndMod( nextProp, propModifier ), dense, BaseRecordFormat.longFromIntAndMod( nextRel, relModifier ), labels ); }