~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/mongo/dbtests/btreetests.inl

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
336
336
            start.appendMinKey( "a" );
337
337
            BSONObjBuilder end;
338
338
            end.appendMaxKey( "a" );
339
 
            auto_ptr< BtreeCursor > c( BtreeCursor::make( nsdetails( ns() ), 1, id(), start.done(), end.done(), false, 1 ) );
 
339
            auto_ptr< BtreeCursor > c( BtreeCursor::make( nsdetails( ns() ),
 
340
                                                          id(),
 
341
                                                          start.done(),
 
342
                                                          end.done(),
 
343
                                                          false,
 
344
                                                          1 ) );
340
345
            while( c->ok() ) {
341
346
                if ( c->curKeyHasChild() ) {
342
347
                    toDel.push_back( c->currKey().firstElement().valuestr() );
393
398
            end.appendMaxKey( "a" );
394
399
            BSONObj l = bt()->keyNode( 0 ).key.toBson();
395
400
            string toInsert;
396
 
            auto_ptr< BtreeCursor > c( BtreeCursor::make( nsdetails( ns() ), 1, id(), start.done(), end.done(), false, 1 ) );
 
401
            auto_ptr< BtreeCursor > c( BtreeCursor::make( nsdetails( ns() ),
 
402
                                                          id(),
 
403
                                                          start.done(),
 
404
                                                          end.done(),
 
405
                                                          false,
 
406
                                                          1 ) );
397
407
            while( c->ok() ) {
398
408
                if ( c->currKey().woCompare( l ) > 0 ) {
399
409
                    toInsert = c->currKey().firstElement().valuestr();
420
430
            }
421
431
//            dump();
422
432
            string ns = id().indexNamespace();
423
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
433
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
424
434
            int expectedCount = 10 - unindexKeys();
425
435
//            dump();
426
 
            ASSERT_EQUALS( 1, nsdetails( ns.c_str() )->stats.nrecords );
 
436
            ASSERT_EQUALS( 1, nsdetails( ns )->stats.nrecords );
427
437
            long long unused = 0;
428
438
            ASSERT_EQUALS( expectedCount, bt()->fullValidate( dl(), order(), &unused, true ) );
429
439
            ASSERT_EQUALS( 0, unused );
474
484
            }
475
485
            //            dump();
476
486
            string ns = id().indexNamespace();
477
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
487
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
478
488
            BSONObj k = key( 'a' + 17 );
479
489
            unindex( k );
480
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
490
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
481
491
            long long unused = 0;
482
492
            ASSERT_EQUALS( 17, bt()->fullValidate( dl(), order(), &unused, true ) );
483
493
            ASSERT_EQUALS( 0, unused );
618
628
//            dump();
619
629
            string ns = id().indexNamespace();
620
630
            ASSERT_EQUALS( 8, bt()->fullValidate( dl(), order(), 0, true ) );
621
 
            ASSERT_EQUALS( 7, nsdetails( ns.c_str() )->stats.nrecords );
 
631
            ASSERT_EQUALS( 7, nsdetails( ns )->stats.nrecords );
622
632
 
623
633
            BSONObj k = BSON( "" << "bb" );
624
634
            verify( unindex( k ) );
625
635
//            dump();
626
636
            ASSERT_EQUALS( 7, bt()->fullValidate( dl(), order(), 0, true ) );
627
 
            ASSERT_EQUALS( 5, nsdetails( ns.c_str() )->stats.nrecords );
 
637
            ASSERT_EQUALS( 5, nsdetails( ns )->stats.nrecords );
628
638
            ArtificialTree::checkStructure( "{b:{a:null},d:{c:null},f:{e:null},_:{g:null}}", id() );
629
639
        }
630
640
    };
636
646
//            dump();
637
647
            string ns = id().indexNamespace();
638
648
            ASSERT_EQUALS( 10, bt()->fullValidate( dl(), order(), 0, true ) );
639
 
            ASSERT_EQUALS( 7, nsdetails( ns.c_str() )->stats.nrecords );
 
649
            ASSERT_EQUALS( 7, nsdetails( ns )->stats.nrecords );
640
650
 
641
651
            BSONObj k = BSON( "" << "bb" );
642
652
            verify( unindex( k ) );
643
653
//            dump();
644
654
            ASSERT_EQUALS( 9, bt()->fullValidate( dl(), order(), 0, true ) );
645
 
            ASSERT_EQUALS( 5, nsdetails( ns.c_str() )->stats.nrecords );
 
655
            ASSERT_EQUALS( 5, nsdetails( ns )->stats.nrecords );
646
656
            ArtificialTree::checkStructure( "{b:{a:null},cc:{c:null},d:null,f:{e:null},h:{g:null}}", id() );
647
657
        }
648
658
    };
655
665
//            dump();
656
666
            string ns = id().indexNamespace();
657
667
            ASSERT_EQUALS( 4, bt()->fullValidate( dl(), order(), 0, true ) );
658
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
668
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
659
669
            BSONObj k = BSON( "" << "c" );
660
670
            verify( unindex( k ) );
