mongous 0.1.8 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.adoc +286 -48
 - data/README.ja.adoc +288 -50
 - data/lib/mongous/base.rb +45 -2
 - data/lib/mongous/document.rb +75 -32
 - data/lib/mongous/extention.rb +74 -55
 - data/lib/mongous/filter.rb +316 -233
 - data/lib/mongous/version.rb +1 -1
 - data/mongous.gemspec +1 -1
 - data/sample/connect_auto_0.rb +9 -0
 - data/sample/declare_compact_1.rb +7 -9
 - data/sample/declare_compact_2.rb +38 -0
 - data/sample/declare_label_1.rb +10 -8
 - data/sample/declare_ndex_1.rb +9 -7
 - data/sample/declare_ndex_2.rb +10 -8
 - data/sample/declare_strict_1.rb +14 -12
 - data/sample/declare_strict_2.rb +5 -5
 - data/sample/{multi_docs_1.rb → multi_collection_1.rb} +0 -2
 - data/sample/multi_collection_2.rb +61 -0
 - data/sample/multi_collection_3.rb +24 -0
 - data/sample/query_basic_1.rb +8 -3
 - data/sample/query_basic_2.rb +11 -6
 - data/sample/query_basic_3.rb +2 -5
 - data/sample/query_basic_4.rb +3 -6
 - data/sample/query_basic_5.rb +2 -5
 - data/sample/query_basic_6.rb +35 -22
 - data/sample/query_detail_1.rb +3 -3
 - data/sample/query_detail_2.rb +3 -3
 - data/sample/query_detail_3.rb +5 -5
 - data/sample/query_filter_1.rb +44 -0
 - data/sample/query_filter_2.rb +48 -0
 - data/sample/{query_super_1.rb → query_find_1.rb} +6 -6
 - data/sample/query_select_1.rb +54 -0
 - data/sample/query_skip_limit_1.rb +48 -0
 - data/sample/query_skip_limit_2.rb +58 -0
 - data/sample/query_sort_1.rb +43 -0
 - data/sample/save_basic_1.rb +2 -7
 - data/sample/save_basic_2.rb +2 -7
 - data/sample/save_basic_3.rb +2 -7
 - data/sample/save_detail_1.rb +7 -6
 - data/sample/save_detail_2.rb +7 -6
 - data/sample/save_detail_3.rb +11 -10
 - data/sample/save_verify_1.rb +7 -6
 - data/sample/save_verify_2.rb +0 -2
 - data/sample/save_verify_3.rb +1 -3
 - data/sample/save_verify_4.rb +0 -2
 - data/sample/save_verify_5.rb +3 -5
 - data/sample/save_verify_6.rb +3 -5
 - data/sample/save_verify_7.rb +21 -0
 - data/sample/update_basic_1.rb +9 -0
 - data/sample/zap_basic_1.rb +1 -5
 - data/sample/zap_basic_2.rb +2 -6
 - data/sample/zap_basic_3.rb +2 -6
 - data/sample/zbenchmark_search_1.rb +114 -0
 - data/sample/zbenchmark_search_2.rb +114 -0
 - data/sample/zbenchmark_search_3.rb +88 -0
 - metadata +20 -12
 - data/sample/multi_docs_2.rb +0 -58
 - data/sample/query_basic_7.rb +0 -38
 - data/sample/query_limit_1.rb +0 -44
 - data/sample/query_order_1.rb +0 -49
 - data/sample/query_projection_1.rb +0 -44
 - data/sample/template_article.rb +0 -5
 - data/sample/template_person.rb +0 -12
 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            require "mongous"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class Book
         
     | 
| 
      
 5 
     | 
    
         
            +
              include  Mongous::Document
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              field  :title,        :must
         
     | 
| 
      
 8 
     | 
    
         
            +
              field  :price,        Integer, (0..1_000_000)
         
     | 
| 
      
 9 
     | 
    
         
            +
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            begin
         
     | 
| 
      
 12 
     | 
    
         
            +
              book  =  Book.new
         
     | 
| 
      
 13 
     | 
    
         
            +
              book.title  =  "title price"
         
     | 
| 
      
 14 
     | 
    
         
            +
              book.price  =  -1
         
     | 
