Projects >> fongo >>11b406d2de2239bff4b46a3db9d52bae8ad925ce

Chunk
Conflicting content
    return Collections.emptyList();
  }

<<<<<<< HEAD:src/main/java/com/foursquare/fongo/impl/index/IndexAbstract.java
  // Only for unique index.
  public List get(DBObject query) {
=======
  // Only for unique index and for query with values. ($in doens't work by example.)
  public synchronized List get(DBObject query) {
    if(!unique) {
      throw new IllegalStateException("get is only for unique index");
    }
    lookupCount++;

>>>>>>> ec8de69f42e32f3e00510209c160587b24164c96:src/main/java/com/foursquare/fongo/impl/Index.java
    DBObject key = getKeyFor(query);
    return mapValues.get(key);
  }
Solution content
    return Collections.emptyList();
  }

  // Only for unique index and for query with values. ($in doens't work by example.)
  public List get(DBObject query) {
    if(!unique) {
      throw new IllegalStateException("get is only for unique index");
    }
    lookupCount++;

    DBObject key = getKeyFor(query);
    return mapValues.get(key);
  }
File
IndexAbstract.java
Developer's decision
Combination
Kind of conflict
Attribute
Comment
If statement
Method signature
Chunk
Conflicting content
    return mapValues.get(key);
  }

<<<<<<< HEAD:src/main/java/com/foursquare/fongo/impl/index/IndexAbstract.java
  public Collection retrieveObjects(DBObject query) {
=======
  public synchronized Collection retrieveObjects(DBObject query) {
    // Optimization
    if(unique && query.keySet().size() == 1 && !(query.toMap().values().iterator().next() instanceof DBObject)) {
      return get(query);
    }

>>>>>>> ec8de69f42e32f3e00510209c160587b24164c96:src/main/java/com/foursquare/fongo/impl/Index.java
    lookupCount++;

    // Filter for the key.
Solution content
    return mapValues.get(key);
  }

  public Collection retrieveObjects(DBObject query) {
    // Optimization
    if(unique && query.keySet().size() == 1 && !(query.toMap().values().iterator().next() instanceof DBObject)) {
      return get(query);
    }

    lookupCount++;

    // Filter for the key.
File
IndexAbstract.java
Developer's decision
Manual
Kind of conflict
Comment
If statement
Method signature
Chunk
Conflicting content
    return aggregator.computeResult();
  }

<<<<<<< HEAD
  private List doGeoNearCollection(String collection, DBObject near, DBObject query, Number limit, Number maxDistance, boolean spherical) {
    FongoDBCollection coll = doGetCollection(collection);
    return coll.geoNear(near, query, limit, maxDistance, spherical);
=======
  private DBObject doMapReduce(String collection, String map, String reduce, DBObject out, DBObject query, DBObject sort, Number limit) {
    FongoDBCollection coll = doGetCollection(collection);
    MapReduce mapReduce = new MapReduce(this, coll, map, reduce, out, query, sort, limit);
    return mapReduce.computeResult();
>>>>>>> ec8de69f42e32f3e00510209c160587b24164c96
  }

Solution content
    return aggregator.computeResult();
  }

  private DBObject doMapReduce(String collection, String map, String reduce, DBObject out, DBObject query, DBObject sort, Number limit) {
    FongoDBCollection coll = doGetCollection(collection);
    MapReduce mapReduce = new MapReduce(this, coll, map, reduce, out, query, sort, limit);
    return mapReduce.computeResult();
  }

  private List doGeoNearCollection(String collection, DBObject near, DBObject query, Number limit, Number maxDistance, boolean spherical) {
    FongoDBCollection coll = doGetCollection(collection);
    return coll.geoNear(near, query, limit, maxDistance, spherical);
  }

File
FongoDB.java
Developer's decision
Concatenation
Kind of conflict
Method invocation
Method signature
Return statement
Variable
Chunk
Conflicting content
      list.addAll(result);
      okResult.put("result", list);
      return okResult;
<<<<<<< HEAD
    } else if (cmd.containsField("geoNear")) {
      // http://docs.mongodb.org/manual/reference/command/geoNear/
      // TODO : handle "num" (override limit)
      try {
        List result = doGeoNearCollection((String) cmd.get("geoNear"),
            (DBObject) cmd.get("near"),
            (DBObject) cmd.get("query"),
            (Number) cmd.get("limit"),
            (Number) cmd.get("maxDistance"),
            Boolean.TRUE.equals(cmd.get("spherical")));
        if (result == null) {
          return notOkErrorResult("can't geoNear");
        }
        CommandResult okResult = okResult();
        BasicDBList list = new BasicDBList();
        list.addAll(result);
        okResult.put("results", list);
        return okResult;
      } catch (MongoException me) {
        CommandResult result = errorResult(me.getCode(), me.getMessage());
        return result;
      }
=======
    } else if (cmd.containsField("mapreduce")) {
      System.out.println(cmd);
      // TODO : sort/limit
      DBObject result = doMapReduce((String) cmd.get("mapreduce"), (String) cmd.get("map"), (String) cmd.get("reduce"), (DBObject) cmd.get("out"), (DBObject) cmd.get("query"), (DBObject) cmd.get("sort"), (Number) cmd.get("limit"));
      if (result == null) {
        return notOkErrorResult("can't mapReduce");
      }
      CommandResult okResult = okResult();
      okResult.put("result", result);
      return okResult;
>>>>>>> ec8de69f42e32f3e00510209c160587b24164c96
    }
    return notOkErrorResult("undefined command: " + cmd);
  }
