src/main/java/com/billybyte/mongo/MongoXml.java
public void batchInsert(Map<String,T> insertMap) throws MongoException {
		// new routine that calculates batchCount on the fly
		List<String> keyList = new ArrayList<String>(insertMap.keySet());
		if(keyList.size()<1)return;
		T t = insertMap.get(keyList.get(0));
		String serialized = xs.toXML(t);
		int recLen = serialized.length();
		long totalMapSerializedSize = recLen * insertMap.size();
		int batchCount = new Long(totalMapSerializedSize  / BATCH_WRITE_MAX_SIZE + 1).intValue();
		int itemsPerLoop = insertMap.size() / batchCount;
		batchInsert(insertMap,itemsPerLoop);
		
//		Map<String,T> newMap = new HashMap<String, T>();
//		for(int l = 0;l<batchCount;l++){
//			for(int j = l*itemsPerLoop;j<(l+1)*itemsPerLoop;j++){
//				String key = keyList.get(j);
//				newMap.put(key, insertMap.get(key));
//			}
//			batchInsert(newMap,batchCount);
////			batchInsert(newMap,itemsPerLoop);
//		}
		
	}
/**
	 * Perform a batch insert on the collection
	 * @param insertMap
	 */
Perform a batch insert on the collection
@param insertMap
Perform a batch insert on the collection @param insertMap
public void batchInsert(Map<String,T> insertMap) throws MongoException {
		List<String> keyList = new ArrayList<String>(insertMap.keySet());
		if(keyList.size()<1)return;
		T t = insertMap.get(keyList.get(0));
		String serialized = xs.toXML(t);
		int recLen = serialized.length();
		long totalMapSerializedSize = recLen * insertMap.size();
		int batchCount = new Long(totalMapSerializedSize  / BATCH_WRITE_MAX_SIZE + 1).intValue();
		int itemsPerLoop = insertMap.size() / batchCount;
		batchInsert(insertMap,itemsPerLoop);
	}
public void batchInsert ( Map < String , T > insertMap ) throws MongoException { List < String > keyList = new ArrayList < String > ( insertMap . keySet ( ) ) ; if ( keyList . size ( ) < 1 ) return ; T t = insertMap . get ( keyList . get ( 0 ) ) ; String serialized = xs . toXML ( t ) ; int recLen = serialized . length ( ) ; long totalMapSerializedSize = recLen * insertMap . size ( ) ; int batchCount = new Long ( totalMapSerializedSize / BATCH_WRITE_MAX_SIZE + 1 ) . intValue ( ) ; int itemsPerLoop = insertMap . size ( ) / batchCount ; batchInsert ( insertMap , itemsPerLoop ) ; }
Perform a batch insert on the collection
 @param insertMap
Perform a batch insert on the collection @param insertMap
// new routine that calculates batchCount on the fly //		Map<String,T> newMap = new HashMap<String, T>(); //		for(int l = 0;l<batchCount;l++){ //			for(int j = l*itemsPerLoop;j<(l+1)*itemsPerLoop;j++){ //				String key = keyList.get(j); //				newMap.put(key, insertMap.get(key)); //			} //			batchInsert(newMap,batchCount); ////			batchInsert(newMap,itemsPerLoop); //		}