@Test public void testTermsNonExistentField() throws Exception { List<String> terms = indexManager.terms(TABLE, FAMILY, "nonexistentfield", "", (short) 100); assertNotNull("Non-existent fields should not return null.", terms); assertEquals("The terms of non-existent fields should be empty.", 0, terms.size()); }
public List<String> terms(final String table, final String columnFamily, final String columnName, final String startWith, final short size) throws Exception { Map<String, BlurIndex> blurIndexes; try { blurIndexes = _indexServer.getIndexes(table); } catch (IOException e) { LOG.error("Unknown error while trying to fetch index readers.", e); throw new BException(e.getMessage(), e); } TableContext tableContext = getTableContext(table); FieldManager fieldManager = tableContext.getFieldManager(); final FieldTypeDefinition typeDefinition = fieldManager.getFieldTypeDefinition(columnFamily + "." + columnName); return ForkJoin.execute(_executor, blurIndexes.entrySet(), new ParallelCall<Entry<String, BlurIndex>, List<String>>() { @Override public List<String> call(Entry<String, BlurIndex> input) throws Exception { BlurIndex index = input.getValue(); IndexSearcherCloseable searcher = index.getIndexSearcher(); try { return terms(searcher.getIndexReader(), typeDefinition, columnFamily, columnName, startWith, size); } finally { searcher.close(); } } }).merge(new Merger<List<String>>() { @Override public List<String> merge(BlurExecutorCompletionService<List<String>> service) throws BlurException { SortedSet<String> terms = new TreeSet<String>(); while (service.getRemainingCount() > 0) { Future<List<String>> future = service.poll(_defaultParallelCallTimeout, TimeUnit.MILLISECONDS, true, table, columnFamily, columnName, startWith, size); terms.addAll(service.getResultThrowException(future, table, columnFamily, columnName, startWith, size)); } return new ArrayList<String>(terms).subList(0, Math.min(size, terms.size())); } }); }
IndexManager { public List<String> terms(final String table, final String columnFamily, final String columnName, final String startWith, final short size) throws Exception { Map<String, BlurIndex> blurIndexes; try { blurIndexes = _indexServer.getIndexes(table); } catch (IOException e) { LOG.error("Unknown error while trying to fetch index readers.", e); throw new BException(e.getMessage(), e); } TableContext tableContext = getTableContext(table); FieldManager fieldManager = tableContext.getFieldManager(); final FieldTypeDefinition typeDefinition = fieldManager.getFieldTypeDefinition(columnFamily + "." + columnName); return ForkJoin.execute(_executor, blurIndexes.entrySet(), new ParallelCall<Entry<String, BlurIndex>, List<String>>() { @Override public List<String> call(Entry<String, BlurIndex> input) throws Exception { BlurIndex index = input.getValue(); IndexSearcherCloseable searcher = index.getIndexSearcher(); try { return terms(searcher.getIndexReader(), typeDefinition, columnFamily, columnName, startWith, size); } finally { searcher.close(); } } }).merge(new Merger<List<String>>() { @Override public List<String> merge(BlurExecutorCompletionService<List<String>> service) throws BlurException { SortedSet<String> terms = new TreeSet<String>(); while (service.getRemainingCount() > 0) { Future<List<String>> future = service.poll(_defaultParallelCallTimeout, TimeUnit.MILLISECONDS, true, table, columnFamily, columnName, startWith, size); terms.addAll(service.getResultThrowException(future, table, columnFamily, columnName, startWith, size)); } return new ArrayList<String>(terms).subList(0, Math.min(size, terms.size())); } }); } }
IndexManager { public List<String> terms(final String table, final String columnFamily, final String columnName, final String startWith, final short size) throws Exception { Map<String, BlurIndex> blurIndexes; try { blurIndexes = _indexServer.getIndexes(table); } catch (IOException e) { LOG.error("Unknown error while trying to fetch index readers.", e); throw new BException(e.getMessage(), e); } TableContext tableContext = getTableContext(table); FieldManager fieldManager = tableContext.getFieldManager(); final FieldTypeDefinition typeDefinition = fieldManager.getFieldTypeDefinition(columnFamily + "." + columnName); return ForkJoin.execute(_executor, blurIndexes.entrySet(), new ParallelCall<Entry<String, BlurIndex>, List<String>>() { @Override public List<String> call(Entry<String, BlurIndex> input) throws Exception { BlurIndex index = input.getValue(); IndexSearcherCloseable searcher = index.getIndexSearcher(); try { return terms(searcher.getIndexReader(), typeDefinition, columnFamily, columnName, startWith, size); } finally { searcher.close(); } } }).merge(new Merger<List<String>>() { @Override public List<String> merge(BlurExecutorCompletionService<List<String>> service) throws BlurException { SortedSet<String> terms = new TreeSet<String>(); while (service.getRemainingCount() > 0) { Future<List<String>> future = service.poll(_defaultParallelCallTimeout, TimeUnit.MILLISECONDS, true, table, columnFamily, columnName, startWith, size); terms.addAll(service.getResultThrowException(future, table, columnFamily, columnName, startWith, size)); } return new ArrayList<String>(terms).subList(0, Math.min(size, terms.size())); } }); } IndexManager(IndexServer indexServer, ClusterStatus clusterStatus, BlurFilterCache filterCache,
      int maxHeapPerRowFetch, int fetchCount, int threadCount, int mutateThreadCount, int facetThreadCount,
      DeepPagingCache deepPagingCache, MemoryAllocationWatcher memoryAllocationWatcher, QueryStatusManager statusManager); }
