本文整理汇总了Java中org.apache.accumulo.core.client.lexicoder.StringLexicoder类的典型用法代码示例。如果您正苦于以下问题:Java StringLexicoder类的具体用法?Java StringLexicoder怎么用?Java StringLexicoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringLexicoder类属于org.apache.accumulo.core.client.lexicoder包,在下文中一共展示了StringLexicoder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testParse
import org.apache.accumulo.core.client.lexicoder.StringLexicoder; //导入依赖的package包/类
@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);
Key k = new Key(row, "tag1=value1".getBytes(), "tag2=value2,tag3=value3".getBytes(), "(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);
}
示例2: testParseWithViz
import org.apache.accumulo.core.client.lexicoder.StringLexicoder; //导入依赖的package包/类
@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);
Key k = new Key(row, "tag1=value1".getBytes(), "tag2=value2,tag3=value3".getBytes(), "(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);
}