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


Java Connector.createScanner方法代码示例

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


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

示例1: SignedScanner

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
/**
 * Create an signed scanner.
 *
 * @param connector
 *          The connector for the Accumulo instance.
 * @param tableName
 *          Name of the table to write to.
 * @param authorizations
 *          The authorizations this user has for querying Accumulo.
 * @param signatureConfig
 *          Configuration for the verification.
 * @param keys
 *          Container with the keys to use for signatures.
 */
public SignedScanner(Connector connector, String tableName, Authorizations authorizations, SignatureConfig signatureConfig, SignatureKeyContainer keys)
    throws TableNotFoundException {
  checkArgument(connector != null, "connection is null");
  checkArgument(tableName != null, "tableName is null");
  checkArgument(authorizations != null, "authorizations is null");
  checkArgument(signatureConfig != null, "config is null");
  checkArgument(keys != null, "keys is null");

  this.valueScanner = connector.createScanner(tableName, authorizations);
  this.verifier = new EntrySigner(signatureConfig, keys);

  if (signatureConfig.destination == SignatureConfig.Destination.SEPARATE_TABLE) {
    this.signatureScanner = connector.createScanner(signatureConfig.destinationTable, authorizations);
  } else {
    this.signatureScanner = null;
  }
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:32,代码来源:SignedScanner.java

示例2: main

import org.apache.accumulo.core.client.Connector; //导入方法依赖的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

示例3: main

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  Opts opts = new Opts();
  ScannerOpts scanOpts = new ScannerOpts();
  BatchWriterOpts bwOpts = new BatchWriterOpts();
  opts.parseArgs(Reverse.class.getName(), args, scanOpts, bwOpts);

  Connector conn = opts.getConnector();

  Scanner scanner = conn.createScanner(opts.shardTable, opts.auths);
  scanner.setBatchSize(scanOpts.scanBatchSize);
  BatchWriter bw = conn.createBatchWriter(opts.doc2TermTable, bwOpts.getBatchWriterConfig());

  for (Entry<Key,Value> entry : scanner) {
    Key key = entry.getKey();
    Mutation m = new Mutation(key.getColumnQualifier());
    m.put(key.getColumnFamily(), new Text(), new Value(new byte[0]));
    bw.addMutation(m);
  }

  bw.close();

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

示例4: printAccumuloTable

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
/**
 * Prints specified Accumulo table (accessible using Accumulo connector parameter)
 *
 * @param conn Accumulo connector of to instance with table to print
 * @param accumuloTable Accumulo table to print
 */
public static void printAccumuloTable(Connector conn, String accumuloTable) {
  Scanner scanner = null;
  try {
    scanner = conn.createScanner(accumuloTable, Authorizations.EMPTY);
  } catch (TableNotFoundException e) {
    throw new IllegalStateException(e);
  }
  Iterator<Map.Entry<Key, Value>> iterator = scanner.iterator();

  System.out.println("== accumulo start ==");
  while (iterator.hasNext()) {
    Map.Entry<Key, Value> entry = iterator.next();
    System.out.println(entry.getKey() + " " + entry.getValue());
  }
  System.out.println("== accumulo end ==");
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:23,代码来源:FluoITHelper.java

示例5: getScanner

import org.apache.accumulo.core.client.Connector; //导入方法依赖的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

示例6: listResults

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
/**
 * Get an {@link Iterator} over the {@link BindingSet}s that are stored in the PCJ table.
 *
 * @param accumuloConn - A connection to the Accumulo that hsots the PCJ table. (not null)
 * @param pcjTableName - The name of the PCJ table that will be scanned. (not null)
 * @param auths - the user's authorizations that will be used to scan the table. (not null)
 * @return An iterator over all of the {@link BindingSet}s that are stored as
 *   results for the PCJ.
 * @throws PCJStorageException The binding sets could not be fetched.
 */
public CloseableIterator<BindingSet> listResults(final Connector accumuloConn, final String pcjTableName, final Authorizations auths) throws PCJStorageException {
    requireNonNull(pcjTableName);

    // Fetch the Variable Orders for the binding sets and choose one of them. It
    // doesn't matter which one we choose because they all result in the same output.
    final PcjMetadata metadata = getPcjMetadata(accumuloConn, pcjTableName);
    final VariableOrder varOrder = metadata.getVarOrders().iterator().next();

    try {
        // Fetch only the Binding Sets whose Variable Order matches the selected one.
        final Scanner scanner = accumuloConn.createScanner(pcjTableName, auths);
        scanner.fetchColumnFamily( new Text(varOrder.toString()) );

        // Return an Iterator that uses that scanner.
        return new ScannerBindingSetIterator(scanner, varOrder);

    } catch (final TableNotFoundException e) {
        throw new PCJStorageException(String.format("PCJ Table does not exist for name '%s'.", pcjTableName), e);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:31,代码来源:PcjTables.java

示例7: loadPcjResults

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
/**
 * Scan accumulo for the results that are stored in a PCJ table. The
 * multimap stores a set of deserialized binding sets that were in the PCJ
 * table for every variable order that is found in the PCJ metadata.
 */
private static Multimap<String, BindingSet> loadPcjResults(final Connector accumuloConn, final String pcjTableName) throws PcjException, TableNotFoundException, BindingSetConversionException {
    final Multimap<String, BindingSet> fetchedResults = HashMultimap.create();

    // Get the variable orders the data was written to.
    final PcjTables pcjs = new PcjTables();
    final PcjMetadata pcjMetadata = pcjs.getPcjMetadata(accumuloConn, pcjTableName);

    // Scan Accumulo for the stored results.
    for(final VariableOrder varOrder : pcjMetadata.getVarOrders()) {
        final Scanner scanner = accumuloConn.createScanner(pcjTableName, new Authorizations());
        scanner.fetchColumnFamily( new Text(varOrder.toString()) );

        for(final Entry<Key, Value> entry : scanner) {
            final byte[] serializedResult = entry.getKey().getRow().getBytes();
            final BindingSet result = converter.convert(serializedResult, varOrder);
            fetchedResults.put(varOrder.toString(), result);
        }
    }

    return fetchedResults;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:PcjTablesIT.java

示例8: main

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  Opts opts = new Opts();
  BatchWriterOpts bwOpts = new BatchWriterOpts();
  opts.parseArgs(InterferenceTest.class.getName(), args, bwOpts);

  if (opts.iterations < 1)
    opts.iterations = Long.MAX_VALUE;

  Connector conn = opts.getConnector();
  if (!conn.tableOperations().exists(opts.getTableName()))
    conn.tableOperations().create(opts.getTableName());

  Thread writer = new Thread(new Writer(conn.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig()), opts.iterations));
  writer.start();
  Reader r;
  if (opts.isolated)
    r = new Reader(new IsolatedScanner(conn.createScanner(opts.getTableName(), opts.auths)));
  else
    r = new Reader(conn.createScanner(opts.getTableName(), opts.auths));
  Thread reader;
  reader = new Thread(r);
  reader.start();
  writer.join();
  r.stopNow();
  reader.join();
  System.out.println("finished");
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:28,代码来源:InterferenceTest.java

示例9: getSplits

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
@Override
public List<InputSplit> getSplits(JobContext jobContext) throws IOException {
    //read the params from AccumuloInputFormat
    Configuration conf = jobContext.getConfiguration();
    Instance instance = MRUtils.AccumuloProps.getInstance(jobContext);
    String user = MRUtils.AccumuloProps.getUsername(jobContext);
    AuthenticationToken password = MRUtils.AccumuloProps.getPassword(jobContext);
    String table = MRUtils.AccumuloProps.getTablename(jobContext);
    ArgumentChecker.notNull(instance);
    ArgumentChecker.notNull(table);

    //find the files necessary
    try {
        Connector connector = instance.getConnector(user, password);
        TableOperations tos = connector.tableOperations();
        String tableId = tos.tableIdMap().get(table);
        Scanner scanner = connector.createScanner("accumulo.metadata", Authorizations.EMPTY); //TODO: auths?
        scanner.setRange(new Range(new Text(tableId + "\u0000"), new Text(tableId + "\uFFFD")));
        scanner.fetchColumnFamily(new Text("file"));
        List<String> files = new ArrayList<String>();
        List<InputSplit> fileSplits = new ArrayList<InputSplit>();
        for (Map.Entry<Key, Value> entry : scanner) {
            String file = entry.getKey().getColumnQualifier().toString();
            Path path = new Path(file);
            FileSystem fs = path.getFileSystem(conf);
            FileStatus fileStatus = fs.getFileStatus(path);
            long len = fileStatus.getLen();
            BlockLocation[] fileBlockLocations = fs.getFileBlockLocations(fileStatus, 0, len);
            files.add(file);
            fileSplits.add(new FileSplit(path, 0, len, fileBlockLocations[0].getHosts()));
        }
        System.out.println(files);
        return fileSplits;
    } catch (Exception e) {
        throw new IOException(e);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:38,代码来源:AccumuloHDFSFileInputFormat.java

示例10: createScanner

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
public static Scanner createScanner(final String tablename, final Configuration conf)
        throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    final Connector connector = ConfigUtils.getConnector(conf);
    final Authorizations auths = ConfigUtils.getAuthorizations(conf);
    return connector.createScanner(tablename, auths);

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:8,代码来源:ConfigUtils.java

示例11: startAccumulo

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
private void startAccumulo() throws Exception {
	LOG.info("Starting Accumulo");
    Process exec = Runtime.getRuntime().exec(new String[] {System.getProperty("ACCUMULO_HOME") + "/bin/start-all.sh"});
    exec.waitFor();
    LOG.info("Checking Accumulo status");
    //Check to see if Accumulo is up and running
    Connector con = this.getConnector();
    Scanner s = con.createScanner(MetadataTable.NAME, con.securityOperations().getUserAuthorizations(con.whoami()));
    for (Entry<Key,Value> kv : s) {
    	//iterate over all keys
    }
    LOG.info("Accumulo started.");
}
 
开发者ID:dlmarion,项目名称:raccovery,代码行数:14,代码来源:DatabaseRecoveryIT.java

示例12: checkTableData

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
protected static void checkTableData(Connector con, String tableName, Map<Key,Value> expectedData) throws Exception {
	Map<Key,Value> test = new TreeMap<Key,Value>();
	Scanner s = con.createScanner(tableName, Authorizations.EMPTY);
	for (Entry<Key,Value> kv : s) {
		test.put(kv.getKey(), kv.getValue());
	}
	Assert.assertEquals("number of table K/V entries do not match", expectedData.size(), test.size());
	Assert.assertEquals("K/V are not equal", expectedData, test);
}
 
开发者ID:dlmarion,项目名称:raccovery,代码行数:10,代码来源:FunctionalBase.java

示例13: main

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  Opts opts = new Opts();
  ScannerOpts scanOpts = new ScannerOpts();
  BatchWriterOpts batchOpts = new BatchWriterOpts();
  opts.parseArgs(SignedConverterExample.class.getName(), args, batchOpts, scanOpts);

  Connector conn = opts.getConnector();

  // add the authorizations to the user
  Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(opts.getPrincipal());
  ByteArraySet auths = new ByteArraySet(userAuthorizations.getAuthorizations());
  auths.addAll(opts.auths.getAuthorizations());
  if (!auths.isEmpty())
    conn.securityOperations().changeUserAuthorizations(opts.getPrincipal(), new Authorizations(auths));

  // create table
  if (opts.createDestinationTable) {
    conn.tableOperations().create(opts.destination);
  }

  // Transform entries
  Scanner scanner = conn.createScanner(opts.source, opts.auths);
  scanner.setBatchSize(scanOpts.scanBatchSize);

  BatchWriterConfig bwConfig = batchOpts.getBatchWriterConfig();
  bwConfig.setDurability(opts.durability);
  BatchWriter writer = new SignedBatchWriter(conn, opts.destination, bwConfig, opts.signatureConfig, opts.signatureKeys);

  long count = 0;
  for (Entry<Key,Value> entry : scanner) {
    Mutation mutation = new Mutation(entry.getKey().getRow());
    mutation.put(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier(), entry.getKey().getColumnVisibilityParsed(), entry.getKey()
        .getTimestamp(), entry.getValue());
    writer.addMutation(mutation);

    count++;
    if (count % 10000 == 0) {
      System.out.println(String.format("converted %d entries", count));
    }
  }

  writer.flush();
  writer.close();

  // delete table
  if (opts.deleteSourceTable)
    conn.tableOperations().delete(opts.source);
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:49,代码来源:SignedConverterExample.java

示例14: main

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  Opts opts = new Opts();
  ScannerOpts scanOpts = new ScannerOpts();
  BatchWriterOpts batchOpts = new BatchWriterOpts();
  opts.parseArgs(EncryptedConverterExample.class.getName(), args, batchOpts, scanOpts);

  Connector conn = opts.getConnector();

  // add the authorizations to the user
  Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(opts.getPrincipal());
  ByteArraySet auths = new ByteArraySet(userAuthorizations.getAuthorizations());
  auths.addAll(opts.auths.getAuthorizations());
  if (!auths.isEmpty())
    conn.securityOperations().changeUserAuthorizations(opts.getPrincipal(), new Authorizations(auths));

  // create table
  if (opts.createDestinationTable) {
    conn.tableOperations().create(opts.destination);
  }

  // Transform entries
  Scanner scanner = conn.createScanner(opts.source, opts.auths);
  scanner.setBatchSize(scanOpts.scanBatchSize);

  BatchWriterConfig bwConfig = batchOpts.getBatchWriterConfig();
  bwConfig.setDurability(opts.durability);
  BatchWriter writer = new EncryptedBatchWriter(conn, opts.destination, bwConfig, opts.encryptionConfig, opts.encryptionKeys);

  long count = 0;
  for (Entry<Key,Value> entry : scanner) {
    Mutation mutation = new Mutation(entry.getKey().getRow());
    mutation.put(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier(), entry.getKey().getColumnVisibilityParsed(), entry.getKey()
        .getTimestamp(), entry.getValue());
    writer.addMutation(mutation);

    count++;
    if (count % 10000 == 0) {
      System.out.println(String.format("converted %d entries", count));
    }
  }

  writer.flush();
  writer.close();

  // delete table
  if (opts.deleteSourceTable)
    conn.tableOperations().delete(opts.source);
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:49,代码来源:EncryptedConverterExample.java

示例15: FileDataQuery

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
public FileDataQuery(Connector conn, String tableName, Authorizations auths)
    throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
  lastRefs = new ArrayList<>();
  cis = new ChunkInputStream();
  scanner = conn.createScanner(tableName, auths);
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:7,代码来源:FileDataQuery.java


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