Examples of BSONWritable


Examples of com.mongodb.hadoop.io.BSONWritable

        rdr = new BSONReader(in);
    }

    protected boolean nextKeyValue() throws IOException {
        if (rdr.hasNext()) {
            value = new BSONWritable( rdr.next() );
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

    public NullWritable createKey() {
        return NullWritable.get();
    }

    public BSONWritable createValue() {
        return new BSONWritable();
    }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

      //TODO: now do whatever processing you want to and emit (as many times as you want) as follows:
      // example, count tags
      if (null != tags) {
        for (Object tagObj: tags) {
          if (tagObj instanceof String) {
            BSONWritable outVal = new BSONWritable();
            outVal.put(DocumentPojo.url_, docUrl);           
            outVal.put(DocumentPojo.title_, docTitle)
            if (_config.fold) { // fold, can be faster for simpler aggregations
              _folder.fold((String) tagObj, outVal, context);
            }
            else {
              // Write don't fold, default:
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

   
    public void fold(String key, BSONWritable value, @SuppressWarnings("rawtypes") org.apache.hadoop.mapreduce.Mapper.Context context) throws IOException, InterruptedException {
     
      // 1] Get current state, or create if not there
     
      BSONWritable currVal = _folderState.get(key);
      if (null == currVal) {
        currVal = new BSONWritable();
        _folderState.put(key, currVal);
      }
     
      // 2] Processing logic
           
      //TODO: write your logic in here, the key/val can be anything you want, since you control the map code also
      // Eg: count the docs
      Integer currDocs = (Integer) currVal.get("count");
      if (null == currDocs) {
        currDocs = 0;
      }
      currDocs++;
      currVal.put("count", currDocs);
         
      //DEBUG:
      if (_logMessages) _logger.info("FOLD_IN " + key + ": " + MongoDbUtil.convert(value) + "->" + MongoDbUtil.convert(currVal).toString());           
           
      // 3] Emit if state getting too large
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

         
          Integer docs = (Integer) value.get("count"); // (if from the folder)
          numDocs += docs;
        }
      }
      BSONWritable outVal = new BSONWritable();
      outVal.put("count", numDocs);
      context.write(key, outVal);

      //DEBUG
      if (_logMessages) _logger.info("COMBINE_OUT " + key + ": " + MongoDbUtil.convert(outVal));
    }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

         
          Integer docs = (Integer) value.get("count"); // (if from the custom combiner OR directly from the folder)
          numDocs += docs;
        }
      }
      BSONWritable outVal = new BSONWritable();
      outVal.put("count", numDocs);
      context.write(key, outVal);

      //DEBUG
      if (_logMessages) _logger.info("REDUCE_OUT " + key + ": " + MongoDbUtil.convert(outVal));
    }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

    }

    @Override
    public boolean nextKeyValue() throws IOException, InterruptedException {
        if (rdr.hasNext()) {
            value = new BSONWritable( rdr.next() );
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

      out.put(entry.getKey(), entry.getValue());
    }
    return out;
  }//TESTED
  public static BSONWritable convert(BSONObject dbo) {
    BSONWritable out = new BSONWritable();
    for (Object entryIt: dbo.toMap().entrySet()) {
      @SuppressWarnings("unchecked")
      Map.Entry<String, Object> entry = (Map.Entry<String, Object>)entryIt;
      out.put(entry.getKey(), entry.getValue());
    }
    return out;
  }//TESTED
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

   
    protected boolean isMemoryOptimized() { return _memoryOptimized; }
   
    // (JS side) Interface
   
    public Object clone(Boolean topLevel) { return topLevel ? new BSONWritable() : new BasicDBObject(); }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

    }//TESTED
   
    public String next() throws IOException, InterruptedException {
      try {
        _secManager.setSecureFlag(false);
        BSONWritable next = _reduceContext.getValues().iterator().next();
        if (null == next) {
          return null;
        }
        else {
          return JSON.serialize(MongoDbUtil.convert(next));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.