org.apache.accumulo.core.client.lexicoder.StringLexicoder Java Examples
The following examples show how to use
org.apache.accumulo.core.client.lexicoder.StringLexicoder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricAdapterTest.java From timely with Apache License 2.0 | 6 votes |
@Test public void testParse() throws Exception { PairLexicoder<String, Long> rowCoder = new PairLexicoder<>(new StringLexicoder(), new LongLexicoder()); byte[] row = rowCoder.encode(new ComparablePair<>("sys.cpu.user", 1000L)); byte[] value = new byte[Double.BYTES]; ByteBuffer.wrap(value).putDouble(2.0D); PairLexicoder<Long, String> colQualCoder = new PairLexicoder<>(new LongLexicoder(), new StringLexicoder()); Key k = new Key(row, "tag1=value1".getBytes(), colQualCoder.encode(new ComparablePair<>(new Long(1000), "tag2=value2,tag3=value3")), "(a&b)|(c&d)".getBytes(), 1000); Value v = new Value(value); Metric m = MetricAdapter.parse(k, v); Assert.assertEquals("sys.cpu.user", m.getName()); List<Tag> tags = new ArrayList<>(); tags.add(new Tag("tag1=value1")); tags.add(new Tag("tag2=value2")); tags.add(new Tag("tag3=value3")); Assert.assertEquals(tags, m.getTags()); Assert.assertEquals(new Long(1000), m.getValue().getTimestamp()); Assert.assertEquals(2.0D, m.getValue().getMeasure(), 0.0D); }
Example #2
Source File: MetricAdapterTest.java From timely with Apache License 2.0 | 6 votes |
@Test public void testParseWithEscapes() throws Exception { PairLexicoder<String, Long> rowCoder = new PairLexicoder<>(new StringLexicoder(), new LongLexicoder()); byte[] row = rowCoder.encode(new ComparablePair<>("sys.cpu.user", 1000L)); byte[] value = new byte[Double.BYTES]; ByteBuffer.wrap(value).putDouble(2.0D); PairLexicoder<Long, String> colQualCoder = new PairLexicoder<>(new LongLexicoder(), new StringLexicoder()); Key k = new Key(row, "tag1=value1".getBytes(), colQualCoder.encode(new ComparablePair<>(new Long(1000), "tag2=test\\,value2,tag3=val\\=ue3")), "(a&b)|(c&d)".getBytes(), 1000); Value v = new Value(value); Metric m = MetricAdapter.parse(k, v); Assert.assertEquals("sys.cpu.user", m.getName()); List<Tag> tags = new ArrayList<>(); tags.add(new Tag("tag1=value1")); tags.add(new Tag("tag2=test,value2")); tags.add(new Tag("tag3=val\\=ue3")); Assert.assertEquals(tags, m.getTags()); Assert.assertEquals(new Long(1000), m.getValue().getTimestamp()); Assert.assertEquals(2.0D, m.getValue().getMeasure(), 0.0D); }
Example #3
Source File: MetricAdapterTest.java From timely with Apache License 2.0 | 6 votes |
@Test public void testParseWithViz() throws Exception { PairLexicoder<String, Long> rowCoder = new PairLexicoder<>(new StringLexicoder(), new LongLexicoder()); byte[] row = rowCoder.encode(new ComparablePair<>("sys.cpu.user", 1000L)); byte[] value = new byte[Double.BYTES]; ByteBuffer.wrap(value).putDouble(2.0D); PairLexicoder<Long, String> colQualCoder = new PairLexicoder<>(new LongLexicoder(), new StringLexicoder()); Key k = new Key(row, "tag1=value1".getBytes(), colQualCoder.encode(new ComparablePair<>(new Long(1000), "tag2=value2,tag3=value3")), "(a&b)|(c&d)".getBytes(), 1000); Value v = new Value(value); Metric m = MetricAdapter.parse(k, v, true); Assert.assertEquals("sys.cpu.user", m.getName()); List<Tag> tags = new ArrayList<>(); tags.add(new Tag("tag1=value1")); tags.add(new Tag("tag2=value2")); tags.add(new Tag("tag3=value3")); tags.add(new Tag("viz=(a&b)|(c&d)")); Assert.assertEquals(tags, m.getTags()); Assert.assertEquals(new Long(1000), m.getValue().getTimestamp()); Assert.assertEquals(2.0D, m.getValue().getMeasure(), 0.0D); }