All Downloads are FREE. Search and download functionalities are using the official Maven repository.

activities.mongodb-crud-dataset.yaml Maven / Gradle / Ivy

There is a newer version: 5.17.0
Show newest version
# nb -v run driver=mongodb yaml=mongodb-crud-dataset tags=phase:schema connection=mongodb://127.0.0.1 database=testdb dataset_file=path/to/data.json

description: |
  This workload emulates CRUD operations for the mongoDB.
  It requires a data set file, where each line is a single JSON document to be used for writes and updates.
  It's a counterpart of the Stargate's Documents API CRUD Dataset workflow.

scenarios:
  default:
    schema:   run driver=mongodb tags==phase:schema threads==1 cycles==UNDEF
    write:    run driver=mongodb tags==phase:main,type:write cycles===TEMPLATE(write-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
    read:     run driver=mongodb tags==phase:main,type:read cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
    update:   run driver=mongodb tags==phase:main,type:update cycles===TEMPLATE(update-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
    delete:   run driver=mongodb tags==phase:main,type:delete cycles===TEMPLATE(delete-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn

bindings:
  seq_key: Mod(<>); ToString() -> String
  random_key: Uniform(0,<>); ToString() -> String

blocks:
  - tags:
      phase: schema
    statements:
      - dummy-insert: |
          {
            insert: "<>",
            documents: [ { _id: "dummyyyy" } ]
          }

      - drop-collection: |
          {
            drop: "<>"
          }
        tags:
          name: drop-collection

      - create-collection: |
          {
            create: "<>"
          }
        tags:
          name: create-collection

      - create-indexes: |
          {
            createIndexes: "<>",
            indexes: <>
          }
        tags:
          name: create-indexes

  - name: main-write
    tags:
      phase: main
      type: write
    statements:
      - write-document: |
          {
            insert: "<>",
            writeConcern: { w: "majority" },
            documents: [ { "_id": "{seq_key}", {document_json_without_id} ]
          }
        tags:
          name: write-document
    bindings:
      document_json_without_id: ModuloLineToString('<>'); ReplaceRegex('^\{', '')

  - name: main-read
    tags:
      phase: main
      type: read
    statements:
      - read-document: |
          {
            find: "<>",
            filter: { _id: "{random_key}" }
          }
        tags:
          name: read-document

  - name: main-update
    tags:
      phase: main
      type: update
    statements:
      - update-document: |
          {
            update: "<>",
            writeConcern: { w: "majority" },
            updates: [
              {
                q: { _id: "{random_key}" },
                u: { "_id": "{random_key}", {document_json_without_id}
              }
            ]
          }
        tags:
          name: update-document
    bindings:
      document_json_without_id: ModuloLineToString('<>'); ReplaceRegex('^\{', '')

  - name: main-delete
    tags:
      phase: main
      type: delete
    statements:
      - delete-document: |
          {
            delete: "<>",
            deletes: [
              {
                q: { _id: "{seq_key}" },
                limit: 1
              }
            ]
          }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy