|
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/indexPageMap.h#2 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef INDEX_PAGE_MAP_H
|
|
Packit Service |
310c69 |
#define INDEX_PAGE_MAP_H 1
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "common.h"
|
|
Packit Service |
310c69 |
#include "geometry.h"
|
|
Packit Service |
310c69 |
#include "indexComponent.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
extern const IndexComponentInfo INDEX_PAGE_MAP_INFO;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef struct indexPageMap IndexPageMap;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef struct {
|
|
Packit Service |
310c69 |
unsigned int lowestList;
|
|
Packit Service |
310c69 |
unsigned int highestList;
|
|
Packit Service |
310c69 |
} IndexPageBounds;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* Notes on IndexPageMap
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* Each volume maintains an index page map which records how the chapter delta
|
|
Packit Service |
310c69 |
* lists are distributed among the index pages for that chapter.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* The map is conceptually a two-dimensional array indexed by chapter number
|
|
Packit Service |
310c69 |
* and index page number within the chapter. Each entry contains the number
|
|
Packit Service |
310c69 |
* of the last delta list on that index page. In order to save memory, the
|
|
Packit Service |
310c69 |
* information for the last page in each chapter is not recorded, as it is
|
|
Packit Service |
310c69 |
* known from the geometry.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef uint16_t IndexPageMapEntry;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
struct indexPageMap {
|
|
Packit Service |
310c69 |
const Geometry *geometry;
|
|
Packit Service |
310c69 |
uint64_t lastUpdate;
|
|
Packit Service |
310c69 |
IndexPageMapEntry *entries;
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Create an index page map.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param geometry The geometry governing the index.
|
|
Packit Service |
310c69 |
* @param mapPtr A pointer to hold the new map.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return A success or error code.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int makeIndexPageMap(const Geometry *geometry, IndexPageMap **mapPtr)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Free an index page map.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param map The index page map to destroy.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void freeIndexPageMap(IndexPageMap *map);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get the virtual chapter number of the last update to the index page map.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param map The index page map
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return the virtual chapter number of the last chapter updated
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
uint64_t getLastUpdate(const IndexPageMap *map);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Update an index page map entry.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param map The map to update
|
|
Packit Service |
310c69 |
* @param virtualChapterNumber The virtual chapter number being updated.
|
|
Packit Service |
310c69 |
* @param chapterNumber The chapter of the entry to update
|
|
Packit Service |
310c69 |
* @param indexPageNumber The index page of the entry to update
|
|
Packit Service |
310c69 |
* @param deltaListNumber The value of the new entry
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int updateIndexPageMap(IndexPageMap *map,
|
|
Packit Service |
310c69 |
uint64_t virtualChapterNumber,
|
|
Packit Service |
310c69 |
unsigned int chapterNumber,
|
|
Packit Service |
310c69 |
unsigned int indexPageNumber,
|
|
Packit Service |
310c69 |
unsigned int deltaListNumber)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Find the page number of the index page in a chapter that will contain the
|
|
Packit Service |
310c69 |
* chapter index entry for a given chunk name, if it exists.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param [in] map The map to search
|
|
Packit Service |
310c69 |
* @param [in] name The chunk name
|
|
Packit Service |
310c69 |
* @param [in] chapterNumber The chapter containing the index page
|
|
Packit Service |
310c69 |
* @param [out] indexPageNumberPtr A pointer to hold the result, guaranteed to
|
|
Packit Service |
310c69 |
* be a valid index page number on UDS_SUCCESS
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS, or UDS_INVALID_ARGUMENT if the chapter number
|
|
Packit Service |
310c69 |
* is out of range
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int findIndexPageNumber(const IndexPageMap *map,
|
|
Packit Service |
310c69 |
const UdsChunkName *name,
|
|
Packit Service |
310c69 |
unsigned int chapterNumber,
|
|
Packit Service |
310c69 |
unsigned int *indexPageNumberPtr)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get the lowest and highest numbered delta lists for the given immutable
|
|
Packit Service |
310c69 |
* chapter index page from the index page map.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param map The index page map
|
|
Packit Service |
310c69 |
* @param chapterNumber The chapter containing the delta list
|
|
Packit Service |
310c69 |
* @param indexPageNumber The index page number within the chapter
|
|
Packit Service |
310c69 |
* @param bounds A structure to hold the list number bounds
|
|
Packit Service |
310c69 |
* for the given page
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getListNumberBounds(const IndexPageMap *map,
|
|
Packit Service |
310c69 |
unsigned int chapterNumber,
|
|
Packit Service |
310c69 |
unsigned int indexPageNumber,
|
|
Packit Service |
310c69 |
IndexPageBounds *bounds)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Compute the size of the index page map save image, including all headers.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param geometry The index geometry.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The number of bytes required to save the index page map.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
uint64_t computeIndexPageMapSaveSize(const Geometry *geometry);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Escaped for testing....
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param geometry The index geometry.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The number of bytes required for the page map data,
|
|
Packit Service |
310c69 |
* exclusive of headers.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
size_t indexPageMapSize(const Geometry *geometry)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif // INDEX_PAGE_MAP_H
|