static int getWriteSizeBytes(const WriteOp& writeOp) {
|
const BatchItemRef& item = writeOp.getWriteItem();
|
BatchedCommandRequest::BatchType batchType = item.getOpType();
|
|
if (batchType == BatchedCommandRequest::BatchType_Insert) {
|
return item.getDocument().objsize();
|
} else if (batchType == BatchedCommandRequest::BatchType_Update) {
|
// Note: Be conservative here - it's okay if we send slightly too many batches
|
int estSize = item.getUpdate()->getQuery().objsize() +
|
item.getUpdate()->getUpdateExpr().objsize() + kEstUpdateOverheadBytes;
|
dassert(estSize >= item.getUpdate()->toBSON().objsize());
|
return estSize;
|
} else {
|
dassert(batchType == BatchedCommandRequest::BatchType_Delete);
|
// Note: Be conservative here - it's okay if we send slightly too many batches
|
int estSize = item.getDelete()->getQuery().objsize() + kEstDeleteOverheadBytes;
|
dassert(estSize >= item.getDelete()->toBSON().objsize());
|
return estSize;
|
}
|
}
|