use of org.apache.accumulo.core.data.Column in project accumulo by apache.
the class ProxyServer method getActiveScans.
@Override
public List<org.apache.accumulo.proxy.thrift.ActiveScan> getActiveScans(ByteBuffer login, String tserver) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
List<org.apache.accumulo.proxy.thrift.ActiveScan> result = new ArrayList<>();
try {
List<ActiveScan> activeScans = getConnector(login).instanceOperations().getActiveScans(tserver);
for (ActiveScan scan : activeScans) {
org.apache.accumulo.proxy.thrift.ActiveScan pscan = new org.apache.accumulo.proxy.thrift.ActiveScan();
pscan.client = scan.getClient();
pscan.user = scan.getUser();
pscan.table = scan.getTable();
pscan.age = scan.getAge();
pscan.idleTime = scan.getIdleTime();
pscan.type = ScanType.valueOf(scan.getType().toString());
pscan.state = ScanState.valueOf(scan.getState().toString());
TabletId e = scan.getTablet();
pscan.extent = new org.apache.accumulo.proxy.thrift.KeyExtent(e.getTableId().toString(), TextUtil.getByteBuffer(e.getEndRow()), TextUtil.getByteBuffer(e.getPrevEndRow()));
pscan.columns = new ArrayList<>();
if (scan.getColumns() != null) {
for (Column c : scan.getColumns()) {
org.apache.accumulo.proxy.thrift.Column column = new org.apache.accumulo.proxy.thrift.Column();
column.setColFamily(c.getColumnFamily());
column.setColQualifier(c.getColumnQualifier());
column.setColVisibility(c.getColumnVisibility());
pscan.columns.add(column);
}
}
pscan.iterators = new ArrayList<>();
for (String iteratorString : scan.getSsiList()) {
String[] parts = iteratorString.split("[=,]");
if (parts.length == 3) {
String name = parts[0];
int priority = Integer.parseInt(parts[1]);
String classname = parts[2];
org.apache.accumulo.proxy.thrift.IteratorSetting settings = new org.apache.accumulo.proxy.thrift.IteratorSetting(priority, name, classname, scan.getSsio().get(name));
pscan.iterators.add(settings);
}
}
pscan.authorizations = new ArrayList<>();
if (scan.getAuthorizations() != null) {
for (byte[] a : scan.getAuthorizations()) {
pscan.authorizations.add(ByteBuffer.wrap(a));
}
}
result.add(pscan);
}
return result;
} catch (Exception e) {
handleException(e);
return null;
}
}
use of org.apache.accumulo.core.data.Column in project accumulo by apache.
the class ScannerOptions method fetchColumnFamily.
@Override
public synchronized void fetchColumnFamily(Text col) {
checkArgument(col != null, "col is null");
Column c = new Column(TextUtil.getBytes(col), null, null);
fetchedColumns.add(c);
}
use of org.apache.accumulo.core.data.Column 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, TimeUnit.MILLISECONDS);
smi.scanner.setBatchTimeout(batchTimeOut, TimeUnit.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 {
skvi = IteratorUtil.loadIterators(smi, tm.values(), serverSideIteratorOptions, new ClientSideIteratorEnvironment(getSamplerConfiguration() != null, getIteratorSamplerConfigurationInternal()), false, null);
} 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.data.Column in project accumulo by apache.
the class ColumnFilterTest method test2.
public void test2() throws Exception {
TreeMap<Key, Value> data = new TreeMap<>();
data.put(newKey("r1", "cf1", "cq1"), new Value(""));
data.put(newKey("r1", "cf2", "cq1"), new Value(""));
data.put(newKey("r1", "cf2", "cq2"), new Value(""));
HashSet<Column> columns = new HashSet<>();
columns.add(newColumn("cf1"));
columns.add(newColumn("cf2", "cq1"));
SortedKeyValueIterator<Key, Value> cf = ColumnQualifierFilter.wrap(new SortedMapIterator(data), columns);
cf.seek(new Range(), Collections.emptySet(), false);
Assert.assertTrue(cf.hasTop());
Assert.assertEquals(newKey("r1", "cf1", "cq1"), cf.getTopKey());
cf.next();
Assert.assertTrue(cf.hasTop());
Assert.assertEquals(newKey("r1", "cf2", "cq1"), cf.getTopKey());
cf.next();
Assert.assertFalse(cf.hasTop());
}
use of org.apache.accumulo.core.data.Column in project accumulo by apache.
the class ColumnFilterTest method test1.
public void test1() {
TreeMap<Key, Value> data = new TreeMap<>();
data.put(newKey("r1", "cf1", "cq1"), new Value(""));
data.put(newKey("r1", "cf2", "cq1"), new Value(""));
HashSet<Column> columns = new HashSet<>();
columns.add(newColumn("cf1"));
SortedMapIterator smi = new SortedMapIterator(data);
SortedKeyValueIterator<Key, Value> cf = ColumnQualifierFilter.wrap(smi, columns);
Assert.assertSame(smi, cf);
}
Aggregations