@Test public void testColumnFamilySet() { ConfigurationCopy conf = new ConfigurationCopy(); conf.set("table.group.lg1", "cf1,cf2"); conf.set("table.groups.enabled", "lg1"); try { Map<String,Set<ByteSequence>> groups = LocalityGroupUtil.getLocalityGroups(conf); assertEquals(1, groups.size()); assertNotNull(groups.get("lg1")); assertEquals(2, groups.get("lg1").size()); assertTrue(groups.get("lg1").contains(new ArrayByteSequence("cf1"))); } catch (LocalityGroupConfigurationError err) { fail(); } try { conf.set("table.group.lg2", "cf1"); conf.set("table.groups.enabled", "lg1,lg2"); LocalityGroupUtil.getLocalityGroups(conf); fail(); } catch (LocalityGroupConfigurationError err) { } }
public static Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuconf) throws LocalityGroupConfigurationError { Map<String,Set<ByteSequence>> result = new HashMap<>(); String[] groups = acuconf.get(Property.TABLE_LOCALITY_GROUPS).split(","); for (String group : groups) { if (!group.isEmpty()) { result.put(group, new HashSet<>()); } } HashSet<ByteSequence> all = new HashSet<>(); for (Entry<String,String> entry : acuconf) { String property = entry.getKey(); String value = entry.getValue(); String prefix = Property.TABLE_LOCALITY_GROUP_PREFIX.getKey(); if (property.startsWith(prefix)) { String group = property.substring(prefix.length()); String[] parts = group.split("\\."); group = parts[0]; if (result.containsKey(group)) { if (parts.length == 1) { Set<ByteSequence> colFamsSet = decodeColumnFamilies(value); if (!Collections.disjoint(all, colFamsSet)) { colFamsSet.retainAll(all); throw new LocalityGroupConfigurationError("Column families " + colFamsSet + " in group " + group + " is already used by another locality group"); } all.addAll(colFamsSet); result.put(group, colFamsSet); } } } } Set<Entry<String,Set<ByteSequence>>> es = result.entrySet(); for (Entry<String,Set<ByteSequence>> entry : es) { if (entry.getValue().isEmpty()) { throw new LocalityGroupConfigurationError( "Locality group " + entry.getKey() + " specified but not declared"); } } return result; }
LocalityGroupUtil { public static Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuconf) throws LocalityGroupConfigurationError { Map<String,Set<ByteSequence>> result = new HashMap<>(); String[] groups = acuconf.get(Property.TABLE_LOCALITY_GROUPS).split(","); for (String group : groups) { if (!group.isEmpty()) { result.put(group, new HashSet<>()); } } HashSet<ByteSequence> all = new HashSet<>(); for (Entry<String,String> entry : acuconf) { String property = entry.getKey(); String value = entry.getValue(); String prefix = Property.TABLE_LOCALITY_GROUP_PREFIX.getKey(); if (property.startsWith(prefix)) { String group = property.substring(prefix.length()); String[] parts = group.split("\\."); group = parts[0]; if (result.containsKey(group)) { if (parts.length == 1) { Set<ByteSequence> colFamsSet = decodeColumnFamilies(value); if (!Collections.disjoint(all, colFamsSet)) { colFamsSet.retainAll(all); throw new LocalityGroupConfigurationError("Column families " + colFamsSet + " in group " + group + " is already used by another locality group"); } all.addAll(colFamsSet); result.put(group, colFamsSet); } } } } Set<Entry<String,Set<ByteSequence>>> es = result.entrySet(); for (Entry<String,Set<ByteSequence>> entry : es) { if (entry.getValue().isEmpty()) { throw new LocalityGroupConfigurationError( "Locality group " + entry.getKey() + " specified but not declared"); } } return result; } }
LocalityGroupUtil { public static Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuconf) throws LocalityGroupConfigurationError { Map<String,Set<ByteSequence>> result = new HashMap<>(); String[] groups = acuconf.get(Property.TABLE_LOCALITY_GROUPS).split(","); for (String group : groups) { if (!group.isEmpty()) { result.put(group, new HashSet<>()); } } HashSet<ByteSequence> all = new HashSet<>(); for (Entry<String,String> entry : acuconf) { String property = entry.getKey(); String value = entry.getValue(); String prefix = Property.TABLE_LOCALITY_GROUP_PREFIX.getKey(); if (property.startsWith(prefix)) { String group = property.substring(prefix.length()); String[] parts = group.split("\\."); group = parts[0]; if (result.containsKey(group)) { if (parts.length == 1) { Set<ByteSequence> colFamsSet = decodeColumnFamilies(value); if (!Collections.disjoint(all, colFamsSet)) { colFamsSet.retainAll(all); throw new LocalityGroupConfigurationError("Column families " + colFamsSet + " in group " + group + " is already used by another locality group"); } all.addAll(colFamsSet); result.put(group, colFamsSet); } } } } Set<Entry<String,Set<ByteSequence>>> es = result.entrySet(); for (Entry<String,Set<ByteSequence>> entry : es) { if (entry.getValue().isEmpty()) { throw new LocalityGroupConfigurationError( "Locality group " + entry.getKey() + " specified but not declared"); } } return result; }  }
LocalityGroupUtil { public static Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuconf) throws LocalityGroupConfigurationError { Map<String,Set<ByteSequence>> result = new HashMap<>(); String[] groups = acuconf.get(Property.TABLE_LOCALITY_GROUPS).split(","); for (String group : groups) { if (!group.isEmpty()) { result.put(group, new HashSet<>()); } } HashSet<ByteSequence> all = new HashSet<>(); for (Entry<String,String> entry : acuconf) { String property = entry.getKey(); String value = entry.getValue(); String prefix = Property.TABLE_LOCALITY_GROUP_PREFIX.getKey(); if (property.startsWith(prefix)) { String group = property.substring(prefix.length()); String[] parts = group.split("\\."); group = parts[0]; if (result.containsKey(group)) { if (parts.length == 1) { Set<ByteSequence> colFamsSet = decodeColumnFamilies(value); if (!Collections.disjoint(all, colFamsSet)) { colFamsSet.retainAll(all); throw new LocalityGroupConfigurationError("Column families " + colFamsSet + " in group " + group + " is already used by another locality group"); } all.addAll(colFamsSet); result.put(group, colFamsSet); } } } } Set<Entry<String,Set<ByteSequence>>> es = result.entrySet(); for (Entry<String,Set<ByteSequence>> entry : es) { if (entry.getValue().isEmpty()) { throw new LocalityGroupConfigurationError( "Locality group " + entry.getKey() + " specified but not declared"); } } return result; }  static Set<ByteSequence> families(Collection<Column> columns); static boolean isLocalityGroupProperty(String prop); static void checkLocalityGroups(Iterable<Entry<String,String>> config); static Map<String,Set<ByteSequence>> getLocalityGroupsIgnoringErrors(AccumuloConfiguration acuconf, TableId tableId); static Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuconf); static Set<ByteSequence> decodeColumnFamilies(String colFams); static ByteSequence decodeColumnFamily(String colFam); static String encodeColumnFamilies(Set<Text> colFams); static String encodeColumnFamily(ByteSequence bs); static void seek(FileSKVIterator reader, Range range, String lgName,
      Map<String,ArrayList<ByteSequence>> localityGroupCF); static void ensureNonOverlappingGroups(Map<String,Set<Text>> groups); }
