-
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
Changes from all commits
0c03d8a
728ea1f
c12e892
11ab1fa
b5a1be9
2d2ad31
fe33813
dd7cf64
3180fe2
b9d4209
b6715a6
fafd6a0
214091c
06bc741
42dfbe3
8a0ea42
3e3416c
8d95bf5
9397ec8
bf1bc49
1afd4b9
8c4856d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| return true; | ||
| } | ||
|
|
||
| public void setPosDelta(long posDelta) { | ||
| this.posDelta = posDelta; | ||
| } | ||
| } | ||
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.
Hmm do we have any
iforassertthat confirmsAllocator'sblockSize==ByteBlockPool.BYTE_BLOCK_SIZEwhen passed toByteBlockPool?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.
We don't have, and this Allocator seems to be only used by ByteBlockPool so maybe we don't need it to have custom block size?