You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Vi...@ril.com on 2018/04/25 10:08:50 UTC

Reading Cassandra's Blob from Apache Ignite

Dear Community,

I'm trying to read the contents of Cassandra table from Ignite(acting as cache). The table is given below::
CREATE TABLE test.epc_table (
    imsi text PRIMARY KEY,
    data blob
)
The data blob is being used to store a C++ class object(Class name is 'RtCassEpcTableDataVo').
I'm trying to use the following c++ program to pass the value of 'imsi' and get the corresponding 'data'.
#include "ignite/ignite.h"
#include "ignite/ignition.h"


#include <iostream>
#include<string>

#include "RtCassEpcTableDataVo.hpp"

using namespace ignite;
using namespace cache;
using namespace std;

int main()
{
        IgniteConfiguration cfg;

        cfg.springCfgPath = "/home/ignite/apache-ignite-fabric-2.4.0-bin/config/cassandra-config.xml";

        try
        {
                // Start a node.
                Ignite ignite = Ignition::Start(cfg);
Cache<string,RtCassEpcTableDataVo> cache = ignite.GetCache<std::string, RtCassEpcTableDataVo>("cache1");

cout<<endl<<"Enter IMSI : ";
string l_imsi;
getline(cin>>ws,l_imsi);

RtCassEpcTableDataVo l_blob=cache.Get(l_imsi);
                Ignition::StopAll(false);
        }
        catch (IgniteError& err)
        {
                std::cout << "An error occurred: " << err.GetText() << std::endl;

                return err.GetCode();
        }

        std::cout << std::endl;

        return 0;
}
However, I'm getting compilation errors.
In file included from /usr/local/include/ignite/impl/binary/binary_writer_impl.h:32:0,
                 from /usr/local/include/ignite/binary/binary_raw_writer.h:30,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/cache/query/query_scan.h:29,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h:21,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/impl/ignite_impl.h:27,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/ignite.h:26,
                 from sample.cpp:1:
/usr/local/include/ignite/impl/binary/binary_utils.h: In instantiation of âstatic T ignite::impl::binary::BinaryUtils::GetDefaultValue() [with T = RtCassEpcTableDataVo]â:
/home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/impl/operations.h:349:62:   required from âvoid ignite::impl::Out1Operation<T>::SetNull() [with T = RtCassEpcTableDataVo]â
sample.cpp:72:1:   required from here
/usr/local/include/ignite/impl/binary/binary_utils.h:475:59: error: âGetNullâ is not a member of âignite::binary::BinaryType<RtCassEpcTableDataVo>â
                     ignite::binary::BinaryType<T>::GetNull(res);
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/local/include/ignite/impl/binary/binary_object_impl.h:31:0,
                 from /usr/local/include/ignite/impl/binary/binary_writer_impl.h:35,
                 from /usr/local/include/ignite/binary/binary_raw_writer.h:30,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/cache/query/query_scan.h:29,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h:21,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/impl/ignite_impl.h:27,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/ignite.h:26,
                 from sample.cpp:1:
/usr/local/include/ignite/impl/binary/binary_reader_impl.h: In instantiation of âvoid ignite::impl::binary::BinaryReaderImpl::ReadTopObject0(T&) [with T = RtCassEpcTableDataVo]â:
/usr/local/include/ignite/impl/binary/binary_type_impl.h:100:17:   required from âstatic T ignite::binary::ReadHelper<T>::Read(R&) [with R = ignite::impl::binary::BinaryReaderImpl; T = RtCassEpcTableDataVo]â
/usr/local/include/ignite/impl/binary/binary_reader_impl.h:887:63:   required from âT ignite::impl::binary::BinaryReaderImpl::ReadTopObject() [with T = RtCassEpcTableDataVo]â
/home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/impl/operations.h:344:21:   required from âvoid ignite::impl::Out1Operation<T>::ProcessOutput(ignite::impl::binary::BinaryReaderImpl&) [with T = RtCassEpcTableDataVo]â
sample.cpp:72:1:   required from here
/usr/local/include/ignite/impl/binary/binary_reader_impl.h:1001:40: error: âReadâ is not a member of âBType {aka ignite::binary::BinaryType<RtCassEpcTableDataVo>}â
                             BType::Read(reader, res);
                             ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/local/include/ignite/impl/binary/binary_reader_impl.h: In instantiation of âT ignite::impl::binary::BinaryReaderImpl::GetNull() const [with T = RtCassEpcTableDataVo]â:
