Skip to content

Commit

Permalink
Intermediate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
robot-piglet committed Apr 22, 2024
1 parent 5506d57 commit d5ea8f9
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"corpus_parts": [
6172475937,
6179377874,
6194160339,
6186642258,
6201626105,
6208401807
6211005253,
6213461710
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"corpus_parts": [
6201641645,
6208364118
6208364118,
6211020087,
6213462973
]
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"corpus_parts": [
6179373922,
6194159388,
6201622973,
6186636558,
6208360859
6213467961
]
}
4 changes: 3 additions & 1 deletion fuzzing/library/cpp/json/fuzzy_test/corpus.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"corpus_parts": [
6211003442,
6201625340,
6208360077
6208360077,
6213460734
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"corpus_parts": [
6208361483
6211002058,
6208361483,
6213461699
]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"corpus_parts": [
6186635968,
6208360449,
6201622793,
6211003386,
6194163390,
6208360449
6213460321
]
}
32 changes: 4 additions & 28 deletions library/cpp/yt/memory/function_view.h
Original file line number Diff line number Diff line change
@@ -1,36 +1,11 @@
#pragma once

#include <concepts>
#include <library/cpp/yt/misc/concepts.h>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

namespace NDetail {

template <class TSignature>
struct TTypeErasureTraits;

template <class TResult, bool NoExcept, class... TArgs>
struct TTypeErasureTraits<TResult(TArgs...) noexcept(NoExcept)>
{
using TSignature = TResult(TArgs...) noexcept(NoExcept);

// TODO(arkady-e1ppa): Support pointer-to-member-function?
template <class T>
static constexpr bool IsInvocable = NoExcept
? requires (T obj, TArgs... args) {
{ obj(std::forward<TArgs>(args)...) } noexcept -> std::same_as<TResult>;
}
: requires (T obj, TArgs... args) {
{ obj(std::forward<TArgs>(args)...) } -> std::same_as<TResult>;
};
};

} // namespace NDetail

////////////////////////////////////////////////////////////////////////////////

// Non-owning type-erasure container.
/*
Example:
Expand Down Expand Up @@ -75,9 +50,10 @@ class TFunctionView;

////////////////////////////////////////////////////////////////////////////////

// TODO(arkady-e1ppa): Support pointer-to-member-function?
template <class T, class TSignature>
concept CTypeErasable =
NDetail::TTypeErasureTraits<TSignature>::template IsInvocable<T> &&
CInvocable<T, TSignature> &&
(!std::same_as<T, TFunctionView<TSignature>>);

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -105,7 +81,7 @@ class TFunctionView<TResult(TArgs...) noexcept(NoExcept)>
bool IsValid() const noexcept;
void Reset() noexcept;

// bool operator==(const TFunctionView& other) const & = default;
bool operator==(const TFunctionView& other) const & = default;

private:
// NB: Technically, this is UB according to C standard, which
Expand Down
49 changes: 49 additions & 0 deletions library/cpp/yt/misc/concepts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once

#include <concepts>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

namespace NDetail {

template <class T, class TSignature>
struct TIsInvocable;

template <class T, class TResult, bool NoExcept, class... TArgs>
struct TIsInvocable<T, TResult(TArgs...) noexcept(NoExcept)>
{
private:
static constexpr bool IsInvocable_ = requires (T&& t, TArgs&&... args) {
{ std::forward<T>(t)(std::forward<TArgs>(args)...) } -> std::same_as<TResult>;
};

static constexpr bool IsNoThrowInvocable_ = requires (T&& t, TArgs&&... args) {
{ std::forward<T>(t)(std::forward<TArgs>(args)...) } noexcept -> std::same_as<TResult>;
};

public:
static constexpr bool Value =
IsInvocable_ &&
(!NoExcept || IsNoThrowInvocable_);
};

} // namespace NDetail

////////////////////////////////////////////////////////////////////////////////

template <class TObject, class TScalar>
concept CScalable = requires (TObject object, TScalar scalar)
{
{ object * scalar } -> std::same_as<TObject>;
};

////////////////////////////////////////////////////////////////////////////////

template <class T, class TSignature>
concept CInvocable = NDetail::TIsInvocable<T, TSignature>::Value;

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT
10 changes: 10 additions & 0 deletions library/python/cityhash/test/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ def test_hash64seed():
assert cityhash.hash64seed('', 0) == 0
assert cityhash.hash64seed('', 117) == 7102524123839304709
assert cityhash.hash64seed('test', 12345) == 14900027982776226655


def test_hash_large_encrypted_files():
path = yc.source_path('devtools/dummy_arcadia/arc_special_files/encrypted/encrypted_files/1mb_file.txt')
try:
cityhash.filehash64(path)
except RuntimeError:
# This is expected to fail on local and in Sandbox but run normally in distbuild
# Replace with 'with raises' once YA-1099 is done
pass

0 comments on commit d5ea8f9

Please sign in to comment.