private CompletableFuture < PageWrapper > fetchPage ( PagePointer pagePointer , PageWrapper parentPage , PageCollection pageCollection , Duration timeout ) { PageWrapper fromCache = pageCollection . get ( pagePointer . getOffset ( ) ) ; if ( fromCache != null ) { return CompletableFuture . completedFuture ( fromCache ) ; } return readPage ( pagePointer . getOffset ( ) , pagePointer . getLength ( ) , timeout ) . thenApply ( data -> { if ( data . getLength ( ) != pagePointer . getLength ( ) ) { throw new IllegalDataFormatException ( String . format ( "Requested page of length %s from offset %s, got a page of length %s." , pagePointer . getLength ( ) , pagePointer . getOffset ( ) , data . getLength ( ) ) ) ; } val pageConfig = BTreePage . isIndexPage ( data ) ? this . indexPageConfig : this . leafPageConfig ; return pageCollection . insert ( PageWrapper . wrapExisting ( new BTreePage ( pageConfig , data ) , parentPage , pagePointer ) ) ; } ) ; }
Loads up a single Page .