MCPcopy Create free account
hub / github.com/ByConity/ByConity / registerStorageFile

Function registerStorageFile

src/Storages/StorageFile.cpp:723–833  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

721
722
723void registerStorageFile(StorageFactory & factory)
724{
725 StorageFactory::StorageFeatures storage_features{
726 .supports_settings = true,
727 .source_access_type = AccessType::FILE
728 };
729
730 factory.registerStorage(
731 "File",
732 [](const StorageFactory::Arguments & factory_args)
733 {
734 StorageFile::CommonArguments storage_args
735 {
736 WithContext(factory_args.getContext()),
737 factory_args.table_id,
738 {},
739 {},
740 {},
741 factory_args.columns,
742 factory_args.constraints,
743 factory_args.comment,
744 };
745
746 ASTs & engine_args_ast = factory_args.engine_args;
747
748 if (!(engine_args_ast.size() >= 1 && engine_args_ast.size() <= 3)) // NOLINT
749 throw Exception(
750 "Storage File requires from 1 to 3 arguments: name of used format, source and compression_method.",
751 ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
752
753 engine_args_ast[0] = evaluateConstantExpressionOrIdentifierAsLiteral(engine_args_ast[0], factory_args.getLocalContext());
754 storage_args.format_name = engine_args_ast[0]->as<ASTLiteral &>().value.safeGet<String>();
755
756 // Use format settings from global server context + settings from
757 // the SETTINGS clause of the create query. Settings from current
758 // session and user are ignored.
759 if (factory_args.storage_def->settings)
760 {
761 FormatFactorySettings user_format_settings;
762
763 // Apply changed settings from global context, but ignore the
764 // unknown ones, because we only have the format settings here.
765 const auto & changes = factory_args.getContext()->getSettingsRef().changes();
766 for (const auto & change : changes)
767 {
768 if (user_format_settings.has(change.name))
769 {
770 user_format_settings.set(change.name, change.value);
771 }
772 }
773
774 // Apply changes from SETTINGS clause, with validation.
775 user_format_settings.applyChanges(
776 factory_args.storage_def->settings->changes);
777
778 storage_args.format_settings = getFormatSettings(
779 factory_args.getContext(), user_format_settings);
780 }

Callers 1

registerStoragesFunction · 0.85

Calls 15

getFormatSettingsFunction · 0.85
registerStorageMethod · 0.80
getLocalContextMethod · 0.80
changesMethod · 0.80
applyChangesMethod · 0.80
get<Int64>Method · 0.80
get<UInt64>Method · 0.80
getUserFilesPathMethod · 0.80
ExceptionClass · 0.50
createFunction · 0.50
tryGetIdentifierNameFunction · 0.50

Tested by

no test coverage detected