lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject svn commit: r1379491 [12/12] - /lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/
Date Fri, 31 Aug 2012 16:01:22 GMT
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/BulkOperationPacked9.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/BulkOperationPacked9.java?rev=1379491&r1=1379490&r2=1379491&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/BulkOperationPacked9.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/BulkOperationPacked9.java Fri Aug 31 16:01:20 2012
@@ -24,460 +24,214 @@ package org.apache.lucene.util.packed;
  */
 final class BulkOperationPacked9 extends BulkOperationPacked {
 
-    public BulkOperationPacked9() {
-      super(9);
-      assert blockCount() == 9;
-      assert valueCount() == 64;
+  public BulkOperationPacked9() {
+    super(9);
+    assert blockCount() == 9;
+    assert valueCount() == 64;
+  }
+
+  @Override
+  public void decode(long[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations) {
+    for (int i = 0; i < iterations; ++i) {
+      final long block0 = blocks[blocksOffset++];
+      values[valuesOffset++] = (int) (block0 >>> 55);
+      values[valuesOffset++] = (int) ((block0 >>> 46) & 511L);
+      values[valuesOffset++] = (int) ((block0 >>> 37) & 511L);
+      values[valuesOffset++] = (int) ((block0 >>> 28) & 511L);
+      values[valuesOffset++] = (int) ((block0 >>> 19) & 511L);
+      values[valuesOffset++] = (int) ((block0 >>> 10) & 511L);
+      values[valuesOffset++] = (int) ((block0 >>> 1) & 511L);
+      final long block1 = blocks[blocksOffset++];
+      values[valuesOffset++] = (int) (((block0 & 1L) << 8) | (block1 >>> 56));
+      values[valuesOffset++] = (int) ((block1 >>> 47) & 511L);
+      values[valuesOffset++] = (int) ((block1 >>> 38) & 511L);
+      values[valuesOffset++] = (int) ((block1 >>> 29) & 511L);
+      values[valuesOffset++] = (int) ((block1 >>> 20) & 511L);
+      values[valuesOffset++] = (int) ((block1 >>> 11) & 511L);
+      values[valuesOffset++] = (int) ((block1 >>> 2) & 511L);
+      final long block2 = blocks[blocksOffset++];
+      values[valuesOffset++] = (int) (((block1 & 3L) << 7) | (block2 >>> 57));
+      values[valuesOffset++] = (int) ((block2 >>> 48) & 511L);
+      values[valuesOffset++] = (int) ((block2 >>> 39) & 511L);
+      values[valuesOffset++] = (int) ((block2 >>> 30) & 511L);
+      values[valuesOffset++] = (int) ((block2 >>> 21) & 511L);
+      values[valuesOffset++] = (int) ((block2 >>> 12) & 511L);
+      values[valuesOffset++] = (int) ((block2 >>> 3) & 511L);
+      final long block3 = blocks[blocksOffset++];
+      values[valuesOffset++] = (int) (((block2 & 7L) << 6) | (block3 >>> 58));
+      values[valuesOffset++] = (int) ((block3 >>> 49) & 511L);
+      values[valuesOffset++] = (int) ((block3 >>> 40) & 511L);
+      values[valuesOffset++] = (int) ((block3 >>> 31) & 511L);
+      values[valuesOffset++] = (int) ((block3 >>> 22) & 511L);
+      values[valuesOffset++] = (int) ((block3 >>> 13) & 511L);
+      values[valuesOffset++] = (int) ((block3 >>> 4) & 511L);
+      final long block4 = blocks[blocksOffset++];
+      values[valuesOffset++] = (int) (((block3 & 15L) << 5) | (block4 >>> 59));
+      values[valuesOffset++] = (int) ((block4 >>> 50) & 511L);
+      values[valuesOffset++] = (int) ((block4 >>> 41) & 511L);
+      values[valuesOffset++] = (int) ((block4 >>> 32) & 511L);
+      values[valuesOffset++] = (int) ((block4 >>> 23) & 511L);
+      values[valuesOffset++] = (int) ((block4 >>> 14) & 511L);
+      values[valuesOffset++] = (int) ((block4 >>> 5) & 511L);
+      final long block5 = blocks[blocksOffset++];
+      values[valuesOffset++] = (int) (((block4 & 31L) << 4) | (block5 >>> 60));
+      values[valuesOffset++] = (int) ((block5 >>> 51) & 511L);
+      values[valuesOffset++] = (int) ((block5 >>> 42) & 511L);
+      values[valuesOffset++] = (int) ((block5 >>> 33) & 511L);
+      values[valuesOffset++] = (int) ((block5 >>> 24) & 511L);
+      values[valuesOffset++] = (int) ((block5 >>> 15) & 511L);
+      values[valuesOffset++] = (int) ((block5 >>> 6) & 511L);
+      final long block6 = blocks[blocksOffset++];
+      values[valuesOffset++] = (int) (((block5 & 63L) << 3) | (block6 >>> 61));
+      values[valuesOffset++] = (int) ((block6 >>> 52) & 511L);
+      values[valuesOffset++] = (int) ((block6 >>> 43) & 511L);
+      values[valuesOffset++] = (int) ((block6 >>> 34) & 511L);
+      values[valuesOffset++] = (int) ((block6 >>> 25) & 511L);
+      values[valuesOffset++] = (int) ((block6 >>> 16) & 511L);
+      values[valuesOffset++] = (int) ((block6 >>> 7) & 511L);
+      final long block7 = blocks[blocksOffset++];
+      values[valuesOffset++] = (int) (((block6 & 127L) << 2) | (block7 >>> 62));
+      values[valuesOffset++] = (int) ((block7 >>> 53) & 511L);
+      values[valuesOffset++] = (int) ((block7 >>> 44) & 511L);
+      values[valuesOffset++] = (int) ((block7 >>> 35) & 511L);
+      values[valuesOffset++] = (int) ((block7 >>> 26) & 511L);
+      values[valuesOffset++] = (int) ((block7 >>> 17) & 511L);
+      values[valuesOffset++] = (int) ((block7 >>> 8) & 511L);
+      final long block8 = blocks[blocksOffset++];
+      values[valuesOffset++] = (int) (((block7 & 255L) << 1) | (block8 >>> 63));
+      values[valuesOffset++] = (int) ((block8 >>> 54) & 511L);
+      values[valuesOffset++] = (int) ((block8 >>> 45) & 511L);
+      values[valuesOffset++] = (int) ((block8 >>> 36) & 511L);
+      values[valuesOffset++] = (int) ((block8 >>> 27) & 511L);
+      values[valuesOffset++] = (int) ((block8 >>> 18) & 511L);
+      values[valuesOffset++] = (int) ((block8 >>> 9) & 511L);
+      values[valuesOffset++] = (int) (block8 & 511L);
     }
+  }
 
-    @Override
-    public void decode(long[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations) {
-      assert blocksOffset + iterations * blockCount() <= blocks.length;
-      assert valuesOffset + iterations * valueCount() <= values.length;
-      for (int i = 0; i < iterations; ++i) {
-        final long block0 = blocks[blocksOffset++];
-        values[valuesOffset++] = (int) (block0 >>> 55);
-        values[valuesOffset++] = (int) ((block0 >>> 46) & 511L);
-        values[valuesOffset++] = (int) ((block0 >>> 37) & 511L);
-        values[valuesOffset++] = (int) ((block0 >>> 28) & 511L);
-        values[valuesOffset++] = (int) ((block0 >>> 19) & 511L);
-        values[valuesOffset++] = (int) ((block0 >>> 10) & 511L);
-        values[valuesOffset++] = (int) ((block0 >>> 1) & 511L);
-        final long block1 = blocks[blocksOffset++];
-        values[valuesOffset++] = (int) (((block0 & 1L) << 8) | (block1 >>> 56));
-        values[valuesOffset++] = (int) ((block1 >>> 47) & 511L);
-        values[valuesOffset++] = (int) ((block1 >>> 38) & 511L);
-        values[valuesOffset++] = (int) ((block1 >>> 29) & 511L);
-        values[valuesOffset++] = (int) ((block1 >>> 20) & 511L);
-        values[valuesOffset++] = (int) ((block1 >>> 11) & 511L);
-        values[valuesOffset++] = (int) ((block1 >>> 2) & 511L);
-        final long block2 = blocks[blocksOffset++];
-        values[valuesOffset++] = (int) (((block1 & 3L) << 7) | (block2 >>> 57));
-        values[valuesOffset++] = (int) ((block2 >>> 48) & 511L);
-        values[valuesOffset++] = (int) ((block2 >>> 39) & 511L);
-        values[valuesOffset++] = (int) ((block2 >>> 30) & 511L);
-        values[valuesOffset++] = (int) ((block2 >>> 21) & 511L);
-        values[valuesOffset++] = (int) ((block2 >>> 12) & 511L);
-        values[valuesOffset++] = (int) ((block2 >>> 3) & 511L);
-        final long block3 = blocks[blocksOffset++];
-        values[valuesOffset++] = (int) (((block2 & 7L) << 6) | (block3 >>> 58));
-        values[valuesOffset++] = (int) ((block3 >>> 49) & 511L);
-        values[valuesOffset++] = (int) ((block3 >>> 40) & 511L);
-        values[valuesOffset++] = (int) ((block3 >>> 31) & 511L);
-        values[valuesOffset++] = (int) ((block3 >>> 22) & 511L);
-        values[valuesOffset++] = (int) ((block3 >>> 13) & 511L);
-        values[valuesOffset++] = (int) ((block3 >>> 4) & 511L);
-        final long block4 = blocks[blocksOffset++];
-        values[valuesOffset++] = (int) (((block3 & 15L) << 5) | (block4 >>> 59));
-        values[valuesOffset++] = (int) ((block4 >>> 50) & 511L);
-        values[valuesOffset++] = (int) ((block4 >>> 41) & 511L);
-        values[valuesOffset++] = (int) ((block4 >>> 32) & 511L);
-        values[valuesOffset++] = (int) ((block4 >>> 23) & 511L);
-        values[valuesOffset++] = (int) ((block4 >>> 14) & 511L);
-        values[valuesOffset++] = (int) ((block4 >>> 5) & 511L);
-        final long block5 = blocks[blocksOffset++];
-        values[valuesOffset++] = (int) (((block4 & 31L) << 4) | (block5 >>> 60));
-        values[valuesOffset++] = (int) ((block5 >>> 51) & 511L);
-        values[valuesOffset++] = (int) ((block5 >>> 42) & 511L);
-        values[valuesOffset++] = (int) ((block5 >>> 33) & 511L);
-        values[valuesOffset++] = (int) ((block5 >>> 24) & 511L);
-        values[valuesOffset++] = (int) ((block5 >>> 15) & 511L);
-        values[valuesOffset++] = (int) ((block5 >>> 6) & 511L);
-        final long block6 = blocks[blocksOffset++];
-        values[valuesOffset++] = (int) (((block5 & 63L) << 3) | (block6 >>> 61));
-        values[valuesOffset++] = (int) ((block6 >>> 52) & 511L);
-        values[valuesOffset++] = (int) ((block6 >>> 43) & 511L);
-        values[valuesOffset++] = (int) ((block6 >>> 34) & 511L);
-        values[valuesOffset++] = (int) ((block6 >>> 25) & 511L);
-        values[valuesOffset++] = (int) ((block6 >>> 16) & 511L);
-        values[valuesOffset++] = (int) ((block6 >>> 7) & 511L);
-        final long block7 = blocks[blocksOffset++];
-        values[valuesOffset++] = (int) (((block6 & 127L) << 2) | (block7 >>> 62));
-        values[valuesOffset++] = (int) ((block7 >>> 53) & 511L);
-        values[valuesOffset++] = (int) ((block7 >>> 44) & 511L);
-        values[valuesOffset++] = (int) ((block7 >>> 35) & 511L);
-        values[valuesOffset++] = (int) ((block7 >>> 26) & 511L);
-        values[valuesOffset++] = (int) ((block7 >>> 17) & 511L);
-        values[valuesOffset++] = (int) ((block7 >>> 8) & 511L);
-        final long block8 = blocks[blocksOffset++];
-        values[valuesOffset++] = (int) (((block7 & 255L) << 1) | (block8 >>> 63));
-        values[valuesOffset++] = (int) ((block8 >>> 54) & 511L);
-        values[valuesOffset++] = (int) ((block8 >>> 45) & 511L);
-        values[valuesOffset++] = (int) ((block8 >>> 36) & 511L);
-        values[valuesOffset++] = (int) ((block8 >>> 27) & 511L);
-        values[valuesOffset++] = (int) ((block8 >>> 18) & 511L);
-        values[valuesOffset++] = (int) ((block8 >>> 9) & 511L);
-        values[valuesOffset++] = (int) (block8 & 511L);
-      }
+  @Override
+  public void decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations) {
+    for (int i = 0; i < 8 * iterations; ++i) {
+      final int byte0 = blocks[blocksOffset++] & 0xFF;
+      final int byte1 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = (byte0 << 1) | (byte1 >>> 7);
+      final int byte2 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte1 & 127) << 2) | (byte2 >>> 6);
+      final int byte3 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte2 & 63) << 3) | (byte3 >>> 5);
+      final int byte4 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte3 & 31) << 4) | (byte4 >>> 4);
+      final int byte5 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte4 & 15) << 5) | (byte5 >>> 3);
+      final int byte6 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte5 & 7) << 6) | (byte6 >>> 2);
+      final int byte7 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte6 & 3) << 7) | (byte7 >>> 1);
+      final int byte8 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte7 & 1) << 8) | byte8;
     }
