packagefs: Add caching for the package file heap reader
* ReaderImplBase:
- Add virtual CreateCachedHeapReader() which can create a cached
reader based on the given heap reader.
- Rename HeapReader() to RawHeapReader() and add HeapReader() for the
cached heap reader.
- Add DetachHeapReader() to allow a clients to remove the heap
reader(s) after deleting the ReaderImplBase object.
* packagefs:
- Add CachedDataReader class, which wraps a given
BAbstractBufferedDataReader and provides caching for it using a
VMCache. The implementation is based on the IOCache implementation.
- Use CachedDataReader to wrap the heap reader. For file data that
means they are cached twice -- in the heap reader cache and in the
file cache -- but due to the heap reader using a VMCache as well,
the pages will be recycled automatically anyway. For attribute data
the cache should be very helpful, since they weren't cached at all
before.
This commit is contained in:
@@ -40,7 +40,9 @@ public:
|
||||
uint64 HeapOffset() const;
|
||||
uint64 HeapSize() const;
|
||||
|
||||
PackageFileHeapReader* HeapReader() const
|
||||
PackageFileHeapReader* RawHeapReader() const
|
||||
{ return inherited::RawHeapReader(); }
|
||||
BAbstractBufferedDataReader* HeapReader() const
|
||||
{ return inherited::HeapReader(); }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace BPackageKit {
|
||||
namespace BHPKG {
|
||||
|
||||
|
||||
class BAbstractBufferedDataReader;
|
||||
class BErrorOutput;
|
||||
|
||||
|
||||
@@ -71,8 +72,23 @@ protected:
|
||||
|
||||
BErrorOutput* ErrorOutput() const;
|
||||
|
||||
PackageFileHeapReader* HeapReader() const
|
||||
uint64 UncompressedHeapSize() const;
|
||||
|
||||
PackageFileHeapReader* RawHeapReader() const
|
||||
{ return fRawHeapReader; }
|
||||
BAbstractBufferedDataReader* HeapReader() const
|
||||
{ return fHeapReader; }
|
||||
// equals RawHeapReader(), if uncached
|
||||
|
||||
BAbstractBufferedDataReader* DetachHeapReader(
|
||||
PackageFileHeapReader** _rawHeapReader
|
||||
= NULL);
|
||||
// Detaches both raw and (if applicable)
|
||||
// cached heap reader. The called gains
|
||||
// ownership. The FD may need to be set on
|
||||
// the raw heap reader, if it shall be used
|
||||
// after destroying this object and Init()
|
||||
// has been called with keepFD == true.
|
||||
|
||||
protected:
|
||||
class AttributeHandlerContext;
|
||||
@@ -95,6 +111,10 @@ protected:
|
||||
uint32 chunkSize, off_t offset,
|
||||
uint64 compressedSize,
|
||||
uint64 uncompressedSize);
|
||||
virtual status_t CreateCachedHeapReader(
|
||||
PackageFileHeapReader* heapReader,
|
||||
BAbstractBufferedDataReader*&
|
||||
_cachedReader);
|
||||
status_t InitSection(PackageFileSection& section,
|
||||
uint64 endOffset, uint64 length,
|
||||
uint64 maxSaneLength, uint64 stringsLength,
|
||||
@@ -156,7 +176,8 @@ private:
|
||||
int fFD;
|
||||
bool fOwnsFD;
|
||||
|
||||
PackageFileHeapReader* fHeapReader;
|
||||
PackageFileHeapReader* fRawHeapReader;
|
||||
BAbstractBufferedDataReader* fHeapReader;
|
||||
|
||||
PackageFileSection* fCurrentSection;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user