Table class, addColumn() has a CATEGORY type. What is that?

The description of the type parameters indicates "int: the type to be used for the new column: INT, LONG, FLOAT, DOUBLE, STRING, or CATEGORY".

What is the CATEGORY type please? How is it used? I've been googling my brains out to trying and find the answers to these question -- and I have looked at the source code for and I still cannot reverse engineer it well enough to understand what it is. (The author clearly doesn't like HashTables -- there's a class called HashTablesBlow! :) )

Thanks in advance for anyone who can explain it! Andy




    If no type is specified, the default type of STRING is used.

  • edited November 2016

    You're absolutely correct, Chrisir. It was that web page that triggered my question. If no type is specified it defaults to STRING. But what type is used if you specify Table.CATEGORY? That's the mystery -- am I missing something very basic here? :)


  • Ha! Well, that makes me feel a little more comfortable that it's not just me! Andy.

  • edited November 2016

    @ajohnsonlaird --

    So you already looked at the Javadoc for addColumn:

    public void addColumn(String title, int type)

    type - the type to be used for the new column: INT, LONG, FLOAT, DOUBLE, STRING, or CATEGORY

    ...and you looked at the source code for Did you check out around Line 2032 and around Line 2341?

    A category is a special int, backed by an enhanced (ahem) HashMap for lookups. While adding things to a category column, they are indexed columnCategories.col[i].

    At least, that's what I see without playing around with it. You should try it in a sketch! (or use BLAME and ask the author who hates hashmaps what it all does).

  • Thanks, Jeremy. I did see the code at those lines and was left puzzled, I'm afraid. I can see what it is doing but could not figure out why -- I certainly tried to use CATEGORY in a sketch but could not get it compile cleanly. Even though I've been a systems programmer for decades, I'm still relatively new to Processing so it's probably PEBKAC on my part. Unfortunately I have yet to get to grips with GIT and BLAME. So, for the time being, I'll find another way and file this under Mysteries That Are Likely Major Time Sinks! :)


  • Misleading CATEGORY argument reported and resolved in Issue 501.

Sign In or Register to comment.