private RelationshipRecord loadRelationship( long relationshipId ) { if ( relationshipRecord == null ) { relationshipRecord = relationshipStore.newRecord(); } relationshipStore.getRecord( relationshipId, relationshipRecord, RecordLoad.NORMAL ); return relationshipRecord; } }
@Override protected RelationshipRecord getLight( long id, RelationshipStore store ) { return store.getRecord( id, store.newRecord(), NORMAL ); }
@Override public <EXCEPTION extends Exception> void relationshipVisit( long relationshipId, RelationshipVisitor<EXCEPTION> relationshipVisitor ) throws EntityNotFoundException, EXCEPTION { // TODO Please don't create a record for this, it's ridiculous RelationshipRecord record = relationshipStore.getRecord( relationshipId, relationshipStore.newRecord(), CHECK ); if ( !record.inUse() ) { throw new EntityNotFoundException( EntityType.RELATIONSHIP, relationshipId ); } relationshipVisitor.visit( relationshipId, record.getType(), record.getFirstNode(), record.getSecondNode() ); }
private <RECEIVER extends PropertyReceiver> void relLoadProperties( long relId, RECEIVER receiver ) { RelationshipRecord relRecord = relStore.getRecord( relId, relStore.newRecord(), NORMAL ); loadProperties( relRecord.getNextProp(), receiver ); }
private void assertRelationshipChain( RelationshipStore relationshipStore, Node node, long firstId, long... chainedIds ) { long nodeId = node.getId(); RelationshipRecord record = relationshipStore.getRecord( firstId, relationshipStore.newRecord(), NORMAL ); Set<Long> readChain = new HashSet<>(); readChain.add( firstId ); while ( true ) { long nextId = record.getFirstNode() == nodeId ? record.getFirstNextRel() : record.getSecondNextRel(); if ( nextId == -1 ) { break; } readChain.add( nextId ); relationshipStore.getRecord( nextId, record, NORMAL ); } Set<Long> expectedChain = new HashSet<>( asList( firstId ) ); for ( long id : chainedIds ) { expectedChain.add( id ); } assertEquals( expectedChain, readChain ); } }
protected RelationshipImporter( BatchingNeoStores stores, IdMapper idMapper, DataStatistics typeDistribution, Monitor monitor, Collector badCollector, boolean validateRelationshipData, boolean doubleRecordUnits ) { super( stores, monitor ); this.doubleRecordUnits = doubleRecordUnits; this.relationshipTypeTokenRepository = stores.getRelationshipTypeRepository(); this.idMapper = idMapper; this.badCollector = badCollector; this.validateRelationshipData = validateRelationshipData; this.relationshipStore = stores.getRelationshipStore(); this.relationshipRecord = relationshipStore.newRecord(); this.relationshipIds = new BatchingIdGetter( relationshipStore ); this.typeCounts = typeDistribution.newClient(); this.prepareIdSequence = PrepareIdSequence.of( doubleRecordUnits ).apply( stores.getRelationshipStore() ); relationshipRecord.setInUse( true ); }
private Sabotage sabotage( RelationshipStore store, long id ) { RelationshipRecord before = store.getRecord( id, store.newRecord(), RecordLoad.NORMAL ); RelationshipRecord after = before.clone(); long otherReference; if ( !after.isFirstInFirstChain() ) { after.setFirstPrevRel( otherReference = after.getFirstPrevRel() + 1 ); } else { after.setFirstNextRel( otherReference = after.getFirstNextRel() + 1 ); } store.prepareForCommit( after ); store.updateRecord( after ); RelationshipRecord other = store.getRecord( otherReference, store.newRecord(), RecordLoad.FORCE ); return new Sabotage( before, after, other ); } }
entity = relationshipStore.getRecord( entityId, relationshipStore.newRecord(), FORCE );
RelationshipRecord record = stores.getRelationshipStore().newRecord(); record = stores.getRelationshipStore().getRecord( relId, record, RecordLoad.NORMAL ); long propId = record.getNextProp();
@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() ); } }
private RelationshipRecord loadRelationship( long relationshipId ) { if ( relationshipRecord == null ) { relationshipRecord = relationshipStore.newRecord(); } relationshipStore.getRecord( relationshipId, relationshipRecord, RecordLoad.NORMAL ); return relationshipRecord; } }
@Override public <EXCEPTION extends Exception> void relationshipVisit( long relationshipId, RelationshipVisitor<EXCEPTION> relationshipVisitor ) throws EntityNotFoundException, EXCEPTION { // TODO Please don't create a record for this, it's ridiculous RelationshipRecord record = relationshipStore.getRecord( relationshipId, relationshipStore.newRecord(), CHECK ); if ( !record.inUse() ) { throw new EntityNotFoundException( EntityType.RELATIONSHIP, relationshipId ); } relationshipVisitor.visit( relationshipId, record.getType(), record.getFirstNode(), record.getSecondNode() ); }
protected RelationshipImporter( BatchingNeoStores stores, IdMapper idMapper, DataStatistics typeDistribution, Monitor monitor, Collector badCollector, boolean validateRelationshipData, boolean doubleRecordUnits ) { super( stores, monitor ); this.doubleRecordUnits = doubleRecordUnits; this.relationshipTypeTokenRepository = stores.getRelationshipTypeRepository(); this.idMapper = idMapper; this.badCollector = badCollector; this.validateRelationshipData = validateRelationshipData; this.relationshipStore = stores.getRelationshipStore(); this.relationshipRecord = relationshipStore.newRecord(); this.relationshipIds = new BatchingIdGetter( relationshipStore ); this.typeCounts = typeDistribution.newClient(); this.prepareIdSequence = PrepareIdSequence.of( doubleRecordUnits ).apply( stores.getRelationshipStore() ); relationshipRecord.setInUse( true ); }
entity = relationshipStore.getRecord( entityId, relationshipStore.newRecord(), FORCE );