mirror of
https://github.com/apache/lucene.git
synced 2025-02-17 23:45:09 +00:00
nuke i/o from byteblockpool
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1438216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2857df98de
commit
bfeaaf83a1
@ -16,12 +16,10 @@ package org.apache.lucene.util;
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.lucene.store.DataOutput;
|
|
||||||
|
|
||||||
import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_OBJECT_REF;
|
import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_OBJECT_REF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -297,18 +295,6 @@ public final class ByteBlockPool {
|
|||||||
assert term.length >= 0;
|
assert term.length >= 0;
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Dereferences the byte block according to {@link BytesRef} offset. The offset
|
|
||||||
* is interpreted as the absolute offset into the {@link ByteBlockPool}.
|
|
||||||
*/
|
|
||||||
public final BytesRef deref(BytesRef bytes) {
|
|
||||||
final int offset = bytes.offset;
|
|
||||||
byte[] buffer = buffers[offset >> BYTE_BLOCK_SHIFT];
|
|
||||||
int pos = offset & BYTE_BLOCK_MASK;
|
|
||||||
bytes.bytes = buffer;
|
|
||||||
bytes.offset = pos;
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies the given {@link BytesRef} at the current positions (
|
* Copies the given {@link BytesRef} at the current positions (
|
||||||
@ -365,18 +351,5 @@ public final class ByteBlockPool {
|
|||||||
} while (true);
|
} while (true);
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the pools content to the given {@link DataOutput}
|
|
||||||
*/
|
|
||||||
public final void writePool(final DataOutput out) throws IOException {
|
|
||||||
int bytesOffset = byteOffset;
|
|
||||||
int block = 0;
|
|
||||||
while (bytesOffset > 0) {
|
|
||||||
out.writeBytes(buffers[block++], BYTE_BLOCK_SIZE);
|
|
||||||
bytesOffset -= BYTE_BLOCK_SIZE;
|
|
||||||
}
|
|
||||||
out.writeBytes(buffers[block], byteUpto);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import org.apache.lucene.store.RAMDirectory;
|
|||||||
*/
|
*/
|
||||||
public class TestByteBlockPool extends LuceneTestCase {
|
public class TestByteBlockPool extends LuceneTestCase {
|
||||||
|
|
||||||
|
/* nocommit: test this in some other way than dumping out
|
||||||
public void testCopyRefAndWrite() throws IOException {
|
public void testCopyRefAndWrite() throws IOException {
|
||||||
Counter bytesUsed = Counter.newCounter();
|
Counter bytesUsed = Counter.newCounter();
|
||||||
ByteBlockPool pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(bytesUsed));
|
ByteBlockPool pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(bytesUsed));
|
||||||
@ -76,5 +77,5 @@ public class TestByteBlockPool extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
dir.close();
|
dir.close();
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user