+  }
 
-    @Override
-    public void decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations) {
-      assert blocksOffset + 8 * iterations * blockCount() <= blocks.length;
-      assert valuesOffset + iterations * valueCount() <= values.length;
-      for (int i = 0; i < iterations; ++i) {
-        final int byte0 = blocks[blocksOffset++] & 0xFF;
-        final int byte1 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte0 << 1) | (byte1 >>> 7);
-        final int byte2 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte1 & 127) << 2) | (byte2 >>> 6);
-        final int byte3 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte2 & 63) << 3) | (byte3 >>> 5);
-        final int byte4 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte3 & 31) << 4) | (byte4 >>> 4);
-        final int byte5 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte4 & 15) << 5) | (byte5 >>> 3);
-        final int byte6 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte5 & 7) << 6) | (byte6 >>> 2);
-        final int byte7 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte6 & 3) << 7) | (byte7 >>> 1);
-        final int byte8 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte7 & 1) << 8) | byte8;
-        final int byte9 = blocks[blocksOffset++] & 0xFF;
-        final int byte10 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte9 << 1) | (byte10 >>> 7);
-        final int byte11 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte10 & 127) << 2) | (byte11 >>> 6);
-        final int byte12 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte11 & 63) << 3) | (byte12 >>> 5);
-        final int byte13 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte12 & 31) << 4) | (byte13 >>> 4);
-        final int byte14 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte13 & 15) << 5) | (byte14 >>> 3);
-        final int byte15 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte14 & 7) << 6) | (byte15 >>> 2);
-        final int byte16 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte15 & 3) << 7) | (byte16 >>> 1);
-        final int byte17 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte16 & 1) << 8) | byte17;
-        final int byte18 = blocks[blocksOffset++] & 0xFF;
-        final int byte19 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte18 << 1) | (byte19 >>> 7);
-        final int byte20 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte19 & 127) << 2) | (byte20 >>> 6);
-        final int byte21 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte20 & 63) << 3) | (byte21 >>> 5);
-        final int byte22 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte21 & 31) << 4) | (byte22 >>> 4);
-        final int byte23 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte22 & 15) << 5) | (byte23 >>> 3);
-        final int byte24 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte23 & 7) << 6) | (byte24 >>> 2);
-        final int byte25 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte24 & 3) << 7) | (byte25 >>> 1);
-        final int byte26 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte25 & 1) << 8) | byte26;
-        final int byte27 = blocks[blocksOffset++] & 0xFF;
-        final int byte28 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte27 << 1) | (byte28 >>> 7);
-        final int byte29 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte28 & 127) << 2) | (byte29 >>> 6);
-        final int byte30 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte29 & 63) << 3) | (byte30 >>> 5);
-        final int byte31 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte30 & 31) << 4) | (byte31 >>> 4);
-        final int byte32 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte31 & 15) << 5) | (byte32 >>> 3);
-        final int byte33 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte32 & 7) << 6) | (byte33 >>> 2);
-        final int byte34 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte33 & 3) << 7) | (byte34 >>> 1);
-        final int byte35 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte34 & 1) << 8) | byte35;
-        final int byte36 = blocks[blocksOffset++] & 0xFF;
-        final int byte37 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte36 << 1) | (byte37 >>> 7);
-        final int byte38 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte37 & 127) << 2) | (byte38 >>> 6);
-        final int byte39 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte38 & 63) << 3) | (byte39 >>> 5);
-        final int byte40 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte39 & 31) << 4) | (byte40 >>> 4);
-        final int byte41 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte40 & 15) << 5) | (byte41 >>> 3);
-        final int byte42 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte41 & 7) << 6) | (byte42 >>> 2);
-        final int byte43 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte42 & 3) << 7) | (byte43 >>> 1);
-        final int byte44 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte43 & 1) << 8) | byte44;
-        final int byte45 = blocks[blocksOffset++] & 0xFF;
-        final int byte46 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte45 << 1) | (byte46 >>> 7);
-        final int byte47 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte46 & 127) << 2) | (byte47 >>> 6);
-        final int byte48 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte47 & 63) << 3) | (byte48 >>> 5);
-        final int byte49 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte48 & 31) << 4) | (byte49 >>> 4);
-        final int byte50 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte49 & 15) << 5) | (byte50 >>> 3);
-        final int byte51 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte50 & 7) << 6) | (byte51 >>> 2);
-        final int byte52 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte51 & 3) << 7) | (byte52 >>> 1);
-        final int byte53 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte52 & 1) << 8) | byte53;
-        final int byte54 = blocks[blocksOffset++] & 0xFF;
-        final int byte55 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte54 << 1) | (byte55 >>> 7);
-        final int byte56 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte55 & 127) << 2) | (byte56 >>> 6);
-        final int byte57 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte56 & 63) << 3) | (byte57 >>> 5);
-        final int byte58 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte57 & 31) << 4) | (byte58 >>> 4);
-        final int byte59 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte58 & 15) << 5) | (byte59 >>> 3);
-        final int byte60 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte59 & 7) << 6) | (byte60 >>> 2);
-        final int byte61 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte60 & 3) << 7) | (byte61 >>> 1);
-        final int byte62 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte61 & 1) << 8) | byte62;
-        final int byte63 = blocks[blocksOffset++] & 0xFF;
-        final int byte64 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte63 << 1) | (byte64 >>> 7);
-        final int byte65 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte64 & 127) << 2) | (byte65 >>> 6);
-        final int byte66 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte65 & 63) << 3) | (byte66 >>> 5);
-        final int byte67 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte66 & 31) << 4) | (byte67 >>> 4);
-        final int byte68 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte67 & 15) << 5) | (byte68 >>> 3);
-        final int byte69 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte68 & 7) << 6) | (byte69 >>> 2);
-        final int byte70 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte69 & 3) << 7) | (byte70 >>> 1);
-        final int byte71 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte70 & 1) << 8) | byte71;
-      }
+  @Override
+  public void decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations) {
+    for (int i = 0; i < iterations; ++i) {
+      final long block0 = blocks[blocksOffset++];
+      values[valuesOffset++] = block0 >>> 55;
+      values[valuesOffset++] = (block0 >>> 46) & 511L;
+      values[valuesOffset++] = (block0 >>> 37) & 511L;
+      values[valuesOffset++] = (block0 >>> 28) & 511L;
+      values[valuesOffset++] = (block0 >>> 19) & 511L;
+      values[valuesOffset++] = (block0 >>> 10) & 511L;
+      values[valuesOffset++] = (block0 >>> 1) & 511L;
+      final long block1 = blocks[blocksOffset++];
+      values[valuesOffset++] = ((block0 & 1L) << 8) | (block1 >>> 56);
+      values[valuesOffset++] = (block1 >>> 47) & 511L;
+      values[valuesOffset++] = (block1 >>> 38) & 511L;
+      values[valuesOffset++] = (block1 >>> 29) & 511L;
+      values[valuesOffset++] = (block1 >>> 20) & 511L;
+      values[valuesOffset++] = (block1 >>> 11) & 511L;
+      values[valuesOffset++] = (block1 >>> 2) & 511L;
+      final long block2 = blocks[blocksOffset++];
+      values[valuesOffset++] = ((block1 & 3L) << 7) | (block2 >>> 57);
+      values[valuesOffset++] = (block2 >>> 48) & 511L;
+      values[valuesOffset++] = (block2 >>> 39) & 511L;
+      values[valuesOffset++] = (block2 >>> 30) & 511L;
+      values[valuesOffset++] = (block2 >>> 21) & 511L;
+      values[valuesOffset++] = (block2 >>> 12) & 511L;
+      values[valuesOffset++] = (block2 >>> 3) & 511L;
+      final long block3 = blocks[blocksOffset++];
+      values[valuesOffset++] = ((block2 & 7L) << 6) | (block3 >>> 58);
+      values[valuesOffset++] = (block3 >>> 49) & 511L;
+      values[valuesOffset++] = (block3 >>> 40) & 511L;
+      values[valuesOffset++] = (block3 >>> 31) & 511L;
+      values[valuesOffset++] = (block3 >>> 22) & 511L;
+      values[valuesOffset++] = (block3 >>> 13) & 511L;
+      values[valuesOffset++] = (block3 >>> 4) & 511L;
+      final long block4 = blocks[blocksOffset++];
+      values[valuesOffset++] = ((block3 & 15L) << 5) | (block4 >>> 59);
+      values[valuesOffset++] = (block4 >>> 50) & 511L;
+      values[valuesOffset++] = (block4 >>> 41) & 511L;
+      values[valuesOffset++] = (block4 >>> 32) & 511L;
+      values[valuesOffset++] = (block4 >>> 23) & 511L;
+      values[valuesOffset++] = (block4 >>> 14) & 511L;
+      values[valuesOffset++] = (block4 >>> 5) & 511L;
+      final long block5 = blocks[blocksOffset++];
+      values[valuesOffset++] = ((block4 & 31L) << 4) | (block5 >>> 60);
+      values[valuesOffset++] = (block5 >>> 51) & 511L;
+      values[valuesOffset++] = (block5 >>> 42) & 511L;
+      values[valuesOffset++] = (block5 >>> 33) & 511L;
+      values[valuesOffset++] = (block5 >>> 24) & 511L;
+      values[valuesOffset++] = (block5 >>> 15) & 511L;
+      values[valuesOffset++] = (block5 >>> 6) & 511L;
+      final long block6 = blocks[blocksOffset++];
+      values[valuesOffset++] = ((block5 & 63L) << 3) | (block6 >>> 61);
+      values[valuesOffset++] = (block6 >>> 52) & 511L;
+      values[valuesOffset++] = (block6 >>> 43) & 511L;
+      values[valuesOffset++] = (block6 >>> 34) & 511L;
+      values[valuesOffset++] = (block6 >>> 25) & 511L;
+      values[valuesOffset++] = (block6 >>> 16) & 511L;
+      values[valuesOffset++] = (block6 >>> 7) & 511L;
+      final long block7 = blocks[blocksOffset++];
+      values[valuesOffset++] = ((block6 & 127L) << 2) | (block7 >>> 62);
+      values[valuesOffset++] = (block7 >>> 53) & 511L;
+      values[valuesOffset++] = (block7 >>> 44) & 511L;
+      values[valuesOffset++] = (block7 >>> 35) & 511L;
+      values[valuesOffset++] = (block7 >>> 26) & 511L;
+      values[valuesOffset++] = (block7 >>> 17) & 511L;
+      values[valuesOffset++] = (block7 >>> 8) & 511L;
+      final long block8 = blocks[blocksOffset++];
+      values[valuesOffset++] = ((block7 & 255L) << 1) | (block8 >>> 63);
+      values[valuesOffset++] = (block8 >>> 54) & 511L;
+      values[valuesOffset++] = (block8 >>> 45) & 511L;
+      values[valuesOffset++] = (block8 >>> 36) & 511L;
+      values[valuesOffset++] = (block8 >>> 27) & 511L;
+      values[valuesOffset++] = (block8 >>> 18) & 511L;
+      values[valuesOffset++] = (block8 >>> 9) & 511L;
+      values[valuesOffset++] = block8 & 511L;
     }
+  }
 
