Exemplo n.º 1
0
 @Override
 public void write(Writable w) throws IOException {
   MapWritable map = (MapWritable) w;
   BasicDBObject dbo = new BasicDBObject();
   for (final Map.Entry<Writable, Writable> entry : map.entrySet()) {
     // System.err.println("Write: key=" + entry.getKey().toString()
     // + ", val=" + entry.getValue().toString());
     String key = entry.getKey().toString();
     //			if ("id".equals(key)) {
     //				key = "_id";
     //			}
     dbo.put(key, getObjectFromWritable(entry.getValue()));
   }
   table.save(dbo);
 }
Exemplo n.º 2
0
  public MongoReader(
      String dbHost,
      String dbPort,
      String dbName,
      String dbUser,
      String dbPasswd,
      String colName,
      MongoSplit split,
      String[] readColumns) {
    this.table = new MongoTable(dbHost, dbPort, dbName, dbUser, dbPasswd, colName);
    this.split = split;
    this.readColumns = readColumns;

    this.cursor = table.findAll(readColumns).batchSize(BATCH_SIZE).skip((int) split.getStart());
    if (!split.isLastSplit()) this.cursor.limit((int) split.getLength()); // if it's the last
    // split,it will read
    // all records since
    // $start

  }
Exemplo n.º 3
0
 @Override
 public void close() throws IOException {
   if (table != null) table.close();
 }