| 
      
 15 
     | 
    
         
            +
              book.save
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            rescue => e
         
     | 
| 
      
 18 
     | 
    
         
            +
              p e.message
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
    
        data/sample/zap_basic_1.rb
    CHANGED
    
    
    
        data/sample/zap_basic_2.rb
    CHANGED
    
    
    
        data/sample/zap_basic_3.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,114 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            require "mongous"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class Card
         
     | 
| 
      
 5 
     | 
    
         
            +
              include  Mongous::Document
         
     | 
| 
      
 6 
     | 
    
         
            +
              field :i1, Integer
         
     | 
| 
      
 7 
     | 
    
         
            +
              field :i2, Integer
         
     | 
| 
      
 8 
     | 
    
         
            +
              field :f1, Float
         
     | 
| 
      
 9 
     | 
    
         
            +
              field :f2, Float
         
     | 
| 
      
 10 
     | 
    
         
            +
              field :s1, String
         
     | 
| 
      
 11 
     | 
    
         
            +
              field :s2, String
         
     | 
| 
      
 12 
     | 
    
         
            +
              field :d1, Date
         
     | 
| 
      
 13 
     | 
    
         
            +
              field :d2, Date
         
     | 
| 
      
 14 
     | 
    
         
            +
              field :t1, Time
         
     | 
| 
      
 15 
     | 
    
         
            +
              field :t2, Time
         
     | 
| 
      
 16 
     | 
    
         
            +
              field :r1, Float
         
     | 
| 
      
 17 
     | 
    
         
            +
              field :r2, Float
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              index :i2, unique: true
         
     | 
| 
      
 20 
     | 
    
         
            +
              index :f2, unique: true
         
     | 
| 
      
 21 
     | 
    
         
            +
              index :s2, unique: true
         
     | 
| 
      
 22 
     | 
    
         
            +
              index :d2, unique: true
         
     | 
| 
      
 23 
     | 
    
         
            +
              index :t2, unique: true
         
     | 
| 
      
 24 
     | 
    
         
            +
              index :r2
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            require "benchmark"
         
     | 
| 
      
 28 
     | 
    
         
            +
            require "date"
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            COUNT = 1000
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            D0  =  Date.parse( "2020-01-01" )
         
     | 
| 
      
 33 
     | 
    
         
            +
            T0  =  D0.to_time
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            Benchmark.bm 32 do |bm|
         
     | 
| 
      
 36 
     | 
    
         
            +
              if COUNT !=  Card.count
         
     | 
| 
      
 37 
     | 
    
         
            +
                Card.delete
         
     | 
| 
      
 38 
     | 
    
         
            +
                bm.report "create #{COUNT}" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                  (0...COUNT).each do |i|
         
     | 
| 
      
 40 
     | 
    
         
            +
                      f  =  i.to_f
         
     | 
| 
      
 41 
     | 
    
         
            +
                      s  =  i.to_s
         
     | 
| 
      
 42 
     | 
    
         
            +
                      d  =  D0 + i
         
     | 
| 
      
 43 
     | 
    
         
            +
                      t  =  T0 + i
         
     | 
| 
      
 44 
     | 
    
         
            +
                      r  =  rand
         
     | 
| 
      
 45 
     | 
    
         
            +
                      card  =  Card.create(
         
     | 
| 
      
 46 
     | 
    
         
            +
                        i1: i,
         
     | 
| 
      
 47 
     | 
    
         
            +
                        i2: i,
         
     | 
| 
      
 48 
     | 
    
         
            +
                        f1: f,
         
     | 
| 
      
 49 
     | 
    
         
            +
                        f2: f,
         
     | 
| 
      
 50 
     | 
    
         
            +
                        s1: s,
         
     | 
| 
      
 51 
     | 
    
         
            +
                        s2: s,
         
     | 
| 
      
 52 
     | 
    
         
            +
                        d1: d,
         
     | 
| 
      
 53 
     | 
    
         
            +
                        d2: d,
         
     | 
| 
      
 54 
     | 
    
         
            +
                        t1: t,
         
     | 
| 
      
 55 
     | 
    
         
            +
                        t2: t,
         
     | 
| 
      
 56 
     | 
    
         
            +
                        r1: r,
         
     | 
| 
      
 57 
     | 
    
         
            +
                        r2: r,
         
     | 
| 
      
 58 
     | 
    
         
            +
                      )
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              bm.report "find a integer without index" do
         
     | 
