本文整理汇总了Java中org.apache.accumulo.core.client.IteratorSetting类的典型用法代码示例。如果您正苦于以下问题:Java IteratorSetting类的具体用法?Java IteratorSetting怎么用?Java IteratorSetting使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IteratorSetting类属于org.apache.accumulo.core.client包,在下文中一共展示了IteratorSetting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchColumnTest
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
private void fetchColumnTest(String configuration) throws Exception {
List<String> rows = Arrays.asList("row1", "row2");
List<String> colFs = Arrays.asList("colF1", "colF2");
List<String> colQs = Arrays.asList("colQ1", "colQ2");
List<String> colVs = Collections.singletonList("");
List<String> values = Collections.singletonList("value");
clearTable();
EncryptedBatchWriter writer = getEncryptedWriter(CHARLIE, configuration);
writeData(writer, rows, colFs, colQs, colVs, values);
writer.close();
EncryptedBatchScanner scanner = getEncryptedScanner(CHARLIE, configuration);
scanner.setRanges(Collections.singletonList(new Range()));
scanner.fetchColumn(new IteratorSetting.Column(new Text("colF1"), new Text("colQ1")));
assertThat("contains the filtered data", scanner, hasData(rows, Collections.singletonList("colF1"), Collections.singletonList("colQ1"), colVs, values));
}
示例2: fetchColumnSemanticEncryptionTest
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
@Test
public void fetchColumnSemanticEncryptionTest() throws Exception {
when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner);
EntryEncryptor encryptor = new EntryEncryptor(getConfig("encrypt-key.ini"), KEYS);
List<Map.Entry<Key,Value>> entries = new ArrayList<>();
Map.Entry<Key,Value> entry = new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
"secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false, false), new Value(new byte[] {4}));
Map.Entry<Key,Value> entry2 = new SimpleImmutableEntry<>(new Key(new byte[] {5}, new byte[] {6}, new byte[] {7},
"secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false, false), new Value(new byte[] {8}));
entries.add(encryptor.encrypt(entry));
entries.add(encryptor.encrypt(entry2));
when(mockScanner.iterator()).thenReturn(entries.iterator()).thenReturn(entries.iterator()).thenReturn(entries.iterator());
BatchScanner scanner = new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("encrypt-key.ini"), KEYS);
assertThat("has correct number of elements", scanner, iterableWithSize(2));
scanner.fetchColumn(new IteratorSetting.Column(new Text(new byte[] {2}), new Text(new byte[] {3})));
assertThat("has correct number of elements", scanner, iterableWithSize(1));
scanner.fetchColumn(new IteratorSetting.Column(new Text(new byte[] {6}), new Text(new byte[] {7})));
assertThat("has correct number of elements", scanner, iterableWithSize(2));
// Should not have been handled server side.
verify(mockScanner, never()).fetchColumn(any());
}
示例3: createScanner
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
private Scanner createScanner(Query<K,T> query) throws TableNotFoundException {
// TODO make isolated scanner optional?
Scanner scanner = new IsolatedScanner(conn.createScanner(mapping.tableName, Constants.NO_AUTHS));
setFetchColumns(scanner, query.getFields());
scanner.setRange(createRange(query));
if (query.getStartTime() != -1 || query.getEndTime() != -1) {
IteratorSetting is = new IteratorSetting(30, TimestampFilter.class);
if (query.getStartTime() != -1)
TimestampFilter.setStart(is, query.getStartTime(), true);
if (query.getEndTime() != -1)
TimestampFilter.setEnd(is, query.getEndTime(), true);
scanner.addScanIterator(is);
}
return scanner;
}
示例4: main
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(FileDataIngest.class.getName(), args, bwOpts);
Connector conn = opts.getConnector();
if (!conn.tableOperations().exists(opts.getTableName())) {
conn.tableOperations().create(opts.getTableName());
conn.tableOperations().attachIterator(opts.getTableName(), new IteratorSetting(1, ChunkCombiner.class));
}
BatchWriter bw = conn.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig());
FileDataIngest fdi = new FileDataIngest(opts.chunkSize, opts.visibility);
for (String filename : opts.files) {
fdi.insertFileData(filename, bw);
}
bw.close();
//TODO
//opts.stopTracing();
}
示例5: testAgeoffFilter
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
@Test
public void testAgeoffFilter() throws Exception {
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
is = new IteratorSetting(10, AgeOffFilter.class);
AgeOffFilter.setTTL(is, 1000L);
c.tableOperations().attachIterator(tableName, is);
sleepUninterruptibly(500, TimeUnit.MILLISECONDS); // let zookeeper updates propagate.
bw = c.createBatchWriter(tableName, bwc);
Mutation m = new Mutation("foo");
m.put("a", "b", "c");
bw.addMutation(m);
bw.close();
sleepUninterruptibly(1, TimeUnit.SECONDS);
assertEquals(0, Iterators.size(c.createScanner(tableName, Authorizations.EMPTY).iterator()));
}
示例6: testWordCount
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
@Test
public void testWordCount() throws Exception {
// TODO Figure out a way to run M/R with Kerberos
assumeTrue(getAdminToken() instanceof PasswordToken);
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
is = new IteratorSetting(10, SummingCombiner.class);
SummingCombiner.setColumns(is, Collections.singletonList(new IteratorSetting.Column(new Text("count"))));
SummingCombiner.setEncodingType(is, SummingCombiner.Type.STRING);
c.tableOperations().attachIterator(tableName, is);
Path readme = new Path(new Path(System.getProperty("user.dir")).getParent(), "README.md");
if (!new File(readme.toString()).exists()) {
log.info("Not running test: README.md does not exist)");
return;
}
fs.copyFromLocalFile(readme, new Path(dir + "/tmp/wc/README.md"));
String[] args;
args = new String[] {"-c", getConnectionFile(), "--input", dir + "/tmp/wc", "-t", tableName};
goodExec(WordCount.class, args);
}
示例7: testInvalidValueType
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
@Test
public void testInvalidValueType() throws Exception {
Combiner comb = new GlobalIndexUidCombiner();
IteratorSetting setting = new IteratorSetting(1, GlobalIndexUidCombiner.class);
GlobalIndexUidCombiner.setCombineAllColumns(setting, true);
GlobalIndexUidCombiner.setLossyness(setting, true);
comb.init(null, setting.getOptions(), null);
Logger.getLogger(GlobalIndexUidCombiner.class).setLevel(Level.OFF);
Value val = new Value(UUID.randomUUID().toString().getBytes());
values.add(val);
Value result = comb.reduce(new Key(), values.iterator());
Uid.List resultList = Uid.List.parseFrom(result.get());
assertTrue(resultList.getIGNORE() == false);
assertTrue(resultList.getUIDCount() == 0);
assertTrue(resultList.getCOUNT() == 0);
}
示例8: removeIterators
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
private void removeIterators(
final String tablename,
final Connector connector )
throws AccumuloSecurityException,
AccumuloException,
TableNotFoundException {
connector.tableOperations().removeIterator(
tablename,
new IteratorSetting(
FeatureCollectionDataAdapter.ARRAY_TO_ELEMENTS_PRIORITY,
ArrayToElementsIterator.class).getName(),
EnumSet.of(IteratorScope.scan));
connector.tableOperations().removeIterator(
tablename,
new IteratorSetting(
FeatureCollectionDataAdapter.ELEMENTS_TO_ARRAY_PRIORITY,
ElementsToArrayIterator.class).getName(),
EnumSet.of(IteratorScope.scan));
}
示例9: detachIterators
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
public static void detachIterators(
final String tablename,
final Connector connector )
throws AccumuloSecurityException,
AccumuloException,
TableNotFoundException {
connector.tableOperations().removeIterator(
tablename,
new IteratorSetting(
FeatureCollectionDataAdapter.ARRAY_TO_ELEMENTS_PRIORITY,
ArrayToElementsIterator.class).getName(),
EnumSet.of(IteratorScope.scan));
connector.tableOperations().removeIterator(
tablename,
new IteratorSetting(
FeatureCollectionDataAdapter.ELEMENTS_TO_ARRAY_PRIORITY,
ElementsToArrayIterator.class).getName(),
EnumSet.of(IteratorScope.scan));
}
示例10: setAdditionalIterators
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
public void setAdditionalIterators(IteratorSetting... additionalIterators){
//TODO do we need to worry about cleaning up
this.set(ITERATOR_SETTINGS_SIZE, Integer.toString(additionalIterators.length));
int i = 0;
for(IteratorSetting iterator : additionalIterators) {
this.set(String.format(ITERATOR_SETTINGS_NAME, i), iterator.getName());
this.set(String.format(ITERATOR_SETTINGS_CLASS, i), iterator.getIteratorClass());
this.set(String.format(ITERATOR_SETTINGS_PRIORITY, i), Integer.toString(iterator.getPriority()));
Map<String, String> options = iterator.getOptions();
this.set(String.format(ITERATOR_SETTINGS_OPTIONS_SIZE, i), Integer.toString(options.size()));
Iterator<Entry<String, String>> it = options.entrySet().iterator();
int j = 0;
while(it.hasNext()) {
Entry<String, String> item = it.next();
this.set(String.format(ITERATOR_SETTINGS_OPTIONS_KEY, i, j), item.getKey());
this.set(String.format(ITERATOR_SETTINGS_OPTIONS_VALUE, i, j), item.getValue());
j++;
}
i++;
}
}
示例11: getAdditionalIterators
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
public IteratorSetting[] getAdditionalIterators(){
int size = Integer.valueOf(this.get(ITERATOR_SETTINGS_SIZE, "0"));
if(size == 0) {
return new IteratorSetting[0];
}
IteratorSetting[] settings = new IteratorSetting[size];
for(int i = 0; i < size; i++) {
String name = this.get(String.format(ITERATOR_SETTINGS_NAME, i));
String iteratorClass = this.get(String.format(ITERATOR_SETTINGS_CLASS, i));
int priority = Integer.valueOf(this.get(String.format(ITERATOR_SETTINGS_PRIORITY, i)));
int optionsSize = Integer.valueOf(this.get(String.format(ITERATOR_SETTINGS_OPTIONS_SIZE, i)));
Map<String, String> options = new HashMap<>(optionsSize);
for(int j = 0; j < optionsSize; j++) {
String key = this.get(String.format(ITERATOR_SETTINGS_OPTIONS_KEY, i, j));
String value = this.get(String.format(ITERATOR_SETTINGS_OPTIONS_VALUE, i, j));
options.put(key, value);
}
settings[i] = new IteratorSetting(priority, name, iteratorClass, options);
}
return settings;
}
示例12: setupIterators
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
@Override
protected void setupIterators(final TaskAttemptContext context,
final Scanner scanner, final String tableName,
final org.apache.accumulo.core.client.mapreduce.RangeInputSplit split) {
List<IteratorSetting> iterators = null;
if (null == split) {
iterators = contextIterators(context, tableName);
} else {
iterators = split.getIterators();
if (null == iterators) {
iterators = contextIterators(context, tableName);
}
}
for (final IteratorSetting iterator : iterators) {
scanner.addScanIterator(iterator);
}
}
示例13: setupAccumuloInput
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
/**
* Sets up Accumulo input for a job: the job receives
* ({@link org.apache.accumulo.core.data.Key},
* {@link org.apache.accumulo.core.data.Value}) pairs from the table
* specified by the configuration (using
* {@link MRUtils#TABLE_PREFIX_PROPERTY} and
* {@link MRUtils#TABLE_LAYOUT_PROP}).
* @param job MapReduce Job to configure
* @throws AccumuloSecurityException if connecting to Accumulo with the
* given username and password fails.
*/
protected void setupAccumuloInput(Job job) throws AccumuloSecurityException {
// set up accumulo input
if (!hdfsInput) {
job.setInputFormatClass(AccumuloInputFormat.class);
} else {
job.setInputFormatClass(AccumuloHDFSFileInputFormat.class);
}
AccumuloInputFormat.setConnectorInfo(job, userName, new PasswordToken(pwd));
String tableName = RdfCloudTripleStoreUtils.layoutPrefixToTable(rdfTableLayout, tablePrefix);
AccumuloInputFormat.setInputTableName(job, tableName);
AccumuloInputFormat.setScanAuthorizations(job, authorizations);
if (mock) {
AccumuloInputFormat.setMockInstance(job, instance);
} else {
ClientConfiguration clientConfig = ClientConfiguration.loadDefault()
.withInstance(instance).withZkHosts(zk);
AccumuloInputFormat.setZooKeeperInstance(job, clientConfig);
}
if (ttl != null) {
IteratorSetting setting = new IteratorSetting(1, "fi", AgeOffFilter.class.getName());
AgeOffFilter.setTTL(setting, Long.valueOf(ttl));
AccumuloInputFormat.addIterator(job, setting);
}
}
示例14: printTable
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
/**
* Prints the table with the specified config and additional settings.
* @param tableName the name of the table to print.
* @param config the {@link AccumuloRdfConfiguration}.
* @param shouldAddCommonIterators {@code true} to add the common iterators to the table scanner.
* {@code false} otherwise.
* @param settings the additional {@link IteratorSetting}s to add besides the common ones.
* @throws IOException
*/
public static void printTable(final String tableName, final AccumuloRdfConfiguration config, final boolean shouldAddCommonIterators, final IteratorSetting... settings) throws IOException {
final Scanner scanner = AccumuloRyaUtils.getScanner(tableName, config, shouldAddCommonIterators);
for (final IteratorSetting setting : settings) {
scanner.addScanIterator(setting);
}
final Iterator<Entry<Key, Value>> iterator = scanner.iterator();
final String instance = config.get(MRUtils.AC_INSTANCE_PROP);
log.info("==================");
log.info("TABLE: " + tableName + " INSTANCE: " + instance);
log.info("------------------");
while (iterator.hasNext()) {
final Entry<Key, Value> entry = iterator.next();
final Key key = entry.getKey();
final Value value = entry.getValue();
final String keyString = getFormattedKeyString(key);
log.info(keyString + " - " + value);
}
log.info("==================");
}
示例15: printTablePretty
import org.apache.accumulo.core.client.IteratorSetting; //导入依赖的package包/类
/**
* Prints the table with pretty formatting using the specified config and additional settings.
* @param tableName the name of the table to print.
* @param config the {@link AccumuloRdfConfiguration}.
* @param shouldAddCommonIterators {@code true} to add the common iterators to the table scanner.
* {@code false} otherwise.
* @param settings the additional {@link IteratorSetting}s to add besides the common ones.
* @throws IOException
*/
public static void printTablePretty(final String tableName, final Configuration config, final boolean shouldAddCommonIterators, final IteratorSetting... settings) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, IOException {
final Scanner scanner = AccumuloRyaUtils.getScanner(tableName, config, shouldAddCommonIterators);
for (final IteratorSetting setting : settings) {
scanner.addScanIterator(setting);
}
final String format = "| %-64s | %-24s | %-28s | %-20s | %-20s | %-10s |";
final int totalFormatLength = String.format(format, 1, 2, 3, 4, 5, 6).length();
final String instance = config.get(MRUtils.AC_INSTANCE_PROP);
log.info(StringUtils.rightPad("==================", totalFormatLength, "="));
log.info(StringUtils.rightPad("| TABLE: " + tableName + " INSTANCE: " + instance, totalFormatLength - 1) + "|");
log.info(StringUtils.rightPad("------------------", totalFormatLength, "-"));
log.info(String.format(format, "--Row--", "--ColumnVisibility--", "--Timestamp--", "--ColumnFamily--", "--ColumnQualifier--", "--Value--"));
log.info(StringUtils.rightPad("|-----------------", totalFormatLength - 1, "-") + "|");
for (final Entry<Key, Value> entry : scanner) {
final Key k = entry.getKey();
final String rowString = Key.appendPrintableString(k.getRow().getBytes(), 0, k.getRow().getLength(), Constants.MAX_DATA_TO_PRINT, new StringBuilder()).toString();
log.info(String.format(format, rowString, k.getColumnVisibility(), new Date(k.getTimestamp()), k.getColumnFamily(), k.getColumnQualifier(), entry.getValue()));
}
log.info(StringUtils.rightPad("==================", totalFormatLength, "="));
}