661
671
//            dump();
662
672
            ASSERT_EQUALS( 3, bt()->fullValidate( dl(), order(), 0, true ) );
663
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
673
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
664
674
            ArtificialTree::checkStructure( "{d:{b:{a:null}}}", id() );
665
675
        }
666
676
    };
672
682
//            dump();
673
683
            string ns = id().indexNamespace();
674
684
            ASSERT_EQUALS( 11, bt()->fullValidate( dl(), order(), 0, true ) );
675
 
            ASSERT_EQUALS( 7, nsdetails( ns.c_str() )->stats.nrecords );
 
685
            ASSERT_EQUALS( 7, nsdetails( ns )->stats.nrecords );
676
686
 
677
687
            BSONObj k = BSON( "" << "bb" );
678
688
            verify( unindex( k ) );
679
689
//            dump();
680
690
            ASSERT_EQUALS( 10, bt()->fullValidate( dl(), order(), 0, true ) );
681
691
            // child does not currently replace parent in this case
682
 
            ASSERT_EQUALS( 6, nsdetails( ns.c_str() )->stats.nrecords );
 
692
            ASSERT_EQUALS( 6, nsdetails( ns )->stats.nrecords );
683
693
            ArtificialTree::checkStructure( "{i:{b:{a:null},cc:{c:null},d:null,f:{e:null},h:{g:null}}}", id() );
684
694
        }
685
695
    };
691
701
//            dump();
692
702
            string ns = id().indexNamespace();
693
703
            ASSERT_EQUALS( 11, bt()->fullValidate( dl(), order(), 0, true ) );
694
 
            ASSERT_EQUALS( 7, nsdetails( ns.c_str() )->stats.nrecords );
 
704
            ASSERT_EQUALS( 7, nsdetails( ns )->stats.nrecords );
695
705
 
696
706
            BSONObj k = BSON( "" << "ff" );
697
707
            verify( unindex( k ) );
698
708
//            dump();
699
709
            ASSERT_EQUALS( 10, bt()->fullValidate( dl(), order(), 0, true ) );
700
710
            // child does not currently replace parent in this case
701
 
            ASSERT_EQUALS( 6, nsdetails( ns.c_str() )->stats.nrecords );
 
711
            ASSERT_EQUALS( 6, nsdetails( ns )->stats.nrecords );
702
712
            ArtificialTree::checkStructure( "{i:{b:{a:null},cc:{c:null},d:null,f:{e:null},h:{g:null}}}", id() );
703
713
        }
704
714
    };
710
720
//            dump();
711
721
            string ns = id().indexNamespace();
712
722
            ASSERT_EQUALS( 11, bt()->fullValidate( dl(), order(), 0, true ) );
713
 
            ASSERT_EQUALS( 7, nsdetails( ns.c_str() )->stats.nrecords );
 
723
            ASSERT_EQUALS( 7, nsdetails( ns )->stats.nrecords );
714
724
 
715
725
            BSONObj k = BSON( "" << "bb" );
716
726
            verify( unindex( k ) );
717
727
//            dump();
718
728
            ASSERT_EQUALS( 10, bt()->fullValidate( dl(), order(), 0, true ) );
719
 
            ASSERT_EQUALS( 7, nsdetails( ns.c_str() )->stats.nrecords );
 
729
            ASSERT_EQUALS( 7, nsdetails( ns )->stats.nrecords );
720
730
            ArtificialTree::checkStructure( "{d:{b:{a:null},cc:{c:null}},dd:null,_:{f:{e:null},h:{g:null}}}", id() );
721
731
        }
722
732
    };
728
738
//            dump();
729
739
            string ns = id().indexNamespace();
730
740
            ASSERT_EQUALS( 7, bt()->fullValidate( dl(), order(), 0, true ) );
731
 
            ASSERT_EQUALS( 5, nsdetails( ns.c_str() )->stats.nrecords );
 
741
            ASSERT_EQUALS( 5, nsdetails( ns )->stats.nrecords );
732
742
 
733
743
            BSONObj k = BSON( "" << "g" );
734
744
            verify( unindex( k ) );
735
745
//            dump();
736
746
            ASSERT_EQUALS( 6, bt()->fullValidate( dl(), order(), 0, true ) );
737
 
            ASSERT_EQUALS( 5, nsdetails( ns.c_str() )->stats.nrecords );
 
747
            ASSERT_EQUALS( 5, nsdetails( ns )->stats.nrecords );
738
748
            ArtificialTree::checkStructure( "{c:{b:{a:null}},d:null,_:{f:{e:null}}}", id() );
739
749
        }
740
750
    };
746
756
//            dump();
747
757
            string ns = id().indexNamespace();
748
758
            ASSERT_EQUALS( 9, bt()->fullValidate( dl(), order(), 0, true ) );
749
 
            ASSERT_EQUALS( 7, nsdetails( ns.c_str() )->stats.nrecords );
 
759
            ASSERT_EQUALS( 7, nsdetails( ns )->stats.nrecords );
750
760
 
751
761
            BSONObj k = BSON( "" << "ee" );
752
762
            verify( unindex( k ) );
