internal virtual void Init(long nodeReference, long reference, Read read)
 {
     _storeCursor.init(nodeReference, reference);
     this._txTypes.clear();
     this._txTypeIterator    = null;
     this._hasCheckedTxState = false;
     this._read = read;
 }
Example #2
0
        /// <summary>
        /// Collect all freed page swapper ids, and pass them to the given callback, after which the freed ids will be
        /// eligible for reuse.
        /// This is done with careful synchronisation such that allocating and freeing of ids is allowed to mostly proceed
        /// concurrently.
        /// </summary>
        internal void Vacuum(System.Action <IntSet> evictAllLoadedPagesCallback)
        {
            // We do this complicated locking to avoid blocking allocate() and free() as much as possible, while still only
            // allow a single thread to do vacuum at a time, and at the same time have consistent locking around the
            // set of free ids.
            lock ( _vacuumLock )
            {
                // Collect currently free ids.
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableIntSet freeIds = new org.eclipse.collections.impl.set.mutable.primitive.IntHashSet();
                MutableIntSet    freeIds         = new IntHashSet();
                SwapperMapping[] swapperMappings = this._swapperMappings;
                for (int id = 0; id < swapperMappings.Length; id++)
                {
                    SwapperMapping swapperMapping = swapperMappings[id];
                    if (swapperMapping == _tombstone)
                    {
                        freeIds.add(id);
                    }
                }

                // Evict all of them without holding up the lock on the free id set. This allows allocate() and free() to
                // proceed concurrently with our eviction. This is safe because we know that the ids we are evicting cannot
                // possibly be reused until we remove them from the free id set, which we won't do until after we've evicted
                // all of their loaded pages.
                evictAllLoadedPagesCallback(freeIds);

                // Finally, all of the pages that remained in memory with an unmapped swapper id have been evicted. We can
                // now safely allow those ids to be reused. Note, however, that free() might have been called while we were
                // doing this, so we can't just free.clear() the set; no, we have to explicitly remove only those specific
                // ids whose pages we evicted.
                lock (this)
                {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.iterator.IntIterator itr = freeIds.intIterator();
                    IntIterator itr = freeIds.intIterator();
                    while (itr.hasNext())
                    {
                        int freeId = itr.next();
                        swapperMappings[freeId] = null;
                    }
                    this._swapperMappings = swapperMappings;                              // Volatile store synchronizes-with loads in getters.
                }
                lock ( _free )
                {
                    _free.addAll(freeIds);
                }
            }
        }
 private bool NextFromTxState()
 {
     if (_txTypeIterator == null && !_txTypes.Empty)
     {
         _txTypeIterator = _txTypes.intIterator();
         //here it may be tempting to do txTypes.clear()
         //however that will also clear the iterator
     }
     if (_txTypeIterator != null && _txTypeIterator.hasNext())
     {
         _storeCursor.setCurrent(_txTypeIterator.next(), NO_ID, NO_ID, NO_ID);
         return(true);
     }
     return(false);
 }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowIterating()
        public virtual void ShouldAllowIterating()
        {
            // Given
            SimpleBitSet set = new SimpleBitSet(64);

            set.Put(4);
            set.Put(7);
            set.Put(63);
            set.Put(78);

            // When
            IntIterator    iterator = set.GetEnumerator();
            MutableIntList found    = new IntArrayList();

            while (iterator.hasNext())
            {
                found.add(iterator.next());
            }

            // Then
            assertThat(found, equalTo(IntLists.immutable.of(4, 7, 63, 78)));
        }