@Override public Object decodeValue(byte[] bytes) throws IOException { return GenericObjectMapper.read(bytes); } }
/** * Deserializes an Object from a byte array created with * {@link #write(Object)}. * * @param b A byte array * @return An Object * @throws IOException if there is a read error */ public static Object read(byte[] b) throws IOException { return read(b, 0); }
/** * Deserializes an Object from a byte array created with * {@link #write(Object)}. * * @param b A byte array * @return An Object * @throws IOException if there is a read error */ public static Object read(byte[] b) throws IOException { return read(b, 0); }
/** * Deserializes an Object from a byte array created with * {@link #write(Object)}. * * @param b A byte array * @return An Object * @throws IOException if there is a read error */ public static Object read(byte[] b) throws IOException { return read(b, 0); }
/** * Parses the primary filter from the given key at the given offset and * adds it to the given entity. */ private static void addPrimaryFilter(TimelineEntity entity, byte[] key, int offset) throws IOException { KeyParser kp = new KeyParser(key, offset); String name = kp.getNextString(); Object value = GenericObjectMapper.read(key, kp.getOffset()); entity.addPrimaryFilter(name, value); }
/** * Parses the primary filter from the given key at the given offset and * adds it to the given entity. */ private static void addPrimaryFilter(TimelineEntity entity, byte[] key, int offset) throws IOException { KeyParser kp = new KeyParser(key, offset); String name = kp.getNextString(); Object value = GenericObjectMapper.read(key, kp.getOffset()); entity.addPrimaryFilter(name, value); }
/** * Parses the primary filter from the given key at the given offset and * adds it to the given entity. */ private static void addPrimaryFilter(TimelineEntity entity, byte[] key, int offset) throws IOException { KeyParser kp = new KeyParser(key, offset); String name = kp.getNextString(); Object value = GenericObjectMapper.read(key, kp.getOffset()); entity.addPrimaryFilter(name, value); }
private static void verify(Object o) throws IOException { assertEquals(o, GenericObjectMapper.read(GenericObjectMapper.write(o))); }
/** * Creates an event object from the given key, offset, and value. If the * event type is not contained in the specified set of event types, * returns null. */ private static TimelineEvent getEntityEvent(Set<String> eventTypes, byte[] key, int offset, byte[] value) throws IOException { KeyParser kp = new KeyParser(key, offset); long ts = kp.getNextLong(); String tstype = kp.getNextString(); if (eventTypes == null || eventTypes.contains(tstype)) { TimelineEvent event = new TimelineEvent(); event.setTimestamp(ts); event.setEventType(tstype); Object o = GenericObjectMapper.read(value); if (o == null) { event.setEventInfo(null); } else if (o instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> m = (Map<String, Object>) o; event.setEventInfo(m); } else { throw new IOException("Couldn't deserialize event info map"); } return event; } return null; }
/** * Creates an event object from the given key, offset, and value. If the * event type is not contained in the specified set of event types, * returns null. */ private static TimelineEvent getEntityEvent(Set<String> eventTypes, byte[] key, int offset, byte[] value) throws IOException { KeyParser kp = new KeyParser(key, offset); long ts = kp.getNextLong(); String tstype = kp.getNextString(); if (eventTypes == null || eventTypes.contains(tstype)) { TimelineEvent event = new TimelineEvent(); event.setTimestamp(ts); event.setEventType(tstype); Object o = GenericObjectMapper.read(value); if (o == null) { event.setEventInfo(null); } else if (o instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> m = (Map<String, Object>) o; event.setEventInfo(m); } else { throw new IOException("Couldn't deserialize event info map"); } return event; } return null; }
/** * Creates an event object from the given key, offset, and value. If the * event type is not contained in the specified set of event types, * returns null. */ private static TimelineEvent getEntityEvent(Set<String> eventTypes, byte[] key, int offset, byte[] value) throws IOException { KeyParser kp = new KeyParser(key, offset); long ts = kp.getNextLong(); String tstype = kp.getNextString(); if (eventTypes == null || eventTypes.contains(tstype)) { TimelineEvent event = new TimelineEvent(); event.setTimestamp(ts); event.setEventType(tstype); Object o = GenericObjectMapper.read(value); if (o == null) { event.setEventInfo(null); } else if (o instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> m = (Map<String, Object>) o; event.setEventInfo(m); } else { throw new IOException("Couldn't deserialize event info map"); } return event; } return null; }
entity.addOtherInfo(parseRemainingKey(key, prefixlen + OTHER_INFO_COLUMN.length), GenericObjectMapper.read(iterator.peekNext().getValue()));
entity.addOtherInfo(parseRemainingKey(key, prefixlen + OTHER_INFO_COLUMN.length), GenericObjectMapper.read(iterator.peekNext().getValue()));
entity.addOtherInfo(parseRemainingKey(key, prefixlen + OTHER_INFO_COLUMN.length), GenericObjectMapper.read(iterator.peekNext().getValue()));
@Test public void testValueTypes() throws IOException { verify(Integer.MAX_VALUE); verify(Integer.MIN_VALUE); assertEquals(Integer.MAX_VALUE, GenericObjectMapper.read( GenericObjectMapper.write((long) Integer.MAX_VALUE))); assertEquals(Integer.MIN_VALUE, GenericObjectMapper.read( GenericObjectMapper.write((long) Integer.MIN_VALUE))); verify((long)Integer.MAX_VALUE + 1l); verify((long)Integer.MIN_VALUE - 1l); verify(Long.MAX_VALUE); verify(Long.MIN_VALUE); assertEquals(42, GenericObjectMapper.read(GenericObjectMapper.write(42l))); verify(42); verify(1.23); verify("abc"); verify(true); List<String> list = new ArrayList<String>(); list.add("123"); list.add("abc"); verify(list); Map<String,String> map = new HashMap<String,String>(); map.put("k1","v1"); map.put("k2","v2"); verify(map); }
prefixlen + PRIMARY_FILTERS_COLUMN.length); String name = kp.getNextString(); Object value = GenericObjectMapper.read(key, kp.getOffset()); deleteKeysWithPrefix(writeBatch, addPrimaryFilterToKey(name, value, deletePrefix), pfIterator);
prefixlen + PRIMARY_FILTERS_COLUMN.length); String name = kp.getNextString(); Object value = GenericObjectMapper.read(key, kp.getOffset()); deleteKeysWithPrefix(writeBatch, addPrimaryFilterToKey(name, value, deletePrefix), pfIterator);
prefixlen + PRIMARY_FILTERS_COLUMN.length); String name = kp.getNextString(); Object value = GenericObjectMapper.read(key, kp.getOffset()); deleteKeysWithPrefix(writeBatch, addPrimaryFilterToKey(name, value, deletePrefix), pfIterator);