Skip to content

Commit 270f63e

Browse files
committed
Merge remote-tracking branch 'origin/main' into int_score
2 parents d1ac4b1 + c28e270 commit 270f63e

27 files changed

+1275
-294
lines changed

dev-tools/scripts/addBackcompatIndexes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import os
2424
import sys
25+
from pathlib import Path
2526

2627
sys.path.append(os.path.dirname(__file__))
2728
import argparse
@@ -188,7 +189,7 @@ def read_config():
188189
def main():
189190
c = read_config()
190191
if not os.path.exists(c.temp_dir):
191-
os.makedirs(c.temp_dir)
192+
Path(c.temp_dir).mkdir(parents=True)
192193

193194
print("\nCreating backwards compatibility indexes")
194195
source = download_release(c.version, c.temp_dir, c.force)

dev-tools/scripts/buildAndPushRelease.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import time
2525
import urllib.request
2626
import xml.etree.ElementTree as ET
27+
from pathlib import Path
2728
from subprocess import TimeoutExpired
2829

2930
import scriptutil
@@ -213,13 +214,13 @@ def normalizeVersion(tup: tuple[str, ...]):
213214

214215
def pushLocal(version: str, root: str, rcNum: int, localDir: str):
215216
print("Push local [%s]..." % localDir)
216-
os.makedirs(localDir)
217+
Path(localDir).mkdir(parents=True)
217218

218219
lucene_dist_dir = "%s/lucene/distribution/build/release" % root
219220
rev = open("%s/lucene/distribution/build/release/.gitrev" % root, encoding="UTF-8").read()
220221

221222
dir = "lucene-%s-RC%d-rev-%s" % (version, rcNum, rev)
222-
os.makedirs("%s/%s/lucene" % (localDir, dir))
223+
Path("%s/%s/lucene" % (localDir, dir)).mkdir(parents=True)
223224
print(" Lucene")
224225
os.chdir(lucene_dist_dir)
225226
print(" archive...")
@@ -237,7 +238,7 @@ def pushLocal(version: str, root: str, rcNum: int, localDir: str):
237238
run("chmod -R a+rX-w .")
238239

239240
print(" done!")
240-
return "file://%s/%s" % (os.path.abspath(localDir), dir)
241+
return "file://%s/%s" % (Path(localDir).resolve(), dir)
241242

242243

243244
def read_version(_path: str):

dev-tools/scripts/pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ ignore = [
9595
"PLW0602", # using global for variable but no assignment is done
9696
"PLW0603", # using global statement to update variable is discouraged
9797
"PLW2901", # loop variable overwritten by assignment target
98-
"PTH100", # os.path.abspath should be replaced by Path.resolve
99-
"PTH103", # os.mkdirs should be replaced by Path.mkdir(parents=True)
10098
"PTH104", # os.rename should be replaced by Path.rename
10199
"PTH107", # os.remove shoudl be replaced by Path.unlink
102100
"PTH109", # os.getcwd should be replaced by Path.cwd

dev-tools/scripts/releaseWizard.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from collections import OrderedDict
4949
from collections.abc import Callable
5050
from datetime import UTC, datetime, timedelta
51+
from pathlib import Path
5152
from typing import Any, Self, TextIO, cast, override
5253

5354
import yaml
@@ -488,7 +489,7 @@ def save(self):
488489
print("Saving")
489490
if not os.path.exists(os.path.join(self.config_path, self.release_version)):
490491
print("Creating folder %s" % os.path.join(self.config_path, self.release_version))
491-
os.makedirs(os.path.join(self.config_path, self.release_version))
492+
Path(os.path.join(self.config_path, self.release_version)).mkdir(parents=True)
492493

493494
with open(os.path.join(self.config_path, self.release_version, "state.yaml"), "w") as fp:
494495
yaml.dump(self.to_dict(), fp, sort_keys=False, default_flow_style=False)
@@ -532,14 +533,14 @@ def get_release_folder(self):
532533
folder = os.path.join(self.config_path, self.release_version)
533534
if not os.path.exists(folder):
534535
print("Creating folder %s" % folder)
535-
os.makedirs(folder)
536+
Path(folder).mkdir(parents=True)
536537
return folder
537538

538539
def get_rc_folder(self):
539540
folder = os.path.join(self.get_release_folder(), "RC%d" % self.rc_number)
540541
if not os.path.exists(folder):
541542
print("Creating folder %s" % folder)
542-
os.makedirs(folder)
543+
Path(folder).mkdir(parents=True)
543544
return folder
544545

545546
def get_dist_folder(self):
@@ -1282,11 +1283,11 @@ def main():
12821283
if root.startswith("~/"):
12831284
release_root = os.path.expanduser(root)
12841285
else:
1285-
release_root = os.path.abspath(root)
1286+
release_root = str(Path(root).resolve())
12861287
if not os.path.exists(release_root):
12871288
try:
12881289
print("Creating release root %s" % release_root)
1289-
os.makedirs(release_root)
1290+
Path(release_root).mkdir(parents=True)
12901291
except Exception as e:
12911292
sys.exit("Error while creating %s: %s" % (release_root, e))
12921293
release_version = get_release_version()
@@ -1305,7 +1306,7 @@ def main():
13051306
y = yaml.load(open(os.path.join(script_path, "releaseWizard.yaml")), Loader=yaml.Loader)
13061307
templates = y.get("templates")
13071308
todo_list = y.get("groups")
1308-
state = ReleaseState(release_root, release_version, getScriptVersion())
1309+
state = ReleaseState(str(release_root), release_version, getScriptVersion())
13091310
state.init_todos(bootstrap_todos(todo_list))
13101311
state.load()
13111312
except Exception as e:
@@ -1351,7 +1352,7 @@ def main():
13511352

13521353

13531354
sys.path.append(os.path.dirname(__file__))
1354-
current_git_root = os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)), os.path.pardir, os.path.pardir))
1355+
current_git_root: str = str(Path(os.path.join(Path(os.path.dirname(__file__)).resolve(), os.path.pardir, os.path.pardir)).resolve())
13551356

