private void CreateNodeRelationships() { RelationshipStore relationshipStore = _neoStores.RelationshipStore; if (Dense) { RecordStore <RelationshipGroupRecord> relationshipGroupStore = _neoStores.RelationshipGroupStore; relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(1, 1)); relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(2, 2)); relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(3, 3)); } relationshipStore.UpdateRecord(CreateRelationship(1, NO_NEXT_RELATIONSHIP.intValue())); relationshipStore.UpdateRecord(CreateRelationship(2, NO_NEXT_RELATIONSHIP.intValue())); relationshipStore.UpdateRecord(CreateRelationship(3, NO_NEXT_RELATIONSHIP.intValue())); }
private void CreateRelationshipChain(int recordsInChain) { RelationshipStore relationshipStore = _neoStores.RelationshipStore; for (int i = 1; i < recordsInChain; i++) { relationshipStore.UpdateRecord(CreateRelationship(i, i + 1)); } relationshipStore.UpdateRecord(CreateRelationship(recordsInChain, NO_NEXT_RELATIONSHIP.intValue())); if (Dense) { RecordStore <RelationshipGroupRecord> relationshipGroupStore = _neoStores.RelationshipGroupStore; for (int i = 1; i < recordsInChain; i++) { relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(i, i)); } relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(recordsInChain, NO_NEXT_RELATIONSHIP.intValue())); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void shouldProcessAllTheRecordsInAStore() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProcessAllTheRecordsInAStore() { // given RecordStore <NodeRecord> nodeStore = Stores.builder().build().NodeStore; Org.Neo4j.Consistency.report.ConsistencyReport_Reporter reporter = mock(typeof(Org.Neo4j.Consistency.report.ConsistencyReport_Reporter)); StoreProcessor processor = new StoreProcessor(Org.Neo4j.Consistency.checking.CheckDecorator_Fields.None, reporter, Stage_Fields.SequentialForward, CacheAccess.EMPTY); nodeStore.UpdateRecord(Node(0, false, 0, 0)); nodeStore.UpdateRecord(Node(1, false, 0, 0)); nodeStore.UpdateRecord(Node(2, false, 0, 0)); nodeStore.HighestPossibleIdInUse = 2; // when processor.ApplyFiltered(nodeStore); // then verify(reporter, times(3)).forNode(any(typeof(NodeRecord)), any(typeof(RecordCheck))); }
private static void Migrate <RECORD>(RecordStore <RECORD> from, RecordStore <RECORD> to) where RECORD : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord { to.HighestPossibleIdInUse = from.HighestPossibleIdInUse; from.ScanAllRecords(record => { to.PrepareForCommit(record); to.UpdateRecord(record); return(false); }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAbortLoadingGroupChainIfComeTooFar() public virtual void ShouldAbortLoadingGroupChainIfComeTooFar() { // GIVEN a node with relationship group chain 2-->4-->10-->23 LogProvider logProvider = NullLogProvider.Instance; StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory(_fs.get()), _pageCache.getPageCache(_fs.get()), _fs.get(), logProvider, EmptyVersionContextSupplier.EMPTY); using (NeoStores stores = storeFactory.OpenNeoStores(true, StoreType.RELATIONSHIP_GROUP)) { RecordStore <RelationshipGroupRecord> store = spy(stores.RelationshipGroupStore); RelationshipGroupRecord group2 = Group(0, 2); RelationshipGroupRecord group4 = Group(1, 4); RelationshipGroupRecord group10 = Group(2, 10); RelationshipGroupRecord group23 = Group(3, 23); Link(group2, group4, group10, group23); store.UpdateRecord(group2); store.UpdateRecord(group4); store.UpdateRecord(group10); store.UpdateRecord(group23); RelationshipGroupGetter groupGetter = new RelationshipGroupGetter(store); NodeRecord node = new NodeRecord(0, true, group2.Id, -1); // WHEN trying to find relationship group 7 RecordAccess <RelationshipGroupRecord, int> access = new DirectRecordAccess <RelationshipGroupRecord, int>(store, Loaders.relationshipGroupLoader(store)); RelationshipGroupGetter.RelationshipGroupPosition result = groupGetter.GetRelationshipGroup(node, 7, access); // THEN only groups 2, 4 and 10 should have been loaded InOrder verification = inOrder(store); verification.verify(store).getRecord(eq(group2.Id), any(typeof(RelationshipGroupRecord)), any(typeof(RecordLoad))); verification.verify(store).getRecord(eq(group4.Id), any(typeof(RelationshipGroupRecord)), any(typeof(RecordLoad))); verification.verify(store).getRecord(eq(group10.Id), any(typeof(RelationshipGroupRecord)), any(typeof(RecordLoad))); verification.verify(store, never()).getRecord(eq(group23.Id), any(typeof(RelationshipGroupRecord)), any(typeof(RecordLoad))); // it should also be reported as not found assertNull(result.Group()); // with group 4 as closes previous one assertEquals(group4, result.ClosestPrevious().forReadingData()); } }
private static void BreakTheChain(RecordStore <RelationshipRecord> relationshipStore) { RelationshipRecord record = relationshipStore.GetRecord(10, relationshipStore.NewRecord(), NORMAL); long relationshipTowardsEndOfChain = record.FirstNode; while (record.InUse() && !record.FirstInFirstChain) { record = relationshipStore.GetRecord(relationshipTowardsEndOfChain, relationshipStore.NewRecord(), FORCE); relationshipTowardsEndOfChain = record.FirstPrevRel; } relationshipStore.UpdateRecord(new RelationshipRecord(relationshipTowardsEndOfChain, 0, 0, 0)); }
private void CreateRecordIn <RECORD>(RecordStore <RECORD> store) where RECORD : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord { RECORD record = store.NewRecord(); record.Id = store.nextId(); record.InUse = true; if (record is PropertyRecord) { // Special hack for property store, since it's not enough to simply set a record as in use there PropertyBlock block = new PropertyBlock(); (( PropertyStore )store).encodeValue(block, 0, Values.of(10)); (( PropertyRecord )record).addPropertyBlock(block); } store.UpdateRecord(record); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDefragmentRelationshipGroupsWhenSomeDense() public virtual void ShouldDefragmentRelationshipGroupsWhenSomeDense() { // GIVEN some nodes which has their groups scattered int nodeCount = 100; int relationshipTypeCount = 50; RecordStore <RelationshipGroupRecord> groupStore = _stores.TemporaryRelationshipGroupStore; RelationshipGroupRecord groupRecord = groupStore.NewRecord(); RecordStore <NodeRecord> nodeStore = _stores.NodeStore; NodeRecord nodeRecord = nodeStore.NewRecord(); long cursor = 0; BitArray initializedNodes = new BitArray(); for (int typeId = relationshipTypeCount - 1; typeId >= 0; typeId--) { for (int nodeId = 0; nodeId < nodeCount; nodeId++, cursor++) { // Reasoning behind this thing is that we want to have roughly 10% of the nodes dense // right from the beginning and then some stray dense nodes coming into this in the // middle of the type range somewhere double comparison = typeId == 0 || initializedNodes.Get(nodeId) ? 0.1 : 0.001; if (_random.NextDouble() < comparison) { // next doesn't matter at all, as we're rewriting it anyway // firstOut/In/Loop we could use in verification phase later groupRecord.Initialize(true, typeId, cursor, cursor + 1, cursor + 2, nodeId, 4); groupRecord.Id = groupStore.nextId(); groupStore.UpdateRecord(groupRecord); if (!initializedNodes.Get(nodeId)) { nodeRecord.Initialize(true, -1, true, groupRecord.Id, 0); nodeRecord.Id = nodeId; nodeStore.UpdateRecord(nodeRecord); nodeStore.HighestPossibleIdInUse = nodeId; initializedNodes.Set(nodeId, true); } } } } // WHEN Defrag(nodeCount, groupStore); // THEN all groups should sit sequentially in the store VerifyGroupsAreSequentiallyOrderedByNode(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDefragmentRelationshipGroupsWhenAllDense() public virtual void ShouldDefragmentRelationshipGroupsWhenAllDense() { // GIVEN some nodes which has their groups scattered int nodeCount = 100; int relationshipTypeCount = 50; RecordStore <RelationshipGroupRecord> groupStore = _stores.TemporaryRelationshipGroupStore; RelationshipGroupRecord groupRecord = groupStore.NewRecord(); RecordStore <NodeRecord> nodeStore = _stores.NodeStore; NodeRecord nodeRecord = nodeStore.NewRecord(); long cursor = 0; for (int typeId = relationshipTypeCount - 1; typeId >= 0; typeId--) { for (long nodeId = 0; nodeId < nodeCount; nodeId++, cursor++) { // next doesn't matter at all, as we're rewriting it anyway // firstOut/In/Loop we could use in verification phase later groupRecord.Initialize(true, typeId, cursor, cursor + 1, cursor + 2, nodeId, 4); groupRecord.Id = groupStore.nextId(); groupStore.UpdateRecord(groupRecord); if (typeId == 0) { // first round also create the nodes nodeRecord.Initialize(true, -1, true, groupRecord.Id, 0); nodeRecord.Id = nodeId; nodeStore.UpdateRecord(nodeRecord); nodeStore.HighestPossibleIdInUse = nodeId; } } } // WHEN Defrag(nodeCount, groupStore); // THEN all groups should sit sequentially in the store VerifyGroupsAreSequentiallyOrderedByNode(); }
private void UpdateStore <RECORD>(RecordStore <RECORD> store, BaseCommand <RECORD> command) where RECORD : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord { store.UpdateRecord(SelectRecordByCommandVersion(command)); }