NewTableConfiguration ntc = new NewTableConfiguration(); ntc = ntc.withSplits(new TreeSet<>( ShellUtil.scanFile(cl.getOptionValue(createTableOptSplit.getOpt()), decode))); } else if (cl.hasOption(createTableOptCopySplits.getOpt())) { throw new TableNotFoundException(null, oldTable, null); ntc = ntc.withSplits( new TreeSet<>(shellState.getAccumuloClient().tableOperations().listSplits(oldTable))); ntc = ntc.createOffline(); ntc.setTimeType(timeType).setProperties(props));
/** * Configure iterator settings for a table prior to its creation. * * Additional calls to this method before table creation will overwrite previous iterator * settings. * * @param setting * object specifying the properties of the iterator * * @since 2.0.0 * * @see TableOperations#attachIterator(String, IteratorSetting) */ public NewTableConfiguration attachIterator(IteratorSetting setting) { return attachIterator(setting, EnumSet.allOf(IteratorScope.class)); }
/** * Add supplied locality groups information to a NewTableConfiguration object. * * Used in conjunction with createtable shell command to allow locality groups to be configured * upon table creation. */ private NewTableConfiguration setLocalityForNewTable(CommandLine cl, NewTableConfiguration ntc) { HashMap<String,Set<Text>> localityGroupMap = new HashMap<>(); String[] options = cl.getOptionValues(createTableOptLocalityProps.getOpt()); for (String localityInfo : options) { final String parts[] = localityInfo.split("=", 2); if (parts.length < 2) throw new IllegalArgumentException("Missing '=' or there are spaces between entries"); final String groupName = parts[0]; final HashSet<Text> colFams = new HashSet<>(); for (String family : parts[1].split(",")) colFams.add(new Text(family.getBytes(Shell.CHARSET))); // check that group names are not duplicated on usage line if (localityGroupMap.put(groupName, colFams) != null) throw new IllegalArgumentException( "Duplicate locality group name found. Group names must be unique"); } ntc.setLocalityGroups(localityGroupMap); return ntc; }
@Override @Deprecated public void create(String tableName, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException { NewTableConfiguration ntc = new NewTableConfiguration().setTimeType(timeType); if (versioningIter) create(tableName, ntc); else create(tableName, ntc.withoutDefaultIterators()); }
@SuppressWarnings("deprecation") @Test public void tableNameAndLimitVersion() throws Exception { log.info("Starting tableNameAndLimitVersion"); // Create a table with the initial properties Connector connector = getConnector(); String tableName = getUniqueNames(2)[0]; boolean limitVersion = false; connector.tableOperations().create(tableName, new NewTableConfiguration().withoutDefaultIterators()); String tableNameOrig = "originalWithLimitVersion"; connector.tableOperations().create(tableNameOrig, limitVersion); int countNew = numProperties(connector, tableName); int countOrig = compareProperties(connector, tableNameOrig, tableName, null); Assert.assertEquals("Extra properties using the new create method", countOrig, countNew); Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, TimeType.MILLIS)); }
new NewTableConfiguration().withoutDefaultIterators() .setProperties(Collections.singletonMap(AccumuloProps.TABLE_DELETE_BEHAVIOR, AccumuloProps.TABLE_DELETE_BEHAVIOR_VALUE)));
ntcProps.put(AccumuloProps.TABLE_DELETE_BEHAVIOR, AccumuloProps.TABLE_DELETE_BEHAVIOR_VALUE); NewTableConfiguration ntc = new NewTableConfiguration().withoutDefaultIterators(); ntc.setLocalityGroups(Collections.singletonMap(ColumnConstants.NOTIFY_LOCALITY_GROUP_NAME, Collections.singleton(new Text(ColumnConstants.NOTIFY_CF.toArray())))); ntc.setProperties(ntcProps); conn.tableOperations().create(config.getAccumuloTable(), ntc);
"Running merge test " + table + " " + Arrays.asList(splits) + " " + start + " " + end); conn.tableOperations().create(table, new NewTableConfiguration().setTimeType(TimeType.LOGICAL)); TreeSet<Text> splitSet = new TreeSet<>(); for (String split : splits) {
@Test public void testSample() throws Exception { final String TEST_TABLE_3 = getUniqueNames(1)[0]; Connector c = getConnector(); c.tableOperations().create(TEST_TABLE_3, new NewTableConfiguration().enableSampling(SAMPLER_CONFIG)); BatchWriter bw = c.createBatchWriter(TEST_TABLE_3, new BatchWriterConfig()); for (int i = 0; i < 100; i++) { Mutation m = new Mutation(new Text(String.format("%09x", i + 1))); m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes())); bw.addMutation(m); } bw.close(); Assert.assertEquals(0, MRTester .main(new String[] {TEST_TABLE_3, AccumuloInputFormat.class.getName(), "False", "True"})); assertEquals(39, assertionErrors.get(TEST_TABLE_3 + "_map").size()); assertEquals(2, assertionErrors.get(TEST_TABLE_3 + "_cleanup").size()); assertionErrors.clear(); Assert.assertEquals(0, MRTester .main(new String[] {TEST_TABLE_3, AccumuloInputFormat.class.getName(), "False", "False"})); assertEquals(1, assertionErrors.get(TEST_TABLE_3 + "_map").size()); assertEquals(1, assertionErrors.get(TEST_TABLE_3 + "_cleanup").size()); assertionErrors.clear(); Assert.assertEquals(0, MRTester .main(new String[] {TEST_TABLE_3, AccumuloInputFormat.class.getName(), "True", "True"})); assertEquals(39, assertionErrors.get(TEST_TABLE_3 + "_map").size()); assertEquals(2, assertionErrors.get(TEST_TABLE_3 + "_cleanup").size()); }
new NewTableConfiguration().setTimeType(timeType).setProperties(props)); if (partitions.size() > 0) { shellState.getConnector().tableOperations().addSplits(tableName, partitions);
@Override public void create(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException { create(tableName, new NewTableConfiguration()); }
String tableName = getUniqueNames(2)[0]; connector.tableOperations().create(tableName, new NewTableConfiguration().setProperties(properties));
@Override @Deprecated public void create(String tableName, boolean limitVersion, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException { checkArgument(tableName != null, "tableName is null"); checkArgument(timeType != null, "timeType is null"); NewTableConfiguration ntc = new NewTableConfiguration().setTimeType(timeType); if (limitVersion) create(tableName, ntc); else create(tableName, ntc.withoutDefaultIterators()); }
NewTableConfiguration ntc = new NewTableConfiguration().withoutDefaultIterators();
NewTableConfiguration ntc = new NewTableConfiguration().withoutDefaultIterators(); ntc.setProperties(ntcProps); conn.tableOperations().create(config.getAccumuloTable(), ntc);
private void runMergeTest(Connector conn, String table, String[] splits, String[] inserts, String start, String end, String last, long expected) throws Exception { log.info("table " + table); conn.tableOperations().create(table, new NewTableConfiguration().setTimeType(TimeType.LOGICAL)); TreeSet<Text> splitSet = new TreeSet<>(); for (String split : splits) { splitSet.add(new Text(split)); } conn.tableOperations().addSplits(table, splitSet); BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig()); for (String row : inserts) { Mutation m = new Mutation(row); m.put("cf", "cq", "v"); bw.addMutation(m); } bw.flush(); conn.tableOperations().merge(table, start == null ? null : new Text(start), end == null ? null : new Text(end)); Mutation m = new Mutation(last); m.put("cf", "cq", "v"); bw.addMutation(m); bw.flush(); Scanner scanner = conn.createScanner(table, Authorizations.EMPTY); scanner.setRange(new Range(last)); bw.close(); long time = scanner.iterator().next().getKey().getTimestamp(); if (time != expected) throw new RuntimeException("unexpected time " + time + " " + expected); }
@Test public void testSample() throws Exception { final String TEST_TABLE_3 = getUniqueNames(1)[0]; Connector c = getConnector(); c.tableOperations().create(TEST_TABLE_3, new NewTableConfiguration().enableSampling(SAMPLER_CONFIG)); BatchWriter bw = c.createBatchWriter(TEST_TABLE_3, new BatchWriterConfig()); for (int i = 0; i < 100; i++) { Mutation m = new Mutation(new Text(String.format("%09x", i + 1))); m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes())); bw.addMutation(m); } bw.close(); MRTester.main(TEST_TABLE_3, "False", "True"); Assert.assertEquals(38, e1Count); Assert.assertEquals(1, e2Count); e2Count = e1Count = 0; MRTester.main(TEST_TABLE_3, "False", "False"); Assert.assertEquals(0, e1Count); Assert.assertEquals(0, e2Count); e2Count = e1Count = 0; MRTester.main(TEST_TABLE_3, "True", "True"); Assert.assertEquals(38, e1Count); Assert.assertEquals(1, e2Count); }
@Override public void create(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException { create(tableName, new NewTableConfiguration()); }
private static void createTable(Connector connector, String tableName) { try { NewTableConfiguration config = new NewTableConfiguration() .withoutDefaultIterators() .setTimeType(TimeType.MILLIS); connector.tableOperations().create(tableName, config); } catch (Exception e) { throw new VertexiumException("Unable to create table " + tableName); } } }
String tableName = getUniqueNames(1)[0]; connector.tableOperations().create(tableName, new NewTableConfiguration().withoutDefaultIterators());