Enhanced search performance in disk logstream, specially when filtering in LARGE files!

This commit is contained in:
Andre Lorbach 2008-09-19 17:10:29 +02:00
parent 2b7d1d790b
commit 7bf38af1a4
3 changed files with 11 additions and 10 deletions

View File

@ -656,8 +656,8 @@ abstract class LogStream {
// "+", // "+",
); );
$this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = preg_replace( $searchArray, $replaceArray, $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] );
// $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = str_replace( '+', ' ', $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE]); // $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = str_replace( '+', ' ', $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE]);
$this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = preg_replace( $searchArray, $replaceArray, $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] );
// --- // ---
} }

View File

@ -234,7 +234,7 @@ class LogStreamDisk extends LogStream {
$ret = $this->ReadNextForwards($uID, $arrProperitesOut); $ret = $this->ReadNextForwards($uID, $arrProperitesOut);
else else
$ret = $this->ReadNextBackwards($uID, $arrProperitesOut); $ret = $this->ReadNextBackwards($uID, $arrProperitesOut);
// Only PARSE on success! // Only PARSE on success!
if ( $ret == SUCCESS && $bParseMessage) if ( $ret == SUCCESS && $bParseMessage)
{ {
@ -243,7 +243,7 @@ class LogStreamDisk extends LogStream {
// Run optional Message Parsers now // Run optional Message Parsers now
$retParser = $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); $retParser = $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut);
// Check if we have to skip the message! // Check if we have to skip the message!
if ( $retParser == ERROR_MSG_SKIPMESSAGE ) if ( $retParser == ERROR_MSG_SKIPMESSAGE )
$ret = $retParser; $ret = $retParser;
@ -523,8 +523,10 @@ class LogStreamDisk extends LogStream {
*/ */
public function GetLastPageUID() public function GetLastPageUID()
{ {
// Obtain last UID if enough records are available! // Only perform lastUID scan if there are NO filters, for performance REASONS!
if ( $this->_filters != null )
return UID_UNKNOWN;
// Helper variables // Helper variables
$myuid = -1; $myuid = -1;
$counter = 0; $counter = 0;

View File

@ -230,10 +230,6 @@ if ( isset($content['Sources'][$currentSourceID]) )
// TODO Implement ORDER // TODO Implement ORDER
$stream->SetReadDirection($content['read_direction']); $stream->SetReadDirection($content['read_direction']);
// Read First and LAST UID's before start reading the stream!
$content['uid_last'] = $stream->GetLastPageUID();
$content['uid_first'] = $stream->GetFirstPageUID();
// Set current ID and init Counter // Set current ID and init Counter
$uID = $content['uid_current']; $uID = $content['uid_current'];
$counter = 0; $counter = 0;
@ -830,9 +826,12 @@ if ( isset($content['Sources'][$currentSourceID]) )
// Increment Counter // Increment Counter
$counter++; $counter++;
} while ($counter < $content['ViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS); } while ($counter < $content['ViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS);
//print_r ( $content['syslogmessages'] ); //print_r ( $content['syslogmessages'] );
// Move below processing - Read First and LAST UID's before start reading the stream!
$content['uid_last'] = $stream->GetLastPageUID();
$content['uid_first'] = $stream->GetFirstPageUID();
if ( $content['main_recordcount'] == -1 || $content['main_recordcount'] > $content['ViewEntriesPerPage'] ) if ( $content['main_recordcount'] == -1 || $content['main_recordcount'] > $content['ViewEntriesPerPage'] )
{ {
// Enable Pager in any case here! // Enable Pager in any case here!