use of org.apache.accumulo.core.client.summary.SummarizerConfiguration in project accumulo by apache.
the class SummaryIT method testExceptions.
@Test
public void testExceptions() throws Exception {
Connector c = getConnector();
try {
c.tableOperations().summaries("foo").retrieve();
Assert.fail();
} catch (TableNotFoundException e) {
}
try {
c.tableOperations().addSummarizers("foo", SummarizerConfiguration.builder(VisibilitySummarizer.class).build());
Assert.fail();
} catch (TableNotFoundException e) {
}
try {
c.tableOperations().listSummarizers("foo");
Assert.fail();
} catch (TableNotFoundException e) {
}
try {
c.tableOperations().removeSummarizers("foo", sc -> true);
Assert.fail();
} catch (TableNotFoundException e) {
}
SummarizerConfiguration sc1 = SummarizerConfiguration.builder(FamilySummarizer.class).setPropertyId("p1").build();
SummarizerConfiguration sc2 = SummarizerConfiguration.builder(VisibilitySummarizer.class).setPropertyId("p1").build();
c.tableOperations().create("foo");
c.tableOperations().addSummarizers("foo", sc1);
c.tableOperations().addSummarizers("foo", sc1);
try {
// adding second summarizer with same id should fail
c.tableOperations().addSummarizers("foo", sc2);
Assert.fail();
} catch (IllegalArgumentException e) {
}
c.tableOperations().removeSummarizers("foo", sc -> true);
Assert.assertEquals(0, c.tableOperations().listSummarizers("foo").size());
try {
// adding two summarizers at the same time with same id should fail
c.tableOperations().addSummarizers("foo", sc1, sc2);
Assert.fail();
} catch (IllegalArgumentException e) {
}
Assert.assertEquals(0, c.tableOperations().listSummarizers("foo").size());
c.tableOperations().offline("foo", true);
try {
c.tableOperations().summaries("foo").retrieve();
Assert.fail();
} catch (TableOfflineException e) {
}
}
use of org.apache.accumulo.core.client.summary.SummarizerConfiguration in project accumulo by apache.
the class SummarizerConfigurationUtil method getSummarizerConfigsFiltered.
private static List<SummarizerConfiguration> getSummarizerConfigsFiltered(SortedMap<String, String> sprops) {
if (sprops.size() == 0) {
return Collections.emptyList();
}
SummarizerConfiguration.Builder builder = null;
List<SummarizerConfiguration> configs = new ArrayList<>();
final int preLen = Property.TABLE_SUMMARIZER_PREFIX.getKey().length();
for (Entry<String, String> entry : sprops.entrySet()) {
String k = entry.getKey().substring(preLen);
String[] tokens = k.split("\\.");
String id = tokens[0];
if (tokens.length == 1) {
if (builder != null) {
configs.add(builder.build());
}
builder = SummarizerConfiguration.builder(entry.getValue()).setPropertyId(id);
} else if (tokens.length == 3 || tokens[1].equals("opt")) {
builder.addOption(tokens[2], entry.getValue());
} else {
throw new IllegalArgumentException("Unable to parse summarizer property : " + k);
}
}
configs.add(builder.build());
return configs;
}
use of org.apache.accumulo.core.client.summary.SummarizerConfiguration in project accumulo by apache.
the class SummarizerConfigurationUtil method toTablePropertiesMap.
public static Map<String, String> toTablePropertiesMap(List<SummarizerConfiguration> summarizers) {
if (summarizers.size() == 0) {
return Collections.emptyMap();
}
Map<String, String> props = new HashMap<>();
for (SummarizerConfiguration sconf : summarizers) {
String cid = sconf.getPropertyId();
String prefix = Property.TABLE_SUMMARIZER_PREFIX.getKey() + cid;
if (props.containsKey(prefix)) {
throw new IllegalArgumentException("Duplicate summarizer config id : " + cid);
}
props.put(prefix, sconf.getClassName());
Set<Entry<String, String>> es = sconf.getOptions().entrySet();
StringBuilder sb = new StringBuilder(prefix + ".opt.");
int resetLen = sb.length();
for (Entry<String, String> entry : es) {
sb.append(entry.getKey());
props.put(sb.toString(), entry.getValue());
sb.setLength(resetLen);
}
}
return props;
}
use of org.apache.accumulo.core.client.summary.SummarizerConfiguration in project accumulo by apache.
the class SummaryCollection method getSummaries.
public List<Summary> getSummaries() {
ArrayList<Summary> ret = new ArrayList<>(mergedSummaries.size());
for (Entry<SummarizerConfiguration, MergedSummary> entry : mergedSummaries.entrySet()) {
SummarizerConfiguration config = entry.getKey();
MergedSummary ms = entry.getValue();
ret.add(new Summary(ms.summary, config, totalFiles, (totalFiles - deletedFiles) - ms.filesContaining, ms.filesExceedingBoundry, ms.filesLarge, deletedFiles));
}
return ret;
}
use of org.apache.accumulo.core.client.summary.SummarizerConfiguration in project accumulo by apache.
the class SummaryReader method load.
private static List<SummarySerializer> load(BlockReader bcReader, Predicate<SummarizerConfiguration> summarySelector) throws IOException {
try (DataInputStream in = bcReader.getMetaBlock(SummaryWriter.METASTORE_INDEX)) {
List<SummarySerializer> stores = new ArrayList<>();
readHeader(in);
int numSummaries = WritableUtils.readVInt(in);
for (int i = 0; i < numSummaries; i++) {
SummarizerConfiguration conf = readConfig(in);
boolean inline = in.readBoolean();
if (inline) {
if (summarySelector.test(conf)) {
stores.add(SummarySerializer.load(conf, in));
} else {
SummarySerializer.skip(in);
}
} else {
int block = WritableUtils.readVInt(in);
int offset = WritableUtils.readVInt(in);
if (summarySelector.test(conf)) {
try (DataInputStream summaryIn = bcReader.getMetaBlock(SummaryWriter.METASTORE_PREFIX + "." + block)) {
long skipped = in.skip(offset);
while (skipped < offset) {
skipped += in.skip(offset - skipped);
}
stores.add(SummarySerializer.load(conf, summaryIn));
} catch (MetaBlockDoesNotExist e) {
// this is unexpected
throw new IOException(e);
}
}
}
}
return stores;
} catch (MetaBlockDoesNotExist e) {
return Collections.emptyList();
}
}
Aggregations