753
763
//            dump();
754
764
            ASSERT_EQUALS( 8, bt()->fullValidate( dl(), order(), 0, true ) );
755
 
            ASSERT_EQUALS( 6, nsdetails( ns.c_str() )->stats.nrecords );
 
765
            ASSERT_EQUALS( 6, nsdetails( ns )->stats.nrecords );
756
766
            ArtificialTree::checkStructure( "{c:{b:{a:null}},_:{e:{d:null},f:null,h:{g:null}}}", id() );
757
767
        }
758
768
    };
764
774
//            dump();
765
775
            string ns = id().indexNamespace();
766
776
            ASSERT_EQUALS( 10, bt()->fullValidate( dl(), order(), 0, true ) );
767
 
            ASSERT_EQUALS( 7, nsdetails( ns.c_str() )->stats.nrecords );
 
777
            ASSERT_EQUALS( 7, nsdetails( ns )->stats.nrecords );
768
778
 
769
779
            BSONObj k = BSON( "" << "ee" );
770
780
            verify( unindex( k ) );
771
781
//            dump();
772
782
            ASSERT_EQUALS( 9, bt()->fullValidate( dl(), order(), 0, true ) );
773
 
            ASSERT_EQUALS( 6, nsdetails( ns.c_str() )->stats.nrecords );
 
783
            ASSERT_EQUALS( 6, nsdetails( ns )->stats.nrecords );
774
784
            ArtificialTree::checkStructure( "{f:{b:{a:null},c:null,e:{d:null}},ff:null,_:{h:{g:null}}}", id() );
775
785
        }
776
786
    };
782
792
//            dump();
783
793
            string ns = id().indexNamespace();
784
794
            ASSERT_EQUALS( 10, bt()->fullValidate( dl(), order(), 0, true ) );
785
 
            ASSERT_EQUALS( 7, nsdetails( ns.c_str() )->stats.nrecords );
 
795
            ASSERT_EQUALS( 7, nsdetails( ns )->stats.nrecords );
786
796
 
787
797
            BSONObj k = BSON( "" << "ee" );
788
798
            verify( unindex( k ) );
789
799
//            dump();
790
800
            ASSERT_EQUALS( 9, bt()->fullValidate( dl(), order(), 0, true ) );
791
 
            ASSERT_EQUALS( 6, nsdetails( ns.c_str() )->stats.nrecords );
 
801
            ASSERT_EQUALS( 6, nsdetails( ns )->stats.nrecords );
792
802
            ArtificialTree::checkStructure( "{c:{b:{a:null}},cc:null,_:{e:{d:null},f:null,h:{g:null}}}", id() );
793
803
        }
794
804
    };
800
810
//            dump();
801
811
            string ns = id().indexNamespace();
802
812
            ASSERT_EQUALS( 10, bt()->fullValidate( dl(), order(), 0, true ) );
803
 
            ASSERT_EQUALS( 6, nsdetails( ns.c_str() )->stats.nrecords );
 
813
            ASSERT_EQUALS( 6, nsdetails( ns )->stats.nrecords );
804
814
 
805
815
            BSONObj k = BSON( "" << "c" );
806
816
            verify( unindex( k ) );
807
817
//            dump();
808
818
            ASSERT_EQUALS( 9, bt()->fullValidate( dl(), order(), 0, true ) );
809
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
819
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
810
820
            // height is not currently reduced in this case
811
821
            ArtificialTree::checkStructure( "{j:{g:{b:{a:null},d:null,e:null,f:null},h:null,i:null}}", id() );
812
822
        }
819
829
//            dump();
820
830
            string ns = id().indexNamespace();
821
831
            ASSERT_EQUALS( 9, bt()->fullValidate( dl(), order(), 0, true ) );
822
 
            ASSERT_EQUALS( 6, nsdetails( ns.c_str() )->stats.nrecords );
 
832
            ASSERT_EQUALS( 6, nsdetails( ns )->stats.nrecords );
823
833
 
824
834
            BSONObj k = BSON( "" << "c" );
825
835
            verify( unindex( k ) );
826
836
//            dump();
827
837
            ASSERT_EQUALS( 8, bt()->fullValidate( dl(), order(), 0, true ) );
828
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
838
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
829
839
            ArtificialTree::checkStructure( "{g:{b:{a:null},d:null,e:null,f:null},h:null,i:null}", id() );
830
840
        }
831
841
    };
836
846
            ArtificialTree::setTree( "{h:{e:{b:{a:null},c:null,d:null},_:{f:null}},_:{i:null}}", id() );
837
847
            string ns = id().indexNamespace();
838
848
            ASSERT_EQUALS( 8, bt()->fullValidate( dl(), order(), 0, true ) );
839
 
            ASSERT_EQUALS( 6, nsdetails( ns.c_str() )->stats.nrecords );
 
849
            ASSERT_EQUALS( 6, nsdetails( ns )->stats.nrecords );
840
850
            BSONObj k = BSON( "" << "c" );
841
851
            verify( unindex( k ) );
842
852
            long long keyCount = bt()->fullValidate( dl(), order(), 0, true );
