@Test public void testOneHundredColumnMultipleEntriesPerSubject() throws Exception { BatchWriter bw = null; bw = accCon.createBatchWriter(tablename, 500L * 1024L * 1024L, Long.MAX_VALUE, 30); for (int i = 0; i < 100; i++) { Mutation m = new Mutation(new Text("" + i)); for(int j= 0; j < 100; j++) { m.put(new Text("cf" + j), new Text(null + "\u0000" +"obj" + "\u0000" + "cq" + j ), new Value(new byte[0])); } if (i == 30 || i == 60 || i == 90 || i == 99) { m.put(new Text("cf" + 100), new Text(null + "\u0000" +"obj" + "\u0000" + "cq" + (100 + i)), new Value(new byte[0])); m.put(new Text("cf" + 100), new Text(null + "\u0000" +"obj" + "\u0000" + "cq" + (100 + i + 1)), new Value(new byte[0])); } bw.addMutation(m); } DocumentIndexIntersectingIterator dii = new DocumentIndexIntersectingIterator(); TextColumn tc1 = new TextColumn(new Text("cf" + 20), new Text("obj" + "\u0000" + "cq" + 20 )); TextColumn tc2 = new TextColumn(new Text("cf" + 50), new Text("obj" + "\u0000" + "cq" + 50)); TextColumn tc3 = new TextColumn(new Text("cf" + 100), new Text("obj")); tc3.setIsPrefix(true); TextColumn[] tc = new TextColumn[3]; tc[0] = tc1; tc[1] = tc2; tc[2] = tc3; IteratorSetting is = new IteratorSetting(30, "fii", DocumentIndexIntersectingIterator.class); dii.setColumnFamilies(is, tc); Scanner scan = accCon.createScanner(tablename, new Authorizations("auths")); scan.addScanIterator(is); int results = 0; System.out.println("************************Test 6****************************"); for (Map.Entry<Key, Value> e : scan) { System.out.println(e); results++; } Assert.assertEquals(8, results); }
public static void setColumnFamilies(IteratorSetting cfg, TextColumn[] columns) { if (columns.length < 2) throw new IllegalArgumentException("Must supply at least two terms to intersect"); boolean[] prefix = new boolean[columns.length]; for(int i = 0; i < columns.length; i++) { prefix[i] = columns[i].isPrefix(); } cfg.addOption(DocumentIndexIntersectingIterator.columnPrefix, DocumentIndexIntersectingIterator.encodeBooleans(prefix)); cfg.addOption(DocumentIndexIntersectingIterator.columnOptionName, DocumentIndexIntersectingIterator.encodeColumns(columns)); }
DocumentIndexIntersectingIterator implements SortedKeyValueIterator<Key,Value> { public static void setColumnFamilies(IteratorSetting cfg, TextColumn[] columns) { if (columns.length < 2) throw new IllegalArgumentException("Must supply at least two terms to intersect"); boolean[] prefix = new boolean[columns.length]; for(int i = 0; i < columns.length; i++) { prefix[i] = columns[i].isPrefix(); } cfg.addOption(DocumentIndexIntersectingIterator.columnPrefix, DocumentIndexIntersectingIterator.encodeBooleans(prefix)); cfg.addOption(DocumentIndexIntersectingIterator.columnOptionName, DocumentIndexIntersectingIterator.encodeColumns(columns)); } }
DocumentIndexIntersectingIterator implements SortedKeyValueIterator<Key,Value> { public static void setColumnFamilies(IteratorSetting cfg, TextColumn[] columns) { if (columns.length < 2) throw new IllegalArgumentException("Must supply at least two terms to intersect"); boolean[] prefix = new boolean[columns.length]; for(int i = 0; i < columns.length; i++) { prefix[i] = columns[i].isPrefix(); } cfg.addOption(DocumentIndexIntersectingIterator.columnPrefix, DocumentIndexIntersectingIterator.encodeBooleans(prefix)); cfg.addOption(DocumentIndexIntersectingIterator.columnOptionName, DocumentIndexIntersectingIterator.encodeColumns(columns)); } DocumentIndexIntersectingIterator(); private  DocumentIndexIntersectingIterator(DocumentIndexIntersectingIterator other, IteratorEnvironment env); }
DocumentIndexIntersectingIterator implements SortedKeyValueIterator<Key,Value> { public static void setColumnFamilies(IteratorSetting cfg, TextColumn[] columns) { if (columns.length < 2) throw new IllegalArgumentException("Must supply at least two terms to intersect"); boolean[] prefix = new boolean[columns.length]; for(int i = 0; i < columns.length; i++) { prefix[i] = columns[i].isPrefix(); } cfg.addOption(DocumentIndexIntersectingIterator.columnPrefix, DocumentIndexIntersectingIterator.encodeBooleans(prefix)); cfg.addOption(DocumentIndexIntersectingIterator.columnOptionName, DocumentIndexIntersectingIterator.encodeColumns(columns)); } DocumentIndexIntersectingIterator(); private  DocumentIndexIntersectingIterator(DocumentIndexIntersectingIterator other, IteratorEnvironment env); @Override SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env); @Override Key getTopKey(); @Override Value getTopValue(); @Override boolean hasTop(); @Override void next(); static String stringTopKey(SortedKeyValueIterator<Key,Value> iter); @Override void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env); @Override void seek(Range range, Collection<ByteSequence> seekColumnFamilies, boolean inclusive); void addSource(SortedKeyValueIterator<Key,Value> source, IteratorEnvironment env, TextColumn column); static void setColumnFamilies(IteratorSetting cfg, TextColumn[] columns); static void setContext(IteratorSetting cfg, String context); }
DocumentIndexIntersectingIterator implements SortedKeyValueIterator<Key,Value> { public static void setColumnFamilies(IteratorSetting cfg, TextColumn[] columns) { if (columns.length < 2) throw new IllegalArgumentException("Must supply at least two terms to intersect"); boolean[] prefix = new boolean[columns.length]; for(int i = 0; i < columns.length; i++) { prefix[i] = columns[i].isPrefix(); } cfg.addOption(DocumentIndexIntersectingIterator.columnPrefix, DocumentIndexIntersectingIterator.encodeBooleans(prefix)); cfg.addOption(DocumentIndexIntersectingIterator.columnOptionName, DocumentIndexIntersectingIterator.encodeColumns(columns)); } DocumentIndexIntersectingIterator(); private  DocumentIndexIntersectingIterator(DocumentIndexIntersectingIterator other, IteratorEnvironment env); @Override SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env); @Override Key getTopKey(); @Override Value getTopValue(); @Override boolean hasTop(); @Override void next(); static String stringTopKey(SortedKeyValueIterator<Key,Value> iter); @Override void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env); @Override void seek(Range range, Collection<ByteSequence> seekColumnFamilies, boolean inclusive); void addSource(SortedKeyValueIterator<Key,Value> source, IteratorEnvironment env, TextColumn column); static void setColumnFamilies(IteratorSetting cfg, TextColumn[] columns); static void setContext(IteratorSetting cfg, String context);  }