Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4542

Option "size" for capped collections

    Details

    • Type: Question
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      In docs:

      Unlike a standard collection, you must explicitly create a capped collection, specifying a collection size in bytes. The collection's data space is then preallocated. Note that the size specified includes database headers.

      But if we take a look at the following code, the insertion of document that larger 10 bytes is possible:

      Mongo m = new Mongo();
      DB db = m.getDB("test");
      db.createCollection("cn", BasicDBObjectBuilder.start()
              .add("size", 10)
              .add("capped", true)
              .get());
      DBCollection collection = db.getCollection("cn");
      collection.insert(BasicDBObjectBuilder.start()
              .add("field", "datadatadatadatadatadatadatadata")
              .add("maxLong", Long.MAX_VALUE)
              .add("minLong", Long.MIN_VALUE)
              .get()
      );
      System.out.println(collection.findOne());

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: