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));
        }
Esempio n. 2
0
            public override void Run(StoreAccess store, PrintStream @out)
            {
                RecordStore <NodeRecord> nodeStore = store.NodeStore;
                NodeRecord node = nodeStore.GetRecord(Id, nodeStore.NewRecord(), NORMAL);

                if (node.Dense)
                {
                    RecordStore <RelationshipGroupRecord> relationshipGroupStore = store.RelationshipGroupStore;
                    RelationshipGroupRecord group = relationshipGroupStore.NewRecord();
                    relationshipGroupStore.GetRecord(node.NextRel, group, NORMAL);
                    do
                    {
                        @out.println("group " + group);
                        @out.println("out:");
                        PrintRelChain(store, @out, group.FirstOut);
                        @out.println("in:");
                        PrintRelChain(store, @out, group.FirstIn);
                        @out.println("loop:");
                        PrintRelChain(store, @out, group.FirstLoop);
                        group = group.Next != -1 ? relationshipGroupStore.GetRecord(group.Next, group, NORMAL) : null;
                    } while (group != null);
                }
                else
                {
                    PrintRelChain(store, @out, node.NextRel);
                }
            }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint:
//ORIGINAL LINE: Scan(RecordStore<R> store, boolean forward, final System.Predicate<? super R>... filters)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
			  internal Scan( RecordStore<R> store, bool forward, params System.Predicate<object>[] filters )
			  {
					this.Filters = filters;
					this.Ids = new StoreIdIterator( store, forward );
					this.Store = store;
					this.Cursor = store.OpenPageCursorForReading( 0 );
					this.Record = store.NewRecord();
			  }
Esempio n. 4
0
        private static T[] ReadAllRecords <T>(Type type, RecordStore <T> store) where T : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord
        {
            type = typeof(T);
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") T[] records = (T[]) Array.newInstance(type, (int) store.getHighId());
            T[] records = ( T[] )Array.CreateInstance(type, ( int )store.HighId);
            for (int i = 0; i < records.Length; i++)
            {
                records[i] = store.GetRecord(i, store.NewRecord(), FORCE);
            }
            return(records);
        }
Esempio n. 5
0
            public override void Run(StoreAccess store, PrintStream @out)
            {
                long propId = FirstPropId(store);
                RecordStore <PropertyRecord> propertyStore = store.PropertyStore;
                PropertyRecord record = propertyStore.NewRecord();

                while (propId != Record.NO_NEXT_PROPERTY.intValue())
                {
                    propertyStore.GetRecord(propId, record, NORMAL);
                    // We rely on this method having the side-effect of loading the property blocks:
                    record.NumberOfProperties();
                    @out.println(record);
                    propId = record.NextProp;
                }
            }
Esempio n. 6
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);
        }
Esempio n. 7
0
//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();
        }
Esempio n. 8
0
 internal virtual void PrintRelChain(StoreAccess access, PrintStream @out, long firstRelId)
 {
     for (long rel = firstRelId; rel != Record.NO_NEXT_RELATIONSHIP.intValue();)
     {
         RecordStore <RelationshipRecord> relationshipStore = access.RelationshipStore;
         RelationshipRecord record = relationshipStore.GetRecord(rel, relationshipStore.NewRecord(), NORMAL);
         @out.println(rel + "\t" + record);
         if (record.FirstNode == Id)
         {
             rel = record.FirstNextRel;
         }
         else
         {
             rel = record.SecondNextRel;
         }
     }
 }
Esempio n. 9
0
            protected internal override void ProcessCache()
            {
                RecordStore <NodeRecord> nodeStore = StoreAccess.NodeStore;
                CacheAccess_Client       client    = CacheAccess.client();
                long highId = nodeStore.HighId;

                for (long nodeId = 0; nodeId < highId; nodeId++)
                {
                    if (client.GetFromCache(nodeId, CacheSlots_NextRelationship_Fields.SLOT_FIRST_IN_TARGET) == 0)
                    {
                        NodeRecord node = nodeStore.GetRecord(nodeId, nodeStore.NewRecord(), FORCE);
                        if (node.InUse() && !node.Dense)
                        {
                            StoreProcessor.processNode(nodeStore, node);
                        }
                    }
                }
            }
