Skip to content
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
This repository was archived by the owner on Aug 13, 2026. It is now read-only.

Wrong JSON format for IndexMapReduce [JIRA: CLIENTS-413] #520

Description

@urzhumskov

I'm trying to perform a simple mapreduce query with 2.0.0 against Riak 2.0.0 (from Scala):

    val query: IndexMapReduce = (new IndexMapReduce.Builder)
      .withNamespace(new Namespace("type", "Bucket"))
      .withIndex("rawId_bin")
      .withMatchValue(BinaryValue.createFromUtf8("06403f5efcc17e4a"))
      .withReducePhase(RiakFunction.newErlangFunction("riak_kv_mapreduce", "reduce_count_inputs"))
      .build()

This fails with

   {error,function_clause,
   [{riak_index,parse_binary,
                [{struct,[{<<"value">>,<<"06403f5efcc17e4a">>}]}],
                [{file,"src/riak_index.erl"},{line,543}]},
    {riak_index,parse_field,3,[{file,"src/riak_index.erl"},{line,192}]},
    {riak_index,'-parse_fields/1-fun-0-',3,
                [{file,"src/riak_index.erl"},{line,158}]},
    {lists,foldl,3,[{file,"lists.erl"},{line,1248}]},
    {riak_index,parse_fields,1,[{file,"src/riak_index.erl"},{line,167}]},
    {riak_kv_mapred_json,parse_index_input,1,
                         [{file,"src/riak_kv_mapred_json.erl"},
                          {line,231}]},
    {riak_kv_mapred_json,parse_request,1,
                         [{file,"src/riak_kv_mapred_json.erl"},{line,55}]},
    {riak_kv_wm_mapred,verify_body,2,
                       [{file,"src/riak_kv_wm_mapred.erl"},{line,170}]}]}

Apparently, the MatchCriteria part of the request is malformed: Riak expects it to be "key": "06403f5efcc17e4a" but the actual request contains "key": { "value": "06403f5efcc17e4a" }

Activity

  1. changed the title [-]Wrong JSON format for IndexMapReduce[/-] [+]Wrong JSON format for IndexMapReduce [JIRA: CLIENTS-413][/+] on May 25, 2015
  2. gfbett commented on Sep 18, 2015

    @gfbett

    I'm having the same issue here. A bin index with an string value, and after setting the value I'm getting the same error. The input after the serialization is this:

      "inputs": {
        "bucket": "features",
        "index": "project_bin",
        "key": {
          "value": "ZmY1NDQ1MmIyYzQ4NGE3ZTkzMjJiZWQxNDBkZDJkMWY="
        }
      },

    And also the value is base64 encoded, is not the same string I passed to the BinaryValue createFromUtf8 method

    Error I'm getting:

    Error processing incoming message: error:function_clause:[{riak_index,
           parse_binary,
           [{struct,
             [{<<"value">>,
               <<"ZmY1NDQ1MmIyYzQ4NGE3ZTkzMjJiZWQxNDBkZDJkMWY=">>}]}],
           [{file,
             "src/riak_index.erl"},
            {line,535}]},
          {riak_index,
           parse_field,3,
           [{file,
             "src/riak_index.erl"},
            {line,188}]},
          {riak_index,
           '-parse_fields/1-fun-0-',
           3,
           [{file,
             "src/riak_index.erl"},
            {line,155}]},
          {lists,foldl,3,
           [{file,"lists.erl"},
            {line,1248}]},
          {riak_index,
           parse_fields,1,
           [{file,
             "src/riak_index.erl"},
            {line,164}]},
          {riak_kv_mapred_json,
           parse_index_input,
           1,
           [{file,
             "src/riak_kv_mapred_json.erl"},
            {line,231}]},
          {riak_kv_mapred_json,
           parse_request,1,
           [{file,
             "src/riak_kv_mapred_json.erl"},
            {line,55}]},
          {riak_kv_pb_mapred,
           decode,2,
           [{file,
             "src/riak_kv_pb_mapred.erl"},
            {line,70}]}]
    
  3. alexmoore commented on Aug 8, 2016

    @alexmoore
    Contributor

    Looks like Jackson doesn't know how to encode the BianryValue objects. I'll have a fix shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions