[ 
https://issues.apache.org/jira/browse/TAJO-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14377039#comment-14377039
 ] 

ASF GitHub Bot commented on TAJO-1407:
--------------------------------------

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

    https://github.com/apache/tajo/pull/426#discussion_r26996803
  
    --- 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 --
    
    Ok. It looks good.


> Minor performance improvement of MemSortExec
> --------------------------------------------
>
>                 Key: TAJO-1407
>                 URL: https://issues.apache.org/jira/browse/TAJO-1407
>             Project: Tajo
>          Issue Type: Improvement
>          Components: physical operator
>            Reporter: Navis
>            Assignee: Navis
>            Priority: Minor
>
> Currently, tajo uses Collections.sort() with TupleCompartor, which can incur 
> some overheads on comparing. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to