-    @Override
-    public void decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations) {
-      assert blocksOffset + iterations * blockCount() <= blocks.length;
-      assert valuesOffset + iterations * valueCount() <= values.length;
-      for (int i = 0; i < iterations; ++i) {
-        final long block0 = blocks[blocksOffset++];
-        values[valuesOffset++] = block0 >>> 55;
-        values[valuesOffset++] = (block0 >>> 46) & 511L;
-        values[valuesOffset++] = (block0 >>> 37) & 511L;
-        values[valuesOffset++] = (block0 >>> 28) & 511L;
-        values[valuesOffset++] = (block0 >>> 19) & 511L;
-        values[valuesOffset++] = (block0 >>> 10) & 511L;
-        values[valuesOffset++] = (block0 >>> 1) & 511L;
-        final long block1 = blocks[blocksOffset++];
-        values[valuesOffset++] = ((block0 & 1L) << 8) | (block1 >>> 56);
-        values[valuesOffset++] = (block1 >>> 47) & 511L;
-        values[valuesOffset++] = (block1 >>> 38) & 511L;
-        values[valuesOffset++] = (block1 >>> 29) & 511L;
-        values[valuesOffset++] = (block1 >>> 20) & 511L;
-        values[valuesOffset++] = (block1 >>> 11) & 511L;
-        values[valuesOffset++] = (block1 >>> 2) & 511L;
-        final long block2 = blocks[blocksOffset++];
-        values[valuesOffset++] = ((block1 & 3L) << 7) | (block2 >>> 57);
-        values[valuesOffset++] = (block2 >>> 48) & 511L;
-        values[valuesOffset++] = (block2 >>> 39) & 511L;
-        values[valuesOffset++] = (block2 >>> 30) & 511L;
-        values[valuesOffset++] = (block2 >>> 21) & 511L;
-        values[valuesOffset++] = (block2 >>> 12) & 511L;
-        values[valuesOffset++] = (block2 >>> 3) & 511L;
-        final long block3 = blocks[blocksOffset++];
-        values[valuesOffset++] = ((block2 & 7L) << 6) | (block3 >>> 58);
-        values[valuesOffset++] = (block3 >>> 49) & 511L;
-        values[valuesOffset++] = (block3 >>> 40) & 511L;
-        values[valuesOffset++] = (block3 >>> 31) & 511L;
-        values[valuesOffset++] = (block3 >>> 22) & 511L;
-        values[valuesOffset++] = (block3 >>> 13) & 511L;
-        values[valuesOffset++] = (block3 >>> 4) & 511L;
-        final long block4 = blocks[blocksOffset++];
-        values[valuesOffset++] = ((block3 & 15L) << 5) | (block4 >>> 59);
-        values[valuesOffset++] = (block4 >>> 50) & 511L;
-        values[valuesOffset++] = (block4 >>> 41) & 511L;
-        values[valuesOffset++] = (block4 >>> 32) & 511L;
-        values[valuesOffset++] = (block4 >>> 23) & 511L;
-        values[valuesOffset++] = (block4 >>> 14) & 511L;
-        values[valuesOffset++] = (block4 >>> 5) & 511L;
-        final long block5 = blocks[blocksOffset++];
-        values[valuesOffset++] = ((block4 & 31L) << 4) | (block5 >>> 60);
-        values[valuesOffset++] = (block5 >>> 51) & 511L;
-        values[valuesOffset++] = (block5 >>> 42) & 511L;
-        values[valuesOffset++] = (block5 >>> 33) & 511L;
-        values[valuesOffset++] = (block5 >>> 24) & 511L;
-        values[valuesOffset++] = (block5 >>> 15) & 511L;
-        values[valuesOffset++] = (block5 >>> 6) & 511L;
-        final long block6 = blocks[blocksOffset++];
-        values[valuesOffset++] = ((block5 & 63L) << 3) | (block6 >>> 61);
-        values[valuesOffset++] = (block6 >>> 52) & 511L;
-        values[valuesOffset++] = (block6 >>> 43) & 511L;
-        values[valuesOffset++] = (block6 >>> 34) & 511L;
-        values[valuesOffset++] = (block6 >>> 25) & 511L;
-        values[valuesOffset++] = (block6 >>> 16) & 511L;
-        values[valuesOffset++] = (block6 >>> 7) & 511L;
-        final long block7 = blocks[blocksOffset++];
-        values[valuesOffset++] = ((block6 & 127L) << 2) | (block7 >>> 62);
-        values[valuesOffset++] = (block7 >>> 53) & 511L;
-        values[valuesOffset++] = (block7 >>> 44) & 511L;
-        values[valuesOffset++] = (block7 >>> 35) & 511L;
-        values[valuesOffset++] = (block7 >>> 26) & 511L;
-        values[valuesOffset++] = (block7 >>> 17) & 511L;
-        values[valuesOffset++] = (block7 >>> 8) & 511L;
-        final long block8 = blocks[blocksOffset++];
-        values[valuesOffset++] = ((block7 & 255L) << 1) | (block8 >>> 63);
-        values[valuesOffset++] = (block8 >>> 54) & 511L;
-        values[valuesOffset++] = (block8 >>> 45) & 511L;
-        values[valuesOffset++] = (block8 >>> 36) & 511L;
-        values[valuesOffset++] = (block8 >>> 27) & 511L;
-        values[valuesOffset++] = (block8 >>> 18) & 511L;
-        values[valuesOffset++] = (block8 >>> 9) & 511L;
-        values[valuesOffset++] = block8 & 511L;
-      }
-    }
-
-    @Override
-    public void decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations) {
-      assert blocksOffset + 8 * iterations * blockCount() <= blocks.length;
-      assert valuesOffset + iterations * valueCount() <= values.length;
-      for (int i = 0; i < iterations; ++i) {
-        final long byte0 = blocks[blocksOffset++] & 0xFF;
-        final long byte1 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte0 << 1) | (byte1 >>> 7);
-        final long byte2 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte1 & 127) << 2) | (byte2 >>> 6);
-        final long byte3 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte2 & 63) << 3) | (byte3 >>> 5);
-        final long byte4 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte3 & 31) << 4) | (byte4 >>> 4);
-        final long byte5 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte4 & 15) << 5) | (byte5 >>> 3);
-        final long byte6 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte5 & 7) << 6) | (byte6 >>> 2);
-        final long byte7 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte6 & 3) << 7) | (byte7 >>> 1);
-        final long byte8 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte7 & 1) << 8) | byte8;
-        final long byte9 = blocks[blocksOffset++] & 0xFF;
-        final long byte10 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte9 << 1) | (byte10 >>> 7);
-        final long byte11 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte10 & 127) << 2) | (byte11 >>> 6);
-        final long byte12 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte11 & 63) << 3) | (byte12 >>> 5);
-        final long byte13 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte12 & 31) << 4) | (byte13 >>> 4);
-        final long byte14 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte13 & 15) << 5) | (byte14 >>> 3);
-        final long byte15 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte14 & 7) << 6) | (byte15 >>> 2);
-        final long byte16 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte15 & 3) << 7) | (byte16 >>> 1);
-        final long byte17 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte16 & 1) << 8) | byte17;
-        final long byte18 = blocks[blocksOffset++] & 0xFF;
-        final long byte19 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte18 << 1) | (byte19 >>> 7);
-        final long byte20 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte19 & 127) << 2) | (byte20 >>> 6);
-        final long byte21 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte20 & 63) << 3) | (byte21 >>> 5);
-        final long byte22 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte21 & 31) << 4) | (byte22 >>> 4);
-        final long byte23 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte22 & 15) << 5) | (byte23 >>> 3);
-        final long byte24 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte23 & 7) << 6) | (byte24 >>> 2);
-        final long byte25 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte24 & 3) << 7) | (byte25 >>> 1);
-        final long byte26 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte25 & 1) << 8) | byte26;
-        final long byte27 = blocks[blocksOffset++] & 0xFF;
-        final long byte28 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte27 << 1) | (byte28 >>> 7);
-        final long byte29 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte28 & 127) << 2) | (byte29 >>> 6);
-        final long byte30 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte29 & 63) << 3) | (byte30 >>> 5);
-        final long byte31 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte30 & 31) << 4) | (byte31 >>> 4);
-        final long byte32 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte31 & 15) << 5) | (byte32 >>> 3);
-        final long byte33 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte32 & 7) << 6) | (byte33 >>> 2);
-        final long byte34 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte33 & 3) << 7) | (byte34 >>> 1);
-        final long byte35 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte34 & 1) << 8) | byte35;
-        final long byte36 = blocks[blocksOffset++] & 0xFF;
-        final long byte37 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte36 << 1) | (byte37 >>> 7);
-        final long byte38 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte37 & 127) << 2) | (byte38 >>> 6);
-        final long byte39 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte38 & 63) << 3) | (byte39 >>> 5);
-        final long byte40 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte39 & 31) << 4) | (byte40 >>> 4);
-        final long byte41 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte40 & 15) << 5) | (byte41 >>> 3);
-        final long byte42 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte41 & 7) << 6) | (byte42 >>> 2);
-        final long byte43 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte42 & 3) << 7) | (byte43 >>> 1);
-        final long byte44 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte43 & 1) << 8) | byte44;
-        final long byte45 = blocks[blocksOffset++] & 0xFF;
-        final long byte46 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte45 << 1) | (byte46 >>> 7);
-        final long byte47 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte46 & 127) << 2) | (byte47 >>> 6);
-        final long byte48 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte47 & 63) << 3) | (byte48 >>> 5);
-        final long byte49 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte48 & 31) << 4) | (byte49 >>> 4);
-        final long byte50 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte49 & 15) << 5) | (byte50 >>> 3);
-        final long byte51 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte50 & 7) << 6) | (byte51 >>> 2);
-        final long byte52 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte51 & 3) << 7) | (byte52 >>> 1);
-        final long byte53 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte52 & 1) << 8) | byte53;
-        final long byte54 = blocks[blocksOffset++] & 0xFF;
-        final long byte55 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte54 << 1) | (byte55 >>> 7);
-        final long byte56 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte55 & 127) << 2) | (byte56 >>> 6);
-        final long byte57 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte56 & 63) << 3) | (byte57 >>> 5);
-        final long byte58 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte57 & 31) << 4) | (byte58 >>> 4);
-        final long byte59 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte58 & 15) << 5) | (byte59 >>> 3);
-        final long byte60 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte59 & 7) << 6) | (byte60 >>> 2);
-        final long byte61 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte60 & 3) << 7) | (byte61 >>> 1);
-        final long byte62 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte61 & 1) << 8) | byte62;
-        final long byte63 = blocks[blocksOffset++] & 0xFF;
-        final long byte64 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = (byte63 << 1) | (byte64 >>> 7);
-        final long byte65 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte64 & 127) << 2) | (byte65 >>> 6);
-        final long byte66 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte65 & 63) << 3) | (byte66 >>> 5);
-        final long byte67 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte66 & 31) << 4) | (byte67 >>> 4);
-        final long byte68 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte67 & 15) << 5) | (byte68 >>> 3);
-        final long byte69 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte68 & 7) << 6) | (byte69 >>> 2);
-        final long byte70 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte69 & 3) << 7) | (byte70 >>> 1);
-        final long byte71 = blocks[blocksOffset++] & 0xFF;
-        values[valuesOffset++] = ((byte70 & 1) << 8) | byte71;
-      }
+  @Override
+  public void decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations) {
+    for (int i = 0; i < 8 * iterations; ++i) {
+      final long byte0 = blocks[blocksOffset++] & 0xFF;
+      final long byte1 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = (byte0 << 1) | (byte1 >>> 7);
+      final long byte2 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte1 & 127) << 2) | (byte2 >>> 6);
+      final long byte3 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte2 & 63) << 3) | (byte3 >>> 5);
+      final long byte4 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte3 & 31) << 4) | (byte4 >>> 4);
+      final long byte5 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte4 & 15) << 5) | (byte5 >>> 3);
+      final long byte6 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte5 & 7) << 6) | (byte6 >>> 2);
+      final long byte7 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte6 & 3) << 7) | (byte7 >>> 1);
+      final long byte8 = blocks[blocksOffset++] & 0xFF;
+      values[valuesOffset++] = ((byte7 & 1) << 8) | byte8;
     }
