Эх сурвалжийг харах

indexcheck to lib

incapsulate roaring bitmap to be dependency for one single source
Aleksey N. Vinogradov 9 сар өмнө
parent
commit
42ba039418

+ 0 - 3
CMakeLists.txt

@@ -244,9 +244,6 @@ target_link_libraries ( lextra INTERFACE cctz::cctz )
 include ( GetxxHash )
 target_link_libraries ( lextra INTERFACE xxHash::xxhash )
 
-include ( GetRBitmap )
-target_link_libraries ( lextra INTERFACE roaring::roaring )
-
 with_get ( jieba "Jieba" "Chinese text segmentation tool" )
 
 # Support for OpenSSL

+ 1 - 1
cmake/GetRBitmap.cmake

@@ -6,7 +6,7 @@ set ( ROARINGBITMAP_SRC_MD5 "9ad3047cd74e5a3562c30f7c8a606373" )
 
 include ( update_bundle )
 
-# try to find quietly (will work most time
+# try to find quietly (will work most of the times)
 find_package ( roaring QUIET CONFIG )
 return_if_target_found ( roaring::roaring "found ready (no need to build)" )
 

+ 6 - 1
src/CMakeLists.txt

@@ -57,7 +57,7 @@ add_library ( lmanticore STATIC sphinx.cpp sphinxutils.cpp
 		sphinxjson.cpp sphinxaot.cpp sphinxplugin.cpp sphinxudf.c sphinxqcache.cpp 
 		attribute.cpp secondaryindex.cpp killlist.cpp searchnode.cpp json/cJSON.c sphinxpq.cpp
 		global_idf.cpp docstore.cpp lz4/lz4.c lz4/lz4hc.c snippetfunctor.cpp snippetindex.cpp
-		snippetstream.cpp snippetpassage.cpp threadutils.cpp sphinxversion.cpp indexcheck.cpp datareader.cpp
+		snippetstream.cpp snippetpassage.cpp threadutils.cpp sphinxversion.cpp datareader.cpp
 		indexformat.cpp indexsettings.cpp fileutils.cpp threads_detached.cpp hazard_pointer.cpp
 		task_info.cpp mini_timer.cpp fileio.cpp memio.cpp queryprofile.cpp columnarfilter.cpp columnargrouper.cpp
 		columnarlib.cpp collation.cpp histogram.cpp
@@ -73,6 +73,11 @@ if (WIN32)
 target_link_libraries ( lmanticore PRIVATE dbghelp AdvAPI32 ShLwApi )
 endif()
 
+include ( GetRBitmap )
+add_library ( indexcheck OBJECT indexcheck.cpp indexcheck.h )
+target_link_libraries ( indexcheck PRIVATE lextra roaring::roaring )
+target_link_libraries ( lmanticore PUBLIC indexcheck )
+
 add_library ( lstem STATIC sphinxsoundex.cpp sphinxmetaphone.cpp sphinxstemen.cpp sphinxstemru.cpp sphinxstemru.inl
 		sphinxstemcz.cpp sphinxstemar.cpp )
 target_link_libraries ( lstem PUBLIC lextra )

+ 27 - 3
src/indexcheck.cpp

@@ -190,7 +190,7 @@ private:
 };
 
 
