protected void initializeScanners(Scan scan, List<KeyValueScanner> additionalScanners) throws IOException { // Here we separate all scanners into two lists - scanner that provide data required // by the filter to operate (scanners list) and all others (joinedScanners list). List<KeyValueScanner> scanners = new ArrayList<>(scan.getFamilyMap().size()); List<KeyValueScanner> joinedScanners = new ArrayList<>(scan.getFamilyMap().size()); // Store all already instantiated scanners for exception handling List<KeyValueScanner> instantiatedScanners = new ArrayList<>(); // handle additionalScanners if (additionalScanners != null && !additionalScanners.isEmpty()) { scanners.addAll(additionalScanners); instantiatedScanners.addAll(additionalScanners); } try { for (Map.Entry<byte[], NavigableSet<byte[]>> entry : scan.getFamilyMap().entrySet()) { HStore store = stores.get(entry.getKey()); KeyValueScanner scanner = store.getScanner(scan, entry.getValue(), this.readPt); instantiatedScanners.add(scanner); if (this.filter == null || !scan.doLoadColumnFamiliesOnDemand() || this.filter.isFamilyEssential(entry.getKey())) { scanners.add(scanner); } else { joinedScanners.add(scanner); } } initializeKVHeap(scanners, joinedScanners, region); } catch (Throwable t) { throw handleException(instantiatedScanners, t); } }
@Override public boolean shouldUseScanner(Scan scan, HStore store, long oldestUnexpiredTS) { // if the file has no entries, no need to validate or create a scanner. byte[] cf = store.getColumnFamilyDescriptor().getName(); TimeRange timeRange = scan.getColumnFamilyTimeRange().get(cf); if (timeRange == null) { timeRange = scan.getTimeRange(); } return reader.passesTimerangeFilter(timeRange, oldestUnexpiredTS) && reader .passesKeyRangeFilter(scan) && reader.passesBloomFilter(scan, scan.getFamilyMap().get(cf)); }
CellWithVersionsNoOptimizeStoreScanner(Scan scan, ScanInfo scanInfo) throws IOException { super(scan, scanInfo, scan.getFamilyMap().get(CF), Arrays.<KeyValueScanner> asList(new KeyValueScanner[] { new KeyValueScanFixture(CellComparator.getInstance(), CELL_WITH_VERSIONS) })); }
private StoreScanner getReversibleStoreScanner(MemStore memstore, HStoreFile sf1, HStoreFile sf2, Scan scan, ScanInfo scanInfo, int readPoint) throws IOException { List<KeyValueScanner> scanners = getScanners(memstore, sf1, sf2, null, false, readPoint); NavigableSet<byte[]> columns = null; for (Map.Entry<byte[], NavigableSet<byte[]>> entry : scan.getFamilyMap().entrySet()) { // Should only one family columns = entry.getValue(); } StoreScanner storeScanner = new ReversedStoreScanner(scan, scanInfo, columns, scanners); return storeScanner; }
CellWithVersionsStoreScanner(final Scan scan, ScanInfo scanInfo) throws IOException { super(scan, scanInfo, scan.getFamilyMap().get(CF), Arrays.<KeyValueScanner> asList(new KeyValueScanner[] { new KeyValueScanFixture(CellComparator.getInstance(), CELL_WITH_VERSIONS) })); }
CellGridStoreScanner(final Scan scan, ScanInfo scanInfo) throws IOException { super(scan, scanInfo, scan.getFamilyMap().get(CF), Arrays.<KeyValueScanner> asList( new KeyValueScanner[] { new KeyValueScanFixture(CellComparator.getInstance(), CELL_GRID) })); }
@Test public void testNullQualifier() { Scan scan = new Scan(); byte[] family = Bytes.toBytes("family"); scan.addColumn(family, null); Set<byte[]> qualifiers = scan.getFamilyMap().get(family); Assert.assertEquals(1, qualifiers.size()); }
/** * For HBASE-2156 */ @Test public void testScanVariableReuse() throws Exception { Scan scan = new Scan(); scan.addFamily(FAMILY); scan.addColumn(FAMILY, ROW); assertTrue(scan.getFamilyMap().get(FAMILY).size() == 1); scan = new Scan(); scan.addFamily(FAMILY); assertTrue(scan.getFamilyMap().get(FAMILY) == null); assertTrue(scan.getFamilyMap().containsKey(FAMILY)); }
/** * @param scan the HBase scan object to use to read data from HBase * @param canFamilyBeAbsent whether column family can be absent in familyMap of scan */ private static void validateParameters(Scan scan, boolean canFamilyBeAbsent) throws IOException { if (scan == null || (Bytes.equals(scan.getStartRow(), scan.getStopRow()) && !Bytes.equals(scan.getStartRow(), HConstants.EMPTY_START_ROW)) || ((Bytes.compareTo(scan.getStartRow(), scan.getStopRow()) > 0) && !Bytes.equals(scan.getStopRow(), HConstants.EMPTY_END_ROW))) { throw new IOException("Agg client Exception: Startrow should be smaller than Stoprow"); } else if (!canFamilyBeAbsent) { if (scan.getFamilyMap().size() != 1) { throw new IOException("There must be only one family."); } } }
private RegionScannerImpl getScanner(Scan scan, List<KeyValueScanner> additionalScanners, long nonceGroup, long nonce) throws IOException { startRegionOperation(Operation.SCAN); try { // Verify families are all valid if (!scan.hasFamilies()) { // Adding all families to scanner for (byte[] family : this.htableDescriptor.getColumnFamilyNames()) { scan.addFamily(family); } } else { for (byte[] family : scan.getFamilyMap().keySet()) { checkFamily(family); } } return instantiateRegionScanner(scan, additionalScanners, nonceGroup, nonce); } finally { closeRegionOperation(Operation.SCAN); } }
return future; int firstPartIndex = scan.getFamilyMap().get(scan.getFamilies()[0]).size() - 1; AbstractAggregationCallback<NavigableMap<byte[], S>> callback = new AbstractAggregationCallback<NavigableMap<byte[], S>>(future) {
/** * Do a small get/scan against one store. This is required because store * has no actual methods of querying itself, and relies on StoreScanner. */ public static List<Cell> getFromStoreFile(HStore store, Get get) throws IOException { Scan scan = new Scan(get); InternalScanner scanner = (InternalScanner) store.getScanner(scan, scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), // originally MultiVersionConcurrencyControl.resetThreadReadPoint() was called to set // readpoint 0. 0); List<Cell> result = new ArrayList<>(); scanner.next(result); if (!result.isEmpty()) { // verify that we are on the row we want: Cell kv = result.get(0); if (!CellUtil.matchingRows(kv, get.getRow())) { result.clear(); } } scanner.close(); return result; }
model.setStartRow(scan.getStartRow()); model.setEndRow(scan.getStopRow()); Map<byte [], NavigableSet<byte []>> families = scan.getFamilyMap(); if (families != null) { for (Map.Entry<byte [], NavigableSet<byte []>> entry : families.entrySet()) {
/** * Getting data from memstore * @throws IOException */ @Test public void testGetFromMemStore() throws IOException { final Configuration conf = HBaseConfiguration.create(); init(name.getMethodName(), conf, false); //Put data in memstore this.store.add(new KeyValue(row, family, qf1, 1, value), null); this.store.add(new KeyValue(row, family, qf2, 1, value), null); this.store.add(new KeyValue(row, family, qf3, 1, value), null); this.store.add(new KeyValue(row, family, qf4, 1, value), null); this.store.add(new KeyValue(row, family, qf5, 1, value), null); this.store.add(new KeyValue(row, family, qf6, 1, value), null); Scan scan = new Scan(get); InternalScanner scanner = (InternalScanner) store.getScanner(scan, scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), 0); List<Cell> results = new ArrayList<>(); scanner.next(results); Collections.sort(results, CellComparatorImpl.COMPARATOR); scanner.close(); //Compare Assert.assertEquals(expected.size(), results.size()); for(int i=0; i<results.size(); i++) { // Verify the values Assert.assertEquals(expected.get(i), results.get(i)); } }
scan.getFamilyMap().entrySet()){ assertTrue(desScan.getFamilyMap().containsKey(entry.getKey())); set = entry.getValue(); desSet = desScan.getFamilyMap().get(entry.getKey()); for(byte[] column : set){ assertTrue(desSet.contains(column));
scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), 0);
scan.setAttribute(MobConstants.MOB_SCAN_RAW, Bytes.toBytes(Boolean.TRUE)); InternalScanner scanner = (InternalScanner) store.getScanner(scan, scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), 0);
scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), 0);
scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), 0);
scan.setAttribute(MobConstants.MOB_SCAN_RAW, Bytes.toBytes(Boolean.TRUE)); InternalScanner scanner = (InternalScanner) store.getScanner(scan, scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), 0);