[DOCS-4061] Comment on: "manual/reference/command/cloneCollectionAsCapped.txt" Created: 18/Sep/14  Updated: 08/Dec/16  Resolved: 10/Oct/14

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: v1.3.12

Type: Improvement Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Andrew Aldridge
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB V2.6.4 64bits, Windows 7 64bits

Location: http://docs.mongodb.org/manual/reference/command/cloneCollectionAsCapped/#dbcmd.cloneCollectionAsCapped
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
Referrer: http://docs.mongodb.org/manual/reference/command/nav-administration/
Screen Resolution: 1920 x 1080
repo: docs
source: reference/command/cloneCollectionAsCapped


Participants:
Days since reply: 9 years, 18 weeks, 5 days ago

 Description   

At the bottom of this page
(http://docs.mongodb.org/manual/reference/command/cloneCollectionAsCapped/#clonecollectionascapped)
has below descriptions:

If the capped size specified for the new collection is smaller than the size of the original uncapped collection, then MongoDB will begin overwriting earlier documents in insertion order, which is first in, first out (e.g “FIFO”).

Then I tried below:

> db.a.find()
{ "_id" : ObjectId("541a400220086dae8eb095ba"), "b" : 1 }
{ "_id" : ObjectId("541a4463668ac6bf3d1da31d"), "a$a" : 1 }
> db.a.stats()
{
        "ns" : "test.a",
        "count" : 2,
        "size" : 92,
        "avgObjSize" : 46,
        "storageSize" : 4096,
        "numExtents" : 1,
        "nindexes" : 1,
        "lastExtentSize" : 4096,
        "paddingFactor" : 1,
        "systemFlags" : 1,
        "userFlags" : 0,
        "totalIndexSize" : 8176,
        "indexSizes" : {
                "_id_" : 8176
        },
        "ok" : 1
}
 
> db.runCommand({cloneCollectionAsCapped:"a", toCollection:"aa", size:1}); // capped size specified is 1 byte
{ "ok" : 1 }
 
> db.aa.find();
{ "_id" : ObjectId("541a400220086dae8eb095ba"), "b" : 1 }
{ "_id" : ObjectId("541a4463668ac6bf3d1da31d"), "a$a" : 1 }
> db.aa.stats()
{
        "ns" : "test.aa",
        "count" : 2,
        "size" : 72,
        "avgObjSize" : 36,
        "storageSize" : 4096,
        "numExtents" : 1,
        "nindexes" : 1,
        "lastExtentSize" : 4096,
        "paddingFactor" : 1,
        "systemFlags" : 1,
        "userFlags" : 0,
        "totalIndexSize" : 8176,
        "indexSizes" : {
                "_id_" : 8176
        },
        "capped" : true,
        "max" : NumberLong("9223372036854775807"),
        "ok" : 1
}

No data have been overwritten in capped collection aa even though I specified a capped size which is smaller than the original collection's.
The size I provided (1 byte) will be converted to ceil-integer times of extent size (4096 bytes). Is it right?



 Comments   
Comment by Githook User [ 10/Oct/14 ]

Author:

{u'username': u'i80and', u'name': u'Andrew Aldridge', u'email': u'i80and@foxquill.com'}

Message: DOCS-4061: Capped collection documentation

Signed-off-by: Sam Kleinman <samk@10gen.com>
Branch: master
https://github.com/mongodb/docs/commit/5295ce340bd4fa196960e95a876a3dd1e59e7594

Generated at Thu Feb 08 07:47:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.