13561357
dry_run = False
13571358

@@ -1389,7 +1390,7 @@ def run_with_log_tail(command: str | list[str], cwd: str | None, logfile: str |
13891390
if logfile:
13901391
logdir = os.path.dirname(logfile)
13911392
if not os.path.exists(logdir):
1392-
os.makedirs(logdir)
1393+
Path(logdir).mkdir(parents=True)
13931394
fh = open(logfile, "w")
13941395
rc = run_follow(command, cwd, fh=fh, tee=tee, live=live, shell=shell)
13951396
if logfile:

dev-tools/scripts/reproduceJenkinsFailures.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import traceback
2626
import urllib.error
2727
import urllib.request
28+
from pathlib import Path
2829
from textwrap import dedent
2930

3031
# Example: Checking out Revision e441a99009a557f82ea17ee9f9c3e9b89c75cee6 (refs/remotes/origin/master)
@@ -236,7 +237,7 @@ def printAndMoveReports(testIters: int, newSubDir: str, location: str):
236237
break
237238
# have to play nice with 'ant clean'...
238239
newDirPath = os.path.join("repro-reports", newSubDir, dir)
239-
os.makedirs(newDirPath, exist_ok=True)
240+
Path(newDirPath).mkdir(exist_ok=True, parents=True)
240241
os.rename(filePath, os.path.join(newDirPath, file))
241242
print("[repro] Failures%s:" % location)
242243
for testcase in sorted(failures, key=lambda t: (failures[t], t)): # sort by failure count, then by testcase

dev-tools/scripts/scriptutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import urllib.request
2323
from collections.abc import Callable
2424
from enum import Enum
25+
from pathlib import Path
2526
from re import Match, Pattern
2627
from typing import Self, override
2728

@@ -188,7 +189,7 @@ def attemptDownload(urlString: str, fileName: str):
188189

189190
def find_current_version():
190191
script_path = os.path.dirname(os.path.realpath(__file__))
191-
top_level_dir = os.path.join(os.path.abspath("%s/" % script_path), os.path.pardir, os.path.pardir)
192+
top_level_dir = os.path.join(Path("%s/" % script_path).resolve(), os.path.pardir, os.path.pardir)
192193
match = version_prop_re.search(open("%s/build.gradle" % top_level_dir).read())
193194
assert match
194195
return match.group(2).strip()

dev-tools/scripts/smokeTestRelease.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import zipfile
3636
from collections import namedtuple
3737
from collections.abc import Callable
38+
from pathlib import Path
3839
from typing import Any
3940

4041
import scriptutil
@@ -262,7 +263,7 @@ def checkSigs(urlString: str, version: str, tmpDir: str, isSigned: bool, keysFil
262263
gpgHomeDir = "%s/lucene.gpg" % tmpDir
263264
if os.path.exists(gpgHomeDir):
264265
shutil.rmtree(gpgHomeDir)
265-
os.makedirs(gpgHomeDir, 0o700)
266+
Path(gpgHomeDir).mkdir(mode=0o700, parents=True)
266267
run("gpg --homedir %s --import %s" % (gpgHomeDir, keysFile), "%s/lucene.gpg.import.log" % tmpDir)
267268

268269
if mavenURL is None:
@@ -446,7 +447,7 @@ def run(command: str, logFile: str):
446447
if cygwin:
447448
command = cygwinifyPaths(command)
448449
if os.system("%s > %s 2>&1" % (command, logFile)):
449-
logPath = os.path.abspath(logFile)
450+
logPath: str = str(Path(logFile).resolve())
450451
print('\ncommand "%s" failed:' % command)
451452
printFileContents(logFile)
452453
raise RuntimeError('command "%s" failed; see log file %s' % (command, logPath))
@@ -501,7 +502,7 @@ def unpackAndVerify(java: Any, tmpDir: str, artifact: str, gitRevision: str, ver
501502
destDir = "%s/unpack" % tmpDir
502503
if os.path.exists(destDir):
503504
shutil.rmtree(destDir)
504-
os.makedirs(destDir)
505+
Path(destDir).mkdir(parents=True)
505506
os.chdir(destDir)
506507
print(" unpack %s..." % artifact)
507508
unpackLogFile = "%s/lucene-unpack-%s.log" % (tmpDir, artifact)
@@ -722,7 +723,7 @@ def checkMaven(baseURL: str, tmpDir: str, gitRevision: str, version: str, isSign
722723
artifactsURL = "%s/lucene/maven/org/apache/lucene/" % baseURL
723724
targetDir = "%s/maven/org/apache/lucene" % tmpDir
724725
if not os.path.exists(targetDir):
725-
os.makedirs(targetDir)
726+
Path(targetDir).mkdir(parents=True)
726727
crawl(artifacts, artifactsURL, targetDir)
727728
print()
728729
verifyPOMperBinaryArtifact(artifacts, version)
@@ -747,7 +748,7 @@ def getBinaryDistFiles(tmpDir: str, version: str, baseURL: str):
747748
destDir = "%s/unpack-lucene-getBinaryDistFiles" % tmpDir
748749
if os.path.exists(destDir):
749750
shutil.rmtree(destDir)
750-
os.makedirs(destDir)
751+
Path(destDir).mkdir(parents=True)
751752
os.chdir(destDir)
752753
print(" unpack %s..." % distribution)
753754
unpackLogFile = "%s/unpack-%s-getBinaryDistFiles.log" % (tmpDir, distribution)
@@ -864,7 +865,7 @@ def verifyMavenSigs(tmpDir: str, artifacts: list[str], keysFile: str):
864865
gpgHomeDir = "%s/lucene.gpg" % tmpDir
865866
if os.path.exists(gpgHomeDir):
866867
shutil.rmtree(gpgHomeDir)
867-
os.makedirs(gpgHomeDir, 0o700)
868+
Path(gpgHomeDir).mkdir(mode=0o700, parents=True)
868869
run("gpg --homedir %s --import %s" % (gpgHomeDir, keysFile), "%s/lucene.gpg.import.log" % tmpDir)
869870

870871
reArtifacts = re.compile(r"\.(?:pom|[jw]ar)$")
@@ -929,7 +930,7 @@ def crawl(downloadedFiles: list[str], urlString: str, targetDir: str, exclusions
929930
path = os.path.join(targetDir, text)
930931
if text.endswith("/"):
931932
if not os.path.exists(path):
932-
os.makedirs(path)
933+
Path(path).mkdir(parents=True)
933934
crawl(downloadedFiles, subURL, path, exclusions)
934935
else:
935936
if not os.path.exists(path) or FORCE_CLEAN:
@@ -1022,7 +1023,7 @@ def parse_config():
10221023
c.java = make_java_config(parser, c.test_alternative_java)
10231024

10241025
if c.tmp_dir:
1025-
c.tmp_dir = os.path.abspath(c.tmp_dir)
1026+
c.tmp_dir = str(Path(c.tmp_dir).resolve())
10261027
else:
10271028
tmp = "/tmp/smoke_lucene_%s_%s" % (c.version, c.revision)
10281029
c.tmp_dir = tmp
@@ -1162,7 +1163,7 @@ def smokeTest(java: Any, baseURL: str, gitRevision: str, version: str, tmpDir: s
11621163
raise RuntimeError("temp dir %s exists; please remove first" % tmpDir)
11631164

11641165
if not os.path.exists(tmpDir):
1165-
os.makedirs(tmpDir)
1166+
Path(tmpDir).mkdir(parents=True)
11661167

11671168
lucenePath = None
11681169
print()

lucene/CHANGES.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ Optimizations
106106

107107
* GITHUB#14447: Compute the doc range more efficiently when flushing doc block. (Pan Guixin)
108108

109+
* GITHUB#14527: Reduce NeighborArray heap memory. (weizijun)
110+
109111
* GITHUB#14529, GITHUB#14555, GITHUB#14618: Impl intoBitset for IndexedDISI and Docvalues. (Guo Feng)
110112

111113
* GITHUB#14552: Speed up flush of softdelete by intoBitset. (Guo Feng)
@@ -119,6 +121,13 @@ Optimizations
119121
* GITHUB#14700: Return MatchNoDocsQuery when IndexOrDocValuesQuery::rewrite does not match
120122
(Chris Hegarty)
121123

124+
* GITHUB#14701: Optimize top-n bulk scorers by evaluating scoring windows in a
125+
term-at-a-time fashion instead of doc-at-a-time. (Adrien Grand)
126+
127+
* GITHUB#14709: Speed up TermQuery by Scorer#nextDocsAndScores. (Guo Feng)
128+
129+
* GITHUB#14674: Optimize AbstractKnnVectorQuery#createBitSet with intoBitset. (Guo Feng)
130+
122131
Bug Fixes
123132
---------------------
124133
* GITHUB#14654: ValueSource.fromDoubleValuesSource(dvs).getSortField() would throw errors when
@@ -142,9 +151,9 @@ Other
142151

143152
* GITHUB#14516: Move sloppySin into SloppyMath from GeoUtils (Ankit Jain)
144153

145-
* GITHUB#14627, GITHUB#11920: Fix mock filesystem WindowsFS to also work on Windows.
146-
This is required to make tests pass on Windows 11 which no longer has
147-
all limitations of previous Windows versions. (Uwe Schindler)
154+
* GITHUB#14627, GITHUB#11920, GITHUB#14706: Fix mock filesystem WindowsFS to also
155+
work on Windows. This is required to make tests pass on Windows 11 which no
156+
longer has all limitations of previous Windows versions. (Uwe Schindler)
148157

149158

150159
======================= Lucene 10.2.1 =======================

lucene/core/src/java/org/apache/lucene/codecs/lucene103/Lucene103PostingsReader.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,32 @@ private void bufferIntoBitSet(int start, int end, FixedBitSet bitSet, int offset
10971097
}
10981098
}
10991099

1100+
@Override
1101+
public int docIDRunEnd() throws IOException {
1102+
// Note: this assumes that BLOCK_SIZE == 128, this bit of the code would need to be changed if
1103+
// the block size was changed.
1104+
// Hack to avoid compiler warning that both sides of the equal sign are identical.
1105+
long blockSize = BLOCK_SIZE;
1106+
assert blockSize == 2 * Long.SIZE;
1107+
boolean level0IsDense =
1108+
encoding == DeltaEncoding.UNARY
1109+
&& docBitSet.getBits()[0] == -1L
1110+
&& docBitSet.getBits()[1] == -1L;
1111+
if (level0IsDense) {
1112+
1113+
int level0DocCountUpto = docFreq - docCountLeft;
1114+
boolean level1IsDense =
1115+
level1LastDocID - level0LastDocID == level1DocCountUpto - level0DocCountUpto;
1116+
if (level1IsDense) {
1117+
return level1LastDocID + 1;
1118+
}
1119+
1120+
return level0LastDocID + 1;
1121+
}
1122+
1123+
return super.docIDRunEnd();
1124+
}
1125+
11001126
private void skipPositions(int freq) throws IOException {
11011127
// Skip positions now:
11021128
int toSkip = posPendingCount - freq;

0 commit comments

Comments
 (0)