java - Astyanax's EntityPersister & Collection Updates -
background
astyanax's entity persister saves map of entity in multiple columns. format mapvariable.key
the problem:
the astyanax's entity persister doesn't remove deleted key/value pairs cassandra when map in entity has been updated
the solution i'm using (bad approach)
i'm deleting whole row, , reinsert it
some more info
i persist java objects in cassandra using astyanax's entity persister (com.netflix.astyanax.entitystore).
what i've noticed when entity's map persisted with, say, 2 values: testkey:testvalue & testkey2:testvalue2, , next time same entity's map persisted 1 value (one key/value pair removed): testkey:testvalue, testkey2:testvalue2 isn't deleted column family.
so, work-around, need delete whole row , reinsert it.
my insertion code:
final entitymanager<t, string> entitymanager = new defaultentitymanager.builder<t, string>() .withentitytype(clazz) .withkeyspace(getkeyspace()) .withcolumnfamily(columnfamily) .build(); entitymanager.put(entity);
what missing? inefficient , think astyanax's entity persister supposed take care of on own.
any thoughts?
you not missing anything.
what happens following: 1. astyanax creates list of columnmappers 1 each field of entity under serialization. 2. then, columnmappers take turns populating mutation batch. 3. maps, mapcolumnmapper used. if take @ code, see adds key:value pairs mutation batch. 4. when data put in row in cassandra, new columns batch added, existing ones overwritten, old ones unfortunately remain same.
one solution here write custom serializer map , save in 1 field.
Comments
Post a Comment