// capped collection of size 1
db.getCollection(HEAD_COLLECTION).insert(new BasicDBObject(ID_FIELD, id.getBytes()));
}
public void readNode(StoredNode node) throws NotFoundException, Exception {
Id id = node.getId();
BasicDBObject key = new BasicDBObject();
if (BINARY_FORMAT) {
key.put(ID_FIELD, id.getBytes());
} else {
key.put(ID_FIELD, id.toString());
}
final BasicDBObject nodeObject = (BasicDBObject) nodes.findOne(key);
if (nodeObject != null) {
Binding binding;
if (BINARY_FORMAT) {
byte[] bytes = (byte[]) nodeObject.get(DATA_FIELD);
binding = new BinaryBinding(new ByteArrayInputStream(bytes));
} else {
binding = new DBObjectBinding(nodeObject);
}
node.deserialize(binding);
} else {
throw new NotFoundException(id.toString());
}
}