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


Java TableOperations类代码示例

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


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

示例1: createBatchWriter

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
/**
 * creates a batchwriter to write data to accumulo
 *
 * @param table to write data into
 * @return a ready to user batch writer object
 * @throws AccumuloSecurityException
 * @throws AccumuloException
 * @throws TableNotFoundException
 */
private BatchWriter createBatchWriter(String table) throws AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException {
    final BatchWriterConfig bwConfig = new BatchWriterConfig();
    // buffer max 100kb ( 100 * 1024 = 102400)
    bwConfig.setMaxMemory(102400);
    // buffer max 10 seconds
    bwConfig.setMaxLatency(10, TimeUnit.SECONDS);
    // ensure persistance
    bwConfig.setDurability(Durability.SYNC);

    // build the accumulo connector
    Instance inst = new ZooKeeperInstance(cfg.accumuloInstanceName, cfg.accumuloZookeeper);
    conn = inst.getConnector(cfg.accumuloUser, new PasswordToken(cfg.accumuloPassword));
    Authorizations auths = new Authorizations(AccumuloIdentifiers.AUTHORIZATION.toString());

    // create the table if not already existent
    TableOperations tableOpts = conn.tableOperations();
    try{
        tableOpts.create(table);
    } catch(Exception e) {}

    // build and return the batchwriter
    return conn.createBatchWriter(table, bwConfig);
}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:33,代码来源:LanguageFrequencySink.java

示例2: createBatchWriter

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
/**
 * creates a batchwriter to write data to accumulo
 *
 * @param table to write data into
 * @return a ready to user batch writer object
 * @throws AccumuloSecurityException
 * @throws AccumuloException
 * @throws TableNotFoundException
 */
private BatchWriter createBatchWriter(String table) throws AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException {
    final BatchWriterConfig bwConfig = new BatchWriterConfig();
    // buffer max 100kb ( 100 * 1024 = 102400)
    bwConfig.setMaxMemory(102400);
    // buffer max 10 seconds
    bwConfig.setMaxLatency(10, TimeUnit.SECONDS);
    // ensure persistance
    bwConfig.setDurability(Durability.SYNC);

    // build the accumulo connector
    Instance inst = new ZooKeeperInstance(cfg.accumuloInstanceName, cfg.accumuloZookeeper);
    conn = inst.getConnector(cfg.accumuloUser, new PasswordToken(cfg.accumuloPassword));
    Authorizations auths = new Authorizations(AccumuloIdentifiers.AUTHORIZATION.toString());
    

    // create the table if not already existent
    TableOperations tableOpts = conn.tableOperations();
    try{
        tableOpts.create(table);
    } catch(Exception e) {}

    // build and return the batchwriter
    return conn.createBatchWriter(table, bwConfig);
}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:34,代码来源:TermIndexSink.java

