Search in sources :

Example 11 with Column

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;
    }
}
Also used : ActiveScan(org.apache.accumulo.core.client.admin.ActiveScan) ArrayList(java.util.ArrayList) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) TException(org.apache.thrift.TException) NoMoreEntriesException(org.apache.accumulo.proxy.thrift.NoMoreEntriesException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) NamespaceNotEmptyException(org.apache.accumulo.core.client.NamespaceNotEmptyException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Column(org.apache.accumulo.core.data.Column) ScanColumn(org.apache.accumulo.proxy.thrift.ScanColumn) TabletId(org.apache.accumulo.core.data.TabletId)

Example 12 with Column

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);
}
Also used : Column(org.apache.accumulo.core.data.Column)

Example 13 with Column

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);
}
Also used : IteratorAdapter(org.apache.accumulo.core.iterators.IteratorAdapter) IOException(java.io.IOException) TreeMap(java.util.TreeMap) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) Column(org.apache.accumulo.core.data.Column) TreeSet(java.util.TreeSet) Value(org.apache.accumulo.core.data.Value) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) Key(org.apache.accumulo.core.data.Key) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence)

Example 14 with Column

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());
}
Also used : Column(org.apache.accumulo.core.data.Column) Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) HashSet(java.util.HashSet)

Example 15 with Column

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);
}
Also used : Column(org.apache.accumulo.core.data.Column) Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Key(org.apache.accumulo.core.data.Key) HashSet(java.util.HashSet)

Aggregations

Column (org.apache.accumulo.core.data.Column)16 Key (org.apache.accumulo.core.data.Key)10 Value (org.apache.accumulo.core.data.Value)10 HashSet (java.util.HashSet)6 TreeMap (java.util.TreeMap)6 Range (org.apache.accumulo.core.data.Range)6 SortedMapIterator (org.apache.accumulo.core.iterators.SortedMapIterator)5 Text (org.apache.hadoop.io.Text)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Scanner (org.apache.accumulo.core.client.Scanner)3 Test (org.junit.Test)3 TreeSet (java.util.TreeSet)2 BatchScanner (org.apache.accumulo.core.client.BatchScanner)2 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)2 ByteSequence (org.apache.accumulo.core.data.ByteSequence)2 IteratorAdapter (org.apache.accumulo.core.iterators.IteratorAdapter)2 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1