Search in sources :

Example 21 with VCollection

use of de.fhg.igd.mongomvcc.VCollection in project mongomvcc by igd-geo.

the class MongoDBVCollectionTest method deleteFromIndex.

/**
	 * Deletes an object from the index
	 */
@Test
public void deleteFromIndex() {
    Map<String, Object> p = putPerson("Peter", 26);
    VCollection persons = _master.getCollection("persons");
    assertEquals(1, persons.find().size());
    persons.delete((Long) p.get("uid"));
    assertEquals(0, persons.find().size());
}
Also used : VCollection(de.fhg.igd.mongomvcc.VCollection) Test(org.junit.Test)

Example 22 with VCollection

use of de.fhg.igd.mongomvcc.VCollection in project mongomvcc by igd-geo.

the class MongoDBVCollectionTest method lifetimeInsertedLaterOptimization.

/**
	 * Tests if lifetime optimization takes effect. Objects that have
	 * been inserted in a later commit should not be loaded but filtered
	 * out on the database level already.
	 */
@Test
@Ignore("Not ready yet. We need to implement full branch history.")
public void lifetimeInsertedLaterOptimization() {
    //ignore this test if we're on MongoDB 1.x
    assumeNotNull(((MongoDBVDatabase) _db).getBuildInfo());
    assumeTrue(((MongoDBVDatabase) _db).getBuildInfo().getMajorVersion() >= 2);
    //insert two documents to skip in-index shortcut
    putPerson("Max", 6);
    putPerson("Pax", 8);
    long firstCID = _master.commit();
    putPerson("Elvis", 3);
    _master.commit();
    VBranch oldMaster = _db.checkout(firstCID);
    VCollection persons = oldMaster.getCollection("persons");
    VCursor cursor = persons.find();
    DBCursor dbcursor = extractDBCursor(cursor);
    assertEquals(2, cursor.size());
    assertTrue(hasAttachedFilter(cursor));
    assertEquals(2, dbcursor.size());
}
Also used : DBCursor(com.mongodb.DBCursor) VBranch(de.fhg.igd.mongomvcc.VBranch) VCursor(de.fhg.igd.mongomvcc.VCursor) VCollection(de.fhg.igd.mongomvcc.VCollection) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

VCollection (de.fhg.igd.mongomvcc.VCollection)22 Test (org.junit.Test)17 VBranch (de.fhg.igd.mongomvcc.VBranch)10 VCursor (de.fhg.igd.mongomvcc.VCursor)7 BasicDBObject (com.mongodb.BasicDBObject)4 AbstractMongoDBVDatabaseTest (de.fhg.igd.mongomvcc.impl.AbstractMongoDBVDatabaseTest)3 HashMap (java.util.HashMap)3 BenchmarkOptions (com.carrotsearch.junitbenchmarks.BenchmarkOptions)2 DBCursor (com.mongodb.DBCursor)2 DBObject (com.mongodb.DBObject)2 VDatabase (de.fhg.igd.mongomvcc.VDatabase)2 Ignore (org.junit.Ignore)2 VException (de.fhg.igd.mongomvcc.VException)1 VFactory (de.fhg.igd.mongomvcc.VFactory)1 VHistory (de.fhg.igd.mongomvcc.VHistory)1 MongoDBVDatabase (de.fhg.igd.mongomvcc.impl.MongoDBVDatabase)1 MongoDBVFactory (de.fhg.igd.mongomvcc.impl.MongoDBVFactory)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1