| 
      
 64 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 65 
     | 
    
         
            +
                  Card.where( i1: i ).first
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
              bm.report "find a integer with    index" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 70 
     | 
    
         
            +
                  Card.where( i2: i ).first
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
              bm.report "find a float   without index" do
         
     | 
| 
      
 74 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 75 
     | 
    
         
            +
                  Card.where( f1: i.to_f ).first
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
              bm.report "find a float   with    index" do
         
     | 
| 
      
 79 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 80 
     | 
    
         
            +
                  Card.where( f2: i.to_f ).first
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
              bm.report "find a string  without index" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 85 
     | 
    
         
            +
                  Card.where( s1: i.to_s ).first
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
              end
         
     | 
| 
      
 88 
     | 
    
         
            +
              bm.report "find a string  with    index" do
         
     | 
| 
      
 89 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 90 
     | 
    
         
            +
                  Card.where( s2: i.to_s ).first
         
     | 
| 
      
 91 
     | 
    
         
            +
                end
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
              bm.report "find a date    without index" do
         
     | 
| 
      
 94 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 95 
     | 
    
         
            +
                  Card.where( d1: D0 + i ).first
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
              bm.report "find a date    with    index" do
         
     | 
| 
      
 99 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 100 
     | 
    
         
            +
                  Card.where( d2: D0 + i ).first
         
     | 
| 
      
 101 
     | 
    
         
            +
                end
         
     | 
| 
      
 102 
     | 
    
         
            +
              end
         
     | 
| 
      
 103 
     | 
    
         
            +
              bm.report "find a time    without index" do
         
     | 
| 
      
 104 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 105 
     | 
    
         
            +
                  Card.where( t1: T0 + i ).first
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
              bm.report "find a time    with    index" do
         
     | 
| 
      
 109 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 110 
     | 
    
         
            +
                  Card.where( t2: T0 + i ).first
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
            end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,114 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            require "mongous"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class Card
         
     | 
| 
      
 5 
     | 
    
         
            +
              include  Mongous::Document
         
     | 
| 
      
 6 
     | 
    
         
            +
              field :i1, Integer
         
     | 
| 
      
 7 
     | 
    
         
            +
              field :i2, Integer
         
     | 
| 
      
 8 
     | 
    
         
            +
              field :f1, Float
         
     | 
| 
      
 9 
     | 
    
         
            +
              field :f2, Float
         
     | 
| 
      
 10 
     | 
    
         
            +
              field :s1, String
         
     | 
| 
      
 11 
     | 
    
         
            +
              field :s2, String
         
     | 
| 
      
 12 
     | 
    
         
            +
              field :d1, Date
         
     | 
| 
      
 13 
     | 
    
         
            +
              field :d2, Date
         
     | 
| 
      
 14 
     | 
    
         
            +
              field :t1, Time
         
     | 
| 
      
 15 
     | 
    
         
            +
              field :t2, Time
         
     | 
| 
      
 16 
     | 
    
         
            +
              field :r1, Float
         
     | 
| 
      
 17 
     | 
    
         
            +
              field :r2, Float
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              index :i2, unique: true
         
     | 
| 
      
 20 
     | 
    
         
            +
              index :f2, unique: true
         
     | 
| 
      
 21 
     | 
    
         
            +
              index :s2, unique: true
         
     | 
| 
      
 22 
     | 
    
         
            +
              index :d2, unique: true
         
     | 
| 
      
 23 
     | 
    
         
            +
              index :t2, unique: true
         
     | 
| 
      
 24 
     | 
    
         
            +
              index :r2
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            require "benchmark"
         
     | 
| 
      
 28 
     | 
    
         
            +
            require "date"
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            COUNT = 1000
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            D0  =  Date.parse( "2020-01-01" )
         
     | 
| 
      
 33 
     | 
    
         
            +
            T0  =  D0.to_time
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            Benchmark.bm 32 do |bm|
         
     | 
| 
      
 36 
     | 
    
         
            +
              if COUNT !=  Card.count
         
     | 
