@Override
  public void init() {
    // Reading all the labels and ordinal.
    // This scan should be done by user with global_admin privileges.. Ensure that it works
    Table labelsTable = null;
    Connection connection = null;
    try {
      connection = ConnectionFactory.createConnection(conf);
      try {
        labelsTable = connection.getTable(LABELS_TABLE_NAME);
      } catch (IOException e) {
        LOG.error("Error opening 'labels' table", e);
        return;
      }
      Scan scan = new Scan();
      scan.setAuthorizations(new Authorizations(VisibilityUtils.SYSTEM_LABEL));
      scan.addColumn(LABELS_TABLE_FAMILY, LABEL_QUALIFIER);
      ResultScanner scanner = null;
      try {
        scanner = labelsTable.getScanner(scan);
        Result next = null;
        while ((next = scanner.next()) != null) {
          byte[] row = next.getRow();
          byte[] value = next.getValue(LABELS_TABLE_FAMILY, LABEL_QUALIFIER);
          labels.put(Bytes.toString(value), Bytes.toInt(row));
        }
      } catch (TableNotFoundException e) {
        // Table not found. So just return
        return;
      } catch (IOException e) {
        LOG.error("Error scanning 'labels' table", e);
      } finally {
        if (scanner != null) {
          scanner.close();
        }
      }
    } catch (IOException ioe) {
      LOG.error("Failed reading 'labels' tags", ioe);
      return;
    } finally {
      if (labelsTable != null) {
        try {
          labelsTable.close();
        } catch (IOException ioe) {
          LOG.warn("Error closing 'labels' table", ioe);
        }
      }
      if (connection != null) {
        try {
          connection.close();
        } catch (IOException ioe) {
          LOG.warn("Failed close of temporary connection", ioe);
        }
      }
    }
  }
This implementation creates tags by expanding expression using label ordinal. Labels will be
serialized in sorted order of it's ordinal.
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/DefaultVisibilityExpressionResolver.java