public void setLocalityGroups(String tableName, Map<String, Set<Text>> groups) { if (groups.isEmpty()) { return; } try { connector.tableOperations().setLocalityGroups(tableName, groups); LOG.debug("Set locality groups for %s to %s", tableName, groups); } catch (AccumuloException | AccumuloSecurityException e) { throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to set locality groups", e); } catch (TableNotFoundException e) { throw new PrestoException(ACCUMULO_TABLE_DNE, "Failed to set locality groups, table does not exist", e); } }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final String tableName = OptUtil.getTableOpt(cl, shellState); final HashMap<String,Set<Text>> groups = new HashMap<>(); for (String arg : cl.getArgs()) { final String sa[] = arg.split("=", 2); if (sa.length < 2) { throw new IllegalArgumentException("Missing '='"); } final String group = sa[0]; final HashSet<Text> colFams = new HashSet<>(); for (String family : sa[1].split(",")) { colFams.add(new Text(family.getBytes(Shell.CHARSET))); } groups.put(group, colFams); } shellState.getAccumuloClient().tableOperations().setLocalityGroups(tableName, groups); return 0; }
private void addLocalityGroup(final TableOperations tops, final String tableName, final String localityGroup) throws AccumuloException, TableNotFoundException, AccumuloSecurityException { if (tops.exists(tableName)) { final Map<String,Set<Text>> localityGroups = tops.getLocalityGroups(tableName); final Set<Text> groupSet = new HashSet<>(); groupSet.add(new Text(localityGroup)); localityGroups.put(localityGroup, groupSet); tops.setLocalityGroups(tableName, localityGroups); } } }
/** * * @param tableName * @param conn * @param groups * - locality groups to be created * * Sets locality groups for more efficient scans - these are * usually the variable orders in the table so that scans for * specific orders are more efficient */ private void setLocalityGroups(final String tableName, final Connector conn, final List<String> groups) { final HashMap<String, Set<Text>> localityGroups = new HashMap<String, Set<Text>>(); for (int i = 0; i < groups.size(); i++) { final HashSet<Text> tempColumn = new HashSet<Text>(); tempColumn.add(new Text(groups.get(i))); final String groupName = groups.get(i).replace(VALUE_DELIM, ""); localityGroups.put(groupName, tempColumn); } try { conn.tableOperations().setLocalityGroups(tableName, localityGroups); } catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) { e.printStackTrace(); } }
/** * * @param tableName * @param conn * @param groups * - locality groups to be created * * Sets locality groups for more efficient scans - these are * usually the variable orders in the table so that scans for * specific orders are more efficient */ private void setLocalityGroups(final String tableName, final Connector conn, final List<String> groups) { final HashMap<String, Set<Text>> localityGroups = new HashMap<String, Set<Text>>(); for (int i = 0; i < groups.size(); i++) { final HashSet<Text> tempColumn = new HashSet<Text>(); tempColumn.add(new Text(groups.get(i))); final String groupName = groups.get(i).replace(VALUE_DELIM, ""); localityGroups.put(groupName, tempColumn); } try { conn.tableOperations().setLocalityGroups(tableName, localityGroups); } catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) { e.printStackTrace(); } }
@Override public void setLocalityGroups(ByteBuffer login, String tableName, Map<String,Set<String>> groupStrings) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { Map<String,Set<Text>> groups = new HashMap<>(); for (Entry<String,Set<String>> groupEntry : groupStrings.entrySet()) { groups.put(groupEntry.getKey(), new HashSet<Text>()); for (String val : groupEntry.getValue()) { groups.get(groupEntry.getKey()).add(new Text(val)); } } getConnector(login).tableOperations().setLocalityGroups(tableName, groups); } catch (Exception e) { handleExceptionTNF(e); } }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final String tableName = OptUtil.getTableOpt(cl, shellState); final HashMap<String,Set<Text>> groups = new HashMap<>(); for (String arg : cl.getArgs()) { final String sa[] = arg.split("=", 2); if (sa.length < 2) { throw new IllegalArgumentException("Missing '='"); } final String group = sa[0]; final HashSet<Text> colFams = new HashSet<>(); for (String family : sa[1].split(",")) { colFams.add(new Text(family.getBytes(Shell.CHARSET))); } groups.put(group, colFams); } shellState.getConnector().tableOperations().setLocalityGroups(tableName, groups); return 0; }
tops.setLocalityGroups(tableName, localityGroups); log.info("Reset the locality groups for " + tableName + " to " + localityGroups);
private static void setupLocalityGroups(Connector conn, int numlg, ArrayList<byte[]> cfset, String table) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (numlg > 1) { int numCF = cfset.size() / numlg; int gNum = 0; Iterator<byte[]> cfiter = cfset.iterator(); Map<String,Set<Text>> groups = new HashMap<>(); while (cfiter.hasNext()) { HashSet<Text> groupCols = new HashSet<>(); for (int i = 0; i < numCF && cfiter.hasNext(); i++) { groupCols.add(new Text(cfiter.next())); } groups.put("lg" + (gNum++), groupCols); } conn.tableOperations().setLocalityGroups(table, groups); conn.tableOperations().offline(table); sleepUninterruptibly(1, TimeUnit.SECONDS); conn.tableOperations().online(table); } }
public static void setLocalityGroups(final AccumuloStore store) throws StoreException { final String tableName = store.getTableName(); Map<String, Set<Text>> localityGroups = new HashMap<>(); for (final String group : store.getSchema().getGroups()) { HashSet<Text> localityGroup = new HashSet<>(); localityGroup.add(new Text(group)); localityGroups.put(group, localityGroup); } LOGGER.info("Setting locality groups on table {}", tableName); try { store.getConnection().tableOperations().setLocalityGroups(tableName, localityGroups); } catch (final AccumuloException | AccumuloSecurityException | TableNotFoundException e) { throw new StoreException(e.getMessage(), e); } }
public void setLocalityGroups() { HashMap<String, Set<Text>> localityGroups = new HashMap<String, Set<Text>>(); Iterator<String> groups = getPredicates(); int i = 1; while(groups.hasNext()) { HashSet<Text> tempColumn = new HashSet<Text>(); String temp = groups.next(); tempColumn.add(new Text(temp)); String groupName = "predicate" + i; localityGroups.put(groupName, tempColumn); i++; } try { conn.tableOperations().setLocalityGroups(tablePrefix + "doc_partitioned_index", localityGroups); //conn.tableOperations().compact(tablePrefix + "doc_partitioned_index", null, null, true, true); } catch (AccumuloException e) { e.printStackTrace(); } catch (AccumuloSecurityException e) { e.printStackTrace(); } catch (TableNotFoundException e) { e.printStackTrace(); } }
public void setLocalityGroups() { HashMap<String, Set<Text>> localityGroups = new HashMap<String, Set<Text>>(); Iterator<String> groups = getPredicates(); int i = 1; while(groups.hasNext()) { HashSet<Text> tempColumn = new HashSet<Text>(); String temp = groups.next(); tempColumn.add(new Text(temp)); String groupName = "predicate" + i; localityGroups.put(groupName, tempColumn); i++; } try { conn.tableOperations().setLocalityGroups(tablePrefix + "doc_partitioned_index", localityGroups); //conn.tableOperations().compact(tablePrefix + "doc_partitioned_index", null, null, true, true); } catch (AccumuloException e) { e.printStackTrace(); } catch (AccumuloSecurityException e) { e.printStackTrace(); } catch (TableNotFoundException e) { e.printStackTrace(); } }
conn.tableOperations().setLocalityGroups(imageTableName, groups); log.debug("Configured locality groups for " + imageTableName + " groups = " + groups);
Map<String,Set<Text>> groups = new TreeMap<>(); groups.put("g1", Collections.singleton(t("colf"))); connector.tableOperations().setLocalityGroups(tableName, groups); ingest(connector, getCluster().getClientConfig(), getAdminPrincipal(), 2000, 1, 50, 0, tableName);
tableOps.setLocalityGroups(state.getString("imageTableName"), groups);
Map<String, Set<Text>> groups = new HashMap<>(); groups.put("notify", Collections.singleton(ByteUtil.toText(ColumnConstants.NOTIFY_CF))); conn.tableOperations().setLocalityGroups(config.getAccumuloTable(), groups);
groups.put("lg1", Collections.singleton(new Text("foo"))); groups.put("dg", Collections.<Text> emptySet()); c.tableOperations().setLocalityGroups(tableName, groups); IteratorSetting setting = new IteratorSetting(30, RowDeletingIterator.class); c.tableOperations().attachIterator(tableName, setting, EnumSet.of(IteratorScope.majc));
mock.setLocalityGroups(EasyMock.anyObject(String.class), EasyMock.anyObject(groups.getClass())); EasyMock.expectLastCall().andAnswer(() -> {
mock.setLocalityGroups(EasyMock.anyObject(String.class), EasyMock.anyObject(groups.getClass())); EasyMock.expectLastCall().andAnswer(() -> {
int i = 0; for (String cfg : config) { to.setLocalityGroups(table, getGroups(cfg)); ingest(connector, getCluster().getClientConfig(), getAdminPrincipal(), ROWS * (i + 1), 1, 50, ROWS * i, table); ingest(connector, getCluster().getClientConfig(), getAdminPrincipal(), ROWS * i, 1, 50, 0, "xyz", table); to.setLocalityGroups(table, getGroups(cfg)); to.flush(table, null, null, true); verify(connector, getCluster().getClientConfig(), getAdminPrincipal(), ROWS * i, 1, 50, 0,