use of org.apache.accumulo.core.client.impl.TabletLocator.TabletLocations in project accumulo by apache.
the class MetadataLocationObtainer method getMetadataLocationEntries.
public static TabletLocations getMetadataLocationEntries(SortedMap<Key, Value> entries) {
Key key;
Value val;
Text location = null;
Text session = null;
Value prevRow = null;
KeyExtent ke;
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 = entry.getKey();
val = entry.getValue();
if (key.compareRow(lastRowFromKey) != 0) {
prevRow = null;
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(TabletsSection.CurrentLocationColumnFamily.NAME) || colf.equals(TabletsSection.FutureLocationColumnFamily.NAME)) {
if (location != null) {
throw new IllegalStateException("Tablet has multiple locations : " + lastRowFromKey);
}
location = new Text(val.toString());
session = new Text(colq);
} else if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.equals(colf, colq)) {
prevRow = new Value(val);
}
if (prevRow != null) {
ke = new KeyExtent(key.getRow(), prevRow);
if (location != null)
results.add(new TabletLocation(ke, location.toString(), session.toString()));
else
locationless.add(ke);
location = null;
prevRow = null;
}
}
return new TabletLocations(results, locationless);
}
Aggregations