Package com.mongodb

Examples of com.mongodb.DBCollection.drop()


            if (deleteData && !isExternal) {
                Map<String, String> tblParams = tbl.getParameters();
                if (tblParams.containsKey(MONGO_URI)) {
                    String mongoURIStr = tblParams.get(MONGO_URI);
                    DBCollection coll = MongoConfigUtil.getCollection(new MongoClientURI(mongoURIStr));
                    coll.drop();
                } else {
                    throw new MetaException(format("No '%s' property found. Collection not dropped.", MONGO_URI));
                }
            }
        }
View Full Code Here


public class HiveMappingTest extends HiveTest {
    @Test
    public void nestedObjects() {
        DBCollection collection = getCollection("hive_addresses");
        collection.drop();
        dropTable("hive_addresses");


        collection.insert(user(1, "Jim", "Beam", "Clermont", "KY"));
        collection.insert(user(2, "Don", "Draper", "New York", "NY"));
View Full Code Here

    @Test
    public void queryBasedHiveTable() {
        String tableName = "filtered";
        DBCollection collection = getCollection(tableName);
        collection.drop();
        dropTable(tableName);

        int size = 1000;
        for (int i = 0; i < size; i++) {
            collection.insert(new BasicDBObject("_id", i)
View Full Code Here

    }

    public void loadMailBson() {
        String name = "messages";
        DBCollection collection = getCollection(name);
        collection.drop();
        dropTable(name);

        loadIntoHDFS(new File(EXAMPLE_DATA_HOME, "dump/enron_mail/messages.bson").getAbsolutePath(), "/user/hive/warehouse/enron");

        ColumnMapping map = new ColumnMapping()
View Full Code Here

        DBCollection collection = db.getCollectionFromString(collectionName);
        if (collection != null) {

          if (types.contains(Struct.COLLECTION)) {
            collection.drop();
            LOGGER.debug("Dropping collection '{}' for DB '{}'. ", collectionName, db.getName());
          } else if (types.contains(Struct.INDEX)) {
            collection.dropIndexes();
            LOGGER.debug("Dropping indexes in collection '{}' for DB '{}'. ", collectionName, db.getName());
          }
View Full Code Here

    DB db = this.mongo.getDB(DATABASE_NAME);

    for (String collectionName : COLLECTION_NAMES) {
      DBCollection collection = db.getCollection(collectionName);
      collection.drop();
      collection.getDB().command(getCreateCollectionCommand(collectionName));
      collection.ensureIndex(new BasicDBObject("firstname", -1));
      collection.ensureIndex(new BasicDBObject("lastname", -1));
    }
  }
View Full Code Here

    if(coll.count() == RECORDS_TO_FETCH){
      return;
    }

    System.out.println("Warning!  Creating data");
    coll.drop();

    for(int i = 0; i < RECORDS_TO_FETCH; i++){
      BasicDBObject dbo = new BasicDBObject();
      dbo.put("_id", new Long(i));
      dbo.put("strval", RandomDataUtil.getRandomAlphaString(24));
View Full Code Here

    }
   
    if (dropCollectionBeforeInsertionSwitch){
      log.info("start to drop collection " + uri.getCollection());
      DBCollection coll = MongoUtils.getCollection(uri);
      coll.drop();
      log.info("drop collection " + uri.getCollection() + " before insert data successfully");
    }

    param.putValue(ParamKey.outputUri, this.outputUri);
    param.putValue(ParamKey.outputFields, this.outputFields);
View Full Code Here

            System.out.println(s);
        }

        // Dropping a collection
        DBCollection testCollection = db.getCollection("testCollection");
        testCollection.drop();
        System.out.println(db.getCollectionNames());

        /* Indexes */
        // get a collection object to work with
        DBCollection coll = db.getCollection("testCollection");
View Full Code Here

        /* Indexes */
        // get a collection object to work with
        DBCollection coll = db.getCollection("testCollection");

        // drop all the data in it
        coll.drop();

        // create an index on the "i" field
        coll.createIndex(new BasicDBObject("i", 1));

        // Geospatial query
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.