843
853
            ASSERT_EQUALS( 7, keyCount );
844
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
854
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
845
855
            // no recursion currently in this case
846
856
            ArtificialTree::checkStructure( "{h:{b:{a:null},d:null,e:null,f:null},_:{i:null}}", id() );
847
857
        }
892
902
                long long unused = 0;
893
903
                ASSERT_EQUALS( _count, bt()->fullValidate( dl(), order(), &unused, true ) );
894
904
                ASSERT_EQUALS( 0, unused );
895
 
                ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
905
                ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
896
906
                BSONObj k = bigKey( *i );
897
907
                unindex( k );
898
908
//                dump();
906
916
            ASSERT_EQUALS( 0, unused );
907
917
            validate();
908
918
            if ( !merge() ) {
909
 
                ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
919
                ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
910
920
            }
911
921
            else {
912
 
                ASSERT_EQUALS( 1, nsdetails( ns.c_str() )->stats.nrecords );
 
922
                ASSERT_EQUALS( 1, nsdetails( ns )->stats.nrecords );
913
923
            }
914
924
        }
915
925
    protected:
1009
1019
            string ns = id().indexNamespace();
1010
1020
            ArtificialTree::setTree( "{$10:{$1:null,$2:null,$3:null,$4:null,$5:null,$6:null},b:{$20:null,$30:null,$40:null,$50:null,a:null},_:{c:null}}", id() );
1011
1021
            ASSERT_EQUALS( 14, bt()->fullValidate( dl(), order(), 0, true ) );
1012
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1022
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1013
1023
            BSONObj k = BSON( "" << bigNumString( 0x40 ) );
1014
1024
//            dump();
1015
1025
            ASSERT( unindex( k ) );
1016
1026
//            dump();
1017
1027
            ASSERT_EQUALS( 13, bt()->fullValidate( dl(), order(), 0, true ) );
1018
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1028
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1019
1029
            ArtificialTree::checkStructure( "{$6:{$1:null,$2:null,$3:null,$4:null,$5:null},b:{$10:null,$20:null,$30:null,$50:null,a:null},_:{c:null}}", id() );
1020
1030
        }
1021
1031
    };
1026
1036
            string ns = id().indexNamespace();
1027
1037
            ArtificialTree::setTree( "{$10:{$1:null,$2:null,$3:null,$4:null},b:{$20:null,$30:null,$40:null,$50:null,$60:null,$70:null},_:{c:null}}", id() );
1028
1038
            ASSERT_EQUALS( 13, bt()->fullValidate( dl(), order(), 0, true ) );
1029
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1039
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1030
1040
            BSONObj k = BSON( "" << bigNumString( 0x3 ) );
1031
1041
//            dump();
1032
1042
            ASSERT( unindex( k ) );
1033
1043
//            dump();
1034
1044
            ASSERT_EQUALS( 12, bt()->fullValidate( dl(), order(), 0, true ) );
1035
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1045
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1036
1046
            ArtificialTree::checkStructure( "{$20:{$1:null,$2:null,$4:null,$10:null},b:{$30:null,$40:null,$50:null,$60:null,$70:null},_:{c:null}}", id() );
1037
1047
        }
1038
1048
    };
1043
1053
            string ns = id().indexNamespace();
1044
1054
            ArtificialTree::setTree( "{$20:{$1:{$0:null},$3:{$2:null},$5:{$4:null},$7:{$6:null},$9:{$8:null},$11:{$10:null},$13:{$12:null},_:{$14:null}},b:{$30:null,$40:{$35:null},$50:{$45:null}},_:{c:null}}", id() );
1045
1055
            ASSERT_EQUALS( 23, bt()->fullValidate( dl(), order(), 0, true ) );
1046
 
            ASSERT_EQUALS( 14, nsdetails( ns.c_str() )->stats.nrecords );
 
1056
            ASSERT_EQUALS( 14, nsdetails( ns )->stats.nrecords );
1047
1057
            BSONObj k = BSON( "" << bigNumString( 0x30 ) );
1048
1058
            //            dump();
1049
1059
            ASSERT( unindex( k ) );
1050
1060
            //            dump();
1051
1061
            ASSERT_EQUALS( 22, bt()->fullValidate( dl(), order(), 0, true ) );
1052
 
            ASSERT_EQUALS( 14, nsdetails( ns.c_str() )->stats.nrecords );
 
1062
            ASSERT_EQUALS( 14, nsdetails( ns )->stats.nrecords );
1053
1063
            ArtificialTree::checkStructure( "{$9:{$1:{$0:null},$3:{$2:null},$5:{$4:null},$7:{$6:null},_:{$8:null}},b:{$11:{$10:null},$13:{$12:null},$20:{$14:null},$40:{$35:null},$50:{$45:null}},_:{c:null}}", id() );
1054
1064
        }
1055
1065
    };
1060
1070
            string ns = id().indexNamespace();