/usr/local/include/ignite/impl/binary/binary_reader_impl.h:905:45:   required from âvoid ignite::impl::binary::BinaryReaderImpl::ReadTopObject0(T&) [with T = RtCassEpcTableDataVo]â
/usr/local/include/ignite/impl/binary/binary_type_impl.h:100:17:   required from âstatic T ignite::binary::ReadHelper<T>::Read(R&) [with R = ignite::impl::binary::BinaryReaderImpl; T = RtCassEpcTableDataVo]â
/usr/local/include/ignite/impl/binary/binary_reader_impl.h:887:63:   required from âT ignite::impl::binary::BinaryReaderImpl::ReadTopObject() [with T = RtCassEpcTableDataVo]â
/home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/impl/operations.h:344:21:   required from âvoid ignite::impl::Out1Operation<T>::ProcessOutput(ignite::impl::binary::BinaryReaderImpl&) [with T = RtCassEpcTableDataVo]â
sample.cpp:72:1:   required from here
/usr/local/include/ignite/impl/binary/binary_reader_impl.h:1024:59: error: âGetNullâ is not a member of âignite::binary::BinaryType<RtCassEpcTableDataVo>â
                     ignite::binary::BinaryType<T>::GetNull(res);
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/local/include/ignite/impl/binary/binary_writer_impl.h:30:0,
                 from /usr/local/include/ignite/binary/binary_raw_writer.h:30,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/cache/query/query_scan.h:29,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h:21,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/impl/ignite_impl.h:27,
                 from /home/ignite/apache-ignite-fabric-2.4.0-bin/platforms/cpp/core/include/ignite/ignite.h:26,
                 from sample.cpp:1:
/usr/local/include/ignite/impl/binary/binary_id_resolver.h: In instantiation of âint32_t ignite::impl::binary::TemplatedBinaryIdResolver<T>::GetTypeId() [with T = RtCassEpcTableDataVo; int32_t = int]â:
sample.cpp:72:1:   required from here
/usr/local/include/ignite/impl/binary/binary_id_resolver.h:88:68: error: âGetTypeIdâ is not a member of âignite::binary::BinaryType<RtCassEpcTableDataVo>â
                     return ignite::binary::BinaryType<T>::GetTypeId();
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/local/include/ignite/impl/binary/binary_id_resolver.h: In instantiation of âint32_t ignite::impl::binary::TemplatedBinaryIdResolver<T>::GetFieldId(int32_t, const char*) [with T = RtCassEpcTableDataVo; int32_t = int]â:
sample.cpp:72:1:   required from here
/usr/local/include/ignite/impl/binary/binary_id_resolver.h:94:73: error: âGetFieldIdâ is not a member of âignite::binary::BinaryType<RtCassEpcTableDataVo>â
                         return ignite::binary::BinaryType<T>::GetFieldId(name);
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
The persistance-settings.xml is as follows:
<persistence keyspace="test" table="epc_table">
    <keyPersistence class="java.lang.String" strategy="PRIMITIVE" column="imsi"/>
    <valuePersistence column="data" />
</persistence>
I don't understand why this same program works(with some minor changes in the cpp as well as the persistence-setting.xml), when used on some other table i.e.
CREATE TABLE test.table2 (
    imsi text PRIMARY KEY,
    data int
)

Please help.

Stack overflow link: https://stackoverflow.com/q/50019277/5701173

Thanks and regards,
Vishal Sharma
"Confidentiality Warning: This message and any attachments are intended only for the use of the intended recipient(s). 
are confidential and may be privileged. If you are not the intended recipient. you are hereby notified that any 
review. re-transmission. conversion to hard copy. copying. circulation or other use of this message and any attachments is 
strictly prohibited. If you are not the intended recipient. please notify the sender immediately by return email. 
and delete this message and any attachments from your system.

Virus Warning: Although the company has taken reasonable precautions to ensure no viruses are present in this email. 
The company cannot accept responsibility for any loss or damage arising from the use of this email or attachment."

Re: Reading Cassandra's Blob from Apache Ignite

Posted by Jonathan Haddad <jo...@jonhaddad.com>.
I think you’ll have better luck with the ignite list, as this looks like an
ignite configuration problem.
On Wed, Apr 25, 2018 at 3:09 AM <Vi...@ril.com> wrote:

