/********************************************************************
* This software is "commercial computer software" as defined in the *
* Federal Acquisition Regulations and is subject to BlackLynx       *
* Inc's standard End User License Agreement.                        *
*                                                                   *
* CONFIDENTIAL - All source code is the propriety and confidential  *
* information of BlackLynx Inc.                                     *
*                                                                   *
* Copyright 2014-2020 BlackLynx Inc.                                *
* Unpublished -- all rights reserved under the copyright laws       *
* of the United States.                                             *
********************************************************************/

#include "Chunk.h"
#include "Utilities/BufferAllocator.h"

BlackLynx::SearchLynx::Chunk::Chunk(
    const std::string&  filename,
    uint64_t            chunkId,
    uint32_t            chunkSize,
    uint32_t            extraSize,
    uint64_t            fileOffset)
    : m_filename(filename),
      m_chunkId(chunkId),
      m_chunkSize(chunkSize),
      m_extraSize(extraSize),
      m_fileOffset(fileOffset),
      p_chunkData(nullptr)
{
}
    
BlackLynx::SearchLynx::Chunk::~Chunk()
{
}

void BlackLynx::SearchLynx::Chunk::allocateBuffer()
{
    auto bufAllocator = BufferAllocator::getInstance();
    p_chunkData = bufAllocator->request(m_chunkSize + m_extraSize);
}

