Commit b33c3a65 authored by Christian Rober's avatar Christian Rober Committed by Yoni Fogel

refs #4885 Fixed comments and comment structure for upgrade helper functions

git-svn-id: file:///svn/toku/tokudb@45214 c7de825b-a66e-492c-adef-691d508d4ae1
parent f6f07370
/* -*- mode: C; c-basic-offset: 4 -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id: ft-serialize.c 43686 2012-05-18 23:21:00Z leifwalsh $"
#ident "$Id: ft-node-serialize.c 43686 2012-05-18 23:21:00Z leifwalsh $"
#ident "Copyright (c) 2007-2010 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <ft-internal.h>
#include <db.h>
////////////////////////////////////////
// 1. Sets initial values
//
/*
* ft-node-deserialize.c -
* This file contains functions used by deserializtion
* code paths in and out of the engine. The functions can,
* essentially, be broken up into two types. Some of these
* functions return error codes based expected values inside
* the fractal tree node, others merely read the specific
* quantities of bytes out of the buffer. It is expeceted
* that these will be called in the correct order by users
* of these functions/this API.
*
*/
// Sets initial values for the given fractal tree node to be
// desiralized
inline void
initialize_ftnode(FTNODE node, BLOCKNUM blocknum)
{
......@@ -22,18 +34,15 @@ initialize_ftnode(FTNODE node, BLOCKNUM blocknum)
node->layout_version_read_from_disk = 0;
}
// TODO:
/************************
* In other deserialization code, we check the rb size member. We
* TODO: In other deserialization code, we check the rb size member. We
* verify that it is greater than or equal to 24. Ignoring this magic
* number for a moment, should we put this check in its own function? *
*************************/
/////////////////////////////////////////////////////////////////////
// 2. Read and check the 'magic' bytes on disk. Returns an error if
// Read and check the 'magic' bytes on disk. Returns an error if
// the magic does not match.
//
int
read_and_check_magic(struct rbuf *rb)
{
......@@ -42,14 +51,14 @@ read_and_check_magic(struct rbuf *rb)
rbuf_literal_bytes(rb, &magic, 8);
if (memcmp(magic, "tokuleaf", 8)!=0 &&
memcmp(magic, "tokunode", 8)!=0) {
r = DB_BADFORMAT; // TODO: Return more meaningful error.
r = DB_BADFORMAT; // TODO: Return more meaningful error.
}
return r;
}
////////////////////
// 3.
// Read the version number from the given buffer
// and returns an error if the version is too old.
int
read_and_check_version(FTNODE node, struct rbuf *rb)
{
......@@ -57,14 +66,14 @@ read_and_check_version(FTNODE node, struct rbuf *rb)
int version = rbuf_int(rb);
node->layout_version_read_from_disk = version;
if (version < FT_LAYOUT_MIN_SUPPORTED_VERSION) {
r = 1; // TODO: Better error reporting.
r = 1; // TODO: Better error reporting.
}
return r;
}
////////////////////
// 4.
// Reads the basic version, build, and child info from
// the given buffer.
void
read_node_info(FTNODE node, struct rbuf *rb, int version)
{
......@@ -74,9 +83,10 @@ read_node_info(FTNODE node, struct rbuf *rb, int version)
node->n_children = rbuf_int(rb);
}
////////////////////
// 5.
// <CER> Should these be two seperate functions?
// Allocates the partitions based on the given node's nubmer
// of children. It then reads, out of the given buffer,
// the start and size of each child partition.
// TODO: Should these be two seperate functions?
void
allocate_and_read_partition_offsets(FTNODE node, struct rbuf *rb, FTNODE_DISK_DATA *ndd)
{
......@@ -90,8 +100,9 @@ allocate_and_read_partition_offsets(FTNODE node, struct rbuf *rb, FTNODE_DISK_DA
}
}
////////////////////
// 6. Check the node info checksum.
// Compares checksum of stored (in the given buffer) checksum
// and the checksum of the buffer itself. If these are NOT
// equal, this function returns an appropriate error code.
int
check_node_info_checksum(struct rbuf *rb)
{
......@@ -102,54 +113,8 @@ check_node_info_checksum(struct rbuf *rb)
if (stored_checksum != checksum) {
// TODO: dump_bad_block(rb->buf, rb->size);
r = TOKUDB_BAD_CHECKSUM;
r = TOKUDB_BAD_CHECKSUM;
}
return r;
}
// Two functions, at this point, SHOULD be split into sperate read and
// checksum check calls:
// 1. read_and_decompress_sub_block - this is generic, used elsewhere.
// So....
// a. call read_compressed_sub_block() directly
// then....
//
// 2. deserialize_ftnode_info() - this actually reads in the node
// 'info' fields, such as height, nodesize, etc.
/////////////////////////////////
// ?. ----
// setup_ftnode_paritions() -
// calls :
// a. update_bfe_using_ftnode
// b. setup_partitions_using_bfe()
/////////////////////////////////
// ?. partition from sub-block deserialization.
// A.decompress_and_deserialize_worker()
// calls:
// a. read_and_decompress_sub_block (SEE ABOVE) -
// -calls:
// -ii. read_compressed_sub_block() - Returns checksum error AND reads out buffer.
// b. deserialize_ftnode_partition()
// -calls:
// -ii. verify_ftnode_sub_block() - JUST verifies checksum.
//
// OR
//
// B. check_and_copy_compressed_sub_block_worker
// calls:
// a. read_compressed_sub_block() - Returns checksum AND reads out of buffer.
/////////////////////////////////
// 1. first calls verify_ftnode_sub_block() which must be refactored
// into two seperate calls.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment