<commit_before># fongo

Fongo is an in-memory java implementation of mongo.  It intercepts calls to the standard mongo-java-driver for 
finds, updates, inserts, removes and other methods.  The primary use is for lightweight unit testing where you
don't want to spin up a mongo process.

The original hope was that this would be significantly faster than using a real mongo server, however, it's still not clear if that's the case.  Another goal was to make it easier to parallelize tests, but that could also be achieved
by fixing each thread to a uniquely named database.

## Usage

1. Clone this repo and build the jar:
    <pre><code>
    mvn package
    </code></pre>
1. Copy jar to classpath

1. Use in place of regular `com.mongodb.Mongo` instance:

    <pre><code>
    import com.foursquare.fongo.Fongo;
    import com.mongodb.BasicDBObject;
    import com.mongodb.DB;
    import com.mognodb.DBCollection;
    ...
    Fongo fongo = new Fongo("mongo server 1");
    
    // once you have a DB instance, you can interact with it
    // just like you would with a real one.
    DB db = fongo.getDB("mydb");
    DBCollection collection = db.getCollection("mycollection");
    collection.insert(new BasicDBObject("name", "jon"));
    </code></pre>
## Scope

fongo doesn't implement all mongo functionality. most query and update syntax is supported.  MapReduce,
gridfs, and capped collections are not supported.  Also, there is no index support other than the \_id index.
Fongo uses a LinkedHashMap internally with the \_id as the key.

## Implementation Details

Fongo depends on mockito to hijack the com.mongodb.Mongo class.  It has a "provided" dependency on the mongo-java-driver and was tested with 2.7.2.

Fongo should be thread safe. All read and write operations on collections are synchronized.  It's pretty course, but<commit_msg>fix formatting moar<commit_after># fongo

Fongo is an in-memory java implementation of mongo.  It intercepts calls to the standard mongo-java-driver for 
finds, updates, inserts, removes and other methods.  The primary use is for lightweight unit testing where you
don't want to spin up a mongo process.

The original hope was that this would be significantly faster than using a real mongo server, however, it's still not clear if that's the case.  Another goal was to make it easier to parallelize tests, but that could also be achieved
by fixing each thread to a uniquely named database.

## Usage

1. Clone this repo and build the jar: `mvn package`
1. Copy jar to classpath
1. Use in place of regular `com.mongodb.Mongo` instance:
    <pre><code>import com.foursquare.fongo.Fongo;
    import com.mongodb.BasicDBObject;
    import com.mongodb.DB;
    import com.mognodb.DBCollection;
    ...
    Fongo fongo = new Fongo("mongo server 1");
    
    // once you have a DB instance, you can interact with it
    // just like you would with a real one.
    DB db = fongo.getDB("mydb");
    DBCollection collection = db.getCollection("mycollection");
    collection.insert(new BasicDBObject("name", "jon"));</code></pre>

## Scope

fongo doesn't implement all mongo functionality. most query and update syntax is supported.  MapReduce,
gridfs, and capped collections are not supported.  Also, there is no index support other than the \_id index.
Fongo uses a LinkedHashMap internally with the \_id as the key.

## Implementation Details

Fongo depends on mockito to hijack the com.mongodb.Mongo class.  It has a "provided" dependency on the mongo-java-driver and was tested with 2.7.2.

Fongo should be thread safe. All read and write operations on collections are synchronized.  It's pretty course, but
{'fraction_non_alphanumeric': 0.07133058984910837, 'fraction_numerical': 0.003840877914951989, 'mean_word_length': 3.72279792746114, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7260438', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1005, 'n_words': 495}