public void map(WritableComparable key, Writable val, Context context) throws IOException, InterruptedException { try{ Configuration config = context.getConfiguration(); String[] strs = val.toString().split(Constants.HIVE_RECORD_COLUMN_SEPARATOR); String family = config.get(Constants.CUBEBUILDER_CONFIGURATION_FAMILY); String column = strs[COLUMN_INDEX]; String Value = strs[VALUE_INDEX]; String sKey = generateKey(strs, config); byte[] bKey = Bytes.toBytes(sKey); Put put = new Put(bKey); put.add(Bytes.toBytes(family), Bytes.toBytes(column), (value <= 0) ? Bytes.toBytes(Double.MIN_VALUE) : Bytes.toBytes(value)); ImmutableBytesWritable ibKey = new ImmutableBytesWritable(bKey); context.write(ibKey, put); context.getCounter(CubeBuilderContextCounters.CompletedMapExecutions).increment(1); } catch(Exception e){ context.getCounter(CubeBuilderContextCounters.FailedMapExecutions).increment(1); } }
public void map(MD5Hash key, OverlapDataWritable value, Context context) Configuration conf = context.getConfiguration(); String someProperty = conf.get("something"); .... }
/** * <p> * Public constructor. * </p> * * @param filterConfig * The servlet filter configuration. */ public Context(FilterConfig filterConfig) { this.filterConfig = filterConfig; init(); }
/** * @return a set of mime types that can be compressed with gzip. */ public Set<String> getSupportedMimeTypes(Context context) { return context.getConfiguration().getToolGzipMimeTypes(); } }
@Override public void destroy() { context.destroy(); } }
/** * * @author Thibault Duchateau * @since 0.10.0 */ @Beta public interface DandelionRuntimeMBean { public void reloadBundles(); public void clearCache(); }
public void clearCache() { context.getCache(); } }
@Override public void init(FilterConfig filterConfig) throws ServletException { LOG.info("Initializing the Dandelion context"); context = new Context(filterConfig); LOG.info("Dandelion context initialized"); }
// driver code Configuration config = Configuration.create(); config.setLong("foo.bar.somelong",1337); ... // mapper code public class SomeMapper ... { private long someLong = 0; public void setup(Context context) { Configuration config = context.getConfiguration(); someLong = config.getLong("foo.bar.somelong"); } }
/** * <p> * Public constructor. * </p> * * @param filterConfig * The servlet filter configuration. */ public Context(FilterConfig filterConfig) { this.filterConfig = filterConfig; init(); }
@Override public void destroy() { context.destroy(); } }
/** * * @author Thibault Duchateau * @since 0.10.0 */ @Beta public interface DandelionRuntimeMBean { public void reloadBundles(); public void clearCache(); }
public void clearCache() { context.getCache(); } }
public void setup(Context context) throws IOException, InterruptedException{ Configuration conf = context.getConfiguration(); Path[] localFiles = DistributedCache.getLocalCacheFiles(conf); //etc }
private long someCount; @Override protected void setup(Context context) throws IOException, InterruptedException { super.setup(context); this.someCount = context.getConfiguration().getLong(CountersClass.N_COUNTERS.SOMECOUNT.name(), 0)); }
public void map(Text key, Text value, Context context) { Configuration conf = context.getConfiguration(); String someParam = conf.get(Constants.SOME_PARAM); // use someParam in processing input }
public void map( IntWritable key, // your key type Text value, // your value type Context context ) { // ... String rowsSerialized = context.getConfiguration().get("CassandraRows"); String[] rows = deserializeRows(rowsSerialized); // TODO: implement deserializer //... }
@Override protected void map(Longwritable key, Text value, Context context) { String filePath = context.getConfiguration().get("map.input.file"); }
public void setup(Context context) { try { String constructor = context.getConfiguration().get("ExtractorConstructor"); this.extractor = (Extractor) construct(constructor); } catch (Exception e) { throw new RuntimeException(e); } }
Extractor extractor = null; protected void setup(Context context) throws IOException, InterruptedException { try { Configuration conf = context.getConfiguration(); String className = conf.get("PrefixExtractorClass"); extractor = Class.forName(className); } Catch (ClassNotFoundException e) { //handle the exception } }