本文整理匯總了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);
}