2

I have to store data structured as a table in JAVA. Besides the columnnames and data i store different metadata like the data type of the column. At the moment I'm using this object.

public class Data {

    private final Map<String, List<Object>> values;
    private final Map<String, Integer> columnSpec;
    private int rowSize;

    //Getter and Setter

As you can see I save the data columnoriented. Sometimes I have to itterate over data in specific column. Sometimes over specific rows. I'm looking for a structre where i can easily switch from column to row layout (or vice versa).

Which object do you suggest? How can i reach the maximum performance (less iteration to change layout)? The table can have over 1 Million lines in some cases.

1 Answer 1

1

If using a library is not a problem, you can use Guava table structures. Some of the avaliable structures are: TreeBasedTable, HashBasedTable, ImmutableTable and ArrayTable. You can pick the most suitable one.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks guava was exactly what i was looking for. This reduced my code enormously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.