示例3: init

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
@Override
    public void init() throws RdfDAOException {
        try {
            if (isInitialized()) {
                throw new IllegalStateException("Already initialized");
            }
            checkNotNull(connector);
            tableLayoutStrategy = conf.getTableLayoutStrategy();
//            evalTable = conf.get(RdfCloudTripleStoreConfiguration.CONF_TBL_EVAL, evalTable);
//            conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_EVAL, evalTable);

            final TableOperations tos = connector.tableOperations();
            AccumuloRdfUtils.createTableIfNotExist(tos, tableLayoutStrategy.getEval());
//            boolean tableExists = tos.exists(evalTable);
//            if (!tableExists)
//                tos.create(evalTable);
            isInitialized.set(true);
        } catch (final Exception e) {
            throw new RdfDAOException(e);
        }
    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:AccumuloRdfEvalStatsDAO.java

示例4: setupSplitsFile

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
private void setupSplitsFile(final Job job, final TableOperations parentTableOperations, final String parentTableName, final String childTableName) throws Exception {
    final FileSystem fs = FileSystem.get(conf);
    fs.setPermission(getPath(baseOutputDir, childTableName), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
    final Path splitsPath = getPath(baseOutputDir, childTableName, "splits.txt");
    final Collection<Text> splits = parentTableOperations.listSplits(parentTableName, 100);
    log.info("Creating splits file at: " + splitsPath);
    try (PrintStream out = new PrintStream(new BufferedOutputStream(fs.create(splitsPath)), false, StandardCharsets.UTF_8.name())) {
        for (final Text split : splits) {
            final String encoded = new String(Base64.encodeBase64(TextUtil.getBytes(split)), StandardCharsets.UTF_8);
            out.println(encoded);
        }
    }
    fs.setPermission(splitsPath, new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));

    final String userDir = PathUtils.clean(System.getProperty("user.dir"));
    // The splits file has a symlink created in the user directory for some reason.
    // It might be better to copy the entire file for Windows but it doesn't seem to matter if
    // the user directory symlink is broken.
    java.nio.file.Files.deleteIfExists(new File(userDir, "splits.txt").toPath());
    //Files.copy(new File(splitsPath.toString()), new File(userDir, "splits.txt"));
    job.setPartitionerClass(KeyRangePartitioner.class);
    KeyRangePartitioner.setSplitFile(job, splitsPath.toString());
    job.setNumReduceTasks(splits.size() + 1);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:CopyTool.java

示例5: exists

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
@Override
public boolean exists(final String instanceName) throws RyaClientException {
    requireNonNull( instanceName );

    final TableOperations tableOps = getConnector().tableOperations();

    // Newer versions of Rya will have a Rya Details table.
    final String ryaDetailsTableName = instanceName + AccumuloRyaInstanceDetailsRepository.INSTANCE_DETAILS_TABLE_NAME;
    if(tableOps.exists(ryaDetailsTableName)) {
        return true;
    }

    // However, older versions only have the data tables.
    final String spoTableName = instanceName + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX;
    final String posTableName = instanceName + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX;
    final String ospTableName = instanceName + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX;
    if(tableOps.exists(spoTableName) && tableOps.exists(posTableName) && tableOps.exists(ospTableName)) {
        return true;
    }

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

示例6: exists_ryaDetailsTable

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
@Test
public void exists_ryaDetailsTable() throws AccumuloException, AccumuloSecurityException, RyaClientException, TableExistsException {
    final Connector connector = getConnector();
    final TableOperations tableOps = connector.tableOperations();

    // Create the Rya instance's Rya details table.
    final String instanceName = "test_instance_";
    final String ryaDetailsTable = instanceName + AccumuloRyaInstanceDetailsRepository.INSTANCE_DETAILS_TABLE_NAME;
    tableOps.create(ryaDetailsTable);

    // Verify the command reports the instance exists.
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(
            getUsername(),
            getPassword().toCharArray(),
            getInstanceName(),
            getZookeepers());

    final AccumuloInstanceExists instanceExists = new AccumuloInstanceExists(connectionDetails, getConnector());
    assertTrue( instanceExists.exists(instanceName) );
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:AccumuloInstanceExistsIT.java

示例7: exists_dataTables

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
@Test
public void exists_dataTables() throws AccumuloException, AccumuloSecurityException, RyaClientException, TableExistsException {
    final Connector connector = getConnector();
    final TableOperations tableOps = connector.tableOperations();

    // Create the Rya instance's Rya details table.
    final String instanceName = "test_instance_";

    final String spoTableName = instanceName + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX;
    final String ospTableName = instanceName + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX;
    final String poTableName = instanceName + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX;
    tableOps.create(spoTableName);
    tableOps.create(ospTableName);
    tableOps.create(poTableName);

    // Verify the command reports the instance exists.
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(
            getUsername(),
            getPassword().toCharArray(),
            getInstanceName(),
            getZookeepers());

    final AccumuloInstanceExists instanceExists = new AccumuloInstanceExists(connectionDetails, getConnector());
    assertTrue( instanceExists.exists(instanceName) );
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:AccumuloInstanceExistsIT.java

示例8: getDetails_instanceDoesNotHaveDetails

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
@Test
public void getDetails_instanceDoesNotHaveDetails() throws AccumuloException, AccumuloSecurityException, InstanceDoesNotExistException, RyaClientException, TableExistsException {
    // Mimic a pre-details rya install.
    final TableOperations tableOps = getConnector().tableOperations();

    final String spoTableName = getRyaInstanceName() + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX;
    final String ospTableName = getRyaInstanceName() + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX;
    final String poTableName = getRyaInstanceName() + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX;
    tableOps.create(spoTableName);
    tableOps.create(ospTableName);
    tableOps.create(poTableName);

    // Verify that the operation returns empty.
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(
            getUsername(),
            getPassword().toCharArray(),
            getInstanceName(),
            getZookeepers());

    final GetInstanceDetails getInstanceDetails = new AccumuloGetInstanceDetails(connectionDetails, getConnector());
    final Optional<RyaDetails> details = getInstanceDetails.getDetails(getRyaInstanceName());
    assertFalse( details.isPresent() );
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:AccumuloGetInstanceDetailsIT.java

示例9: printTables

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
public static void printTables(Configuration conf) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    TableOperations tops = ConfigUtils.getConnector(conf).tableOperations();

    // print tables
    String FORMAT = "%-20s  %-20s  %-40s  %-40s\n";
    for (String table : tops.list()) {
        System.out.println("Reading : " + table);
        System.out.format(FORMAT, "--Row--", "--ColumnFamily--", "--ColumnQualifier--", "--Value--");
        Scanner s = ConfigUtils.getConnector(conf).createScanner(table, Authorizations.EMPTY);
        for (Entry<Key, org.apache.accumulo.core.data.Value> entry : s) {
            Key k = entry.getKey();
            System.out.format(FORMAT, k.getRow(), k.getColumnFamily(), k.getColumnQualifier(), entry.getValue());
        }
        System.out.println();
    }

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

示例10: init

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
@Override
public void init() throws RdfDAOException {
  try {
    if (isInitialized()) {
      throw new IllegalStateException("Already initialized");
    }
    if (!resd.isInitialized()) {
      resd.init();
    }
    checkNotNull(connector);
    tableLayoutStrategy = conf.getTableLayoutStrategy();
    TableOperations tos = connector.tableOperations();
    AccumuloRdfUtils.createTableIfNotExist(tos, tableLayoutStrategy.getSelectivity());
    AccumuloRdfUtils.createTableIfNotExist(tos, tableLayoutStrategy.getProspects());
    initialized = true;
  } catch (Exception e) {
    throw new RdfDAOException(e);
  }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:20,代码来源:AccumuloSelectivityEvalDAO.java

示例11: ProspectorService

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
/**
 * Constructs an instance of {@link ProspectorService}.
 *
 * @param connector - The Accumulo connector used to communicate with the table. (not null)
 * @param tableName - The name of the Accumulo table that will be queried for Prospect results. (not null)
 * @throws AccumuloException A problem occurred while creating the table.
 * @throws AccumuloSecurityException A problem occurred while creating the table.
 */
public ProspectorService(Connector connector, String tableName) throws AccumuloException, AccumuloSecurityException {
    this.connector = requireNonNull(connector);
    this.tableName = requireNonNull(tableName);

    this.plans = ProspectorUtils.planMap(manager.getPlans());

    // Create the table if it doesn't already exist.
    try {
        final TableOperations tos = connector.tableOperations();
        if(!tos.exists(tableName)) {
            tos.create(tableName);
        }
    } catch(TableExistsException e) {
        // Do nothing. Something else must have made it while we were.
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:ProspectorService.java

示例12: testInitialize

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
@Test
public void testInitialize() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {

    AccumuloSelectivityEvalDAO accc = new AccumuloSelectivityEvalDAO();
    accc.setConf(arc);
    accc.setConnector(conn);
    accc.setRdfEvalDAO(res);
    accc.init();

    TableOperations tos = conn.tableOperations();
    Assert.assertTrue(tos.exists("rya_prospects") && tos.exists("rya_selectivity"));
    Assert.assertTrue(accc.isInitialized());
    Assert.assertTrue(accc.getConf().equals(arc));
    Assert.assertTrue(accc.getConnector().equals(conn));
    Assert.assertTrue(accc.getRdfEvalDAO().equals(res));

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

示例13: testCreateExistingTable

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
@Test
public void testCreateExistingTable() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
  TableOperations tops = connector.tableOperations();
  try {
    Assert.assertFalse(tops.exists(table));
    tops.create(table);
    Assert.assertTrue(tops.exists(table));

    try {
      tops.create(table);
      Assert.fail("Expected second table create to fail.");
    } catch (TableExistsException tee) {
      // expected
      Assert.assertTrue(true);
    }
  } finally {
    if (tops.exists(table)) {
      tops.delete(table);
    }
    Assert.assertFalse(tops.exists(table));
  }
}
 
开发者ID:JHUAPL,项目名称:accumulo-proxy-instance,代码行数:23,代码来源:TableOpsTest.java

示例14: optimizeIndices

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
/**
 * Given some {@link Index}s, we can assign locality groups to make queries over those columns more efficient, especially for operations like groupBy.
 * 
 * @param indices
 * @throws AccumuloSecurityException
 * @throws TableNotFoundException
 * @throws AccumuloException
 */
public void optimizeIndices(Iterable<Index> indices) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
  Preconditions.checkNotNull(indices);
  
  final TableOperations tops = connector().tableOperations();
  
  Map<String,Set<Text>> locGroups = tops.getLocalityGroups(dataTable());
  int size = locGroups.size();
  
  // Take the set of indicies that were requested to be "optimized" (read as locality group'ed)
  for (Index i : indices) {
    String colf = i.column().name();
    // And update our mapping accordingly
    if (!locGroups.containsKey(colf)) {
      locGroups.put(colf, Sets.newHashSet(new Text(colf)));
    }
  }
  
  // If we've actually added some locality groups, set them back on the table
  if (size != locGroups.size()) {
    log.debug("Setting {} new locality groups", locGroups.size() - size);
    tops.setLocalityGroups(dataTable(), locGroups);
  } else {
    log.debug("No new locality groups to set");
  }
}
 
开发者ID:joshelser,项目名称:cosmos,代码行数:34,代码来源:Store.java

示例15: createTables

import org.apache.accumulo.core.client.admin.TableOperations; //导入依赖的package包/类
private void createTables(Connector connector) throws AccumuloException, AccumuloSecurityException {
    TableOperations tops = connector.tableOperations();

    try {
        if (!tops.exists(table)) {
            tops.create(table);
        }

        if (!tops.exists(indexTable)) {
            tops.create(indexTable);
        }
    } catch (TableExistsException e) {
        // shouldn't happen as we check for table existence prior to each create() call
        throw new AccumuloException(e);
    }
}
 
开发者ID:tequalsme,项目名称:accumulo-starter,代码行数:17,代码来源:MessageWriter.java


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