-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use value-based LRU cache in NodeHash #12738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0c03d8a
Use value-based LRU cache in NodeHash (#12714)
dungba88 728ea1f
tidy code
dungba88 c12e892
Add a nocommit about OffsetAndLength
dungba88 11ab1fa
Fix the readBytes method
dungba88 b5a1be9
Use List<byte[]> instead of ByteBlockPool
dungba88 2d2ad31
Move nodesEqual to PagedGrowableHash
dungba88 fe33813
Add generic type
dungba88 dd7cf64
Fix the count variable
dungba88 3180fe2
Fix the RAM usage measurement
dungba88 b9d4209
Use PagedGrowableWriter instead of HashMap
dungba88 b6715a6
Remove unused generic type
dungba88 fafd6a0
Update the ramBytesUsed formula
dungba88 214091c
Retain the FSTCompiler.addNode signature
dungba88 06bc741
Switch back to ByteBlockPool
dungba88 42dfbe3
Remove the unnecessary assertion
dungba88 8a0ea42
Remove fstHashAddress
dungba88 3e3416c
Add some javadoc
dungba88 8d95bf5
Fix the address offset when reading from fallback table
dungba88 9397ec8
tidy code
dungba88 bf1bc49
Address comments
dungba88 1afd4b9
Add assertions
dungba88 8c4856d
Merge branch 'apache:main' into refactor-nodehash
dungba88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
lucene/core/src/java/org/apache/lucene/util/fst/ByteBlockPoolReverseBytesReader.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.lucene.util.fst; | ||
|
|
||
| import java.io.IOException; | ||
| import org.apache.lucene.util.ByteBlockPool; | ||
|
|
||
| /** Reads in reverse from a ByteBlockPool. */ | ||
| final class ByteBlockPoolReverseBytesReader extends FST.BytesReader { | ||
|
|
||
| private final ByteBlockPool buf; | ||
| // the difference between the FST node address and the hash table copied node address | ||
| private long posDelta; | ||
| private long pos; | ||
|
|
||
| public ByteBlockPoolReverseBytesReader(ByteBlockPool buf) { | ||
| this.buf = buf; | ||
| } | ||
|
|
||
| @Override | ||
| public byte readByte() { | ||
| return buf.readByte(pos--); | ||
| } | ||
|
|
||
| @Override | ||
| public void readBytes(byte[] b, int offset, int len) { | ||
| for (int i = 0; i < len; i++) { | ||
| b[offset + i] = buf.readByte(pos--); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void skipBytes(long numBytes) throws IOException { | ||
| pos -= numBytes; | ||
| } | ||
|
|
||
| @Override | ||
| public long getPosition() { | ||
| return pos + posDelta; | ||
| } | ||
|
|
||
| @Override | ||
| public void setPosition(long pos) { | ||
| this.pos = pos - posDelta; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean reversed() { | ||
| return true; | ||
| } | ||
|
|
||
| public void setPosDelta(long posDelta) { | ||
| this.posDelta = posDelta; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why
FST.BytesReadereven has this method? It might be a holdover (now dead?) from thepackdays (long ago removed). But we should not try to fix it here ... this change is awesome enough already!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open a spinoff issue for this -- it seems at quick glance to be dead/pointless code.