Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions build_tooling/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,38 @@ def install_tools():
return black or clang


def lint_python(in_place: bool):
def lint_python(in_place: bool, specific_file: str = None):
try:
import black
assert black.__version__ == black_version
except ImportError:
raise RuntimeError("black not installed. Run this script with --install-tools then try again")

if specific_file:
path = specific_file
else:
path = "python/"

if in_place:
return subprocess.run(["black", "-l", "120", "python/"]).returncode
return subprocess.run(["black", "-l", "120", path]).returncode
else:
return subprocess.run(["black", "-l", "120", "--check", "python/"]).returncode
return subprocess.run(["black", "-l", "120", "--check", path]).returncode


def lint_cpp(in_place: bool):
def lint_cpp(in_place: bool, specific_file: str = None):
try:
import clang_format
except ImportError:
raise RuntimeError("clang-format not installed. Run this script with --install-tools then try again")

files = []
root = pathlib.Path("cpp", "arcticdb")
for e in ("*.cpp", "*.hpp"):
for f in root.rglob(e):
files.append(str(f))
if specific_file:
files.append(specific_file)
else:
root = pathlib.Path("cpp", "arcticdb")
for e in ("*.cpp", "*.hpp"):
for f in root.rglob(e):
files.append(str(f))

args = ["clang-format"]
if in_place:
Expand All @@ -69,11 +77,11 @@ def lint_cpp(in_place: bool):
return subprocess.run(args).returncode


def main(type: str, in_place: bool):
def main(type: str, in_place: bool, specific_file: str):
if type == "python":
return lint_python(in_place)
return lint_python(in_place, specific_file)
elif type == "cpp":
return lint_cpp(in_place)
return lint_cpp(in_place, specific_file)
else:
return lint_python(in_place) or lint_cpp(in_place)

Expand Down Expand Up @@ -105,6 +113,11 @@ def main(type: str, in_place: bool):
action='store_true',
help="Apply linting rules to your working copy. Changes files."
)
parser.add_argument(
"-f",
"--file",
help="Apply linting rules to a specific file."
)
args = parser.parse_args()

if args.install_tools:
Expand All @@ -122,6 +135,7 @@ def main(type: str, in_place: bool):
return_code = main(
type=args.type,
in_place=args.in_place,
specific_file=args.file,
)

sys.exit(return_code)
3 changes: 3 additions & 0 deletions cpp/arcticdb/storage/library_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ void LibraryManager::modify_library_option(
case ModifiableLibraryOption::COLUMNS_PER_SEGMENT:
mutable_write_options->set_column_group_size(get_positive_int(new_value));
break;
case ModifiableLibraryOption::RECURSIVE_NORMALIZERS:
mutable_write_options->set_recursive_normalizers(get_bool(new_value));
break;
default:
throw UnsupportedLibraryOptionValue(fmt::format("Invalid library option: {}", option));
}
Expand Down
9 changes: 8 additions & 1 deletion cpp/arcticdb/storage/library_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
#include <arcticdb/entity/protobufs.hpp>

namespace arcticdb::storage {
enum class ModifiableLibraryOption { DEDUP = 1, ROWS_PER_SEGMENT = 2, COLUMNS_PER_SEGMENT = 3 };
enum class ModifiableLibraryOption {
DEDUP = 1,
ROWS_PER_SEGMENT = 2,
COLUMNS_PER_SEGMENT = 3,
RECURSIVE_NORMALIZERS = 4
};
enum class ModifiableEnterpriseLibraryOption { REPLICATION = 1, BACKGROUND_DELETION = 2 };
using LibraryOptionValue = std::variant<bool, int64_t>;

Expand Down Expand Up @@ -101,6 +106,8 @@ struct formatter<arcticdb::storage::ModifiableLibraryOption> {
return fmt::format_to(ctx.out(), "ROWS_PER_SEGMENT");
case arcticdb::storage::ModifiableLibraryOption::COLUMNS_PER_SEGMENT:
return fmt::format_to(ctx.out(), "COLUMNS_PER_SEGMENT");
case arcticdb::storage::ModifiableLibraryOption::RECURSIVE_NORMALIZERS:
return fmt::format_to(ctx.out(), "RECURSIVE_NORMALIZERS");
default:
arcticdb::util::raise_rte("Unrecognized modifiable option {}", int(o));
}
Expand Down
3 changes: 2 additions & 1 deletion cpp/arcticdb/storage/python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ void register_bindings(py::module& storage, py::exception<arcticdb::ArcticExcept
)pbdoc")
.value("DEDUP", ModifiableLibraryOption::DEDUP)
.value("ROWS_PER_SEGMENT", ModifiableLibraryOption::ROWS_PER_SEGMENT)
.value("COLUMNS_PER_SEGMENT", ModifiableLibraryOption::COLUMNS_PER_SEGMENT);
.value("COLUMNS_PER_SEGMENT", ModifiableLibraryOption::COLUMNS_PER_SEGMENT)
.value("RECURSIVE_NORMALIZERS", ModifiableLibraryOption::RECURSIVE_NORMALIZERS);

py::enum_<ModifiableEnterpriseLibraryOption>(storage, "ModifiableEnterpriseLibraryOption", R"pbdoc(
Enterprise library options that can be modified after library creation.
Expand Down
Loading
Loading