kvs = toKeyValue(row, data.get(row), get.getMaxVersions()); } else { for (byte[] family : get.getFamilyMap().keySet()) { if (data.get(row).get(family) == null) continue; NavigableSet<byte[]> qualifiers = get.getFamilyMap().get(family); if (qualifiers == null || qualifiers.isEmpty()) qualifiers = data.get(row).get(family).navigableKeySet();
@Test public void testNullQualifier() { Get get = new Get(ROW); byte[] family = Bytes.toBytes("family"); get.addColumn(family, null); Set<byte[]> qualifiers = get.getFamilyMap().get(family); Assert.assertEquals(1, qualifiers.size()); }
/** * 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, byte [] row, NavigableSet<byte[]> columns ) throws IOException { Get get = new Get(row); Map<byte[], NavigableSet<byte[]>> s = get.getFamilyMap(); s.put(store.getColumnFamilyDescriptor().getName(), columns); return getFromStoreFile(store,get); }
@Override public Result get(Get get) throws IOException { TimeRange range = get.getTimeRange(); String spec = buildRowSpec(get.getRow(), get.getFamilyMap(), range.getMin(), range.getMax(), get.getMaxVersions()); if (get.getFilter() != null) { LOG.warn("filters not supported on gets"); } Result[] results = getResults(spec); if (results.length > 0) { if (results.length > 1) { LOG.warn("too many results for get (" + results.length + ")"); } return results[0]; } else { return new Result(); } }
NavigableMap<byte[], NavigableMap<byte[], MutableLong>> sums = new TreeMap<>(Bytes.BYTES_COMPARATOR); get.getFamilyMap().forEach((cf, cqs) -> { NavigableMap<byte[], MutableLong> ss = new TreeMap<>(Bytes.BYTES_COMPARATOR); sums.put(cf, ss);
@Test public void testMatchWhenFilterReturnsIncludeAndSeekNextRow() throws IOException { List<MatchCode> expected = new ArrayList<>(); expected.add(ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_ROW); expected.add(ScanQueryMatcher.MatchCode.DONE); Scan scanWithFilter = new Scan(scan).setFilter(new AlwaysIncludeAndSeekNextRowFilter()); long now = EnvironmentEdgeManager.currentTime(); // scan with column 2,4,5 UserScanQueryMatcher qm = UserScanQueryMatcher.create( scanWithFilter, new ScanInfo(this.conf, fam2, 0, 1, ttl, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), get.getFamilyMap().get(fam2), now - ttl, now, null); List<KeyValue> memstore = new ArrayList<>(); // ColumnTracker will return INCLUDE_AND_SEEK_NEXT_COL , and filter will return // INCLUDE_AND_SEEK_NEXT_ROW, so final match code will be INCLUDE_AND_SEEK_NEXT_ROW. memstore.add(new KeyValue(row1, fam2, col2, 1, data)); memstore.add(new KeyValue(row2, fam1, col1, data)); List<ScanQueryMatcher.MatchCode> actual = new ArrayList<>(memstore.size()); KeyValue k = memstore.get(0); qm.setToNewRow(k); for (KeyValue kv : memstore) { actual.add(qm.match(kv)); } assertEquals(expected.size(), actual.size()); for (int i = 0; i < expected.size(); i++) { LOG.debug("expected " + expected.get(i) + ", actual " + actual.get(i)); assertEquals(expected.get(i), actual.get(i)); } }
scan, new ScanInfo(this.conf, fam2, 0, 1, ttl, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), get.getFamilyMap().get(fam2), now - ttl, now, null);
this.checkExistenceOnly = get.isCheckExistenceOnly(); this.loadColumnFamiliesOnDemand = get.getLoadColumnFamiliesOnDemandValue(); Map<byte[], NavigableSet<byte[]>> fams = get.getFamilyMap(); for (Map.Entry<byte[],NavigableSet<byte[]>> entry : fams.entrySet()) { byte [] fam = entry.getKey();
this.storeOffset = get.getRowOffsetPerColumnFamily(); this.tr = get.getTimeRange(); this.familyMap = get.getFamilyMap(); this.asyncPrefetch = false; this.consistency = get.getConsistency();
scanWithFilter, new ScanInfo(this.conf, fam2, 0, 5, ttl, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), get.getFamilyMap().get(fam2), now - ttl, now, null);
scanWithFilter, new ScanInfo(this.conf, fam2, 0, 3, ttl, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), get.getFamilyMap().get(fam2), now - ttl, now, null); scanWithFilter, new ScanInfo(this.conf, fam2, 0, 2, ttl, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), get.getFamilyMap().get(fam2), now - ttl, now, null);
@Test public void testGet() throws Exception{ byte[] row = "row".getBytes(); byte[] fam = "fam".getBytes(); byte[] qf1 = "qf1".getBytes(); long ts = System.currentTimeMillis(); int maxVersions = 2; Get get = new Get(row); get.addColumn(fam, qf1); get.setTimeRange(ts, ts+1); get.setMaxVersions(maxVersions); ClientProtos.Get getProto = ProtobufUtil.toGet(get); Get desGet = ProtobufUtil.toGet(getProto); assertTrue(Bytes.equals(get.getRow(), desGet.getRow())); Set<byte[]> set = null; Set<byte[]> desSet = null; for(Map.Entry<byte[], NavigableSet<byte[]>> entry : get.getFamilyMap().entrySet()){ assertTrue(desGet.getFamilyMap().containsKey(entry.getKey())); set = entry.getValue(); desSet = desGet.getFamilyMap().get(entry.getKey()); for(byte [] qualifier : set){ assertTrue(desSet.contains(qualifier)); } } assertEquals(get.getMaxVersions(), desGet.getMaxVersions()); TimeRange tr = get.getTimeRange(); TimeRange desTr = desGet.getTimeRange(); assertEquals(tr.getMax(), desTr.getMax()); assertEquals(tr.getMin(), desTr.getMin()); }
out.setStoreOffset(in.getRowOffsetPerColumnFamily()); out.setExistence_only(in.isCheckExistenceOnly()); for (Map.Entry<byte[], NavigableSet<byte[]>> family : in.getFamilyMap().entrySet()) {
new ScanInfo(this.conf, fam2, 0, 1, testTTL, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), get.getFamilyMap().get(fam2), now - testTTL, now, null);
/** * This is a cryptic test. It is checking that we don't include a fake cell, one that has a * timestamp of {@link HConstants#OLDEST_TIMESTAMP}. See HBASE-16074 for background. * @throws IOException */ @Test public void testNeverIncludeFakeCell() throws IOException { long now = EnvironmentEdgeManager.currentTime(); // Do with fam2 which has a col2 qualifier. UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan, new ScanInfo(this.conf, fam2, 10, 1, ttl, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), get.getFamilyMap().get(fam2), now - ttl, now, null); Cell kv = new KeyValue(row1, fam2, col2, 1, data); Cell cell = PrivateCellUtil.createLastOnRowCol(kv); qm.setToNewRow(kv); MatchCode code = qm.match(cell); assertFalse(code.compareTo(MatchCode.SEEK_NEXT_COL) != 0); }
Map<byte[], NavigableSet<byte[]>> families = get.getFamilyMap(); for (Map.Entry<byte[], NavigableSet<byte[]>> family: families.entrySet()) { NavigableSet<byte[]> qualifiers = family.getValue();
Map<byte[], NavigableSet<byte[]>> families = get.getFamilyMap(); for (Map.Entry<byte[], NavigableSet<byte[]>> family: families.entrySet()) { NavigableSet<byte[]> qualifiers = family.getValue();
case GET: case EXISTS: families = ((Get)query).getFamilyMap(); break; case SCAN:
@Test public void testNullQualifier() { Get get = new Get(ROW); byte[] family = Bytes.toBytes("family"); get.addColumn(family, null); Set<byte[]> qualifiers = get.getFamilyMap().get(family); Assert.assertEquals(1, qualifiers.size()); }
@Override public boolean exists(Get get) throws IOException { if(get.getFamilyMap() == null || get.getFamilyMap().size() == 0) { return data.containsKey(get.getRow()); } else { byte[] row = get.getRow(); if(!data.containsKey(row)) { return false; } for(byte[] family : get.getFamilyMap().keySet()) { if(!data.get(row).containsKey(family)) { return false; } else { return true; } } return true; } }