Blame source/uds/openChapter.h

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

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

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

Upon index shutdown, the open chapter zone records are again

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