Thread View: pl.comp.lang.c
5 messages
5 total messages
Started by Borneq
Wed, 20 Jun 2018 23:21
futures, wielokrotne templaty, lambdy i standard c++17
Author: Borneq
Date: Wed, 20 Jun 2018 23:21
Date: Wed, 20 Jun 2018 23:21
115 lines
6067 bytes
6067 bytes
Potrzebuję do zarządzania bazą HBase z kodu C++ skompilować klienta
natywnego c++. To są bardzo stare źródła, od lat nie modyfikowane,
korzystają z facebookowych bibliotek (dla Ubuntu) folly i wangle.
Kiedyś udało się i nawet działa HBase 1.3.1
Teraz chcę uruchomić HBase 2.0.0
Biblioteki folly i wangle stały się nowe.
Natywny klient HBase znajduje się na github w źródłach Apache Hbase w
gałęzi HBASE-14850.
Jest problem kompilacji:
```
template <typename F, typename R = futures::detail::callableResult<T, F>>
typename R::Return then(F&& func) {
return this->template thenImplementation<F, R>(
std::forward<F>(func), typename R::Arg());
}
```
plik /usr/local/include/folly/futures/Future.h
to odwołuje się do folly:
```
// mimic: std::invoke_result_t, C++17
template <typename F, typename... Args>
using invoke_result_t = typename invoke_result<F, Args...>::type;
```
plik /usr/local/include/folly/functional/Invoke.h
aż do mojego projektu ze źródłami klienta:
```
GetRegionLocations(actions, locate_timeout_ns)
.then([=](std::vector<Try<std::shared_ptr<RegionLocation>>> &loc) {
std::lock_guard<std::recursive_mutex> lck(multi_mutex_);
ActionsByServer actions_by_server;
std::vector<std::shared_ptr<Action>> locate_failed;
```
plik
/home/andrzej/projects/simple-hbase2/src/hbase/client/async-batch-rpc-retrying-caller.cc
włączyłem -std=gnu++17
Jest błąd i uwagi:
====================================================
/home/andrzej/projects/simple-hbase2/src/hbase/client/async-batch-rpc-retrying-caller.cc|259|error:
no matching function for call to
‘folly::Future<std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation>
> > >::then(hbase::AsyncBatchRpcRetryingCaller<REQ,
RESP>::GroupAndSend(const std::vector<std::shared_ptr<hbase::Action> >&,
int32_t) [with REQ = std::shared_ptr<hbase::Row>; RESP =
std::shared_ptr<hbase::Result>; int32_t =
int]::<lambda(std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation>
> >&)>)’|
/usr/local/include/folly/futures/Future.h|737|note: candidate:
template<class F, class R> typename R::Return
folly::Future<T>::then(F&&) [with F = F; R = R; T =
std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation> > >]|
/usr/local/include/folly/futures/Future.h|737|note: substitution of
deduced template arguments resulted in errors seen above|
/usr/local/include/folly/futures/Future.h|753|note: candidate:
template<class R, class Caller, class ... Args> folly::Future<typename
folly::isFuture<F>::Inner> folly::Future<T>::then(R (Caller::*)(Args
...), Caller*) [with R = R; Caller = Caller; Args = {Args ...}; T =
std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation> > >]|
/usr/local/include/folly/futures/Future.h|753|note: template argument
deduction/substitution failed:|
/home/andrzej/projects/simple-hbase2/src/hbase/client/async-batch-rpc-retrying-caller.cc|259|note:
mismatched types ‘R (Caller::*)(Args ...)’ and
‘hbase::AsyncBatchRpcRetryingCaller<REQ, RESP>::GroupAndSend(const
std::vector<std::shared_ptr<hbase::Action> >&, int32_t) [with REQ =
std::shared_ptr<hbase::Row>; RESP = std::shared_ptr<hbase::Result>;
int32_t =
int]::<lambda(std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation>
> >&)>’|
/usr/local/include/folly/futures/Future.h|770|note: candidate:
template<class Executor, class Arg, class ... Args> auto
folly::Future<T>::then(Executor*, Arg&&, Args&& ...) [with Executor =
Executor; Arg = Arg; Args = {Args ...}; T =
std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation> > >]|
/usr/local/include/folly/futures/Future.h|770|note: template argument
deduction/substitution failed:|
/home/andrzej/projects/simple-hbase2/src/hbase/client/async-batch-rpc-retrying-caller.cc|259|note:
mismatched types ‘Executor*’ and
‘hbase::AsyncBatchRpcRetryingCaller<REQ, RESP>::GroupAndSend(const
std::vector<std::shared_ptr<hbase::Action> >&, int32_t) [with REQ =
std::shared_ptr<hbase::Row>; RESP = std::shared_ptr<hbase::Result>;
int32_t =
int]::<lambda(std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation>
> >&)>’|
/usr/local/include/folly/futures/Future-inl.h|975|note: candidate:
folly::Future<folly::Unit> folly::Future<T>::then() [with T =
std::vector<folly::Try<std::shared_ptr<hbase::RegionLocation> > >]|
/usr/local/include/folly/futures/Future-inl.h|975|note: candidate
expects 0 arguments, 1 provided|
====================================================
Tutaj w pliku async-batch-rpc-retrying-caller.cc brakuje mu odpowiedniej
wersji "then", mimo że w folly jest wiele.
Ale jak to zmienić nie w folly ale w kliencie
Czy nowa wersja gcc c++17 ma obługę futures, która nie potrzebuje tej z
folly, włączone są pewne rzeczy do może eksperymentalnej biblioteki
standardowej?
Nowy gcc-6 i g++-6 ma jakieś rzeczy w swojej bibliotece standardowej,
tak że nie kompiluje się z folly bo jest konflikt,
może to jest rozwiązanie - przejść na testowy , eksperymentalny gcc i
wyrzucić niektóre headery od folly?
Re: futures, wielokrotne templaty, lambdy i standard c++17
Author: Borneq
Date: Thu, 21 Jun 2018 14:30
Date: Thu, 21 Jun 2018 14:30
37 lines
2416 bytes
2416 bytes
Myślę że problem może polegać na tym że mamy szablon, a tam dwa typy od
których zależy. Realizacja tego szablonu wymaga dedukcji dwóch typów.
Jeden można wydedukować z typu wyniku, a drugi - właśnie jak?
GetRegionLocations(actions, locate_timeout_ns)
.then([=](std::vector<Try<std::shared_ptr<RegionLocation>>> &loc) {
std::lock_guard<std::recursive_mutex> lck(multi_mutex_);
ActionsByServer actions_by_server;
std::vector<std::shared_ptr<Action>> locate_failed;
Metoda GetRegionLocations zwraca AsyncBatchRpcRetryingCaller<REQ, RESP>
mamy dwa argumenty do instantiacji (realizacji) szablonu:
argumenty to REQ i RESP
RESP jest zdefiniowane w Call() AsyncBatchRpcRetryingCaller'a
folly::Future<std::vector<folly::Try<RESP>>> Call();
we have std::vector<Try<std::shared_ptr<RegionLocation>>> jako parametr
Ale parametr REQ zdefiniowany jest dla konstruktora
AsyncBatchRpcRetryingCaller'a
REQ nie jest znane przy wyniku
musi być chyba std::vector<std::shared_ptr<Action>>
Metoda GetRegionLocations nie jest szablonem , ma ten typ REQ na stałe.
Jak powiedzieć kompilatorowi że typ REQ musi być
std::vector<std::shared_ptr<Action>>
?
Czy jest możliwe wskazanie explicite w kodzie?
Być może zamieniając GetRegionLocations ma szablon?
Ale jak w
GetRegionLocations(actions, locate_timeout_ns)
.then([=](std::vector<Try<std::shared_ptr<RegionLocation>>>
Wskazać REQ=std::vector<std::shared_ptr<Action>> ?
Re: futures, wielokrotne templaty, lambdy i standard c++17
Author: Borneq
Date: Thu, 21 Jun 2018 15:48
Date: Thu, 21 Jun 2018 15:48
29 lines
1862 bytes
1862 bytes
Zobaczyłem czym się różnią wersje folly:
/usr/local/include/folly/futures/Future.h
na starej wersji:
template <typename F, typename R = futures::detail::callableResult<T, F>>
typename R::Return then(F&& func) {
return thenImplementation<F, R>(std::forward<F>(func), typename
R::Arg());
}
i nowa :
template <typename F, typename R = futures::detail::callableResult<T, F>>
typename R::Return then(F&& func) {
return this->template thenImplementation<F, R>(
std::forward<F>(func), typename R::Arg());
}
co oznacza "this->template" dla kodu, który używa tego szablonu?
nowe folly używa również:
/usr/local/include/folly/functional/Invoke.h
or /usr/include/c++/8/type_traits
/// std::invoke_result_t
template<typename _Fn, typename... _Args>
using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
Na czym mają polegać zmiany w kodzie?
Re: futures, wielokrotne templaty, lambdy i standard c++17
Author: bartekltg
Date: Thu, 21 Jun 2018 16:02
Date: Thu, 21 Jun 2018 16:02
39 lines
2214 bytes
2214 bytes
On 21.06.2018 17:48, Borneq wrote:
> Zobaczyłem czym się różnią wersje folly:
>
> /usr/local/include/folly/futures/Future.h
> na starej wersji:
>
> template <typename F, typename R = futures::detail::callableResult<T, F>>
> typename R::Return then(F&& func) {
> return thenImplementation<F, R>(std::forward<F>(func), typename
> R::Arg());
> }
>
> i nowa :
>
> template <typename F, typename R = futures::detail::callableResult<T,
> F>>
> typename R::Return then(F&& func) {
> return this->template thenImplementation<F, R>(
> std::forward<F>(func), typename R::Arg());
> }
>
> co oznacza "this->template" dla kodu, który używa tego szablonu?
>
> nowe folly używa również:
> /usr/local/include/folly/functional/Invoke.h
> or /usr/include/c++/8/type_traits
> /// std::invoke_result_t
> template<typename _Fn, typename... _Args>
> using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
>
> Na czym mają polegać zmiany w kodzie?
Jesteś pewien, że kod biblioteki jest zły? To dość duża i popularna
biblioteka, ludzie ją kompilują i działa;)
Spróbuj skompilować w c++14 w wersji koszernej i gnu.
pzdr
bartekltg
Re: futures, wielokrotne templaty, lambdy i standard c++17
Author: Borneq
Date: Thu, 21 Jun 2018 16:11
Date: Thu, 21 Jun 2018 16:11
9 lines
1521 bytes
1521 bytes
W dniu 21.06.2018 o 18:02, bartekltg pisze: > Jesteś pewien, że kod biblioteki jest zły? To dość duża i popularna > biblioteka, ludzie ją kompilują i działa;) Nie, biblioteka jest dobra, tylko po roku mamy nową wersję. Z tamtą starą bilioteką dział stary kod natywnego klienta HBase. Ten natywny klient HBase pozostał stary, i teraz chcę zmodyfikować te rzeczy, które powinienem w związku z nową biblioteką folly. Folly i wangle zainstalowałem, było ok, teraz jak je użyć z klientem HBase?
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads