@@ -186,8 +186,11 @@ public int open_(String filename, int mode, int sharing) {
186186 } else {
187187 dbConf .setAllowCreate (true );
188188 }
189-
190- dbConf .setSortedDuplicates (this .keys [i ].getFlag () != 0 );
189+ /*if(this.keys[i].getFlag() != 0) {
190+ dbConf.setSortedDuplicates(true);
191+ }*/
192+ //dbConf.setSortedDuplicates(this.keys[i].getFlag() != 0);
193+ dbConf .setSortedDuplicates (true );
191194
192195 if (mode == COB_OPEN_OUTPUT ) {
193196 try {
@@ -586,11 +589,7 @@ public int readNext(int readOpts) {
586589 }
587590 if (read_nextprev ) {
588591 try {
589- //output_data("22222 p.key", p.key);
590- //System.out.println("<<<Log>>> p.key_index = " + p.key_index);
591592 result = p .cursor [p .key_index ].get (p .key , p .data , nextprev , readOptions );
592- //output_data("33333 p.key", p.key);
593- //output_data("33333 p.data", p.data);
594593 } catch (LockConflictException e ) {
595594 this .discardCursors (p );
596595 return COB_STATUS_51_RECORD_LOCKED ;
@@ -628,7 +627,6 @@ public int readNext(int readOpts) {
628627 }
629628 if (p .key_index == 0 ) {
630629 p .last_readkey [0 ].memcpy (p .key .getData (), p .key .getSize ());
631- //output_data("xxxxxx p.key", p.key);
632630 } else {
633631 p .last_readkey [p .key_index ].memcpy (p .temp_key , this .keys [p .key_index ].getField ().getSize ());
634632 p .last_readkey [p .key_index + this .nkeys ].memcpy (p .key .getData (),
@@ -703,8 +701,6 @@ private int indexed_write_internal(boolean rewrite, int opt) {
703701 }
704702
705703 p .data = new DatabaseEntry (this .record .getDataStorage ().getByteArray (0 , this .record .getSize ()));
706- //output_data("write 0 p.key", p.key);
707- //output_data("write 0 p.data", p.data);
708704 try {
709705 p .cursor [0 ].put (p .key , p .data );
710706 } catch (LockConflictException e ) {
@@ -728,8 +724,6 @@ private int indexed_write_internal(boolean rewrite, int opt) {
728724 }
729725
730726 p .key = DBT_SET (this .keys [i ].getField ());
731- //output_data("write " + i + " p.key", p.key);
732- //output_data("write " + i + " p.data", p.data);
733727 try {
734728 if (p .db [i ].put (null , p .key , p .data , flags , null ) == null ) {
735729 if (close_cursor ) {
@@ -799,9 +793,9 @@ public int write_(int opt) {
799793 private boolean check_alt_keys (boolean rewrite ) {
800794 IndexedFile p = this .filei ;
801795 for (int i = 1 ; i < this .nkeys ; ++i ) {
802- if (this .keys [i ].getFlag () ! = 0 ) {
796+ if (this .keys [i ].getFlag () = = 0 ) {
803797 p .key = DBT_SET (this .keys [i ].getField ());
804- if (p .db [i ].get (null , p .key , p .data , Get .SEARCH , null ) = = null ) {
798+ if (p .db [i ].get (null , p .key , p .data , Get .SEARCH , null ) ! = null ) {
805799 if (rewrite ) {
806800 byte [] dataBytes = p .data .getData ();
807801 if (this .keys [0 ].getField ().getDataStorage ().memcmp (dataBytes ,
@@ -849,10 +843,10 @@ private int get_dupno(int i) {
849843 //berkley dbの重複スキーに対するデータは新しいものほど先頭に格納されるが
850844 //java editionでは挿入位置が自動で設定されるため,以下の実装を変えた.
851845 int dupno = 0 ;
852- while (ret != null ) {
853- int tempDupno = ByteBuffer .wrap (p .key .getData (), this .keys [0 ].getField ().getSize (), 4 ).getInt ();
854- if ( tempDupno > dupno ) {
855- dupno = tempDupno ;
846+ while (ret != null && p . temp_key . memcmp ( p . key . getData (), p . key . getSize ()) == 0 ) {
847+ int tempdupno = ByteBuffer .wrap (p .data .getData (), this .keys [0 ].getField ().getSize (), 4 ).getInt ();
848+ if ( dupno < tempdupno ) {
849+ dupno = tempdupno ;
856850 }
857851 ret = p .cursor [i ].get (p .key , p .data , Get .NEXT_DUP , null );
858852 }
@@ -861,7 +855,7 @@ private int get_dupno(int i) {
861855 p .cursor [i ] = null ;
862856
863857 return ++dupno ;
864- }
858+ }
865859
866860 @ Override
867861 /**
0 commit comments