Get a collection of Scans, one per region, that cover the range of the table having the given
key prefix. Thes will be used as the map task input splits.
333320
public static List<Scan> scansThisCubeOnly(byte[] keyPrefix,
                                               byte[][] splitKeys) throws IOException {
        Scan copyScan = new Scan();
        copyScan.setCaching(5000);
        copyScan.setCacheBlocks(false);

        // Hack: generate a key that probably comes after all this cube's keys but doesn't include any
        // keys not belonging to this cube.
        byte[] keyAfterCube = ArrayUtils.addAll(keyPrefix, fiftyBytesFF);

        List<Scan> scans = new ArrayList<Scan>();
        Scan scanUnderConstruction = new Scan(copyScan);

        for (byte[] splitKey : splitKeys) {
            scanUnderConstruction.setStopRow(splitKey);

            // Coerce scan to only touch keys belonging to this cube
            Scan truncated = truncateScan(scanUnderConstruction, keyPrefix, keyAfterCube);
            if (truncated != null) {
                scans.add(truncated);
            }

            scanUnderConstruction = new Scan(copyScan);
            scanUnderConstruction.setStartRow(splitKey);
        }

        // There's another region from last split key to the end of the table.
        Scan truncated = truncateScan(scanUnderConstruction, keyPrefix, keyAfterCube);
        if (truncated != null) {
            scans.add(truncated);
        }

        return scans;
    }
500029
def get_all_regions_with_tiles(self):
        
        for key in self.get_all_keys():
            (layer, rx, ry) = struct.unpack('>BHH', key)
            if layer == 1:
                yield (rx, ry)
47307
def _load_regions(target):
    """"""
    regions = []
    with open(target) as in_handle:
        for line in in_handle:
            if not line.startswith("#"):
                c, s, e = line.strip().split("\t")
                regions.append((c, s, e))
    return regions
797505
private ParsedResultAccumulator getBestCostPlanForEphemeralScans(List<StmtEphemeralTableScan> scans) {
        int nextPlanId = m_planSelector.m_planId;
        boolean orderIsDeterministic = true;
        boolean hasSignificantOffsetOrLimit = false;
        String contentNonDeterminismMessage = null;
        for (StmtEphemeralTableScan scan : scans) {
            if (scan instanceof StmtSubqueryScan) {
                nextPlanId = planForParsedSubquery((StmtSubqueryScan)scan, nextPlanId);
                // If we can't plan this, then give up.
                if (((StmtSubqueryScan) scan).getBestCostPlan() == null) {
                    return null;
                }
            }
            else if (scan instanceof StmtCommonTableScan) {
                nextPlanId = planForCommonTableQuery((StmtCommonTableScan)scan, nextPlanId);
                if (((StmtCommonTableScan) scan).getBestCostBasePlan() == null) {
                    return null;
                }
            }
            else {
                throw new PlanningErrorException("Unknown scan plan type.");
            }
            orderIsDeterministic = scan.isOrderDeterministic(orderIsDeterministic);
            contentNonDeterminismMessage = scan.contentNonDeterminismMessage(contentNonDeterminismMessage);
            hasSignificantOffsetOrLimit = scan.hasSignificantOffsetOrLimit(hasSignificantOffsetOrLimit);
        }
        // need to reset plan id for the entire SQL
        m_planSelector.m_planId = nextPlanId;

        return new ParsedResultAccumulator(orderIsDeterministic,
                                           hasSignificantOffsetOrLimit,
                                           contentNonDeterminismMessage);
    }