Esempio n. 10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void dump(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException
        internal virtual void Dump(DatabaseLayout databaseLayout)
        {
            using (DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction(), PageCache pageCache = createPageCache(fs, createInitialisedScheduler()))
            {
                DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
                Config       config       = Config.defaults();
                StoreFactory storeFactory = new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, fs, LogProvider(), EmptyVersionContextSupplier.EMPTY);

                using (NeoStores neoStores = storeFactory.OpenNeoStores(StoreTypes))
                {
                    RecordStore <RECORD> store = store(neoStores);
                    RECORD record = store.NewRecord();
                    for (long next = FirstRecord; next != -1;)
                    {
                        store.GetRecord(next, record, RecordLoad.FORCE);
                        Console.WriteLine(record);
                        next = next(record);
                    }
                }
            }
        }
Esempio n. 11
0
//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();
        }
 public OwningNodeRelationshipChain(RelationshipChainExplorer relationshipChainExplorer, RecordStore <NodeRecord> nodeStore)
 {
     this._relationshipChainExplorer = relationshipChainExplorer;
     this._nodeStore  = nodeStore;
     this._nodeRecord = nodeStore.NewRecord();
 }
Esempio n. 13
0
 private static ISet <long> LabelsFor <T1>(RecordStore <NodeRecord> nodeStore, CheckerEngine <T1> engine, RecordAccess recordAccess, long nodeId) where T1 : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord
 {
     return(getListOfLabels(nodeStore.GetRecord(nodeId, nodeStore.NewRecord(), FORCE), recordAccess, engine));
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLoadAllConnectedRelationshipRecordsAndTheirFullChainsOfRelationshipRecords()
        public virtual void ShouldLoadAllConnectedRelationshipRecordsAndTheirFullChainsOfRelationshipRecords()
        {
            // given
            RecordStore <RelationshipRecord> relationshipStore = _store.RelationshipStore;

            // when
            int relationshipIdInMiddleOfChain      = 10;
            RecordSet <RelationshipRecord> records = (new RelationshipChainExplorer(relationshipStore)).ExploreRelationshipRecordChainsToDepthTwo(relationshipStore.GetRecord(relationshipIdInMiddleOfChain, relationshipStore.NewRecord(), NORMAL));

            // then
            assertEquals(DEGREE_TWO_NODES * 2, records.Size());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCopeWithAChainThatReferencesNotInUseZeroValueRecords()
        public virtual void ShouldCopeWithAChainThatReferencesNotInUseZeroValueRecords()
        {
            // given
            RecordStore <RelationshipRecord> relationshipStore = _store.RelationshipStore;

            BreakTheChain(relationshipStore);

            // when
            int relationshipIdInMiddleOfChain      = 10;
            RecordSet <RelationshipRecord> records = (new RelationshipChainExplorer(relationshipStore)).ExploreRelationshipRecordChainsToDepthTwo(relationshipStore.GetRecord(relationshipIdInMiddleOfChain, relationshipStore.NewRecord(), NORMAL));

            // then
            int recordsInaccessibleBecauseOfBrokenChain = 3;

            assertEquals(DEGREE_TWO_NODES * 2 - recordsInaccessibleBecauseOfBrokenChain, records.Size());
        }
Esempio n. 16
0
 internal virtual DirectRecordReference <RECORD> ReferenceTo <RECORD>(RecordStore <RECORD> store, long id) where RECORD : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord
 {
     return(new DirectRecordReference <RECORD>(store.GetRecord(id, store.NewRecord(), FORCE), this));
 }
Esempio n. 17
0
            protected internal override long FirstPropId(StoreAccess access)
            {
                RecordStore <NodeRecord> nodeStore = access.NodeStore;

                return(nodeStore.GetRecord(Id, nodeStore.NewRecord(), NORMAL).NextProp);
            }
Esempio n. 18
0
            protected internal override long FirstPropId(StoreAccess access)
            {
                RecordStore <RelationshipRecord> relationshipStore = access.RelationshipStore;

                return(relationshipStore.GetRecord(Id, relationshipStore.NewRecord(), NORMAL).NextProp);
            }