/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 org.apache.asterix.formats.nontagged;

import org.apache.asterix.dataflow.data.nontagged.keynormalizers.AWrappedAscNormalizedKeyComputerFactory;
import org.apache.asterix.dataflow.data.nontagged.keynormalizers.AWrappedDescNormalizedKeyComputerFactory;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.data.INormalizedKeyComputerFactoryProvider;
import org.apache.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
import org.apache.hyracks.dataflow.common.data.normalizers.ByteArrayNormalizedKeyComputerFactory;
import org.apache.hyracks.dataflow.common.data.normalizers.DoubleNormalizedKeyComputerFactory;
import org.apache.hyracks.dataflow.common.data.normalizers.FloatNormalizedKeyComputerFactory;
import org.apache.hyracks.dataflow.common.data.normalizers.Integer64NormalizedKeyComputerFactory;
import org.apache.hyracks.dataflow.common.data.normalizers.IntegerNormalizedKeyComputerFactory;
import org.apache.hyracks.dataflow.common.data.normalizers.UTF8StringNormalizedKeyComputerFactory;

public class AqlNormalizedKeyComputerFactoryProvider implements INormalizedKeyComputerFactoryProvider {

    public static final AqlNormalizedKeyComputerFactoryProvider INSTANCE = new AqlNormalizedKeyComputerFactoryProvider();

    private AqlNormalizedKeyComputerFactoryProvider() {
    }

    @Override
    public INormalizedKeyComputerFactory getNormalizedKeyComputerFactory(Object type, boolean ascending) {
        IAType aqlType = (IAType) type;
        if (ascending) {
            switch (aqlType.getTypeTag()) {
                case DATE:
                case TIME:
                case YEARMONTHDURATION:
                case INT32: {
                    return new AWrappedAscNormalizedKeyComputerFactory(new IntegerNormalizedKeyComputerFactory());
                }
                case DATETIME:
                case DAYTIMEDURATION:
                case INT64: {
                    return new AWrappedAscNormalizedKeyComputerFactory(new Integer64NormalizedKeyComputerFactory());
                }
                case FLOAT: {
                    return new AWrappedAscNormalizedKeyComputerFactory(new FloatNormalizedKeyComputerFactory());
                }
                case DOUBLE: {
                    return new AWrappedAscNormalizedKeyComputerFactory(new DoubleNormalizedKeyComputerFactory());
                }
                case STRING: {
                    return new AWrappedAscNormalizedKeyComputerFactory(new UTF8StringNormalizedKeyComputerFactory());
                }
                case BINARY: {
                    return new AWrappedAscNormalizedKeyComputerFactory(new ByteArrayNormalizedKeyComputerFactory());
                }
                default: {
                    return null;
                }
            }
        } else {
            switch (aqlType.getTypeTag()) {
                case DATE:
                case TIME:
                case YEARMONTHDURATION:
                case INT32: {
                    return new AWrappedDescNormalizedKeyComputerFactory(new IntegerNormalizedKeyComputerFactory());
                }
                case DATETIME:
                case DAYTIMEDURATION:
                case INT64: {
                    return new AWrappedDescNormalizedKeyComputerFactory(new Integer64NormalizedKeyComputerFactory());
                }
                case FLOAT: {
                    return new AWrappedDescNormalizedKeyComputerFactory(new FloatNormalizedKeyComputerFactory());
                }
                case DOUBLE: {
                    return new AWrappedDescNormalizedKeyComputerFactory(new DoubleNormalizedKeyComputerFactory());
                }
                case STRING: {
                    return new AWrappedDescNormalizedKeyComputerFactory(new UTF8StringNormalizedKeyComputerFactory());
                }
                case BINARY: {
                    return new AWrappedDescNormalizedKeyComputerFactory(new ByteArrayNormalizedKeyComputerFactory());
                }
                default: {
                    return null;
                }
            }
        }
    }
}

@@ -2476,35 +2476,33 @@
      case INT32:
- %7B
 %0A
+
                 
@@ -2600,34 +2600,16 @@
 ory());%0A
-                %7D%0A
         
@@ -2688,34 +2688,32 @@
      case INT64:
- %7B
 %0A               
@@ -2814,34 +2814,16 @@
 ory());%0A
-                %7D%0A
         
@@ -2833,34 +2833,32 @@
      case FLOAT:
- %7B
 %0A               
@@ -2955,34 +2955,16 @@
 ory());%0A
-                %7D%0A
         
@@ -2975,34 +2975,32 @@
     case DOUBLE:
- %7B
 %0A               
@@ -3098,34 +3098,16 @@
 ory());%0A
-                %7D%0A
         
@@ -3118,34 +3118,32 @@
     case STRING:
- %7B
 %0A               
@@ -3245,34 +3245,16 @@
 ory());%0A
-                %7D%0A
         
@@ -3265,34 +3265,32 @@
     case BINARY:
- %7B
 %0A               
@@ -3391,34 +3391,16 @@
 ory());%0A
-                %7D%0A
         
@@ -3407,34 +3407,32 @@
         default:
- %7B
 %0A               
@@ -3449,34 +3449,16 @@
 n null;%0A
-                %7D%0A
         
@@ -3645,18 +3645,16 @@
 e INT32:
- %7B
 %0A       
@@ -3762,34 +3762,16 @@
 ory());%0A
-                %7D%0A
         
@@ -3858,18 +3858,16 @@
 e INT64:
- %7B
 %0A       
@@ -3977,34 +3977,16 @@
 ory());%0A
-                %7D%0A
         
@@ -4004,18 +4004,16 @@
 e FLOAT:
- %7B
 %0A       
@@ -4119,34 +4119,16 @@
 ory());%0A
-                %7D%0A
         
@@ -4147,18 +4147,16 @@
  DOUBLE:
- %7B
 %0A       
@@ -4263,34 +4263,16 @@
 ory());%0A
-                %7D%0A
         
@@ -4291,18 +4291,16 @@
  STRING:
- %7B
 %0A       
@@ -4411,34 +4411,16 @@
 ory());%0A
-                %7D%0A
         
@@ -4439,18 +4439,16 @@
  BINARY:
- %7B
 %0A       
@@ -4558,34 +4558,16 @@
 ory());%0A
-                %7D%0A
         
@@ -4582,18 +4582,16 @@
 default:
- %7B
 %0A       
@@ -4620,26 +4620,8 @@
 ll;%0A
-                %7D%0A
     

remove more useless curly braces