Package com.mongodb.hadoop.io

Examples of com.mongodb.hadoop.io.MongoUpdateWritable


        BasicBSONObject query = new BasicBSONObject("devices", new ObjectId(pKey.toString()));
        BasicBSONObject update = new BasicBSONObject("$inc", new BasicBSONObject("logs_count", count));
        LOG.debug("query: " + query);
        LOG.debug("update: " + update);
        pContext.write(null, new MongoUpdateWritable(query, update, true, false));
    }
View Full Code Here


        BasicBSONObject query = new BasicBSONObject("devices", new ObjectId(key.toString()));
        BasicBSONObject update = new BasicBSONObject("$inc", new BasicBSONObject("logs_count", count));
        LOG.debug("query: " + query);
        LOG.debug("update: " + update);
        output.collect(null, new MongoUpdateWritable(query, update, true, false));
    }
View Full Code Here

        for (Text val : pValues) {
            devices.add(new ObjectId(val.toString()));
        }

        BasicBSONObject update = new BasicBSONObject("$pushAll", new BasicBSONObject("devices", devices));
        pContext.write(null, new MongoUpdateWritable(query, update, true, false));
    }
View Full Code Here

            Text val = values.next();
            devices.add(new ObjectId(val.toString()));
        }

        BasicBSONObject update = new BasicBSONObject("$pushAll", new BasicBSONObject("devices", devices));
        output.collect(null, new MongoUpdateWritable(query, update, true, false));
    }
View Full Code Here

        for (BSONWritable val : values) {
            books.add(val.getDoc());
        }

        BasicBSONObject update = new BasicBSONObject("$set", new BasicBSONObject("books", books));
        context.write(null, new MongoUpdateWritable(query, update, true, false));
    }
View Full Code Here

        while (values.hasNext()) {
            books.add(values.next().getDoc());
        }

        BasicBSONObject update = new BasicBSONObject("$set", new BasicBSONObject("books", books));
        output.collect(null, new MongoUpdateWritable(query, update, true, false));
    }
View Full Code Here

                                                  .add("sum", sum)
                                                  .get());

        modifiers.put("$push", new BasicBSONObject("calculatedAt", new Date()));
        modifiers.put("$inc", new BasicBSONObject("numCalculations", 1));
        pContext.write(null, new MongoUpdateWritable(query, modifiers, true, false));
    }
View Full Code Here

            if (mu != null) {
                isUpsert = !mu.containsField("upsert") || mu.getBoolean("upsert");
                isMulti = mu.containsField("multi") && mu.getBoolean("multi");
            }

            recordWriter.write(null, new MongoUpdateWritable(q, u,
                                                             isUpsert,
                                                             isMulti));
        } catch (Exception e) {
            throw new IOException("Couldn't convert tuple to bson: ", e);
        }
View Full Code Here

    public void write(final K key, final V value) throws IOException {
        final DBObject o = new BasicDBObject();

        if (value instanceof MongoUpdateWritable) {
            //ignore the key - just use the update directly.
            MongoUpdateWritable muw = (MongoUpdateWritable) value;
            try {
                DBCollection dbCollection = getDbCollectionByRoundRobin();
                dbCollection.update(new BasicDBObject(muw.getQuery()), new BasicDBObject(muw.getModifiers()), muw.isUpsert(),
                                    muw.isMultiUpdate());
                return;
            } catch (final MongoException e) {
                throw new IOException("can't write to mongo", e);
            }
        }
View Full Code Here

    public void write(final K key, final V value) throws IOException {
        final DBObject o = new BasicDBObject();

        if (value instanceof MongoUpdateWritable) {
            //ignore the key - just use the update directly.
            MongoUpdateWritable muw = (MongoUpdateWritable) value;
            try {
                DBCollection dbCollection = getDbCollectionByRoundRobin();
                dbCollection.update(new BasicDBObject(muw.getQuery()), new BasicDBObject(muw.getModifiers()), muw.isUpsert(),
                                    muw.isMultiUpdate());
                return;
            } catch (final MongoException e) {
                throw new IOException("can't write to mongo", e);
            }
        }
View Full Code Here

TOP

Related Classes of com.mongodb.hadoop.io.MongoUpdateWritable

Copyright © 2018 www.massapicom. 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.