-void DebugCheckHelper_c::DebugCheck_Attributes ( DebugCheckReader_i & tAttrs, DebugCheckReader_i & tBlobs, int64_t nRows, int64_t iMinMaxBytes, const CSphSchema & tSchema, DebugCheckError_i & tReporter ) const
+void DebugCheck_Attributes ( DebugCheckReader_i & tAttrs, DebugCheckReader_i & tBlobs, int64_t nRows, int64_t iMinMaxBytes, const CSphSchema & tSchema, DebugCheckError_i & tReporter )
 {
 	// empty?
 	if ( !tAttrs.GetLengthBytes() )
@@ -295,7 +295,7 @@ void DebugCheckHelper_c::DebugCheck_Attributes ( DebugCheckReader_i & tAttrs, De
 }
 
 
-void DebugCheckHelper_c::DebugCheck_DeadRowMap ( int64_t iSizeBytes, int64_t nRows, DebugCheckError_i & tReporter ) const
+void DebugCheck_DeadRowMap ( int64_t iSizeBytes, int64_t nRows, DebugCheckError_i & tReporter )
 {
 	tReporter.Msg ( "checking dead row map..." );
 
@@ -361,7 +361,7 @@ static JsonEscapedBuilder& operator<< ( JsonEscapedBuilder& dOut, const Wordid_t
 
 using cbWordidFn = std::function<void ( RowID_t, Wordid_t, int iField, int iPos, bool bIsEnd )>;
 
-class DiskIndexChecker_c::Impl_c : public DebugCheckHelper_c
+class DiskIndexChecker_c::Impl_c
 {
 public:
 			Impl_c ( CSphIndex & tIndex, DebugCheckError_i & tReporter );
@@ -1780,3 +1780,27 @@ void DebugCheckSchema ( const ISphSchema & tSchema, DebugCheckError_i & tReporte
 {
 	DebugCheckSchema_T ( tSchema, tReporter );
 }
+
+
+bool SchemaConfigureCheckAttribute ( const CSphSchema & tSchema, const CSphColumnInfo & tCol, CSphString & sError )
+{
+	if ( tCol.m_sName.IsEmpty() )
+	{
+		sError.SetSprintf ( "column number %d has no name", tCol.m_iIndex );
+		return false;
+	}
+
+	if ( tSchema.GetAttr ( tCol.m_sName.cstr() ) )
+	{
+		sError.SetSprintf ( "can not add multiple attributes with same name '%s'", tCol.m_sName.cstr () );
+		return false;
+	}
+
+	if ( CSphSchema::IsReserved ( tCol.m_sName.cstr() ) )
+	{
+		sError.SetSprintf ( "%s is not a valid attribute name", tCol.m_sName.cstr() );
+		return false;
+	}
+
+	return true;
+}

+ 3 - 9
src/indexcheck.h

@@ -44,15 +44,6 @@ public:
 
 DebugCheckError_i* MakeDebugCheckError ( FILE* fp, DocID_t* pExtract );
 
-// common code for debug checks in RT and disk indexes
-class DebugCheckHelper_c
-{
-protected:
-	void	DebugCheck_Attributes ( DebugCheckReader_i & tAttrs, DebugCheckReader_i & tBlobs, int64_t nRows, int64_t iMinMaxBytes, const CSphSchema & tSchema, DebugCheckError_i & tReporter ) const;
-	void	DebugCheck_DeadRowMap (  int64_t iSizeBytes, int64_t nRows, DebugCheckError_i & tReporter ) const;
-};
-
-
 // disk index checker
 class DiskIndexChecker_c
 {
@@ -69,6 +60,9 @@ public:
 	void	Check();
 };
 
+// common code for debug checks in RT and disk indexes
+void DebugCheck_Attributes ( DebugCheckReader_i & tAttrs, DebugCheckReader_i & tBlobs, int64_t nRows, int64_t iMinMaxBytes, const CSphSchema & tSchema, DebugCheckError_i & tReporter );
+void DebugCheck_DeadRowMap (  int64_t iSizeBytes, int64_t nRows, DebugCheckError_i & tReporter );
 void DebugCheckSchema ( const ISphSchema & tSchema, DebugCheckError_i & tReporter );
 bool DebugCheckSchema ( const ISphSchema & tSchema, CSphString & sError );
 bool SchemaConfigureCheckAttribute ( const CSphSchema & tSchema, const CSphColumnInfo & tCol, CSphString & sError );

+ 2 - 2
src/indexing_sources/CMakeLists.txt

@@ -19,7 +19,7 @@ target_link_libraries ( indexer_sources INTERFACE sourcedoc )
 
 # tsv/csv pipe
 add_library ( source_svpipe source_svpipe.cpp source_svpipe.h )
-target_link_libraries ( source_svpipe PUBLIC lextra )
+target_link_libraries ( source_svpipe PUBLIC lextra indexcheck )
 target_link_libraries ( indexer_sources INTERFACE source_svpipe )
 
 # generic sql
@@ -74,7 +74,7 @@ endif ()
 #xmlpipe (with or without iconv)
 if (WITH_EXPAT)
 	add_library ( source_xmlpipe2 source_xmlpipe2.cpp source_xmlpipe2.h )
-	target_link_libraries ( source_xmlpipe2 PRIVATE lextra )
+	target_link_libraries ( source_xmlpipe2 PRIVATE lextra indexcheck )
 	if (DL_EXPAT)
 		target_link_libraries ( source_xmlpipe2 PRIVATE EXPAT::EXPAT_ld )
 	else ()

+ 6 - 31
src/sphinx.cpp

@@ -1137,7 +1137,7 @@ public:
 class CSphHitBuilder;
 
 /// this is my actual VLN-compressed phrase index implementation
-class CSphIndex_VLN : public CSphIndex, public IndexAlterHelper_c, public DebugCheckHelper_c
+class CSphIndex_VLN : public CSphIndex, public IndexAlterHelper_c
 {
 	friend class DiskIndexQwordSetup_c;
 	friend class CSphMerger;
@@ -11612,18 +11612,18 @@ size_t strnlen ( const char * s, size_t iMaxLen )
 
 int CSphIndex_VLN::DebugCheck ( DebugCheckError_i & tReporter, FilenameBuilder_i * pFilenameBuilder )
 {
-	auto pIndexChecker = std::make_unique<DiskIndexChecker_c> ( *this, tReporter );
+	DiskIndexChecker_c tIndexChecker { *this, tReporter };
 
-	pIndexChecker->Setup ( m_iDocinfo, m_iDocinfoIndex, m_iMinMaxIndex, m_bCheckIdDups );
+	tIndexChecker.Setup ( m_iDocinfo, m_iDocinfoIndex, m_iMinMaxIndex, m_bCheckIdDups );
 
 	// check if index is ready
 	if ( !m_bPassedAlloc )
 		tReporter.Fail ( "table not preread" );
 
-	if ( !pIndexChecker->OpenFiles() )
+	if ( !tIndexChecker.OpenFiles() )
 		return 1;
 
-	if ( !LoadHitlessWords ( m_tSettings.m_sHitlessFiles, m_pTokenizer, m_pDict, pIndexChecker->GetHitlessWords(), m_sLastError ) )
+	if ( !LoadHitlessWords ( m_tSettings.m_sHitlessFiles, m_pTokenizer, m_pDict, tIndexChecker.GetHitlessWords(), m_sLastError ) )
 		tReporter.Fail ( "unable to load hitless words: %s", m_sLastError.cstr() );
 
 	CSphSavedFile tStat;
@@ -11674,8 +11674,7 @@ int CSphIndex_VLN::DebugCheck ( DebugCheckError_i & tReporter, FilenameBuilder_i
 		}
 	}
 
-	pIndexChecker->Check();
-
+	tIndexChecker.Check();
 	tReporter.Done();
 
 	return (int)Min ( tReporter.GetNumFails(), 255 ); // this is the exitcode; so cap it
@@ -12252,30 +12251,6 @@ bool ParseMorphFields ( const CSphString & sMorphology, const CSphString & sMorp
 	return ( !sMissed.GetLength() );
 }
 
-
-bool SchemaConfigureCheckAttribute ( const CSphSchema & tSchema, const CSphColumnInfo & tCol, CSphString & sError )
-{
-	if ( tCol.m_sName.IsEmpty() )
-	{
-		sError.SetSprintf ( "column number %d has no name", tCol.m_iIndex );
-		return false;
-	}
-
-	if ( tSchema.GetAttr ( tCol.m_sName.cstr() ) )
-	{
-		sError.SetSprintf ( "can not add multiple attributes with same name '%s'", tCol.m_sName.cstr () );
-		return false;
-	}
-
-	if ( CSphSchema::IsReserved ( tCol.m_sName.cstr() ) )
-	{
-		sError.SetSprintf ( "%s is not a valid attribute name", tCol.m_sName.cstr() );
-		return false;
-	}
-
-	return true;
-}
-
 /////////////////////////////////////////////////////////////////////////////
 
 

+ 1 - 1
src/sphinxrt.cpp

@@ -1333,7 +1333,7 @@ enum class MergeSeg_e : BYTE
 	EXIT 	= 4,	// shutdown and exit
 };
 
-class RtIndex_c final : public RtIndex_i, public ISphNoncopyable, public ISphWordlist, public ISphWordlistSuggest, public IndexAlterHelper_c, public DebugCheckHelper_c
+class RtIndex_c final : public RtIndex_i, public ISphNoncopyable, public ISphWordlist, public ISphWordlistSuggest, public IndexAlterHelper_c
 {
 public:
 						RtIndex_c ( CSphString sIndexName, CSphString sPath, CSphSchema tSchema, int64_t iRamSize, bool bKeywordDict );