1061
1071
            ArtificialTree::setTree( "{$20:{$1:{$0:null},$3:{$2:null},$5:null,_:{$14:null}},b:{$30:{$25:null},$40:{$35:null},$50:{$45:null},$60:{$55:null},$70:{$65:null},$80:{$75:null},$90:{$85:null},$100:{$95:null}},_:{c:null}}", id() );
1062
1072
            ASSERT_EQUALS( 25, bt()->fullValidate( dl(), order(), 0, true ) );
1063
 
            ASSERT_EQUALS( 15, nsdetails( ns.c_str() )->stats.nrecords );
 
1073
            ASSERT_EQUALS( 15, nsdetails( ns )->stats.nrecords );
1064
1074
            BSONObj k = BSON( "" << bigNumString( 0x5 ) );
1065
1075
//            dump();
1066
1076
            ASSERT( unindex( k ) );
1067
1077
//            dump();
1068
1078
            ASSERT_EQUALS( 24, bt()->fullValidate( dl(), order(), 0, true ) );
1069
 
            ASSERT_EQUALS( 15, nsdetails( ns.c_str() )->stats.nrecords );
 
1079
            ASSERT_EQUALS( 15, nsdetails( ns )->stats.nrecords );
1070
1080
            ArtificialTree::checkStructure( "{$50:{$1:{$0:null},$3:{$2:null},$20:{$14:null},$30:{$25:null},$40:{$35:null},_:{$45:null}},b:{$60:{$55:null},$70:{$65:null},$80:{$75:null},$90:{$85:null},$100:{$95:null}},_:{c:null}}", id() );
1071
1081
        }
1072
1082
    };
1077
1087
            string ns = id().indexNamespace();
1078
1088
            ArtificialTree::setTree( "{$10:{$1:null,$2:null,$3:null,$4:null,$5:null,$6:null},_:{$20:null,$30:null,$40:null,$50:null,a:null}}", id() );
1079
1089
            ASSERT_EQUALS( 12, bt()->fullValidate( dl(), order(), 0, true ) );
1080
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
1090
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
1081
1091
            BSONObj k = BSON( "" << bigNumString( 0x40 ) );
1082
1092
//            dump();
1083
1093
            ASSERT( unindex( k ) );
1084
1094
//            dump();
1085
1095
            ASSERT_EQUALS( 11, bt()->fullValidate( dl(), order(), 0, true ) );
1086
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
1096
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
1087
1097
            ArtificialTree::checkStructure( "{$6:{$1:null,$2:null,$3:null,$4:null,$5:null},_:{$10:null,$20:null,$30:null,$50:null,a:null}}", id() );
1088
1098
        }
1089
1099
    };
1146
1156
            string ns = id().indexNamespace();
1147
1157
            ArtificialTree::setTree( "{$10:{$1:null,$2:null,$3:null,$4:null,$5:null,$6:null},_:{$20:null,$30:null,$40:null,$50:null,a:null}}", id() );
1148
1158
            ASSERT_EQUALS( 12, bt()->fullValidate( dl(), order(), 0, true ) );
1149
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
1159
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
1150
1160
            // force parent pack
1151
1161
            ArtificialTree::is( dl() )->forcePack();
1152
1162
            BSONObj k = BSON( "" << bigNumString( 0x40 ) );
1154
1164
            ASSERT( unindex( k ) );
1155
1165
//            dump();
1156
1166
            ASSERT_EQUALS( 11, bt()->fullValidate( dl(), order(), 0, true ) );
1157
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
1167
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
1158
1168
            ArtificialTree::checkStructure( "{$6:{$1:null,$2:null,$3:null,$4:null,$5:null},_:{$10:null,$20:null,$30:null,$50:null,a:null}}", id() );
1159
1169
        }
1160
1170
    };
1165
1175
            string ns = id().indexNamespace();
1166
1176
            ArtificialTree::setTree( "{$10$10:{$1:null,$2:null,$3:null,$4:null},$100:{$20:null,$30:null,$40:null,$50:null,$60:null,$70:null,$80:null},$200:null,$300:null,$400:null,$500:null,$600:null,$700:null,$800:null,$900:null,_:{c:null}}", id() );
1167
1177
            ASSERT_EQUALS( 22, bt()->fullValidate( dl(), order(), 0, true ) );
1168
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1178
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1169
1179
            BSONObj k = BSON( "" << bigNumString( 0x3 ) );
1170
1180
//            dump();
1171
1181
            ASSERT( unindex( k ) );
1172
1182
//            dump();
1173
1183
            ASSERT_EQUALS( 21, bt()->fullValidate( dl(), order(), 0, true ) );
1174
 
            ASSERT_EQUALS( 6, nsdetails( ns.c_str() )->stats.nrecords );
 
1184
            ASSERT_EQUALS( 6, nsdetails( ns )->stats.nrecords );
1175
1185
            ArtificialTree::checkStructure( "{$500:{$30:{$1:null,$2:null,$4:null,$10$10:null,$20:null},$100:{$40:null,$50:null,$60:null,$70:null,$80:null},$200:null,$300:null,$400:null},_:{$600:null,$700:null,$800:null,$900:null,_:{c:null}}}", id() );
1176
1186
        }
1177
1187
    };
