Browse Source

fix docid-rowid lookup for huge docID

related to #2090
Aleksey N. Vinogradov 1 year ago
parent
commit
275706cd71
4 changed files with 36 additions and 6 deletions
  1. 2 4
      src/docidlookup.h
  2. 2 2
      src/killlist.h
  3. 1 0
      test/test_282/model.bin
  4. 31 0
      test/test_282/test.xml

+ 2 - 4
src/docidlookup.h

@@ -83,8 +83,7 @@ public:
 		int iDocsInCheckpoint = GetNumDocsInCheckpoint(pFound);
 		for ( int i = 1; i < iDocsInCheckpoint; i++ )
 		{
-			DocID_t tDeltaDocID = UnzipOffsetBE(pCur);
-			assert ( tDeltaDocID>=0 );
+			uint64_t tDeltaDocID = UnzipOffsetBE(pCur);
 			tRowID = sphUnalignedRead ( *(const RowID_t*)pCur );
 			pCur += sizeof(RowID_t);
 
@@ -178,8 +177,7 @@ public:
 			return true;
 		}
 
-		DocID_t tDelta = UnzipOffsetBE ( m_pCur );
-		assert ( tDelta>=0 );
+		uint64_t tDelta = UnzipOffsetBE ( m_pCur );
 
 		tRowID = sphUnalignedRead ( *(RowID_t*)const_cast<BYTE*>(m_pCur) );
 		m_pCur += sizeof(RowID_t);

+ 2 - 2
src/killlist.h

@@ -142,11 +142,11 @@ void Intersect ( READER1& tReader1, READER2& tReader2, FUNCTOR&& fnFunctor )
 
 	while ( bHaveDocs1 && bHaveDocs2 )
 	{
-		if ( tDocID1 < tDocID2 )
+		if ( (uint64_t)tDocID1 < (uint64_t)tDocID2 )
 		{
 			tReader1.HintDocID ( tDocID2 );
 			bHaveDocs1 = tReader1.Read ( tDocID1, tRowID1 );
-		} else if ( tDocID1 > tDocID2 )
+		} else if ( (uint64_t)tDocID1 > (uint64_t)tDocID2 )
 		{
 			tReader2.HintDocID ( tDocID1 );
 			bHaveDocs2 = tReader2.ReadDocID ( tDocID2 );

+ 1 - 0
test/test_282/model.bin

@@ -0,0 +1 @@
+a:1:{i:0;a:6:{i:0;a:2:{s:8:"sphinxql";s:22:"drop table if exists t";s:14:"total_affected";i:0;}i:1;a:2:{s:8:"sphinxql";s:14:"create table t";s:14:"total_affected";i:0;}i:2;a:2:{s:8:"sphinxql";s:49:"replace into t values (10000000000000000000), (2)";s:14:"total_affected";i:2;}i:3;a:2:{s:8:"sphinxql";s:16:"flush ramchunk t";s:14:"total_affected";i:0;}i:4;a:2:{s:8:"sphinxql";s:44:"replace into t values (10000000000000000000)";s:14:"total_affected";i:1;}i:5;a:3:{s:8:"sphinxql";s:15:"select * from t";s:10:"total_rows";i:2;s:4:"rows";a:2:{i:0;a:1:{s:2:"id";s:20:"-8446744073709551616";}i:1;a:1:{s:2:"id";s:1:"2";}}}}}

+ 31 - 0
test/test_282/test.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<test>
+
+<name>dupes on huge delta-docid</name>
+
+<requires>
+	<force-rt/>
+</requires>
+
+<skip_indexer/>
+
+<config>
+searchd
+{
+	<searchd_Settings/>
+	data_dir = <data_path path="data0"/>
+}
+</config>
+
+<queries>
+<sphinxql>
+	drop table if exists t;
+	create table t;
+	replace into t values (10000000000000000000), (2);
+	flush ramchunk t;
+	replace into t values (10000000000000000000);
+	select * from t;
+</sphinxql>
+</queries>
+
+</test>