test_class.file: tajo-storage/src/test/java/org/apache/tajo/storage/TestTupleComparator.java
test_class.identifier: TestTupleComparator
test_case.body: @Test
    public final void testCompare() {
      Schema schema = new Schema();
      schema.addColumn("col1", Type.INT4);
      schema.addColumn("col2", Type.INT4);
      schema.addColumn("col3", Type.INT4);
      schema.addColumn("col4", Type.INT4);
      schema.addColumn("col5", Type.TEXT);
      
      Tuple tuple1 = new VTuple(5);
      Tuple tuple2 = new VTuple(5);
  
      tuple1.put(
          new Datum[] {
          DatumFactory.createInt4(9),
          DatumFactory.createInt4(3),
          DatumFactory.createInt4(33),
          DatumFactory.createInt4(4),
          DatumFactory.createText("abc")});
      tuple2.put(
          new Datum[] {
          DatumFactory.createInt4(1),
          DatumFactory.createInt4(25),
          DatumFactory.createInt4(109),
          DatumFactory.createInt4(4),
          DatumFactory.createText("abd")});
  
      SortSpec sortKey1 = new SortSpec(schema.getColumn("col4"), true, false);
      SortSpec sortKey2 = new SortSpec(schema.getColumn("col5"), true, false);
  
      TupleComparator tc = new TupleComparator(schema,
          new SortSpec[] {sortKey1, sortKey2});
      assertEquals(-1, tc.compare(tuple1, tuple2));
      assertEquals(1, tc.compare(tuple2, tuple1));
    }
test_case.class_method_signature: TestTupleComparator.testCompare()
test_case.full_signature: @Test public final void testCompare()
test_case.identifier: testCompare
test_case.invocations: addColumn addColumn addColumn addColumn addColumn put createInt4 createInt4 createInt4 createInt4 createText put createInt4 createInt4 createInt4 createInt4 createText getColumn getColumn assertEquals compare assertEquals compare
test_case.modifiers: @Test public final
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCompare()
focal_class.declarator: sortKeyIds
focal_class.modifier: private final
focal_class.original_string: private final int[] sortKeyIds;
focal_class.type: int[]
focal_class.var_name: sortKeyIds
focal_class.declarator: asc
focal_class.modifier: private final
focal_class.original_string: private final boolean[] asc;
focal_class.type: boolean[]
focal_class.var_name: asc
focal_class.declarator: nullFirsts
focal_class.modifier: @SuppressWarnings("unused")
    private final
focal_class.original_string: @SuppressWarnings("unused")
    private final boolean[] nullFirsts;
focal_class.type: boolean[]
focal_class.var_name: nullFirsts
focal_class.declarator: left
focal_class.modifier: private
focal_class.original_string: private Datum left;
focal_class.type: Datum
focal_class.var_name: left
focal_class.declarator: right
focal_class.modifier: private
focal_class.original_string: private Datum right;
focal_class.type: Datum
focal_class.var_name: right
focal_class.declarator: compVal
focal_class.modifier: private
focal_class.original_string: private int compVal;
focal_class.type: int
focal_class.var_name: compVal
focal_class.file: tajo-storage/src/main/java/org/apache/tajo/storage/TupleComparator.java
focal_class.identifier: TupleComparator
focal_class.interfaces: implements Comparator<Tuple>, ProtoObject<TupleComparatorProto>
focal_class.class_method_signature: TupleComparator.TupleComparator(Schema schema, SortSpec[] sortKeys)
focal_class.full_signature: public  TupleComparator(Schema schema, SortSpec[] sortKeys)
focal_class.identifier: TupleComparator
focal_class.modifiers: public
focal_class.parameters: (Schema schema, SortSpec[] sortKeys)
focal_class.signature:  TupleComparator(Schema schema, SortSpec[] sortKeys)
focal_class.class_method_signature: TupleComparator.TupleComparator(TupleComparatorProto proto)
focal_class.full_signature: public  TupleComparator(TupleComparatorProto proto)
focal_class.identifier: TupleComparator
focal_class.modifiers: public
focal_class.parameters: (TupleComparatorProto proto)
focal_class.signature:  TupleComparator(TupleComparatorProto proto)
focal_class.class_method_signature: TupleComparator.isAscendingFirstKey()
focal_class.full_signature: public boolean isAscendingFirstKey()
focal_class.identifier: isAscendingFirstKey
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isAscendingFirstKey()
focal_class.class_method_signature: TupleComparator.compare(Tuple tuple1, Tuple tuple2)
focal_class.full_signature: @Override public int compare(Tuple tuple1, Tuple tuple2)
focal_class.identifier: compare
focal_class.modifiers: @Override public
focal_class.parameters: (Tuple tuple1, Tuple tuple2)
focal_class.return: int
focal_class.signature: int compare(Tuple tuple1, Tuple tuple2)
focal_class.class_method_signature: TupleComparator.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_class.class_method_signature: TupleComparator.equals(Object obj)
focal_class.full_signature: @Override public boolean equals(Object obj)
focal_class.identifier: equals
focal_class.modifiers: @Override public
focal_class.parameters: (Object obj)
focal_class.return: boolean
focal_class.signature: boolean equals(Object obj)
focal_class.class_method_signature: TupleComparator.getProto()
focal_class.full_signature: @Override public TupleComparatorProto getProto()
focal_class.identifier: getProto
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: TupleComparatorProto
focal_class.signature: TupleComparatorProto getProto()
focal_method.body: @Override
    public int compare(Tuple tuple1, Tuple tuple2) {
      for (int i = 0; i < sortKeyIds.length; i++) {
        left = tuple1.get(sortKeyIds[i]);
        right = tuple2.get(sortKeyIds[i]);
  
        if (left instanceof NullDatum || right instanceof NullDatum) {
          if (!left.equals(right)) {
            if (left instanceof NullDatum) {
              compVal = 1;
            } else if (right instanceof NullDatum) {
              compVal = -1;
            }
            if (nullFirsts[i]) {
              if (compVal != 0) {
                compVal *= -1;
              }
            }
          } else {
            compVal = 0;
          }
        } else {
          if (asc[i]) {
            compVal = left.compareTo(right);
          } else {
            compVal = right.compareTo(left);
          }
        }
  
        if (compVal < 0 || compVal > 0) {
          return compVal;
        }
      }
      return 0;
    }
focal_method.class_method_signature: TupleComparator.compare(Tuple tuple1, Tuple tuple2)
focal_method.full_signature: @Override public int compare(Tuple tuple1, Tuple tuple2)
focal_method.identifier: compare
focal_method.invocations: get get equals compareTo compareTo
focal_method.modifiers: @Override public
focal_method.parameters: (Tuple tuple1, Tuple tuple2)
focal_method.return: int
focal_method.signature: int compare(Tuple tuple1, Tuple tuple2)