private static RelationshipRecord relationship( long id, long startNodeId, long endNodeId ) { return new RelationshipRecord( id ).initialize( true, Record.NO_NEXT_PROPERTY.longValue(), startNodeId, endNodeId, 0, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), false, false ); } }
private RelationshipRecord getRelationship( long relId, boolean inUse, int type ) { return new RelationshipRecord( relId ).initialize( inUse, NO_NEXT_PROPERTY.longValue(), 0, 0, type, NO_NEXT_RELATIONSHIP.longValue(), NO_NEXT_RELATIONSHIP.longValue(), NO_NEXT_RELATIONSHIP.longValue(), NO_NEXT_RELATIONSHIP.longValue(), true, false ); } }
public static RelationshipGroupRecord relGroup( long id, Consumer<RelationshipGroupRecord>... modifiers ) { RelationshipGroupRecord record = new RelationshipGroupRecord( id ); record.initialize( true, 0, Record.NO_NEXT_RELATIONSHIP.longValue(), Record.NO_NEXT_RELATIONSHIP.longValue(), Record.NO_NEXT_RELATIONSHIP.longValue(), -1, Record.NO_NEXT_RELATIONSHIP.longValue() ); for ( Consumer<RelationshipGroupRecord> modifier : modifiers ) { modifier.accept( record ); } return record; }
public static RelationshipRecord rel( long id, Consumer<RelationshipRecord>... modifiers ) { RelationshipRecord record = new RelationshipRecord( id ); record.initialize( true, Record.NO_NEXT_PROPERTY.intValue(), -1, -1, 0, Record.NO_PREV_RELATIONSHIP.longValue(), Record.NO_NEXT_RELATIONSHIP.longValue(), Record.NO_PREV_RELATIONSHIP.longValue(), Record.NO_NEXT_RELATIONSHIP.longValue(), true, true ); for ( Consumer<RelationshipRecord> modifier : modifiers ) { modifier.accept( record ); } return record; }
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; }
protected static List<RelationshipGroupRecord> groups( Group... groups ) { List<RelationshipGroupRecord> records = new ArrayList<>(); for ( Group group : groups ) { for ( int i = 0; i < group.count; i++ ) { RelationshipGroupRecord record = new RelationshipGroupRecord( NULL_REFERENCE.longValue() ); record.setOwningNode( group.owningNode ); record.setNext( group.count - i - 1 ); // count: how many come after it (importer does this) records.add( record ); } } return records; }
@Override public void endOfEntity() { // Make sure we have an ID if ( nodeRecord.getId() == NULL_REFERENCE.longValue() ) { nodeRecord.setId( nodeIds.next() ); } // Compose the labels if ( !hasLabelField ) { long[] labelIds = labelTokenRepository.getOrCreateIds( labels, labelsCursor ); InlineNodeLabels.putSorted( nodeRecord, labelIds, null, nodeStore.getDynamicLabelStore() ); } labelsCursor = 0; // Write data to stores nodeRecord.setNextProp( createAndWritePropertyChain() ); nodeRecord.setInUse( true ); nodeStore.updateRecord( nodeRecord ); nodeCount++; nodeRecord.clear(); nodeRecord.setId( NULL_REFERENCE.longValue() ); hasLabelField = false; super.endOfEntity(); }
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() ) ) ); }
private void assertBatch( RelationshipGroupRecord[] batch, long lastOwningNodeLastBatch ) { for ( int i = 0; i < batch.length; i++ ) { RelationshipGroupRecord record = batch[i]; assertTrue( record.getId() > Record.NULL_REFERENCE.longValue() ); assertTrue( record.getOwningNode() > lastOwningNodeLastBatch ); assertEquals( 1, record.getFirstOut() ); // the mark our store mock sets when preparing if ( record.getNext() == Record.NULL_REFERENCE.longValue() ) { // This is the last in the chain, verify that this is either: assertTrue( // - the last one in the batch, or i == batch.length - 1 || // - the last one for this node batch[i + 1].getOwningNode() > record.getOwningNode() ); } } }
return Record.NO_NEXT_PROPERTY.longValue();
@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 ); } ); }
@Test public void shouldDeleteIdGeneratorsWhenOpeningExistingStore() throws IOException { // given long expectedHighId; try ( BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache( storage.fileSystem(), storage.pageCache(), PageCacheTracer.NULL, storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.getInstance(), EMPTY, Config.defaults() ) ) { stores.createNew(); RelationshipStore relationshipStore = stores.getRelationshipStore(); RelationshipRecord record = relationshipStore.newRecord(); long no = NULL_REFERENCE.longValue(); record.initialize( true, no, 1, 2, 0, no, no, no, no, true, true ); record.setId( relationshipStore.nextId() ); expectedHighId = relationshipStore.getHighId(); relationshipStore.updateRecord( record ); // fiddle with the highId relationshipStore.setHighId( record.getId() + 999 ); } // when try ( BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache( storage.fileSystem(), storage.pageCache(), PageCacheTracer.NULL, storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.getInstance(), EMPTY, Config.defaults() ) ) { stores.pruneAndOpenExistingStore( Predicates.alwaysTrue(), Predicates.alwaysTrue() ); // then assertEquals( expectedHighId, stores.getRelationshipStore().getHighId() ); } }
@Override public void endOfEntity() { // Make sure we have an ID if ( nodeRecord.getId() == NULL_REFERENCE.longValue() ) { nodeRecord.setId( nodeIds.next() ); } // Compose the labels if ( !hasLabelField ) { long[] labelIds = labelTokenRepository.getOrCreateIds( labels, labelsCursor ); InlineNodeLabels.putSorted( nodeRecord, labelIds, null, nodeStore.getDynamicLabelStore() ); } labelsCursor = 0; // Write data to stores nodeRecord.setNextProp( createAndWritePropertyChain() ); nodeRecord.setInUse( true ); nodeStore.updateRecord( nodeRecord ); nodeCount++; nodeRecord.clear(); nodeRecord.setId( NULL_REFERENCE.longValue() ); hasLabelField = false; super.endOfEntity(); }
return Record.NO_NEXT_PROPERTY.longValue();