本文整理汇总了C++中DBClientConnection::dropDatabase方法的典型用法代码示例。如果您正苦于以下问题:C++ DBClientConnection::dropDatabase方法的具体用法?C++ DBClientConnection::dropDatabase怎么用?C++ DBClientConnection::dropDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBClientConnection
的用法示例。
在下文中一共展示了DBClientConnection::dropDatabase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseFile
void parseFile(ifstream& input,DBClientConnection& c){
//DES: parse text file and input into mongo database
//IN: input text file, mongo db connection
//clean up database if it already exists
c.dropDatabase("hw3");
//hold parsed elements
string date;
string value;
string volume;
//track row numbers
long count=0;
int total=0;
//holds batch of "documents" to be inserted into database
vector<BSONObj> bobjp(BATCH_SIZE);
//holds last DUPLICATE_ARRAY_SIZE elements to be used for duplicate search
string comparison[DUPLICATE_ARRAY_SIZE];
int compCount=0;
bool duplicate;
int test=0;
XLog logInsert("Inserting...");
while(!input.eof()){
duplicate=false;
//parse a line
getline(input,date,',');
getline(input,value,',');
getline(input,volume);
//create "document" to be inserted from parsed information
BSONObjBuilder b;
double dValue=atof(value.c_str());
int iVol=atol(volume.c_str());
b.append("date", date);
b.append("value", dValue);
b.append("volume", iVol);
//check for duplicates within a window of size DUPLICATE_ARRAY_SIZE
duplicate=checkDuplicates(date,comparison);
comparison[compCount]=date;
compCount++;
if (compCount>=DUPLICATE_ARRAY_SIZE)compCount=0;
//create "document" to be inserted into database
BSONObj p = b.obj();
//if no duplicates, add to array for batch insertion
if (duplicate==false){
bobjp[count]=p;
total++;
count++;
}
//if it is a duplicate, insert right away into noise collection
else {
c.insert("hw3.noise", p);
test++;
}
//insert batch of documents into collection once vector is full
if (total%BATCH_SIZE==0){
c.insert("hw3.signal", bobjp);
count=0;
if(total%(BATCH_SIZE*10)==0)logInsert.log("Lines inserted so far: ",total);
}
}
//process leftover elements after eof
for (int i=0;i<count;i++){
c.insert("hw3.signal", bobjp[i]);
}
}