Skip to content

Commit

Permalink
fbcode/cachelib/
Browse files Browse the repository at this point in the history
Reviewed By: therealgymmy

Differential Revision: D44835388

fbshipit-source-id: c4f2fd0327d088de120fa4429846d3f39c485421
  • Loading branch information
generatedunixname226714639793621 authored and facebook-github-bot committed Apr 15, 2023
1 parent 1c1b638 commit eee2913
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
5 changes: 4 additions & 1 deletion cachelib/benchmarks/DataTypeBench.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

namespace cpp2 facebook.cachelib.datatypebench

include "thrift/annotation/cpp.thrift"

struct StdMap {
1: required map<i32, string> m;
}

struct StdUnorderedMap {
1: required map<i32, string> (cpp.template = "std::unordered_map") m;
@cpp.Type{template = "std::unordered_map"}
1: required map<i32, string> m;
}
38 changes: 17 additions & 21 deletions cachelib/experimental/objcache/tests/ThriftCustomAllocator.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ namespace cpp2 facebook.cachelib.objcache

cpp_include "cachelib/experimental/objcache/tests/Common.h"

include "thrift/annotation/cpp.thrift"

struct UseSimpleCustomAllocator {
// map<string, string>
// We want to use custom allocator for it

// A template type like map needs to use "cpp.template" to specify a replacement template
@cpp.Type{template = "facebook::cachelib::objcache::test::TestMap"}
1: map<
string_cpptype_facebookcachelibobjcachetestTestString_cppuse_allocator_1_607,
string_cpptype_facebookcachelibobjcachetestTestString_cppuse_allocator_1_607
> (
cpp.use_allocator,
cpp.template = "facebook::cachelib::objcache::test::TestMap",
) m;
> (cpp.use_allocator) m;

// Native types or types that do not allocate memory do NOT need custom allocator
2: i32 m2;
Expand All @@ -46,17 +46,13 @@ struct UseSimpleCustomAllocator {
// } (cpp.allocator="facebook::cachelib::objcache::test::ScopedTestAllocator")

union UnionWithCustomAllocator {
@cpp.Type{template = "facebook::cachelib::objcache::test::TestMap"}
1: map<
i32,
string_cpptype_facebookcachelibobjcachetestTestString_cppuse_allocator_1_607
> (
cpp.use_allocator,
cpp.template = "facebook::cachelib::objcache::test::TestMap",
) m1;
2: string (
cpp.use_allocator,
cpp.type = "facebook::cachelib::objcache::test::TestString",
) m2;
> (cpp.use_allocator) m1;
@cpp.Type{name = "facebook::cachelib::objcache::test::TestString"}
2: string (cpp.use_allocator) m2;
3: i32 m3;
} (cpp.allocator = "facebook::cachelib::objcache::test::ScopedTestAllocator")
// TODO: even though thrift union does not support allocator. We still need to
Expand Down Expand Up @@ -87,20 +83,20 @@ union UnionWithCustomAllocator {
// }

struct UseTwoF14Maps {
1: map<i32, i32> (
cpp.use_allocator,
cpp.template = "facebook::cachelib::objcache::test::TestFollyF14FastMap",
) m1;
2: map<i32, double> (
cpp.use_allocator,
cpp.template = "facebook::cachelib::objcache::test::TestFollyF14FastMap",
) m2;
@cpp.Type{
template = "facebook::cachelib::objcache::test::TestFollyF14FastMap",
}
1: map<i32, i32> (cpp.use_allocator) m1;
@cpp.Type{
template = "facebook::cachelib::objcache::test::TestFollyF14FastMap",
}
2: map<i32, double> (cpp.use_allocator) m2;
} (
cpp.allocator = "facebook::cachelib::objcache::test::TestF14TemplateAllocator<std::pair<const int32_t, int32_t>>",
)

// The following were automatically generated and may benefit from renaming.
@cpp.Type{name = "facebook::cachelib::objcache::test::TestString"}
typedef string (
cpp.type = 'facebook::cachelib::objcache::test::TestString',
cpp.use_allocator = '1',
) string_cpptype_facebookcachelibobjcachetestTestString_cppuse_allocator_1_607

0 comments on commit eee2913

Please sign in to comment.