IndexManager { public List<String> terms(final String table, final String columnFamily, final String columnName, final String startWith, final short size) throws Exception { Map<String, BlurIndex> blurIndexes; try { blurIndexes = _indexServer.getIndexes(table); } catch (IOException e) { LOG.error("Unknown error while trying to fetch index readers.", e); throw new BException(e.getMessage(), e); } TableContext tableContext = getTableContext(table); FieldManager fieldManager = tableContext.getFieldManager(); final FieldTypeDefinition typeDefinition = fieldManager.getFieldTypeDefinition(columnFamily + "." + columnName); return ForkJoin.execute(_executor, blurIndexes.entrySet(), new ParallelCall<Entry<String, BlurIndex>, List<String>>() { @Override public List<String> call(Entry<String, BlurIndex> input) throws Exception { BlurIndex index = input.getValue(); IndexSearcherCloseable searcher = index.getIndexSearcher(); try { return terms(searcher.getIndexReader(), typeDefinition, columnFamily, columnName, startWith, size); } finally { searcher.close(); } } }).merge(new Merger<List<String>>() { @Override public List<String> merge(BlurExecutorCompletionService<List<String>> service) throws BlurException { SortedSet<String> terms = new TreeSet<String>(); while (service.getRemainingCount() > 0) { Future<List<String>> future = service.poll(_defaultParallelCallTimeout, TimeUnit.MILLISECONDS, true, table, columnFamily, columnName, startWith, size); terms.addAll(service.getResultThrowException(future, table, columnFamily, columnName, startWith, size)); } return new ArrayList<String>(terms).subList(0, Math.min(size, terms.size())); } }); } IndexManager(IndexServer indexServer, ClusterStatus clusterStatus, BlurFilterCache filterCache,
      int maxHeapPerRowFetch, int fetchCount, int threadCount, int mutateThreadCount, int facetThreadCount,
      DeepPagingCache deepPagingCache, MemoryAllocationWatcher memoryAllocationWatcher, QueryStatusManager statusManager); synchronized void close(); List<FetchResult> fetchRowBatch(final String table, List<Selector> selectors); void fetchRow(String table, Selector selector, FetchResult fetchResult); static void populateSelector(IndexSearcherCloseable searcher, String shardName, String table, Selector selector); static void validSelector(Selector selector); BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts); String parseQuery(String table, org.apache.blur.thrift.generated.Query simpleQuery); void cancelQuery(String table, String uuid); List<BlurQueryStatus> currentQueries(String table); BlurQueryStatus queryStatus(String table, String uuid); List<String> queryStatusIdList(String table); static void fetchRow(IndexReader reader, String table, String shard, Selector selector,
      FetchResult fetchResult, Query highlightQuery, int maxHeap, TableContext tableContext, Filter filter); static void fetchRow(IndexReader reader, String table, String shard, Selector selector,
      FetchResult fetchResult, Query highlightQuery, FieldManager fieldManager, int maxHeap, TableContext tableContext,
      Filter filter); static ResetableDocumentStoredFieldVisitor getFieldSelector(final Selector selector); IndexServer getIndexServer(); long recordFrequency(final String table, final String columnFamily, final String columnName, final String value); List<String> terms(final String table, final String columnFamily, final String columnName,
      final String startWith, final short size); static long recordFrequency(IndexReader reader, String columnFamily, String columnName, String value); static List<String> terms(IndexReader reader, FieldTypeDefinition typeDef, String columnFamily,
      String columnName, String startWith, short size); void mutate(final RowMutation mutation); void mutate(final List<RowMutation> mutations); void enqueue(List<RowMutation> mutations); static boolean resetExitableReader(IndexReader indexReader, AtomicBoolean running); void optimize(String table, int numberOfSegmentsPerShard); void enqueue(RowMutation mutation); void bulkMutateAdd(String table, String bulkId, RowMutation mutation); void bulkMutateFinish(Set<String> potentialTables, String bulkId, boolean apply, boolean blockUntilComplete); void bulkMutateAddMultiple(String table, String bulkId, List<RowMutation> rowMutations); }
