本文整理汇总了Java中org.calrissian.mango.domain.Pair类的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Pair类属于org.calrissian.mango.domain包,在下文中一共展示了Pair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetNext
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
@Test
public void testGetNext() throws Exception {
setUpJob();
List<Pair<String, MetricFeature>> mocks = new ArrayList<Pair<String, MetricFeature>>();
mocks.add(new Pair<String, MetricFeature>("", metric));
MockRecordReader<String, MetricFeature> mockRecordReader = new MockRecordReader<String, MetricFeature>(mocks);
MetricFeatureLoader loader = new MetricFeatureLoader();
setLocation(loader, new Job(), "mockInst", "mockZk",accumuloMiniClusterDriver.getRootPassword());
loader.prepareToRead(mockRecordReader, new PigSplit());
org.apache.pig.data.Tuple t;
while((t = loader.getNext()) != null) {
assertEquals(metric.getTimestamp(), t.get(0));
assertEquals(TimeUnit.MINUTES.toString(), t.get(1));
assertEquals(metric.getGroup(), t.get(2));
assertEquals(metric.getType(), t.get(3));
assertEquals(metric.getName(), t.get(4));
assertEquals(metric.getVisibility(), t.get(5));
assertEquals(metric.getVector().getSum(), t.get(6));
}
}
示例2: testNonEmpty_returnsData
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
@Test
public void testNonEmpty_returnsData() {
List<Pair<String,String>> pairs = new ArrayList<Pair<String, String>>();
pairs.add(pair1);
pairs.add(pair2);
MockRecordReader<String, String> mockRecordReader = new MockRecordReader<String, String>(pairs);
RecordReaderValueIterator<String,String> rrvi = new RecordReaderValueIterator<String, String>(mockRecordReader);
int count = 0;
while(rrvi.hasNext()) {
if(count == 0) {
assertEquals(pair1.getTwo(), rrvi.next());
} else if(count == 1)
assertEquals(pair2.getTwo(), rrvi.next());
else
fail();
count++;
}
assertEquals(2, count);
}
示例3: testKeys
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
@Test
public void testKeys() throws Exception {
Entity entity = EntityBuilder.create("type", "id")
.attr(new Attribute("hasIp", "true", meta))
.attr(new Attribute("ip", "1.1.1.1", meta))
.build();
Entity entity2 = EntityBuilder.create("type", "id2")
.attr(new Attribute("hasIp", "true", meta))
.attr(new Attribute("ip", "2.2.2.2", meta))
.build();
Entity entity3 = EntityBuilder.create("type", "id3")
.attr(new Attribute("hasIp", "true", meta))
.attr(new Attribute("ip", "3.3.3.3", meta))
.build();
store.save(asList(entity, entity2, entity3));
store.flush();
CloseableIterable<Pair<String, String>> keys = store.uniqueKeys("", "type", DEFAULT_AUTHS);
assertEquals(2, Iterables.size(keys));
assertEquals(new Pair<String, String>("hasIp", "string"), get(keys, 0));
assertEquals(new Pair<String, String>("ip", "string"), get(keys, 1));
}
示例4: end
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
@Override public StreamBuilder end() {
for(Pair<Filter, String> pair : paths) {
if(pair.getOne() == null || pair.getTwo() == null)
throw new RuntimeException("Each path in the split operator must have both a non-null filter and destination stream name.");
}
//TODO: Verify destination stream exists
getStreamBuilder().addFlowOp(new SplitOp(defaultPath, paths));
return getStreamBuilder();
}
示例5: SortOp
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public SortOp(List<Pair<String,Order>> sortBy, boolean clearOnTrigger, Policy evictionPolicy, long evictionThreshold, Policy triggerPolicy, long triggerThreshold, boolean progressive) {
this.sortBy = sortBy;
this.clearOnTrigger = clearOnTrigger;
this.evictionPolicy = evictionPolicy;
this.evictionThreshold = evictionThreshold;
this.triggerPolicy = triggerPolicy;
this.triggerThreshold = triggerThreshold;
this.progressive = progressive;
}
示例6: testGetNext
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
@Test
public void testGetNext() throws Exception {
setUpJob();
List<Pair<String, EntityWritable>> mocks = new ArrayList<Pair<String, EntityWritable>>();
mocks.add(new Pair<String, EntityWritable>("", new EntityWritable(entity)));
MockRecordReader<String, EntityWritable> mockRecordReader = new MockRecordReader<String, EntityWritable>(mocks);
EntityLoader loader = new EntityLoader("q.eq('key','val')");
loader.prepareToRead(mockRecordReader, new PigSplit());
org.apache.pig.data.Tuple t;
int count = 0;
Iterator<org.calrissian.mango.domain.Attribute> attributes = entity.getAttributes().iterator();
while((t = loader.getNext()) != null) {
org.calrissian.mango.domain.Attribute attribute = attributes.next();
count++;
if(count == 1) {
assertEquals(entity.getType(), t.get(0));
assertEquals(entity.getId(), t.get(1));
assertEquals(attribute.getKey(), t.get(2));
assertEquals(loader.registry.getAlias(attribute.getValue()), t.get(3));
assertEquals(loader.registry.encode(attribute.getValue()), t.get(4));
} else if(count == 2) {
assertEquals(entity.getType(), t.get(0));
assertEquals(entity.getId(), t.get(1));
assertEquals(attribute.getKey(), t.get(2));
assertEquals(loader.registry.getAlias(attribute.getValue()), t.get(3));
assertEquals(loader.registry.encode(attribute.getValue()), t.get(4));
}
}
assertEquals(2, count);
}
示例7: testGetNext
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
@Test
public void testGetNext() throws Exception {
setUpJob();
List<Pair<String, EventWritable>> mocks = new ArrayList<Pair<String, EventWritable>>();
mocks.add(new Pair<String, EventWritable>("", new EventWritable(event)));
MockRecordReader<String, EventWritable> mockRecordReader = new MockRecordReader<String, EventWritable>(mocks);
EventLoader loader = new EventLoader("q.eq('key','val')");
loader.prepareToRead(mockRecordReader, new PigSplit());
org.apache.pig.data.Tuple t;
int count = 0;
Iterator<org.calrissian.mango.domain.Attribute> attributes = event.getAttributes().iterator();
while((t = loader.getNext()) != null) {
org.calrissian.mango.domain.Attribute attribute = attributes.next();
count++;
if(count == 1) {
assertEquals(event.getId(), t.get(0));
assertEquals(event.getTimestamp(), t.get(1));
assertEquals(attribute.getKey(), t.get(2));
assertEquals(loader.registry.getAlias(attribute.getValue()), t.get(3));
assertEquals(loader.registry.encode(attribute.getValue()), t.get(4));
} else if(count == 2) {
assertEquals(event.getId(), t.get(0));
assertEquals(event.getTimestamp(), t.get(1));
assertEquals(attribute.getKey(), t.get(2));
assertEquals(loader.registry.getAlias(attribute.getValue()), t.get(3));
assertEquals(loader.registry.encode(attribute.getValue()), t.get(4));
}
}
assertEquals(2, count);
}
示例8: uniqueKeys
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
/**
* Returns all the unique keys for the given event type for the given prefix. Unique key is defined as a unique key + data type alias
* @param connector
* @param indexTable
* @param prefix
* @param type
* @param maxQueryThreads
* @param auths
* @return
*/
public static CloseableIterable<Pair<String,String>> uniqueKeys(Connector connector, String indexTable, String prefix, String type, int maxQueryThreads, Auths auths) {
checkNotNull(prefix);
checkNotNull(auths);
try {
BatchScanner scanner = connector.createBatchScanner(indexTable, auths.getAuths(), maxQueryThreads);
IteratorSetting setting = new IteratorSetting(15, GlobalIndexUniqueKeyValueIterator.class);
scanner.addScanIterator(setting);
scanner.setRanges(singletonList(
new Range(INDEX_K + INDEX_SEP + type + INDEX_SEP + prefix + Constants.NULL_BYTE,
INDEX_K + INDEX_SEP + type + INDEX_SEP + prefix + END_BYTE))
);
return transform(closeableIterable(scanner), new Function<Map.Entry<Key, Value>, Pair<String, String>>() {
@Override
public Pair<String, String> apply(Map.Entry<Key, Value> keyValueEntry) {
AttributeIndexKey key = new AttributeIndexKey(keyValueEntry.getKey());
return new Pair(key.getKey(), key.getAlias());
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例9: test
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
@Test
public void test() throws AccumuloSecurityException, AccumuloException, TableExistsException, TableNotFoundException {
Instance instance = new MockInstance();
Connector connector = instance.getConnector("root", "".getBytes());
EventStore eventStore = new AccumuloEventStore(connector);
KeyValueIndex eventKeyValueIndex = new KeyValueIndex(
connector, "eventStore_index", DEFAULT_SHARD_BUILDER, DEFAULT_STORE_CONFIG,
LEXI_TYPES
);
Event event = EventBuilder.create("", "id", System.currentTimeMillis())
.attr(new Attribute("key1", "val1"))
.attr(new Attribute("key2", "val2")).build();
Event event2 = EventBuilder.create("", "id2", System.currentTimeMillis())
.attr(new Attribute("key1", "val1"))
.attr(new Attribute("key2", "val2"))
.attr(new Attribute("key3", true))
.attr(new Attribute("aKey", 1)).build();
eventStore.save(Arrays.asList(new Event[] {event, event2}));
dumpTable(connector, DEFAULT_IDX_TABLE_NAME);
assertEquals(4, Iterables.size(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY)));
assertEquals("aKey", Iterables.<Pair<String,String>>get(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY), 0).getOne());
assertEquals("key1", Iterables.<Pair<String,String>>get(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY), 1).getOne());
assertEquals("key2", Iterables.<Pair<String,String>>get(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY), 2).getOne());
assertEquals("key3", Iterables.<Pair<String,String>>get(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY), 3).getOne());
}
示例10: sortBy
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public SortBuilder sortBy(String field, Order order) {
sortBy.add(new Pair<String, Order>(field, order));
return this;
}
示例11: path
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public SplitBuilder path(Filter filter, String destinationStream) {
this.paths.add(new Pair<Filter,String>(filter, destinationStream));
return this;
}
示例12: all
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public SplitBuilder all(String destinationStream) {
this.paths.add(new Pair<Filter,String>(new NoFilter(), destinationStream));
return this;
}
示例13: getSortBy
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public List<Pair<String,Order>> getSortBy() {
return sortBy;
}
示例14: SplitOp
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public SplitOp(Filter defaultPath, List<Pair<Filter,String>> paths) {
this.defaultPath = defaultPath;
this.paths = paths;
}
示例15: getPaths
import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public List<Pair<Filter,String>> getPaths() {
return paths;
}