@Override
 public void write(DataOutput out) throws IOException {
   schema.write(out);
   out.writeInt(slots.size());
   for (List<KeyRange> orclause : slots) {
     out.writeInt(orclause.size());
     for (KeyRange range : orclause) {
       range.write(out);
     }
   }
 }
 public SkipScanFilter(List<List<KeyRange>> slots, RowKeySchema schema) {
   int maxKeyLength = getTerminatorCount(schema);
   for (List<KeyRange> slot : slots) {
     int maxSlotLength = 0;
     for (KeyRange range : slot) {
       int maxRangeLength = Math.max(range.getLowerRange().length, range.getUpperRange().length);
       if (maxSlotLength < maxRangeLength) {
         maxSlotLength = maxRangeLength;
       }
     }
     maxKeyLength += maxSlotLength;
   }
   init(slots, schema, maxKeyLength);
 }
 @Override
 public void readFields(DataInput in) throws IOException {
   RowKeySchema schema = new RowKeySchema();
   schema.readFields(in);
   int maxLength = getTerminatorCount(schema);
   int andLen = in.readInt();
   List<List<KeyRange>> slots = Lists.newArrayListWithExpectedSize(andLen);
   for (int i = 0; i < andLen; i++) {
     int orlen = in.readInt();
     List<KeyRange> orclause = Lists.newArrayListWithExpectedSize(orlen);
     slots.add(orclause);
     int maxSlotLength = 0;
     for (int j = 0; j < orlen; j++) {
       KeyRange range = new KeyRange();
       range.readFields(in);
       if (range.getLowerRange().length > maxSlotLength) {
         maxSlotLength = range.getLowerRange().length;
       }
       if (range.getUpperRange().length > maxSlotLength) {
         maxSlotLength = range.getUpperRange().length;
       }
       orclause.add(range);
     }
     maxLength += maxSlotLength;
   }
   this.init(slots, schema, maxLength);
 }
