Search in sources :

Example 1 with TabletLocations

use of org.apache.accumulo.core.clientImpl.TabletLocator.TabletLocations in project accumulo by apache.

the class MetadataLocationObtainer method getMetadataLocationEntries.

public static TabletLocations getMetadataLocationEntries(SortedMap<Key, Value> entries) {
    Text location = null;
    Text session = null;
    List<TabletLocation> results = new ArrayList<>();
    ArrayList<KeyExtent> locationless = new ArrayList<>();
    Text lastRowFromKey = new Text();
    // text obj below is meant to be reused in loop for efficiency
    Text colf = new Text();
    Text colq = new Text();
    for (Entry<Key, Value> entry : entries.entrySet()) {
        Key key = entry.getKey();
        Value val = entry.getValue();
        if (key.compareRow(lastRowFromKey) != 0) {
            location = null;
            session = null;
            key.getRow(lastRowFromKey);
        }
        colf = key.getColumnFamily(colf);
        colq = key.getColumnQualifier(colq);
        // interpret the row id as a key extent
        if (colf.equals(CurrentLocationColumnFamily.NAME) || colf.equals(FutureLocationColumnFamily.NAME)) {
            if (location != null) {
                throw new IllegalStateException("Tablet has multiple locations : " + lastRowFromKey);
            }
            location = new Text(val.toString());
            session = new Text(colq);
        } else if (TabletColumnFamily.PREV_ROW_COLUMN.equals(colf, colq)) {
            KeyExtent ke = KeyExtent.fromMetaPrevRow(entry);
            if (location != null)
                results.add(new TabletLocation(ke, location.toString(), session.toString()));
            else
                locationless.add(ke);
            location = null;
        }
    }
    return new TabletLocations(results, locationless);
}
Also used : TabletLocations(org.apache.accumulo.core.clientImpl.TabletLocator.TabletLocations) TabletLocation(org.apache.accumulo.core.clientImpl.TabletLocator.TabletLocation) ArrayList(java.util.ArrayList) Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey)

Aggregations

ArrayList (java.util.ArrayList)1 TabletLocation (org.apache.accumulo.core.clientImpl.TabletLocator.TabletLocation)1 TabletLocations (org.apache.accumulo.core.clientImpl.TabletLocator.TabletLocations)1 Key (org.apache.accumulo.core.data.Key)1 PartialKey (org.apache.accumulo.core.data.PartialKey)1 Value (org.apache.accumulo.core.data.Value)1 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)1 Text (org.apache.hadoop.io.Text)1