Example usage for org.apache.hadoop.conf Configuration getPattern

List of usage examples for org.apache.hadoop.conf Configuration getPattern

Introduction

In this page you can find the example usage for org.apache.hadoop.conf Configuration getPattern.

Prototype

public Pattern getPattern(String name, Pattern defaultValue) 

Source Link

Document

Get the value of the name property as a Pattern.

Usage

From source file:com.jumptap.h2redis.RedisOutputMapper.java

License:Open Source License

@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
    Configuration conf = context.getConfiguration();
    int keyIdx = conf.getInt(RedisDriver.REDIS_KEY_FIELD, -1);
    int hashIdx = conf.getInt(RedisDriver.REDIS_HASHKEY_FIELD, -1);
    int valIdx = conf.getInt(RedisDriver.REDIS_HASHVAL_FIELD, -1);

    if (keyIdx == -1 || hashIdx == -1 || valIdx == -1)
        return;//  w  w  w .  j a  v  a  2s .co m

    String[] payload = StringUtils.getStrings(value.toString());
    String keyStr = payload[keyIdx];
    String hashStr = payload[hashIdx];
    String valStr = payload[valIdx];

    // check filters
    Pattern p = conf.getPattern(RedisDriver.REDIS_KEY_FILTER, null);
    if (p != null && p.matcher(keyStr).find()) {
        return;
    }

    p = conf.getPattern(RedisDriver.REDIS_HASH_FILTER, null);
    if (p != null && p.matcher(hashStr).find()) {
        return;
    }

    p = conf.getPattern(RedisDriver.REDIS_VAL_FILTER, null);
    if (p != null && p.matcher(valStr).find()) {
        return;
    }

    outkey.set(keyStr);
    outvalue.set(hashStr + "," + valStr);
    context.write(outkey, outvalue);
}