Blame source/uds/openChapter.h

Packit b55c50
/*
Packit b55c50
 * Copyright (c) 2020 Red Hat, Inc.
Packit b55c50
 *
Packit b55c50
 * This program is free software; you can redistribute it and/or
Packit b55c50
 * modify it under the terms of the GNU General Public License
Packit b55c50
 * as published by the Free Software Foundation; either version 2
Packit b55c50
 * of the License, or (at your option) any later version.
Packit b55c50
 * 
Packit b55c50
 * This program is distributed in the hope that it will be useful,
Packit b55c50
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit b55c50
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit b55c50
 * GNU General Public License for more details.
Packit b55c50
 * 
Packit b55c50
 * You should have received a copy of the GNU General Public License
Packit b55c50
 * along with this program; if not, write to the Free Software
Packit b55c50
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit b55c50
 * 02110-1301, USA. 
Packit b55c50
 *
Packit b55c50
 * $Id: //eng/uds-releases/jasper/src/uds/openChapter.h#1 $
Packit b55c50
 */
Packit b55c50
Packit b55c50
#ifndef OPENCHAPTER_H
Packit b55c50
#define OPENCHAPTER_H 1
Packit b55c50
Packit b55c50
#include "common.h"
Packit b55c50
#include "geometry.h"
Packit b55c50
#include "index.h"
Packit b55c50
#include "indexComponent.h"
Packit b55c50
Packit b55c50
extern const IndexComponentInfo OPEN_CHAPTER_INFO;
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * OpenChapter handles writing the open chapter records to the volume. It also
Packit b55c50
 * manages the open chapter index component, and all the tools to generate and
Packit b55c50
 * parse the open chapter file. The open chapter file interleaves records from
Packit b55c50
 * each openChapterZone structure.
Packit b55c50
 *
Packit b55c50
 * 

Once each open chapter zone is filled, the records are interleaved to

Packit b55c50
 * preserve temporal locality, the index pages are generated through a
Packit b55c50
 * delta chapter index, and the record pages are derived by sorting each
Packit b55c50
 * page-sized batch of records by their names.
Packit b55c50
 *
Packit b55c50
 * 

Upon index shutdown, the open chapter zone records are again

Packit b55c50
 * interleaved, and the records are stored as a single array. The hash
Packit b55c50
 * slots are not preserved, since the records may be reassigned to new
Packit b55c50
 * zones at load time.
Packit b55c50
 **/
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Close the open chapter and write it to disk.
Packit b55c50
 *
Packit b55c50
 * @param chapterZones         The zones of the chapter to close
Packit b55c50
 * @param zoneCount            The number of zones
Packit b55c50
 * @param volume               The volume to which to write the chapter
Packit b55c50
 * @param chapterIndex         The OpenChapterIndex to use while writing
Packit b55c50
 * @param collatedRecords      Collated records array to use while writing
Packit b55c50
 * @param virtualChapterNumber The virtual chapter number of the open chapter
Packit b55c50
 *
Packit b55c50
 * @return UDS_SUCCESS or an error code
Packit b55c50
 **/
Packit b55c50
int closeOpenChapter(OpenChapterZone  **chapterZones,
Packit b55c50
                     unsigned int       zoneCount,
Packit b55c50
                     Volume            *volume,
Packit b55c50
                     OpenChapterIndex  *chapterIndex,
Packit b55c50
                     UdsChunkRecord    *collatedRecords,
Packit b55c50
                     uint64_t           virtualChapterNumber)
Packit b55c50
  __attribute__((warn_unused_result));
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Write out a partially filled chapter to a file.
Packit b55c50
 *
Packit b55c50
 * @param index        the index to save the data from
Packit b55c50
 * @param writer       the writer to write out the chapters
Packit b55c50
 *
Packit b55c50
 * @return UDS_SUCCESS on success
Packit b55c50
 **/
Packit b55c50
int saveOpenChapters(Index *index, BufferedWriter *writer)
Packit b55c50
  __attribute__((warn_unused_result));
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Read a partially filled chapter from a file.
Packit b55c50
 *
Packit b55c50
 * @param index        the index to load the data into
Packit b55c50
 * @param reader       the buffered reader to read from
Packit b55c50
 *
Packit b55c50
 * @return UDS_SUCCESS on success
Packit b55c50
 **/
Packit b55c50
int loadOpenChapters(Index *index, BufferedReader *reader)
Packit b55c50
  __attribute__((warn_unused_result));
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Compute the size of the maximum open chapter save image.
Packit b55c50
 *
Packit b55c50
 * @param geometry      the index geometry
Packit b55c50
 *
Packit b55c50
 * @return the number of bytes of the largest possible open chapter save
Packit b55c50
 *         image
Packit b55c50
 **/
Packit b55c50
uint64_t computeSavedOpenChapterSize(Geometry *geometry);
Packit b55c50
Packit b55c50
#endif /* OPENCHAPTER_H */