Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCombineProperFiveByteLabelField() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCombineProperFiveByteLabelField()
        {
            // GIVEN
            // -- a store
            EphemeralFileSystemAbstraction fs = _efs.get();

            _nodeStore = NewNodeStore(fs);

            // -- a record with the msb carrying a negative value
            long       nodeId = 0;
            long       labels = 0x8000000001L;
            NodeRecord record = new NodeRecord(nodeId, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue());

            record.InUse = true;
            record.SetLabelField(labels, Collections.emptyList());
            _nodeStore.updateRecord(record);

            // WHEN
            // -- reading that record back
            NodeRecord readRecord = _nodeStore.getRecord(nodeId, _nodeStore.newRecord(), NORMAL);

            // THEN
            // -- the label field must be the same
            assertEquals(labels, readRecord.LabelField);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void scanningRecordsShouldVisitEachInUseRecordOnce() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ScanningRecordsShouldVisitEachInUseRecordOnce()
        {
            // GIVEN we have a NodeStore with data that spans several pages...
            EphemeralFileSystemAbstraction fs = _efs.get();

            _nodeStore = NewNodeStore(fs);

            ThreadLocalRandom rng = ThreadLocalRandom.current();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet nextRelSet = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet();
            MutableLongSet nextRelSet = new LongHashSet();

            for (int i = 0; i < 10_000; i++)
            {
                // Enough records to span several pages
                int nextRelCandidate = rng.Next(0, int.MaxValue);
                if (nextRelSet.add(nextRelCandidate))
                {
                    long       nodeId = _nodeStore.nextId();
                    NodeRecord record = new NodeRecord(nodeId, false, nextRelCandidate, 20, true);
                    _nodeStore.updateRecord(record);
                    if (rng.Next(0, 10) < 3)
                    {
                        nextRelSet.remove(nextRelCandidate);
                        record.InUse = false;
                        _nodeStore.updateRecord(record);
                    }
                }
            }

            // ...WHEN we now have an interesting set of node records, and we
            // visit each and remove that node from our nextRelSet...

            Visitor <NodeRecord, IOException> scanner = record =>
            {
                // ...THEN we should observe that no nextRel is ever removed twice...
                assertTrue(nextRelSet.remove(record.NextRel));
                return(false);
            };

            _nodeStore.scanAllRecords(scanner);

            // ...NOR do we have anything left in the set afterwards.
            assertTrue(nextRelSet.Empty);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFreeSecondaryUnitIdOfShrunkRecord() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFreeSecondaryUnitIdOfShrunkRecord()
        {
            // GIVEN
            EphemeralFileSystemAbstraction fs = _efs.get();

            _nodeStore = NewNodeStore(fs);
            NodeRecord record = new NodeRecord(5L);

            record.RequiresSecondaryUnit = true;
            record.SecondaryUnitId       = 10L;
            record.InUse = true;
            _nodeStore.updateRecord(record);
            _nodeStore.HighestPossibleIdInUse = 10L;

            // WHEN
            record.RequiresSecondaryUnit = false;
            _nodeStore.updateRecord(record);

            // THEN
            IdGenerator idGenerator = _idGeneratorFactory.get(IdType.NODE);

            verify(idGenerator, never()).freeId(5L);
            verify(idGenerator).freeId(10L);
        }