[ https://issues.apache.org/jira/browse/LUCENE-1990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12803743#action_12803743 ]
Paul Elschot commented on LUCENE-1990: -------------------------------------- The generated code in the patches has quite a few switch statements to decode a single value. These switch statements could be avoided by using something like this (adapted from the 1410b patch): {code} /** Decode a value from the compressed array of b bit values by retrieving the corresponding bits. * Since numFrameBits is always smaller than the number of bits in an int, * at most two ints in the buffer will be used. */ public int decodeCompressedValueBase(int compressedPos, int numBits) { int compressedBitPos = numBits * compressedPos; int intIndex = (compressedBitPos >> 5); int firstBitPosition = compressedBitPos & 31; int value = intBuffer.get(intIndex) >>> firstBitPosition; if ((firstBitPosition + numBits) > 32) { // value does not fit in first int intIndex++; value |= (intBuffer.get(intIndex) << (32 - firstBitPosition)); } final int maxValue = (int) ((1L << numBits) - 1); return value & maxValue; } {code} As maxValue is essentially a mask, it could also be looked up in an array. Could that be faster than these generated switch statements? > Add unsigned packed int impls in oal.util > ----------------------------------------- > > Key: LUCENE-1990 > URL: https://issues.apache.org/jira/browse/LUCENE-1990 > Project: Lucene - Java > Issue Type: Improvement > Components: Index > Reporter: Michael McCandless > Priority: Minor > Attachments: LUCENE-1990-te20100122.patch, LUCENE-1990.patch, > LUCENE-1990_PerformanceMeasurements20100104.zip > > > There are various places in Lucene that could take advantage of an > efficient packed unsigned int/long impl. EG the terms dict index in > the standard codec in LUCENE-1458 could subsantially reduce it's RAM > usage. FieldCache.StringIndex could as well. And I think "load into > RAM" codecs like the one in TestExternalCodecs could use this too. > I'm picturing something very basic like: > {code} > interface PackedUnsignedLongs { > long get(long index); > void set(long index, long value); > } > {code} > Plus maybe an iterator for getting and maybe also for setting. If it > helps, most of the usages of this inside Lucene will be "write once" > so eg the set could make that an assumption/requirement. > And a factory somewhere: > {code} > PackedUnsignedLongs create(int count, long maxValue); > {code} > I think we should simply autogen the code (we can start from the > autogen code in LUCENE-1410), or, if there is an good existing impl > that has a compatible license that'd be great. > I don't have time near-term to do this... so if anyone has the itch, > please jump! -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org