IndexManager { public List<String> terms(final String table, final String columnFamily, final String columnName, final String startWith, final short size) throws Exception { Map<String, BlurIndex> blurIndexes; try { blurIndexes = _indexServer.getIndexes(table); } catch (IOException e) { LOG.error("Unknown error while trying to fetch index readers.", e); throw new BException(e.getMessage(), e); } TableContext tableContext = getTableContext(table); FieldManager fieldManager = tableContext.getFieldManager(); final FieldTypeDefinition typeDefinition = fieldManager.getFieldTypeDefinition(columnFamily + "." + columnName); return ForkJoin.execute(_executor, blurIndexes.entrySet(), new ParallelCall<Entry<String, BlurIndex>, List<String>>() { @Override public List<String> call(Entry<String, BlurIndex> input) throws Exception { BlurIndex index = input.getValue(); IndexSearcherCloseable searcher = index.getIndexSearcher(); try { return terms(searcher.getIndexReader(), typeDefinition, columnFamily, columnName, startWith, size); } finally { searcher.close(); } } }).merge(new Merger<List<String>>() { @Override public List<String> merge(BlurExecutorCompletionService<List<String>> service) throws BlurException { SortedSet<String> terms = new TreeSet<String>(); while (service.getRemainingCount() > 0) { Future<List<String>> future = service.poll(_defaultParallelCallTimeout, TimeUnit.MILLISECONDS, true, table, columnFamily, columnName, startWith, size); terms.addAll(service.getResultThrowException(future, table, columnFamily, columnName, startWith, size)); } return new ArrayList<String>(terms).subList(0, Math.min(size, terms.size())); } }); } IndexManager(IndexServer indexServer, ClusterStatus clusterStatus, BlurFilterCache filterCache,
      int maxHeapPerRowFetch, int fetchCount, int threadCount, int mutateThreadCount, int facetThreadCount,
      DeepPagingCache deepPagingCache, MemoryAllocationWatcher memoryAllocationWatcher, QueryStatusManager statusManager); synchronized void close(); List<FetchResult> fetchRowBatch(final String table, List<Selector> selectors); void fetchRow(String table, Selector selector, FetchResult fetchResult); static void populateSelector(IndexSearcherCloseable searcher, String shardName, String table, Selector selector); static void validSelector(Selector selector); BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts); String parseQuery(String table, org.apache.blur.thrift.generated.Query simpleQuery); void cancelQuery(String table, String uuid); List<BlurQueryStatus> currentQueries(String table); BlurQueryStatus queryStatus(String table, String uuid); List<String> queryStatusIdList(String table); static void fetchRow(IndexReader reader, String table, String shard, Selector selector,
      FetchResult fetchResult, Query highlightQuery, int maxHeap, TableContext tableContext, Filter filter); static void fetchRow(IndexReader reader, String table, String shard, Selector selector,
      FetchResult fetchResult, Query highlightQuery, FieldManager fieldManager, int maxHeap, TableContext tableContext,
      Filter filter); static ResetableDocumentStoredFieldVisitor getFieldSelector(final Selector selector); IndexServer getIndexServer(); long recordFrequency(final String table, final String columnFamily, final String columnName, final String value); List<String> terms(final String table, final String columnFamily, final String columnName,
      final String startWith, final short size); static long recordFrequency(IndexReader reader, String columnFamily, String columnName, String value); static List<String> terms(IndexReader reader, FieldTypeDefinition typeDef, String columnFamily,
      String columnName, String startWith, short size); void mutate(final RowMutation mutation); void mutate(final List<RowMutation> mutations); void enqueue(List<RowMutation> mutations); static boolean resetExitableReader(IndexReader indexReader, AtomicBoolean running); void optimize(String table, int numberOfSegmentsPerShard); void enqueue(RowMutation mutation); void bulkMutateAdd(String table, String bulkId, RowMutation mutation); void bulkMutateFinish(Set<String> potentialTables, String bulkId, boolean apply, boolean blockUntilComplete); void bulkMutateAddMultiple(String table, String bulkId, List<RowMutation> rowMutations); static final String NOT_FOUND; static AtomicBoolean DEBUG_RUN_SLOW; }