Results 1 to 5 of 5

Thread: addBytes problem in C++ client program

  1. #1
    New Member
    Join Date
    Dec 2015
    Posts
    7

    addBytes problem in C++ client program

    Hi,
    Now I'm trying to program a C++ program (modified from HellowWorld.cpp), to invoke default procedure of table ABC:

    CREATE TABLE ABC (
    ID integer NOT NULL,
    VALUE float,
    QUALITY tinyint,
    HIS varbinary(40),
    TIME_STAMP timestamp,
    PRIMARY KEY (ID)
    );

    my code just like below:
    ......
    voltdb::ClientConfig config("","");
    voltdb::Client client = voltdb::Client::create(config);
    client.createConnection("localhost");

    /*
    * Describe the stored procedure to be invoked
    */
    std::vector<voltdb::Parameter> parameterTypes(5);
    parameterTypes[0] = voltdb::Parameter(voltdb::WIRE_TYPE_INTEGER);
    parameterTypes[1] = voltdb::Parameter(voltdb::WIRE_TYPE_FLOAT);
    parameterTypes[2] = voltdb::Parameter(voltdb::WIRE_TYPE_VARBINARY);
    parameterTypes[3] = voltdb::Parameter(voltdb::WIRE_TYPE_TINYINT);
    parameterTypes[4] = voltdb::Parameter(voltdb::WIRE_TYPE_TIMESTAMP);
    voltdb::Procedure procedure("ABC.upsert", parameterTypes);

    voltdb::InvocationResponse response;
    /*
    * Load the database.
    */
    const uint8_t vars[40] = {1,1,1};
    voltdb::ParameterSet* params = procedure.params();
    params->addInt32(202).addDouble(55.55).addBytes(40, vars).addInt8(1).addTimestamp(1415289765);

    response = client.invoke(procedure);
    if (response.failure()) { std::cout << response.toString() << std::endl; return -1; }
    ......

    When execute, error occurred:

    Status: -2, VOLTDB ERROR: PROCEDURE ABC.upsert TYPE ERROR FOR PARAMETER 3: org.voltdb.VoltTypeException: Array / Scalar parameter mismatch (java.lang.Byte to [B)
    App Status: -128,
    Client Data: -9223372036854775610
    Cluster Round Trip Time: 0

    What's wrong with my program, thank you for your help.

  2. #2
    New Member
    Join Date
    Dec 2015
    Posts
    7
    The problem was settled. It's not caused by program, but running environment. I just run the program on another linux system with voltdb deployed then it run well.

  3. #3
    New Member
    Join Date
    Apr 2015
    Posts
    13
    Hi, this is Bill White from VoltDB.

    It turns out that the wire protocol representation of VARBINARY and array of TINYINT are almost exactly identical. The only difference is in the type metadata. ARRAY OF TINYINT uses two bytes, one to tell that the value is an array and one to tell that the element type is TINYINT. VARBINARY uses one byte, with a special VARBINARY value. There is no way in Java to specify VARBINARY or ARRAY OF TINYINT though. There is just byte[] for both. So the Java client doesn't necessarily know the types of the values they are sending given only the value. Sometimes it chooses incorrectly. This is a bug which we are working through right now.

    It's my understanding that both the C++ and Java clients turn array of byte (or array of char) to VARBINARY in the most recent release. So, I think you should be alright if you always use VARBINARY in the parameter type.

  4. #4
    New Member
    Join Date
    Apr 2015
    Posts
    13
    I reread your post and see that you are using VARBINARY already. Try using ARRAY OF TINYINT instead. VARBINARY should work correctly with the release of the C++ client that is in the master branch in github. However, I don't know if that version has been formally released yet. The release engineer is out of the office this week, so I can't ask her.

    Is this a high priority problem?

  5. #5
    New Member
    Join Date
    Dec 2015
    Posts
    7
    Thank you, Bill. Yes it's a hight priority problem but my program is now running well by using VARBINARY, I'll also try your suggestion. I'm not sure why the issue occurred, but after I rebuild the program on another linux environment, the problem disappeared.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •