/**
 * Copyright 2011-2015 Asakusa Framework Team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.asakusafw.spark.compiler.planning;

import com.asakusafw.lang.compiler.planning.SubPlan;

/**
 * Estimated data-set size information.
 */
public class SizeInfo {

    /**
     * Represents information of not sure.
     */
    public static final SizeInfo UNKNOWN = new SizeInfo(Double.NaN);

    private final double size;

    /**
     * Creates a new instance.
     * @param size the estimated data-set size in bytes
     */
    public SizeInfo(double size) {
        this.size = size;
    }

    /**
     * Returns the estimated size.
     * @return the estimated size (in bytes), or {@code Double.NaN} if the target size is not sure
     */
    public double getSize() {
        return size;
    }

    /**
     * Returns the estimated size for the target sub-plan input/output.
     * @param port the target port
     * @return the estimated size (in bytes), or {@code Double.NaN} if the target size is not sure
     */
    public static double getSize(SubPlan.Port port) {
        SizeInfo info = port.getAttribute(SizeInfo.class);
        if (info != null) {
            return info.getSize();
        }
        return Double.NaN;
    }

    @Override
    public String toString() {
        if (Double.isNaN(size)) {
            return "N/A";
        } else {
            return String.format("%.2fbytes", size); //$NON-NLS-1$
        }
    }
}

@@ -1868,16 +1868,103 @@
  %22N/A%22;%0A
+        %7D else if (Double.isInfinite(size)) %7B%0A            return String.valueOf(size);%0A
         
@@ -2011,10 +2011,11 @@
 t(%22%25
-.2
+,.0
 fbyt

Revise SizeInfo.toString().