812858
private AbstractPlanNode indexAccessForGroupByExprs(SeqScanPlanNode root,
            IndexGroupByInfo gbInfo) {
        if (! root.isPersistentTableScan()) {
            // subquery and common tables are not handled
            return root;
        }

        String fromTableAlias = root.getTargetTableAlias();
        assert(fromTableAlias != null);

        List<ParsedColInfo> groupBys = m_parsedSelect.groupByColumns();
        Table targetTable = m_catalogDb.getTables().get(root.getTargetTableName());
        assert(targetTable != null);
        CatalogMap<Index> allIndexes = targetTable.getIndexes();

        List<Integer> maxCoveredGroupByColumns = new ArrayList<>();
        ArrayList<AbstractExpression> maxCoveredBindings = null;
        Index pickedUpIndex = null;
        boolean foundAllGroupByCoveredIndex = false;

        for (Index index : allIndexes) {
            if ( ! IndexType.isScannable(index.getType())) {
                continue;
            }

            if ( ! index.getPredicatejson().isEmpty()) {
                // do not try to look at Partial/Sparse index
                continue;
            }

            ArrayList<AbstractExpression> bindings = new ArrayList<>();
            List<Integer> coveredGroupByColumns = calculateGroupbyColumnsCovered(
                    index, fromTableAlias, bindings);

            if (coveredGroupByColumns.size() > maxCoveredGroupByColumns.size()) {
                maxCoveredGroupByColumns = coveredGroupByColumns;
                pickedUpIndex = index;
                maxCoveredBindings = bindings;

                if (maxCoveredGroupByColumns.size() == groupBys.size()) {
                    foundAllGroupByCoveredIndex = true;
                    break;
                }
            }
        }
        if (pickedUpIndex == null) {
            return root;
        }

        IndexScanPlanNode indexScanNode = new IndexScanPlanNode(
                root, null, pickedUpIndex, SortDirectionType.INVALID);
        indexScanNode.setForGroupingOnly();
        indexScanNode.setBindings(maxCoveredBindings);

        gbInfo.m_coveredGroupByColumns = maxCoveredGroupByColumns;
        gbInfo.m_canBeFullySerialized = foundAllGroupByCoveredIndex;
        return indexScanNode;
    }
784743
public float[] query(Region region) throws IOException {
        BigWigIterator bigWigIterator = iterator(region);
        float[] values = new float[region.getEnd() - region.getStart() + 1];
        while (bigWigIterator.hasNext()) {
            WigItem wigItem = bigWigIterator.next();
            for (int i = wigItem.getStartBase(), j = wigItem.getStartBase() - region.getStart(); i <= wigItem.getEndBase(); i++, j++) {
                values[j] = wigItem.getWigValue();
            }
        }
        return values;
    }
878147
private List<String> extractRanges(String range) {
		List<String> ranges;
		String[] rangeSpl = range.split(",");

		// Recent versions of scop always specify a chain, so no processing is needed
		if(scopVersion.compareTo("1.73") < 0 ) {
			for(int i=0; i<rangeSpl.length;i++) {
				String subRange = rangeSpl[i];

				// Allow single-chains, as well as the '-' special case
				if(subRange.length()<2) {
					continue;
				}

				// Allow explicit chain syntax
				if(subRange.charAt(1) != ':') {
					// Early versions sometimes skip the chain identifier for single-chain domains
					// Indicate this with a chain "_"
					rangeSpl[i] = "_:"+subRange;
				}
			}
		}
		ranges = Arrays.asList(rangeSpl);
		return ranges;
	}
1201852
def scan(self, cursor=0, match=None, count=None):
        
        f = Future()
        if self.keyspace is None:
            with self.pipe as pipe:
                res = pipe.scan(cursor=cursor, match=match, count=count)

                def cb():
                    f.set((res[0], [self.keyparse.decode(v) for v in res[1]]))

                pipe.on_execute(cb)
                return f

        if match is None:
            match = '*'
        match = "%s{%s}" % (self.keyspace, match)
        pattern = re.compile(r'^%s\{(.*)\}$' % self.keyspace)

        with self.pipe as pipe:

            res = pipe.scan(cursor=cursor, match=match, count=count)

            def cb():
                keys = []
                for k in res[1]:
                    k = self.keyparse.decode(k)
                    m = pattern.match(k)
                    if m:
                        keys.append(m.group(1))

                f.set((res[0], keys))

            pipe.on_execute(cb)
            return f
993355
function listRegionKeys() {
  const regionKeys = new Array(regionKeysByRegion.size);
  const iter = regionKeysByRegion.values();
  let v = iter.next();
  let i = -1;
  while (!v.done) {
    regionKeys[++i] = v.value;
    v = iter.next();
  }
  return regionKeys;
}
561007
private List<HBaseDataWrapper> scanResults(final String tableName, List<HBaseDataWrapper> results)
            throws IOException
    {
        if (fetchSize == null)
        {
            for (Result result : scanner)
            {
                HBaseDataWrapper data = new HBaseDataWrapper(tableName, result.getRow());
                data.setColumns(result.listCells());
                results.add(data);
            }

            scanner = null;
            resultsIter = null;
        }
        return results;
    }
