Github user navis commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/426#discussion_r26909337
  
    --- Diff: 
tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/VectorizedSorter.java
 ---
    @@ -0,0 +1,210 @@
    +/**
    + * 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.tajo.engine.planner.physical;
    +
    +import com.google.common.primitives.Booleans;
    +import com.google.common.primitives.Doubles;
    +import com.google.common.primitives.Floats;
    +import com.google.common.primitives.Ints;
    +import com.google.common.primitives.Longs;
    +import com.google.common.primitives.Shorts;
    +import org.apache.hadoop.util.IndexedSortable;
    +import org.apache.hadoop.util.QuickSort;
    +import org.apache.tajo.catalog.SortSpec;
    +import org.apache.tajo.common.TajoDataTypes;
    +import org.apache.tajo.datum.Datum;
    +import org.apache.tajo.datum.IntervalDatum;
    +import org.apache.tajo.datum.TextDatum;
    +import org.apache.tajo.exception.UnsupportedException;
    +import org.apache.tajo.storage.Tuple;
    +
    +import java.util.BitSet;
    +import java.util.Iterator;
    +import java.util.List;
    +
    +/**
    + * Extract raw level values (primitive or String/byte[]) from each of key 
columns before sorting
    + * Uses indirection for efficient swapping
    + */
    +public class VectorizedSorter implements IndexedSortable, TupleSorter {
    +
    +  private final Tuple[] tuples;         // source tuples
    +  private final TupleVector[] vectors;  // values of key columns
    +  private final int[] mappings;         // index indirection
    +
    +  public VectorizedSorter(List<Tuple> source, SortSpec[] sortKeys, int[] 
keyIndex) {
    +    this.tuples = source.toArray(new Tuple[source.size()]);
    +    vectors = new TupleVector[sortKeys.length];
    +    mappings = new int[tuples.length];
    +    for (int i = 0; i < vectors.length; i++) {
    +      TajoDataTypes.Type type = 
sortKeys[i].getSortKey().getDataType().getType();
    +      boolean nullFirst = sortKeys[i].isNullFirst();
    +      boolean ascending = sortKeys[i].isAscending();
    +      boolean nullInvert = nullFirst && ascending || !nullFirst && 
!ascending;
    +      vectors[i] = new TupleVector(TupleVector.getType(type), 
tuples.length, nullInvert, ascending);
    --- End diff --
    
    It's possible but I prefer switch-case block to be compact as possible as 
it can be. And most of types in PB enum cannot be supported by this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to