当前位置: 首页>>代码示例>>Java>>正文


Java Pair类代码示例

本文整理汇总了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));
    }
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:26,代码来源:MetricsLoaderIT.java

示例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);

}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:26,代码来源:RecordReaderValueIteratorTest.java

示例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));
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:27,代码来源:AccumuloEntityStoreIT.java

示例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();
  }
 
开发者ID:calrissian,项目名称:flowmix,代码行数:13,代码来源:SplitBuilder.java

示例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;
}
 
开发者ID:calrissian,项目名称:flowmix,代码行数:10,代码来源:SortOp.java

示例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);
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:37,代码来源:EntityLoaderIT.java

示例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);
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:37,代码来源:EventLoaderIT.java

示例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);
    }
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:37,代码来源:KeyValueIndex.java

示例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());
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:34,代码来源:EventKeyValueIndexTest.java

示例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;
}
 
开发者ID:calrissian,项目名称:flowmix,代码行数:5,代码来源:SortBuilder.java

示例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;
}
 
开发者ID:calrissian,项目名称:flowmix,代码行数:5,代码来源:SplitBuilder.java

示例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;
}
 
开发者ID:calrissian,项目名称:flowmix,代码行数:5,代码来源:SplitBuilder.java

示例13: getSortBy

import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public List<Pair<String,Order>> getSortBy() {
  return sortBy;
}
 
开发者ID:calrissian,项目名称:flowmix,代码行数:4,代码来源:SortOp.java

示例14: SplitOp

import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public SplitOp(Filter defaultPath, List<Pair<Filter,String>> paths) {
  this.defaultPath = defaultPath;
  this.paths = paths;
}
 
开发者ID:calrissian,项目名称:flowmix,代码行数:5,代码来源:SplitOp.java

示例15: getPaths

import org.calrissian.mango.domain.Pair; //导入依赖的package包/类
public List<Pair<Filter,String>> getPaths() {
  return paths;
}
 
开发者ID:calrissian,项目名称:flowmix,代码行数:4,代码来源:SplitOp.java


注:本文中的org.calrissian.mango.domain.Pair类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。