985143
function scan(req, res) {
  var records = []
    , position
    , i
    , key
    , inc
    , map = this.map
    , len = this.cursor + this.count;

  for(i = this.cursor; i < len;i++) {
    if(i === this.target.length) {
      position = 0;
      break;
    }
    key = '' + this.target[i];
    inc = !this.pattern || (this.pattern && this.pattern.test(key));
    if(inc) {
      records.push(key);
      if(map) records.push(this.stringify ? '' + map[key] : map[key]);
    }
    position = i + 1;
  }

  res.send(null, [position, records]);
}
679356
public static List<Scanner> getScanners(final Query query) {
    final List<Scanner> scanners = new ArrayList<Scanner>(
        Const.SALT_WIDTH() > 0 ? Const.SALT_BUCKETS() : 1);
    if (Const.SALT_WIDTH() > 0) {
      for (int i = 0; i < Const.SALT_BUCKETS(); i++) {
        scanners.add(((TsdbQuery) query).getScanner(i));
      }
    } else {
      scanners.add(((TsdbQuery) query).getScanner());
    }
    return scanners;
  }
401245
public Set<Map.Entry<String, V>> prefixSearch(String key)
    {
        Set<Map.Entry<String, V>> entrySet = new TreeSet<Map.Entry<String, V>>();
        StringBuilder sb = new StringBuilder(key.substring(0, key.length() - 1));
        BaseNode branch = this;
        char[] chars = key.toCharArray();
        for (char aChar : chars)
        {
            if (branch == null) return entrySet;
            branch = branch.getChild(aChar);
        }

        if (branch == null) return entrySet;
        branch.walk(sb, entrySet);
        return entrySet;
    }
961050
def Regions(self,
              skip_mapped_files=False,
              skip_shared_regions=False,
              skip_executable_regions=False,
              skip_readonly_regions=False):
    """"""
    try:
      maps_file = open("/proc/" + str(self.pid) + "/maps", "r")
    except OSError as e:
      raise process_error.ProcessError(e)

    with maps_file:
      for line in maps_file:
        m = self.maps_re.match(line)
        if not m:
          continue
        start = int(m.group(1), 16)
        end = int(m.group(2), 16)
        region_protec = m.group(3)
        inode = int(m.group(6))

        if "r" in region_protec:
          if skip_mapped_files and inode != 0:
            continue
          if skip_shared_regions and "s" in region_protec:
            continue
          if skip_executable_regions and "x" in region_protec:
            continue
          if skip_readonly_regions and "w" not in region_protec:
            continue
          yield start, end - start
1005286
def cluster_get_keys_in_slots(self, slot, count, *, encoding):
        """"""
        return self.execute(b'CLUSTER', b'GETKEYSINSLOT', slot, count,
                            encoding=encoding)
588249
public List<KeyRange> getLocalKeyPartition() throws BackendException {
        ensureKeyspaceExists(keySpaceName);

        @SuppressWarnings("rawtypes")
        Collection<Range<Token>> ranges = StorageService.instance.getPrimaryRanges(keySpaceName);

        List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());

        for (@SuppressWarnings("rawtypes") Range<Token> range : ranges) {
            keyRanges.add(CassandraHelper.transformRange(range));
        }

        return keyRanges;
    }
417097
def keys(self, prefix=None, delimiter=None):
        
        if delimiter:
            # WE REALLY DO NOT GET KEYS, BUT RATHER Prefix OBJECTS
            # AT LEAST THEY ARE UNIQUE
            candidates = [k.name.rstrip(delimiter) for k in self.bucket.list(prefix=prefix, delimiter=delimiter)]
        else:
            candidates = [strip_extension(k.key) for k in self.bucket.list(prefix=prefix)]

        if prefix == None:
            return set(c for c in candidates if c != "0.json")
        else:
            return set(k for k in candidates if k == prefix or k.startswith(prefix + ".") or k.startswith(prefix + ":"))