class ThriftListenerUtils {

  public static List<ObjectPair<Integer, byte[]>> toObjectPairs(Table table, List<Partition> partitions) {
    List<ObjectPair<Integer, byte[]>> pairs = new ArrayList<>(partitions.size());
    for (Partition partition : partitions) {
      Map<String, String> partitionSpec = Warehouse.makeSpecFromValues(table.getPartitionKeys(), partition.getValues());
      ExprNodeGenericFuncDesc partitionExpression;
      try {
        partitionExpression = new ExpressionBuilder(table, partitionSpec).build();
      } catch (SemanticException e) {
        throw new RuntimeException("Unable to build expression", e);
      }
      ObjectPair<Integer, byte[]> serializedPartitionExpression = new ObjectPair<>(partitionSpec.size(),
          SerializationUtilities.serializeExpressionToKryo(partitionExpression));
      pairs.add(serializedPartitionExpression);
    }
    return pairs;
  }

  private  ThriftListenerUtils();

}