Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DataStorm strings #3015

Merged
merged 8 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
119 changes: 62 additions & 57 deletions cpp/include/DataStorm/DataStorm.h

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions cpp/include/DataStorm/InternalI.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ namespace DataStormI
{
public:
Sample(
const std::string& session,
const std::string& origin,
std::string session,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind that even if the caller keeps his string (neglects to move it), the performance is identical - the previous code was copying this string.

std::string origin,
std::int64_t id,
DataStorm::SampleEvent event,
const std::shared_ptr<Key>& key,
const std::shared_ptr<Tag>& tag,
Ice::ByteSeq value,
std::int64_t timestamp)
: session(session),
origin(origin),
: session(std::move(session)),
origin(std::move(origin)),
id(id),
event(event),
key(key),
Expand Down Expand Up @@ -119,8 +119,8 @@ namespace DataStormI
virtual ~SampleFactory() = default;

virtual std::shared_ptr<Sample> create(
const std::string&,
const std::string&,
std::string,
std::string,
std::int64_t,
DataStorm::SampleEvent,
const std::shared_ptr<Key>&,
Expand Down Expand Up @@ -227,16 +227,16 @@ namespace DataStormI
public:
virtual std::shared_ptr<DataReader> createFiltered(
const std::shared_ptr<Filter>&,
const std::string&,
std::string,
DataStorm::ReaderConfig,
const std::string& = std::string(),
std::string = std::string(),
Ice::ByteSeq = {}) = 0;

virtual std::shared_ptr<DataReader> create(
const std::vector<std::shared_ptr<Key>>&,
const std::string&,
std::string,
DataStorm::ReaderConfig,
const std::string& = std::string(),
std::string = std::string(),
Ice::ByteSeq = {}) = 0;

virtual void setDefaultConfig(DataStorm::ReaderConfig) = 0;
Expand All @@ -248,7 +248,7 @@ namespace DataStormI
{
public:
virtual std::shared_ptr<DataWriter>
create(const std::vector<std::shared_ptr<Key>>&, const std::string&, DataStorm::WriterConfig) = 0;
create(const std::vector<std::shared_ptr<Key>>&, std::string, DataStorm::WriterConfig) = 0;

virtual void setDefaultConfig(DataStorm::WriterConfig) = 0;
virtual bool hasReaders() const = 0;
Expand All @@ -261,20 +261,20 @@ namespace DataStormI
virtual ~TopicFactory() = default;

virtual std::shared_ptr<TopicReader> createTopicReader(
const std::string&,
const std::shared_ptr<KeyFactory>&,
const std::shared_ptr<TagFactory>&,
const std::shared_ptr<SampleFactory>&,
const std::shared_ptr<FilterManager>&,
const std::shared_ptr<FilterManager>&) = 0;
std::string,
std::shared_ptr<KeyFactory>,
std::shared_ptr<TagFactory>,
std::shared_ptr<SampleFactory>,
std::shared_ptr<FilterManager>,
std::shared_ptr<FilterManager>) = 0;

virtual std::shared_ptr<TopicWriter> createTopicWriter(
const std::string&,
const std::shared_ptr<KeyFactory>&,
const std::shared_ptr<TagFactory>&,
const std::shared_ptr<SampleFactory>&,
const std::shared_ptr<FilterManager>&,
const std::shared_ptr<FilterManager>&) = 0;
std::string,
std::shared_ptr<KeyFactory>,
std::shared_ptr<TagFactory>,
std::shared_ptr<SampleFactory>,
std::shared_ptr<FilterManager>,
std::shared_ptr<FilterManager>) = 0;

virtual Ice::CommunicatorPtr getCommunicator() const = 0;
};
Expand Down
30 changes: 19 additions & 11 deletions cpp/include/DataStorm/InternalT.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,15 @@ namespace DataStormI
{
public:
SampleT(
const std::string& session,
const std::string& origin,
std::string session,
std::string origin,
std::int64_t id,
DataStorm::SampleEvent event,
const std::shared_ptr<DataStormI::Key>& key,
const std::shared_ptr<DataStormI::Tag>& tag,
Ice::ByteSeq value,
std::int64_t timestamp)
: Sample(session, origin, id, event, key, tag, value, timestamp),
: Sample(std::move(session), std::move(origin), id, event, key, tag, value, timestamp),
_hasValue(false)
{
}
Expand Down Expand Up @@ -407,17 +407,24 @@ namespace DataStormI
{
public:
virtual std::shared_ptr<Sample> create(
const std::string& session,
const std::string& origin,
std::string session,
std::string origin,
std::int64_t id,
DataStorm::SampleEvent type,
const std::shared_ptr<DataStormI::Key>& key,
const std::shared_ptr<DataStormI::Tag>& tag,
Ice::ByteSeq value,
std::int64_t timestamp)
{
return std::make_shared<
SampleT<Key, Value, UpdateTag>>(session, origin, id, type, key, tag, std::move(value), timestamp);
return std::make_shared<SampleT<Key, Value, UpdateTag>>(
std::move(session),
std::move(origin),
id,
type,
key,
tag,
std::move(value),
timestamp);
}
};

Expand Down Expand Up @@ -491,8 +498,8 @@ namespace DataStormI

template<typename Criteria> struct FactoryT : Factory
{
FactoryT(const std::string& name, std::function<std::function<bool(const Value&)>(const Criteria&)> lambda)
: name(name),
FactoryT(std::string name, std::function<std::function<bool(const Value&)>(const Criteria&)> lambda)
: name(std::move(name)),
lambda(std::move(lambda))
{
}
Expand Down Expand Up @@ -560,11 +567,12 @@ namespace DataStormI
}

template<typename Criteria>
void set(const std::string& name, std::function<std::function<bool(const Value&)>(const Criteria&)> lambda)
void set(std::string name, std::function<std::function<bool(const Value&)>(const Criteria&)> lambda)
{
if (lambda)
{
_factories[name] = std::unique_ptr<Factory>(new FactoryT<Criteria>(name, std::move(lambda)));
auto factory = std::make_unique<FactoryT<Criteria>>(name, std::move(lambda));
_factories.emplace(std::move(name), std::move(factory));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/DataStorm/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ namespace DataStorm
* @return The connection associated with the given session
* @see DataStorm::Sample::ElementId DataStorm::Sample::getSession
*/
Ice::ConnectionPtr getSessionConnection(const std::string& ident) const noexcept;
Ice::ConnectionPtr getSessionConnection(std::string_view ident) const noexcept;

private:
Node(
Expand Down
36 changes: 18 additions & 18 deletions cpp/src/DataStorm/DataElementI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ namespace
}
}

DataElementI::DataElementI(TopicI* parent, const string& name, int64_t id, const DataStorm::Config& config)
DataElementI::DataElementI(TopicI* parent, string name, int64_t id, const DataStorm::Config& config)
: _traceLevels(parent->getInstance()->getTraceLevels()),
_name(name),
_name(std::move(name)),
_id(id),
_config(make_shared<ElementConfig>()),
_executor(parent->getInstance()->getCallbackExecutor()),
Expand All @@ -63,9 +63,9 @@ DataElementI::DataElementI(TopicI* parent, const string& name, int64_t id, const
{
_config->sampleCount = config.sampleCount;
_config->sampleLifetime = config.sampleLifetime;
if (!name.empty())
if (!_name.empty())
{
_config->name = name;
_config->name = _name;
}
if (config.clearHistory)
{
Expand Down Expand Up @@ -643,18 +643,18 @@ DataElementI::forward(const Ice::ByteSeq& inParams, const Ice::Current& current)

DataReaderI::DataReaderI(
TopicReaderI* topic,
const string& name,
string name,
int64_t id,
const string& sampleFilterName,
string sampleFilterName,
Ice::ByteSeq sampleFilterCriteria,
const DataStorm::ReaderConfig& config)
: DataElementI(topic, name, id, config),
: DataElementI(topic, std::move(name), id, config),
_parent(topic),
_discardPolicy(config.discardPolicy ? *config.discardPolicy : DataStorm::DiscardPolicy::None)
{
if (!sampleFilterName.empty())
{
_config->sampleFilter = FilterInfo{sampleFilterName, std::move(sampleFilterCriteria)};
_config->sampleFilter = FilterInfo{std::move(sampleFilterName), std::move(sampleFilterCriteria)};
}
}

Expand Down Expand Up @@ -979,8 +979,8 @@ DataReaderI::addConnectedKey(const shared_ptr<Key>& key, const shared_ptr<Subscr
}
}

DataWriterI::DataWriterI(TopicWriterI* topic, const string& name, int64_t id, const DataStorm::WriterConfig& config)
: DataElementI(topic, name, id, config),
DataWriterI::DataWriterI(TopicWriterI* topic, string name, int64_t id, const DataStorm::WriterConfig& config)
: DataElementI(topic, std::move(name), id, config),
_parent(topic),
_subscribers{Ice::uncheckedCast<DataStormContract::SubscriberSessionPrx>(_forwarder)}
{
Expand Down Expand Up @@ -1043,13 +1043,13 @@ DataWriterI::publish(const shared_ptr<Key>& key, const shared_ptr<Sample>& sampl

KeyDataReaderI::KeyDataReaderI(
TopicReaderI* topic,
const string& name,
string name,
int64_t id,
const vector<shared_ptr<Key>>& keys,
const string& sampleFilterName,
string sampleFilterName,
const Ice::ByteSeq sampleFilterCriteria,
const DataStorm::ReaderConfig& config)
: DataReaderI(topic, name, id, sampleFilterName, sampleFilterCriteria, config),
: DataReaderI(topic, std::move(name), id, std::move(sampleFilterName), sampleFilterCriteria, config),
_keys(keys)
{
if (_traceLevels->data > 0)
Expand Down Expand Up @@ -1131,11 +1131,11 @@ KeyDataReaderI::matchKey(const shared_ptr<Key>& key) const

KeyDataWriterI::KeyDataWriterI(
TopicWriterI* topic,
const string& name,
string name,
int64_t id,
const vector<shared_ptr<Key>>& keys,
const DataStorm::WriterConfig& config)
: DataWriterI(topic, name, id, config),
: DataWriterI(topic, std::move(name), id, config),
_keys(keys)
{
if (_traceLevels->data > 0)
Expand Down Expand Up @@ -1325,13 +1325,13 @@ KeyDataWriterI::forward(const Ice::ByteSeq& inParams, const Ice::Current& curren

FilteredDataReaderI::FilteredDataReaderI(
TopicReaderI* topic,
const string& name,
string name,
int64_t id,
const shared_ptr<Filter>& filter,
const string& sampleFilterName,
string sampleFilterName,
Ice::ByteSeq sampleFilterCriteria,
const DataStorm::ReaderConfig& config)
: DataReaderI(topic, name, id, sampleFilterName, sampleFilterCriteria, config),
: DataReaderI(topic, std::move(name), id, std::move(sampleFilterName), std::move(sampleFilterCriteria), config),
_filter(filter)
{
if (_traceLevels->data > 0)
Expand Down
22 changes: 11 additions & 11 deletions cpp/src/DataStorm/DataElementI.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ namespace DataStormI
std::int64_t id,
const std::shared_ptr<Filter>& filter,
const std::shared_ptr<Filter>& sampleFilter,
const std::string& name,
std::string name,
int priority)
: id(id),
filter(filter),
sampleFilter(sampleFilter),
name(name),
name(std::move(name)),
priority(priority)
{
}
Expand Down Expand Up @@ -133,7 +133,7 @@ namespace DataStormI
};

public:
DataElementI(TopicI*, const std::string&, std::int64_t, const DataStorm::Config&);
DataElementI(TopicI*, std::string, std::int64_t, const DataStorm::Config&);
virtual ~DataElementI();

virtual void destroy() override;
Expand Down Expand Up @@ -281,9 +281,9 @@ namespace DataStormI
public:
DataReaderI(
TopicReaderI*,
const std::string&,
std::string,
std::int64_t,
const std::string&,
std::string,
Ice::ByteSeq,
const DataStorm::ReaderConfig&);

Expand Down Expand Up @@ -330,7 +330,7 @@ namespace DataStormI
class DataWriterI : public DataElementI, public DataWriter
{
public:
DataWriterI(TopicWriterI*, const std::string&, std::int64_t, const DataStorm::WriterConfig&);
DataWriterI(TopicWriterI*, std::string, std::int64_t, const DataStorm::WriterConfig&);

virtual void publish(const std::shared_ptr<Key>&, const std::shared_ptr<Sample>&) override;

Expand All @@ -348,10 +348,10 @@ namespace DataStormI
public:
KeyDataReaderI(
TopicReaderI*,
const std::string&,
std::string,
std::int64_t,
const std::vector<std::shared_ptr<Key>>&,
const std::string&,
std::string,
Ice::ByteSeq,
const DataStorm::ReaderConfig&);

Expand All @@ -373,7 +373,7 @@ namespace DataStormI
public:
KeyDataWriterI(
TopicWriterI*,
const std::string&,
std::string,
std::int64_t,
const std::vector<std::shared_ptr<Key>>&,
const DataStorm::WriterConfig&);
Expand Down Expand Up @@ -406,10 +406,10 @@ namespace DataStormI
public:
FilteredDataReaderI(
TopicReaderI*,
const std::string&,
std::string,
std::int64_t,
const std::shared_ptr<Filter>&,
const std::string&,
std::string,
Ice::ByteSeq,
const DataStorm::ReaderConfig&);

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/DataStorm/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Node::getCommunicator() const noexcept
}

Ice::ConnectionPtr
Node::getSessionConnection(const string& ident) const noexcept
Node::getSessionConnection(string_view ident) const noexcept
{
return _instance ? _instance->getNode()->getSessionConnection(ident) : nullptr;
}
2 changes: 1 addition & 1 deletion cpp/src/DataStorm/NodeI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ NodeI::removePublisherSession(NodePrx node, const shared_ptr<PublisherSessionI>&
}

Ice::ConnectionPtr
NodeI::getSessionConnection(const string& id) const
NodeI::getSessionConnection(string_view id) const
{
auto session = getSession(Ice::stringToIdentity(id));
if (session)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/DataStorm/NodeI.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace DataStormI
const std::shared_ptr<PublisherSessionI>&,
std::exception_ptr);

Ice::ConnectionPtr getSessionConnection(const std::string&) const;
Ice::ConnectionPtr getSessionConnection(std::string_view) const;

std::shared_ptr<SessionI> getSession(const Ice::Identity&) const;

Expand Down
Loading
Loading