org.apache.accumulo.core.client.Connector.tableOperations()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.apache.accumulo.core.client.Connector.tableOperations()方法的一些代码示例,展示了Connector.tableOperations()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connector.tableOperations()方法的具体详情如下:
包路径:org.apache.accumulo.core.client.Connector
类名称:Connector
方法名:tableOperations

Connector.tableOperations介绍

[英]Retrieves a TableOperations object to perform table functions, such as create and delete.
[中]检索TableOperations对象以执行表函数,例如创建和删除。

代码示例

代码示例来源:origin: prestodb/presto

public void createAccumuloTable(String table)
{
  try {
    connector.tableOperations().create(table);
  }
  catch (AccumuloException | AccumuloSecurityException e) {
    throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to create Accumulo table", e);
  }
  catch (TableExistsException e) {
    throw new PrestoException(ACCUMULO_TABLE_EXISTS, "Accumulo table already exists", e);
  }
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test(expected = AccumuloException.class)
public void createTableInAccumuloNamespace() throws Exception {
 String tableName = Namespaces.ACCUMULO_NAMESPACE + ".1";
 assertFalse(c.tableOperations().exists(tableName));
 c.tableOperations().create(tableName); // should fail
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

private void writeData(String tableName, Connector conn)
  throws AccumuloException, AccumuloSecurityException, TableExistsException,
  TableNotFoundException, MutationsRejectedException {
 TreeSet<Text> splits = new TreeSet<>();
 for (int i = 1; i < 100; i++) {
  splits.add(new Text(String.format("%06d", i * 100)));
 }
 conn.tableOperations().create(tableName);
 conn.tableOperations().addSplits(tableName, splits);
 BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
 for (int i = 0; i < 100; i++) {
  String row = String.format("%06d", i * 100 + 3);
  Mutation m = new Mutation(row);
  m.put("cf1", "cq1", "1");
  bw.addMutation(m);
 }
 bw.close();
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void createTable() throws TableExistsException, AccumuloException,
  AccumuloSecurityException, TableNotFoundException {
 String tableName = getUniqueNames(1)[0];
 connector.tableOperations().create(tableName);
 Iterable<Map.Entry<String,String>> itrProps = connector.tableOperations()
   .getProperties(tableName);
 Map<String,String> props = propsToMap(itrProps);
 assertEquals(DefaultKeySizeConstraint.class.getName(),
   props.get(Property.TABLE_CONSTRAINT_PREFIX.toString() + "1"));
 connector.tableOperations().delete(tableName);
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void replicationTableCreated() throws AccumuloException, AccumuloSecurityException {
 Assert.assertTrue(getConnector().tableOperations().exists(ReplicationTable.NAME));
 Assert.assertEquals(ReplicationTable.ID,
   getConnector().tableOperations().tableIdMap().get(ReplicationTable.NAME));
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void testNoFiles() throws Exception {
 Connector conn = getConnector();
 String tableName = getUniqueNames(1)[0];
 conn.tableOperations().create(tableName);
 KeyExtent ke = new KeyExtent("0", null, null);
 Mutation mut = ke.getPrevRowUpdateMutation();
 TabletsSection.ServerColumnFamily.TIME_COLUMN.put(mut, new Value("M0".getBytes()));
 TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut,
   new Value("/default_tablet".getBytes()));
 BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig());
 bw1.addMutation(mut);
 bw1.close();
 BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig());
 MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2);
 int rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
 assertEquals(0, rc);
 // scan tables metadata entries and confirm the same
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test(expected = AccumuloException.class)
public void testRootTableSplit() throws Exception {
 TableOperations opts = getConnector().tableOperations();
 SortedSet<Text> splits = new TreeSet<>();
 splits.add(new Text("5"));
 opts.addSplits(RootTable.NAME, splits);
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void testMerge() throws Exception {
 Connector conn = getConnector();
 String tableName = getUniqueNames(1)[0];
 conn.tableOperations().create(tableName);
 BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig());
 bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
 bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2"));
 bw1.flush();
 BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig());
 MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2);
 bw1.addMutation(deleteTablet("0", "m", null, "/d1", "/d1/file1"));
 Mutation mut = createTablet("0", null, null, "/d2", "/d2/file2");
 mut.put(DataFileColumnFamily.NAME.toString(), "/d1/file1",
   new DataFileValue(10, 200).encodeAsString());
 bw1.addMutation(mut);
 bw1.flush();
 try {
  MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
  assertTrue(false);
 } catch (TabletIterator.TabletDeletedException tde) {}
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

private void testDropNone(Map<String,String> options) throws Exception {
 Connector c = getConnector();
 String tableName = getUniqueNames(1)[0];
 c.tableOperations().create(tableName);
 writeFlush(c, tableName, "a");
 writeFlush(c, tableName, "b");
 CompactionStrategyConfig csConfig = new CompactionStrategyConfig(
   TestCompactionStrategy.class.getName());
 csConfig.setOptions(options);
 c.tableOperations().compact(tableName,
   new CompactionConfig().setWait(true).setCompactionStrategy(csConfig));
 Assert.assertEquals(ImmutableSet.of("a", "b"), getRows(c, tableName));
}

代码示例来源:origin: org.calrissian.accumulorecipes/entity-store

public EntityKeyValueIndex(Connector connector, String indexTable, ShardBuilder<Entity> shardBuilder, StoreConfig config, TypeRegistry<String> typeRegistry) throws TableNotFoundException, TableExistsException, AccumuloSecurityException, AccumuloException {
  this.shardBuilder = shardBuilder;
  this.typeRegistry = typeRegistry;
  if(!connector.tableOperations().exists(indexTable))
    connector.tableOperations().create(indexTable);
  writer = connector.createBatchWriter(indexTable, config.getMaxMemory(), config.getMaxLatency(), config.getMaxWriteThreads());
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void testRealWrite() throws Exception {
 Connector c = getConnector();
 c.tableOperations().create(TEST_TABLE);
 BatchWriter bw = c.createBatchWriter(TEST_TABLE, new BatchWriterConfig());
 Mutation m = new Mutation("Key");
 m.put("", "", "");
 bw.addMutation(m);
 bw.close();
 handleWriteTests(true);
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void testCompactEmptyTableWithGeneratorIterator() throws TableExistsException,
  AccumuloException, AccumuloSecurityException, TableNotFoundException {
 String tableName = getUniqueNames(1)[0];
 connector.tableOperations().create(tableName);
 List<IteratorSetting> list = new ArrayList<>();
 list.add(new IteratorSetting(15, HardListIterator.class));
 connector.tableOperations().compact(tableName, null, null, list, true, true);
 Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
 Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
 for (Map.Entry<Key,Value> entry : scanner)
  actual.put(entry.getKey(), entry.getValue());
 assertEquals(HardListIterator.allEntriesToInject, actual);
 connector.tableOperations().delete(tableName);
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void createTableInDefaultNamespace() throws Exception {
 String tableName = "1";
 c.tableOperations().create(tableName);
 assertTrue(c.tableOperations().exists(tableName));
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void testRootTableMerge() throws Exception {
 TableOperations opts = getConnector().tableOperations();
 opts.merge(RootTable.NAME, null, null);
}

代码示例来源:origin: prestodb/presto

conn.tableOperations().create(table.getFullTableName());
conn.tableOperations().create(table.getIndexTableName());
conn.tableOperations().create(table.getMetricsTableName());
  conn.tableOperations().attachIterator(table.getMetricsTableName(), s);

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void merge() throws Exception {
 Connector c = getConnector();
 String tableName = getUniqueNames(1)[0];
 c.tableOperations().create(tableName);
 c.tableOperations().addSplits(tableName, splits("a b c d e f g h i j k".split(" ")));
 BatchWriter bw = c.createBatchWriter(tableName, null);
 for (String row : "a b c d e f g h i j k".split(" ")) {
  Mutation m = new Mutation(row);
  m.put("cf", "cq", "value");
  bw.addMutation(m);
 }
 bw.close();
 c.tableOperations().flush(tableName, null, null, true);
 c.tableOperations().merge(tableName, new Text("c1"), new Text("f1"));
 assertEquals(8, c.tableOperations().listSplits(tableName).size());
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void testCompactEmptyTableWithGeneratorIterator_Splits() throws TableExistsException,
  AccumuloException, AccumuloSecurityException, TableNotFoundException {
 String tableName = getUniqueNames(1)[0];
 connector.tableOperations().create(tableName);
 SortedSet<Text> splitset = new TreeSet<>();
 splitset.add(new Text("f"));
 connector.tableOperations().addSplits(tableName, splitset);
 List<IteratorSetting> list = new ArrayList<>();
 list.add(new IteratorSetting(15, HardListIterator.class));
 connector.tableOperations().compact(tableName, null, null, list, true, true);
 Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
 Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
 for (Map.Entry<Key,Value> entry : scanner)
  actual.put(entry.getKey(), entry.getValue());
 assertEquals(HardListIterator.allEntriesToInject, actual);
 connector.tableOperations().delete(tableName);
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Test
public void testPreSplit() throws Exception {
 String tableName = getUniqueNames(1)[0];
 Connector c = getConnector();
 c.tableOperations().create(tableName);
 SortedSet<Text> splits = new TreeSet<>();
 splits.add(new Text("8"));
 splits.add(new Text("256"));
 c.tableOperations().addSplits(tableName, splits);
 runTest(c, tableName);
}

代码示例来源:origin: prestodb/presto

conn.tableOperations().create(table.getFullTableName());
conn.tableOperations().create(table.getIndexTableName());
conn.tableOperations().create(table.getMetricsTableName());
  conn.tableOperations().attachIterator(table.getMetricsTableName(), s);

代码示例来源:origin: org.apache.accumulo/accumulo-test

private void writeFlush(Connector conn, String tablename, String row) throws Exception {
 BatchWriter bw = conn.createBatchWriter(tablename, new BatchWriterConfig());
 Mutation m = new Mutation(row);
 m.put("", "", "");
 bw.addMutation(m);
 bw.close();
 conn.tableOperations().flush(tablename, null, null, true);
}

相关文章