@Test public void testFetchRowByRowIdWithColumnSet() throws Exception { Selector selector = new Selector().setRowId("row-6"); selector.putToColumnsToFetch(FAMILY, new HashSet<String>(Arrays.asList("testcol12"))); FetchResult fetchResult = new FetchResult(); indexManager.fetchRow(TABLE, selector, fetchResult); assertNotNull(fetchResult.rowResult.row); Row row = newRow("row-6", newRecord(FAMILY, "record-6A", newColumn("testcol12", "value110")), newRecord(FAMILY, "record-6B", newColumn("testcol12", "value101"))); FetchRowResult rowResult = fetchResult.getRowResult(); assertEquals(row, rowResult.getRow()); assertEquals(2, rowResult.getTotalRecords()); }
public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); TableContext tableContext = getTableContext(table); ReadInterceptor interceptor = tableContext.getReadInterceptor(); Filter filter = interceptor.getFilter(); BlurIndex index = null; String shard = null; Tracer trace = Trace.trace("manager fetch", Trace.param("table", table)); IndexSearcherCloseable searcher = null; try { if (selector.getLocationId() == null) { ShardServerContext.resetSearchers(); shard = MutationHelper.getShardName(table, selector.rowId, getNumberOfShards(table), _blurPartitioner); index = getBlurIndex(table, shard); searcher = index.getIndexSearcher(); populateSelector(searcher, shard, table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } if (shard == null) { shard = getShard(locationId); } if (index == null) { index = getBlurIndex(table, shard); } } catch (BlurException e) { throw e; } catch (Exception e) { LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector); throw new BException(e.getMessage(), e); } TimerContext timerContext = _fetchTimer.time(); boolean usedCache = true; try { ShardServerContext shardServerContext = ShardServerContext.getShardServerContext(); if (shardServerContext != null) { searcher = shardServerContext.getIndexSearcherClosable(table, shard); } if (searcher == null) { searcher = index.getIndexSearcher(); usedCache = false; } FieldManager fieldManager = tableContext.getFieldManager(); Query highlightQuery = getHighlightQuery(selector, table, fieldManager); fetchRow(searcher.getIndexReader(), table, shard, selector, fetchResult, highlightQuery, fieldManager, _maxHeapPerRowFetch, tableContext, filter); } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { trace.done(); timerContext.stop(); if (!usedCache && searcher != null) { try { searcher.close(); } catch (IOException e) { LOG.error("Unknown error trying to call close on searcher [{0}]", e, searcher); } } } }
IndexManager { public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); TableContext tableContext = getTableContext(table); ReadInterceptor interceptor = tableContext.getReadInterceptor(); Filter filter = interceptor.getFilter(); BlurIndex index = null; String shard = null; Tracer trace = Trace.trace("manager fetch", Trace.param("table", table)); IndexSearcherCloseable searcher = null; try { if (selector.getLocationId() == null) { ShardServerContext.resetSearchers(); shard = MutationHelper.getShardName(table, selector.rowId, getNumberOfShards(table), _blurPartitioner); index = getBlurIndex(table, shard); searcher = index.getIndexSearcher(); populateSelector(searcher, shard, table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } if (shard == null) { shard = getShard(locationId); } if (index == null) { index = getBlurIndex(table, shard); } } catch (BlurException e) { throw e; } catch (Exception e) { LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector); throw new BException(e.getMessage(), e); } TimerContext timerContext = _fetchTimer.time(); boolean usedCache = true; try { ShardServerContext shardServerContext = ShardServerContext.getShardServerContext(); if (shardServerContext != null) { searcher = shardServerContext.getIndexSearcherClosable(table, shard); } if (searcher == null) { searcher = index.getIndexSearcher(); usedCache = false; } FieldManager fieldManager = tableContext.getFieldManager(); Query highlightQuery = getHighlightQuery(selector, table, fieldManager); fetchRow(searcher.getIndexReader(), table, shard, selector, fetchResult, highlightQuery, fieldManager, _maxHeapPerRowFetch, tableContext, filter); } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { trace.done(); timerContext.stop(); if (!usedCache && searcher != null) { try { searcher.close(); } catch (IOException e) { LOG.error("Unknown error trying to call close on searcher [{0}]", e, searcher); } } } } }
IndexManager { public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); TableContext tableContext = getTableContext(table); ReadInterceptor interceptor = tableContext.getReadInterceptor(); Filter filter = interceptor.getFilter(); BlurIndex index = null; String shard = null; Tracer trace = Trace.trace("manager fetch", Trace.param("table", table)); IndexSearcherCloseable searcher = null; try { if (selector.getLocationId() == null) { ShardServerContext.resetSearchers(); shard = MutationHelper.getShardName(table, selector.rowId, getNumberOfShards(table), _blurPartitioner); index = getBlurIndex(table, shard); searcher = index.getIndexSearcher(); populateSelector(searcher, shard, table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } if (shard == null) { shard = getShard(locationId); } if (index == null) { index = getBlurIndex(table, shard); } } catch (BlurException e) { throw e; } catch (Exception e) { LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector); throw new BException(e.getMessage(), e); } TimerContext timerContext = _fetchTimer.time(); boolean usedCache = true; try { ShardServerContext shardServerContext = ShardServerContext.getShardServerContext(); if (shardServerContext != null) { searcher = shardServerContext.getIndexSearcherClosable(table, shard); } if (searcher == null) { searcher = index.getIndexSearcher(); usedCache = false; } FieldManager fieldManager = tableContext.getFieldManager(); Query highlightQuery = getHighlightQuery(selector, table, fieldManager); fetchRow(searcher.getIndexReader(), table, shard, selector, fetchResult, highlightQuery, fieldManager, _maxHeapPerRowFetch, tableContext, filter); } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { trace.done(); timerContext.stop(); if (!usedCache && searcher != null) { try { searcher.close(); } catch (IOException e) { LOG.error("Unknown error trying to call close on searcher [{0}]", e, searcher); } } } } 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 void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); TableContext tableContext = getTableContext(table); ReadInterceptor interceptor = tableContext.getReadInterceptor(); Filter filter = interceptor.getFilter(); BlurIndex index = null; String shard = null; Tracer trace = Trace.trace("manager fetch", Trace.param("table", table)); IndexSearcherCloseable searcher = null; try { if (selector.getLocationId() == null) { ShardServerContext.resetSearchers(); shard = MutationHelper.getShardName(table, selector.rowId, getNumberOfShards(table), _blurPartitioner); index = getBlurIndex(table, shard); searcher = index.getIndexSearcher(); populateSelector(searcher, shard, table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } if (shard == null) { shard = getShard(locationId); } if (index == null) { index = getBlurIndex(table, shard); } } catch (BlurException e) { throw e; } catch (Exception e) { LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector); throw new BException(e.getMessage(), e); } TimerContext timerContext = _fetchTimer.time(); boolean usedCache = true; try { ShardServerContext shardServerContext = ShardServerContext.getShardServerContext(); if (shardServerContext != null) { searcher = shardServerContext.getIndexSearcherClosable(table, shard); } if (searcher == null) { searcher = index.getIndexSearcher(); usedCache = false; } FieldManager fieldManager = tableContext.getFieldManager(); Query highlightQuery = getHighlightQuery(selector, table, fieldManager); fetchRow(searcher.getIndexReader(), table, shard, selector, fetchResult, highlightQuery, fieldManager, _maxHeapPerRowFetch, tableContext, filter); } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { trace.done(); timerContext.stop(); if (!usedCache && searcher != null) { try { searcher.close(); } catch (IOException e) { LOG.error("Unknown error trying to call close on searcher [{0}]", e, searcher); } } } } 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 void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); TableContext tableContext = getTableContext(table); ReadInterceptor interceptor = tableContext.getReadInterceptor(); Filter filter = interceptor.getFilter(); BlurIndex index = null; String shard = null; Tracer trace = Trace.trace("manager fetch", Trace.param("table", table)); IndexSearcherCloseable searcher = null; try { if (selector.getLocationId() == null) { ShardServerContext.resetSearchers(); shard = MutationHelper.getShardName(table, selector.rowId, getNumberOfShards(table), _blurPartitioner); index = getBlurIndex(table, shard); searcher = index.getIndexSearcher(); populateSelector(searcher, shard, table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } if (shard == null) { shard = getShard(locationId); } if (index == null) { index = getBlurIndex(table, shard); } } catch (BlurException e) { throw e; } catch (Exception e) { LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector); throw new BException(e.getMessage(), e); } TimerContext timerContext = _fetchTimer.time(); boolean usedCache = true; try { ShardServerContext shardServerContext = ShardServerContext.getShardServerContext(); if (shardServerContext != null) { searcher = shardServerContext.getIndexSearcherClosable(table, shard); } if (searcher == null) { searcher = index.getIndexSearcher(); usedCache = false; } FieldManager fieldManager = tableContext.getFieldManager(); Query highlightQuery = getHighlightQuery(selector, table, fieldManager); fetchRow(searcher.getIndexReader(), table, shard, selector, fetchResult, highlightQuery, fieldManager, _maxHeapPerRowFetch, tableContext, filter); } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { trace.done(); timerContext.stop(); if (!usedCache && searcher != null) { try { searcher.close(); } catch (IOException e) { LOG.error("Unknown error trying to call close on searcher [{0}]", e, searcher); } } } } 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; }