當前位置: 首頁>>代碼示例>>Java>>正文


Java HBaseProjectionCriteria類代碼示例

本文整理匯總了Java中org.apache.storm.hbase.bolt.mapper.HBaseProjectionCriteria的典型用法代碼示例。如果您正苦於以下問題:Java HBaseProjectionCriteria類的具體用法?Java HBaseProjectionCriteria怎麽用?Java HBaseProjectionCriteria使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HBaseProjectionCriteria類屬於org.apache.storm.hbase.bolt.mapper包,在下文中一共展示了HBaseProjectionCriteria類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: constructGetRequests

import org.apache.storm.hbase.bolt.mapper.HBaseProjectionCriteria; //導入依賴的package包/類
public Get constructGetRequests(byte[] rowKey, HBaseProjectionCriteria projectionCriteria) {
    Get get = new Get(rowKey);

    if (projectionCriteria != null) {
        for (byte[] columnFamily : projectionCriteria.getColumnFamilies()) {
            get.addFamily(columnFamily);
        }

        for (HBaseProjectionCriteria.ColumnMetaData columnMetaData : projectionCriteria.getColumns()) {
            get.addColumn(columnMetaData.getColumnFamily(), columnMetaData.getQualifier());
        }
    }

    return get;
}
 
開發者ID:mengzhiyi,項目名稱:storm-hbase-1.0.x,代碼行數:16,代碼來源:HBaseClient.java

示例2: withProjectionCriteria

import org.apache.storm.hbase.bolt.mapper.HBaseProjectionCriteria; //導入依賴的package包/類
public Options withProjectionCriteria(HBaseProjectionCriteria projectionCriteria) {
    this.projectionCriteria = projectionCriteria;
    return this;
}
 
開發者ID:mengzhiyi,項目名稱:storm-hbase-1.0.x,代碼行數:5,代碼來源:HBaseState.java

示例3: withProjectionCriteria

import org.apache.storm.hbase.bolt.mapper.HBaseProjectionCriteria; //導入依賴的package包/類
public HBaseLookupBolt withProjectionCriteria(HBaseProjectionCriteria projectionCriteria) {
    this.projectionCriteria = projectionCriteria;
    return this;
}
 
開發者ID:mengzhiyi,項目名稱:storm-hbase-1.0.x,代碼行數:5,代碼來源:HBaseLookupBolt.java

示例4: buildTopology

import org.apache.storm.hbase.bolt.mapper.HBaseProjectionCriteria; //導入依賴的package包/類
public static StormTopology buildTopology(String hbaseRoot){
    Fields fields = new Fields("word", "count");
    FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
            new Values("storm", 1),
            new Values("trident", 1),
            new Values("needs", 1),
            new Values("javadoc", 1)
    );
    spout.setCycle(true);

    TridentHBaseMapper tridentHBaseMapper = new SimpleTridentHBaseMapper()
            .withColumnFamily("cf")
            .withColumnFields(new Fields("word"))
            .withCounterFields(new Fields("count"))
            .withRowKeyField("word");

    HBaseValueMapper rowToStormValueMapper = new WordCountValueMapper();

    HBaseProjectionCriteria projectionCriteria = new HBaseProjectionCriteria();
    projectionCriteria.addColumn(new HBaseProjectionCriteria.ColumnMetaData("cf", "count"));

    HBaseState.Options options = new HBaseState.Options()
            .withConfigKey(hbaseRoot)
            .withDurability(Durability.SYNC_WAL)
            .withMapper(tridentHBaseMapper)
            .withProjectionCriteria(projectionCriteria)
            .withRowToStormValueMapper(rowToStormValueMapper)
            .withTableName("WordCount");

    StateFactory factory = new HBaseStateFactory(options);

    TridentTopology topology = new TridentTopology();
    Stream stream = topology.newStream("spout1", spout);

    stream.partitionPersist(factory, fields,  new HBaseUpdater(), new Fields());

    TridentState state = topology.newStaticState(factory);
    stream = stream.stateQuery(state, new Fields("word"), new HBaseQuery(), new Fields("columnName","columnValue"));
    stream.each(new Fields("word","columnValue"), new PrintFunction(), new Fields());
    return topology.build();
}
 
開發者ID:mengzhiyi,項目名稱:storm-hbase-1.0.x,代碼行數:42,代碼來源:WordCountTrident.java

示例5: main

import org.apache.storm.hbase.bolt.mapper.HBaseProjectionCriteria; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    Config config = new Config();

    Map<String, Object> hbConf = new HashMap<String, Object>();
    if(args.length > 0){
        hbConf.put("hbase.rootdir", args[0]);
    }
    config.put("hbase.conf", hbConf);

    WordSpout spout = new WordSpout();
    TotalWordCounter totalBolt = new TotalWordCounter();

    SimpleHBaseMapper mapper = new SimpleHBaseMapper().withRowKeyField("word");
    HBaseProjectionCriteria projectionCriteria = new HBaseProjectionCriteria();
    projectionCriteria.addColumn(new HBaseProjectionCriteria.ColumnMetaData("cf", "count"));

    WordCountValueMapper rowToTupleMapper = new WordCountValueMapper();

    HBaseLookupBolt hBaseLookupBolt = new HBaseLookupBolt("WordCount", mapper, rowToTupleMapper)
            .withConfigKey("hbase.conf")
            .withProjectionCriteria(projectionCriteria);

    //wordspout -> lookupbolt -> totalCountBolt
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(WORD_SPOUT, spout, 1);
    builder.setBolt(LOOKUP_BOLT, hBaseLookupBolt, 1).shuffleGrouping(WORD_SPOUT);
    builder.setBolt(TOTAL_COUNT_BOLT, totalBolt, 1).fieldsGrouping(LOOKUP_BOLT, new Fields("columnName"));

    if (args.length == 1) {
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("test", config, builder.createTopology());
        Thread.sleep(30000);
        cluster.killTopology("test");
        cluster.shutdown();
        System.exit(0);
    } else if (args.length == 2) {
        StormSubmitter.submitTopology(args[1], config, builder.createTopology());
    } else{
        System.out.println("Usage: LookupWordCount <hbase.rootdir>");
    }
}
 
開發者ID:mengzhiyi,項目名稱:storm-hbase-1.0.x,代碼行數:42,代碼來源:LookupWordCount.java


注:本文中的org.apache.storm.hbase.bolt.mapper.HBaseProjectionCriteria類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。