@Test public void testFetchRowByLocationId() throws Exception { Selector selector = new Selector().setLocationId(SHARD_NAME + "/0"); FetchResult fetchResult = new FetchResult(); indexManager.fetchRow(TABLE, selector, fetchResult); assertNotNull(fetchResult.rowResult.row); Row row = newRow("row-1", newRecord(FAMILY, "record-1", newColumn("testcol1", "value1"), newColumn("testcol2", "value2"), newColumn("testcol3", "value3"))); row.recordCount = 1; assertEquals(row, fetchResult.rowResult.row); }
public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); BlurIndex index; try { if (selector.getLocationId() == null) { populateSelector(table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } String shard = getShard(locationId); Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table); if (blurIndexes == null) { LOG.error("Table [{0}] not found", table); throw new BlurException("Table [" + table + "] not found", null); } index = blurIndexes.get(shard); if (index == null) { if (index == null) { LOG.error("Shard [{0}] not found in table [{1}]", shard, table); throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]", null); } } } 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); } IndexReader reader = null; try { reader = index.getIndexReader(); fetchRow(reader, table, selector, fetchResult); if (_blurMetrics != null) { if (fetchResult.rowResult != null) { if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records != null) { _blurMetrics.recordReads.addAndGet(fetchResult.rowResult.row.records.size()); } _blurMetrics.rowReads.incrementAndGet(); } else if (fetchResult.recordResult != null) { _blurMetrics.recordReads.incrementAndGet(); } } } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { if (reader != null) { try { reader.decRef(); } catch (IOException e) { LOG.error("Unknown error trying to call decRef on reader [{0}]", e, reader); } } } }
IndexManager { public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); BlurIndex index; try { if (selector.getLocationId() == null) { populateSelector(table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } String shard = getShard(locationId); Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table); if (blurIndexes == null) { LOG.error("Table [{0}] not found", table); throw new BlurException("Table [" + table + "] not found", null); } index = blurIndexes.get(shard); if (index == null) { if (index == null) { LOG.error("Shard [{0}] not found in table [{1}]", shard, table); throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]", null); } } } 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); } IndexReader reader = null; try { reader = index.getIndexReader(); fetchRow(reader, table, selector, fetchResult); if (_blurMetrics != null) { if (fetchResult.rowResult != null) { if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records != null) { _blurMetrics.recordReads.addAndGet(fetchResult.rowResult.row.records.size()); } _blurMetrics.rowReads.incrementAndGet(); } else if (fetchResult.recordResult != null) { _blurMetrics.recordReads.incrementAndGet(); } } } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { if (reader != null) { try { reader.decRef(); } catch (IOException e) { LOG.error("Unknown error trying to call decRef on reader [{0}]", e, reader); } } } } }
IndexManager { public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); BlurIndex index; try { if (selector.getLocationId() == null) { populateSelector(table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } String shard = getShard(locationId); Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table); if (blurIndexes == null) { LOG.error("Table [{0}] not found", table); throw new BlurException("Table [" + table + "] not found", null); } index = blurIndexes.get(shard); if (index == null) { if (index == null) { LOG.error("Shard [{0}] not found in table [{1}]", shard, table); throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]", null); } } } 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); } IndexReader reader = null; try { reader = index.getIndexReader(); fetchRow(reader, table, selector, fetchResult); if (_blurMetrics != null) { if (fetchResult.rowResult != null) { if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records != null) { _blurMetrics.recordReads.addAndGet(fetchResult.rowResult.row.records.size()); } _blurMetrics.rowReads.incrementAndGet(); } else if (fetchResult.recordResult != null) { _blurMetrics.recordReads.incrementAndGet(); } } } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { if (reader != null) { try { reader.decRef(); } catch (IOException e) { LOG.error("Unknown error trying to call decRef on reader [{0}]", e, reader); } } } }  }
IndexManager { public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); BlurIndex index; try { if (selector.getLocationId() == null) { populateSelector(table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } String shard = getShard(locationId); Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table); if (blurIndexes == null) { LOG.error("Table [{0}] not found", table); throw new BlurException("Table [" + table + "] not found", null); } index = blurIndexes.get(shard); if (index == null) { if (index == null) { LOG.error("Shard [{0}] not found in table [{1}]", shard, table); throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]", null); } } } 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); } IndexReader reader = null; try { reader = index.getIndexReader(); fetchRow(reader, table, selector, fetchResult); if (_blurMetrics != null) { if (fetchResult.rowResult != null) { if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records != null) { _blurMetrics.recordReads.addAndGet(fetchResult.rowResult.row.records.size()); } _blurMetrics.rowReads.incrementAndGet(); } else if (fetchResult.recordResult != null) { _blurMetrics.recordReads.incrementAndGet(); } } } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { if (reader != null) { try { reader.decRef(); } catch (IOException e) { LOG.error("Unknown error trying to call decRef on reader [{0}]", e, reader); } } } }  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 void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException { validSelector(selector); BlurIndex index; try { if (selector.getLocationId() == null) { populateSelector(table, selector); } String locationId = selector.getLocationId(); if (locationId.equals(NOT_FOUND)) { fetchResult.setDeleted(false); fetchResult.setExists(false); return; } String shard = getShard(locationId); Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table); if (blurIndexes == null) { LOG.error("Table [{0}] not found", table); throw new BlurException("Table [" + table + "] not found", null); } index = blurIndexes.get(shard); if (index == null) { if (index == null) { LOG.error("Shard [{0}] not found in table [{1}]", shard, table); throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]", null); } } } 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); } IndexReader reader = null; try { reader = index.getIndexReader(); fetchRow(reader, table, selector, fetchResult); if (_blurMetrics != null) { if (fetchResult.rowResult != null) { if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records != null) { _blurMetrics.recordReads.addAndGet(fetchResult.rowResult.row.records.size()); } _blurMetrics.rowReads.incrementAndGet(); } else if (fetchResult.recordResult != null) { _blurMetrics.recordReads.incrementAndGet(); } } } catch (Exception e) { LOG.error("Unknown error while trying to fetch row.", e); throw new BException(e.getMessage(), e); } finally { if (reader != null) { try { reader.decRef(); } catch (IOException e) { LOG.error("Unknown error trying to call decRef on reader [{0}]", e, reader); } } } }  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);  }