Use strong enum for blocklist prefetch state
This commit is contained in:
parent
cc3ef4cbca
commit
face7c0b0f
@ -72,9 +72,9 @@ void TileGenerator::setSilenceSuggestion(unsigned flags)
|
|||||||
m_silenceSuggestions |= flags;
|
m_silenceSuggestions |= flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileGenerator::setGenerateNoPrefetch(int enable)
|
void TileGenerator::setGenerateNoPrefetch(BlockListPrefetch enable)
|
||||||
{
|
{
|
||||||
m_generateNoPrefetch = enable;
|
m_generatePrefetch = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileGenerator::setDBFormat(BlockPos::StrFormat format, bool query)
|
void TileGenerator::setDBFormat(BlockPos::StrFormat format, bool query)
|
||||||
@ -614,15 +614,15 @@ void TileGenerator::loadBlocks()
|
|||||||
std::cerr << "WARNING: querying database format is only sensible when using the leveldb backend - querying disabled" << std::endl;
|
std::cerr << "WARNING: querying database format is only sensible when using the leveldb backend - querying disabled" << std::endl;
|
||||||
m_reportDatabaseFormat = false;
|
m_reportDatabaseFormat = false;
|
||||||
}
|
}
|
||||||
if (m_reportDatabaseFormat && m_generateNoPrefetch) {
|
if (m_reportDatabaseFormat && m_generatePrefetch != BlockListPrefetch::Prefetch) {
|
||||||
std::cerr << "WARNING: querying database format: ignoring '--disable-blocklist-prefetch' and/or '--prescan-world=disabled'." << std::endl;
|
std::cerr << "WARNING: querying database format: ignoring '--disable-blocklist-prefetch' and/or '--prescan-world=disabled'." << std::endl;
|
||||||
m_generateNoPrefetch = 0;
|
m_generatePrefetch = BlockListPrefetch::Prefetch;
|
||||||
}
|
}
|
||||||
if (m_generateNoPrefetch && !m_databaseFormatSet && m_backend == "leveldb") {
|
if (m_generatePrefetch != BlockListPrefetch::Prefetch && !m_databaseFormatSet && m_backend == "leveldb") {
|
||||||
throw(std::runtime_error("When using --disable-blocklist-prefetch with a leveldb backend, database format must be set (--database-format)"));
|
throw(std::runtime_error("When using --disable-blocklist-prefetch with a leveldb backend, database format must be set (--database-format)"));
|
||||||
}
|
}
|
||||||
if (m_generateNoPrefetch) {
|
if (m_generatePrefetch != BlockListPrefetch::Prefetch) {
|
||||||
if (m_generateNoPrefetch == 1) {
|
if (m_generatePrefetch == BlockListPrefetch::NoPrefetch) {
|
||||||
long long volume = (long long)(m_reqXMax - m_reqXMin + 1) * (m_reqYMax - m_reqYMin + 1) * (m_reqZMax - m_reqZMin + 1);
|
long long volume = (long long)(m_reqXMax - m_reqXMin + 1) * (m_reqYMax - m_reqYMin + 1) * (m_reqZMax - m_reqZMin + 1);
|
||||||
if (volume > MAX_NOPREFETCH_VOLUME) {
|
if (volume > MAX_NOPREFETCH_VOLUME) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -914,7 +914,7 @@ void TileGenerator::loadBlocks()
|
|||||||
<< std::setw(10) << map_blocks << "\n";
|
<< std::setw(10) << map_blocks << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_backend == "leveldb" && !m_generateNoPrefetch) {
|
if (m_backend == "leveldb" && m_generatePrefetch == BlockListPrefetch::Prefetch) {
|
||||||
if (m_databaseFormatFound[BlockPos::AXYZ] && m_databaseFormatFound[BlockPos::I64])
|
if (m_databaseFormatFound[BlockPos::AXYZ] && m_databaseFormatFound[BlockPos::I64])
|
||||||
m_recommendedDatabaseFormat = "mixed";
|
m_recommendedDatabaseFormat = "mixed";
|
||||||
else if (m_databaseFormatFound[BlockPos::AXYZ])
|
else if (m_databaseFormatFound[BlockPos::AXYZ])
|
||||||
@ -1366,7 +1366,7 @@ void TileGenerator::renderMap()
|
|||||||
MapBlockIterator *position;
|
MapBlockIterator *position;
|
||||||
MapBlockIterator *begin;
|
MapBlockIterator *begin;
|
||||||
MapBlockIterator *end;
|
MapBlockIterator *end;
|
||||||
if (m_generateNoPrefetch) {
|
if (m_generatePrefetch != BlockListPrefetch::Prefetch) {
|
||||||
position = new MapBlockIteratorBlockPos();
|
position = new MapBlockIteratorBlockPos();
|
||||||
begin = new MapBlockIteratorBlockPos(BlockPosIterator(
|
begin = new MapBlockIteratorBlockPos(BlockPosIterator(
|
||||||
BlockPos(m_xMin, m_yMax, m_zMax, m_databaseFormat),
|
BlockPos(m_xMin, m_yMax, m_zMax, m_databaseFormat),
|
||||||
@ -1511,7 +1511,7 @@ void TileGenerator::renderMap()
|
|||||||
<< ")\n";
|
<< ")\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_generateNoPrefetch && m_backend == "leveldb" && (m_reportDatabaseFormat || verboseStatistics >= 1)) {
|
if (m_generatePrefetch == BlockListPrefetch::Prefetch && m_backend == "leveldb" && (m_reportDatabaseFormat || verboseStatistics >= 1)) {
|
||||||
cout
|
cout
|
||||||
<< "Database format setting when using --disable-blocklist-prefetch: ";
|
<< "Database format setting when using --disable-blocklist-prefetch: ";
|
||||||
if (!m_recommendedDatabaseFormat.empty())
|
if (!m_recommendedDatabaseFormat.empty())
|
||||||
@ -1536,7 +1536,7 @@ void TileGenerator::renderMap()
|
|||||||
if (progressIndicator && eraseProgress)
|
if (progressIndicator && eraseProgress)
|
||||||
cout << std::setw(50) << "" << "\r";
|
cout << std::setw(50) << "" << "\r";
|
||||||
|
|
||||||
if (m_generateNoPrefetch) {
|
if (m_generatePrefetch != BlockListPrefetch::Prefetch) {
|
||||||
double queryFactor = 1.0 * m_db->getBlocksQueriedCount() / m_db->getBlocksReadCount();
|
double queryFactor = 1.0 * m_db->getBlocksQueriedCount() / m_db->getBlocksReadCount();
|
||||||
if (verboseStatistics >= 4) {
|
if (verboseStatistics >= 4) {
|
||||||
std::cout << std::fixed << std::setprecision(2);
|
std::cout << std::fixed << std::setprecision(2);
|
||||||
|
@ -96,10 +96,16 @@ public:
|
|||||||
UnpackError(const char *t, size_t o, size_t l, size_t dl) : type(t), offset(o), length(l), dataLength(dl) {}
|
UnpackError(const char *t, size_t o, size_t l, size_t dl) : type(t), offset(o), length(l), dataLength(dl) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class BlockListPrefetch {
|
||||||
|
Prefetch,
|
||||||
|
NoPrefetch,
|
||||||
|
NoPrefetchForced
|
||||||
|
};
|
||||||
|
|
||||||
TileGenerator();
|
TileGenerator();
|
||||||
~TileGenerator();
|
~TileGenerator();
|
||||||
void setSilenceSuggestion(unsigned flags);
|
void setSilenceSuggestion(unsigned flags);
|
||||||
void setGenerateNoPrefetch(int enable);
|
void setGenerateNoPrefetch(BlockListPrefetch enable);
|
||||||
void setDBFormat(BlockPos::StrFormat format, bool query);
|
void setDBFormat(BlockPos::StrFormat format, bool query);
|
||||||
void setHeightMap(bool enable);
|
void setHeightMap(bool enable);
|
||||||
void setHeightMapYScale(float scale);
|
void setHeightMapYScale(float scale);
|
||||||
@ -230,7 +236,7 @@ private:
|
|||||||
int m_heightScaleMinor{ 0 };
|
int m_heightScaleMinor{ 0 };
|
||||||
|
|
||||||
DB *m_db = nullptr;
|
DB *m_db = nullptr;
|
||||||
int m_generateNoPrefetch{ 0 };
|
BlockListPrefetch m_generatePrefetch{ BlockListPrefetch::Prefetch };
|
||||||
bool m_databaseFormatSet{ false };
|
bool m_databaseFormatSet{ false };
|
||||||
BlockPos::StrFormat m_databaseFormat{ BlockPos::Unknown };
|
BlockPos::StrFormat m_databaseFormat{ BlockPos::Unknown };
|
||||||
std::string m_recommendedDatabaseFormat;
|
std::string m_recommendedDatabaseFormat;
|
||||||
|
@ -162,7 +162,7 @@ int Mapper::start(int argc, char *argv[]) {
|
|||||||
case OPT_NO_BLOCKLIST_PREFETCH:
|
case OPT_NO_BLOCKLIST_PREFETCH:
|
||||||
if (optarg && *optarg) {
|
if (optarg && *optarg) {
|
||||||
if (strlower(optarg) == "force")
|
if (strlower(optarg) == "force")
|
||||||
generator.setGenerateNoPrefetch(2);
|
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::NoPrefetchForced);
|
||||||
else {
|
else {
|
||||||
std::cerr << "Invalid parameter to '" << long_options[option_index].name << "'; expected 'force' or nothing." << std::endl;
|
std::cerr << "Invalid parameter to '" << long_options[option_index].name << "'; expected 'force' or nothing." << std::endl;
|
||||||
usage();
|
usage();
|
||||||
@ -170,7 +170,7 @@ int Mapper::start(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
generator.setGenerateNoPrefetch(1);
|
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::NoPrefetch);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPT_DATABASE_FORMAT: {
|
case OPT_DATABASE_FORMAT: {
|
||||||
@ -192,11 +192,11 @@ int Mapper::start(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
case OPT_PRESCAN_WORLD: {
|
case OPT_PRESCAN_WORLD: {
|
||||||
std::string opt = strlower(optarg);
|
std::string opt = strlower(optarg);
|
||||||
generator.setGenerateNoPrefetch(0);
|
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::Prefetch);
|
||||||
if (opt == "disabled-force")
|
if (opt == "disabled-force")
|
||||||
generator.setGenerateNoPrefetch(2);
|
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::NoPrefetchForced);
|
||||||
else if (opt == "disabled")
|
else if (opt == "disabled")
|
||||||
generator.setGenerateNoPrefetch(1);
|
generator.setGenerateNoPrefetch(TileGenerator::BlockListPrefetch::NoPrefetch);
|
||||||
else if (opt == "auto")
|
else if (opt == "auto")
|
||||||
generator.setScanEntireWorld(false);
|
generator.setScanEntireWorld(false);
|
||||||
else if (opt == "full")
|
else if (opt == "full")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user