Exemple #1
0
        /// <summary>
        /// Assume the given cursor is writable and has already been positioned at the record offset.
        /// </summary>
        public virtual long IncrementCounter(PageCursor cursor, int threadId)
        {
            int recordOffset   = cursor.Offset;
            int fieldOffset    = recordOffset + (_fieldSize * threadId);
            int checksumOffset = recordOffset + _checksumFieldOffset;

            long newValue = 1 + cursor.GetLong(fieldOffset);

            cursor.PutLong(fieldOffset, newValue);
            cursor.PutLong(checksumOffset, 1 + cursor.GetLong(checksumOffset));
            return(newValue);
        }
Exemple #2
0
        /// <summary>
        /// Verify the checksums on all the records on the given page
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void verifyCheckSums(org.neo4j.io.pagecache.PageCursor cursor) throws java.io.IOException
        public virtual void VerifyCheckSums(PageCursor cursor)
        {
            int recordsPerPage = RecordsPerPage;

            for (int i = 0; i < recordsPerPage; i++)
            {
                int  recordOffset = i * _recordSize;
                long expectedChecksum;
                long actualChecksum;
                do
                {
                    actualChecksum = 0;
                    for (int j = 0; j < _numberOfThreads; j++)
                    {
                        actualChecksum += cursor.GetLong(recordOffset + (j * _fieldSize));
                    }
                    expectedChecksum = cursor.GetLong(recordOffset + _checksumFieldOffset);
                } while (cursor.ShouldRetry());
                string msg = "Checksum for record " + i + " on page " + cursor.CurrentPageId;
                assertThat(msg, actualChecksum, @is(expectedChecksum));
            }
        }
Exemple #3
0
        /// <summary>
        /// Sum up the fields for the given thread for all records on the given page.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public long sumCountsForThread(org.neo4j.io.pagecache.PageCursor cursor, int threadId) throws java.io.IOException
        public virtual long SumCountsForThread(PageCursor cursor, int threadId)
        {
            int  recordsPerPage = RecordsPerPage;
            int  fieldOffset    = _fieldSize * threadId;
            long sum;

            do
            {
                sum = 0;
                for (int i = 0; i < recordsPerPage; i++)
                {
                    sum += cursor.GetLong((i * _recordSize) + fieldOffset);
                }
            } while (cursor.ShouldRetry());
            return(sum);
        }
Exemple #4
0
        public override long GetLong(long index, int offset)
        {
            long pageId = pageId(index);

            offset += offset(index);
            try
            {
                using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_READ_LOCK))
                {
                    cursor.Next();
                    long result;
                    do
                    {
                        result = cursor.GetLong(offset);
                    } while (cursor.ShouldRetry());
                    CheckBounds(cursor);
                    return(result);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }