APISonar


org.neo4j.io.pagecache.PagedFile.io

> org > neo4j > io > pagecache > PagedFile > io
org APIs neo4j APIs io APIs pagecache APIs PagedFile APIs io APIs

Example 1
SingleCursorPageLoader( PagedFile file ) throws IOException
    {
        cursor = file.io( 0, PF_SHARED_READ_LOCK );
    }
Example 2
protected PagedFile pagedFile;

    public void writeToPagedFile( RECORD record ) throws IOException
    {
        try(PageCursor io = pagedFile.io( storeToolkit.pageId( recordFormat.id( record ) ), PagedFile.PF_EXCLUSIVE_LOCK ))
        {
            io.next();
            recordFormat.serialize( io, storeToolkit.recordOffset( recordFormat.id( record ) ), record );
        }
    }
Example 3
public void verifyChecksums( PagedFile pagedFile ) throws Exception
    {
        try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_LOCK ) )
        {
            while ( cursor.next() )
            {
                for ( int recordNumber = 0; recordNumber < recordsPerPage; recordNumber++ )
                {
                    verifyChecksum( cursor, recordNumber );
                }
            }
        }
    }
Example 4
public void verifyCounts( PagedFile pagedFile ) throws IOException
    {
        try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_LOCK ) )
        {
            for ( int pageNumber = 0; cursor.next(); pageNumber++ )
            {
                verifyPage( cursor, pageNumber );
            }
        }
    }
Example 5
private final PagedFile pageFile = mock( PagedFile.class );

    public void setUpMocks() throws IOException
    {
        when( idGeneratorFactory.open( any( File.class ), eq( idType ), anyInt(), anyInt() ) )
                .thenReturn( idGenerator );

        when( pageFile.pageSize() ).thenReturn( PAGE_SIZE );
        when( pageFile.io( anyLong(), anyInt() ) ).thenReturn( pageCursor );
        when( pageCache.map( eq( storeFile ), anyInt() ) ).thenReturn( pageFile );
    }
Example 6
private final PagedFile delegate;

    public PageCursor io( long pageId, int pf_flags ) throws IOException
    {
        adversary.injectFailure( IllegalStateException.class );
        PageCursor pageCursor = delegate.io( pageId, pf_flags );
        if ( (pf_flags & PF_SHARED_READ_LOCK) == PF_SHARED_READ_LOCK )
        {
            return new AdversarialReadPageCursor( pageCursor, adversary );
        }
        return new AdversarialWritePageCursor( pageCursor, adversary );
    }
Example 7
private void verifyResults( RecordFormat format, PagedFile pagedFile, List<RecordStresser> recordStressers )
            throws IOException
    {
        for ( RecordStresser stresser : recordStressers )
        {
            stresser.verifyCounts();
        }
        try ( PageCursor cursor = pagedFile.io( 0, PagedFile.PF_SHARED_READ_LOCK ) )
        {
            while ( cursor.next() )
            {
                format.verifyCheckSums( cursor );
            }
        }
    }
Example 8
public void write( PagedFile pagedFile ) throws IOException
    {
        try ( PageCursor page = pagedFile.io( 0, PF_EXCLUSIVE_LOCK ) )
        {
            if ( page.next() )
            {
                write( page );
            }
            else
            {
                throw new IOException( "Could not write count store header page" );
            }
        }
    }
Example 9
private final PagedFile pagedFile;

    private PageCursor openRootCursor( int pfFlags ) throws IOException
    {
        PageCursor cursor = pagedFile.io( 0L /*Ignored*/, pfFlags );
        root.goTo( cursor );
        return cursor;
    }
Example 10
private final PagedFile pagedFile;

    public void verifyCounts() throws IOException
    {
        long actualSum = 0;
        try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_READ_LOCK ) )
        {
            while ( cursor.next() )
            {
                actualSum += format.sumCountsForThread( cursor, threadId );
            }
        }
        assertThat( "Thread specific sum across all records", actualSum, is( countSum ) );
    }
Example 11
protected PagedFile storeFile;

    public PageCursor openPageCursorForReading( long id )
    {
        try
        {
            long pageId = pageIdForRecord( id );
            return storeFile.io( pageId, PF_SHARED_READ_LOCK );
        }
        catch ( IOException e )
        {
            // TODO: think about what we really should be doing with the exception handling here...
            throw new UnderlyingStorageException( e );
        }
    }
Example 12
protected PagedFile pagedFile;

    public RECORD getRecord( long id, RECORD record, RecordLoad mode )
    {
        try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_READ_LOCK ) )
        {
            readIntoRecord( id, record, mode, cursor );
            return record;
        }
        catch ( IOException e )
        {
            throw new UnderlyingStorageException( e );
        }
    }
Example 13
private final PagedFile pagedFile = mock( PagedFile.class );

    void setUpPagedFile() throws IOException
    {
        cursor = new PageAwareByteArrayCursor( PAGE_SIZE );
        when( pagedFile.io( anyLong(), anyInt() ) ).thenAnswer(
                invocation -> cursor.duplicate( invocation.getArgument( 0 ) ) );
        freelist.initialize( BASE_ID + 1, BASE_ID + 1, BASE_ID + 1, 0, 0 );
    }