| 
      
 37 
     | 
    
         
            +
                Card.delete
         
     | 
| 
      
 38 
     | 
    
         
            +
                bm.report "create #{COUNT}" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                  (0...COUNT).each do |i|
         
     | 
| 
      
 40 
     | 
    
         
            +
                      f  =  i.to_f
         
     | 
| 
      
 41 
     | 
    
         
            +
                      s  =  i.to_s
         
     | 
| 
      
 42 
     | 
    
         
            +
                      d  =  D0 + i
         
     | 
| 
      
 43 
     | 
    
         
            +
                      t  =  T0 + i
         
     | 
| 
      
 44 
     | 
    
         
            +
                      r  =  rand
         
     | 
| 
      
 45 
     | 
    
         
            +
                      card  =  Card.create(
         
     | 
| 
      
 46 
     | 
    
         
            +
                        i1: i,
         
     | 
| 
      
 47 
     | 
    
         
            +
                        i2: i,
         
     | 
| 
      
 48 
     | 
    
         
            +
                        f1: f,
         
     | 
| 
      
 49 
     | 
    
         
            +
                        f2: f,
         
     | 
| 
      
 50 
     | 
    
         
            +
                        s1: s,
         
     | 
| 
      
 51 
     | 
    
         
            +
                        s2: s,
         
     | 
| 
      
 52 
     | 
    
         
            +
                        d1: d,
         
     | 
| 
      
 53 
     | 
    
         
            +
                        d2: d,
         
     | 
| 
      
 54 
     | 
    
         
            +
                        t1: t,
         
     | 
| 
      
 55 
     | 
    
         
            +
                        t2: t,
         
     | 
| 
      
 56 
     | 
    
         
            +
                        r1: r,
         
     | 
| 
      
 57 
     | 
    
         
            +
                        r2: r,
         
     | 
| 
      
 58 
     | 
    
         
            +
                      )
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              bm.report "find range integer without index" do
         
     | 
| 
      
 64 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 65 
     | 
    
         
            +
                  Card.where( i1: ( i ... (i+10) ) ).all
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
              bm.report "find range integer with    index" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 70 
     | 
    
         
            +
                  Card.where( i2: ( i ... (i+10) ) ).all
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
              bm.report "find range float   without index" do
         
     | 
| 
      
 74 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 75 
     | 
    
         
            +
                  Card.where( f1: ( i.to_f ... (i+10).to_f ) ).all
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
              bm.report "find range float   with    index" do
         
     | 
| 
      
 79 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 80 
     | 
    
         
            +
                  Card.where( f2: ( i.to_f ... (i+10).to_f ) ).all
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
              bm.report "find range string  without index" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 85 
     | 
    
         
            +
                  Card.where( s1: ( i.to_s ... (i+10).to_s ) ).all
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
              end
         
     | 
| 
      
 88 
     | 
    
         
            +
              bm.report "find range string  with    index" do
         
     | 
| 
      
 89 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 90 
     | 
    
         
            +
                  Card.where( s2: ( i.to_s ... (i+10).to_s ) ).all
         
     | 
| 
      
 91 
     | 
    
         
            +
                end
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
              bm.report "find range date    without index" do
         
     | 
| 
      
 94 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 95 
     | 
    
         
            +
                  Card.where( d1: ( (D0 + i) ... (D0 + i + 10) ) ).all
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
              bm.report "find range date    with    index" do
         
     | 
| 
      
 99 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 100 
     | 
    
         
            +
                  Card.where( d2: ( (D0 + i) ... (D0 + i + 10) ) ).all
         
     | 
| 
      
 101 
     | 
    
         
            +
                end
         
     | 
| 
      
 102 
     | 
    
         
            +
              end
         
     | 
| 
      
 103 
     | 
    
         
            +
              bm.report "find range time    without index" do
         
     | 
| 
      
 104 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 105 
     | 
    
         
            +
                  Card.where( t1: ( (T0 + i) ... (T0 + i + 10) ) ).all
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
              bm.report "find range time    with    index" do
         
     | 
| 
      
 109 
     | 
    
         
            +
                (0...COUNT).each do |i|
         
     | 
