2011-06-27 18:22:14 +00:00
|
|
|
|
#ifndef DBMS_COMMON_BUFFERWITHOWNMEMORY_H
|
|
|
|
|
#define DBMS_COMMON_BUFFERWITHOWNMEMORY_H
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#define DBMS_DEFAULT_BUFFER_SIZE 1048576ULL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Буфер, который сам владеет своим куском памяти для работы.
|
|
|
|
|
* Аргумент шаблона - ReadBuffer или WriteBuffer
|
|
|
|
|
*/
|
|
|
|
|
template <typename Base>
|
|
|
|
|
class BufferWithOwnMemory : public Base
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
std::vector<char> memory;
|
|
|
|
|
public:
|
2011-06-27 18:33:23 +00:00
|
|
|
|
BufferWithOwnMemory(size_t size = DBMS_DEFAULT_BUFFER_SIZE) : Base(NULL, 0), memory(size)
|
2011-06-27 18:22:14 +00:00
|
|
|
|
{
|
|
|
|
|
Base::set(&memory[0], size);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|