catboost 1.25.1 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/DEPLOYMENT.md +22 -15
  2. package/README.md +37 -27
  3. package/binding.gyp +5 -7
  4. package/build_scripts/bootstrap.js +2 -1
  5. package/build_scripts/out/build.js +46 -68
  6. package/build_scripts/out/build_model.js +1 -1
  7. package/build_scripts/out/{build_ya.js → build_native.js} +1 -1
  8. package/build_scripts/out/ci.js +5 -5
  9. package/build_scripts/out/config.js +32 -18
  10. package/build_scripts/out/install.js +5 -3
  11. package/build_scripts/out/package_prepublish.js +1 -1
  12. package/build_scripts/out/packaging.js +1 -19
  13. package/build_scripts/out/run_tests.js +1 -1
  14. package/build_scripts/out/test.js +8 -3
  15. package/config.json +18 -11
  16. package/inc/catboost/libs/model_interface/c_api.h +349 -3
  17. package/lib/catboost.d.ts +65 -21
  18. package/package.json +4 -4
  19. package/src/api_helpers.cpp +100 -24
  20. package/src/api_helpers.h +8 -7
  21. package/src/api_module.cpp +1 -2
  22. package/src/model.cpp +483 -83
  23. package/src/model.h +24 -9
  24. package/inc/contrib/libs/cxxsupp/system_stl/include/stlfwd +0 -14
  25. package/inc/util/charset/recode_result.h +0 -9
  26. package/inc/util/charset/unicode_table.h +0 -123
  27. package/inc/util/charset/unidata.h +0 -421
  28. package/inc/util/charset/utf8.h +0 -384
  29. package/inc/util/charset/wide.h +0 -843
  30. package/inc/util/charset/wide_specific.h +0 -22
  31. package/inc/util/datetime/base.h +0 -669
  32. package/inc/util/datetime/constants.h +0 -7
  33. package/inc/util/datetime/cputimer.h +0 -124
  34. package/inc/util/datetime/parser.h +0 -292
  35. package/inc/util/datetime/systime.h +0 -47
  36. package/inc/util/datetime/uptime.h +0 -8
  37. package/inc/util/digest/city.h +0 -88
  38. package/inc/util/digest/fnv.h +0 -73
  39. package/inc/util/digest/multi.h +0 -14
  40. package/inc/util/digest/murmur.h +0 -57
  41. package/inc/util/digest/numeric.h +0 -86
  42. package/inc/util/digest/sequence.h +0 -48
  43. package/inc/util/draft/date.h +0 -129
  44. package/inc/util/draft/datetime.h +0 -184
  45. package/inc/util/draft/enum.h +0 -136
  46. package/inc/util/draft/holder_vector.h +0 -102
  47. package/inc/util/draft/ip.h +0 -131
  48. package/inc/util/draft/matrix.h +0 -108
  49. package/inc/util/draft/memory.h +0 -40
  50. package/inc/util/folder/dirent_win.h +0 -46
  51. package/inc/util/folder/dirut.h +0 -121
  52. package/inc/util/folder/filelist.h +0 -81
  53. package/inc/util/folder/fts.h +0 -108
  54. package/inc/util/folder/iterator.h +0 -109
  55. package/inc/util/folder/lstat_win.h +0 -20
  56. package/inc/util/folder/path.h +0 -225
  57. package/inc/util/folder/pathsplit.h +0 -113
  58. package/inc/util/folder/tempdir.h +0 -42
  59. package/inc/util/generic/adaptor.h +0 -134
  60. package/inc/util/generic/algorithm.h +0 -765
  61. package/inc/util/generic/array_ref.h +0 -282
  62. package/inc/util/generic/array_size.h +0 -24
  63. package/inc/util/generic/benchmark/vector_count_ctor/f.h +0 -9
  64. package/inc/util/generic/bitmap.h +0 -1115
  65. package/inc/util/generic/bitops.h +0 -459
  66. package/inc/util/generic/bt_exception.h +0 -24
  67. package/inc/util/generic/buffer.h +0 -232
  68. package/inc/util/generic/cast.h +0 -176
  69. package/inc/util/generic/deque.h +0 -24
  70. package/inc/util/generic/explicit_type.h +0 -42
  71. package/inc/util/generic/fastqueue.h +0 -55
  72. package/inc/util/generic/flags.h +0 -244
  73. package/inc/util/generic/function.h +0 -103
  74. package/inc/util/generic/fwd.h +0 -171
  75. package/inc/util/generic/guid.h +0 -61
  76. package/inc/util/generic/hash.h +0 -2032
  77. package/inc/util/generic/hash_primes.h +0 -140
  78. package/inc/util/generic/hash_set.h +0 -490
  79. package/inc/util/generic/hide_ptr.h +0 -3
  80. package/inc/util/generic/intrlist.h +0 -876
  81. package/inc/util/generic/is_in.h +0 -53
  82. package/inc/util/generic/iterator.h +0 -137
  83. package/inc/util/generic/iterator_range.h +0 -105
  84. package/inc/util/generic/lazy_value.h +0 -66
  85. package/inc/util/generic/list.h +0 -22
  86. package/inc/util/generic/map.h +0 -44
  87. package/inc/util/generic/mapfindptr.h +0 -60
  88. package/inc/util/generic/maybe.h +0 -713
  89. package/inc/util/generic/maybe_traits.h +0 -164
  90. package/inc/util/generic/mem_copy.h +0 -55
  91. package/inc/util/generic/noncopyable.h +0 -38
  92. package/inc/util/generic/object_counter.h +0 -53
  93. package/inc/util/generic/ptr.h +0 -1113
  94. package/inc/util/generic/queue.h +0 -57
  95. package/inc/util/generic/refcount.h +0 -162
  96. package/inc/util/generic/reserve.h +0 -11
  97. package/inc/util/generic/scope.h +0 -65
  98. package/inc/util/generic/serialized_enum.h +0 -406
  99. package/inc/util/generic/set.h +0 -42
  100. package/inc/util/generic/singleton.h +0 -136
  101. package/inc/util/generic/size_literals.h +0 -65
  102. package/inc/util/generic/stack.h +0 -18
  103. package/inc/util/generic/store_policy.h +0 -120
  104. package/inc/util/generic/strbase.h +0 -612
  105. package/inc/util/generic/strbuf.h +0 -552
  106. package/inc/util/generic/strfcpy.h +0 -17
  107. package/inc/util/generic/string.h +0 -1572
  108. package/inc/util/generic/string_hash.h +0 -21
  109. package/inc/util/generic/string_ut.h +0 -1175
  110. package/inc/util/generic/type_name.h +0 -34
  111. package/inc/util/generic/typelist.h +0 -114
  112. package/inc/util/generic/typetraits.h +0 -325
  113. package/inc/util/generic/utility.h +0 -132
  114. package/inc/util/generic/va_args.h +0 -400
  115. package/inc/util/generic/variant.h +0 -631
  116. package/inc/util/generic/variant_traits.h +0 -171
  117. package/inc/util/generic/vector.h +0 -119
  118. package/inc/util/generic/xrange.h +0 -258
  119. package/inc/util/generic/yexception.h +0 -212
  120. package/inc/util/generic/yexception_ut.h +0 -14
  121. package/inc/util/generic/ylimits.h +0 -92
  122. package/inc/util/generic/ymath.h +0 -206
  123. package/inc/util/memory/addstorage.h +0 -93
  124. package/inc/util/memory/alloc.h +0 -27
  125. package/inc/util/memory/blob.h +0 -296
  126. package/inc/util/memory/mmapalloc.h +0 -8
  127. package/inc/util/memory/pool.h +0 -432
  128. package/inc/util/memory/segmented_string_pool.h +0 -194
  129. package/inc/util/memory/segpool_alloc.h +0 -118
  130. package/inc/util/memory/smallobj.h +0 -141
  131. package/inc/util/memory/tempbuf.h +0 -111
  132. package/inc/util/network/address.h +0 -136
  133. package/inc/util/network/endpoint.h +0 -61
  134. package/inc/util/network/hostip.h +0 -16
  135. package/inc/util/network/init.h +0 -60
  136. package/inc/util/network/interface.h +0 -17
  137. package/inc/util/network/iovec.h +0 -65
  138. package/inc/util/network/ip.h +0 -116
  139. package/inc/util/network/nonblock.h +0 -8
  140. package/inc/util/network/pair.h +0 -9
  141. package/inc/util/network/poller.h +0 -58
  142. package/inc/util/network/pollerimpl.h +0 -707
  143. package/inc/util/network/sock.h +0 -608
  144. package/inc/util/network/socket.h +0 -421
  145. package/inc/util/random/common_ops.h +0 -130
  146. package/inc/util/random/easy.h +0 -47
  147. package/inc/util/random/entropy.h +0 -21
  148. package/inc/util/random/fast.h +0 -101
  149. package/inc/util/random/init_atfork.h +0 -3
  150. package/inc/util/random/lcg_engine.h +0 -66
  151. package/inc/util/random/mersenne.h +0 -46
  152. package/inc/util/random/mersenne32.h +0 -50
  153. package/inc/util/random/mersenne64.h +0 -50
  154. package/inc/util/random/normal.h +0 -38
  155. package/inc/util/random/random.h +0 -30
  156. package/inc/util/random/shuffle.h +0 -39
  157. package/inc/util/str_stl.h +0 -266
  158. package/inc/util/stream/aligned.h +0 -99
  159. package/inc/util/stream/buffer.h +0 -119
  160. package/inc/util/stream/buffered.h +0 -225
  161. package/inc/util/stream/debug.h +0 -53
  162. package/inc/util/stream/direct_io.h +0 -43
  163. package/inc/util/stream/file.h +0 -108
  164. package/inc/util/stream/format.h +0 -444
  165. package/inc/util/stream/fwd.h +0 -100
  166. package/inc/util/stream/hex.h +0 -8
  167. package/inc/util/stream/holder.h +0 -44
  168. package/inc/util/stream/input.h +0 -273
  169. package/inc/util/stream/labeled.h +0 -19
  170. package/inc/util/stream/length.h +0 -100
  171. package/inc/util/stream/mem.h +0 -255
  172. package/inc/util/stream/multi.h +0 -32
  173. package/inc/util/stream/null.h +0 -61
  174. package/inc/util/stream/output.h +0 -304
  175. package/inc/util/stream/pipe.h +0 -112
  176. package/inc/util/stream/printf.h +0 -25
  177. package/inc/util/stream/str.h +0 -207
  178. package/inc/util/stream/tee.h +0 -28
  179. package/inc/util/stream/tempbuf.h +0 -21
  180. package/inc/util/stream/tokenizer.h +0 -214
  181. package/inc/util/stream/trace.h +0 -60
  182. package/inc/util/stream/walk.h +0 -35
  183. package/inc/util/stream/zerocopy.h +0 -91
  184. package/inc/util/stream/zerocopy_output.h +0 -57
  185. package/inc/util/stream/zlib.h +0 -173
  186. package/inc/util/string/ascii.h +0 -236
  187. package/inc/util/string/builder.h +0 -39
  188. package/inc/util/string/cast.h +0 -347
  189. package/inc/util/string/cstriter.h +0 -14
  190. package/inc/util/string/escape.h +0 -70
  191. package/inc/util/string/hex.h +0 -59
  192. package/inc/util/string/join.h +0 -194
  193. package/inc/util/string/printf.h +0 -13
  194. package/inc/util/string/reverse.h +0 -16
  195. package/inc/util/string/split.h +0 -1080
  196. package/inc/util/string/strip.h +0 -257
  197. package/inc/util/string/strspn.h +0 -65
  198. package/inc/util/string/subst.h +0 -56
  199. package/inc/util/string/type.h +0 -50
  200. package/inc/util/string/util.h +0 -195
  201. package/inc/util/string/vector.h +0 -132
  202. package/inc/util/system/align.h +0 -50
  203. package/inc/util/system/atexit.h +0 -22
  204. package/inc/util/system/atomic.h +0 -51
  205. package/inc/util/system/atomic_gcc.h +0 -90
  206. package/inc/util/system/atomic_ops.h +0 -189
  207. package/inc/util/system/atomic_win.h +0 -114
  208. package/inc/util/system/backtrace.h +0 -39
  209. package/inc/util/system/byteorder.h +0 -186
  210. package/inc/util/system/compat.h +0 -84
  211. package/inc/util/system/compiler.h +0 -620
  212. package/inc/util/system/condvar.h +0 -71
  213. package/inc/util/system/context.h +0 -181
  214. package/inc/util/system/context_aarch64.h +0 -8
  215. package/inc/util/system/context_i686.h +0 -9
  216. package/inc/util/system/context_x86.h +0 -12
  217. package/inc/util/system/context_x86_64.h +0 -7
  218. package/inc/util/system/cpu_id.h +0 -159
  219. package/inc/util/system/daemon.h +0 -28
  220. package/inc/util/system/datetime.h +0 -98
  221. package/inc/util/system/defaults.h +0 -149
  222. package/inc/util/system/demangle.h +0 -5
  223. package/inc/util/system/demangle_impl.h +0 -23
  224. package/inc/util/system/direct_io.h +0 -71
  225. package/inc/util/system/dynlib.h +0 -119
  226. package/inc/util/system/env.h +0 -32
  227. package/inc/util/system/error.h +0 -95
  228. package/inc/util/system/event.h +0 -122
  229. package/inc/util/system/execpath.h +0 -17
  230. package/inc/util/system/fasttime.h +0 -6
  231. package/inc/util/system/fhandle.h +0 -27
  232. package/inc/util/system/file.h +0 -210
  233. package/inc/util/system/file_lock.h +0 -34
  234. package/inc/util/system/filemap.h +0 -383
  235. package/inc/util/system/flock.h +0 -35
  236. package/inc/util/system/fs.h +0 -156
  237. package/inc/util/system/fs_win.h +0 -29
  238. package/inc/util/system/fstat.h +0 -46
  239. package/inc/util/system/getpid.h +0 -12
  240. package/inc/util/system/guard.h +0 -179
  241. package/inc/util/system/hi_lo.h +0 -139
  242. package/inc/util/system/hostname.h +0 -10
  243. package/inc/util/system/hp_timer.h +0 -36
  244. package/inc/util/system/info.h +0 -12
  245. package/inc/util/system/interrupt_signals.h +0 -22
  246. package/inc/util/system/madvise.h +0 -30
  247. package/inc/util/system/maxlen.h +0 -32
  248. package/inc/util/system/mem_info.h +0 -18
  249. package/inc/util/system/mincore.h +0 -38
  250. package/inc/util/system/mktemp.h +0 -11
  251. package/inc/util/system/mlock.h +0 -43
  252. package/inc/util/system/mutex.h +0 -67
  253. package/inc/util/system/nice.h +0 -3
  254. package/inc/util/system/pipe.h +0 -90
  255. package/inc/util/system/platform.h +0 -246
  256. package/inc/util/system/progname.h +0 -13
  257. package/inc/util/system/protect.h +0 -25
  258. package/inc/util/system/rusage.h +0 -26
  259. package/inc/util/system/rwlock.h +0 -78
  260. package/inc/util/system/sanitizers.h +0 -122
  261. package/inc/util/system/sem.h +0 -41
  262. package/inc/util/system/shellcommand.h +0 -472
  263. package/inc/util/system/shmat.h +0 -32
  264. package/inc/util/system/sigset.h +0 -78
  265. package/inc/util/system/spin_wait.h +0 -10
  266. package/inc/util/system/spinlock.h +0 -121
  267. package/inc/util/system/src_location.h +0 -25
  268. package/inc/util/system/src_root.h +0 -68
  269. package/inc/util/system/sys_alloc.h +0 -43
  270. package/inc/util/system/sysstat.h +0 -52
  271. package/inc/util/system/tempfile.h +0 -34
  272. package/inc/util/system/thread.h +0 -167
  273. package/inc/util/system/tls.h +0 -307
  274. package/inc/util/system/types.h +0 -119
  275. package/inc/util/system/unaligned_mem.h +0 -67
  276. package/inc/util/system/user.h +0 -5
  277. package/inc/util/system/utime.h +0 -6
  278. package/inc/util/system/valgrind.h +0 -48
  279. package/inc/util/system/winint.h +0 -43
  280. package/inc/util/system/yassert.h +0 -121
  281. package/inc/util/system/yield.h +0 -4
  282. package/inc/util/thread/factory.h +0 -65
  283. package/inc/util/thread/fwd.h +0 -30
  284. package/inc/util/thread/lfqueue.h +0 -406
  285. package/inc/util/thread/lfstack.h +0 -188
  286. package/inc/util/thread/pool.h +0 -388
  287. package/inc/util/thread/singleton.h +0 -42
  288. package/inc/util/ysafeptr.h +0 -427
  289. package/inc/util/ysaveload.h +0 -700
