Examples of BSONWritable


Examples of com.mongodb.hadoop.io.BSONWritable

      _javascript.map(key, value);
     
      if (!_javascript.isMemoryOptimized()) {
        BasicBSONList out = _javascript.generateOutput();
        for (Object bson: out) {
          BSONWritable bsonObj = (BSONWritable) bson;
          BSONWritable outkey = (BSONWritable) bsonObj.get("key");
          BSONWritable outval = (BSONWritable) bsonObj.get("val");
          if (null == outkey) {
            throw new IOException("Map: Can't output a null key from " + value.get("_id"));         
          }
          if (null == outval) {         
            throw new IOException("Map: Can't output a null value, key: " + MongoDbUtil.convert(outkey) + " from " + value.get("_id"));
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

      _javascript.combine(key, values);

      if (!_javascript.isMemoryOptimized()) {
        BasicBSONList out = _javascript.generateOutput();
        for (Object bson: out) {
          BSONWritable bsonObj = (BSONWritable) bson;
          BSONWritable outkey = (BSONWritable) bsonObj.get("key");
          BSONWritable outval = (BSONWritable) bsonObj.get("val");
          if (null == outkey) {
            throw new IOException("Combine: Can't output a null key from " + key);         
          }
          if (null == outval) {         
            throw new IOException("Combine: Can't output a null value, key: " + MongoDbUtil.convert(outkey) + " from " + key);
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

      _javascript.reduce(key, values);
     
      if (!_javascript.isMemoryOptimized()) {
        BasicBSONList out = _javascript.generateOutput();
        for (Object bson: out) {
          BSONWritable bsonObj = (BSONWritable) bson;
          BSONWritable outkey = (BSONWritable) bsonObj.get("key");
          BSONWritable outval = (BSONWritable) bsonObj.get("val");
          if (null == outkey) {
            throw new IOException("Reduce: Can't output a null key from " + key);         
          }
          if (null == outval) {         
            throw new IOException("Reduce: Can't output a null value, key: " + MongoDbUtil.convert(outkey) + " from " + key);
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

        job.set(INPUT_DIR, new File(EXAMPLE_DATA_HOME, "/dump/enron_mail/messages.bson").getAbsoluteFile().toURI().toString());
            FileSplit[] splits = inputFormat.getSplits(job, 5);
        int count = 0;
        for (FileSplit split : splits) {
            RecordReader<NullWritable, BSONWritable> recordReader = inputFormat.getRecordReader(split, job, null);
            while (recordReader.next(null, new BSONWritable())) {
                count++;
            }
        }
        assertEquals("There are 501513 messages in the enron corpus", 501513, count);
    }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

        BasicBSONObject output = new BasicBSONObject();
        output.put("count", count);
        output.put("avg", avg);
        output.put("sum", sum);
        pContext.write(pKey, new BSONWritable(output));
    }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

        BasicBSONObject bsonObject = new BasicBSONObject();
        bsonObject.put("count", count);
        bsonObject.put("avg", avg);
        bsonObject.put("sum", sum);
        output.collect(key, new BSONWritable(bsonObject));
    }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

            LOG.info("V2: Average 10 Year Treasury for " + key.get() + " was " + avg);
            BasicBSONObject outputObj = new BasicBSONObject();
            outputObj.put("count", count);
            outputObj.put("avg", avg);
            outputObj.put("sum", sum);
            output.collect(key, new BSONWritable(outputObj));
        }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

        job.set(INPUT_DIR, new File(EXAMPLE_DATA_HOME, "/dump/enron_mail/messages.bson").getAbsoluteFile().toURI().toString());
        FileSplit[] splits = inputFormat.getSplits(job, 5);
        int count = 0;
        for (FileSplit split : splits) {
            RecordReader<NullWritable, BSONWritable> recordReader = inputFormat.getRecordReader(split, job, null);
            while (recordReader.next(null, new BSONWritable())) {
                count++;
            }
        }
        assertEquals("There are 501513 messages in the enron corpus", 501513, count);
    }
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

    @Override
    public boolean readKeyValue() throws IOException {
        // Actually, just read the value as the key is embedded.
        try {
            bson = new BSONWritable();
            bson.readFields(in);
            // If successful we'll have an _id field
            return bson.getDoc().containsField("_id");
        } catch (IndexOutOfBoundsException e) {
            // No more data
View Full Code Here

Examples of com.mongodb.hadoop.io.BSONWritable

        }
    }

    @Override
    public BSONWritable getCurrentKey() throws IOException {
        return new BSONWritable(new BasicDBObject("_id", bson.getDoc().get("_id")));
    }
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.