@Override public RoaringBitmap deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser); final TreeNode bitmapObject = treeNode.get(RoaringBitmapConstants.BITMAP_WRAPPER_OBJECT_NAME); if (null != bitmapObject) { final TextNode jsonNodes = (TextNode) bitmapObject.get(RoaringBitmapConstants.BITMAP_VALUE_FIELD_NAME); return (RoaringBitmap) bitmapSerialiser.deserialise(jsonNodes.binaryValue()); } else { throw new IllegalArgumentException("Received null bitmap treenode"); } }
@Override public HyperLogLogPlus deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser); final TreeNode coreHyperLogLogPlusObject = treeNode.get("hyperLogLogPlus"); if (null != coreHyperLogLogPlusObject) { final TextNode jsonNodes = (TextNode) coreHyperLogLogPlusObject.get(HyperLogLogPlusJsonConstants.HYPER_LOG_LOG_PLUS_SKETCH_BYTES_FIELD); final byte[] nodeAsString = jsonNodes.binaryValue(); final HyperLogLogPlus hyperLogLogPlus = HyperLogLogPlus.Builder.build(nodeAsString); return hyperLogLogPlus; } else { throw new IllegalArgumentException("Receieved null or empty HyperLogLogPlus sketch"); } } }
@Override public RoaringBitmap deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser); final TreeNode bitmapObject = treeNode.get(RoaringBitmapConstants.BITMAP_WRAPPER_OBJECT_NAME); if (null != bitmapObject) { final TextNode jsonNodes = (TextNode) bitmapObject.get(RoaringBitmapConstants.BITMAP_VALUE_FIELD_NAME); return (RoaringBitmap) bitmapSerialiser.deserialise(jsonNodes.binaryValue()); } else { throw new IllegalArgumentException("Received null bitmap treenode"); } }
@Override public HyperLogLogPlus deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser); final TreeNode coreHyperLogLogPlusObject = treeNode.get("hyperLogLogPlus"); if (null != coreHyperLogLogPlusObject) { final TextNode jsonNodes = (TextNode) coreHyperLogLogPlusObject.get(HyperLogLogPlusJsonConstants.HYPER_LOG_LOG_PLUS_SKETCH_BYTES_FIELD); final byte[] nodeAsString = jsonNodes.binaryValue(); final HyperLogLogPlus hyperLogLogPlus = HyperLogLogPlus.Builder.build(nodeAsString); return hyperLogLogPlus; } else { throw new IllegalArgumentException("Receieved null or empty HyperLogLogPlus sketch"); } } }
@Test(groups = "fast") public void testTimelineChunkCompactMapping() throws Exception { final String chunkToString = mapper.writerWithView(Compact.class).writeValueAsString(chunk); final Map chunkFromString = mapper.readValue(chunkToString, Map.class); Assert.assertEquals(chunkFromString.keySet().size(), 10); Assert.assertEquals(chunkFromString.get("sourceId"), HOST_ID); Assert.assertEquals(chunkFromString.get("metricId"), SAMPLE_KIND_ID); final Map<String, String> timeBytesAndSampleBytes = (Map<String, String>) chunkFromString.get("timeBytesAndSampleBytes"); Assert.assertEquals(new TextNode(timeBytesAndSampleBytes.get("timeBytes")).binaryValue(), timeBytes); Assert.assertEquals(new TextNode(timeBytesAndSampleBytes.get("sampleBytes")).binaryValue(), samples); Assert.assertEquals(chunkFromString.get("sampleCount"), SAMPLE_COUNT); Assert.assertEquals(chunkFromString.get("aggregationLevel"), 0); Assert.assertEquals(chunkFromString.get("notValid"), false); Assert.assertEquals(chunkFromString.get("dontAggregate"), false); Assert.assertEquals(chunkFromString.get("chunkId"), (int) CHUNK_ID); }