[Demonstration 1]

[Buggy Method]
public static void main(String[] args) {
    // int[] a = new int[] { 32, 16, 15, 18, 2, 40, 3, 38 };
    int[] a = new int[] { 6, 2, 3, 4, 1, 6, 7, 7, 4, 4, 1, 2, 1 };
    // System.out.println(partition(a, 0, a.length));
    // System.out.println(Arrays.toString(a));
    /*
		 
		int[] a = new int[] { 406, 157, 415, 318, 472, 46, 252, 187, 364, 481, 450, 90, 390, 35, 452, 74, 196, 312, 142,
				160, 143, 220, 483, 392, 443, 488, 79, 234, 68, 150, 356, 496, 69, 88, 177, 12, 288, 120, 222, 270, 441,
				422, 103, 321, 65, 316, 448, 331, 117, 183, 184, 128, 323, 141, 467, 31, 172, 48, 95, 359, 239, 209,
				398, 99, 440, 171, 86, 233, 293, 162, 121, 61, 317, 52, 54, 273, 30, 226, 421, 64, 204, 444, 418, 275,
				263, 108, 10, 149, 497, 20, 97, 136, 139, 200, 266, 238, 493, 22, 17, 39 }; 
				
		*/
    quicksort(a, 0, a.length - 1);
    System.out.println(Arrays.toString(a));
}

[Buggy Hunk]
int[] a = new int[] { 6, 2, 3, 4, 1, 6, 7, 7, 4, 4, 1, 2, 1 };

[Patch]
int[] a = new int[] { 37, 25, 42, 16, 48, 39, 63 };

[Demonstration 2]

[Buggy Method]
@Override
public void addPartitions(String databaseName, String tableName, List<CatalogProtos.PartitionDescProto> partitions, boolean ifNotExists) {
    HiveCatalogStoreClientPool.HiveCatalogStoreClient client = null;
    List<Partition> addPartitions = TUtil.newList();
    CatalogProtos.PartitionDescProto existingPartition = null;
    try {
        client = clientPool.getClient();
        for (CatalogProtos.PartitionDescProto partitionDescProto : partitions) {
            existingPartition = getPartition(databaseName, tableName, partitionDescProto.getPartitionName());
            // Unfortunately, hive client add_partitions doesn't run as expected. The method never read the ifNotExists
            // parameter. So, if Tajo adds existing partition to Hive, it will threw AlreadyExistsException. To avoid
            // above error, we need to filter existing partitions before call add_partitions.
            if (existingPartition != null) {
                Partition partition = new Partition();
                partition.setDbName(databaseName);
                partition.setTableName(tableName);
                List<String> values = Lists.newArrayList();
                for (CatalogProtos.PartitionKeyProto keyProto : partitionDescProto.getPartitionKeysList()) {
                    values.add(keyProto.getPartitionValue());
                }
                partition.setValues(values);
                Table table = client.getHiveClient().getTable(databaseName, tableName);
                StorageDescriptor sd = table.getSd();
                sd.setLocation(partitionDescProto.getPath());
                partition.setSd(sd);
                addPartitions.add(partition);
            }
        }
        if (addPartitions.size() > 0) {
            client.getHiveClient().add_partitions(addPartitions, true, true);
        }
    } catch (Exception e) {
        throw new TajoInternalError(e);
    } finally {
        if (client != null) {
            client.release();
        }
    }
}

[Buggy Hunk]
if (existingPartition != null) {

[Patch]
if (existingPartition == null) {

[Demonstration 3]

[Buggy Method]
protected void partition() throws PartitionException {
    if (!this.isLeafNode()) {
        throw new PartitionException("Cannot partition a non-leaf node.");
    }
    if (!this.isEmpty()) {
        @SuppressWarnings("unchecked")
        T[] pointArray = this.points.toArray((T[]) Array.newInstance(points.iterator().next().getClass(), 0));
        this.partition(pointArray, 0, pointArray.length);
    } else {
        throw new PartitionException("Cannot partition an empty node.");
    }
}

[Buggy Hunk]
protected void partition() throws PartitionException {

[Patch]
public void partition() throws PartitionException {