Search in sources :

Example 1 with TokenDatum

use of org.apache.gora.examples.generated.TokenDatum in project gora by apache.

the class SparkWordCount method run.

public int run(String[] args) throws Exception {
    DataStore<String, WebPage> inStore;
    DataStore<String, TokenDatum> outStore;
    Configuration hadoopConf = new Configuration();
    if (args.length > 0) {
        String dataStoreClass = args[0];
        inStore = DataStoreFactory.getDataStore(dataStoreClass, String.class, WebPage.class, hadoopConf);
        if (args.length > 1) {
            dataStoreClass = args[1];
        }
        outStore = DataStoreFactory.getDataStore(dataStoreClass, String.class, TokenDatum.class, hadoopConf);
    } else {
        inStore = DataStoreFactory.getDataStore(String.class, WebPage.class, hadoopConf);
        outStore = DataStoreFactory.getDataStore(String.class, TokenDatum.class, hadoopConf);
    }
    return wordCount(inStore, outStore);
}
Also used : WebPage(org.apache.gora.examples.generated.WebPage) Configuration(org.apache.hadoop.conf.Configuration) TokenDatum(org.apache.gora.examples.generated.TokenDatum)

Example 2 with TokenDatum

use of org.apache.gora.examples.generated.TokenDatum in project gora by apache.

the class WordCount method run.

@Override
public int run(String[] args) throws Exception {
    DataStore<String, WebPage> inStore;
    DataStore<String, TokenDatum> outStore;
    Configuration conf = new Configuration();
    if (args.length > 0) {
        String dataStoreClass = args[0];
        inStore = DataStoreFactory.getDataStore(dataStoreClass, String.class, WebPage.class, conf);
        if (args.length > 1) {
            dataStoreClass = args[1];
        }
        outStore = DataStoreFactory.getDataStore(dataStoreClass, String.class, TokenDatum.class, conf);
    } else {
        inStore = DataStoreFactory.getDataStore(String.class, WebPage.class, conf);
        outStore = DataStoreFactory.getDataStore(String.class, TokenDatum.class, conf);
    }
    return wordCount(inStore, outStore);
}
Also used : WebPage(org.apache.gora.examples.generated.WebPage) Configuration(org.apache.hadoop.conf.Configuration) TokenDatum(org.apache.gora.examples.generated.TokenDatum)

Example 3 with TokenDatum

use of org.apache.gora.examples.generated.TokenDatum in project gora by apache.

the class MapReduceTestUtils method assertTokenCount.

private static void assertTokenCount(DataStore<String, TokenDatum> outStore, String token, int count) throws Exception {
    TokenDatum datum = outStore.get(token, null);
    assertNotNull("token:" + token + " cannot be found in datastore", datum);
    assertEquals("count for token:" + token + " is wrong", count, datum.getCount().intValue());
}
Also used : TokenDatum(org.apache.gora.examples.generated.TokenDatum)

Aggregations

TokenDatum (org.apache.gora.examples.generated.TokenDatum)3 WebPage (org.apache.gora.examples.generated.WebPage)2 Configuration (org.apache.hadoop.conf.Configuration)2