test_class.file: tajo-core/src/test/java/org/apache/tajo/engine/planner/TestUniformRangePartition.java
test_class.identifier: TestUniformRangePartition
test_case.body: @Test
    public void testPartitionForOnePartNum() {
      Schema schema = new Schema()
          .addColumn("l_returnflag", Type.TEXT)
          .addColumn("l_linestatus", Type.TEXT);
  
      SortSpec [] sortSpecs = PlannerUtil.schemaToSortSpecs(schema);
  
      Tuple s = new VTuple(2);
      s.put(0, DatumFactory.createText("A"));
      s.put(1, DatumFactory.createText("F"));
      Tuple e = new VTuple(2);
      e.put(0, DatumFactory.createText("R"));
      e.put(1, DatumFactory.createText("O"));
      TupleRange expected = new TupleRange(sortSpecs, s, e);
      RangePartitionAlgorithm partitioner =
          new UniformRangePartition(expected, sortSpecs, true);
      TupleRange [] ranges = partitioner.partition(1);
  
      assertEquals(expected, ranges[0]);
    }
test_case.class_method_signature: TestUniformRangePartition.testPartitionForOnePartNum()
test_case.full_signature: @Test public void testPartitionForOnePartNum()
test_case.identifier: testPartitionForOnePartNum
test_case.invocations: addColumn addColumn schemaToSortSpecs put createText put createText put createText put createText partition assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPartitionForOnePartNum()
focal_class.declarator: variableId
focal_class.modifier: private
focal_class.original_string: private int variableId;
focal_class.type: int
focal_class.var_name: variableId
focal_class.declarator: cardForEachDigit
focal_class.modifier: private
focal_class.original_string: private BigDecimal[] cardForEachDigit;
focal_class.type: BigDecimal[]
focal_class.var_name: cardForEachDigit
focal_class.declarator: colCards
focal_class.modifier: private
focal_class.original_string: private BigDecimal[] colCards;
focal_class.type: BigDecimal[]
focal_class.var_name: colCards
focal_class.file: tajo-core/src/main/java/org/apache/tajo/engine/planner/UniformRangePartition.java
focal_class.identifier: UniformRangePartition
focal_class.class_method_signature: UniformRangePartition.UniformRangePartition(TupleRange totalRange, SortSpec[] sortSpecs, boolean inclusive)
focal_class.full_signature: public  UniformRangePartition(TupleRange totalRange, SortSpec[] sortSpecs, boolean inclusive)
focal_class.identifier: UniformRangePartition
focal_class.modifiers: public
focal_class.parameters: (TupleRange totalRange, SortSpec[] sortSpecs, boolean inclusive)
focal_class.signature:  UniformRangePartition(TupleRange totalRange, SortSpec[] sortSpecs, boolean inclusive)
focal_class.class_method_signature: UniformRangePartition.UniformRangePartition(TupleRange range, SortSpec [] sortSpecs)
focal_class.full_signature: public  UniformRangePartition(TupleRange range, SortSpec [] sortSpecs)
focal_class.identifier: UniformRangePartition
focal_class.modifiers: public
focal_class.parameters: (TupleRange range, SortSpec [] sortSpecs)
focal_class.signature:  UniformRangePartition(TupleRange range, SortSpec [] sortSpecs)
focal_class.class_method_signature: UniformRangePartition.partition(int partNum)
focal_class.full_signature: @Override public TupleRange[] partition(int partNum)
focal_class.identifier: partition
focal_class.modifiers: @Override public
focal_class.parameters: (int partNum)
focal_class.return: TupleRange[]
focal_class.signature: TupleRange[] partition(int partNum)
focal_class.class_method_signature: UniformRangePartition.isOverflow(int colId, Datum last, BigDecimal inc, SortSpec [] sortSpecs)
focal_class.full_signature: public boolean isOverflow(int colId, Datum last, BigDecimal inc, SortSpec [] sortSpecs)
focal_class.identifier: isOverflow
focal_class.modifiers: public
focal_class.parameters: (int colId, Datum last, BigDecimal inc, SortSpec [] sortSpecs)
focal_class.return: boolean
focal_class.signature: boolean isOverflow(int colId, Datum last, BigDecimal inc, SortSpec [] sortSpecs)
focal_class.class_method_signature: UniformRangePartition.incrementAndGetReminder(int colId, Datum last, long inc)
focal_class.full_signature: public long incrementAndGetReminder(int colId, Datum last, long inc)
focal_class.identifier: incrementAndGetReminder
focal_class.modifiers: public
focal_class.parameters: (int colId, Datum last, long inc)
focal_class.return: long
focal_class.signature: long incrementAndGetReminder(int colId, Datum last, long inc)
focal_class.class_method_signature: UniformRangePartition.increment(final Tuple last, final long inc, final int baseDigit)
focal_class.full_signature: public Tuple increment(final Tuple last, final long inc, final int baseDigit)
focal_class.identifier: increment
focal_class.modifiers: public
focal_class.parameters: (final Tuple last, final long inc, final int baseDigit)
focal_class.return: Tuple
focal_class.signature: Tuple increment(final Tuple last, final long inc, final int baseDigit)
focal_class.superclass: extends RangePartitionAlgorithm
focal_method.body: @Override
    public TupleRange[] partition(int partNum) {
      Preconditions.checkArgument(partNum > 0,
          "The number of partitions must be positive, but the given number: "
              + partNum);
      Preconditions.checkArgument(totalCard.compareTo(new BigDecimal(partNum)) >= 0,
          "the number of partition cannot exceed total cardinality (" + totalCard + ")");
  
      int varId;
      for (varId = 0; varId < cardForEachDigit.length; varId++) {
        if (cardForEachDigit[varId].compareTo(new BigDecimal(partNum)) >= 0)
          break;
      }
      this.variableId = varId;
  
      BigDecimal [] reverseCardsForDigit = new BigDecimal[variableId+1];
      for (int i = variableId; i >= 0; i--) {
        if (i == variableId) {
          reverseCardsForDigit[i] = colCards[i];
        } else {
          reverseCardsForDigit[i] = reverseCardsForDigit[i+1].multiply(colCards[i]);
        }
      }
  
      List<TupleRange> ranges = Lists.newArrayList();
      BigDecimal term = reverseCardsForDigit[0].divide(
          new BigDecimal(partNum), RoundingMode.CEILING);
      BigDecimal reminder = reverseCardsForDigit[0];
      Tuple last = range.getStart();
      while(reminder.compareTo(new BigDecimal(0)) > 0) {
        if (reminder.compareTo(term) <= 0) { // final one is inclusive
          ranges.add(new TupleRange(sortSpecs, last, range.getEnd()));
        } else {
          Tuple next = increment(last, term.longValue(), variableId);
          ranges.add(new TupleRange(sortSpecs, last, next));
        }
        last = ranges.get(ranges.size() - 1).getEnd();
        reminder = reminder.subtract(term);
      }
  
      return ranges.toArray(new TupleRange[ranges.size()]);
    }
focal_method.class_method_signature: UniformRangePartition.partition(int partNum)
focal_method.full_signature: @Override public TupleRange[] partition(int partNum)
focal_method.identifier: partition
focal_method.invocations: checkArgument checkArgument compareTo compareTo multiply newArrayList divide getStart compareTo compareTo add getEnd increment longValue add getEnd get size subtract toArray size
focal_method.modifiers: @Override public
focal_method.parameters: (int partNum)
focal_method.return: TupleRange[]
focal_method.signature: TupleRange[] partition(int partNum)