@Test public void testQueryRecordOnly() throws Exception { BlurQuery blurQuery = new BlurQuery(); blurQuery.simpleQuery = new SimpleQuery(); blurQuery.simpleQuery.queryStr = "test-family.testcol1:value1"; blurQuery.selector = new Selector(); blurQuery.selector.setRecordOnly(true); BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, null); assertEquals(iterable.getTotalResults(), 2); int matchRecord1 = 0; int matchRecord4 = 0; for (BlurResult result : iterable) { assertNull(result.fetchResult.rowResult); assertNotNull(result.fetchResult.recordResult); Record r = result.fetchResult.recordResult.record; if (r.getRecordId().equals("record-1")) { matchRecord1 += 1; } else if (r.getRecordId().equals("record-4")) { matchRecord4 += 1; } else { fail("Unexpected record ID [" + r.getRecordId() + "]"); } } assertEquals("Unexpected number of record-1 results", 1, matchRecord1); assertEquals("Unexpected number of record-4 results", 1, matchRecord4); }
public BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts) throws Exception { final AtomicBoolean running = new AtomicBoolean(true); final QueryStatus status = _statusManager.newQueryStatus(table, blurQuery, _threadCount, running); _blurMetrics.queriesExternal.incrementAndGet(); try { 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); } Analyzer analyzer = _indexServer.getAnalyzer(table); ParallelCall<Entry<String, BlurIndex>, BlurResultIterable> call; if (isSimpleQuery(blurQuery)) { SimpleQuery simpleQuery = blurQuery.simpleQuery; Filter preFilter = QueryParserUtil.parseFilter(table, simpleQuery.preSuperFilter, false, analyzer, _filterCache); Filter postFilter = QueryParserUtil.parseFilter(table, simpleQuery.postSuperFilter, true, analyzer, _filterCache); Query userQuery = QueryParserUtil.parseQuery(simpleQuery.queryStr, simpleQuery.superQueryOn, analyzer, postFilter, preFilter, getScoreType(simpleQuery.type)); Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } else { Query query = getQuery(blurQuery.expertQuery); Filter filter = getFilter(blurQuery.expertQuery); Query userQuery; if (filter != null) { userQuery = new FilteredQuery(query, filter); } else { userQuery = query; } Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery); return ForkJoin.execute(_executor, blurIndexes.entrySet(), call, new Cancel() { @Override public void cancel() { running.set(false); } }).merge(merger); } finally { _statusManager.removeStatus(status); } }
IndexManager { public BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts) throws Exception { final AtomicBoolean running = new AtomicBoolean(true); final QueryStatus status = _statusManager.newQueryStatus(table, blurQuery, _threadCount, running); _blurMetrics.queriesExternal.incrementAndGet(); try { 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); } Analyzer analyzer = _indexServer.getAnalyzer(table); ParallelCall<Entry<String, BlurIndex>, BlurResultIterable> call; if (isSimpleQuery(blurQuery)) { SimpleQuery simpleQuery = blurQuery.simpleQuery; Filter preFilter = QueryParserUtil.parseFilter(table, simpleQuery.preSuperFilter, false, analyzer, _filterCache); Filter postFilter = QueryParserUtil.parseFilter(table, simpleQuery.postSuperFilter, true, analyzer, _filterCache); Query userQuery = QueryParserUtil.parseQuery(simpleQuery.queryStr, simpleQuery.superQueryOn, analyzer, postFilter, preFilter, getScoreType(simpleQuery.type)); Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } else { Query query = getQuery(blurQuery.expertQuery); Filter filter = getFilter(blurQuery.expertQuery); Query userQuery; if (filter != null) { userQuery = new FilteredQuery(query, filter); } else { userQuery = query; } Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery); return ForkJoin.execute(_executor, blurIndexes.entrySet(), call, new Cancel() { @Override public void cancel() { running.set(false); } }).merge(merger); } finally { _statusManager.removeStatus(status); } } }
IndexManager { public BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts) throws Exception { final AtomicBoolean running = new AtomicBoolean(true); final QueryStatus status = _statusManager.newQueryStatus(table, blurQuery, _threadCount, running); _blurMetrics.queriesExternal.incrementAndGet(); try { 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); } Analyzer analyzer = _indexServer.getAnalyzer(table); ParallelCall<Entry<String, BlurIndex>, BlurResultIterable> call; if (isSimpleQuery(blurQuery)) { SimpleQuery simpleQuery = blurQuery.simpleQuery; Filter preFilter = QueryParserUtil.parseFilter(table, simpleQuery.preSuperFilter, false, analyzer, _filterCache); Filter postFilter = QueryParserUtil.parseFilter(table, simpleQuery.postSuperFilter, true, analyzer, _filterCache); Query userQuery = QueryParserUtil.parseQuery(simpleQuery.queryStr, simpleQuery.superQueryOn, analyzer, postFilter, preFilter, getScoreType(simpleQuery.type)); Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } else { Query query = getQuery(blurQuery.expertQuery); Filter filter = getFilter(blurQuery.expertQuery); Query userQuery; if (filter != null) { userQuery = new FilteredQuery(query, filter); } else { userQuery = query; } Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery); return ForkJoin.execute(_executor, blurIndexes.entrySet(), call, new Cancel() { @Override public void cancel() { running.set(false); } }).merge(merger); } finally { _statusManager.removeStatus(status); } }  }
IndexManager { public BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts) throws Exception { final AtomicBoolean running = new AtomicBoolean(true); final QueryStatus status = _statusManager.newQueryStatus(table, blurQuery, _threadCount, running); _blurMetrics.queriesExternal.incrementAndGet(); try { 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); } Analyzer analyzer = _indexServer.getAnalyzer(table); ParallelCall<Entry<String, BlurIndex>, BlurResultIterable> call; if (isSimpleQuery(blurQuery)) { SimpleQuery simpleQuery = blurQuery.simpleQuery; Filter preFilter = QueryParserUtil.parseFilter(table, simpleQuery.preSuperFilter, false, analyzer, _filterCache); Filter postFilter = QueryParserUtil.parseFilter(table, simpleQuery.postSuperFilter, true, analyzer, _filterCache); Query userQuery = QueryParserUtil.parseQuery(simpleQuery.queryStr, simpleQuery.superQueryOn, analyzer, postFilter, preFilter, getScoreType(simpleQuery.type)); Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } else { Query query = getQuery(blurQuery.expertQuery); Filter filter = getFilter(blurQuery.expertQuery); Query userQuery; if (filter != null) { userQuery = new FilteredQuery(query, filter); } else { userQuery = query; } Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery); return ForkJoin.execute(_executor, blurIndexes.entrySet(), call, new Cancel() { @Override public void cancel() { running.set(false); } }).merge(merger); } finally { _statusManager.removeStatus(status); } }  void setMaxClauseCount(int maxClauseCount); void init(); synchronized void close(); void fetchRow(String table, Selector selector, FetchResult fetchResult); static void validSelector(Selector selector); BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts); void cancelQuery(String table, long uuid); List<BlurQueryStatus> currentQueries(String table); BlurQueryStatus queryStatus(String table, long uuid); List<Long> queryStatusIdList(String table); static void fetchRow(IndexReader reader, String table, Selector selector, FetchResult fetchResult); static FieldSelector getFieldSelector(final Selector selector); IndexServer getIndexServer(); void setIndexServer(IndexServer indexServer); 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, String columnFamily, String columnName, String startWith, short size); Schema schema(String table); void setStatusCleanupTimerDelay(long delay); void mutate(final RowMutation mutation); void mutate(final List<RowMutation> mutations); void setThreadCount(int threadCount); void setBlurMetrics(BlurMetrics blurMetrics); void setFilterCache(BlurFilterCache filterCache); void optimize(String table, int numberOfSegmentsPerShard); }
IndexManager { public BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts) throws Exception { final AtomicBoolean running = new AtomicBoolean(true); final QueryStatus status = _statusManager.newQueryStatus(table, blurQuery, _threadCount, running); _blurMetrics.queriesExternal.incrementAndGet(); try { 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); } Analyzer analyzer = _indexServer.getAnalyzer(table); ParallelCall<Entry<String, BlurIndex>, BlurResultIterable> call; if (isSimpleQuery(blurQuery)) { SimpleQuery simpleQuery = blurQuery.simpleQuery; Filter preFilter = QueryParserUtil.parseFilter(table, simpleQuery.preSuperFilter, false, analyzer, _filterCache); Filter postFilter = QueryParserUtil.parseFilter(table, simpleQuery.postSuperFilter, true, analyzer, _filterCache); Query userQuery = QueryParserUtil.parseQuery(simpleQuery.queryStr, simpleQuery.superQueryOn, analyzer, postFilter, preFilter, getScoreType(simpleQuery.type)); Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } else { Query query = getQuery(blurQuery.expertQuery); Filter filter = getFilter(blurQuery.expertQuery); Query userQuery; if (filter != null) { userQuery = new FilteredQuery(query, filter); } else { userQuery = query; } Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer); call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector, _blurMetrics); } MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery); return ForkJoin.execute(_executor, blurIndexes.entrySet(), call, new Cancel() { @Override public void cancel() { running.set(false); } }).merge(merger); } finally { _statusManager.removeStatus(status); } }  void setMaxClauseCount(int maxClauseCount); void init(); synchronized void close(); void fetchRow(String table, Selector selector, FetchResult fetchResult); static void validSelector(Selector selector); BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts); void cancelQuery(String table, long uuid); List<BlurQueryStatus> currentQueries(String table); BlurQueryStatus queryStatus(String table, long uuid); List<Long> queryStatusIdList(String table); static void fetchRow(IndexReader reader, String table, Selector selector, FetchResult fetchResult); static FieldSelector getFieldSelector(final Selector selector); IndexServer getIndexServer(); void setIndexServer(IndexServer indexServer); 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, String columnFamily, String columnName, String startWith, short size); Schema schema(String table); void setStatusCleanupTimerDelay(long delay); void mutate(final RowMutation mutation); void mutate(final List<RowMutation> mutations); void setThreadCount(int threadCount); void setBlurMetrics(BlurMetrics blurMetrics); void setFilterCache(BlurFilterCache filterCache); void optimize(String table, int numberOfSegmentsPerShard);  }