2019-10-17 13:44:47 +08:00
|
|
|
/*
|
|
|
|
* FileConverter.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2019 Apple Inc. and the FoundationDB project authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FDBBACKUP_FILECONVERTER_H
|
|
|
|
#define FDBBACKUP_FILECONVERTER_H
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-26 13:00:13 +08:00
|
|
|
#include <cinttypes>
|
2019-10-17 13:44:47 +08:00
|
|
|
#include "flow/SimpleOpt.h"
|
|
|
|
|
2019-10-27 00:27:29 +08:00
|
|
|
namespace file_converter {
|
|
|
|
|
2019-10-17 13:44:47 +08:00
|
|
|
// File format convertion constants
|
|
|
|
enum {
|
|
|
|
OPT_CONTAINER,
|
|
|
|
OPT_BEGIN_VERSION,
|
Decode out of order mutations in old mutation logs
In the old mutation logs, a version's mutations are serialized as a buffer.
Then the buffer is split into smaller chunks, e.g., 10000 bytes each. When
writting chunks to the final mutation log file, these chunks can be flushed
out of order. For instance, the (version, chunck_part) can be in the order of
(3, 0), (4, 0), (3, 1). As a result, the decoder must read forward to find all
chunks of data for a version.
Another complication is that the files are organized into blocks, where (3, 1)
can be in a subsequent block. This change checks the value size for each
version, if the size is smaller than the right size, the decoder will look
for the missing chucks in the next block.
2020-03-11 06:45:57 +08:00
|
|
|
OPT_CRASHONERROR,
|
2019-10-17 13:44:47 +08:00
|
|
|
OPT_END_VERSION,
|
|
|
|
OPT_TRACE,
|
|
|
|
OPT_TRACE_DIR,
|
|
|
|
OPT_TRACE_FORMAT,
|
|
|
|
OPT_TRACE_LOG_GROUP,
|
2019-11-26 13:00:13 +08:00
|
|
|
OPT_INPUT_FILE,
|
2019-10-17 13:44:47 +08:00
|
|
|
OPT_HELP
|
|
|
|
};
|
|
|
|
|
2019-11-26 13:00:13 +08:00
|
|
|
CSimpleOpt::SOption gConverterOptions[] = { { OPT_CONTAINER, "-r", SO_REQ_SEP },
|
|
|
|
{ OPT_CONTAINER, "--container", SO_REQ_SEP },
|
|
|
|
{ OPT_BEGIN_VERSION, "-b", SO_REQ_SEP },
|
|
|
|
{ OPT_BEGIN_VERSION, "--begin", SO_REQ_SEP },
|
Decode out of order mutations in old mutation logs
In the old mutation logs, a version's mutations are serialized as a buffer.
Then the buffer is split into smaller chunks, e.g., 10000 bytes each. When
writting chunks to the final mutation log file, these chunks can be flushed
out of order. For instance, the (version, chunck_part) can be in the order of
(3, 0), (4, 0), (3, 1). As a result, the decoder must read forward to find all
chunks of data for a version.
Another complication is that the files are organized into blocks, where (3, 1)
can be in a subsequent block. This change checks the value size for each
version, if the size is smaller than the right size, the decoder will look
for the missing chucks in the next block.
2020-03-11 06:45:57 +08:00
|
|
|
{ OPT_CRASHONERROR, "--crash", SO_NONE },
|
2019-11-26 13:00:13 +08:00
|
|
|
{ OPT_END_VERSION, "-e", SO_REQ_SEP },
|
|
|
|
{ OPT_END_VERSION, "--end", SO_REQ_SEP },
|
|
|
|
{ OPT_TRACE, "--log", SO_NONE },
|
|
|
|
{ OPT_TRACE_DIR, "--logdir", SO_REQ_SEP },
|
|
|
|
{ OPT_TRACE_FORMAT, "--trace_format", SO_REQ_SEP },
|
|
|
|
{ OPT_TRACE_LOG_GROUP, "--loggroup", SO_REQ_SEP },
|
|
|
|
{ OPT_INPUT_FILE, "-i", SO_REQ_SEP },
|
|
|
|
{ OPT_INPUT_FILE, "--input", SO_REQ_SEP },
|
|
|
|
{ OPT_HELP, "-?", SO_NONE },
|
|
|
|
{ OPT_HELP, "-h", SO_NONE },
|
|
|
|
{ OPT_HELP, "--help", SO_NONE },
|
|
|
|
SO_END_OF_OPTIONS };
|
2019-10-17 13:44:47 +08:00
|
|
|
|
2019-10-27 00:27:29 +08:00
|
|
|
} // namespace file_converter
|
|
|
|
|
2019-10-17 13:44:47 +08:00
|
|
|
#endif // FDBBACKUP_FILECONVERTER_H
|