public BSONObject validate() { BSONObject response = new BasicBSONObject("ns", getFullName()); response.put("extentCount", Integer.valueOf(0)); response.put("datasize", Long.valueOf(dataSize.get())); response.put("nrecords", Integer.valueOf(documents.size())); response.put("padding", Integer.valueOf(1)); response.put("deletedCount", Integer.valueOf(emptyPositions.size())); response.put("deletedSize", Integer.valueOf(0)); response.put("nIndexes", Integer.valueOf(indexes.size())); BSONObject keysPerIndex = new BasicBSONObject(); for (Index index : indexes) { keysPerIndex.put(index.getName(), Long.valueOf(index.getCount())); } response.put("keysPerIndex", keysPerIndex); response.put("valid", Boolean.TRUE); response.put("errors", Arrays.asList()); Utils.markOkay(response); return response; }
public BSONObject getStats() { BSONObject response = new BasicBSONObject("ns", getFullName()); response.put("count", Integer.valueOf(documents.size())); response.put("size", Long.valueOf(dataSize.get())); double averageSize = 0; if (!documents.isEmpty()) { averageSize = dataSize.get() / (double) documents.size(); } response.put("avgObjSize", Double.valueOf(averageSize)); response.put("storageSize", Integer.valueOf(0)); response.put("numExtents", Integer.valueOf(0)); response.put("nindexes", Integer.valueOf(indexes.size())); BSONObject indexSizes = new BasicBSONObject(); for (Index index : indexes) { indexSizes.put(index.getName(), Long.valueOf(index.getDataSize())); } response.put("indexSize", indexSizes); Utils.markOkay(response); return response; }