| 
      
 110 
     | 
    
         
            +
                  Card.where( t2: ( (T0 + i) ... (T0 + i + 10) ) ).all
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
            end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,88 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            require "mongous"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class Plate
         
     | 
| 
      
 5 
     | 
    
         
            +
              include  Mongous::Document
         
     | 
| 
      
 6 
     | 
    
         
            +
              field :i1, Integer
         
     | 
| 
      
 7 
     | 
    
         
            +
              field :i2, Integer
         
     | 
| 
      
 8 
     | 
    
         
            +
              field :f1, Float
         
     | 
| 
      
 9 
     | 
    
         
            +
              field :f2, Float
         
     | 
| 
      
 10 
     | 
    
         
            +
              field :s1, String
         
     | 
| 
      
 11 
     | 
    
         
            +
              field :s2, String
         
     | 
| 
      
 12 
     | 
    
         
            +
              field :d1, Date
         
     | 
| 
      
 13 
     | 
    
         
            +
              field :d2, Date
         
     | 
| 
      
 14 
     | 
    
         
            +
              field :t1, Time
         
     | 
| 
      
 15 
     | 
    
         
            +
              field :t2, Time
         
     | 
| 
      
 16 
     | 
    
         
            +
              field :r1, Float
         
     | 
| 
      
 17 
     | 
    
         
            +
              field :r2, Float
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              index :i2, unique: true
         
     | 
| 
      
 20 
     | 
    
         
            +
              index :f2, unique: true
         
     | 
| 
      
 21 
     | 
    
         
            +
              index :s2, unique: true
         
     | 
| 
      
 22 
     | 
    
         
            +
              index :d2, unique: true
         
     | 
| 
      
 23 
     | 
    
         
            +
              index :t2, unique: true
         
     | 
| 
      
 24 
     | 
    
         
            +
              index :r2
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            require "benchmark"
         
     | 
| 
      
 28 
     | 
    
         
            +
            require "date"
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            COUNT = 100000
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            D0  =  Date.parse( "2020-01-01" )
         
     | 
| 
      
 33 
     | 
    
         
            +
            T0  =  D0.to_time
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            Benchmark.bm 40 do |bm|
         
     | 
| 
      
 36 
     | 
    
         
            +
              if COUNT !=  Plate.count
         
     | 
| 
      
 37 
     | 
    
         
            +
                Plate.delete
         
     | 
| 
      
 38 
     | 
    
         
            +
                bm.report "create #{COUNT}" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                  (0...COUNT).each do |i|
         
     | 
| 
      
 40 
     | 
    
         
            +
                      f  =  i.to_f
         
     | 
| 
      
 41 
     | 
    
         
            +
                      s  =  i.to_s
         
     | 
| 
      
 42 
     | 
    
         
            +
                      d  =  D0 + i
         
     | 
| 
      
 43 
     | 
    
         
            +
                      t  =  T0 + i
         
     | 
| 
      
 44 
     | 
    
         
            +
                      r  =  rand
         
     | 
| 
      
 45 
     | 
    
         
            +
                      card  =  Plate.create(
         
     | 
| 
      
 46 
     | 
    
         
            +
                        i1: i,
         
     | 
| 
      
 47 
     | 
    
         
            +
                        i2: i,
         
     | 
| 
      
 48 
     | 
    
         
            +
                        f1: f,
         
     | 
| 
      
 49 
     | 
    
         
            +
                        f2: f,
         
     | 
| 
      
 50 
     | 
    
         
            +
                        s1: s,
         
     | 
| 
      
 51 
     | 
    
         
            +
                        s2: s,
         
     | 
| 
      
 52 
     | 
    
         
            +
                        d1: d,
         
     | 
| 
      
 53 
     | 
    
         
            +
                        d2: d,
         
     | 
| 
      
 54 
     | 
    
         
            +
                        t1: t,
         
     | 
| 
      
 55 
     | 
    
         
            +
                        t2: t,
         
     | 
| 
      
 56 
     | 
    
         
            +
                        r1: r,
         
     | 
| 
      
 57 
     | 
    
         
            +
                        r2: r,
         
     | 
| 
      
 58 
     | 
    
         
            +
                      )
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              bm.report "first,  order by asc   without index" do
         
     | 
