MCPcopy Create free account
hub / github.com/apache/solr / addOldLog

Method addOldLog

solr/core/src/java/org/apache/solr/update/UpdateLog.java:737–766  ·  view source on GitHub ↗
(TransactionLog oldLog, boolean removeOld)

Source from the content-addressed store, hash-verified

735 and then decrementing its reference and dropping it.
736 */
737 @SuppressWarnings(
738 "ReferenceEquality") // TransactionLog identity, not equality, is what matters here
739 protected synchronized void addOldLog(TransactionLog oldLog, boolean removeOld) {
740 if (oldLog == null) return;
741
742 numOldRecords += oldLog.numRecords();
743
744 int currRecords = numOldRecords;
745
746 if (oldLog != tlog && tlog != null) {
747 currRecords += tlog.numRecords();
748 }
749
750 while (removeOld && logs.size() > 0) {
751 TransactionLog log = logs.peekLast();
752 int nrec = log.numRecords();
753 // remove oldest log if we don't need it to keep at least numRecordsToKeep, or if
754 // we already have the limit of 10 log files.
755 if (currRecords - nrec >= numRecordsToKeep
756 || (maxNumLogsToKeep > 0 && logs.size() >= maxNumLogsToKeep)) {
757 currRecords -= nrec;
758 numOldRecords -= nrec;
759 logs.removeLast().decref(); // dereference so it will be deleted when no longer in use
760 continue;
761 }
762
763 break;
764 }
765
766 // don't incref... we are taking ownership from the caller.
767 logs.addFirst(oldLog);
768 }
769

Callers 2

initTlogDirMethod · 0.95
postCommitMethod · 0.95

Calls 3

numRecordsMethod · 0.95
sizeMethod · 0.65
decrefMethod · 0.45

Tested by

no test coverage detected