1289
1299
            string ns = id().indexNamespace();
1290
1300
            ArtificialTree::setTree( "{$10:{$1:null,$2:null,$3:null,$4:null,$5:null,$6:null},$20:{$11:null,$12:null,$13:null,$14:null},_:{$30:null}}", id() );
1291
1301
            ASSERT_EQUALS( 13, bt()->fullValidate( dl(), order(), 0, true ) );
1292
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1302
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1293
1303
            BSONObj k = BSON( "" << bigNumString( 0x12 ) );
1294
1304
//            dump();
1295
1305
            ASSERT( unindex( k ) );
1296
1306
//            dump();
1297
1307
            ASSERT_EQUALS( 12, bt()->fullValidate( dl(), order(), 0, true ) );
1298
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1308
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1299
1309
            ArtificialTree::checkStructure( "{$5:{$1:null,$2:null,$3:null,$4:null},$20:{$6:null,$10:null,$11:null,$13:null,$14:null},_:{$30:null}}", id() );
1300
1310
        }
1301
1311
    };
1306
1316
            string ns = id().indexNamespace();
1307
1317
            ArtificialTree::setTree( "{$10:{$1:null},$20:{$11:null,$12:null,$13:null,$14:null},_:{$31:null,$32:null,$33:null,$34:null,$35:null,$36:null}}", id() );
1308
1318
            ASSERT_EQUALS( 13, bt()->fullValidate( dl(), order(), 0, true ) );
1309
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1319
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1310
1320
            BSONObj k = BSON( "" << bigNumString( 0x12 ) );
1311
1321
            //            dump();
1312
1322
            ASSERT( unindex( k ) );
1313
1323
            //            dump();
1314
1324
            ASSERT_EQUALS( 12, bt()->fullValidate( dl(), order(), 0, true ) );
1315
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1325
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1316
1326
            ArtificialTree::checkStructure( "{$10:{$1:null},$31:{$11:null,$13:null,$14:null,$20:null},_:{$32:null,$33:null,$34:null,$35:null,$36:null}}", id() );
1317
1327
        }
1318
1328
    };
1323
1333
            string ns = id().indexNamespace();
1324
1334
            ArtificialTree::setTree( "{$10:{$5:{$1:null,$2:null},$8:{$6:null,$7:null}},_:{$20:null,$30:null,$40:null,$50:null,$60:null,$70:null,$80:null,$90:null}}", id() );
1325
1335
            ASSERT_EQUALS( 15, bt()->fullValidate( dl(), order(), 0, true ) );
1326
 
            ASSERT_EQUALS( 5, nsdetails( ns.c_str() )->stats.nrecords );
 
1336
            ASSERT_EQUALS( 5, nsdetails( ns )->stats.nrecords );
1327
1337
            BSONObj k = BSON( "" << bigNumString( 0x7 ) );
1328
1338
            //            dump();
1329
1339
            ASSERT( unindex( k ) );
1330
1340
            //            dump();
1331
1341
            ASSERT_EQUALS( 14, bt()->fullValidate( dl(), order(), 0, true ) );
1332
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1342
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1333
1343
            ArtificialTree::checkStructure( "{$40:{$8:{$1:null,$2:null,$5:null,$6:null},$10:null,$20:null,$30:null},_:{$50:null,$60:null,$70:null,$80:null,$90:null}}", id() );
1334
1344
        }
1335
1345
    };
1396
1406
            string ns = id().indexNamespace();
1397
1407
            ArtificialTree::setTree( "{b:{a:null}}", id() );
1398
1408
            ASSERT_EQUALS( 2, bt()->fullValidate( dl(), order(), 0, true ) );
1399
 
            ASSERT_EQUALS( 2, nsdetails( ns.c_str() )->stats.nrecords );
 
1409
            ASSERT_EQUALS( 2, nsdetails( ns )->stats.nrecords );
1400
1410
            BSONObj k = BSON( "" << "a" );
1401
1411
            //            dump();
1402
1412
            ASSERT( unindex( k ) );
1403
1413
            //            dump();
1404
1414
            ASSERT_EQUALS( 1, bt()->fullValidate( dl(), order(), 0, true ) );
1405
 
            ASSERT_EQUALS( 1, nsdetails( ns.c_str() )->stats.nrecords );
 
1415
            ASSERT_EQUALS( 1, nsdetails( ns )->stats.nrecords );
1406
1416
            ArtificialTree::checkStructure( "{b:null}", id() );
1407
1417
        }
1408
1418
    };
1413
1423
            string ns = id().indexNamespace();
1414
1424
            ArtificialTree::setTree( "{a:null,c:{b:null},d:null}", id() );
1415
1425
            ASSERT_EQUALS( 4, bt()->fullValidate( dl(), order(), 0, true ) );
1416
 
            ASSERT_EQUALS( 2, nsdetails( ns.c_str() )->stats.nrecords );
 
1426
            ASSERT_EQUALS( 2, nsdetails( ns )->stats.nrecords );
1417
1427
            BSONObj k = BSON( "" << "b" );
1418
1428
            //            dump();
1419
1429
            ASSERT( unindex( k ) );