@@ -1,124 +0,0 @@
1
- #pragma once
2
-
3
- #include "base.h"
4
-
5
- #include <util/system/rusage.h>
6
- #include <util/generic/string.h>
7
- #include <util/stream/str.h>
8
-
9
- class TTimer {
10
- private:
11
- TInstant Start_;
12
- TStringStream Message_;
13
-
14
- public:
15
- TTimer(const TStringBuf message = TStringBuf(" took: "));
16
- ~TTimer();
17
- };
18
-
19
- class TSimpleTimer {
20
- TInstant T;
21
-
22
- public:
23
- TSimpleTimer() {
24
- Reset();
25
- }
26
- TDuration Get() const {
27
- return TInstant::Now() - T;
28
- }
29
- void Reset() {
30
- T = TInstant::Now();
31
- }
32
- };
33
-
34
- class TProfileTimer {
35
- TDuration T;
36
-
37
- public:
38
- TProfileTimer() {
39
- Reset();
40
- }
41
- TDuration Get() const {
42
- return TRusage::Get().Utime - T;
43
- }
44
- TDuration Step() {
45
- TRusage r;
46
- r.Fill();
47
- TDuration d = r.Utime - T;
48
- T = r.Utime;
49
- return d;
50
- }
51
- void Reset() {
52
- T = TRusage::Get().Utime;
53
- }
54
- };
55
-
56
- /// Return cached processor cycle count per second. Method takes 1 second at first invocation.
57
- /// Note, on older systems cycle rate may change during program lifetime,
58
- /// so returned value may be incorrect. Modern Intel and AMD processors keep constant TSC rate.
59
- ui64 GetCyclesPerMillisecond();
60
- void SetCyclesPerSecond(ui64 cycles);
61
-
62
- TDuration CyclesToDuration(ui64 cycles);
63
- ui64 DurationToCycles(TDuration duration);
64
-
65
- class TPrecisionTimer {
66
- private:
67
- ui64 Start = 0;
68
-
69
- public:
70
- TPrecisionTimer();
71
-
72
- ui64 GetCycleCount() const;
73
- };
74
-
75
- TString FormatCycles(ui64 cycles);
76
-
77
- class TFormattedPrecisionTimer {
78
- private:
79
- ui64 Start;
80
- const char* Message;
81
- IOutputStream* Out;
82
-
83
- public:
84
- TFormattedPrecisionTimer(const char* message = "took ", IOutputStream* out = &Cout);
85
- ~TFormattedPrecisionTimer();
86
- };
87
-
88
- class TFuncTimer {
89
- public:
90
- TFuncTimer(const char* func);
91
- ~TFuncTimer();
92
-
93
- private:
94
- const TInstant Start_;
95
- const char* Func_;
96
- };
97
-
98
- class TFakeTimer {
99
- public:
100
- inline TFakeTimer(const char* = nullptr) noexcept {
101
- }
102
- };
103
-
104
- #if defined(WITH_DEBUG)
105
- #define TDebugTimer TFuncTimer
106
- #else
107
- #define TDebugTimer TFakeTimer
108
- #endif
109
-
110
- class TTimeLogger {
111
- private:
112
- TString Message;
113
- bool Verbose;
114
- bool OK;
115
- time_t Begin;
116
- ui64 BeginCycles;
117
-
118
- public:
119
- TTimeLogger(const TString& message, bool verbose = true);
120
- ~TTimeLogger();
121
-
122
- void SetOK();
123
- double ElapsedTime() const;
124
- };
@@ -1,292 +0,0 @@
1
- #pragma once
2
-
3
- // probably you do not need to include this file directly, use "util/datetime/base.h"
4
-
5
- #include "base.h"
6
-
7
- struct TDateTimeFields {
8
- TDateTimeFields() {
9
- Zero(*this);
10
- ZoneOffsetMinutes = 0;
11
- Hour = 0;
12
- }
13
-
14
- ui32 Year;
15
- ui32 Month; // 1..12
16
- ui32 Day; // 1 .. 31
17
- ui32 Hour; // 0 .. 23
18
- ui32 Minute; // 0 .. 59
19
- ui32 Second; // 0 .. 60
20
- ui32 MicroSecond; // 0 .. 999999
21
- i32 ZoneOffsetMinutes;
22
-
23
- void SetLooseYear(ui32 year) {
24
- if (year < 60)
25
- year += 100;
26
- if (year < 160)
27
- year += 1900;
28
- Year = year;
29
- }
30
-
31
- bool IsOk() const noexcept {
32
- if (Year < 1970)
33
- return false;
34
- if (Month < 1 || Month > 12)
35
- return false;
36
-
37
- unsigned int maxMonthDay = 31;
38
- if (Month == 4 || Month == 6 || Month == 9 || Month == 11) {
39
- maxMonthDay = 30;
40
- } else if (Month == 2) {
41
- if (Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0))
42
- // leap year
43
- maxMonthDay = 29;
44
- else
45
- maxMonthDay = 28;
46
- }
47
- if (Day > maxMonthDay)
48
- return false;
49
-
50
- if (Hour > 23)
51
- return false;
52
-
53
- if (Minute > 59)
54
- return false;
55
-
56
- if (Second > 60)
57
- return false;
58
-
59
- if (MicroSecond > 999999)
60
- return false;
61
-
62
- if (Year == 1970 && Month == 1 && Day == 1) {
63
- if ((i64)(3600 * Hour + 60 * Minute + Second) < (60 * ZoneOffsetMinutes))
64
- return false;
65
- }
66
-
67
- return true;
68
- }
69
-
70
- TInstant ToInstant(TInstant defaultValue) const {
71
- time_t tt = ToTimeT(-1);
72
- if (tt == -1)
73
- return defaultValue;
74
- return TInstant::Seconds(tt) + TDuration::MicroSeconds(MicroSecond);
75
- }
76
-
77
- time_t ToTimeT(time_t defaultValue) const {
78
- if (!IsOk())
79
- return defaultValue;
80
- struct tm tm;
81
- Zero(tm);
82
- tm.tm_year = Year - 1900;
83
- tm.tm_mon = Month - 1;
84
- tm.tm_mday = Day;
85
- tm.tm_hour = Hour;
86
- tm.tm_min = Minute;
87
- tm.tm_sec = Second;
88
- time_t tt = TimeGM(&tm);
89
- if (tt == -1)
90
- return defaultValue;
91
- return tt - ZoneOffsetMinutes * 60;
92
- }
93
- };
94
-
95
- class TDateTimeParserBase {
96
- public:
97
- const TDateTimeFields& GetDateTimeFields() const {
98
- return DateTimeFields;
99
- }
100
-
101
- protected:
102
- TDateTimeFields DateTimeFields;
103
- int cs; //for ragel
104
- int Sign;
105
- int I;
106
- int Dc;
107
-
108
- protected:
109
- TDateTimeParserBase()
110
- : DateTimeFields()
111
- , cs(0)
112
- , Sign(0)
113
- , I(0xDEADBEEF) // to guarantee unittest break if ragel code is incorrect
114
- , Dc(0xDEADBEEF)
115
- {
116
- }
117
-
118
- inline TInstant GetResult(int firstFinalState, TInstant defaultValue) const {
119
- if (cs < firstFinalState)
120
- return defaultValue;
121
- return DateTimeFields.ToInstant(defaultValue);
122
- }
123
- };
124
-
125
- #define DECLARE_PARSER(CLASS) \
126
- struct CLASS: public TDateTimeParserBase { \
127
- CLASS(); \
128
- bool ParsePart(const char* input, size_t len); \
129
- TInstant GetResult(TInstant defaultValue) const; \
130
- };
131
-
132
- DECLARE_PARSER(TIso8601DateTimeParser)
133
- DECLARE_PARSER(TRfc822DateTimeParser)
134
- DECLARE_PARSER(THttpDateTimeParser)
135
- DECLARE_PARSER(TX509ValidityDateTimeParser)
136
- DECLARE_PARSER(TX509Validity4yDateTimeParser)
137
-
138
- #undef DECLARE_PARSER
139
-
140
- struct TDurationParser {
141
- int cs;
142
-
143
- ui64 I;
144
- ui32 Dc;
145
-
146
- i32 MultiplierPower; // 6 for seconds, 0 for microseconds, -3 for nanoseconds
147
- i32 Multiplier;
148
- ui64 IntegerPart;
149
- ui32 FractionPart;
150
- ui32 FractionDigits;
151
-
152
- TDurationParser();
153
- bool ParsePart(const char* input, size_t len);
154
- TDuration GetResult(TDuration defaultValue) const;
155
- };
156
-
157
- /**
158
- Depcrecated cause of default hour offset (+4 hours)
159
- @see IGNIETFERRO-823
160
- */
161
- struct TDateTimeFieldsDeprecated {
162
- TDateTimeFieldsDeprecated() {
163
- Zero(*this);
164
- ZoneOffsetMinutes = (i32)TDuration::Hours(4).Minutes(); // legacy code
165
- Hour = 11;
166
- }
167
-
168
- ui32 Year;
169
- ui32 Month; // 1..12
170
- ui32 Day; // 1 .. 31
171
- ui32 Hour; // 0 .. 23
172
- ui32 Minute; // 0 .. 59
173
- ui32 Second; // 0 .. 60
174
- ui32 MicroSecond; // 0 .. 999999
175
- i32 ZoneOffsetMinutes;
176
-
177
- void SetLooseYear(ui32 year) {
178
- if (year < 60)
179
- year += 100;
180
- if (year < 160)
181
- year += 1900;
182
- Year = year;
183
- }
184
-
185
- bool IsOk() const noexcept {
186
- if (Year < 1970)
187
- return false;
188
- if (Month < 1 || Month > 12)
189
- return false;
190
-
191
- unsigned int maxMonthDay = 31;
192
- if (Month == 4 || Month == 6 || Month == 9 || Month == 11) {
193
- maxMonthDay = 30;
194
- } else if (Month == 2) {
195
- if (Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0))
196
- // leap year
197
- maxMonthDay = 29;
198
- else
199
- maxMonthDay = 28;
200
- }
201
- if (Day > maxMonthDay)
202
- return false;
203
-
204
- if (Hour > 23)
205
- return false;
206
-
207
- if (Minute > 59)
208
- return false;
209
-
210
- if (Second > 60)
211
- return false;
212
-
213
- if (MicroSecond > 999999)
214
- return false;
215
-
216
- if (Year == 1970 && Month == 1 && Day == 1) {
217
- if ((i64)(3600 * Hour + 60 * Minute + Second) < (60 * ZoneOffsetMinutes))
218
- return false;
219
- }
220
-
221
- return true;
222
- }
223
-
224
- TInstant ToInstant(TInstant defaultValue) const {
225
- time_t tt = ToTimeT(-1);
226
- if (tt == -1)
227
- return defaultValue;
228
- return TInstant::Seconds(tt) + TDuration::MicroSeconds(MicroSecond);
229
- }
230
-
231
- time_t ToTimeT(time_t defaultValue) const {
232
- if (!IsOk())
233
- return defaultValue;
234
- struct tm tm;
235
- Zero(tm);
236
- tm.tm_year = Year - 1900;
237
- tm.tm_mon = Month - 1;
238
- tm.tm_mday = Day;
239
- tm.tm_hour = Hour;
240
- tm.tm_min = Minute;
241
- tm.tm_sec = Second;
242
- time_t tt = TimeGM(&tm);
243
- if (tt == -1)
244
- return defaultValue;
245
- return tt - ZoneOffsetMinutes * 60;
246
- }
247
- };
248
-
249
- class TDateTimeParserBaseDeprecated {
250
- public:
251
- const TDateTimeFieldsDeprecated& GetDateTimeFields() const {
252
- return DateTimeFields;
253
- }
254
-
255
- protected:
256
- TDateTimeFieldsDeprecated DateTimeFields;
257
- int cs; //for ragel
258
- int Sign;
259
- int I;
260
- int Dc;
261
-
262
- protected:
263
- TDateTimeParserBaseDeprecated()
264
- : DateTimeFields()
265
- , cs(0)
266
- , Sign(0)
267
- , I(0xDEADBEEF) // to guarantee unittest break if ragel code is incorrect
268
- , Dc(0xDEADBEEF)
269
- {
270
- }
271
-
272
- inline TInstant GetResult(int firstFinalState, TInstant defaultValue) const {
273
- if (cs < firstFinalState)
274
- return defaultValue;
275
- return DateTimeFields.ToInstant(defaultValue);
276
- }
277
- };
278
-
279
- #define DECLARE_PARSER(CLASS) \
280
- struct CLASS: public TDateTimeParserBaseDeprecated { \
281
- CLASS(); \
282
- bool ParsePart(const char* input, size_t len); \
283
- TInstant GetResult(TInstant defaultValue) const; \
284
- };
285
-
286
- DECLARE_PARSER(TIso8601DateTimeParserDeprecated)
287
- DECLARE_PARSER(TRfc822DateTimeParserDeprecated)
288
- DECLARE_PARSER(THttpDateTimeParserDeprecated)
289
- DECLARE_PARSER(TX509ValidityDateTimeParserDeprecated)
290
- DECLARE_PARSER(TX509Validity4yDateTimeParserDeprecated)
291
-
292
- #undef DECLARE_PARSER
@@ -1,47 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/system/platform.h>
4
- #include <util/generic/string.h>
5
-
6
- #include <ctime>
7
-
8
- // timegm and gmtime_r versions that don't need access to filesystem or a big stack
9
- time_t TimeGM(const struct tm* t);
10
- struct tm* GmTimeR(const time_t* timer, struct tm* tmbuf);
11
- // safe version of ctime, convinient version of ctime_r
12
- TString CTimeR(const time_t* timer);
13
-
14
- #ifdef _win_
15
- #include <util/system/winint.h>
16
- #include <winsock2.h>
17
-
18
- void FileTimeToTimeval(const FILETIME* ft, struct timeval* tv);
19
-
20
- // obtains the current time, expressed as seconds and microseconds since 00:00 UTC, January 1, 1970
21
- int gettimeofday(struct timeval* tp, void*);
22
-
23
- // thou should not mix these with non-_r functions
24
- tm* localtime_r(const time_t* clock, tm* result);
25
- tm* gmtime_r(const time_t* clock, tm* result);
26
- char* ctime_r(const time_t* clock, char* buf);
27
-
28
- inline time_t timegm(struct tm* t) {
29
- return TimeGM(t);
30
- }
31
-
32
- char* strptime(const char* buf, const char* fmt, struct tm* tm); // strptime.cpp
33
- #else
34
- #include <sys/time.h>
35
- #endif
36
-
37
- #ifndef timersub
38
- #define timersub(tvp, uvp, vvp) \
39
- do { \
40
- (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
41
- (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
42
- if ((vvp)->tv_usec < 0) { \
43
- (vvp)->tv_sec--; \
44
- (vvp)->tv_usec += 1000000; \
45
- } \
46
- } while (0)
47
- #endif
@@ -1,8 +0,0 @@
1
- #pragma once
2
-
3
- #include "base.h"
4
-
5
- /**
6
- * Returns system uptime
7
- */
8
- TDuration Uptime();
@@ -1,88 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/generic/utility.h>
4
- #include <util/generic/strbuf.h>
5
-
6
- #include <utility>
7
-
8
- // NOTE: These functions provide CityHash 1.0 implementation whose results are *different* from
9
- // the mainline version of CityHash.
10
-
11
- using uint128 = std::pair<ui64, ui64>;
12
-
13
- constexpr ui64 Uint128Low64(const uint128& x) {
14
- return x.first;
15
- }
16
-
17
- constexpr ui64 Uint128High64(const uint128& x) {
18
- return x.second;
19
- }
20
-
21
- // Hash functions for a byte array.
22
- // http://en.wikipedia.org/wiki/CityHash
23
-
24
- Y_PURE_FUNCTION
25
- ui64 CityHash64(const char* buf, size_t len) noexcept;
26
-
27
- Y_PURE_FUNCTION
28
- ui64 CityHash64WithSeed(const char* buf, size_t len, ui64 seed) noexcept;
29
-
30
- Y_PURE_FUNCTION
31
- ui64 CityHash64WithSeeds(const char* buf, size_t len, ui64 seed0, ui64 seed1) noexcept;
32
-
33
- Y_PURE_FUNCTION
34
- uint128 CityHash128(const char* s, size_t len) noexcept;
35
-
36
- Y_PURE_FUNCTION
37
- uint128 CityHash128WithSeed(const char* s, size_t len, uint128 seed) noexcept;
38
-
39
- // Hash 128 input bits down to 64 bits of output.
40
- // This is intended to be a reasonably good hash function.
41
- inline ui64 Hash128to64(const uint128& x) {
42
- // Murmur-inspired hashing.
43
- const ui64 kMul = 0x9ddfea08eb382d69ULL;
44
- ui64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
45
- a ^= (a >> 47);
46
- ui64 b = (Uint128High64(x) ^ a) * kMul;
47
- b ^= (b >> 47);
48
- b *= kMul;
49
- return b;
50
- }
51
-
52
- namespace NPrivateCityHash {
53
- template <class TStringType>
54
- inline TStringBuf GetBufFromStr(const TStringType& str) {
55
- static_assert(std::is_integral<std::remove_reference_t<decltype(*str.data())>>::value, "invalid type passed to hash function");
56
- return TStringBuf(reinterpret_cast<const char*>(str.data()), (str.size()) * sizeof(*str.data()));
57
- }
58
- }
59
-
60
- template <class TStringType>
61
- inline ui64 CityHash64(const TStringType& str) {
62
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
63
- return CityHash64(buf.data(), buf.size());
64
- }
65
-
66
- template <class TStringType>
67
- inline ui64 CityHash64WithSeeds(const TStringType& str, ui64 seed0, ui64 seed1) {
68
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
69
- return CityHash64WithSeeds(buf.data(), buf.size(), seed0, seed1);
70
- }
71
-
72
- template <class TStringType>
73
- inline ui64 CityHash64WithSeed(const TStringType& str, ui64 seed) {
74
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
75
- return CityHash64WithSeed(buf.data(), buf.size(), seed);
76
- }
77
-
78
- template <class TStringType>
79
- inline uint128 CityHash128(const TStringType& str) {
80
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
81
- return CityHash128(buf.data(), buf.size());
82
- }
83
-
84
- template <class TStringType>
85
- inline uint128 CityHash128WithSeed(const TStringType& str, uint128 seed) {
86
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
87
- return CityHash128WithSeed(buf.data(), buf.size(), seed);
88
- }
@@ -1,73 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/system/defaults.h>
4
-
5
- #define FNV32INIT 2166136261U
6
- #define FNV32PRIME 16777619U
7
- #define FNV64INIT ULL(14695981039346656037)
8
- #define FNV64PRIME ULL(1099511628211)
9
-
10
- namespace NFnvPrivate {
11
- template <class It>
12
- constexpr ui32 FnvHash32(It b, It e, ui32 init) {
13
- while (b != e) {
14
- init = (init * FNV32PRIME) ^ (unsigned char)*b++;
15
- }
16
-
17
- return init;
18
- }
19
-
20
- template <class It>
21
- constexpr ui64 FnvHash64(It b, It e, ui64 init) {
22
- while (b != e) {
23
- init = (init * FNV64PRIME) ^ (unsigned char)*b++;
24
- }
25
-
26
- return init;
27
- }
28
-
29
- template <unsigned N>
30
- struct TFnvHelper;
31
-
32
- #define DEF_FNV(t) \
33
- template <> \
34
- struct TFnvHelper<t> { \
35
- static const ui##t Init = FNV##t##INIT; \
36
- template <class It> \
37
- static constexpr ui##t FnvHash(It b, It e, ui##t init) { \
38
- return FnvHash##t(b, e, init); \
39
- } \
40
- };
41
-
42
- DEF_FNV(32)
43
- DEF_FNV(64)
44
-
45
- #undef DEF_FNV
46
- }
47
-
48
- template <class T, class It>
49
- static constexpr T FnvHash(It b, It e, T init) {
50
- static_assert(sizeof(*b) == 1, "expect sizeof(*b) == 1");
51
-
52
- return (T)NFnvPrivate::TFnvHelper<8 * sizeof(T)>::FnvHash(b, e, init);
53
- }
54
-
55
- template <class T, class It>
56
- static constexpr T FnvHash(It b, It e) {
57
- return FnvHash<T>(b, e, (T)NFnvPrivate::TFnvHelper<8 * sizeof(T)>::Init);
58
- }
59
-
60
- template <class T>
61
- static constexpr T FnvHash(const void* buf, size_t len, T init) {
62
- return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + len, init);
63
- }
64
-
65
- template <class T>
66
- static constexpr T FnvHash(const void* buf, size_t len) {
67
- return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + len);
68
- }
69
-
70
- template <class T, class Buf>
71
- static constexpr T FnvHash(const Buf& buf) {
72
- return FnvHash<T>(buf.data(), buf.size() * sizeof(*buf.data()));
73
- }
@@ -1,14 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/str_stl.h>
4
-
5
- #include "numeric.h"
6
-
7
- template <typename TOne>
8
- constexpr size_t MultiHash(const TOne& one) noexcept {
9
- return THash<TOne>()(one);
10
- }
11
- template <typename THead, typename... TTail>
12
- constexpr size_t MultiHash(const THead& head, const TTail&... tail) noexcept {
13
- return CombineHashes(MultiHash(tail...), THash<THead>()(head));
14
- }
@@ -1,57 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/system/defaults.h>
4
- #include <util/generic/array_ref.h>
5
-
6
- /*
7
- * murmur2 from http://murmurhash.googlepages.com/
8
- *
9
- */
10
- namespace NMurmurPrivate {
11
- Y_PURE_FUNCTION
12
- ui32 MurmurHash32(const void* key, size_t len, ui32 seed) noexcept;
13
-
14
- Y_PURE_FUNCTION
15
- ui64 MurmurHash64(const void* key, size_t len, ui64 seed) noexcept;
16
-
17
- template <unsigned N>
18
- struct TMurHelper;
19
-
20
- #define DEF_MUR(t) \
21
- template <> \
22
- struct TMurHelper<t> { \
23
- static inline ui##t MurmurHash(const void* buf, size_t len, ui##t init) noexcept { \
24
- return MurmurHash##t(buf, len, init); \
25
- } \
26
- };
27
-
28
- DEF_MUR(32)
29
- DEF_MUR(64)
30
-
31
- #undef DEF_MUR
32
- }
33
-
34
- template <class T>
35
- static inline T MurmurHash(const void* buf, size_t len, T init) noexcept {
36
- return (T)NMurmurPrivate::TMurHelper<8 * sizeof(T)>::MurmurHash(buf, len, init);
37
- }
38
-
39
- template <class T>
40
- static inline T MurmurHash(const void* buf, size_t len) noexcept {
41
- return MurmurHash<T>(buf, len, (T)0);
42
- }
43
-
44
- //non-inline version
45
- size_t MurmurHashSizeT(const char* buf, size_t len) noexcept;
46
-
47
- template <typename TOut = size_t>
48
- struct TMurmurHash {
49
- TOut operator()(const void* buf, size_t len) const noexcept {
50
- return MurmurHash<TOut>(buf, len);
51
- }
52
-
53
- template <typename ElementType>
54
- TOut operator()(const TArrayRef<ElementType>& data) const noexcept {
55
- return operator()(data.data(), data.size() * sizeof(ElementType));
56
- }
57
- };