| 
      
 64 
     | 
    
         
            +
                Plate.sort( r1: 1 ).first
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
              bm.report "first,  order by desc  without index" do
         
     | 
| 
      
 67 
     | 
    
         
            +
                Plate.sort( r1: -1 ).first
         
     | 
| 
      
 68 
     | 
    
         
            +
              end
         
     | 
| 
      
 69 
     | 
    
         
            +
              bm.report "top 10, order by asc   without index" do
         
     | 
| 
      
 70 
     | 
    
         
            +
                Plate.sort( r1: 1 )[0,10].all
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
              bm.report "top 10, order by desc  without index" do
         
     | 
| 
      
 73 
     | 
    
         
            +
                Plate.sort( r1: -1 )[0,10].all
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
              bm.report "first,  order by asc   with    index" do
         
     | 
| 
      
 76 
     | 
    
         
            +
                Plate.sort( r2: 1 ).first
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
              bm.report "first,  order by desc  with    index" do
         
     | 
| 
      
 79 
     | 
    
         
            +
                Plate.sort( r2: -1 ).first
         
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
              bm.report "top 10, order by asc   with    index" do
         
     | 
| 
      
 82 
     | 
    
         
            +
                Plate.sort( r2: 1 )[0,10].all
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
              bm.report "top 10, order by desc  with    index" do
         
     | 
| 
      
 85 
     | 
    
         
            +
                Plate.sort( r2: -1 )[0,10].all
         
     | 
| 
      
 86 
     | 
    
         
            +
              end
         
     | 
| 
      
 87 
     | 
    
         
            +
            end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mongous
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - arimay
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2020- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-12-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: mongo
         
     | 
| 
         @@ -52,7 +52,7 @@ dependencies: 
     | 
|
| 
       52 
52 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '3.0'
         
     | 
| 
       55 
     | 
    
         
            -
            description: " Yet another  
     | 
| 
      
 55 
     | 
    
         
            +
            description: " Yet another mongo wrapper library. "
         
     | 
| 
       56 
56 
     | 
    
         
             
            email:
         
     | 
| 
       57 
57 
     | 
    
         
             
            - arima.yasuhiro@gmail.com
         
     | 
| 
       58 
58 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -75,6 +75,7 @@ files: 
     | 
|
| 
       75 
75 
     | 
    
         
             
            - lib/mongous/filter.rb
         
     | 
| 
       76 
76 
     | 
    
         
             
            - lib/mongous/version.rb
         
     | 
| 
       77 
77 
     | 
    
         
             
            - mongous.gemspec
         
     | 
| 
      
 78 
     | 
    
         
            +
            - sample/connect_auto_0.rb
         
     | 
| 
       78 
79 
     | 
    
         
             
            - sample/connect_auto_1.rb
         
     | 
| 
       79 
80 
     | 
    
         
             
            - sample/connect_auto_2.rb
         
     | 
| 
       80 
81 
     | 
    
         
             
            - sample/connect_default_1.rb
         
     | 
| 
         @@ -85,27 +86,31 @@ files: 
     | 
|
| 
       85 
86 
     | 
    
         
             
            - sample/connect_loadfile_2.rb
         
     | 
| 
       86 
87 
     | 
    
         
             
            - sample/connect_mongo.yml
         
     | 
| 
       87 
88 
     | 
    
         
             
            - sample/declare_compact_1.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
            - sample/declare_compact_2.rb
         
     | 
| 
       88 
90 
     | 
    
         
             
            - sample/declare_label_1.rb
         
     | 
| 
       89 
91 
     | 
    
         
             
            - sample/declare_ndex_1.rb
         
     | 
| 
       90 
92 
     | 
    
         
             
            - sample/declare_ndex_2.rb
         
     | 
| 
       91 
93 
     | 
    
         
             
            - sample/declare_strict_1.rb
         
     | 
| 
       92 
94 
     | 
    
         
             
            - sample/declare_strict_2.rb
         
     | 
| 
       93 
     | 
    
         
            -
            - sample/ 
     | 
| 
       94 
     | 
    
         
            -
            - sample/ 
     | 
| 
      
 95 
     | 
    
         
            +
            - sample/multi_collection_1.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            - sample/multi_collection_2.rb
         
     | 
