docs: private Optional<String> getTabletLocation(String table, Key key)
      {
          try {
              // Get the Accumulo table ID so we can scan some fun stuff
              String tableId = connector.tableOperations().tableIdMap().get(table);
  
              // Create our scanner against the metadata table, fetching 'loc' family
              Scanner scanner = connector.createScanner("accumulo.metadata", auths);
              scanner.fetchColumnFamily(new Text("loc"));
  
              // Set the scan range to just this table, from the table ID to the default tablet
              // row, which is the last listed tablet
              Key defaultTabletRow = new Key(tableId + '<');
              Key start = new Key(tableId);
              Key end = defaultTabletRow.followingKey(PartialKey.ROW);
              scanner.setRange(new Range(start, end));
  
              Optional<String> location = Optional.empty();
              if (key == null) {
                  // if the key is null, then it is -inf, so get first tablet location
                  Iterator<Entry<Key, Value>> iter = scanner.iterator();
                  if (iter.hasNext()) {
                      location = Optional.of(iter.next().getValue().toString());
                  }
              }
              else {
                  // Else, we will need to scan through the tablet location data and find the location
  
                  // Create some text objects to do comparison for what we are looking for
                  Text splitCompareKey = new Text();
                  key.getRow(splitCompareKey);
                  Text scannedCompareKey = new Text();
  
                  // Scan the table!
                  for (Entry<Key, Value> entry : scanner) {
                      // Get the bytes of the key
                      byte[] keyBytes = entry.getKey().getRow().copyBytes();
  
                      // If the last byte is <, then we have hit the default tablet, so use this location
                      if (keyBytes[keyBytes.length - 1] == '<') {
                          location = Optional.of(entry.getValue().toString());
                          break;
                      }
                      else {
                          // Chop off some magic nonsense
                          scannedCompareKey.set(keyBytes, 3, keyBytes.length - 3);
  
                          // Compare the keys, moving along the tablets until the location is found
                          if (scannedCompareKey.getLength() > 0) {
                              int compareTo = splitCompareKey.compareTo(scannedCompareKey);
                              if (compareTo <= 0) {
                                  location = Optional.of(entry.getValue().toString());
                              }
                              else {
                                  // all future tablets will be greater than this key
                                  break;
                              }
                          }
                      }
                  }
                  scanner.close();
              }
  
              // If we were unable to find the location for some reason, return the default tablet
              // location
              return location.isPresent() ? location : getDefaultTabletLocation(table);
          }
          catch (Exception e) {
              // Swallow this exception so the query does not fail due to being unable
              // to locate the tablet server for the provided Key.
              // This is purely an optimization, but we will want to log the error.
              LOG.error("Failed to get tablet location, returning dummy location", e);
              return Optional.empty();
          }
      }