Skip to content

Commit

Permalink
Review update
Browse files Browse the repository at this point in the history
  • Loading branch information
lordgamez committed Jan 15, 2025
1 parent 7c8f3cc commit efe1fd8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 24 deletions.
6 changes: 1 addition & 5 deletions libminifi/include/core/AbstractProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ class AbstractProcessor : public Processor {
minifi::core::annotation::Input getInputRequirement() const noexcept final { return ProcessorT::InputRequirement; }
bool isSingleThreaded() const noexcept final { return ProcessorT::IsSingleThreaded; }
std::string getProcessorType() const final {
constexpr auto class_name = className<ProcessorT>();
if (auto short_name = utils::string::partAfterLastOccurrenceOf(class_name, ':')) {
return *short_name;
}
return std::string{class_name};
return utils::string::partAfterLastOccurrenceOf(className<ProcessorT>(), ':');
}
};
} // namespace org::apache::nifi::minifi::core
2 changes: 1 addition & 1 deletion libminifi/include/utils/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ nonstd::expected<T, ParseError> parseNumber(std::string_view input) {
return t;
}

std::optional<std::string> partAfterLastOccurrenceOf(std::string_view input, char delimiter);
std::string partAfterLastOccurrenceOf(std::string_view input, char delimiter);

} // namespace string

Expand Down
15 changes: 3 additions & 12 deletions libminifi/src/core/flow/StructuredConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ void StructuredConfiguration::parseParameterProvidersNode(const Node& parameter_
logger_->log_debug("Using type {} for parameter provider node", type);

std::string fullType = type;
if (auto short_type = utils::string::partAfterLastOccurrenceOf(type, '.')) {
type = *short_type;
}
type = utils::string::partAfterLastOccurrenceOf(type, '.');

auto name = parameter_provider_node[schema_.name].getString().value();
auto id = getRequiredIdField(parameter_provider_node);
Expand Down Expand Up @@ -324,12 +322,7 @@ void StructuredConfiguration::parseProcessorNode(const Node& processors_node, co
logger_->log_debug("parseProcessorNode: class => [{}]", procCfg.javaClass);

// Determine the processor name only from the Java class
if (auto short_processor_name = utils::string::partAfterLastOccurrenceOf(procCfg.javaClass, '.')) {
processor = createProcessor(*short_processor_name, procCfg.javaClass, uuid);
} else {
processor = createProcessor(procCfg.javaClass, uuid);
}

processor = createProcessor(utils::string::partAfterLastOccurrenceOf(procCfg.javaClass, '.'), procCfg.javaClass, uuid);
if (!processor) {
logger_->log_error("Could not create a processor {} with id {}", procCfg.name, procCfg.id);
throw std::invalid_argument("Could not create processor " + procCfg.name);
Expand Down Expand Up @@ -637,9 +630,7 @@ void StructuredConfiguration::parseControllerServices(const Node& controller_ser
logger_->log_debug("Using type {} for controller service node", type);

std::string fullType = type;
if (auto short_type = utils::string::partAfterLastOccurrenceOf(type, '.')) {
type = *short_type;
}
type = utils::string::partAfterLastOccurrenceOf(type, '.');

auto name = service_node[schema_.name].getString().value();
auto id = getRequiredIdField(service_node);
Expand Down
5 changes: 1 addition & 4 deletions libminifi/src/sitetosite/HTTPProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ namespace org::apache::nifi::minifi::sitetosite {
std::shared_ptr<utils::IdGenerator> HttpSiteToSiteClient::id_generator_ = utils::IdGenerator::getIdGenerator();

std::optional<utils::Identifier> HttpSiteToSiteClient::parseTransactionId(const std::string &uri) {
if (auto last_uri_part = utils::string::partAfterLastOccurrenceOf(uri, '/')) {
return utils::Identifier::parse(*last_uri_part);
}
return utils::Identifier::parse(uri);
return utils::Identifier::parse(utils::string::partAfterLastOccurrenceOf(uri, '/'));
}

std::shared_ptr<sitetosite::Transaction> HttpSiteToSiteClient::createTransaction(sitetosite::TransferDirection direction) {
Expand Down
4 changes: 2 additions & 2 deletions libminifi/src/utils/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,10 @@ std::string repeat(std::string_view str, size_t count) {
return result;
}

std::optional<std::string> partAfterLastOccurrenceOf(std::string_view input, char delimiter) {
std::string partAfterLastOccurrenceOf(std::string_view input, char delimiter) {
const size_t last_pos = input.find_last_of(delimiter);
if (last_pos == std::string::npos) {
return std::nullopt;
return std::string{input};
}
return std::string{input.substr(last_pos + 1)};
}
Expand Down

0 comments on commit efe1fd8

Please sign in to comment.