Search code examples
javaaccumulo

Get Accumulo column family from api?


Learning Accumulo at the moment and I noticed there wasn't a direct call that I found for figuring out the column family for an entry. I need data from an Accumulo table in the format of

for example:

{key:"XPZ-878-S12",
    columns:[{name:"NAME",value:"FOO BAR"},
             {name:"JOB",value:"ENGINEER"}
            ]
}

And these spots are where I am trying to take data from:

{key:"key value from table",
    columns:[{name:"name of column family",value:"value from table"},
             {name:"name of column family",value:"value from table"}
            ]
}

So obviously key and value are easy to get ahold of, but what I call the "name" is extremely important to me as well, aka the column family name.


Solution

  • Yes it is possible. For example take a look at this:

    for (Entry<Key, Value> entry : scan) {
        Text key = entry.getKey().getRow();
        Value val = entry.getValue();
        returnVal.append("KEY" + key + " " + entry.getKey().getColumnFamily() + ": " + val + "\n");
    }
    

    The solution being for whatever entry you are looking at do entry.getKey().getColumnFamily()