@ -738,7 +738,7 @@ private:
if ( s . ok ( ) ) {
if ( s . ok ( ) ) {
buffer_offset_ = offset ;
buffer_offset_ = offset ;
buffer_ . Size ( result . size ( ) ) ;
buffer_ . Size ( result . size ( ) ) ;
assert ( buffer_ . BufferStart ( ) = = result . data ( ) ) ;
assert ( result . size ( ) = = 0 | | buffer_ . BufferStart ( ) = = result . data ( ) ) ;
}
}
return s ;
return s ;
}
}
@ -886,7 +886,7 @@ class ReadaheadSequentialFile : public SequentialFile {
if ( s . ok ( ) ) {
if ( s . ok ( ) ) {
buffer_offset_ = read_offset_ ;
buffer_offset_ = read_offset_ ;
buffer_ . Size ( result . size ( ) ) ;
buffer_ . Size ( result . size ( ) ) ;
assert ( buffer_ . BufferStart ( ) = = result . data ( ) ) ;
assert ( result . size ( ) = = 0 | | buffer_ . BufferStart ( ) = = result . data ( ) ) ;
}
}
return s ;
return s ;
}
}
@ -1027,6 +1027,11 @@ std::unique_ptr<RandomAccessFile> NewReadaheadRandomAccessFile(
std : : unique_ptr < SequentialFile >
std : : unique_ptr < SequentialFile >
SequentialFileReader : : NewReadaheadSequentialFile (
SequentialFileReader : : NewReadaheadSequentialFile (
std : : unique_ptr < SequentialFile > & & file , size_t readahead_size ) {
std : : unique_ptr < SequentialFile > & & file , size_t readahead_size ) {
if ( file - > GetRequiredBufferAlignment ( ) > = readahead_size ) {
// Short-circuit and return the original file if readahead_size is
// too small and hence doesn't make sense to be used for prefetching.
return std : : move ( file ) ;
}
std : : unique_ptr < SequentialFile > result (
std : : unique_ptr < SequentialFile > result (
new ReadaheadSequentialFile ( std : : move ( file ) , readahead_size ) ) ;
new ReadaheadSequentialFile ( std : : move ( file ) , readahead_size ) ) ;
return result ;
return result ;