use of org.apache.accumulo.core.dataImpl.thrift.IterInfo in project accumulo by apache.
the class ClientSideIteratorScanner method iterator.
@Override
public Iterator<Entry<Key, Value>> iterator() {
smi.scanner.setBatchSize(size);
smi.scanner.setTimeout(timeOut, MILLISECONDS);
smi.scanner.setBatchTimeout(batchTimeOut, MILLISECONDS);
smi.scanner.setReadaheadThreshold(readaheadThreshold);
if (isolated)
smi.scanner.enableIsolation();
else
smi.scanner.disableIsolation();
smi.samplerConfig = getSamplerConfiguration();
final TreeMap<Integer, IterInfo> tm = new TreeMap<>();
for (IterInfo iterInfo : serverSideIteratorList) {
tm.put(iterInfo.getPriority(), iterInfo);
}
SortedKeyValueIterator<Key, Value> skvi;
try {
IteratorEnvironment env = new ClientSideIteratorEnvironment(getSamplerConfiguration() != null, getIteratorSamplerConfigurationInternal());
IterLoad iterLoad = new IterLoad().iters(tm.values()).iterOpts(serverSideIteratorOptions).iterEnv(env).useAccumuloClassLoader(false);
skvi = IterConfigUtil.loadIterators(smi, iterLoad);
} catch (IOException e) {
throw new RuntimeException(e);
}
final Set<ByteSequence> colfs = new TreeSet<>();
for (Column c : this.getFetchedColumns()) {
colfs.add(new ArrayByteSequence(c.getColumnFamily()));
}
try {
skvi.seek(range, colfs, true);
} catch (IOException e) {
throw new RuntimeException(e);
}
return new IteratorAdapter(skvi);
}
use of org.apache.accumulo.core.dataImpl.thrift.IterInfo in project accumulo by apache.
the class CompressedIterators method decompress.
public IterConfig decompress(ByteBuffer iterators) {
IterConfig config = new IterConfig();
UnsynchronizedBuffer.Reader in = new UnsynchronizedBuffer.Reader(iterators);
int num = in.readVInt();
for (int i = 0; i < num; i++) {
String name = symbolTable.get(in.readVInt());
String iterClass = symbolTable.get(in.readVInt());
int prio = in.readVInt();
config.ssiList.add(new IterInfo(prio, iterClass, name));
int numOpts = in.readVInt();
HashMap<String, String> opts = new HashMap<>();
for (int j = 0; j < numOpts; j++) {
String key = symbolTable.get(in.readVInt());
String val = symbolTable.get(in.readVInt());
opts.put(key, val);
}
config.ssio.put(name, opts);
}
return config;
}
use of org.apache.accumulo.core.dataImpl.thrift.IterInfo in project accumulo by apache.
the class VerifyTabletAssignments method checkTabletServer.
private static void checkTabletServer(ClientContext context, Entry<HostAndPort, List<KeyExtent>> entry, HashSet<KeyExtent> failures) throws ThriftSecurityException, TException, NoSuchScanIDException {
TabletClientService.Iface client = ThriftUtil.getTServerClient(entry.getKey(), context);
Map<TKeyExtent, List<TRange>> batch = new TreeMap<>();
for (KeyExtent keyExtent : entry.getValue()) {
Text row = keyExtent.endRow();
Text row2 = null;
if (row == null) {
row = keyExtent.prevEndRow();
if (row != null) {
row = new Text(row);
row.append(new byte[] { 'a' }, 0, 1);
} else {
row = new Text("1234567890");
}
row2 = new Text(row);
row2.append(new byte[] { '!' }, 0, 1);
} else {
row = new Text(row);
row2 = new Text(row);
row.getBytes()[row.getLength() - 1] = (byte) (row.getBytes()[row.getLength() - 1] - 1);
}
Range r = new Range(row, true, row2, false);
batch.put(keyExtent.toThrift(), Collections.singletonList(r.toThrift()));
}
TInfo tinfo = TraceUtil.traceInfo();
Map<String, Map<String, String>> emptyMapSMapSS = Collections.emptyMap();
List<IterInfo> emptyListIterInfo = Collections.emptyList();
List<TColumn> emptyListColumn = Collections.emptyList();
InitialMultiScan is = client.startMultiScan(tinfo, context.rpcCreds(), batch, emptyListColumn, emptyListIterInfo, emptyMapSMapSS, Authorizations.EMPTY.getAuthorizationsBB(), false, null, 0L, null, null);
if (is.result.more) {
MultiScanResult result = client.continueMultiScan(tinfo, is.scanID);
checkFailures(entry.getKey(), failures, result);
while (result.more) {
result = client.continueMultiScan(tinfo, is.scanID);
checkFailures(entry.getKey(), failures, result);
}
}
client.closeMultiScan(tinfo, is.scanID);
ThriftUtil.returnClient((TServiceClient) client, context);
}
use of org.apache.accumulo.core.dataImpl.thrift.IterInfo in project accumulo by apache.
the class MetadataLocationObtainer method lookupTablet.
@Override
public TabletLocations lookupTablet(ClientContext context, TabletLocation src, Text row, Text stopRow, TabletLocator parent) throws AccumuloSecurityException, AccumuloException {
try {
OpTimer timer = null;
if (log.isTraceEnabled()) {
log.trace("tid={} Looking up in {} row={} extent={} tserver={}", Thread.currentThread().getId(), src.tablet_extent.tableId(), TextUtil.truncate(row), src.tablet_extent, src.tablet_location);
timer = new OpTimer().start();
}
Range range = new Range(row, true, stopRow, true);
TreeMap<Key, Value> encodedResults = new TreeMap<>();
TreeMap<Key, Value> results = new TreeMap<>();
// Use the whole row iterator so that a partial mutations is not read. The code that extracts
// locations for tablets does a sanity check to ensure there is
// only one location. Reading a partial mutation could make it appear there are multiple
// locations when there are not.
List<IterInfo> serverSideIteratorList = new ArrayList<>();
serverSideIteratorList.add(new IterInfo(10000, WholeRowIterator.class.getName(), "WRI"));
Map<String, Map<String, String>> serverSideIteratorOptions = Collections.emptyMap();
boolean more = ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, 0L, null);
decodeRows(encodedResults, results);
if (more && results.size() == 1) {
range = new Range(results.lastKey().followingKey(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME), true, new Key(stopRow).followingKey(PartialKey.ROW), false);
encodedResults.clear();
more = ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, 0L, null);
decodeRows(encodedResults, results);
}
if (timer != null) {
timer.stop();
log.trace("tid={} Got {} results from {} in {}", Thread.currentThread().getId(), results.size(), src.tablet_extent, String.format("%.3f secs", timer.scale(SECONDS)));
}
return MetadataLocationObtainer.getMetadataLocationEntries(results);
} catch (AccumuloServerException ase) {
if (log.isTraceEnabled())
log.trace("{} lookup failed, {} server side exception", src.tablet_extent.tableId(), src.tablet_location);
throw ase;
} catch (AccumuloException e) {
if (log.isTraceEnabled())
log.trace("{} lookup failed", src.tablet_extent.tableId(), e);
parent.invalidateCache(context, src.tablet_location);
}
return null;
}
use of org.apache.accumulo.core.dataImpl.thrift.IterInfo in project accumulo by apache.
the class CompactionInfo method toThrift.
public ActiveCompaction toThrift() {
TCompactionType type;
if (compactor.hasIMM())
if (!compactor.getFilesToCompact().isEmpty())
type = TCompactionType.MERGE;
else
type = TCompactionType.MINOR;
else if (!compactor.willPropagateDeletes())
type = TCompactionType.FULL;
else
type = TCompactionType.MAJOR;
List<IterInfo> iiList = new ArrayList<>();
Map<String, Map<String, String>> iterOptions = new HashMap<>();
for (IteratorSetting iterSetting : compactor.getIterators()) {
iiList.add(new IterInfo(iterSetting.getPriority(), iterSetting.getIteratorClass(), iterSetting.getName()));
iterOptions.put(iterSetting.getName(), iterSetting.getOptions());
}
List<String> files = compactor.getFilesToCompact().stream().map(StoredTabletFile::getPathStr).collect(Collectors.toList());
return new ActiveCompaction(compactor.extent.toThrift(), System.currentTimeMillis() - compactor.getStartTime(), files, compactor.getOutputFile(), type, reason, localityGroup, entriesRead, entriesWritten, iiList, iterOptions);
}
Aggregations