Streams Java 8 and Chronicle map

94 views
Skip to first unread message

Siva Sekhar Nalluri

unread,
Jun 22, 2015, 5:15:20 PM6/22/15
to java-ch...@googlegroups.com
Hi,

I am trying to read CSV file and building map out of it. 

sample.csv is something like this

a, a, a
a, ab, ads, dsd
we, sd, sd, sd
sd, sd

my requirement is first element is key and rest of the element is value as list 

below code its working fine but includes first element

ChronicleMap<String, List<String>> cMap = ChronicleMapBuilder.of(String.class,List.class).create()

Stream<String> stream = Files.lines(Paths.get("sample.csv"));
 =(Map<String, List<String>>) 
stream
.filter(s -> !s.trim().isEmpty())
.map(line -> Arrays.asList(line.split(",")))
                                .forEach(a -> cmaps.put(a.get(0), a));



ChronicleMap<String, List<String>> cMap = ChronicleMapBuilder.of(String.class,List.class).create()

Stream<String> stream = Files.lines(Paths.get("sample.csv"));
 =(Map<String, List<String>>) 
stream
.filter(s -> !s.trim().isEmpty())
.map(line -> Arrays.asList(line.split(",")))
                                .forEach(a -> cmaps.put(a.get(0), a.subList(1,a.size())));

above code is giving me the java.lang.IllegalStateException : we try to figure out size of objets in serialized orm, but it exceeds 16777216bytes. we assume this is a error and  at throw exception at this point. if you really want larger keys/values, use ChronicleMapBuilder.KeySize(int)/valueSize(int) configurations


Whats wrong in the above code and how can I get the requirement fulfilled.
any help is appreciated.

Best Regards, 
Siva

Roman Leventov

unread,
Jun 22, 2015, 5:21:35 PM6/22/15
to java-ch...@googlegroups.com

This is because List.subList() you provide as values are not Serializable. I agree the error message is confusing. Write a custom serializer for any List, or wrap as cmap.put(a.get(0), new arrayList(a.sublist(1, a.size())))

--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Siva Sekhar Nalluri

unread,
Jun 22, 2015, 7:49:08 PM6/22/15
to java-ch...@googlegroups.com
Thanks you for the quick response.

--
You received this message because you are subscribed to a topic in the Google Groups "Chronicle" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/java-chronicle/HLg9FnlNEpk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to java-chronicl...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Best regards,
Siva Sekhar Nalluri



Reply all
Reply to author
Forward
0 new messages