> Dear Community,
>
>
>
> I'm trying to read the contents of Cassandra table from Ignite(acting as
> cache). The table is given below::
>
> CREATE TABLE test.epc_table (
>
>     imsi text PRIMARY KEY,
>
>     data blob
>
> )
>
> The data blob is being used to store a C++ class object(Class name is
> 'RtCassEpcTableDataVo').
>
> I'm trying to use the following c++ program to pass the value of 'imsi'
> and get the corresponding 'data'.
>
> #include "ignite/ignite.h"
>
> #include "ignite/ignition.h"
>
>
>
>
>
> #include <iostream>
>
> #include<string>
>
>
>
> #include "RtCassEpcTableDataVo.hpp"
>
>
>
> using namespace ignite;
>
> using namespace cache;
>
> using namespace std;
>
>
>
> int main()
>
> {
>
>         IgniteConfiguration cfg;
>
>
>
>         cfg.springCfgPath =
> "/home/ignite/apache-ignite-fabric-2.4.0-bin/config/cassandra-config.xml";
>
>
>
>         try
>
>         {
>
>                 // Start a node.
>
>                 Ignite ignite = Ignition::Start(cfg);
>
> Cache<string,RtCassEpcTableDataVo> cache = ignite.GetCache<std::string,
> RtCassEpcTableDataVo>("cache1");
>
>
>
> cout<<endl<<"Enter IMSI : ";
>
> string l_imsi;
>
> getline(cin>>ws,l_imsi);
>
>
>
> RtCassEpcTableDataVo l_blob=cache.Get(l_imsi);
>
>                 Ignition::StopAll(false);
>
>         }
>
>         catch (IgniteError& err)
>
>         {
>
>                 std::cout << "An error occurred: " << err.GetText() <<
> std::endl;
>
>
>
>                 return err.GetCode();
>
>         }
>
>
>
>         std::cout << std::endl;
>
>
>
>         return 0;
>
> }
>
> However, I'm getting compilation errors.
>
> In file included from
> /usr/local/include/ignite/impl/binary/binary_writer_impl.h:32:0,
>
>                  from /usr/local/include/ignite/binary/binary_raw_writer.h:
> 30,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/cache/query/query_scan.h:29,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h:21,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/impl/ignite_impl.h:27,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/ignite.h:26,
>
>                  from sample.cpp:1:
>
> /usr/local/include/ignite/impl/binary/binary_utils.h: In instantiation of
> âstatic T ignite::impl::binary::BinaryUtils::GetDefaultValue() [with T =
> RtCassEpcTableDataVo]â:
>
> /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/impl/operations.h:349:62:
> required from âvoid ignite::impl::Out1Operation<T>::SetNull() [with T =
> RtCassEpcTableDataVo]â
>
> sample.cpp:72:1:   required from here
>
> /usr/local/include/ignite/impl/binary/binary_utils.h:475:59: error: â
> GetNullâ is not a member of âignite::binary::BinaryType<
> RtCassEpcTableDataVo>â
>
>                      ignite::binary::BinaryType<T>::GetNull(res);
>
>                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
>
> In file included from
> /usr/local/include/ignite/impl/binary/binary_object_impl.h:31:0,
>
>                  from
> /usr/local/include/ignite/impl/binary/binary_writer_impl.h:35,
>
>                  from /usr/local/include/ignite/binary/binary_raw_writer.h:
> 30,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/cache/query/query_scan.h:29,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h:21,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/impl/ignite_impl.h:27,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/ignite.h:26,
>
>                  from sample.cpp:1:
>
> /usr/local/include/ignite/impl/binary/binary_reader_impl.h: In
> instantiation of âvoid ignite::impl::binary::BinaryReaderImpl::
> ReadTopObject0(T&) [with T = RtCassEpcTableDataVo]â:
>
> /usr/local/include/ignite/impl/binary/binary_type_impl.h:100:17:
> required from âstatic T ignite::binary::ReadHelper<T>::Read(R&) [with R =
> ignite::impl::binary::BinaryReaderImpl; T = RtCassEpcTableDataVo]â
>
> /usr/local/include/ignite/impl/binary/binary_reader_impl.h:887:63:
> required from âT ignite::impl::binary::BinaryReaderImpl::ReadTopObject()
> [with T = RtCassEpcTableDataVo]â
>
> /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/impl/operations.h:344:21:
> required from âvoid ignite::impl::Out1Operation<T>::ProcessOutput
> (ignite::impl::binary::BinaryReaderImpl&) [with T = RtCassEpcTableDataVo]â
>
> sample.cpp:72:1:   required from here
>
> /usr/local/include/ignite/impl/binary/binary_reader_impl.h:1001:40:
> error: âReadâ is not a member of âBType {aka ignite::binary::BinaryType<
> RtCassEpcTableDataVo>}â
>
>                              BType::Read(reader, res);
>
>                              ~~~~~~~~~~~^~~~~~~~~~~~~
>
> /usr/local/include/ignite/impl/binary/binary_reader_impl.h: In
> instantiation of âT ignite::impl::binary::BinaryReaderImpl::GetNull()
> const [with T = RtCassEpcTableDataVo]â:
>
> /usr/local/include/ignite/impl/binary/binary_reader_impl.h:905:45:
> required from âvoid ignite::impl::binary::BinaryReaderImpl::ReadTopObject0(T&)
> [with T = RtCassEpcTableDataVo]â
>
> /usr/local/include/ignite/impl/binary/binary_type_impl.h:100:17:
> required from âstatic T ignite::binary::ReadHelper<T>::Read(R&) [with R =
> ignite::impl::binary::BinaryReaderImpl; T = RtCassEpcTableDataVo]â
>
> /usr/local/include/ignite/impl/binary/binary_reader_impl.h:887:63:
> required from âT ignite::impl::binary::BinaryReaderImpl::ReadTopObject()
> [with T = RtCassEpcTableDataVo]â
>
> /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/impl/operations.h:344:21:
> required from âvoid ignite::impl::Out1Operation<T>::ProcessOutput
> (ignite::impl::binary::BinaryReaderImpl&) [with T = RtCassEpcTableDataVo]â
>
> sample.cpp:72:1:   required from here
>
> /usr/local/include/ignite/impl/binary/binary_reader_impl.h:1024:59:
> error: âGetNullâ is not a member of âignite::binary::BinaryType<
> RtCassEpcTableDataVo>â
>
>                      ignite::binary::BinaryType<T>::GetNull(res);
>
>                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
>
> In file included from
> /usr/local/include/ignite/impl/binary/binary_writer_impl.h:30:0,
>
>                  from /usr/local/include/ignite/binary/binary_raw_writer.h:
> 30,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/cache/query/query_scan.h:29,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h:21,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/impl/ignite_impl.h:27,
>
>                  from /home/ignite/apache-ignite-fabric-2.4.0
> -bin/platforms/cpp/core/include/ignite/ignite.h:26,
>
>                  from sample.cpp:1:
>
> /usr/local/include/ignite/impl/binary/binary_id_resolver.h: In
> instantiation of âint32_t ignite::impl::binary::TemplatedBinaryIdResolver
> <T>::GetTypeId() [with T = RtCassEpcTableDataVo; int32_t = int]â:
>
> sample.cpp:72:1:   required from here
>
> /usr/local/include/ignite/impl/binary/binary_id_resolver.h:88:68: error: â
> GetTypeIdâ is not a member of âignite::binary::BinaryType<
> RtCassEpcTableDataVo>â
>
>                      return ignite::binary::BinaryType<T>::GetTypeId();
>
>                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
>
> /usr/local/include/ignite/impl/binary/binary_id_resolver.h: In
> instantiation of âint32_t ignite::impl::binary::TemplatedBinaryIdResolver
> <T>::GetFieldId(int32_t, const char*) [with T = RtCassEpcTableDataVo;
> int32_t = int]â:
>
> sample.cpp:72:1:   required from here
>
> /usr/local/include/ignite/impl/binary/binary_id_resolver.h:94:73: error: â
> GetFieldIdâ is not a member of âignite::binary::BinaryType<
> RtCassEpcTableDataVo>â
>
>                          return ignite::binary::BinaryType<T>::GetFieldId
> (name);
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
>
> The persistance-settings.xml is as follows:
>
> <persistence keyspace="test" table="epc_table">
>
>     <keyPersistence class="java.lang.String" strategy="PRIMITIVE" column=
> "imsi"/>
>
>     <valuePersistence column="data" />
>
> </persistence>
>
>