Here are the examples of the java api class org.apache.accumulo.core.client.admin.TableOperations taken from open source projects.
1. AccumuloFreeTextIndexerTest#printTables()
Project: incubator-rya
File: AccumuloFreeTextIndexerTest.java
File: AccumuloFreeTextIndexerTest.java
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(); } }
2. AccumuloTestHelper#deleteTable()
Project: apex-malhar
File: AccumuloTestHelper.java
File: AccumuloTestHelper.java
public static void deleteTable() { TableOperations tableoper = con.tableOperations(); if (tableoper.exists("tab1")) { try { tableoper.delete("tab1"); } catch (AccumuloException e) { logger.error("error in test helper"); DTThrowable.rethrow(e); } catch (AccumuloSecurityException e) { logger.error("error in test helper"); DTThrowable.rethrow(e); } catch (TableNotFoundException e) { logger.error("error in test helper"); DTThrowable.rethrow(e); } } }
3. GeoIndexerTest#before()
Project: incubator-rya
File: GeoIndexerTest.java
File: GeoIndexerTest.java
@Before public void before() throws Exception { System.out.println(UUID.randomUUID().toString()); String tableName = "triplestore_geospacial"; conf = new Configuration(); conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true); conf.set(ConfigUtils.CLOUDBASE_USER, "USERNAME"); conf.set(ConfigUtils.CLOUDBASE_PASSWORD, "PASS"); conf.set(ConfigUtils.GEO_TABLENAME, tableName); conf.set(ConfigUtils.CLOUDBASE_AUTHS, "U"); TableOperations tops = ConfigUtils.getConnector(conf).tableOperations(); // get all of the table names with the prefix Set<String> toDel = Sets.newHashSet(); for (String t : tops.list()) { if (t.startsWith(tableName)) { toDel.add(t); } } for (String t : toDel) { tops.delete(t); } }
4. AccumuloTestHelper#clearTable()
Project: apex-malhar
File: AccumuloTestHelper.java
File: AccumuloTestHelper.java
public static void clearTable() { TableOperations tableoper = con.tableOperations(); if (!tableoper.exists("tab1")) { try { tableoper.create("tab1"); } catch (Exception e) { logger.error("error in test helper"); DTThrowable.rethrow(e); } } try { tableoper.deleteRows("tab1", null, null); } catch (AccumuloException e) { logger.error("error in test helper"); DTThrowable.rethrow(e); } catch (AccumuloSecurityException e) { logger.error("error in test helper"); DTThrowable.rethrow(e); } catch (TableNotFoundException e) { logger.error("error in test helper"); DTThrowable.rethrow(e); } }
5. AccumuloTestHelper#createTable()
Project: apex-malhar
File: AccumuloTestHelper.java
File: AccumuloTestHelper.java
public static void createTable() { TableOperations tableoper = con.tableOperations(); if (!tableoper.exists("tab1")) { try { tableoper.create("tab1"); } catch (Exception e) { logger.error("error in test helper"); DTThrowable.rethrow(e); } } }
6. AccumuloSelectivityEvalDAOTest#testInitialize()
Project: incubator-rya
File: AccumuloSelectivityEvalDAOTest.java
File: AccumuloSelectivityEvalDAOTest.java
@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)); }
7. AccumuloTemporalIndexerTest#createTable()
Project: incubator-rya
File: AccumuloTemporalIndexerTest.java
File: AccumuloTemporalIndexerTest.java
/** * Create a table for test after deleting it. */ private static void createTable(Configuration conf, String tablename) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException { TableOperations tableOps = ConfigUtils.getConnector(conf).tableOperations(); if (tableOps.exists(tablename)) { tableOps.delete(tablename); } tableOps.create(tablename); }
8. AccumuloFreeTextIndexerTest#createTable()
Project: incubator-rya
File: AccumuloFreeTextIndexerTest.java
File: AccumuloFreeTextIndexerTest.java
private static void createTable(Configuration conf, String tablename) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException { TableOperations tableOps = ConfigUtils.getConnector(conf).tableOperations(); if (tableOps.exists(tablename)) { tableOps.delete(tablename); } tableOps.create(tablename); }
9. GeoIndexerSfTest#before()
Project: incubator-rya
File: GeoIndexerSfTest.java
File: GeoIndexerSfTest.java
@Before public void before() throws Exception { System.out.println(UUID.randomUUID().toString()); String tableName = "triplestore_geospacial"; conf = new Configuration(); conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true); conf.set(ConfigUtils.CLOUDBASE_USER, "USERNAME"); conf.set(ConfigUtils.CLOUDBASE_PASSWORD, "PASS"); conf.set(ConfigUtils.GEO_TABLENAME, tableName); conf.set(ConfigUtils.CLOUDBASE_AUTHS, "U"); TableOperations tops = ConfigUtils.getConnector(conf).tableOperations(); // get all of the table names with the prefix Set<String> toDel = Sets.newHashSet(); for (String t : tops.list()) { if (t.startsWith(tableName)) { toDel.add(t); } } for (String t : toDel) { tops.delete(t); } g = new GeoMesaGeoIndexer(); g.setConf(conf); g.storeStatement(statement(A)); g.storeStatement(statement(B)); g.storeStatement(statement(C)); g.storeStatement(statement(D)); g.storeStatement(statement(F)); g.storeStatement(statement(E)); }
10. AccumuloTemporalIndexerTest#tearDown()
Project: incubator-rya
File: AccumuloTemporalIndexerTest.java
File: AccumuloTemporalIndexerTest.java
/** * @throws java.lang.Exception */ @After public void tearDown() throws Exception { tIndexer.close(); TableOperations tableOps = ConfigUtils.getConnector(conf).tableOperations(); if (tableOps.exists(uniquePerTestTemporalIndexTableName)) tableOps.delete(uniquePerTestTemporalIndexTableName); }
11. AccumuloFreeTextIndexer#init()
Project: incubator-rya
File: AccumuloFreeTextIndexer.java
File: AccumuloFreeTextIndexer.java
private void init() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException { String doctable = ConfigUtils.getFreeTextDocTablename(conf); String termtable = ConfigUtils.getFreeTextTermTablename(conf); docTableNumPartitions = ConfigUtils.getFreeTextDocNumPartitions(conf); int termTableNumPartitions = ConfigUtils.getFreeTextTermNumPartitions(conf); TableOperations tableOps = ConfigUtils.getConnector(conf).tableOperations(); // Create term table partitions boolean createdTermTable = ConfigUtils.createTableIfNotExists(conf, termtable); if (createdTermTable && !ConfigUtils.useMockInstance(conf) && termTableNumPartitions > 0) { TreeSet<Text> splits = new TreeSet<Text>(); // split on the "Term List" and "Reverse Term list" boundary splits.add(new Text(ColumnPrefixes.getRevTermListColFam(""))); // Symmetrically split the "Term List" and "Reverse Term list" int numSubpartitions = ((termTableNumPartitions - 1) / 2); if (numSubpartitions > 0) { int step = (26 / numSubpartitions); for (int i = 0; i < numSubpartitions; i++) { String nextChar = String.valueOf((char) ('a' + (step * i))); splits.add(new Text(ColumnPrefixes.getTermListColFam(nextChar))); splits.add(new Text(ColumnPrefixes.getRevTermListColFam(nextChar))); } } tableOps.addSplits(termtable, splits); } // Create document (text) table partitions boolean createdDocTable = ConfigUtils.createTableIfNotExists(conf, doctable); if (createdDocTable && !ConfigUtils.useMockInstance(conf)) { TreeSet<Text> splits = new TreeSet<Text>(); for (int i = 0; i < docTableNumPartitions; i++) { splits.add(genPartition(i, docTableNumPartitions)); } tableOps.addSplits(doctable, splits); // Add a tablet level Bloom filter for the Column Family. // This will allow us to quickly determine if a term is contained in a tablet. tableOps.setProperty(doctable, "table.bloom.key.functor", ColumnFamilyFunctor.class.getCanonicalName()); tableOps.setProperty(doctable, "table.bloom.enabled", Boolean.TRUE.toString()); } mtbw = ConfigUtils.createMultitableBatchWriter(conf); docTableBw = mtbw.getBatchWriter(doctable); termTableBw = mtbw.getBatchWriter(termtable); tokenizer = ConfigUtils.getFreeTextTokenizer(conf); validPredicates = ConfigUtils.getFreeTextPredicates(conf); queryTermLimit = ConfigUtils.getFreeTextTermLimit(conf); }
12. ConfigUtils#createTableIfNotExists()
Project: incubator-rya
File: ConfigUtils.java
File: ConfigUtils.java
/** * @param conf * @param tablename * @return if the table was created * @throws AccumuloException * @throws AccumuloSecurityException * @throws TableExistsException */ public static boolean createTableIfNotExists(Configuration conf, String tablename) throws AccumuloException, AccumuloSecurityException, TableExistsException { TableOperations tops = getConnector(conf).tableOperations(); if (!tops.exists(tablename)) { logger.info("Creating table: " + tablename); tops.create(tablename); return true; } return false; }
13. TestAccumuloPigCluster#loadTestData()
Project: pig
File: TestAccumuloPigCluster.java
File: TestAccumuloPigCluster.java
private void loadTestData() throws Exception { ZooKeeperInstance inst = new ZooKeeperInstance(accumuloCluster.getInstanceName(), accumuloCluster.getZooKeepers()); Connector c = inst.getConnector("root", new PasswordToken("password")); TableOperations tops = c.tableOperations(); if (!tops.exists("airports")) { tops.create("airports"); } if (!tops.exists("flights")) { tops.create("flights"); } BatchWriterConfig config = new BatchWriterConfig(); config.setMaxWriteThreads(1); config.setMaxLatency(100000l, TimeUnit.MILLISECONDS); config.setMaxMemory(10000l); BatchWriter bw = c.createBatchWriter("airports", config); try { int i = 1; for (Map<String, String> record : AIRPORTS) { Mutation m = new Mutation(Integer.toString(i)); for (Entry<String, String> entry : record.entrySet()) { m.put(entry.getKey(), "", entry.getValue()); } bw.addMutation(m); i++; } } finally { if (null != bw) { bw.close(); } } bw = c.createBatchWriter("flights", config); try { int i = 1; for (Map<String, String> record : flightData) { Mutation m = new Mutation(Integer.toString(i)); for (Entry<String, String> entry : record.entrySet()) { m.put(entry.getKey(), "", entry.getValue()); } bw.addMutation(m); i++; } } finally { if (null != bw) { bw.close(); } } }