1420
1430
            //            dump();
1421
1431
            ASSERT_EQUALS( 3, bt()->fullValidate( dl(), order(), 0, true ) );
1422
 
            ASSERT_EQUALS( 1, nsdetails( ns.c_str() )->stats.nrecords );
 
1432
            ASSERT_EQUALS( 1, nsdetails( ns )->stats.nrecords );
1423
1433
            ArtificialTree::checkStructure( "{a:null,c:null,d:null}", id() );
1424
1434
        }
1425
1435
    };
1432
1442
            long long unused = 0;
1433
1443
            ASSERT_EQUALS( 4, bt()->fullValidate( dl(), order(), &unused, true ) );
1434
1444
            ASSERT_EQUALS( 0, unused );
1435
 
            ASSERT_EQUALS( 2, nsdetails( ns.c_str() )->stats.nrecords );
 
1445
            ASSERT_EQUALS( 2, nsdetails( ns )->stats.nrecords );
1436
1446
            BSONObj k = BSON( "" << "c" );
1437
1447
//            dump();
1438
1448
            ASSERT( unindex( k ) );
1439
1449
//            dump();
1440
1450
            ASSERT_EQUALS( 3, bt()->fullValidate( dl(), order(), &unused, true ) );
1441
1451
            ASSERT_EQUALS( 0, unused );
1442
 
            ASSERT_EQUALS( 1, nsdetails( ns.c_str() )->stats.nrecords );
 
1452
            ASSERT_EQUALS( 1, nsdetails( ns )->stats.nrecords );
1443
1453
            ArtificialTree::checkStructure( "{a:null,b:null,d:null}", id() );
1444
1454
        }
1445
1455
    };
1453
1463
            long long unused = 0;
1454
1464
            ASSERT_EQUALS( 3, bt()->fullValidate( dl(), order(), &unused, true ) );
1455
1465
            ASSERT_EQUALS( 1, unused );
1456
 
            ASSERT_EQUALS( 2, nsdetails( ns.c_str() )->stats.nrecords );
 
1466
            ASSERT_EQUALS( 2, nsdetails( ns )->stats.nrecords );
1457
1467
            BSONObj k = BSON( "" << "c" );
1458
1468
//            dump();
1459
1469
            ASSERT( unindex( k ) );
1461
1471
            unused = 0;
1462
1472
            ASSERT_EQUALS( 2, bt()->fullValidate( dl(), order(), &unused, true ) );
1463
1473
            ASSERT_EQUALS( 1, unused );
1464
 
            ASSERT_EQUALS( 1, nsdetails( ns.c_str() )->stats.nrecords );
 
1474
            ASSERT_EQUALS( 1, nsdetails( ns )->stats.nrecords );
1465
1475
            // doesn't discriminate between used and unused
1466
1476
            ArtificialTree::checkStructure( "{a:null,b:null,d:null}", id() );
1467
1477
        }
1475
1485
            long long unused = 0;
1476
1486
            ASSERT_EQUALS( 2, bt()->fullValidate( dl(), order(), &unused, true ) );
1477
1487
            ASSERT_EQUALS( 0, unused );
1478
 
            ASSERT_EQUALS( 2, nsdetails( ns.c_str() )->stats.nrecords );
 
1488
            ASSERT_EQUALS( 2, nsdetails( ns )->stats.nrecords );
1479
1489
            BSONObj k = BSON( "" << "a" );
1480
1490
//            dump();
1481
1491
            ASSERT( unindex( k ) );
1483
1493
            unused = 0;
1484
1494
            ASSERT_EQUALS( 1, bt()->fullValidate( dl(), order(), &unused, true ) );
1485
1495
            ASSERT_EQUALS( 0, unused );
1486
 
            ASSERT_EQUALS( 1, nsdetails( ns.c_str() )->stats.nrecords );
 
1496
            ASSERT_EQUALS( 1, nsdetails( ns )->stats.nrecords );
1487
1497
            ArtificialTree::checkStructure( "{b:null}", id() );
1488
1498
        }
1489
1499
    };
1496
1506
            long long unused = 0;
1497
1507
            ASSERT_EQUALS( 7, bt()->fullValidate( dl(), order(), &unused, true ) );
1498
1508
            ASSERT_EQUALS( 0, unused );
1499
 
            ASSERT_EQUALS( 5, nsdetails( ns.c_str() )->stats.nrecords );
 
1509
            ASSERT_EQUALS( 5, nsdetails( ns )->stats.nrecords );
1500
1510
            BSONObj k = BSON( "" << "y" );
1501
1511
//            dump();
1502
1512
            ASSERT( unindex( k ) );
1504
1514
            unused = 0;
1505
1515
            ASSERT_EQUALS( 6, bt()->fullValidate( dl(), order(), &unused, true ) );
1506
1516
            ASSERT_EQUALS( 0, unused );
1507
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
1517
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
1508
1518
            ArtificialTree::checkStructure( "{a:null,e:{c:{b:null},d:null},z:null}", id() );
1509
1519
        }
1510
1520
    };