Пример #4
0
 @Parameters(name = "{0} {1} {2}")
 public static Collection<Object> data() {
   List<Object> testCases = Lists.newArrayList();
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("aaa"), true, Bytes.toBytes("aaa"), true),
               KeyRange.getKeyRange(Bytes.toBytes("aac"), true, Bytes.toBytes("aad"), true),
               KeyRange.getKeyRange(Bytes.toBytes("abc"), true, Bytes.toBytes("def"), true)
             }
           },
           new int[] {3},
           new SeekNext("aab", "aac"),
           new SeekNext("abb", "abc"),
           new Include("abc"),
           new Include("abe"),
           new Include("def"),
           new Finished("deg")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("aaa"), true, Bytes.toBytes("aaa"), true),
               KeyRange.getKeyRange(Bytes.toBytes("abc"), false, Bytes.toBytes("def"), true)
             }
           },
           new int[] {3},
           new SeekNext("aba", "abd"),
           new Include("abe"),
           new Include("def"),
           new Finished("deg")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("aaa"), true, Bytes.toBytes("aaa"), true),
               KeyRange.getKeyRange(Bytes.toBytes("abc"), false, Bytes.toBytes("def"), false)
             }
           },
           new int[] {3},
           new SeekNext("aba", "abd"),
           new Finished("def")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("abc"), true, Bytes.toBytes("def"), true),
               KeyRange.getKeyRange(Bytes.toBytes("dzy"), false, Bytes.toBytes("xyz"), false),
             }
           },
           new int[] {3},
           new Include("def"),
           new SeekNext("deg", "dzz"),
           new Include("eee"),
           new Finished("xyz")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("aaa"), true, Bytes.toBytes("aaa"), true),
               KeyRange.getKeyRange(Bytes.toBytes("abc"), true, Bytes.toBytes("abc"), true),
               KeyRange.getKeyRange(Bytes.toBytes("def"), true, Bytes.toBytes("def"), true),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("AB"), true, Bytes.toBytes("AX"), true),
               KeyRange.getKeyRange(Bytes.toBytes("EA"), false, Bytes.toBytes("EZ"), false),
               KeyRange.getKeyRange(Bytes.toBytes("PO"), true, Bytes.toBytes("PP"), false),
             }
           },
           new int[] {3, 2},
           new Include("abcAB"),
           new SeekNext("abcAY", "abcEB"),
           new Include("abcEF"),
           new SeekNext("abcPP", "defAB"),
           new SeekNext("defEZ", "defPO"),
           new Include("defPO"),
           new Finished("defPP")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("AB"), true, Bytes.toBytes("AX"), true),
               KeyRange.getKeyRange(Bytes.toBytes("EA"), false, Bytes.toBytes("EZ"), false),
               KeyRange.getKeyRange(Bytes.toBytes("PO"), true, Bytes.toBytes("PP"), false),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("abc"), true, Bytes.toBytes("abc"), true),
               KeyRange.getKeyRange(Bytes.toBytes("def"), true, Bytes.toBytes("def"), true),
             }
           },
           new int[] {2, 3},
           new Include("ABabc"),
           new SeekNext("ABdeg", "ACabc"),
           new Include("AMabc"),
           new SeekNext("AYabc", "EBabc"),
           new Include("EFabc"),
           new SeekNext("EZdef", "POabc"),
           new SeekNext("POabd", "POdef"),
           new Include("POdef"),
           new Finished("PPabc")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("PO"), true, Bytes.toBytes("PP"), false),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("def"), true, Bytes.toBytes("def"), true),
             }
           },
           new int[] {2, 3},
           new Include("POdef"),
           new Finished("POdeg")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("PO"), true, Bytes.toBytes("PO"), true),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("def"), true, Bytes.toBytes("def"), true),
             }
           },
           new int[] {2, 3},
           new Include("POdef"),
           new Finished("PPdef")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("abc"), true, Bytes.toBytes("def"), true),
               KeyRange.getKeyRange(Bytes.toBytes("dzy"), false, Bytes.toBytes("xyz"), false),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("AA"), true, Bytes.toBytes("AB"), false),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("AA"), true, Bytes.toBytes("AB"), false),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("AA"), true, Bytes.toBytes("AB"), false),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("AA"), true, Bytes.toBytes("AB"), false),
             }
           },
           new int[] {3, 2, 2, 2, 2},
           new SeekNext("abcABABABAB", "abdAAAAAAAA"),
           new SeekNext("defAAABABAB", "dzzAAAAAAAA"),
           new Finished("xyyABABABAB")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("AAA"), true, Bytes.toBytes("AAA"), true),
               KeyRange.getKeyRange(Bytes.toBytes("abc"), true, Bytes.toBytes("def"), true),
               KeyRange.getKeyRange(Bytes.toBytes("dzy"), false, Bytes.toBytes("xyz"), false),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("AB"), true, Bytes.toBytes("AX"), true),
               KeyRange.getKeyRange(Bytes.toBytes("EA"), false, Bytes.toBytes("EZ"), false),
               KeyRange.getKeyRange(Bytes.toBytes("PO"), true, Bytes.toBytes("PP"), false),
             }
           },
           new int[] {3, 2},
           new SeekNext("aaaAA", "abcAB"),
           new SeekNext("abcZZ", "abdAB"),
           new SeekNext("abdZZ", "abeAB"),
           new SeekNext(
               new byte[] {'d', 'e', 'a', (byte) 0xFF, (byte) 0xFF},
               new byte[] {'d', 'e', 'b', 'A', 'B'}),
           new Include("defAB"),
           new Include("defAC"),
           new Include("defAW"),
           new Include("defAX"),
           new Include("defEB"),
           new Include("defPO"),
           new SeekNext("degAB", "dzzAB"),
           new Include("dzzAX"),
           new Include("dzzEY"),
           new SeekNext("dzzEZ", "dzzPO"),
           new Include("eeeAB"),
           new Include("eeeAC"),
           new SeekNext("eeeEA", "eeeEB"),
           new Include("eeeEF"),
           new SeekNext("eeeEZ", "eeePO"),
           new Finished("xyzAA")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("aaa"), true, Bytes.toBytes("aaa"), true),
               KeyRange.getKeyRange(Bytes.toBytes("abc"), true, Bytes.toBytes("def"), true),
               KeyRange.getKeyRange(Bytes.toBytes("dzz"), true, Bytes.toBytes("xyz"), false),
             }
           },
           new int[] {3},
           new SeekNext("abb", "abc"),
           new Include("abc"),
           new Include("abe"),
           new Finished("xyz")));
   testCases.addAll(
       foreach(
           new KeyRange[][] {
             {
               KeyRange.getKeyRange(Bytes.toBytes("abc"), true, Bytes.toBytes("def"), true),
               KeyRange.getKeyRange(Bytes.toBytes("dzy"), false, Bytes.toBytes("xyz"), false),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("AB"), true, Bytes.toBytes("AX"), true),
               KeyRange.getKeyRange(Bytes.toBytes("EA"), false, Bytes.toBytes("EZ"), false),
               KeyRange.getKeyRange(Bytes.toBytes("PO"), true, Bytes.toBytes("PP"), false),
             },
             {
               KeyRange.getKeyRange(Bytes.toBytes("100"), true, Bytes.toBytes("250"), false),
               KeyRange.getKeyRange(Bytes.toBytes("700"), false, Bytes.toBytes("901"), false),
             }
           },
           new int[] {3, 2, 3},
           new SeekNext("abcEB700", "abcEB701"),
           new Include("abcEB701"),
           new SeekNext("dzzAB250", "dzzAB701"),
           new Finished("zzzAA000")));
   // TODO variable length columns
   //        testCases.addAll(
   //                foreach(new KeyRange[][]{{
   //                    KeyRange.getKeyRange(Bytes.toBytes("apple"), true, Bytes.toBytes("lemon"),
   // true),
   //                    KeyRange.getKeyRange(Bytes.toBytes("pear"), false, Bytes.toBytes("yam"),
   // false),
   //                },
   //                {
   //                    KeyRange.getKeyRange(Bytes.toBytes("AB"), true, Bytes.toBytes("AX"),
   // true),
   //                    KeyRange.getKeyRange(Bytes.toBytes("EA"), false, Bytes.toBytes("EZ"),
   // false),
   //                    KeyRange.getKeyRange(Bytes.toBytes("PO"), true, Bytes.toBytes("PP"),
   // false),
   //                },
   //                {
   //                    KeyRange.getKeyRange(Bytes.toBytes("100"), true, Bytes.toBytes("250"),
   // false),
   //                    KeyRange.getKeyRange(Bytes.toBytes("700"), false, Bytes.toBytes("901"),
   // false),
   //                }},
   //                new int[]{3,3})
   //        );
   return testCases;
 }