Attempt to implement streaming optimization in DiskS3.

This commit is contained in:
Vladimir Chebotarev 2020-07-12 16:53:08 +03:00
parent 718523b0ee
commit 67f9d8124b

View File

@ -26,9 +26,28 @@ public:
off_t seek(off_t off, int whence) override off_t seek(off_t off, int whence) override
{ {
swap(*nested); off_t position = getPosition();
off_t position = nested->seek(off, whence);
swap(*nested); if (whence == SEEK_CUR)
{
off += position;
whence = SEEK_SET;
}
if (whence == SEEK_SET && off >= position && off < position + 1024*1024)
{
swap(*nested);
nested->ignore(off - position);
swap(*nested);
position = off;
}
else
{
swap(*nested);
position = nested->seek(off, whence);
swap(*nested);
}
return position; return position;
} }