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);
}
Aggregations