Solution content
      list.addAll(result);
      okResult.put("result", list);
      return okResult;
    } else if (cmd.containsField("mapreduce")) {
      // TODO : sort/limit
      DBObject result = doMapReduce((String) cmd.get("mapreduce"), (String) cmd.get("map"), (String) cmd.get("reduce"), (DBObject) cmd.get("out"), (DBObject) cmd.get("query"), (DBObject) cmd.get("sort"), (Number) cmd.get("limit"));
      if (result == null) {
        return notOkErrorResult("can't mapReduce");
      }
      CommandResult okResult = okResult();
      okResult.put("result", result);
      return okResult;
    } else if (cmd.containsField("geoNear")) {
      // http://docs.mongodb.org/manual/reference/command/geoNear/
      // TODO : handle "num" (override limit)
      try {
        List result = doGeoNearCollection((String) cmd.get("geoNear"),
            (DBObject) cmd.get("near"),
            (DBObject) cmd.get("query"),
            (Number) cmd.get("limit"),
            (Number) cmd.get("maxDistance"),
            Boolean.TRUE.equals(cmd.get("spherical")));
        if (result == null) {
          return notOkErrorResult("can't geoNear");
        }
        CommandResult okResult = okResult();
        BasicDBList list = new BasicDBList();
        list.addAll(result);
        okResult.put("results", list);
        return okResult;
      } catch (MongoException me) {
        CommandResult result = errorResult(me.getCode(), me.getMessage());
        return result;
      }
    }
    return notOkErrorResult("undefined command: " + cmd);
  }
File
FongoDB.java
Developer's decision
Combination
Kind of conflict
Comment
If statement
Method invocation
Return statement
Try statement
Variable
Chunk
Conflicting content
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
<<<<<<< HEAD
import org.junit.rules.ExpectedException;
import org.junit.rules.RuleChain;
=======
>>>>>>> ec8de69f42e32f3e00510209c160587b24164c96

public class FongoIndexTest {
Solution content
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.RuleChain;

public class FongoIndexTest {
File
FongoIndexTest.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
  public final ExpectedException exception = ExpectedException.none();

  @Rule
<<<<<<< HEAD
  public RuleChain ruleChain = RuleChain.outerRule(exception).around(fongoRule);
=======
  public FongoRule fongoRule = new FongoRule("db");
>>>>>>> ec8de69f42e32f3e00510209c160587b24164c96

  @Test
  public void testCreateIndexes() {
Solution content
  public final ExpectedException exception = ExpectedException.none();

  @Rule
  public RuleChain ruleChain = RuleChain.outerRule(exception).around(fongoRule);

  @Test
  public void testCreateIndexes() {
File
FongoIndexTest.java
Developer's decision
Version 1
Kind of conflict
Attribute
Method invocation
Chunk
Conflicting content
  @Test(expected = MongoException.class)
  public void testStrangeIndexThrowException() throws Exception {
<<<<<<< HEAD
    exception.expect(MongoException.class);
    DBCollection collection = fongoRule.newCollection();
=======
    DBCollection collection = FongoTest.newCollection();
>>>>>>> ec8de69f42e32f3e00510209c160587b24164c96
    collection.ensureIndex(new BasicDBObject("a", new BasicDBObject("n", 1)));

    // Code : 10098
Solution content
  @Test
  public void testStrangeIndexThrowException() throws Exception {
    ExpectedMongoException.expectCode(exception, 10098, MongoException.class);
    DBCollection collection = fongoRule.newCollection();
    collection.ensureIndex(new BasicDBObject("a", new BasicDBObject("n", 1)));
File
FongoIndexTest.java
Developer's decision
Manual
Kind of conflict
Method invocation
Variable