+  }
 
 }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/BulkOperationPackedSingleBlock.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/BulkOperationPackedSingleBlock.java?rev=1379491&r1=1379490&r2=1379491&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/BulkOperationPackedSingleBlock.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/BulkOperationPackedSingleBlock.java Fri Aug 31 16:01:20 2012
@@ -20,7 +20,7 @@ package org.apache.lucene.util.packed;
 /**
  * Non-specialized {@link BulkOperation} for {@link PackedInts.Format#PACKED_SINGLE_BLOCK}.
  */
-class BulkOperationPackedSingleBlock extends BulkOperation {
+final class BulkOperationPackedSingleBlock extends BulkOperation {
 
   private static final int BLOCK_COUNT = 1;
 

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/gen_BulkOperation.py
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/gen_BulkOperation.py?rev=1379491&r1=1379490&r2=1379491&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/gen_BulkOperation.py (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/gen_BulkOperation.py Fri Aug 31 16:01:20 2012
@@ -86,6 +86,9 @@ FOOTER="""
 }
 """
 
+def is_power_of_two(n):
+  return n & (n - 1) == 0
+
 def casts(typ):
   cast_start = "(%s) (" %typ
   cast_end = ")"
@@ -118,104 +121,25 @@ def get_type(bits):
   else:
     assert False
 
-def packed64singleblock(bpv, f):
-  values = 64 / bpv
-  f.write("\n")
-  f.write("    public BulkOperationPackedSingleBlock%d() {\n" %bpv)
-  f.write("      super(%d);\n" %bpv)
-  f.write("    }\n\n")
-  p64sb_decode(bpv, f, 32)
-  p64sb_decode(bpv, f, 64)
-
-def p64sb_decode(bpv, f, bits):
-  values = 64 / bpv
-  typ = get_type(bits)
-  cast_start, cast_end = casts(typ)
-  f.write("    @Override\n")
-  f.write("    public void decode(long[] blocks, int blocksOffset, %s[] values, int valuesOffset, int iterations) {\n" %typ)
-  if bits < bpv:
-    f.write("      throw new UnsupportedOperationException();\n")
-    f.write("    }\n\n")
-    return 
-  f.write("      assert blocksOffset + iterations * blockCount() <= blocks.length;\n")
-  f.write("      assert valuesOffset + iterations * valueCount() <= values.length;\n")
-  f.write("      for (int i = 0; i < iterations; ++i) {\n")
-  f.write("        final long block = blocks[blocksOffset++];\n")
-  mask = (1 << bpv) - 1
-  for i in xrange(values):
-    block_offset = i / values
-    offset_in_block = i % values
-    if i == 0:
-      f.write("        values[valuesOffset++] = %sblock & %dL%s;\n" %(cast_start, mask, cast_end))
-    elif i == values - 1:
-      f.write("        values[valuesOffset++] = %sblock >>> %d%s;\n" %(cast_start, i * bpv, cast_end))
-    else:
-      f.write("        values[valuesOffset++] = %s(block >>> %d) & %dL%s;\n" %(cast_start, i * bpv, mask, cast_end))
-  f.write("      }\n")
-  f.write("    }\n\n")
-
-  f.write("    @Override\n")
-  f.write("    public void decode(byte[] blocks, int blocksOffset, %s[] values, int valuesOffset, int iterations) {\n" %typ)
-  if bits < bpv:
-    f.write("      throw new UnsupportedOperationException();\n")
-    f.write("    }\n\n")
-  f.write("      assert blocksOffset + 8 * iterations * blockCount() <= blocks.length;\n")
-  f.write("      assert valuesOffset + iterations * valueCount() <= values.length;\n")
-  f.write("      for (int i = 0; i < iterations; ++i) {\n")
-  if bpv >= 32 and bits > 32:
-    for i in xrange(7, -1, -1):
-      f.write("        final long byte%d = blocks[blocksOffset++] & 0xFF;\n" %i)
-  else:
-    for i in xrange(7, -1, -1):
-      f.write("        final int byte%d = blocks[blocksOffset++] & 0xFF;\n" %i)
-  for i in xrange(values):
-    byte_start = (i * bpv) / 8
-    bit_start = (i * bpv) % 8
-    byte_end = ((i + 1) * bpv - 1) / 8
-    bit_end = ((i + 1) * bpv - 1) % 8
-    f.write("        values[valuesOffset++] =")
-    if byte_start == byte_end:
-      # only one byte
-      if bit_start == 0:
-        if bit_end == 7:
-          f.write(" byte%d" %byte_start)
-        else:
-          f.write(" byte%d & %d" %(byte_start, mask))
-      else:
-        if bit_end == 7:
-          f.write(" byte%d >>> %d" %(byte_start, bit_start))
-        else:
-          f.write(" (byte%d >>> %d) & %d" %(byte_start, bit_start, mask))
-    else:
-      if bit_start == 0:
-        f.write(" byte%d" %byte_start)
-      else:
-        f.write(" (byte%d >>> %d)" %(byte_start, bit_start))
-      for b in xrange(byte_start + 1, byte_end):
-        f.write(" | (byte%d << %d)" %(b, 8 * (b - byte_start) - bit_start))
-      if bit_end == 7:
-        f.write(" | (byte%d << %d)" %(byte_end, 8 * (byte_end - byte_start) - bit_start))
-      else:
-        f.write(" | ((byte%d & %d) << %d)" %(byte_end, 2 ** (bit_end + 1) - 1, 8 * (byte_end - byte_start) - bit_start))
-    f.write(";\n")
-  f.write("      }\n")
-  f.write("    }\n\n")
-
-def packed64(bpv, f):
+def block_value_count(bpv, bits=64):
   blocks = bpv
-  values = blocks * 64 / bpv
+  values = blocks * bits / bpv
   while blocks % 2 == 0 and values % 2 == 0:
     blocks /= 2
     values /= 2
-  assert values * bpv == 64 * blocks, "%d values, %d blocks, %d bits per value" %(values, blocks, bpv)
+  assert values * bpv == bits * blocks, "%d values, %d blocks, %d bits per value" %(values, blocks, bpv)
+  return (blocks, values)
+
+def packed64(bpv, f):
+  blocks, values = block_value_count(bpv)
   mask = (1 << bpv) - 1
 
   f.write("\n")
-  f.write("    public BulkOperationPacked%d() {\n" %bpv)
-  f.write("      super(%d);\n" %bpv)
-  f.write("      assert blockCount() == %d;\n" %blocks)
-  f.write("      assert valueCount() == %d;\n" %values)
-  f.write("    }\n\n")
+  f.write("  public BulkOperationPacked%d() {\n" %bpv)
+  f.write("    super(%d);\n" %bpv)
+  f.write("    assert blockCount() == %d;\n" %blocks)
+  f.write("    assert valueCount() == %d;\n" %values)
+  f.write("  }\n\n")
 
   if bpv == 64:
     f.write("""    @Override
@@ -239,94 +163,118 @@ def packed64(bpv, f):
     }
 """)
   else:
-    p64_decode(bpv, f, 32, values)
-    p64_decode(bpv, f, 64, values)
+    p64_decode(bpv, f, 32)
+    p64_decode(bpv, f, 64)
 
-def p64_decode(bpv, f, bits, values):
+def p64_decode(bpv, f, bits):
+  blocks, values = block_value_count(bpv)
   typ = get_type(bits)
   cast_start, cast_end = casts(typ)
 
-  f.write("    @Override\n")
-  f.write("    public void decode(long[] blocks, int blocksOffset, %s[] values, int valuesOffset, int iterations) {\n" %typ)
+  f.write("  @Override\n")
+  f.write("  public void decode(long[] blocks, int blocksOffset, %s[] values, int valuesOffset, int iterations) {\n" %typ)
   if bits < bpv:
-    f.write("      throw new UnsupportedOperationException();\n")
+    f.write("    throw new UnsupportedOperationException();\n")
   else:
-    f.write("      assert blocksOffset + iterations * blockCount() <= blocks.length;\n")
-    f.write("      assert valuesOffset + iterations * valueCount() <= values.length;\n")
-    f.write("      for (int i = 0; i < iterations; ++i) {\n")
+    f.write("    for (int i = 0; i < iterations; ++i) {\n")
     mask = (1 << bpv) - 1
-    for i in xrange(0, values):
-      block_offset = i * bpv / 64
-      bit_offset = (i * bpv) % 64
-      if bit_offset == 0:
-        # start of block
-        f.write("        final long block%d = blocks[blocksOffset++];\n" %block_offset);
-        f.write("        values[valuesOffset++] = %sblock%d >>> %d%s;\n" %(cast_start, block_offset, 64 - bpv, cast_end))
-      elif bit_offset + bpv == 64:
-        # end of block
-        f.write("        values[valuesOffset++] = %sblock%d & %dL%s;\n" %(cast_start, block_offset, mask, cast_end))
-      elif bit_offset + bpv < 64:
-        # middle of block
-        f.write("        values[valuesOffset++] = %s(block%d >>> %d) & %dL%s;\n" %(cast_start, block_offset, 64 - bit_offset - bpv, mask, cast_end))
-      else:
-        # value spans across 2 blocks
-        mask1 = (1 << (64 - bit_offset)) -1
-        shift1 = bit_offset + bpv - 64
-        shift2 = 64 - shift1
-        f.write("        final long block%d = blocks[blocksOffset++];\n" %(block_offset + 1));
-        f.write("        values[valuesOffset++] = %s((block%d & %dL) << %d) | (block%d >>> %d)%s;\n" %(cast_start, block_offset, mask1, shift1, block_offset + 1, shift2, cast_end))
-    f.write("      }\n")
-  f.write("    }\n\n")
 
-  f.write("    @Override\n")
-  f.write("    public void decode(byte[] blocks, int blocksOffset, %s[] values, int valuesOffset, int iterations) {\n" %typ)
+    if is_power_of_two(bpv):
+      f.write("      final long block = blocks[blocksOffset++];\n")
+      f.write("      for (int shift = %d; shift >= 0; shift -= %d) {\n" %(64 - bpv, bpv))
+      f.write("        values[valuesOffset++] = %s(block >>> shift) & %d%s;\n" %(cast_start, mask, cast_end))
+      f.write("      }\n") 
+    else:
+      for i in xrange(0, values):
+        block_offset = i * bpv / 64
+        bit_offset = (i * bpv) % 64
+        if bit_offset == 0:
+          # start of block
+          f.write("      final long block%d = blocks[blocksOffset++];\n" %block_offset);
+          f.write("      values[valuesOffset++] = %sblock%d >>> %d%s;\n" %(cast_start, block_offset, 64 - bpv, cast_end))
+        elif bit_offset + bpv == 64:
+          # end of block
+          f.write("      values[valuesOffset++] = %sblock%d & %dL%s;\n" %(cast_start, block_offset, mask, cast_end))
+        elif bit_offset + bpv < 64:
+          # middle of block
+          f.write("      values[valuesOffset++] = %s(block%d >>> %d) & %dL%s;\n" %(cast_start, block_offset, 64 - bit_offset - bpv, mask, cast_end))
+        else:
+          # value spans across 2 blocks
+          mask1 = (1 << (64 - bit_offset)) -1
+          shift1 = bit_offset + bpv - 64
+          shift2 = 64 - shift1
+          f.write("      final long block%d = blocks[blocksOffset++];\n" %(block_offset + 1));
+          f.write("      values[valuesOffset++] = %s((block%d & %dL) << %d) | (block%d >>> %d)%s;\n" %(cast_start, block_offset, mask1, shift1, block_offset + 1, shift2, cast_end))
+    f.write("    }\n")
+  f.write("  }\n\n")
+
+  byte_blocks, byte_values = block_value_count(bpv, 8)
+
+  f.write("  @Override\n")
+  f.write("  public void decode(byte[] blocks, int blocksOffset, %s[] values, int valuesOffset, int iterations) {\n" %typ)
   if bits < bpv:
-    f.write("      throw new UnsupportedOperationException();\n")
+    f.write("    throw new UnsupportedOperationException();\n")
   else:
-    f.write("      assert blocksOffset + 8 * iterations * blockCount() <= blocks.length;\n")
-    f.write("      assert valuesOffset + iterations * valueCount() <= values.length;\n")
-    f.write("      for (int i = 0; i < iterations; ++i) {\n")
-    blocks = values * bpv / 8
-    for i in xrange(0, values):
-      byte_start = i * bpv / 8
-      bit_start = (i * bpv) % 8
-      byte_end = ((i + 1) * bpv - 1) / 8
-      bit_end = ((i + 1) * bpv - 1) % 8
-      shift = lambda b: 8 * (byte_end - b - 1) + 1 + bit_end
-      if bit_start == 0:
-        f.write("        final %s byte%d = blocks[blocksOffset++] & 0xFF;\n" %(typ, byte_start))
-      for b in xrange(byte_start + 1, byte_end + 1):
-        f.write("        final %s byte%d = blocks[blocksOffset++] & 0xFF;\n" %(typ, b))
-      f.write("        values[valuesOffset++] =")
-      if byte_start == byte_end:
+
+    if is_power_of_two(bpv) and bpv < 8:
+      f.write("    for (int j = 0; j < 8 * iterations; ++j) {\n")
+      f.write("      final byte block = blocks[blocksOffset++];\n")
+      for shift in xrange(8 - bpv, 0, -bpv):
+        f.write("      values[valuesOffset++] = (block >>> %d) & %d;\n" %(shift, mask))
+      f.write("      values[valuesOffset++] = block & %d;\n" %mask)
+      f.write("    }\n")
+    elif bpv == 8:
+      f.write("    for (int j = 0; j < 8 * iterations; ++j) {\n")
+      f.write("      values[valuesOffset++] = blocks[blocksOffset++] & 0xFF;\n")
+      f.write("    }\n")
+    elif is_power_of_two(bpv) and bpv > 8:
+      f.write("    for (int j = 0; j < %d * iterations; ++j) {\n" %(64 / bpv))
+      m = bits <= 32 and "0xFF" or "0xFFL"
+      f.write("      values[valuesOffset++] =")
+      for i in xrange(bpv / 8 - 1):
+        f.write(" ((blocks[blocksOffset++] & %s) << %d) |" %(m, bpv - 8))
+      f.write(" (blocks[blocksOffset++] & %s);\n" %m)
+      f.write("    }\n")
+    else:
+      f.write("    for (int i = 0; i < 8 * iterations; ++i) {\n")
+      for i in xrange(0, byte_values):
+        byte_start = i * bpv / 8
+        bit_start = (i * bpv) % 8
+        byte_end = ((i + 1) * bpv - 1) / 8
+        bit_end = ((i + 1) * bpv - 1) % 8
+        shift = lambda b: 8 * (byte_end - b - 1) + 1 + bit_end
         if bit_start == 0:
-          if bit_end == 7:
-            f.write(" byte%d" %byte_start)
+          f.write("      final %s byte%d = blocks[blocksOffset++] & 0xFF;\n" %(typ, byte_start))
+        for b in xrange(byte_start + 1, byte_end + 1):
+          f.write("      final %s byte%d = blocks[blocksOffset++] & 0xFF;\n" %(typ, b))
+        f.write("      values[valuesOffset++] =")
+        if byte_start == byte_end:
+          if bit_start == 0:
+            if bit_end == 7:
+              f.write(" byte%d" %byte_start)
+            else:
+              f.write(" byte%d >>> %d" %(byte_start, 7 - bit_end))
           else:
-            f.write(" byte%d >>> %d" %(byte_start, 7 - bit_end))
+            if bit_end == 7:
+              f.write(" byte%d & %d" %(byte_start, 2 ** (8 - bit_start) - 1))
+            else:
+              f.write(" (byte%d >>> %d) & %d" %(byte_start, 7 - bit_end, 2 ** (bit_end - bit_start + 1) - 1))
         else:
+          if bit_start == 0:
+            f.write(" (byte%d << %d)" %(byte_start, shift(byte_start)))
+          else:
+            f.write(" ((byte%d & %d) << %d)" %(byte_start, 2 ** (8 - bit_start) - 1, shift(byte_start)))
+          for b in xrange(byte_start + 1, byte_end):
+            f.write(" | (byte%d << %d)" %(b, shift(b)))
           if bit_end == 7:
-            f.write(" byte%d & %d" %(byte_start, 2 ** (8 - bit_start) - 1))
+            f.write(" | byte%d" %byte_end)
           else:
-            f.write(" (byte%d >>> %d) & %d" %(byte_start, 7 - bit_end, 2 ** (bit_end - bit_start + 1) - 1))
-      else:
-        if bit_start == 0:
-          f.write(" (byte%d << %d)" %(byte_start, shift(byte_start)))
-        else:
-          f.write(" ((byte%d & %d) << %d)" %(byte_start, 2 ** (8 - bit_start) - 1, shift(byte_start)))
-        for b in xrange(byte_start + 1, byte_end):
-          f.write(" | (byte%d << %d)" %(b, shift(b)))
-        if bit_end == 7:
-          f.write(" | byte%d" %byte_end)
-        else:
-          f.write(" | (byte%d >>> %d)" %(byte_end, 7 - bit_end))
-      f.write(";\n")
-    f.write("      }\n")
-  f.write("    }\n\n")
+            f.write(" | (byte%d >>> %d)" %(byte_end, 7 - bit_end))
+        f.write(";\n")
+      f.write("    }\n")
+  f.write("  }\n\n")
 
 if __name__ == '__main__':
-  p64_bpv = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16, 21, 32]
-
   f = open(OUTPUT_FILE, 'w')
   f.write(HEADER)
   f.write('\n')
@@ -363,19 +311,7 @@ if __name__ == '__main__':
   f.write('  private static final BulkOperation[] packedSingleBlockBulkOps = new BulkOperation[] {\n')
   for bpv in xrange(1, max(PACKED_64_SINGLE_BLOCK_BPV)+1):
     if bpv in PACKED_64_SINGLE_BLOCK_BPV:
-      if bpv > MAX_SPECIALIZED_BITS_PER_VALUE:
-        f.write('    new BulkOperationPackedSingleBlock(%d),\n' % bpv)
-        continue
-      f2 = open('BulkOperationPackedSingleBlock%d.java' % bpv, 'w')
-      f2.write(HEADER)
-      f2.write('''/**
- * Efficient sequential read/write of packed integers.
- */\n''')
-      f2.write('final class BulkOperationPackedSingleBlock%d extends BulkOperationPackedSingleBlock {\n' % bpv)
-      packed64singleblock(bpv,f2)
-      f2.write('}\n')
-      f2.close()
-      f.write('    new BulkOperationPackedSingleBlock%d(),\n' % bpv)
+      f.write('    new BulkOperationPackedSingleBlock(%d),\n' % bpv)
     else:
       f.write('    null,\n')
   f.write('  };\n')



Mime
View raw message