コード例 #1
0
//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());
                }
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleRelationshipTypesBeyond2Bytes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleRelationshipTypesBeyond2Bytes()
        {
            // given
            RecordFormat <RelationshipTypeTokenRecord> format = HighLimit.RecordFormats.relationshipTypeToken();
            int typeId = 1 << ((sizeof(short) * 8) + (sizeof(sbyte) * 8)) - 1;
            RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord(typeId);
            int recordSize = format.GetRecordSize(NO_STORE_HEADER);

            record.Initialize(true, 10);
            IdSequence doubleUnits = mock(typeof(IdSequence));
            PageCursor cursor      = new StubPageCursor(0, ( int )kibiBytes(8));

            // when
            format.Prepare(record, recordSize, doubleUnits);
            format.Write(record, cursor, recordSize);
            verifyNoMoreInteractions(doubleUnits);

            // then
            RelationshipTypeTokenRecord read = new RelationshipTypeTokenRecord(typeId);

            format.Read(record, cursor, NORMAL, recordSize);
            assertEquals(record, read);
        }