1517
1527
            long long unused = 0;
1518
1528
            ASSERT_EQUALS( 4, bt()->fullValidate( dl(), order(), &unused, true ) );
1519
1529
            ASSERT_EQUALS( 0, unused );
1520
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1530
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1521
1531
            BSONObj k = BSON( "" << "a" );
1522
1532
//            dump();
1523
1533
            ASSERT( unindex( k ) );
1525
1535
            unused = 0;
1526
1536
            ASSERT_EQUALS( 3, bt()->fullValidate( dl(), order(), &unused, true ) );
1527
1537
            ASSERT_EQUALS( 0, unused );
1528
 
            ASSERT_EQUALS( 2, nsdetails( ns.c_str() )->stats.nrecords );
 
1538
            ASSERT_EQUALS( 2, nsdetails( ns )->stats.nrecords );
1529
1539
            ArtificialTree::checkStructure( "{c:null,_:{e:null,f:null}}", id() );
1530
1540
        }
1531
1541
    };
1538
1548
            long long unused = 0;
1539
1549
            ASSERT_EQUALS( 5, bt()->fullValidate( dl(), order(), &unused, true ) );
1540
1550
            ASSERT_EQUALS( 0, unused );
1541
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
1551
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
1542
1552
            BSONObj k = BSON( "" << "d" );
1543
1553
            //            dump();
1544
1554
            ASSERT( unindex( k ) );
1545
1555
            //            dump();
1546
1556
            ASSERT_EQUALS( 4, bt()->fullValidate( dl(), order(), &unused, true ) );
1547
1557
            ASSERT_EQUALS( 1, unused );
1548
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
1558
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
1549
1559
            ArtificialTree::checkStructure( "{a:null,d:{c:{b:null}},e:null}", id() );
1550
1560
            ASSERT( bt()->keyNode( 1 ).recordLoc.getOfs() & 1 ); // check 'unused' key
1551
1561
        }
1559
1569
            long long unused = 0;
1560
1570
            ASSERT_EQUALS( 3, bt()->fullValidate( dl(), order(), &unused, true ) );
1561
1571
            ASSERT_EQUALS( 0, unused );
1562
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
1572
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
1563
1573
            BSONObj k = BSON( "" << "a" );
1564
1574
            //            dump();
1565
1575
            ASSERT( unindex( k ) );
1566
1576
            //            dump();
1567
1577
            ASSERT_EQUALS( 2, bt()->fullValidate( dl(), order(), &unused, true ) );
1568
1578
            ASSERT_EQUALS( 1, unused );
1569
 
            ASSERT_EQUALS( 3, nsdetails( ns.c_str() )->stats.nrecords );
 
1579
            ASSERT_EQUALS( 3, nsdetails( ns )->stats.nrecords );
1570
1580
            ArtificialTree::checkStructure( "{a:null,_:{c:null,_:{d:null}}}", id() );
1571
1581
            ASSERT( bt()->keyNode( 0 ).recordLoc.getOfs() & 1 ); // check 'unused' key
1572
1582
        }
1580
1590
            long long unused = 0;
1581
1591
            ASSERT_EQUALS( 13, bt()->fullValidate( dl(), order(), &unused, true ) );
1582
1592
            ASSERT_EQUALS( 0, unused );
1583
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1593
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1584
1594
            BSONObj k = BSON( "" << bigNumString( 0x30, 0x10 ) );
1585
1595
//            dump();
1586
1596
            ASSERT( unindex( k ) );
1587
1597
//            dump();
1588
1598
            ASSERT_EQUALS( 12, bt()->fullValidate( dl(), order(), &unused, true ) );
1589
1599
            ASSERT_EQUALS( 0, unused );
1590
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1600
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1591
1601
            ArtificialTree::checkStructure( "{$60:{$10:null,$20:null,$27:{$23:null,$25:null},$40:null,$50:null},_:{$70:null,$80:null,$90:null,$100:null}}", id() );
1592
1602
        }
1593
1603
    };
1600
1610
            long long unused = 0;
1601
1611
            ASSERT_EQUALS( 13, bt()->fullValidate( dl(), order(), &unused, true ) );
1602
1612
            ASSERT_EQUALS( 0, unused );
1603
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1613
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1604
1614
            BSONObj k = BSON( "" << bigNumString( 0x100, 0x10 ) );
1605
1615
//            dump();
1606
1616
            ASSERT( unindex( k ) );
1607
1617
//            dump();
1608
1618
            ASSERT_EQUALS( 12, bt()->fullValidate( dl(), order(), &unused, true ) );
1609
1619
            ASSERT_EQUALS( 0, unused );
1610
 
            ASSERT_EQUALS( 4, nsdetails( ns.c_str() )->stats.nrecords );
 
1620
            ASSERT_EQUALS( 4, nsdetails( ns )->stats.nrecords );
1611
1621
            ArtificialTree::checkStructure( "{$80:{$10:null,$20:null,$30:null,$40:null,$50:null,$60:null,$70:null},_:{$90:null,$97:{$93:null,$95:null}}}", id() );
1612
1622
        }
1613
1623
    };