while (!feof($handle)) { $line = fgets($handle); if ($lineNo !== false) { if ($lineCount < $lineNo) { unset($line); $lineCount++; // echo "\t\tSkipping: {$lineCount} (>> {$lineNo})\n"; continue; } if ($lineCount == $lineNo) { $lineNo = false; // start crunching } } $doc = LogfileAnalysis::parseLine($line); if ($doc === false) { $lineCount++; continue; } $doc['_id'] = md5($doc['line']); $bulk->docs[] = $doc; // LogfileAnalysis::sendToCouchDB($doc, $prettyLog, $lineCount); unset($line); unset($doc); if ($lineCount % 50 == 0) { // send the bulk request LogfileAnalysis::sendBulkRequest($bulk, $prettyLog, $lineCount); } $lineCount++; } echo "\t" . round(memory_get_usage(true) / 1024 / 1024, 2) . "MB\n";
continue; } $lineCount = 1; while (!feof($handle)) { $line = fgets($handle); if ($lineNo !== false) { if ($lineCount < $lineNo) { unset($line); $lineCount++; // echo "\t\tSkipping: {$lineCount} (>> {$lineNo})\n"; continue; } if ($lineCount == $lineNo) { $lineNo = false; // start crunching } } $doc = LogfileAnalysis::parseLine($line); if ($doc === false) { $lineCount++; continue; } LogfileAnalysis::sendToCouchDB($doc, $prettyLog, $lineCount); // usleep(500000); unset($line); unset($doc); $lineCount++; } unset($prettyLog); echo "\t" . round(memory_get_usage(true) / 1024 / 1024, 2) . "MB\n"; }