public static ParsedScrollId parseScrollId(String scrollId) {
try {
scrollId = Unicode.fromBytes(Base64.decode(scrollId, Base64.URL_SAFE));
} catch (IOException e) {
throw new ElasticSearchIllegalArgumentException("Failed to decode scrollId", e);
}
String[] elements = Strings.splitStringToArray(scrollId, ';');
int index = 0;
String type = elements[index++];
int contextSize = Integer.parseInt(elements[index++]);
@SuppressWarnings({"unchecked"}) Tuple<String, Long>[] context = new Tuple[contextSize];
for (int i = 0; i < contextSize; i++) {
String element = elements[index++];
int sep = element.indexOf(':');
if (sep == -1) {
throw new ElasticSearchIllegalArgumentException("Malformed scrollId [" + scrollId + "]");
}
context[i] = new Tuple<String, Long>(element.substring(sep + 1), Long.parseLong(element.substring(0, sep)));
}
Map<String, String> attributes;
int attributesSize = Integer.parseInt(elements[index++]);