aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcobat <cobat@yandex-team.ru>2022-02-10 16:49:07 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:07 +0300
commit1d2e8a8e9976488ea69a7e4763aa749244f82612 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8
parente486e109b08823b61996f2154f0bc6b7c27a4af4 (diff)
downloadydb-1d2e8a8e9976488ea69a7e4763aa749244f82612.tar.gz
Restoring authorship annotation for <cobat@yandex-team.ru>. Commit 2 of 2.
-rw-r--r--build/scripts/merge_coverage_data.py4
-rw-r--r--library/README.md4
-rw-r--r--library/cpp/binsaver/mem_io.cpp2
-rw-r--r--library/cpp/binsaver/mem_io.h390
-rw-r--r--library/cpp/binsaver/ya.make2
-rw-r--r--library/cpp/blockcodecs/core/stream.cpp2
-rw-r--r--library/cpp/codecs/README.md8
-rw-r--r--library/cpp/codecs/static/tools/static_codec_checker/README4
-rw-r--r--library/cpp/codecs/static/tools/static_codec_generator/README4
-rw-r--r--library/cpp/containers/comptrie/README.md92
-rw-r--r--library/cpp/html/pcdata/pcdata.h4
-rw-r--r--library/cpp/json/easy_parse/json_easy_parser.h28
-rw-r--r--library/cpp/lcs/README.md48
-rw-r--r--library/cpp/packers/README.md2
-rw-r--r--library/cpp/resource/README.md46
-rw-r--r--library/cpp/resource/registry.cpp2
-rw-r--r--library/cpp/threading/local_executor/README.md34
-rw-r--r--library/cpp/threading/local_executor/local_executor.cpp60
-rw-r--r--library/cpp/threading/local_executor/local_executor.h6
-rw-r--r--library/cpp/threading/local_executor/ut/local_executor_ut.cpp112
-rw-r--r--library/cpp/threading/local_executor/ut/ya.make16
-rw-r--r--util/README.md36
-rw-r--r--util/folder/iterator_ut.cpp2
-rw-r--r--util/generic/benchmark/log2/main.cpp88
-rw-r--r--util/generic/yexception_ut.cpp2
-rw-r--r--util/memory/blob.h84
-rw-r--r--util/network/iovec.h2
-rw-r--r--util/network/socket.cpp2
-rw-r--r--util/string/cast.cpp6
-rw-r--r--util/string/strip.h14
-rw-r--r--util/string/type.h6
-rw-r--r--util/string/util.h10
-rw-r--r--util/system/hp_timer.h8
-rw-r--r--util/system/rwlock.cpp4
-rw-r--r--util/system/types.h2
-rw-r--r--util/ysafeptr.h26
36 files changed, 581 insertions, 581 deletions
diff --git a/build/scripts/merge_coverage_data.py b/build/scripts/merge_coverage_data.py
index 89d7120e51..b7fa3c6a86 100644
--- a/build/scripts/merge_coverage_data.py
+++ b/build/scripts/merge_coverage_data.py
@@ -7,8 +7,8 @@ import uuid
def main(args):
output_file, args = args[0], args[1:]
- # heretic@: Splits files on which could be merged( files ) and which should not be merged( expendables )
- # expendables will be in output_file in form {name}{ordinal number of archive in args[]}.{extension}
+ # heretic@: Splits files on which could be merged( files ) and which should not be merged( expendables )
+ # expendables will be in output_file in form {name}{ordinal number of archive in args[]}.{extension}
try:
split_i = args.index('-no-merge')
except ValueError:
diff --git a/library/README.md b/library/README.md
index 1eaee694c2..fc418bef7b 100644
--- a/library/README.md
+++ b/library/README.md
@@ -36,11 +36,11 @@ library
12. All language specific aspects are defined by `<language>` committee: see `library/<language>/README.md`.
13. The library **MUST** satisfy `<language>` style-guide.
-
+
14. The existing library **SHOULD** be improved instead of creating a new one - if it is possible.
Please do not create yet another library for the same thing: just improve existing one.
-
+
Contacts
===
If you have any language-specific questions, please contact `<language>` [committee](https://wiki.yandex-team.ru/devrules/#profilnyekomitety).
diff --git a/library/cpp/binsaver/mem_io.cpp b/library/cpp/binsaver/mem_io.cpp
index c55464328f..82316606b6 100644
--- a/library/cpp/binsaver/mem_io.cpp
+++ b/library/cpp/binsaver/mem_io.cpp
@@ -1 +1 @@
-#include "mem_io.h"
+#include "mem_io.h"
diff --git a/library/cpp/binsaver/mem_io.h b/library/cpp/binsaver/mem_io.h
index 6ec0ba8539..2a9e36fe68 100644
--- a/library/cpp/binsaver/mem_io.h
+++ b/library/cpp/binsaver/mem_io.h
@@ -1,212 +1,212 @@
#pragma once
-#include "bin_saver.h"
-
-namespace NMemIoInternals {
- class TMemoryStream: public IBinaryStream {
- TVector<char>& Data;
- ui64 Pos;
-
- public:
- TMemoryStream(TVector<char>* data, ui64 pos = 0)
- : Data(*data)
- , Pos(pos)
- {
- }
- ~TMemoryStream() override {
- } // keep gcc happy
-
- bool IsValid() const override {
- return true;
- }
- bool IsFailed() const override {
- return false;
- }
-
- private:
- int WriteImpl(const void* userBuffer, int size) override {
- if (size == 0)
- return 0;
- Y_ASSERT(size > 0);
- if (Pos + size > Data.size())
- Data.yresize(Pos + size);
- memcpy(&Data[Pos], userBuffer, size);
- Pos += size;
- return size;
- }
- int ReadImpl(void* userBuffer, int size) override {
- if (size == 0)
- return 0;
- Y_ASSERT(size > 0);
- int res = Min(Data.size() - Pos, (ui64)size);
- if (res)
- memcpy(userBuffer, &Data[Pos], res);
- Pos += res;
- return res;
- }
- };
-
- template <class T>
- inline void SerializeMem(bool bRead, TVector<char>* data, T& c, bool stableOutput = false) {
- if (IBinSaver::HasNonTrivialSerializer<T>(0u)) {
- TMemoryStream f(data);
- {
- IBinSaver bs(f, bRead, stableOutput);
- bs.Add(1, &c);
- }
+#include "bin_saver.h"
+
+namespace NMemIoInternals {
+ class TMemoryStream: public IBinaryStream {
+ TVector<char>& Data;
+ ui64 Pos;
+
+ public:
+ TMemoryStream(TVector<char>* data, ui64 pos = 0)
+ : Data(*data)
+ , Pos(pos)
+ {
+ }
+ ~TMemoryStream() override {
+ } // keep gcc happy
+
+ bool IsValid() const override {
+ return true;
+ }
+ bool IsFailed() const override {
+ return false;
+ }
+
+ private:
+ int WriteImpl(const void* userBuffer, int size) override {
+ if (size == 0)
+ return 0;
+ Y_ASSERT(size > 0);
+ if (Pos + size > Data.size())
+ Data.yresize(Pos + size);
+ memcpy(&Data[Pos], userBuffer, size);
+ Pos += size;
+ return size;
+ }
+ int ReadImpl(void* userBuffer, int size) override {
+ if (size == 0)
+ return 0;
+ Y_ASSERT(size > 0);
+ int res = Min(Data.size() - Pos, (ui64)size);
+ if (res)
+ memcpy(userBuffer, &Data[Pos], res);
+ Pos += res;
+ return res;
+ }
+ };
+
+ template <class T>
+ inline void SerializeMem(bool bRead, TVector<char>* data, T& c, bool stableOutput = false) {
+ if (IBinSaver::HasNonTrivialSerializer<T>(0u)) {
+ TMemoryStream f(data);
+ {
+ IBinSaver bs(f, bRead, stableOutput);
+ bs.Add(1, &c);
+ }
} else {
- if (bRead) {
- Y_ASSERT(data->size() == sizeof(T));
- c = *reinterpret_cast<T*>(&(*data)[0]);
- } else {
- data->yresize(sizeof(T));
- *reinterpret_cast<T*>(&(*data)[0]) = c;
- }
+ if (bRead) {
+ Y_ASSERT(data->size() == sizeof(T));
+ c = *reinterpret_cast<T*>(&(*data)[0]);
+ } else {
+ data->yresize(sizeof(T));
+ *reinterpret_cast<T*>(&(*data)[0]) = c;
+ }
}
}
- ////////////////////////////////////////////////////////////////////////////
- class THugeMemoryStream: public IBinaryStream {
- TVector<TVector<char>>& Data;
- i64 Block, Pos;
- bool ShrinkOnRead;
-
- enum {
- MAX_BLOCK_SIZE = 1024 * 1024 // Aligned with cache size
- };
-
- public:
- THugeMemoryStream(TVector<TVector<char>>* data, bool shrinkOnRead = false)
- : Data(*data)
- , Block(0)
- , Pos(0)
- , ShrinkOnRead(shrinkOnRead)
- {
- Y_ASSERT(!data->empty());
+ ////////////////////////////////////////////////////////////////////////////
+ class THugeMemoryStream: public IBinaryStream {
+ TVector<TVector<char>>& Data;
+ i64 Block, Pos;
+ bool ShrinkOnRead;
+
+ enum {
+ MAX_BLOCK_SIZE = 1024 * 1024 // Aligned with cache size
+ };
+
+ public:
+ THugeMemoryStream(TVector<TVector<char>>* data, bool shrinkOnRead = false)
+ : Data(*data)
+ , Block(0)
+ , Pos(0)
+ , ShrinkOnRead(shrinkOnRead)
+ {
+ Y_ASSERT(!data->empty());
+ }
+
+ ~THugeMemoryStream() override {
+ } // keep gcc happy
+
+ bool IsValid() const override {
+ return true;
}
-
- ~THugeMemoryStream() override {
- } // keep gcc happy
-
- bool IsValid() const override {
- return true;
+ bool IsFailed() const override {
+ return false;
}
- bool IsFailed() const override {
- return false;
- }
-
- private:
- int WriteImpl(const void* userDataArg, int sizeArg) override {
- if (sizeArg == 0)
- return 0;
- const char* userData = (const char*)userDataArg;
- i64 size = sizeArg;
- i64 newSize = Pos + size;
- if (newSize > Data[Block].ysize()) {
- while (newSize > MAX_BLOCK_SIZE) {
- int maxWrite = MAX_BLOCK_SIZE - Pos;
- Data[Block].yresize(MAX_BLOCK_SIZE);
- if (maxWrite) {
- memcpy(&Data[Block][Pos], userData, maxWrite);
- userData += maxWrite;
- size -= maxWrite;
- }
- ++Block;
- Pos = 0;
- Data.resize(Block + 1);
- newSize = Pos + size;
+
+ private:
+ int WriteImpl(const void* userDataArg, int sizeArg) override {
+ if (sizeArg == 0)
+ return 0;
+ const char* userData = (const char*)userDataArg;
+ i64 size = sizeArg;
+ i64 newSize = Pos + size;
+ if (newSize > Data[Block].ysize()) {
+ while (newSize > MAX_BLOCK_SIZE) {
+ int maxWrite = MAX_BLOCK_SIZE - Pos;
+ Data[Block].yresize(MAX_BLOCK_SIZE);
+ if (maxWrite) {
+ memcpy(&Data[Block][Pos], userData, maxWrite);
+ userData += maxWrite;
+ size -= maxWrite;
+ }
+ ++Block;
+ Pos = 0;
+ Data.resize(Block + 1);
+ newSize = Pos + size;
}
- Data[Block].yresize(newSize);
+ Data[Block].yresize(newSize);
+ }
+ if (size) {
+ memcpy(&Data[Block][Pos], userData, size);
}
- if (size) {
- memcpy(&Data[Block][Pos], userData, size);
- }
- Pos += size;
- return sizeArg;
+ Pos += size;
+ return sizeArg;
}
- int ReadImpl(void* userDataArg, int sizeArg) override {
- if (sizeArg == 0)
- return 0;
-
- char* userData = (char*)userDataArg;
- i64 size = sizeArg;
- i64 rv = 0;
- while (size > 0) {
- int curBlockSize = Data[Block].ysize();
- int maxRead = 0;
- if (Pos + size > curBlockSize) {
- maxRead = curBlockSize - Pos;
- if (maxRead) {
- memcpy(userData, &Data[Block][Pos], maxRead);
- userData += maxRead;
- size -= maxRead;
- rv += maxRead;
- }
- if (Block + 1 == Data.ysize()) {
- memset(userData, 0, size);
- return rv;
- }
- if (ShrinkOnRead) {
- TVector<char>().swap(Data[Block]);
- }
- ++Block;
- Pos = 0;
- } else {
- memcpy(userData, &Data[Block][Pos], size);
- Pos += size;
- rv += size;
+ int ReadImpl(void* userDataArg, int sizeArg) override {
+ if (sizeArg == 0)
+ return 0;
+
+ char* userData = (char*)userDataArg;
+ i64 size = sizeArg;
+ i64 rv = 0;
+ while (size > 0) {
+ int curBlockSize = Data[Block].ysize();
+ int maxRead = 0;
+ if (Pos + size > curBlockSize) {
+ maxRead = curBlockSize - Pos;
+ if (maxRead) {
+ memcpy(userData, &Data[Block][Pos], maxRead);
+ userData += maxRead;
+ size -= maxRead;
+ rv += maxRead;
+ }
+ if (Block + 1 == Data.ysize()) {
+ memset(userData, 0, size);
+ return rv;
+ }
+ if (ShrinkOnRead) {
+ TVector<char>().swap(Data[Block]);
+ }
+ ++Block;
+ Pos = 0;
+ } else {
+ memcpy(userData, &Data[Block][Pos], size);
+ Pos += size;
+ rv += size;
return rv;
}
}
- return rv;
+ return rv;
+ }
+ };
+
+ template <class T>
+ inline void SerializeMem(bool bRead, TVector<TVector<char>>* data, T& c, bool stableOutput = false) {
+ if (data->empty()) {
+ data->resize(1);
}
- };
-
- template <class T>
- inline void SerializeMem(bool bRead, TVector<TVector<char>>* data, T& c, bool stableOutput = false) {
- if (data->empty()) {
- data->resize(1);
- }
- THugeMemoryStream f(data);
- {
- IBinSaver bs(f, bRead, stableOutput);
- bs.Add(1, &c);
- }
- }
-}
-
-template <class T>
-inline void SerializeMem(const TVector<char>& data, T& c) {
- if (IBinSaver::HasNonTrivialSerializer<T>(0u)) {
- TVector<char> tmp(data);
- SerializeFromMem(&tmp, c);
- } else {
- Y_ASSERT(data.size() == sizeof(T));
- c = *reinterpret_cast<const T*>(&data[0]);
+ THugeMemoryStream f(data);
+ {
+ IBinSaver bs(f, bRead, stableOutput);
+ bs.Add(1, &c);
+ }
+ }
+}
+
+template <class T>
+inline void SerializeMem(const TVector<char>& data, T& c) {
+ if (IBinSaver::HasNonTrivialSerializer<T>(0u)) {
+ TVector<char> tmp(data);
+ SerializeFromMem(&tmp, c);
+ } else {
+ Y_ASSERT(data.size() == sizeof(T));
+ c = *reinterpret_cast<const T*>(&data[0]);
+ }
+}
+
+template <class T, class D>
+inline void SerializeToMem(D* data, T& c, bool stableOutput = false) {
+ NMemIoInternals::SerializeMem(false, data, c, stableOutput);
+}
+
+template <class T, class D>
+inline void SerializeFromMem(D* data, T& c, bool stableOutput = false) {
+ NMemIoInternals::SerializeMem(true, data, c, stableOutput);
+}
+
+// Frees memory in (*data)[i] immediately upon it's deserialization, thus keeps low overall memory consumption for data + object.
+template <class T>
+inline void SerializeFromMemShrinkInput(TVector<TVector<char>>* data, T& c) {
+ if (data->empty()) {
+ data->resize(1);
+ }
+ NMemIoInternals::THugeMemoryStream f(data, true);
+ {
+ IBinSaver bs(f, true, false);
+ bs.Add(1, &c);
}
+ data->resize(0);
+ data->shrink_to_fit();
}
-
-template <class T, class D>
-inline void SerializeToMem(D* data, T& c, bool stableOutput = false) {
- NMemIoInternals::SerializeMem(false, data, c, stableOutput);
-}
-
-template <class T, class D>
-inline void SerializeFromMem(D* data, T& c, bool stableOutput = false) {
- NMemIoInternals::SerializeMem(true, data, c, stableOutput);
-}
-
-// Frees memory in (*data)[i] immediately upon it's deserialization, thus keeps low overall memory consumption for data + object.
-template <class T>
-inline void SerializeFromMemShrinkInput(TVector<TVector<char>>* data, T& c) {
- if (data->empty()) {
- data->resize(1);
- }
- NMemIoInternals::THugeMemoryStream f(data, true);
- {
- IBinSaver bs(f, true, false);
- bs.Add(1, &c);
- }
- data->resize(0);
- data->shrink_to_fit();
-}
diff --git a/library/cpp/binsaver/ya.make b/library/cpp/binsaver/ya.make
index 076ab811c9..9693c54639 100644
--- a/library/cpp/binsaver/ya.make
+++ b/library/cpp/binsaver/ya.make
@@ -7,7 +7,7 @@ SRCS(
bin_saver.cpp
blob_io.cpp
buffered_io.cpp
- mem_io.cpp
+ mem_io.cpp
util_stream_io.cpp
)
diff --git a/library/cpp/blockcodecs/core/stream.cpp b/library/cpp/blockcodecs/core/stream.cpp
index 0a60b3908d..4f7db3c32b 100644
--- a/library/cpp/blockcodecs/core/stream.cpp
+++ b/library/cpp/blockcodecs/core/stream.cpp
@@ -100,7 +100,7 @@ void TCodedOutput::DoWrite(const void* buf, size_t len) {
in += avail;
len -= avail;
- Y_VERIFY(FlushImpl(), "flush on writing failed");
+ Y_VERIFY(FlushImpl(), "flush on writing failed");
}
}
diff --git a/library/cpp/codecs/README.md b/library/cpp/codecs/README.md
index 6e65f710fb..42646ccd97 100644
--- a/library/cpp/codecs/README.md
+++ b/library/cpp/codecs/README.md
@@ -1,4 +1,4 @@
-This is a library of compression algorithms with a unified interface and serialization.
+This is a library of compression algorithms with a unified interface and serialization.
See also library/cpp/codecs/static, where a support for statically compiled dictionaries is implemented.
All algorithms have a common `ICodec` interface (described in codecs.h).
@@ -26,9 +26,9 @@ The `ICodec` interface has the following methods:\
            - The name of the codec. It is required for registration of the codec in the system of serialization/deserialization.\
                    For example, it allows you to save information about which combination of codecs was in use (see below).\
    `virtual void Learn(ISequenceReader*);`\
-            - The interface for teaching codecs that use information about the distribution of data.
+            - The interface for teaching codecs that use information about the distribution of data.
-In addition, the library has a number of utilities that allow a more flexible use of it.
+In addition, the library has a number of utilities that allow a more flexible use of it.
In the `ICodec` class the following methods are available:\
    `static TCodecPtr GetInstance(const TString& name);`\
@@ -43,4 +43,4 @@ In the `ICodec` class the following methods are available:\
    `static TCodecPtr RestoreFromString(TStringBuf data);`\
            - Loads the codec instance from the string\
    `static TVector<TString> GetCodecsList();`\
-            - The list of registered codecs
+            - The list of registered codecs
diff --git a/library/cpp/codecs/static/tools/static_codec_checker/README b/library/cpp/codecs/static/tools/static_codec_checker/README
index 775854c8f9..723a68300b 100644
--- a/library/cpp/codecs/static/tools/static_codec_checker/README
+++ b/library/cpp/codecs/static/tools/static_codec_checker/README
@@ -1,4 +1,4 @@
-This is a viewer for generated codec and utility for verification of the compression quality on a new data.
+This is a viewer for generated codec and utility for verification of the compression quality on a new data.
-Usage:
+Usage:
static_codec_checker -t -c 029b29ff64a74927.codec_info -f plain samples.txt
diff --git a/library/cpp/codecs/static/tools/static_codec_generator/README b/library/cpp/codecs/static/tools/static_codec_generator/README
index e7900ddcca..e6bb52b959 100644
--- a/library/cpp/codecs/static/tools/static_codec_generator/README
+++ b/library/cpp/codecs/static/tools/static_codec_generator/README
@@ -1,4 +1,4 @@
-This is a utility for reproducible teaching of a codec. And also for saving it into a file with a unique name for a static compilation as a resource.
+This is a utility for reproducible teaching of a codec. And also for saving it into a file with a unique name for a static compilation as a resource.
-Usage:
+Usage:
static_codec_generator -t -m 'the training data description' -f plain samples.txt
diff --git a/library/cpp/containers/comptrie/README.md b/library/cpp/containers/comptrie/README.md
index a2496a8e38..43c298e2c8 100644
--- a/library/cpp/containers/comptrie/README.md
+++ b/library/cpp/containers/comptrie/README.md
@@ -1,17 +1,17 @@
-Compact trie
-=============
+Compact trie
+=============
The comptrie library is a fast and very tightly packed
-implementation of a prefix tree (Sedgewick's T-trie, that is a ternary tree,
-see https://www.cs.princeton.edu/~rs/strings/paper.pdf,
+implementation of a prefix tree (Sedgewick's T-trie, that is a ternary tree,
+see https://www.cs.princeton.edu/~rs/strings/paper.pdf,
https://www.cs.upc.edu/~ps/downloads/tst/tst.html). It contains tools for creating, optimizing, and serializing trees, accessing by key, and performing
various searches. Because it is template-based and performance-oriented, a significant
-part of the library consists of inline functions, so if you don't need all the
+part of the library consists of inline functions, so if you don't need all the
features of the library, consider including a more specific header file instead of the top-level
comptrie.h file.
-Description of the data structure
----------------------------------
+Description of the data structure
+---------------------------------
A prefix tree is an implementation of the map data structure
for cases when keys are sequences of characters. The nodes on this tree
@@ -29,9 +29,9 @@ The library implements tree optimization by merging identical subtrees, which me
the tree becomes a DAG (Directed Acyclic Graph –
an oriented graph without oriented cycles).
-The main class TCompactTrie is defined in comptrie_trie.h and is templatized:
+The main class TCompactTrie is defined in comptrie_trie.h and is templatized:
- The first parameter of the template is the character type. It should be an
-integer type, which means that arithmetical operations must be defined for it.
+integer type, which means that arithmetical operations must be defined for it.
- The second parameter of the template is the value type.
- The third parameter is the packer class, which packs values in order to quickly and compactly
serialize the value type to a continuous memory buffer, deserialize it
@@ -40,29 +40,29 @@ memory buffer. Good packers have already been written for most types, and they a
library/cpp/packers. For more information, please refer to the documentation for these packers.
The set.h file defines a modification for cases when keys must be stored
-without values.
+without values.
When a tree is built from scratch, the value corresponding to an empty key is
assigned to a single-character key '\0'. So in a tree with the 'char' character type,
the empty key and the '\0' key are bound together. For a subtree received from
a call to FindTails, this restriction no longer exists.
-Creating trees
---------------
+Creating trees
+--------------
-Building a tree from a list of key-value pairs is performed by the
+Building a tree from a list of key-value pairs is performed by the
TCompactTrieBuilder class described in the comptrie_builder.h file.
This class allows you to add words to a tree one at a time, merge a complete
-subtree, and also use an unfinished tree as a map.
+subtree, and also use an unfinished tree as a map.
-An important optimization is the prefix-grouped mode when you need to add keys
+An important optimization is the prefix-grouped mode when you need to add keys
in a certain order (for details, see the comments in the header file). The resulting tree is compactly packed while keys are being added, and the memory consumption is approximately the same as for
the completed tree. For the default mode, compact stacking is turned on at the
very end, and the data consumes quite a lot of memory up until that point.
-Optimizing trees
-----------------
+Optimizing trees
+----------------
After a tree is created, there are two optimizing operations that can be applied:
- Minimization to a DAG by merging equal subtrees.
@@ -70,7 +70,7 @@ After a tree is created, there are two optimizing operations that can be applied
The functions that implement these operations are declared in the comptrie_builder.h file. The first
optimization is implemented by the CompactTrieMinimize function, and the second is implemented by
CompactTrieMakeFastLayout. You can perform both at once by calling the
-CompactTrieMinimizeAndMakeFastLayout function.
+CompactTrieMinimizeAndMakeFastLayout function.
### Minimization ###
@@ -86,21 +86,21 @@ won't have any effect on the tree.
The second optimization function results in fewer cache misses, but it causes the
tree to grow in size. Our experience has shown a 5% gain
in speed for some tries. The algorithm consumes about three times more memory than
-the amount required for the source tree. So if the machine has enough memory to
+the amount required for the source tree. So if the machine has enough memory to
assemble a tree, it does not neccessarily mean that it has enough memory to run
the algorithm. To learn about the theory behind this algorithm, read the comments before the declaration of the CompactTrieMinimize function.
-Serializing trees
------------------
+Serializing trees
+-----------------
The tree resides in memory as a sequence of nodes. Links to other nodes are always
-counted relative to the position of the current node. This allows you to save a
+counted relative to the position of the current node. This allows you to save a
tree to disk as it is and then re-load it using mmap(). The TCompactTrie class has the
TBlob constructor for reading a tree from disk. The TCompactTrieBuilder class has
-Save/SaveToFile methods for writing a built tree to a stream or a file.
+Save/SaveToFile methods for writing a built tree to a stream or a file.
Accessing trees
----------------
+---------------
As a rule, all methods that accept a key as input have two variants:
- One takes the key in the format: pointer to the beginning of the key, length.
@@ -115,51 +115,51 @@ An important operation that distinguishes a tree from a simple map is implemente
which allows you to obtain a subtree consisting of all possible extensions of the
given prefix.
-Iterators for trees
--------------------
+Iterators for trees
+-------------------
First of all, there is a typical map iterator over all key-value pairs called
TConstIterator. A tree has three methods that return it: Begin, End, and
-UpperBound. The latter takes a key as input and returns an iterator to the
+UpperBound. The latter takes a key as input and returns an iterator to the
smallest key that is not smaller than the input key.
-The rest of the iterators are not so widely used, and thus are located in
-separate files.
+The rest of the iterators are not so widely used, and thus are located in
+separate files.
TPrefixIterator is defined in the prefix_iterator.h file. It allows
-iterations over all the prefixes of this key available in the tree.
+iterations over all the prefixes of this key available in the tree.
TSearchIterator is defined in the search_iterator.h file. It allows you to enter
a key in a tree one character at a time and see where it ends up. The following character can
-be selected depending on the current result. You can also copy the iterator and
+be selected depending on the current result. You can also copy the iterator and
proceed on two different paths. You can actually achieve the same result with
repeated use of the FindTails method, but the authors of this iterator claim
that they obtained a performance gain with it.
Appendix. Memory implementation details
----------------------------------------
+---------------------------------------
-*If you are not going to modify the library, then you do not need to read further.*
+*If you are not going to modify the library, then you do not need to read further.*
First, if the character type has a size larger than 1 byte, then all keys that use these characters are converted to byte strings in the big-endian way. This
means that character bytes are written in a string from the most significant
-to the least significant from left to right. Thus it is reduced to the case when
+to the least significant from left to right. Thus it is reduced to the case when
the character in use is 'char'.
The tree resides in memory as a series of consecutive nodes. The nodes can have different
sizes, so the only way to identify the boundaries of nodes is by passing the entire
-tree.
+tree.
-### Node structure ###
+### Node structure ###
The structure of a node, as can be understood from thoughtfully reading the
LeapByte function in Comptrie_impl.h, is the following:
-- The first byte is for service flags.
+- The first byte is for service flags.
- The second byte is a character (unless it is the ε-link type of node
described below, which has from 1 to 7 bytes of offset distance from the
beginning of this node to the content node, and nothing else).
-Thus, the size of any node is at least 2 bytes. All other elements of a node
+Thus, the size of any node is at least 2 bytes. All other elements of a node
are optional. Next there is from 0 to 7 bytes of the packed offset from the beginning
of this node to the beginning of the root node of a subtree with the younger
siblings. It is followed by 0 to 7 bytes of the packed offset from the beginning of this
@@ -171,15 +171,15 @@ that the tree has children, there is a root node of the subtree of children.
The packed offset is restricted to 7 bytes, and this gives us a limit on the largest
possible size of a tree. You need to study the packer code to understand
-the exact limit.
+the exact limit.
All packed offsets are nonnegative, meaning that roots of subtrees with
siblings and the node pointed to by the ε-link must be located
strictly to the right of the current node in memory. This does not allow placement of
finite state machines with oriented cycles in the comptrie. But it does allow you to
-effectively stack the comptrie from right to left.
+effectively stack the comptrie from right to left.
-### Service flags ###
+### Service flags ###
The byte of service flags contains (as shown by the constants at the beginning of
the comptrie_impl.h file):
@@ -189,14 +189,14 @@ the comptrie_impl.h file):
with elder siblings.
- 3 bits of MT_SIZEMASK << MT_LEFTSHIFT, indicating the size of the packed
offset to a subtree with younger siblings.
-If one of these subtrees is not present, then the size of the corresponding
-packed offset is 0, and vice versa.
+If one of these subtrees is not present, then the size of the corresponding
+packed offset is 0, and vice versa.
-### ε-links ###
+### ε-links ###
These nodes only occur if we optimized a tree into a DAG and got two nodes with
merged subtrees of children. Since the offset to the subtree of children can't be
-specified and the root of this subtree should lie just after the value, we have
+specified and the root of this subtree should lie just after the value, we have
to add a node of the ε-link type, which contains the offset to the root subtree of
children and nothing more. This applies to all nodes that have equal subtrees of children,
except the rightmost node. The size of this offset is set in 3 bits of MT_SIZEMASK
@@ -206,7 +206,7 @@ As the implementation of the IsEpsilonLink function in
comptrie_impl.h demonstrates, the ε-link differs from other nodes in that it does not have the MT_NEXT flag or the MT_FINAL
flag, so it can always be
identified by the flags. Of course, the best programming practice is to call the
-function itself instead of examining the flags.
+function itself instead of examining the flags.
Note that the ε-link flags do not use the MT_SIZEMASK <<
MT_LEFTSHIFT` bits, which allows us to start using ε-links for some other purpose.
diff --git a/library/cpp/html/pcdata/pcdata.h b/library/cpp/html/pcdata/pcdata.h
index 66d43ea6da..7dd741f53d 100644
--- a/library/cpp/html/pcdata/pcdata.h
+++ b/library/cpp/html/pcdata/pcdata.h
@@ -2,9 +2,9 @@
#include <util/generic/fwd.h>
-/// Converts a text into HTML-code. Special characters of HTML («<», «>», ...) replaced with entities.
+/// Converts a text into HTML-code. Special characters of HTML («<», «>», ...) replaced with entities.
TString EncodeHtmlPcdata(const TStringBuf str, bool qAmp = true);
void EncodeHtmlPcdataAppend(const TStringBuf str, TString& strout);
-/// Reverse of EncodeHtmlPcdata()
+/// Reverse of EncodeHtmlPcdata()
TString DecodeHtmlPcdata(const TString& sz);
diff --git a/library/cpp/json/easy_parse/json_easy_parser.h b/library/cpp/json/easy_parse/json_easy_parser.h
index afa7fc420b..59d7791ab1 100644
--- a/library/cpp/json/easy_parse/json_easy_parser.h
+++ b/library/cpp/json/easy_parse/json_easy_parser.h
@@ -7,20 +7,20 @@
#include "json_easy_parser_impl.h"
namespace NJson {
- /* This class filters out nodes from a source JSON by a xpath-style description. It represent these nodes as a tab-delimited string (or a vector).
- * It is useful if you need to parse a data which comes into JSON in a known and fixed format.
- * Fields are set as a list of keys separated by slash, for example:
- * Field x/y/z in JSON { "x" : { "y" : { "w" : 1, "z" : 2 } } contains number 2.
- * In a path to a field you can also provide a special array identifier "[]", identifier of a particular field in an array (for example "[4]") or wildcard "*".
- *
- * The parser of the class supports parsing of several fields. Each of them could be marked as mandatory or as optional.
- * If a mandatory field is not found in JSON, then Parse() returns false and ConvertToTabDelimited() returns an empty string.
- * If an optional field is not found in JSON, then it's value in Parse()/ConvertToTabDelimited() is an empty string.
- * In particular ConvertToTabDelimited() always returns either an empty string, or a string of the same number of tab-delimited fields starting from the same Prefix.
- *
- * NB! Library can not extract values of not a simple type (namely it doesn't support the case when a result is a vocabulary or an array) from JSON.
- * If you expect such a case, please check json_value.h.
- */
+ /* This class filters out nodes from a source JSON by a xpath-style description. It represent these nodes as a tab-delimited string (or a vector).
+ * It is useful if you need to parse a data which comes into JSON in a known and fixed format.
+ * Fields are set as a list of keys separated by slash, for example:
+ * Field x/y/z in JSON { "x" : { "y" : { "w" : 1, "z" : 2 } } contains number 2.
+ * In a path to a field you can also provide a special array identifier "[]", identifier of a particular field in an array (for example "[4]") or wildcard "*".
+ *
+ * The parser of the class supports parsing of several fields. Each of them could be marked as mandatory or as optional.
+ * If a mandatory field is not found in JSON, then Parse() returns false and ConvertToTabDelimited() returns an empty string.
+ * If an optional field is not found in JSON, then it's value in Parse()/ConvertToTabDelimited() is an empty string.
+ * In particular ConvertToTabDelimited() always returns either an empty string, or a string of the same number of tab-delimited fields starting from the same Prefix.
+ *
+ * NB! Library can not extract values of not a simple type (namely it doesn't support the case when a result is a vocabulary or an array) from JSON.
+ * If you expect such a case, please check json_value.h.
+ */
class TJsonParser {
TString Prefix;
diff --git a/library/cpp/lcs/README.md b/library/cpp/lcs/README.md
index 4e8c9e7b40..7ed3d946d6 100644
--- a/library/cpp/lcs/README.md
+++ b/library/cpp/lcs/README.md
@@ -1,33 +1,33 @@
-A set of algorithms for approximate string matching.
-====================================================
+A set of algorithms for approximate string matching.
+====================================================
-**Lcs_via_lis.h**
-Combinatorial algorithm LCS (Longest common subsequence) through LIS (Longest increasing subsequence) for rows S1 and S2 of lengths n and m respectively (we assume that n < m).
+**Lcs_via_lis.h**
+Combinatorial algorithm LCS (Longest common subsequence) through LIS (Longest increasing subsequence) for rows S1 and S2 of lengths n and m respectively (we assume that n < m).
-Complexity is O(r log n) by time and O(r) of additional memory, where r is the number of pairs (i, j) for which S1[i] = S2[j]. Thus for the uniform distribution of letters of an alphabet of s elements the estimate is O(nm / s * log n).
+Complexity is O(r log n) by time and O(r) of additional memory, where r is the number of pairs (i, j) for which S1[i] = S2[j]. Thus for the uniform distribution of letters of an alphabet of s elements the estimate is O(nm / s * log n).
-Effective for large alphabets s = O(n) (like hashes of words in a text). If only the LCS length is needed, the LCS itself will not be built.
-See Gusfield, Algorithms on Strings, Trees and Sequences, 1997, Chapt.12.5
-Or here: http://www.cs.ucf.edu/courses/cap5937/fall2004/Longest%20common%20subsequence.pdf
+Effective for large alphabets s = O(n) (like hashes of words in a text). If only the LCS length is needed, the LCS itself will not be built.
+See Gusfield, Algorithms on Strings, Trees and Sequences, 1997, Chapt.12.5
+Or here: http://www.cs.ucf.edu/courses/cap5937/fall2004/Longest%20common%20subsequence.pdf
-#### Summary of the idea:
-Let's suppose we have a sequence of numbers.
+#### Summary of the idea:
+Let's suppose we have a sequence of numbers.
-Denote by:
-- IS is a subsequence strictly increasing from left to right.
-- LIS is the largest IS of the original sequence.
-- DS is a subsequence that does not decrease from left to right.
-- C is a covering of disjoint DS of the original sequence.
-- SC is the smallest such covering.
+Denote by:
+- IS is a subsequence strictly increasing from left to right.
+- LIS is the largest IS of the original sequence.
+- DS is a subsequence that does not decrease from left to right.
+- C is a covering of disjoint DS of the original sequence.
+- SC is the smallest such covering.
-It is easy to prove the theorem that the dimensions of SC and LIS are the same, and it is possible to construct LIS from SC.
+It is easy to prove the theorem that the dimensions of SC and LIS are the same, and it is possible to construct LIS from SC.
-Next, let's suppose we have 2 strings of S1 and S2. It can be shown that if for each symbol in S1 we take the list of its appearances in S2 in the reverse order, and concatenate all such lists keeping order, then any IS in the resulting list will be equivalent to some common subsequence S1 and S2 of the same length. And, consequently, LIS will be equivalent to LCS.
+Next, let's suppose we have 2 strings of S1 and S2. It can be shown that if for each symbol in S1 we take the list of its appearances in S2 in the reverse order, and concatenate all such lists keeping order, then any IS in the resulting list will be equivalent to some common subsequence S1 and S2 of the same length. And, consequently, LIS will be equivalent to LCS.
-The idea of the algorithm for constructing DS:
-- Going along the original sequence, for the current member x in the list of its DS we find the leftmost, such that its last term is not less than x.
-- If there is one, then add x to the end.
-- If not, add a new DS consisting of x to the DS list.
+The idea of the algorithm for constructing DS:
+- Going along the original sequence, for the current member x in the list of its DS we find the leftmost, such that its last term is not less than x.
+- If there is one, then add x to the end.
+- If not, add a new DS consisting of x to the DS list.
+
+It can be shown that the DS list constructed this way will be SC.
-It can be shown that the DS list constructed this way will be SC.
-
diff --git a/library/cpp/packers/README.md b/library/cpp/packers/README.md
index 1bc9c6a9b2..c635bf8c8a 100644
--- a/library/cpp/packers/README.md
+++ b/library/cpp/packers/README.md
@@ -1,2 +1,2 @@
A library of packers used to serialize data in the library/cpp/containers/comptrie.
-It is specially excluded as separate library since many packers are of standalone interest.
+It is specially excluded as separate library since many packers are of standalone interest.
diff --git a/library/cpp/resource/README.md b/library/cpp/resource/README.md
index 1353d57cb1..b1e4961c1f 100644
--- a/library/cpp/resource/README.md
+++ b/library/cpp/resource/README.md
@@ -1,24 +1,24 @@
-This library provides implementation to access a resource (data, file, image, etc.) by a key.
-=============================================================================================
-
-See ya make documentation, resources section for more details.
-
-### Example - adding a resource file into build:
-```
-LIBRARY()
-OWNER(user1)
-RESOURCE(
- path/to/file1 /key/in/program/1
- path/to/file2 /key2
-)
-END()
-```
-
-### Example - access to a file content by a key:
-```cpp
+This library provides implementation to access a resource (data, file, image, etc.) by a key.
+=============================================================================================
+
+See ya make documentation, resources section for more details.
+
+### Example - adding a resource file into build:
+```
+LIBRARY()
+OWNER(user1)
+RESOURCE(
+ path/to/file1 /key/in/program/1
+ path/to/file2 /key2
+)
+END()
+```
+
+### Example - access to a file content by a key:
+```cpp
#include <library/cpp/resource/resource.h>
-int main() {
- Cout << NResource::Find("/key/in/program/1") << Endl;
- Cout << NResource::Find("/key2") << Endl;
-}
-```
+int main() {
+ Cout << NResource::Find("/key/in/program/1") << Endl;
+ Cout << NResource::Find("/key2") << Endl;
+}
+```
diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp
index e116f003dd..66001c4769 100644
--- a/library/cpp/resource/registry.cpp
+++ b/library/cpp/resource/registry.cpp
@@ -46,7 +46,7 @@ namespace {
(*this)[key] = &D_.back();
}
- Y_VERIFY(size() == Count(), "size mismatch");
+ Y_VERIFY(size() == Count(), "size mismatch");
}
bool FindExact(const TStringBuf key, TString* out) const override {
diff --git a/library/cpp/threading/local_executor/README.md b/library/cpp/threading/local_executor/README.md
index 6191f76b9f..aaad2e2986 100644
--- a/library/cpp/threading/local_executor/README.md
+++ b/library/cpp/threading/local_executor/README.md
@@ -2,7 +2,7 @@
This library allows easy parallelization of existing code and cycles.
It provides `NPar::TLocalExecutor` class and `NPar::LocalExecutor()` singleton accessor.
-At start, `TLocalExecutor` has no threads in thread pool and all async tasks will be queued for later execution when extra threads appear.
+At start, `TLocalExecutor` has no threads in thread pool and all async tasks will be queued for later execution when extra threads appear.
All tasks should be `NPar::ILocallyExecutable` child class or function equal to `std::function<void(int)>`
## TLocalExecutor methods
@@ -16,20 +16,20 @@ All tasks should be `NPar::ILocallyExecutable` child class or function equal to
- `TLocalExecutor::LOW_PRIORITY = 2` - put task in low priority queue
- `TLocalExecutor::WAIT_COMPLETE = 4` - wait for task completion
-`void TLocalExecutor::ExecRange(TLocallyExecutableFunction exec, TExecRangeParams blockParams, int flags);` - run range of tasks `[TExecRangeParams::FirstId, TExecRangeParams::LastId).`
+`void TLocalExecutor::ExecRange(TLocallyExecutableFunction exec, TExecRangeParams blockParams, int flags);` - run range of tasks `[TExecRangeParams::FirstId, TExecRangeParams::LastId).`
`flags` is the same as for `TLocalExecutor::Exec`.
-`TExecRangeParams` is a structure that describes the range.
+`TExecRangeParams` is a structure that describes the range.
By default each task is executed separately. Threads from thread pool are taking
the tasks in the manner first come first serve.
It is also possible to partition range of tasks in consequtive blocks and execute each block as a bigger task.
-`TExecRangeParams::SetBlockCountToThreadCount()` will result in thread count tasks,
+`TExecRangeParams::SetBlockCountToThreadCount()` will result in thread count tasks,
where thread count is the count of threads in thread pool.
each thread will execute approximately equal count of tasks from range.
-`TExecRangeParams::SetBlockSize()` and `TExecRangeParams::SetBlockCount()` will partition
+`TExecRangeParams::SetBlockSize()` and `TExecRangeParams::SetBlockCount()` will partition
the range of tasks into consequtive blocks of approximately given size, or of size calculated
by partitioning the range into approximately equal size blocks of given count.
@@ -59,16 +59,16 @@ using namespace NPar;
LocalExecutor().Run(4);
LocalExecutor().ExecRange([](int id) {
SomeFunc(id);
-}, TExecRangeParams(0, 10), TLocalExecutor::WAIT_COMPLETE | TLocalExecutor::MED_PRIORITY);
+}, TExecRangeParams(0, 10), TLocalExecutor::WAIT_COMPLETE | TLocalExecutor::MED_PRIORITY);
```
-
-### Exception handling
-
-By default if a not caught exception arise in a task which runs through the Local Executor, then std::terminate() will be called immediately. The exception will be printed to stderr before the termination. Best practice is to handle exception within a task, or avoid throwing exceptions at all for performance reasons.
-
-However, if you'd like to handle and/or rethrow exceptions outside of a range, you can use ExecRangeWithFuture().
-It returns vector [0 .. LastId-FirstId] elements, where i-th element is a TFuture corresponding to task with id = (FirstId + i).
-Use method .HasValue() of the element to check in Async mode if the corresponding task is complete.
-Use .GetValue() or .GetValueSync() to wait for completion of the corresponding task. GetValue() and GetValueSync() will also rethrow an exception if it appears during execution of the task.
-
-You may also use ExecRangeWithThrow() to just receive an exception from a range if it appears. It rethrows an exception from a task with minimal id if such an exception exists, and guarantees normal flow if no exception arise.
+
+### Exception handling
+
+By default if a not caught exception arise in a task which runs through the Local Executor, then std::terminate() will be called immediately. The exception will be printed to stderr before the termination. Best practice is to handle exception within a task, or avoid throwing exceptions at all for performance reasons.
+
+However, if you'd like to handle and/or rethrow exceptions outside of a range, you can use ExecRangeWithFuture().
+It returns vector [0 .. LastId-FirstId] elements, where i-th element is a TFuture corresponding to task with id = (FirstId + i).
+Use method .HasValue() of the element to check in Async mode if the corresponding task is complete.
+Use .GetValue() or .GetValueSync() to wait for completion of the corresponding task. GetValue() and GetValueSync() will also rethrow an exception if it appears during execution of the task.
+
+You may also use ExecRangeWithThrow() to just receive an exception from a range if it appears. It rethrows an exception from a task with minimal id if such an exception exists, and guarantees normal flow if no exception arise.
diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp
index 2605a35166..1d3fbb4bf4 100644
--- a/library/cpp/threading/local_executor/local_executor.cpp
+++ b/library/cpp/threading/local_executor/local_executor.cpp
@@ -36,40 +36,40 @@ namespace {
};
class TFunctionWrapperWithPromise: public NPar::ILocallyExecutable {
- private:
+ private:
NPar::TLocallyExecutableFunction Exec;
- int FirstId, LastId;
- TVector<NThreading::TPromise<void>> Promises;
+ int FirstId, LastId;
+ TVector<NThreading::TPromise<void>> Promises;
- public:
+ public:
TFunctionWrapperWithPromise(NPar::TLocallyExecutableFunction exec, int firstId, int lastId)
: Exec(std::move(exec))
- , FirstId(firstId)
- , LastId(lastId)
- {
- Y_ASSERT(FirstId <= LastId);
- const int rangeSize = LastId - FirstId;
- Promises.resize(rangeSize, NThreading::NewPromise());
- for (auto& promise : Promises) {
- promise = NThreading::NewPromise();
- }
- }
-
- void LocalExec(int id) override {
- Y_ASSERT(FirstId <= id && id < LastId);
- NThreading::NImpl::SetValue(Promises[id - FirstId], [=] { Exec(id); });
- }
-
- TVector<NThreading::TFuture<void>> GetFutures() const {
- TVector<NThreading::TFuture<void>> out;
- out.reserve(Promises.ysize());
- for (auto& promise : Promises) {
- out.push_back(promise.GetFuture());
- }
- return out;
- }
- };
-
+ , FirstId(firstId)
+ , LastId(lastId)
+ {
+ Y_ASSERT(FirstId <= LastId);
+ const int rangeSize = LastId - FirstId;
+ Promises.resize(rangeSize, NThreading::NewPromise());
+ for (auto& promise : Promises) {
+ promise = NThreading::NewPromise();
+ }
+ }
+
+ void LocalExec(int id) override {
+ Y_ASSERT(FirstId <= id && id < LastId);
+ NThreading::NImpl::SetValue(Promises[id - FirstId], [=] { Exec(id); });
+ }
+
+ TVector<NThreading::TFuture<void>> GetFutures() const {
+ TVector<NThreading::TFuture<void>> out;
+ out.reserve(Promises.ysize());
+ for (auto& promise : Promises) {
+ out.push_back(promise.GetFuture());
+ }
+ return out;
+ }
+ };
+
struct TSingleJob {
TIntrusivePtr<NPar::ILocallyExecutable> Exec;
int Id{0};
diff --git a/library/cpp/threading/local_executor/local_executor.h b/library/cpp/threading/local_executor/local_executor.h
index d661756008..c1c824f67c 100644
--- a/library/cpp/threading/local_executor/local_executor.h
+++ b/library/cpp/threading/local_executor/local_executor.h
@@ -60,7 +60,7 @@ namespace NPar {
// Describes a range of tasks with parameters from integer range [FirstId, LastId).
//
- class TExecRangeParams {
+ class TExecRangeParams {
public:
template <typename TFirst, typename TLast>
TExecRangeParams(TFirst firstId, TLast lastId)
@@ -95,7 +95,7 @@ namespace NPar {
// Partition tasks into thread count blocks of approximately equal size, each of which
// will be executed as a separate bigger task.
//
- TExecRangeParams& SetBlockCountToThreadCount() {
+ TExecRangeParams& SetBlockCountToThreadCount() {
BlockEqualToThreads = true;
return *this;
}
@@ -147,7 +147,7 @@ namespace NPar {
}
template <typename TBody>
- inline void ExecRange(TBody&& body, TExecRangeParams params, int flags) {
+ inline void ExecRange(TBody&& body, TExecRangeParams params, int flags) {
if (TryExecRangeSequentially(body, params.FirstId, params.LastId, flags)) {
return;
}
diff --git a/library/cpp/threading/local_executor/ut/local_executor_ut.cpp b/library/cpp/threading/local_executor/ut/local_executor_ut.cpp
index 0ad343a279..ac5737717c 100644
--- a/library/cpp/threading/local_executor/ut/local_executor_ut.cpp
+++ b/library/cpp/threading/local_executor/ut/local_executor_ut.cpp
@@ -2,23 +2,23 @@
#include <library/cpp/threading/future/future.h>
#include <library/cpp/testing/unittest/registar.h>
-#include <util/system/mutex.h>
-#include <util/system/rwlock.h>
+#include <util/system/mutex.h>
+#include <util/system/rwlock.h>
#include <util/generic/algorithm.h>
-
-using namespace NPar;
-
-class TTestException: public yexception {
-};
-
-static const int DefaultThreadsCount = 41;
-static const int DefaultRangeSize = 999;
-
+
+using namespace NPar;
+
+class TTestException: public yexception {
+};
+
+static const int DefaultThreadsCount = 41;
+static const int DefaultRangeSize = 999;
+
Y_UNIT_TEST_SUITE(ExecRangeWithFutures){
bool AllOf(const TVector<int>& vec, int value){
- return AllOf(vec, [value](int element) { return value == element; });
+ return AllOf(vec, [value](int element) { return value == element; });
}
-
+
void AsyncRunAndWaitFuturesReady(int rangeSize, int threads) {
TLocalExecutor localExecutor;
localExecutor.RunAdditionalThreads(threads);
@@ -37,26 +37,26 @@ void AsyncRunAndWaitFuturesReady(int rangeSize, int threads) {
AtomicSet(signal, 1);
for (auto& future : futures) {
future.GetValueSync();
- }
+ }
UNIT_ASSERT(AllOf(data, 1));
}
-
+
Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReady) {
AsyncRunAndWaitFuturesReady(DefaultRangeSize, DefaultThreadsCount);
}
-
+
Y_UNIT_TEST(AsyncRunOneTaskAndWaitFuturesReady) {
AsyncRunAndWaitFuturesReady(1, DefaultThreadsCount);
}
-
+
Y_UNIT_TEST(AsyncRunRangeAndWaitFuturesReadyOneExtraThread) {
AsyncRunAndWaitFuturesReady(DefaultRangeSize, 1);
}
-
+
Y_UNIT_TEST(AsyncRunOneThreadAndWaitFuturesReadyOneExtraThread) {
AsyncRunAndWaitFuturesReady(1, 1);
}
-
+
Y_UNIT_TEST(AsyncRunTwoRangesAndWaitFuturesReady) {
TLocalExecutor localExecutor;
localExecutor.RunAdditionalThreads(DefaultThreadsCount);
@@ -83,11 +83,11 @@ Y_UNIT_TEST(AsyncRunTwoRangesAndWaitFuturesReady) {
for (int i = 0; i < DefaultRangeSize; ++i) {
futures1[i].GetValueSync();
futures2[i].GetValueSync();
- }
+ }
UNIT_ASSERT(AllOf(data1, 1));
UNIT_ASSERT(AllOf(data2, 2));
}
-
+
void AsyncRunRangeAndWaitExceptions(int rangeSize, int threadsCount) {
TLocalExecutor localExecutor;
localExecutor.RunAdditionalThreads(threadsCount);
@@ -111,29 +111,29 @@ void AsyncRunRangeAndWaitExceptions(int rangeSize, int threadsCount) {
} catch (int& e) {
if (e == 10000 + i) {
++exceptionsCaught;
- }
- }
- }
+ }
+ }
+ }
UNIT_ASSERT(exceptionsCaught == rangeSize);
UNIT_ASSERT(AllOf(data, 1));
}
-
+
Y_UNIT_TEST(AsyncRunRangeAndWaitExceptions) {
AsyncRunRangeAndWaitExceptions(DefaultRangeSize, DefaultThreadsCount);
}
-
+
Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptions) {
AsyncRunRangeAndWaitExceptions(1, DefaultThreadsCount);
}
-
+
Y_UNIT_TEST(AsyncRunRangeAndWaitExceptionsOneExtraThread) {
AsyncRunRangeAndWaitExceptions(DefaultRangeSize, 1);
}
-
+
Y_UNIT_TEST(AsyncRunOneTaskAndWaitExceptionsOneExtraThread) {
AsyncRunRangeAndWaitExceptions(1, 1);
}
-
+
Y_UNIT_TEST(AsyncRunTwoRangesAndWaitExceptions) {
TLocalExecutor localExecutor;
localExecutor.RunAdditionalThreads(DefaultThreadsCount);
@@ -156,7 +156,7 @@ Y_UNIT_TEST(AsyncRunTwoRangesAndWaitExceptions) {
throw 16000 + i;
},
0, DefaultRangeSize, TLocalExecutor::HIGH_PRIORITY);
-
+
UNIT_ASSERT(AllOf(data1, 0));
UNIT_ASSERT(AllOf(data2, 0));
UNIT_ASSERT(futures1.size() == DefaultRangeSize);
@@ -169,21 +169,21 @@ Y_UNIT_TEST(AsyncRunTwoRangesAndWaitExceptions) {
} catch (int& e) {
if (e == 15000 + i) {
++exceptionsCaught;
- }
+ }
}
try {
futures2[i].GetValueSync();
} catch (int& e) {
if (e == 16000 + i) {
++exceptionsCaught;
- }
- }
- }
+ }
+ }
+ }
UNIT_ASSERT(exceptionsCaught == 2 * DefaultRangeSize);
UNIT_ASSERT(AllOf(data1, 1));
UNIT_ASSERT(AllOf(data2, 2));
}
-
+
void RunRangeAndCheckExceptionsWithWaitComplete(int rangeSize, int threadsCount) {
TLocalExecutor localExecutor;
localExecutor.RunAdditionalThreads(threadsCount);
@@ -202,39 +202,39 @@ void RunRangeAndCheckExceptionsWithWaitComplete(int rangeSize, int threadsCount)
} catch (int& e) {
if (e == 30000 + i) {
++exceptionsCaught;
- }
- }
- }
+ }
+ }
+ }
UNIT_ASSERT(exceptionsCaught == rangeSize);
UNIT_ASSERT(AllOf(data, 1));
}
-
+
Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitComplete) {
RunRangeAndCheckExceptionsWithWaitComplete(DefaultRangeSize, DefaultThreadsCount);
}
-
+
Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitComplete) {
RunRangeAndCheckExceptionsWithWaitComplete(1, DefaultThreadsCount);
}
-
+
Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteOneExtraThread) {
RunRangeAndCheckExceptionsWithWaitComplete(DefaultRangeSize, 1);
}
-
+
Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteOneExtraThread) {
RunRangeAndCheckExceptionsWithWaitComplete(1, 1);
}
-
+
Y_UNIT_TEST(RunRangeAndCheckExceptionsWithWaitCompleteZeroExtraThreads) {
RunRangeAndCheckExceptionsWithWaitComplete(DefaultRangeSize, 0);
}
-
+
Y_UNIT_TEST(RunOneAndCheckExceptionsWithWaitCompleteZeroExtraThreads) {
RunRangeAndCheckExceptionsWithWaitComplete(1, 0);
}
}
;
-
+
Y_UNIT_TEST_SUITE(ExecRangeWithThrow){
void RunParallelWhichThrowsTTestException(int rangeStart, int rangeSize, int threadsCount, int flags, TAtomic& processed){
AtomicSet(processed, 0);
@@ -246,7 +246,7 @@ localExecutor.ExecRangeWithThrow([&processed](int) {
},
rangeStart, rangeStart + rangeSize, flags);
}
-
+
Y_UNIT_TEST(RunParallelWhichThrowsTTestException) {
TAtomic processed = 0;
UNIT_ASSERT_EXCEPTION(
@@ -255,7 +255,7 @@ Y_UNIT_TEST(RunParallelWhichThrowsTTestException) {
TTestException);
UNIT_ASSERT(AtomicGet(processed) == 40);
}
-
+
void ThrowAndCatchTTestException(int rangeSize, int threadsCount, int flags) {
TAtomic processed = 0;
UNIT_ASSERT_EXCEPTION(
@@ -263,44 +263,44 @@ void ThrowAndCatchTTestException(int rangeSize, int threadsCount, int flags) {
TTestException);
UNIT_ASSERT(AtomicGet(processed) == rangeSize);
}
-
+
Y_UNIT_TEST(ThrowAndCatchTTestExceptionLowPriority) {
ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount,
TLocalExecutor::EFlags::WAIT_COMPLETE | TLocalExecutor::EFlags::LOW_PRIORITY);
}
-
+
Y_UNIT_TEST(ThrowAndCatchTTestExceptionMedPriority) {
ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount,
TLocalExecutor::EFlags::WAIT_COMPLETE | TLocalExecutor::EFlags::MED_PRIORITY);
}
-
+
Y_UNIT_TEST(ThrowAndCatchTTestExceptionHighPriority) {
ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount,
TLocalExecutor::EFlags::WAIT_COMPLETE | TLocalExecutor::EFlags::HIGH_PRIORITY);
}
-
+
Y_UNIT_TEST(ThrowAndCatchTTestExceptionWaitComplete) {
ThrowAndCatchTTestException(DefaultRangeSize, DefaultThreadsCount,
TLocalExecutor::EFlags::WAIT_COMPLETE);
}
-
+
Y_UNIT_TEST(RethrowExeptionSequentialWaitComplete) {
ThrowAndCatchTTestException(DefaultRangeSize, 0,
TLocalExecutor::EFlags::WAIT_COMPLETE);
}
-
+
Y_UNIT_TEST(RethrowExeptionOneExtraThreadWaitComplete) {
ThrowAndCatchTTestException(DefaultRangeSize, 1,
TLocalExecutor::EFlags::WAIT_COMPLETE);
}
-
+
void ThrowsTTestExceptionFromNested(TLocalExecutor& localExecutor) {
localExecutor.ExecRangeWithThrow([](int) {
throw TTestException();
},
0, 10, TLocalExecutor::EFlags::WAIT_COMPLETE);
}
-
+
void CatchTTestExceptionFromNested(TAtomic& processed1, TAtomic& processed2) {
TLocalExecutor localExecutor;
localExecutor.RunAdditionalThreads(DefaultThreadsCount);
@@ -313,7 +313,7 @@ void CatchTTestExceptionFromNested(TAtomic& processed1, TAtomic& processed2) {
},
0, DefaultRangeSize, TLocalExecutor::EFlags::WAIT_COMPLETE);
}
-
+
Y_UNIT_TEST(NestedParallelExceptionsDoNotLeak) {
TAtomic processed1 = 0;
TAtomic processed2 = 0;
diff --git a/library/cpp/threading/local_executor/ut/ya.make b/library/cpp/threading/local_executor/ut/ya.make
index 645ce823e9..be579a5ca0 100644
--- a/library/cpp/threading/local_executor/ut/ya.make
+++ b/library/cpp/threading/local_executor/ut/ya.make
@@ -1,12 +1,12 @@
-OWNER(
- g:matrixnet
+OWNER(
+ g:matrixnet
gulin
)
-
+
UNITTEST_FOR(library/cpp/threading/local_executor)
-SRCS(
- local_executor_ut.cpp
-)
-
-END()
+SRCS(
+ local_executor_ut.cpp
+)
+
+END()
diff --git a/util/README.md b/util/README.md
index b4c4785e77..496efa633c 100644
--- a/util/README.md
+++ b/util/README.md
@@ -4,37 +4,37 @@ Style guide for the util folder is a stricter version of
[general style guide](https://docs.yandex-team.ru/arcadia-cpp/cpp_style_guide)
(mostly in terms of ambiguity resolution).
- * all {} must be in K&R style
- * &, * tied closer to a type, not to variable
- * always use `using` not `typedef`
- * even a single line block must be in braces {}:
+ * all {} must be in K&R style
+ * &, * tied closer to a type, not to variable
+ * always use `using` not `typedef`
+ * even a single line block must be in braces {}:
```
if (A) {
B();
}
```
- * _ at the end of private data member of a class - `First_`, `Second_`
- * every .h file must be accompanied with corresponding .cpp to avoid a leakage and check that it is self contained
- * prohibited to use `printf`-like functions
+ * _ at the end of private data member of a class - `First_`, `Second_`
+ * every .h file must be accompanied with corresponding .cpp to avoid a leakage and check that it is self contained
+ * prohibited to use `printf`-like functions
-Things declared in the general style guide, which sometimes are missed:
+Things declared in the general style guide, which sometimes are missed:
- * `template <`, not `template<`
- * `noexcept`, not `throw ()` nor `throw()`, not required for destructors
- * indents inside `namespace` same as inside `class`
+ * `template <`, not `template<`
+ * `noexcept`, not `throw ()` nor `throw()`, not required for destructors
+ * indents inside `namespace` same as inside `class`
-Requirements for a new code (and for corrections in an old code which involves change of behaviour) in util:
+Requirements for a new code (and for corrections in an old code which involves change of behaviour) in util:
- * presence of UNIT-tests
- * presence of comments in Doxygen style
- * accessors without Get prefix (`Length()`, but not `GetLength()`)
+ * presence of UNIT-tests
+ * presence of comments in Doxygen style
+ * accessors without Get prefix (`Length()`, but not `GetLength()`)
-This guide is not a mandatory as there is the general style guide.
-Nevertheless if it is not followed, then a next `ya style .` run in the util folder will undeservedly update authors of some lines of code.
+This guide is not a mandatory as there is the general style guide.
+Nevertheless if it is not followed, then a next `ya style .` run in the util folder will undeservedly update authors of some lines of code.
-Thus before a commit it is recommended to run `ya style .` in the util folder.
+Thus before a commit it is recommended to run `ya style .` in the util folder.
Don't forget to run tests from folder `tests`: `ya make -t tests`
diff --git a/util/folder/iterator_ut.cpp b/util/folder/iterator_ut.cpp
index d8e0cf892d..936becd139 100644
--- a/util/folder/iterator_ut.cpp
+++ b/util/folder/iterator_ut.cpp
@@ -60,7 +60,7 @@ private:
break;
case 2:
- ythrow yexception() << "unknown path type";
+ ythrow yexception() << "unknown path type";
}
Paths_.push_back(path);
diff --git a/util/generic/benchmark/log2/main.cpp b/util/generic/benchmark/log2/main.cpp
index 44db7bf4cf..969f09a309 100644
--- a/util/generic/benchmark/log2/main.cpp
+++ b/util/generic/benchmark/log2/main.cpp
@@ -14,8 +14,8 @@ namespace {
TVector<T> Examples;
TExamplesHolder()
- : Examples(N)
- {
+ : Examples(N)
+ {
TFastRng<ui64> prng{N * 42};
for (auto& x : Examples) {
x = prng.GenRandReal4() + prng.Uniform(1932); // 1934 is just a random number
@@ -25,25 +25,25 @@ namespace {
}
#define DEFINE_BENCHMARK(type, count) \
- Y_CPU_BENCHMARK(libm_log2f_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(log2f(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(libm_logf_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(logf(e)); \
- } \
- } \
- } \
+ Y_CPU_BENCHMARK(libm_log2f_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(log2f(e)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(libm_logf_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(logf(e)); \
+ } \
+ } \
+ } \
Y_CPU_BENCHMARK(STL_Log2_##type##_##count, iface) { \
const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
for (const auto i : xrange(iface.Iterations())) { \
@@ -74,7 +74,7 @@ namespace {
} \
} \
\
- Y_CPU_BENCHMARK(FastLogf##type##_##count, iface) { \
+ Y_CPU_BENCHMARK(FastLogf##type##_##count, iface) { \
const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
for (const auto i : xrange(iface.Iterations())) { \
Y_UNUSED(i); \
@@ -89,7 +89,7 @@ namespace {
for (const auto i : xrange(iface.Iterations())) { \
Y_UNUSED(i); \
for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FasterLog2f(e)); \
+ Y_DO_NOT_OPTIMIZE_AWAY(FasterLog2f(e)); \
} \
} \
} \
@@ -99,29 +99,29 @@ namespace {
for (const auto i : xrange(iface.Iterations())) { \
Y_UNUSED(i); \
for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FasterLogf(e)); \
+ Y_DO_NOT_OPTIMIZE_AWAY(FasterLogf(e)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(Fastest_Log2f_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FastestLog2f(e)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(Fastest_Log_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FastestLogf(e)); \
} \
} \
- } \
- \
- Y_CPU_BENCHMARK(Fastest_Log2f_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FastestLog2f(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(Fastest_Log_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FastestLogf(e)); \
- } \
- } \
}
DEFINE_BENCHMARK(float, 1)
diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp
index cf085f8fc9..cb3e29fed8 100644
--- a/util/generic/yexception_ut.cpp
+++ b/util/generic/yexception_ut.cpp
@@ -59,7 +59,7 @@ private:
inline void TestRethrowAppend() {
try {
try {
- ythrow yexception() << "it";
+ ythrow yexception() << "it";
} catch (yexception& e) {
e << "happens";
diff --git a/util/memory/blob.h b/util/memory/blob.h
index 4708ea6d1f..20c02a68df 100644
--- a/util/memory/blob.h
+++ b/util/memory/blob.h
@@ -61,7 +61,7 @@ public:
using const_iterator = const_pointer;
/**
- * Constructs a null blob (data array points to nullptr).
+ * Constructs a null blob (data array points to nullptr).
*/
TBlob() noexcept
: S_(nullptr, 0, nullptr)
@@ -96,22 +96,22 @@ public:
return *this;
}
- /// Swaps content of two data arrays.
+ /// Swaps content of two data arrays.
inline void Swap(TBlob& r) noexcept {
S_.Swap(r.S_);
}
- /// Returns a const reference to the data array.
+ /// Returns a const reference to the data array.
inline const void* Data() const noexcept {
return S_.Data;
}
- /// Returns the size of the data array in bytes.
+ /// Returns the size of the data array in bytes.
inline size_t Length() const noexcept {
return S_.Length;
}
- /// Checks if the object has an empty data array.
+ /// Checks if the object has an empty data array.
Y_PURE_FUNCTION inline bool Empty() const noexcept {
return !Length();
}
@@ -121,17 +121,17 @@ public:
return S_.Base != nullptr;
}
- /// Checks if the object has a data array.
+ /// Checks if the object has a data array.
inline bool IsNull() const noexcept {
return !Data();
}
- /// Returns a const pointer of char type to the data array.
+ /// Returns a const pointer of char type to the data array.
inline const char* AsCharPtr() const noexcept {
return (const char*)Data();
}
- /// Returns a const pointer of unsigned char type to the data array.
+ /// Returns a const pointer of unsigned char type to the data array.
inline const unsigned char* AsUnsignedCharPtr() const noexcept {
return (const unsigned char*)Data();
}
@@ -140,13 +140,13 @@ public:
return TStringBuf(AsCharPtr(), size());
}
- /// Drops the data array.
+ /// Drops the data array.
inline void Drop() noexcept {
TBlob().Swap(*this);
}
/*
- * Some stl-like methods
+ * Some stl-like methods
*/
/// Returns a const reference to the data array.
@@ -157,7 +157,7 @@ public:
return static_cast<const_pointer>(Data());
}
- /// Returns the size of the data array in bytes.
+ /// Returns the size of the data array in bytes.
inline size_t size() const noexcept {
return Length();
}
@@ -167,12 +167,12 @@ public:
return Length();
}
- /// Standard iterator.
+ /// Standard iterator.
inline const_iterator Begin() const noexcept {
return AsUnsignedCharPtr();
}
- /// Standard iterator.
+ /// Standard iterator.
inline const_iterator End() const noexcept {
return Begin() + Size();
}
@@ -181,26 +181,26 @@ public:
return *(Begin() + n);
}
- /// Shortcut to SubBlob(0, len)
+ /// Shortcut to SubBlob(0, len)
TBlob SubBlob(size_t len) const;
- /// Creates a new object from the provided range [begin, end) of internal data. No memory allocation and no copy.
- /// @details Increments the refcounter of the current object
+ /// Creates a new object from the provided range [begin, end) of internal data. No memory allocation and no copy.
+ /// @details Increments the refcounter of the current object
TBlob SubBlob(size_t begin, size_t end) const;
- /// Calls Copy() for the internal data.
+ /// Calls Copy() for the internal data.
TBlob DeepCopy() const;
- /// Creates a new blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies the data content.
+ /// Creates a new blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies the data content.
static TBlob CopySingleThreaded(const void* data, size_t length);
- /// Creates a new blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies the data content.
+ /// Creates a new blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies the data content.
static TBlob Copy(const void* data, size_t length);
- /// Creates a blob which doesn't own data. No refcounter, no memory allocation, no data copy.
+ /// Creates a blob which doesn't own data. No refcounter, no memory allocation, no data copy.
static TBlob NoCopy(const void* data, size_t length);
- /// Creates a blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data.
+ /// Creates a blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data.
static TBlob FromFileSingleThreaded(const TString& path, EMappingMode);
/// Creates a blob with a multi-threaded (atomic) refcounter. It maps the file on the path as data.
@@ -215,27 +215,27 @@ public:
/// Creates a blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data.
static TBlob FromFileSingleThreaded(const TString& path);
- /// Creates a blob with a multi-threaded (atomic) refcounter. It maps the file on the path as data.
+ /// Creates a blob with a multi-threaded (atomic) refcounter. It maps the file on the path as data.
static TBlob FromFile(const TString& path);
- /// Creates a blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data.
+ /// Creates a blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data.
static TBlob FromFileSingleThreaded(const TFile& file);
- /// Creates a blob with a multi-threaded (atomic) refcounter. It maps the file on the path as data.
+ /// Creates a blob with a multi-threaded (atomic) refcounter. It maps the file on the path as data.
static TBlob FromFile(const TFile& file);
// TODO: drop Precharged* functions.
- /// Creates a precharged blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data.
+ /// Creates a precharged blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data.
static TBlob PrechargedFromFileSingleThreaded(const TString& path);
- /// Creates a precharged blob with a multi-threaded (atomic) refcounter. It maps the file on the path as data.
+ /// Creates a precharged blob with a multi-threaded (atomic) refcounter. It maps the file on the path as data.
static TBlob PrechargedFromFile(const TString& path);
- /// Creates a precharged blob with a single-threaded (non atomic) refcounter. It maps the file content as data.
+ /// Creates a precharged blob with a single-threaded (non atomic) refcounter. It maps the file content as data.
static TBlob PrechargedFromFileSingleThreaded(const TFile& file);
- /// Creates a precharged blob with a multi-threaded (atomic) refcounter. It maps the file content as data.
+ /// Creates a precharged blob with a multi-threaded (atomic) refcounter. It maps the file content as data.
static TBlob PrechargedFromFile(const TFile& file);
/// Creates a locked blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data.
@@ -256,42 +256,42 @@ public:
/// Creates a locked blob with a multi-threaded (atomic) refcounter from the mapped memory.
static TBlob LockedFromMemoryMap(const TMemoryMap& map, ui64 offset, size_t length);
- /// Creates a blob with a single-threaded (non atomic) refcounter from the mapped memory.
+ /// Creates a blob with a single-threaded (non atomic) refcounter from the mapped memory.
static TBlob FromMemoryMapSingleThreaded(const TMemoryMap& map, ui64 offset, size_t length);
- /// Creates a blob with a multi-threaded (atomic) refcounter from the mapped memory.
+ /// Creates a blob with a multi-threaded (atomic) refcounter from the mapped memory.
static TBlob FromMemoryMap(const TMemoryMap& map, ui64 offset, size_t length);
- /// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the file on the path using pread().
+ /// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the file on the path using pread().
static TBlob FromFileContentSingleThreaded(const TString& path);
- /// Creates a blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies data from the file on the path using pread().
+ /// Creates a blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies data from the file on the path using pread().
static TBlob FromFileContent(const TString& path);
- /// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the file using pread().
+ /// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the file using pread().
static TBlob FromFileContentSingleThreaded(const TFile& file);
- /// Creates a blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies data from the file using pread().
+ /// Creates a blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies data from the file using pread().
static TBlob FromFileContent(const TFile& file);
- /// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the provided range of the file content using pread().
+ /// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the provided range of the file content using pread().
static TBlob FromFileContentSingleThreaded(const TFile& file, ui64 offset, size_t length);
- /// Creates a blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies data from the provided range of the file content using pread().
+ /// Creates a blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies data from the provided range of the file content using pread().
static TBlob FromFileContent(const TFile& file, ui64 offset, size_t length);
- /// Creates a blob from the stream content with a single-threaded (non atomic) refcounter.
+ /// Creates a blob from the stream content with a single-threaded (non atomic) refcounter.
static TBlob FromStreamSingleThreaded(IInputStream& in);
- /// Creates a blob from the stream content with a multi-threaded (atomic) refcounter.
+ /// Creates a blob from the stream content with a multi-threaded (atomic) refcounter.
static TBlob FromStream(IInputStream& in);
- /// Creates a blob with a single-threaded (non atomic) refcounter. No memory allocation, no content copy.
- /// @details The input object becomes empty.
+ /// Creates a blob with a single-threaded (non atomic) refcounter. No memory allocation, no content copy.
+ /// @details The input object becomes empty.
static TBlob FromBufferSingleThreaded(TBuffer& in);
- /// Creates a blob with a multi-threaded (atomic) refcounter. No memory allocation, no content copy.
- /// @details The input object becomes empty.
+ /// Creates a blob with a multi-threaded (atomic) refcounter. No memory allocation, no content copy.
+ /// @details The input object becomes empty.
static TBlob FromBuffer(TBuffer& in);
/// Creates a blob from TString with a single-threaded (non atomic) refcounter.
diff --git a/util/network/iovec.h b/util/network/iovec.h
index 1ba5d0f18b..ac15a41f54 100644
--- a/util/network/iovec.h
+++ b/util/network/iovec.h
@@ -29,7 +29,7 @@ public:
}
if (len) {
- Y_ASSERT(0 && "non zero length left");
+ Y_ASSERT(0 && "non zero length left");
}
}
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index 9061372b90..4f6e804346 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -695,7 +695,7 @@ static inline SOCKET DoConnectImpl(const struct addrinfo* res, const TInstant& d
return s.Release();
}
- ythrow yexception() << "something went wrong: nullptr at addrinfo";
+ ythrow yexception() << "something went wrong: nullptr at addrinfo";
}
static inline SOCKET DoConnect(const struct addrinfo* res, const TInstant& deadLine) {
diff --git a/util/string/cast.cpp b/util/string/cast.cpp
index 560fb22044..aa1e65a8e9 100644
--- a/util/string/cast.cpp
+++ b/util/string/cast.cpp
@@ -788,7 +788,7 @@ namespace {
static inline size_t DoDtoa(double d, char* buf, size_t len, int prec) noexcept {
TBuilder sb(buf, len);
- Y_VERIFY(ToStringConverterNoPad().ToPrecision(d, prec, sb.SB), "conversion failed");
+ Y_VERIFY(ToStringConverterNoPad().ToPrecision(d, prec, sb.SB), "conversion failed");
return FixEnd(buf, FixZeros(buf, sb.SB->position()));
}
@@ -808,7 +808,7 @@ size_t FloatToString(float t, char* buf, size_t len, EFloatToStringMode mode, in
if (mode == PREC_AUTO) {
TBuilder sb(buf, len);
- Y_VERIFY(ToStringConverterNoPad().ToShortestSingle(t, sb.SB), "conversion failed");
+ Y_VERIFY(ToStringConverterNoPad().ToShortestSingle(t, sb.SB), "conversion failed");
return FixEnd(buf, sb.SB->position());
}
@@ -827,7 +827,7 @@ size_t FloatToString(double t, char* buf, size_t len, EFloatToStringMode mode, i
TBuilder sb(buf, len);
if (mode == PREC_AUTO) {
- Y_VERIFY(ToStringConverterNoPad().ToShortest(t, sb.SB), "conversion failed");
+ Y_VERIFY(ToStringConverterNoPad().ToShortest(t, sb.SB), "conversion failed");
return FixEnd(buf, sb.SB->position());
}
diff --git a/util/string/strip.h b/util/string/strip.h
index cde1e1d038..d5ef6da96d 100644
--- a/util/string/strip.h
+++ b/util/string/strip.h
@@ -177,18 +177,18 @@ static inline T StripStringRight(const T& from, TStripCriterion&& criterion) {
return TStripImpl<false, true>::StripString(from, criterion);
}
-/// Copies the given string removing leading and trailing spaces.
+/// Copies the given string removing leading and trailing spaces.
static inline bool Strip(const TString& from, TString& to) {
return StripString(from, to);
}
-/// Removes leading and trailing spaces from the string.
+/// Removes leading and trailing spaces from the string.
inline TString& StripInPlace(TString& s) {
Strip(s, s);
return s;
}
-/// Returns a copy of the given string with removed leading and trailing spaces.
+/// Returns a copy of the given string with removed leading and trailing spaces.
inline TString Strip(const TString& s) Y_WARN_UNUSED_RESULT;
inline TString Strip(const TString& s) {
TString ret = s;
@@ -232,13 +232,13 @@ bool CollapseImpl(const TStringType& from, TStringType& to, size_t maxLen, const
bool Collapse(const TString& from, TString& to, size_t maxLen = 0);
-/// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes)
+/// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes)
inline TString& CollapseInPlace(TString& s, size_t maxLen = 0) {
Collapse(s, s, maxLen);
return s;
}
-/// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes)
+/// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes)
inline TString Collapse(const TString& s, size_t maxLen = 0) Y_WARN_UNUSED_RESULT;
inline TString Collapse(const TString& s, size_t maxLen) {
TString ret;
@@ -248,8 +248,8 @@ inline TString Collapse(const TString& s, size_t maxLen) {
void CollapseText(const TString& from, TString& to, size_t maxLen);
-/// The same as Collapse() + truncates the string to maxLen.
-/// @details An ellipsis is inserted at the end of the truncated line.
+/// The same as Collapse() + truncates the string to maxLen.
+/// @details An ellipsis is inserted at the end of the truncated line.
inline void CollapseText(TString& s, size_t maxLen) {
TString to;
CollapseText(s, to, maxLen);
diff --git a/util/string/type.h b/util/string/type.h
index 9602f260d1..d6cb29ea58 100644
--- a/util/string/type.h
+++ b/util/string/type.h
@@ -4,17 +4,17 @@
Y_PURE_FUNCTION bool IsSpace(const char* s, size_t len) noexcept;
-/// Checks if a string is a set of only space symbols.
+/// Checks if a string is a set of only space symbols.
Y_PURE_FUNCTION static inline bool IsSpace(const TStringBuf s) noexcept {
return IsSpace(s.data(), s.size());
}
-/// Returns "true" if the given string is an arabic number ([0-9]+)
+/// Returns "true" if the given string is an arabic number ([0-9]+)
Y_PURE_FUNCTION bool IsNumber(const TStringBuf s) noexcept;
Y_PURE_FUNCTION bool IsNumber(const TWtringBuf s) noexcept;
-/// Returns "true" if the given string is a hex number ([0-9a-fA-F]+)
+/// Returns "true" if the given string is a hex number ([0-9a-fA-F]+)
Y_PURE_FUNCTION bool IsHexNumber(const TStringBuf s) noexcept;
Y_PURE_FUNCTION bool IsHexNumber(const TWtringBuf s) noexcept;
diff --git a/util/string/util.h b/util/string/util.h
index a958a7a1a4..0d77a5042b 100644
--- a/util/string/util.h
+++ b/util/string/util.h
@@ -14,7 +14,7 @@
/// @{
int a2i(const TString& s);
-/// Removes the last character if it is equal to c.
+/// Removes the last character if it is equal to c.
template <class T>
inline void RemoveIfLast(T& s, int c) {
const size_t length = s.length();
@@ -22,7 +22,7 @@ inline void RemoveIfLast(T& s, int c) {
s.remove(length - 1);
}
-/// Adds lastCh symbol to the the of the string if it is not already there.
+/// Adds lastCh symbol to the the of the string if it is not already there.
inline void addIfNotLast(TString& s, int lastCh) {
size_t len = s.length();
if (!len || s[len - 1] != lastCh) {
@@ -30,9 +30,9 @@ inline void addIfNotLast(TString& s, int lastCh) {
}
}
-/// @details Finishes the string with lastCh1 if lastCh2 is not present in the string and lastCh1 is not already at the end of the string.
-/// Else, if lastCh2 is not equal to the symbol before the last, it finishes the string with lastCh2.
-/// @todo ?? Define, when to apply the function. Is in use several times for URLs parsing.
+/// @details Finishes the string with lastCh1 if lastCh2 is not present in the string and lastCh1 is not already at the end of the string.
+/// Else, if lastCh2 is not equal to the symbol before the last, it finishes the string with lastCh2.
+/// @todo ?? Define, when to apply the function. Is in use several times for URLs parsing.
inline void addIfAbsent(TString& s, char lastCh1, char lastCh2) {
size_t pos = s.find(lastCh2);
if (pos == TString::npos) {
diff --git a/util/system/hp_timer.h b/util/system/hp_timer.h
index e9ab10ec26..0a4c252ec2 100644
--- a/util/system/hp_timer.h
+++ b/util/system/hp_timer.h
@@ -4,13 +4,13 @@
namespace NHPTimer {
using STime = i64;
- // May delay for ~50ms to compute frequency
+ // May delay for ~50ms to compute frequency
double GetSeconds(const STime& a) noexcept;
- // Returns the current time
+ // Returns the current time
void GetTime(STime* pTime) noexcept;
- // Returns the time passed since *pTime, and writes the current time into *pTime.
+ // Returns the time passed since *pTime, and writes the current time into *pTime.
double GetTimePassed(STime* pTime) noexcept;
- // Get TSC frequency, may delay for ~50ms to compute frequency
+ // Get TSC frequency, may delay for ~50ms to compute frequency
double GetClockRate() noexcept;
// same as GetClockRate, but in integer
ui64 GetCyclesPerSecond() noexcept;
diff --git a/util/system/rwlock.cpp b/util/system/rwlock.cpp
index abe7435960..bb3dcbf188 100644
--- a/util/system/rwlock.cpp
+++ b/util/system/rwlock.cpp
@@ -41,8 +41,8 @@ TRWMutex::TImpl::TImpl()
}
TRWMutex::TImpl::~TImpl() {
- Y_VERIFY(State_ == 0, "failure, State_ != 0");
- Y_VERIFY(BlockedWriters_ == 0, "failure, BlockedWriters_ != 0");
+ Y_VERIFY(State_ == 0, "failure, State_ != 0");
+ Y_VERIFY(BlockedWriters_ == 0, "failure, BlockedWriters_ != 0");
}
void TRWMutex::TImpl::AcquireRead() noexcept {
diff --git a/util/system/types.h b/util/system/types.h
index 3408749656..12e68a6060 100644
--- a/util/system/types.h
+++ b/util/system/types.h
@@ -33,7 +33,7 @@ typedef int64_t i64;
#define LL(number) INT64_C(number)
#define ULL(number) UINT64_C(number)
-// Macro for size_t and ptrdiff_t types
+// Macro for size_t and ptrdiff_t types
#if defined(_32_)
#if defined(_darwin_)
#define PRISZT "lu"
diff --git a/util/ysafeptr.h b/util/ysafeptr.h
index d9678ff93a..af7dfd4bed 100644
--- a/util/ysafeptr.h
+++ b/util/ysafeptr.h
@@ -6,20 +6,20 @@
#include <util/system/tls.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
-// There are different templates of pointers:
-// 1. Simple pointers.
-// 2. TPtr with refereces.
-// 3. TObj/TMObj with ownership. After destruction of a TObj the object it referenced to is
-// cleaned up and marked as non valid. Similarly does TMobj organizing the parallel ownership
-// of an object.
-//
-// Limitations:
-// 1. It may be necessary to use BASIC_REGISTER_CLASS() in .cpp files to be able to use a
-// pointer to a forward declared class.
-// 2. It's prohibited to override the 'new' operator, since the standard 'delete' will be used
-// for destruction of objects (because of 'delete this').
+// There are different templates of pointers:
+// 1. Simple pointers.
+// 2. TPtr with refereces.
+// 3. TObj/TMObj with ownership. After destruction of a TObj the object it referenced to is
+// cleaned up and marked as non valid. Similarly does TMobj organizing the parallel ownership
+// of an object.
+//
+// Limitations:
+// 1. It may be necessary to use BASIC_REGISTER_CLASS() in .cpp files to be able to use a
+// pointer to a forward declared class.
+// 2. It's prohibited to override the 'new' operator, since the standard 'delete' will be used
+// for destruction of objects (because of 'delete this').
////////////////////////////////////////////////////////////////////////////////////////////////////
-
+
#if defined(_MSC_VER) && defined(_DEBUG)
#include <util/system/winint.h>
#define CHECK_YPTR2