blob: 362eac375b3923b64438e79f1ddbc006410af2df [file] [log] [blame]
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
#include "cli/Flags.hpp"
#include <cstddef>
#include <cstdio>
#include <string>
#include "cli/DefaultsConfigurator.hpp"
#include "storage/StorageConstants.hpp"
#include "gflags/gflags.h"
using std::fprintf;
namespace quickstep {
DEFINE_bool(print_query, false,
"Print each input query statement. This is useful when running a "
"large number of queries in a batch.");
DEFINE_bool(initialize_db, false, "If true, initialize a database.");
static bool ValidateNumWorkers(const char *flagname, int value) {
if (value > 0) {
return true;
// Detect the hardware concurrency level.
const std::size_t num_hw_threads =
// Use the command-line value if that was supplied, else use the value
// that we computed above, provided it did return a valid value.
// TODO(jmp): May need to change this at some point to keep one thread
// available for the OS if the hardware concurrency level is high.
FLAGS_num_workers = num_hw_threads != 0 ? num_hw_threads : 1;
return FLAGS_num_workers > 0;
DEFINE_int32(num_workers, 0, "Number of worker threads. If this value is "
"specified and is greater than 0, then this user-supplied value is "
"used. Else (i.e. the default case), we examine the reported "
"hardware concurrency level, and use that.");
static const volatile bool num_workers_dummy
= gflags::RegisterFlagValidator(&FLAGS_num_workers, &ValidateNumWorkers);
DEFINE_string(worker_affinities, "",
"A comma-separated list of CPU IDs to pin worker threads to "
"(leaving this empty will cause all worker threads to inherit "
"the affinity mask of the Quickstep process, which typically "
"means that they will all be runable on any CPU according to "
"the kernel's own scheduling policy).");
static bool ValidateStoragePath(const char *flagname,
const std::string &value) {
if (!value.empty() && value.back() != kPathSeparator) {
return true;
DEFINE_string(storage_path, kDefaultStoragePath,
"Filesystem path to store the Quickstep database.");
static const volatile bool storage_path_dummy
= gflags::RegisterFlagValidator(&FLAGS_storage_path, &ValidateStoragePath);
DEFINE_bool(preload_buffer_pool, false,
"If true, pre-load all known blocks into buffer pool before "
"accepting queries (should also set --buffer_pool_slots to be "
"large enough to accomodate the entire database).");
} // namespace quickstep