A zipped version of my MongoDB project is attached below. I downloaded version 2.4.6 (latest current) - but the 32-bit version.As usual, I set MONGODB_HOME to the root folder and added %MONGODB_HOME%/bin to my path
In order to start the server, run mongod on a DOS shell (as long as you have set the MONGODB_HOME variable and added the bin folder to your path as explained above) ConfigurationYou should be able to execute the connectivity tests once you have set the server up (which demonstrates database creation, testConnectivity, and deletion, testDropDB)You can now launch the mongo.exe command on another DOS shell. If you execute show dbs Data PopulationI decided to store serialized objects of Trade and Market data into the document (collection). Perhaps this is not the way MongoDB was best designed for use, but it kept my use case consistent across the systems. Binaries are stored in BSON format and I must admit I am not a fan. The method insertMarketData in MarketDataCreatorTest shows how this is done
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectMapper mapper = new ObjectMapper(new BsonFactory()); mapper.writeValue(baos, marketData); dbObj.put("marketData", baos.toByteArray()); Querying and FilteringMongoDB requires the parameters involved in a query to be exposed as attributes in the document. For example, optionType was exposed as a Boolean attribute for TradeData (see insertTradeData in TradeDataCreatorTest) private WriteResult insertTradeData(DBCollection dbCol, EquityTradeData equityTradeData) throws IOException { BasicDBObject dbObj = new BasicDBObject(); ... ... dbObj.put("optionType", equityTradeData.isCall()); When executing testPricing (see PricingTest.java), the query is built up as follows BasicDBObject query = new BasicDBObject("optionType", false); DBCursor cursor = tdCol.find(query); The resulting cursor should contain the appropriate filtered document set |