当前位置: 首页>>代码示例>>Java>>正文


Java Scanner.setRange方法代码示例

本文整理汇总了Java中org.apache.accumulo.core.client.Scanner.setRange方法的典型用法代码示例。如果您正苦于以下问题:Java Scanner.setRange方法的具体用法?Java Scanner.setRange怎么用?Java Scanner.setRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.accumulo.core.client.Scanner的用法示例。


在下文中一共展示了Scanner.setRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        try (ConfigurableApplicationContext ctx = new SpringApplicationBuilder(SpringBootstrap.class)
                .bannerMode(Mode.OFF).web(false).run(args)) {
            Configuration conf = ctx.getBean(Configuration.class);

            final BaseConfiguration apacheConf = new BaseConfiguration();
            Configuration.Accumulo accumuloConf = conf.getAccumulo();
            apacheConf.setProperty("instance.name", accumuloConf.getInstanceName());
            apacheConf.setProperty("instance.zookeeper.host", accumuloConf.getZookeepers());
            final ClientConfiguration aconf = new ClientConfiguration(Collections.singletonList(apacheConf));
            final Instance instance = new ZooKeeperInstance(aconf);
            Connector con = instance.getConnector(accumuloConf.getUsername(),
                    new PasswordToken(accumuloConf.getPassword()));
            Scanner s = con.createScanner(conf.getMetaTable(),
                    con.securityOperations().getUserAuthorizations(con.whoami()));
            try {
                s.setRange(new Range(Meta.METRIC_PREFIX, true, Meta.TAG_PREFIX, false));
                for (Entry<Key, Value> e : s) {
                    System.out.println(e.getKey().getRow().toString().substring(Meta.METRIC_PREFIX.length()));
                }
            } finally {
                s.close();
            }
        }
    }
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:27,代码来源:GetMetricTableSplitPoints.java