LocalityGroupUtil { public static Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuconf) throws LocalityGroupConfigurationError { Map<String,Set<ByteSequence>> result = new HashMap<>(); String[] groups = acuconf.get(Property.TABLE_LOCALITY_GROUPS).split(","); for (String group : groups) { if (!group.isEmpty()) { result.put(group, new HashSet<>()); } } HashSet<ByteSequence> all = new HashSet<>(); for (Entry<String,String> entry : acuconf) { String property = entry.getKey(); String value = entry.getValue(); String prefix = Property.TABLE_LOCALITY_GROUP_PREFIX.getKey(); if (property.startsWith(prefix)) { String group = property.substring(prefix.length()); String[] parts = group.split("\\."); group = parts[0]; if (result.containsKey(group)) { if (parts.length == 1) { Set<ByteSequence> colFamsSet = decodeColumnFamilies(value); if (!Collections.disjoint(all, colFamsSet)) { colFamsSet.retainAll(all); throw new LocalityGroupConfigurationError("Column families " + colFamsSet + " in group " + group + " is already used by another locality group"); } all.addAll(colFamsSet); result.put(group, colFamsSet); } } } } Set<Entry<String,Set<ByteSequence>>> es = result.entrySet(); for (Entry<String,Set<ByteSequence>> entry : es) { if (entry.getValue().isEmpty()) { throw new LocalityGroupConfigurationError( "Locality group " + entry.getKey() + " specified but not declared"); } } return result; }  static Set<ByteSequence> families(Collection<Column> columns); static boolean isLocalityGroupProperty(String prop); static void checkLocalityGroups(Iterable<Entry<String,String>> config); static Map<String,Set<ByteSequence>> getLocalityGroupsIgnoringErrors(AccumuloConfiguration acuconf, TableId tableId); static Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuconf); static Set<ByteSequence> decodeColumnFamilies(String colFams); static ByteSequence decodeColumnFamily(String colFam); static String encodeColumnFamilies(Set<Text> colFams); static String encodeColumnFamily(ByteSequence bs); static void seek(FileSKVIterator reader, Range range, String lgName,
      Map<String,ArrayList<ByteSequence>> localityGroupCF); static void ensureNonOverlappingGroups(Map<String,Set<Text>> groups); static final Set<ByteSequence> EMPTY_CF_SET; }