| 
      
 97 
     | 
    
         
            +
            - sample/multi_collection_3.rb
         
     | 
| 
       95 
98 
     | 
    
         
             
            - sample/query_basic_1.rb
         
     | 
| 
       96 
99 
     | 
    
         
             
            - sample/query_basic_2.rb
         
     | 
| 
       97 
100 
     | 
    
         
             
            - sample/query_basic_3.rb
         
     | 
| 
       98 
101 
     | 
    
         
             
            - sample/query_basic_4.rb
         
     | 
| 
       99 
102 
     | 
    
         
             
            - sample/query_basic_5.rb
         
     | 
| 
       100 
103 
     | 
    
         
             
            - sample/query_basic_6.rb
         
     | 
| 
       101 
     | 
    
         
            -
            - sample/query_basic_7.rb
         
     | 
| 
       102 
104 
     | 
    
         
             
            - sample/query_detail_1.rb
         
     | 
| 
       103 
105 
     | 
    
         
             
            - sample/query_detail_2.rb
         
     | 
| 
       104 
106 
     | 
    
         
             
            - sample/query_detail_3.rb
         
     | 
| 
       105 
     | 
    
         
            -
            - sample/ 
     | 
| 
       106 
     | 
    
         
            -
            - sample/ 
     | 
| 
       107 
     | 
    
         
            -
            - sample/ 
     | 
| 
       108 
     | 
    
         
            -
            - sample/ 
     | 
| 
      
 107 
     | 
    
         
            +
            - sample/query_filter_1.rb
         
     | 
| 
      
 108 
     | 
    
         
            +
            - sample/query_filter_2.rb
         
     | 
| 
      
 109 
     | 
    
         
            +
            - sample/query_find_1.rb
         
     | 
| 
      
 110 
     | 
    
         
            +
            - sample/query_select_1.rb
         
     | 
| 
      
 111 
     | 
    
         
            +
            - sample/query_skip_limit_1.rb
         
     | 
| 
      
 112 
     | 
    
         
            +
            - sample/query_skip_limit_2.rb
         
     | 
| 
      
 113 
     | 
    
         
            +
            - sample/query_sort_1.rb
         
     | 
| 
       109 
114 
     | 
    
         
             
            - sample/save_basic_1.rb
         
     | 
| 
       110 
115 
     | 
    
         
             
            - sample/save_basic_2.rb
         
     | 
| 
       111 
116 
     | 
    
         
             
            - sample/save_basic_3.rb
         
     | 
| 
         @@ -118,11 +123,14 @@ files: 
     | 
|
| 
       118 
123 
     | 
    
         
             
            - sample/save_verify_4.rb
         
     | 
| 
       119 
124 
     | 
    
         
             
            - sample/save_verify_5.rb
         
     | 
| 
       120 
125 
     | 
    
         
             
            - sample/save_verify_6.rb
         
     | 
| 
       121 
     | 
    
         
            -
            - sample/ 
     | 
| 
       122 
     | 
    
         
            -
            - sample/ 
     | 
| 
      
 126 
     | 
    
         
            +
            - sample/save_verify_7.rb
         
     | 
| 
      
 127 
     | 
    
         
            +
            - sample/update_basic_1.rb
         
     | 
| 
       123 
128 
     | 
    
         
             
            - sample/zap_basic_1.rb
         
     | 
| 
       124 
129 
     | 
    
         
             
            - sample/zap_basic_2.rb
         
     | 
| 
       125 
130 
     | 
    
         
             
            - sample/zap_basic_3.rb
         
     | 
| 
      
 131 
     | 
    
         
            +
            - sample/zbenchmark_search_1.rb
         
     | 
| 
      
 132 
     | 
    
         
            +
            - sample/zbenchmark_search_2.rb
         
     | 
| 
      
 133 
     | 
    
         
            +
            - sample/zbenchmark_search_3.rb
         
     | 
| 
       126 
134 
     | 
    
         
             
            homepage: https://github.com/arimay/mongous
         
     | 
| 
       127 
135 
     | 
    
         
             
            licenses:
         
     | 
| 
       128 
136 
     | 
    
         
             
            - MIT
         
     |