//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Void call() throws Exception public override Void Call() { Random random = new Random(); int recordsPerPage = _format.RecordsPerPage; int recordSize = _format.RecordSize; using (PageCursor cursor = _pagedFile.io(0, PF_SHARED_WRITE_LOCK)) { while (!_condition.fulfilled()) { int recordId = random.Next(_maxRecords); int pageId = recordId / recordsPerPage; int recordOffset = (recordId % recordsPerPage) * recordSize; _locks.@lock(recordId); try { assertTrue(cursor.Next(pageId), "I must be able to access pages"); cursor.Offset = recordOffset; long newValue = _format.incrementCounter(cursor, _threadId); _countSum++; assertFalse(cursor.ShouldRetry(), "Write lock, so never a need to retry"); assertThat("Record-local count must be less than or equal to thread-local count sum", newValue, lessThanOrEqualTo(_countSum)); } finally { _locks.unlock(recordId); } } } return(null); }
public override void Get(long index, sbyte[] into) { long pageId = pageId(index); int offset = offset(index); try { using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_READ_LOCK)) { cursor.Next(); do { for (int i = 0; i < into.Length; i++) { into[i] = cursor.GetByte(offset + i); } } while (cursor.ShouldRetry()); CheckBounds(cursor); } } catch (IOException e) { throw new UncheckedIOException(e); } }
public override int Get3ByteInt(long index, int offset) { long pageId = pageId(index); offset += offset(index); try { using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_READ_LOCK)) { cursor.Next(); int result; do { int lowWord = cursor.GetShort(offset) & 0xFFFF; int highByte = cursor.GetByte(offset + Short.BYTES) & 0xFF; result = lowWord | (highByte << (sizeof(short) * 8)); } while (cursor.ShouldRetry()); CheckBounds(cursor); return(result == 0xFFFFFF ? -1 : result); } } catch (IOException e) { throw new UncheckedIOException(e); } }
public override long Get6ByteLong(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 { long low4b = cursor.GetInt(offset) & 0xFFFFFFFFL; long high2b = cursor.GetShort(offset + Integer.BYTES) & 0xFFFF; result = low4b | (high2b << (sizeof(int) * 8)); } while (cursor.ShouldRetry()); CheckBounds(cursor); return(result == 0xFFFFFFFFFFFFL ? -1 : result); } } catch (IOException e) { throw new UncheckedIOException(e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Record readRecord(org.neo4j.io.pagecache.PageCursor cursor) throws java.io.IOException public override Record ReadRecord(PageCursor cursor) { int offset = cursor.Offset; sbyte[] bytes = new sbyte[RecordSize]; do { cursor.Offset = offset; cursor.GetBytes(bytes); } while (cursor.ShouldRetry()); return(new PageCountRecord(bytes)); }
/// <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); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Record readRecord(org.neo4j.io.pagecache.PageCursor cursor) throws java.io.IOException public override Record ReadRecord(PageCursor cursor) { int offset = cursor.Offset; sbyte t; sbyte f; short f1; int r; long f2; do { cursor.Offset = offset; t = cursor.Byte; f = cursor.Byte; f1 = cursor.Short; r = cursor.Int; f2 = cursor.Long; } while (cursor.ShouldRetry()); return(new StandardRecord(t, f, f1, r, f2)); }
/// <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)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private <R extends org.neo4j.kernel.impl.store.record.AbstractBaseRecord> void readAndVerifyRecord(R written, R read, RecordFormat<R> format, RecordKey<R> key, org.neo4j.io.pagecache.PagedFile storeFile, int recordSize, boolean assertPostReadOffset) throws java.io.IOException private void ReadAndVerifyRecord <R>(R written, R read, RecordFormat <R> format, RecordKey <R> key, PagedFile storeFile, int recordSize, bool assertPostReadOffset) where R : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord { using (PageCursor cursor = storeFile.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PF_SHARED_READ_LOCK)) { AssertedNext(cursor); read.Id = written.Id; /* * Retry loop is needed here because format does not handle retries on the primary cursor. * Same retry is done on the store level in {@link org.neo4j.kernel.impl.store.CommonAbstractStore} */ int offset = Math.toIntExact(written.Id * recordSize); do { cursor.Offset = offset; format.Read(read, cursor, NORMAL, recordSize); } while (cursor.ShouldRetry()); AssertWithinBounds(written, cursor, "reading"); if (assertPostReadOffset) { assertEquals("Cursor is positioned on first byte of next record after a read", offset + recordSize, cursor.Offset); } cursor.CheckAndClearCursorException(); // THEN if (written.inUse()) { assertEquals(written.inUse(), read.inUse()); assertEquals(written.Id, read.Id); assertEquals(written.SecondaryUnitId, read.SecondaryUnitId); key.AssertRecordsEquals(written, read); } else { assertEquals(written.inUse(), read.inUse()); } } }
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); } }