本文整理汇总了Java中org.apache.accumulo.core.iterators.SortedMapIterator类的典型用法代码示例。如果您正苦于以下问题:Java SortedMapIterator类的具体用法?Java SortedMapIterator怎么用?Java SortedMapIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortedMapIterator类属于org.apache.accumulo.core.iterators包,在下文中一共展示了SortedMapIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newSI
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
SnapshotIterator newSI(TestData input, long startTs, boolean returnReadLocks) {
SnapshotIterator si = new SnapshotIterator();
Map<String, String> options = new HashMap<>();
options.put(SnapshotIterator.RETURN_READLOCK_PRESENT_OPT, returnReadLocks + "");
options.put(SnapshotIterator.TIMESTAMP_OPT, startTs + "");
IteratorEnvironment env = TestIteratorEnv.create(IteratorScope.scan, true);
try {
SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(input.data);
si.init(source, options, env);
} catch (IOException e) {
throw new RuntimeException(e);
}
return si;
}
示例2: runQuery
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
private Map<Set<Tag>, Aggregation> runQuery(SortedKeyValueIterator<Key, Value> iter,
SortedMap<Key, Value> testData, long period) throws Exception {
IteratorSetting is = new IteratorSetting(100, AggregationIterator.class);
AggregationIterator.setAggregationOptions(is, Collections.singletonMap("host", ".*"), Avg.class.getName());
SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(testData);
iter.init(source, is.getOptions(), null);
iter.seek(new Range(), Collections.emptyList(), true);
assertTrue(iter.hasTop());
Key key = iter.getTopKey();
assertEquals(testData.lastKey(), key);
Map<Set<Tag>, Aggregation> samples = AggregationIterator.decodeValue(iter.getTopValue());
return samples;
}
示例3: runQuery
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
private Map<Set<Tag>, Downsample> runQuery(SortedKeyValueIterator<Key, Value> iter, SortedMap<Key, Value> testData,
long period) throws Exception {
IteratorSetting is = new IteratorSetting(100, DownsampleIterator.class);
DownsampleIterator.setDownsampleOptions(is, 0, 1000, period, Avg.class.getName());
SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(testData);
iter.init(source, is.getOptions(), null);
iter.seek(new Range(), Collections.emptyList(), true);
assertTrue(iter.hasTop());
Key key = iter.getTopKey();
assertEquals(testData.lastKey(), key);
Map<Set<Tag>, Downsample> samples = DownsampleIterator.decodeValue(iter.getTopValue());
return samples;
}
示例4: testMovingAverage
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
@Test
public void testMovingAverage() throws Exception {
SortedMapIterator source = new SortedMapIterator(table);
TimeSeriesGroupingIterator iter = new TimeSeriesGroupingIterator();
IteratorSetting settings = new IteratorSetting(100, TimeSeriesGroupingIterator.class);
settings.addOption(TimeSeriesGroupingIterator.FILTER, "0.20,0.20,0.20,0.20,0.20");
iter.init(source, settings.getOptions(), SCAN_IE);
iter.seek(new Range(), EMPTY_COL_FAMS, true);
for (int i = 4; i < 100; i++) {
checkNextResult(iter, new double[] { i - 4, i - 3, i - 2, i - 1, i });
}
assertFalse(iter.hasTop());
}
示例5: testMultipleTimeSeriesMovingAverage
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
@Test
public void testMultipleTimeSeriesMovingAverage() throws Exception {
table.clear();
long ts = System.currentTimeMillis();
List<Tag> tags1 = new ArrayList<>();
tags1.add(new Tag("host", "r01n01"));
List<Tag> tags2 = new ArrayList<>();
tags2.add(new Tag("host", "r01n02"));
for (int i = 0; i < 100; i++) {
ts += 1000;
Metric m = new Metric("sys.cpu.user", ts, i * 1.0D, tags1);
byte[] row = MetricAdapter.encodeRowKey(m);
Key k = new Key(row, tags1.get(0).join().getBytes(StandardCharsets.UTF_8), new byte[0], new byte[0], ts);
Value v = new Value(MetricAdapter.encodeValue(m.getValue().getMeasure()));
table.put(k, v);
Metric m2 = new Metric("sys.cpu.user", ts, i * 2.0D, tags2);
byte[] row2 = MetricAdapter.encodeRowKey(m2);
Key k2 = new Key(row2, tags2.get(0).join().getBytes(StandardCharsets.UTF_8), new byte[0], new byte[0], ts);
Value v2 = new Value(MetricAdapter.encodeValue(m2.getValue().getMeasure()));
table.put(k2, v2);
}
SortedMapIterator source = new SortedMapIterator(table);
TimeSeriesGroupingIterator iter = new TimeSeriesGroupingIterator();
IteratorSetting settings = new IteratorSetting(100, TimeSeriesGroupingIterator.class);
settings.addOption(TimeSeriesGroupingIterator.FILTER, "0.20,0.20,0.20,0.20,0.20");
iter.init(source, settings.getOptions(), SCAN_IE);
iter.seek(new Range(), EMPTY_COL_FAMS, true);
for (int i = 4; i < 100; i++) {
checkNextResult(iter, new double[] { i - 4, i - 3, i - 2, i - 1, i });
checkNextResult(iter, new double[] { (i - 4) * 2, (i - 3) * 2, (i - 2) * 2, (i - 1) * 2, i * 2 });
}
assertFalse(iter.hasTop());
}
示例6: testConstantTimeRate
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
@Test
public void testConstantTimeRate() throws Exception {
SortedMapIterator source = new SortedMapIterator(table);
RateIterator iter = new RateIterator();
IteratorSetting settings = new IteratorSetting(100, RateIterator.class);
iter.init(source, settings.getOptions(), SCAN_IE);
iter.seek(new Range(), EMPTY_COL_FAMS, true);
for (int i = 0; i < 99; i++) {
assertTrue(iter.hasTop());
assertEquals(0.001D, MetricAdapter.decodeValue(iter.getTopValue().get()), 0.0D);
iter.next();
}
assertFalse(iter.hasTop());
}
示例7: testCounterRate
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
@Test
public void testCounterRate() throws Exception {
table.clear();
long ts = System.currentTimeMillis();
for (int j = 0; j < 10; j++) {
for (int i = 1; i <= 10; i++) {
ts += 1000;
Metric m = new Metric("sys.cpu.user", ts, i * 1.0D, tags);
byte[] row = MetricAdapter.encodeRowKey(m);
Key k = new Key(row, tags.get(0).join().getBytes(StandardCharsets.UTF_8), new byte[0], new byte[0], ts);
Value v = new Value(MetricAdapter.encodeValue(m.getValue().getMeasure()));
table.put(k, v);
}
}
SortedMapIterator source = new SortedMapIterator(table);
RateIterator iter = new RateIterator();
IteratorSetting settings = new IteratorSetting(100, RateIterator.class);
QueryRequest.RateOption option = new QueryRequest.RateOption();
option.setCounter(true);
option.setCounterMax(0);
RateIterator.setRateOptions(settings, option);
iter.init(source, settings.getOptions(), SCAN_IE);
iter.seek(new Range(), EMPTY_COL_FAMS, true);
for (int i = 0; i < 99; i++) {
assertTrue(iter.hasTop());
assertEquals(0.001D, MetricAdapter.decodeValue(iter.getTopValue().get()), 0.0D);
iter.next();
}
assertFalse(iter.hasTop());
}
示例8: testCounterRateWithMax
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
@Test
public void testCounterRateWithMax() throws Exception {
table.clear();
long ts = System.currentTimeMillis();
for (int j = 0; j < 10; j++) {
for (int i = 0; i < 10; i++) {
ts += 1000;
Metric m = new Metric("sys.cpu.user", ts, i * 1.0D, tags);
byte[] row = MetricAdapter.encodeRowKey(m);
Key k = new Key(row, tags.get(0).join().getBytes(StandardCharsets.UTF_8), new byte[0], new byte[0], ts);
Value v = new Value(MetricAdapter.encodeValue(m.getValue().getMeasure()));
table.put(k, v);
}
}
SortedMapIterator source = new SortedMapIterator(table);
RateIterator iter = new RateIterator();
IteratorSetting settings = new IteratorSetting(100, RateIterator.class);
QueryRequest.RateOption option = new QueryRequest.RateOption();
option.setCounter(true);
option.setCounterMax(10);
RateIterator.setRateOptions(settings, option);
iter.init(source, settings.getOptions(), SCAN_IE);
iter.seek(new Range(), EMPTY_COL_FAMS, true);
for (int i = 0; i < 99; i++) {
assertTrue(iter.hasTop());
assertEquals(0.001D, MetricAdapter.decodeValue(iter.getTopValue().get()), 0.0D);
iter.next();
}
assertFalse(iter.hasTop());
}
示例9: testCounterRateWithReset
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
@Test
public void testCounterRateWithReset() throws Exception {
table.clear();
long ts = System.currentTimeMillis();
for (int j = 0; j < 10; j++) {
for (int i = 0; i < 10; i++) {
ts += 1000;
Metric m = new Metric("sys.cpu.user", ts, i * 1.0D, tags);
byte[] row = MetricAdapter.encodeRowKey(m);
Key k = new Key(row, tags.get(0).join().getBytes(StandardCharsets.UTF_8), new byte[0], new byte[0], ts);
Value v = new Value(MetricAdapter.encodeValue(m.getValue().getMeasure()));
table.put(k, v);
}
}
SortedMapIterator source = new SortedMapIterator(table);
RateIterator iter = new RateIterator();
IteratorSetting settings = new IteratorSetting(100, RateIterator.class);
QueryRequest.RateOption option = new QueryRequest.RateOption();
option.setCounter(true);
option.setCounterMax(Long.MAX_VALUE);
option.setResetValue(1);
RateIterator.setRateOptions(settings, option);
iter.init(source, settings.getOptions(), SCAN_IE);
iter.seek(new Range(), EMPTY_COL_FAMS, true);
for (int i = 0; i < 99; i++) {
assertTrue(iter.hasTop());
assertEquals(((i + 1) % 10 == 0 ? 0.0D : 0.001D), MetricAdapter.decodeValue(iter.getTopValue().get()), 0.0D);
iter.next();
}
assertFalse(iter.hasTop());
}
示例10: testDefaultMissing
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testDefaultMissing() throws Exception {
SortedMap<Key, Value> table = new TreeMap<>();
SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(table);
MetricAgeOffIterator iter = new MetricAgeOffIterator();
HashMap<String, String> options = new HashMap<>();
iter.init(source, options, null);
}
示例11: testDefault
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
@Test
public void testDefault() throws Exception {
SortedMap<Key, Value> table = new TreeMap<>();
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME), new byte[0], new byte[0], new byte[0],
TEST_TIME), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 1), new byte[0], new byte[0],
new byte[0], TEST_TIME + 1), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 2), new byte[0], new byte[0],
new byte[0], TEST_TIME + 2), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 3), new byte[0], new byte[0],
new byte[0], TEST_TIME + 3), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 4), new byte[0], new byte[0],
new byte[0], TEST_TIME + 4), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 5), new byte[0], new byte[0],
new byte[0], TEST_TIME + 5), EMPTY_VALUE);
SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(table);
MetricAgeOffIterator iter = new MetricAgeOffIterator();
HashMap<String, String> options = new HashMap<>();
options.put(MetricAgeOffIterator.AGE_OFF_PREFIX + "default", Integer.toString(1 * ONE_DAY));
iter.init(source, options, null);
iter.seek(new Range(), columnFamilies, true);
int seen = 0;
while (iter.hasTop()) {
Key k = iter.getTopKey();
Assert.assertTrue(k.getTimestamp() >= TEST_TIME && k.getTimestamp() <= TEST_TIME + 5);
seen++;
iter.next();
}
Assert.assertEquals(6, seen);
}
示例12: testSeekPastEndKey
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
@Test
public void testSeekPastEndKey() throws Exception {
SortedMap<Key, Value> table = new TreeMap<>();
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME), new byte[0], new byte[0], new byte[0],
TEST_TIME), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 1), new byte[0], new byte[0],
new byte[0], TEST_TIME + 1), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 2), new byte[0], new byte[0],
new byte[0], TEST_TIME + 2), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 3), new byte[0], new byte[0],
new byte[0], TEST_TIME + 3), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 4), new byte[0], new byte[0],
new byte[0], TEST_TIME + 4), EMPTY_VALUE);
table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 5), new byte[0], new byte[0],
new byte[0], TEST_TIME + 5), EMPTY_VALUE);
SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(table);
MetricAgeOffIterator iter = new MetricAgeOffIterator();
HashMap<String, String> options = new HashMap<>();
options.put(MetricAgeOffIterator.AGE_OFF_PREFIX + "default", Integer.toString(1));
iter.init(source, options, null);
iter.seek(
new Range(new Key("sys.cpu.user"), true, new Key(MetricAdapter.encodeRowKey("sys.cpu.user",
TEST_TIME + 3), new byte[0], new byte[0], new byte[0], TEST_TIME + 3), true), columnFamilies,
true);
int seen = 0;
while (iter.hasTop()) {
Key k = iter.getTopKey();
Assert.assertTrue(k.getTimestamp() >= TEST_TIME && k.getTimestamp() <= TEST_TIME + 5);
seen++;
iter.next();
}
Assert.assertEquals(0, seen);
}
示例13: newGCI
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
GarbageCollectionIterator newGCI(TestData input, long oldestActive, boolean fullMajc) {
GarbageCollectionIterator gci = new GarbageCollectionIterator();
Map<String, String> options = new HashMap<>();
options.put(GarbageCollectionIterator.GC_TIMESTAMP_OPT, Long.toString(oldestActive));
IteratorEnvironment env = TestIteratorEnv.create(IteratorScope.majc, fullMajc);
try {
gci.init(new SortedMapIterator(input.data), options, env);
} catch (IOException e) {
throw new RuntimeException(e);
}
return gci;
}
示例14: newNI
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
NotificationIterator newNI(TestData input, IteratorScope scope, boolean fullMajc) {
NotificationIterator ni = new NotificationIterator();
IteratorEnvironment env = TestIteratorEnv.create(scope, fullMajc);
try {
Map<String, String> opts = Collections.emptyMap();
ni.init(new SortedMapIterator(input.data), opts, env);
} catch (IOException e) {
throw new RuntimeException(e);
}
return ni;
}
示例15: newORLI
import org.apache.accumulo.core.iterators.SortedMapIterator; //导入依赖的package包/类
OpenReadLockIterator newORLI(TestData input) {
OpenReadLockIterator si = new OpenReadLockIterator();
IteratorEnvironment env = TestIteratorEnv.create(IteratorScope.scan, true);
try {
SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(input.data);
si.init(source, Collections.emptyMap(), env);
} catch (IOException e) {
throw new RuntimeException(e);
}
return si;
}