示例2: createScanner

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
private Scanner createScanner(Query<K,T> query) throws TableNotFoundException {
  // TODO make isolated scanner optional?
  Scanner scanner = new IsolatedScanner(conn.createScanner(mapping.tableName, Constants.NO_AUTHS));
  setFetchColumns(scanner, query.getFields());

  scanner.setRange(createRange(query));

  if (query.getStartTime() != -1 || query.getEndTime() != -1) {
    IteratorSetting is = new IteratorSetting(30, TimestampFilter.class);
    if (query.getStartTime() != -1)
      TimestampFilter.setStart(is, query.getStartTime(), true);
    if (query.getEndTime() != -1)
      TimestampFilter.setEnd(is, query.getEndTime(), true);

    scanner.addScanIterator(is);
  }

  return scanner;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:20,代码来源:AccumuloStore.java

示例3: findMaxDepth

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
private int findMaxDepth(Scanner scanner, int min, int mid, int max) {
  // check to see if the mid point exist
  if (max < min)
    return -1;

  scanner.setRange(new Range(String.format("%03d", mid), true, String.format("%03d", mid + 1), false));

  if (scanner.iterator().hasNext()) {
    // this depth exist, check to see if a larger depth exist
    int ret = findMaxDepth(scanner, mid + 1, max);
    if (ret == -1)
      return mid; // this must the max
    else
      return ret;
  } else {
    // this depth does not exist, look lower
    return findMaxDepth(scanner, min, mid - 1);
  }

}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:21,代码来源:FileCount.java

示例4: getDirList

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Uses the directory table to list the contents of a directory.
 *
 * @param path
 *          the full path of a directory
 */
public Map<String,Map<String,String>> getDirList(String path) throws TableNotFoundException {
  if (!path.endsWith("/"))
    path = path + "/";
  Map<String,Map<String,String>> fim = new TreeMap<>();
  Scanner scanner = conn.createScanner(tableName, auths);
  scanner.setRange(Range.prefix(getRow(path)));
  for (Entry<Key,Value> e : scanner) {
    String name = e.getKey().getRow().toString();
    name = name.substring(name.lastIndexOf("/") + 1);
    String type = getType(e.getKey().getColumnFamily());
    if (!fim.containsKey(name)) {
      fim.put(name, new TreeMap<String,String>());
      fim.get(name).put("fullname", e.getKey().getRow().toString().substring(3));
    }
    fim.get(name).put(type + e.getKey().getColumnQualifier().toString() + ":" + e.getKey().getColumnVisibility().toString(), new String(e.getValue().get()));
  }
  return fim;
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:25,代码来源:QueryUtil.java

示例5: singleRestrictedWildCardSearch

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Scans over the index table for files or directories with a given name, prefix, or suffix (indicated by a wildcard '*' at the beginning or end of the term.
 *
 * @param exp
 *          the name a file or directory to search for with an optional wildcard '*' at the beginning or end
 */
public Iterable<Entry<Key,Value>> singleRestrictedWildCardSearch(String exp) throws Exception {
  if (exp.indexOf("/") >= 0)
    throw new Exception("this method only works with unqualified names");

  Scanner scanner = conn.createScanner(tableName, auths);
  if (exp.startsWith("*")) {
    System.out.println("executing beginning wildcard search for " + exp);
    exp = exp.substring(1);
    scanner.setRange(Range.prefix(getReverseIndex(exp)));
  } else if (exp.endsWith("*")) {
    System.out.println("executing ending wildcard search for " + exp);
    exp = exp.substring(0, exp.length() - 1);
    scanner.setRange(Range.prefix(getForwardIndex(exp)));
  } else if (exp.indexOf("*") >= 0) {
    throw new Exception("this method only works for beginning or ending wild cards");
  } else {
    return exactTermSearch(exp);
  }
  return scanner;
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:27,代码来源:QueryUtil.java

示例6: getCommittedWindowId

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Override
public long getCommittedWindowId(String appId, int operatorId)
{
  byte[] value = null;
  Authorizations auths = new Authorizations();
  Scanner scan = null;
  String columnKey = appId + "_" + operatorId + "_" + lastWindowColumnName;
  lastWindowColumnBytes = columnKey.getBytes();
  try {
    scan = connector.createScanner(tableName, auths);
  } catch (TableNotFoundException e) {
    logger.error("error getting committed window id", e);
    DTThrowable.rethrow(e);
  }
  scan.setRange(new Range(new Text(rowBytes)));
  scan.fetchColumn(new Text(columnFamilyBytes), new Text(lastWindowColumnBytes));
  for (Entry<Key, Value> entry : scan) {
    value = entry.getValue().get();
  }
  if (value != null) {
    long longval = toLong(value);
    return longval;
  }
  return -1;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:26,代码来源:AccumuloWindowStore.java

示例7: getScanner

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Override
public Scanner getScanner(Connector conn)
{
  Authorizations auths = new Authorizations();
  Scanner scan = null;
  try {
    scan = conn.createScanner(getStore().getTableName(), auths);
  } catch (TableNotFoundException e) {
    logger.error("table not found ");
    DTThrowable.rethrow(e);
  }
  scan.setRange(new Range());
  // scan.fetchColumnFamily("attributes");

  return scan;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:AccumuloInputOperatorTest.java

示例8: getAccumuloTuple

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public static AccumuloTuple getAccumuloTuple(String row, String colFam,
    String colName)
{
  Authorizations auths = new Authorizations();

  Scanner scan = null;
  try {
    scan = con.createScanner("tab1", auths);
  } catch (TableNotFoundException e) {
    logger.error("error in test helper");
    DTThrowable.rethrow(e);
  }

  scan.setRange(new Range(new Text(row)));
  scan.fetchColumn(new Text(colFam), new Text(colName));
  // assuming only one row
  for (Entry<Key, Value> entry : scan) {
    AccumuloTuple tuple = new AccumuloTuple();
    tuple.setRow(entry.getKey().getRow().toString());
    tuple.setColFamily(entry.getKey().getColumnFamily().toString());
    tuple.setColName(entry.getKey().getColumnQualifier().toString());
    tuple.setColValue(entry.getValue().toString());
    return tuple;
  }
  return null;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:27,代码来源:AccumuloTestHelper.java

示例9: getNamespace

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Override
public String getNamespace(final String pfx) throws RyaDAOException {
    try {
        final Scanner scanner = connector.createScanner(tableLayoutStrategy.getNs(),
                ALL_AUTHORIZATIONS);
        scanner.fetchColumn(INFO_NAMESPACE_TXT, EMPTY_TEXT);
        scanner.setRange(new Range(new Text(pfx)));
        final Iterator<Map.Entry<Key, Value>> iterator = scanner
                .iterator();

        if (iterator.hasNext()) {
            return new String(iterator.next().getValue().get(), StandardCharsets.UTF_8);
        }
    } catch (final Exception e) {
        throw new RyaDAOException(e);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:19,代码来源:AccumuloRyaDAO.java

示例10: getDomainStats

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public DomainStats getDomainStats(String domain) {
  DomainStats stats = new DomainStats(domain);
  Scanner scanner;
  try {
    scanner = conn.createScanner(accumuloIndexTable, Authorizations.EMPTY);
    scanner.setRange(Range.exact("d:" + URL.reverseHost(domain), Constants.DOMAIN));
    for (Map.Entry<Key, Value> entry : scanner) {
      switch (entry.getKey().getColumnQualifier().toString()) {
        case Constants.PAGECOUNT:
          stats.setTotal(getLongValue(entry));
          break;
        default:
          log.error("Unknown page domain {}", entry.getKey().getColumnQualifier());
      }
    }
  } catch (TableNotFoundException e) {
    e.printStackTrace();
  }
  return stats;
}
 
开发者ID:astralway,项目名称:webindex,代码行数:21,代码来源:IndexClient.java

示例11: queryIntervalBefore

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * find intervals stored in the repository before the given Interval. Find interval endings that are
 * before the given beginning.
 * Indexing Intervals  will probably change or be removed.
 * Currently predicate and subject constraints are filtered on the client.
 */
@Override
public CloseableIteration<Statement, QueryEvaluationException> queryIntervalBefore(
        final TemporalInterval queryInterval, final StatementConstraints constraints) throws QueryEvaluationException
{
    final Scanner scanner = getScanner();
    if (scanner != null) {
        // get rows where the end date is less than the queryInterval.getBefore()
        final Range range = new Range(null, false, new Key(new Text(queryInterval.getHasBeginning().getAsKeyBytes())), false);
        scanner.setRange(range);
         if (constraints.hasContext()) {
            scanner.fetchColumn(new Text(constraints.getContext().toString()), new Text(KeyParts.CQ_END));
        } else {
            scanner.fetchColumn(new Text(""), new Text(KeyParts.CQ_END));
        }
    }
    return getIteratorWrapper(scanner);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:AccumuloTemporalIndexer.java

示例12: queryIntervalAfter

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Interval after given interval.  Find intervals that begin after the endings of the given interval.
 * Use the special following prefix mechanism to avoid matching the beginning date.
 * Indexing Intervals  will probably change or be removed.
 * Currently predicate and subject and context constraints are filtered on the client.
 */
@Override
public CloseableIteration<Statement, QueryEvaluationException> queryIntervalAfter(
        final TemporalInterval queryInterval, final StatementConstraints constraints)
        throws QueryEvaluationException {

    final Scanner scanner = getScanner();
    if (scanner != null) {
        // get rows where the start date is greater than the queryInterval.getEnd()
        final Range range = new Range(new Key(Range.followingPrefix(new Text(queryInterval.getHasEnd().getAsKeyBytes()))), false, null, true);
        scanner.setRange(range);

        if (constraints.hasContext()) {
            scanner.fetchColumn(new Text(constraints.getContext().toString()), new Text(KeyParts.CQ_BEGIN));
        } else {
            scanner.fetchColumn(new Text(""), new Text(KeyParts.CQ_BEGIN));
        }
    }
    // TODO currently predicate, subject and context constraints are filtered on the clients
    return getIteratorWrapper(scanner);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:AccumuloTemporalIndexer.java

示例13: getData

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Scans over the directory table and pulls out stat information about a path.
 *
 * @param path
 *          the full path of a file or directory
 */
public Map<String,String> getData(String path) throws TableNotFoundException {
  if (path.endsWith("/"))
    path = path.substring(0, path.length() - 1);
  Scanner scanner = conn.createScanner(tableName, auths);
  scanner.setRange(new Range(getRow(path)));
  Map<String,String> data = new TreeMap<>();
  for (Entry<Key,Value> e : scanner) {
    String type = getType(e.getKey().getColumnFamily());
    data.put("fullname", e.getKey().getRow().toString().substring(3));
    data.put(type + e.getKey().getColumnQualifier().toString() + ":" + e.getKey().getColumnVisibility().toString(), new String(e.getValue().get()));
  }
  return data;
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:20,代码来源:QueryUtil.java

示例14: exactTermSearch

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Scans over the index table for files or directories with a given name.
 *
 * @param term
 *          the name a file or directory to search for
 */
public Iterable<Entry<Key,Value>> exactTermSearch(String term) throws Exception {
  System.out.println("executing exactTermSearch for " + term);
  Scanner scanner = conn.createScanner(tableName, auths);
  scanner.setRange(new Range(getForwardIndex(term)));
  return scanner;
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:13,代码来源:QueryUtil.java

示例15: singleWildCardSearch

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Scans over the index table for files or directories with a given name that can contain a single wildcard '*' anywhere in the term.
 *
 * @param exp
 *          the name a file or directory to search for with one optional wildcard '*'
 */
public Iterable<Entry<Key,Value>> singleWildCardSearch(String exp) throws Exception {
  int starIndex = exp.indexOf("*");
  if (exp.indexOf("*", starIndex + 1) >= 0)
    throw new Exception("only one wild card for search");

  if (starIndex < 0) {
    return exactTermSearch(exp);
  } else if (starIndex == 0 || starIndex == exp.length() - 1) {
    return singleRestrictedWildCardSearch(exp);
  }

  String firstPart = exp.substring(0, starIndex);
  String lastPart = exp.substring(starIndex + 1);
  String regexString = ".*/" + exp.replace("*", "[^/]*");

  Scanner scanner = conn.createScanner(tableName, auths);
  if (firstPart.length() >= lastPart.length()) {
    System.out.println("executing middle wildcard search for " + regexString + " from entries starting with " + firstPart);
    scanner.setRange(Range.prefix(getForwardIndex(firstPart)));
  } else {
    System.out.println("executing middle wildcard search for " + regexString + " from entries ending with " + lastPart);
    scanner.setRange(Range.prefix(getReverseIndex(lastPart)));
  }
  IteratorSetting regex = new IteratorSetting(50, "regex", RegExFilter.class);
  RegExFilter.setRegexs(regex, null, null, regexString, null, false);
  scanner.addScanIterator(regex);
  return scanner;
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:35,代码来源:QueryUtil.java


注:本文中的org.apache.accumulo.core.client.Scanner.setRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。