Example 14
public void getPageCursor() throws IOException
    {
        PageCache mockedPageCache = mock( PageCache.class );
        PagedFile mockedPagedFile = mock( PagedFile.class );
        PageCursor mockedCursor = mock( PageCursor.class );
        when( mockedPagedFile.io( anyLong(), anyInt() ) ).thenReturn( mockedCursor );
        when( mockedPageCache.map( any( File.class ), anyInt(), anyVararg() ) ).thenReturn( mockedPagedFile );
        pageCache = new AccessCheckingPageCache( mockedPageCache );
        PagedFile file = pageCache.map( new File( "some file" ), 512 );
        cursor = file.io( 0, PagedFile.PF_SHARED_READ_LOCK );
    }
Example 15
private void initializeFile( PagedFile pagedFile, Page... pages ) throws IOException
    {
        try ( PageCursor cursor = pagedFile.io( 0, PagedFile.PF_SHARED_WRITE_LOCK ) )
        {
            for ( Page page : pages )
            {
                cursor.next();
                page.write( pagedFile, cursor, treeNode, layout, checkpointedTreeState, unstableTreeState );
            }
        }
    }
Example 16
private final PagedFile pagedFile;

    public void onCounterUpdated( int pageNumber, int recordNumber, int counterNumber ) throws IOException
    {
        try ( PageCursor cursor = pagedFile.io( pageNumber, PF_EXCLUSIVE_LOCK ) )
        {
            assertThat( "i must be able to access pages", cursor.next(), is( true ) );

            setOffset( cursor, recordNumber, counterNumber );
            long count = cursor.getLong();
            setOffset( cursor, recordNumber, counterNumber );
            cursor.putLong( count + 1 );
        }
    }
Example 17
protected PagedFile storeFile;

    public RecordCursor<RECORD> placeRecordCursor( final long id, final RecordCursor<RECORD> cursor,
            final RecordLoad mode )
    {
        try
        {
            PageCursor pageCursor = storeFile.io( pageIdForRecord( id ), PF_SHARED_READ_LOCK );
            cursor.init( id, mode, pageCursor );
            return cursor;
        }
        catch ( IOException e )
        {
            throw new UnderlyingStorageException( e );
        }
    }
Example 18
private final PagedFile pagedFile;

    void initializeAfterCreation() throws IOException
    {
        // Allocate a new free-list page id and set both write/read free-list page id to it.
        writePageId = nextLastId();
        readPageId = writePageId;

        try ( PageCursor cursor = pagedFile.io( writePageId, PagedFile.PF_SHARED_WRITE_LOCK ) )
        {
            goTo( cursor, "free-list", writePageId );
            FreelistNode.initialize( cursor );
            checkOutOfBounds( cursor );
        }
    }
Example 19
static <Buffer extends BigEndianByteArrayBuffer> void scanAll( PagedFile file, int startOffset,
            EntryVisitor<? super Buffer> visitor, Buffer key, Buffer value ) throws IOException
    {
        boolean visitHeaders = !(visitor instanceof KeyValueVisitor);
        try ( PageCursor cursor = file.io( startOffset / file.pageSize(), PF_SHARED_READ_LOCK ) )
        {
            if ( !cursor.next() )
            {
                return;
            }
            readKeyValuePair( cursor, startOffset, key, value );
            visitKeyValuePairs( file.pageSize(), cursor, startOffset, visitor, visitHeaders, key, value );
        }
    }
Example 20
private final PagedFile pagedFile;

    private static PageCursor openMetaPageCursor( PagedFile pagedFile, int pfFlags ) throws IOException
    {
        PageCursor metaCursor = pagedFile.io( IdSpace.META_PAGE_ID, pfFlags );
        PageCursorUtil.goTo( metaCursor, "meta page", IdSpace.META_PAGE_ID );
        return metaCursor;
    }
Example 21
private static Pair<TreeState,TreeState> readStatePages( PagedFile pagedFile ) throws IOException
    {
        Pair<TreeState,TreeState> states;
        try ( PageCursor cursor = pagedFile.io( 0L /*ignored*/, PagedFile.PF_SHARED_READ_LOCK ) )
        {
            states = TreeStatePair.readStatePages(
                    cursor, IdSpace.STATE_PAGE_A, IdSpace.STATE_PAGE_B );
        }
        return states;
    }
Example 22
private final PagedFile pagedFile;

    public RawCursor<Hit<KEY,VALUE>,IOException> seek( KEY fromInclusive, KEY toExclusive ) throws IOException
    {
        long generation = this.generation;
        long stableGeneration = stableGeneration( generation );
        long unstableGeneration = unstableGeneration( generation );

        PageCursor cursor = pagedFile.io( 0L /*ignored*/, PagedFile.PF_SHARED_READ_LOCK );
        long rootGen = root.goTo( cursor );

        // Returns cursor which is now initiated with left-most leaf node for the specified range
        return new SeekCursor<>( cursor, bTreeNode, fromInclusive, toExclusive, layout,
                stableGeneration, unstableGeneration, generationSupplier, rootCatchup, rootGen );
    }