public SortExec(TaskAttemptContext context, Schema inSchema, Schema outSchema, PhysicalExec child, SortSpec [] sortSpecs) { super(context, inSchema, outSchema, child); this.sortSpecs = sortSpecs; this.comparator = new BaseTupleComparator(inSchema, sortSpecs); }
protected TupleSorter getSorter(List tupleSlots) { if (!tupleSlots.isEmpty() && ComparableVector.isVectorizable(sortSpecs)) { return new VectorizedSorter(tupleSlots, sortSpecs, comparator.getSortKeyIds()); } return new TupleSorter.DefaultSorter(tupleSlots, comparator); }
@Test public void testIncrementOfUnicode() { Schema schema = SchemaBuilder.builder() .add("col1", Type.TEXT) .build(); SortSpec [] sortSpecs = PlannerUtil.schemaToSortSpecs(schema); VTuple s = new VTuple(1); s.put(0, DatumFactory.createText("가가가")); VTuple e = new VTuple(1); e.put(0, DatumFactory.createText("하하하")); TupleRange expected = new TupleRange(sortSpecs, s, e); UniformRangePartition partitioner = new UniformRangePartition(expected, sortSpecs); BaseTupleComparator comp = new BaseTupleComparator(schema, sortSpecs); Tuple tuple = s; Tuple prevTuple = null; for (int i = 0; i < 100; i++) { tuple = partitioner.increment(tuple, BigInteger.valueOf(30000), 0); if (prevTuple != null) { assertTrue("prev=" + prevTuple + ", current=" + tuple, comp.compare(prevTuple, tuple) < 0); } prevTuple = tuple; } }
SortSpec sortKey2 = new SortSpec(schema.getColumn("col5"), true, false); BaseTupleComparator tc = new BaseTupleComparator(schema, new SortSpec[] {sortKey1, sortKey2}); assertEquals(-1, tc.compare(tuple1, tuple2)); assertEquals(1, tc.compare(tuple2, tuple1));
public SortExec(TaskAttemptContext context, Schema inSchema, Schema outSchema, PhysicalExec child, SortSpec [] sortSpecs) { super(context, inSchema, outSchema, child); this.sortSpecs = sortSpecs; this.comparator = new BaseTupleComparator(inSchema, sortSpecs); }
}).build(); BaseTupleComparator comparator = new BaseTupleComparator(sortSchema, new SortSpec[]{ new SortSpec(new Column("managerid", Type.INT8)), curVal = tuple; if (preVal != null) { assertTrue("prev: " + preVal + ", but cur: " + curVal + ", cnt: " + cnt, comparator.compare(preVal, curVal) <= 0); curVal = tuple; if (preVal != null) { assertTrue("prev: " + preVal + ", but cur: " + curVal, comparator.compare(preVal, curVal) <= 0);
protected TupleSorter getSorter(List tupleSlots) { if (!tupleSlots.isEmpty() && ComparableVector.isVectorizable(sortSpecs)) { return new VectorizedSorter(tupleSlots, sortSpecs, comparator.getSortKeyIds()); } return new TupleSorter.DefaultSorter(tupleSlots, comparator); }
public static TupleComparator [] getComparatorsFromJoinQual(EvalNode joinQual, Schema leftSchema, Schema rightSchema) { SortSpec[][] sortSpecs = PlannerUtil.getSortKeysFromJoinQual(joinQual, leftSchema, rightSchema); BaseTupleComparator[] comparators = new BaseTupleComparator[2]; comparators[0] = new BaseTupleComparator(leftSchema, sortSpecs[0]); comparators[1] = new BaseTupleComparator(rightSchema, sortSpecs[1]); return comparators; }
int cnt = 0; exec.init(); BaseTupleComparator comparator = new BaseTupleComparator(proj.getSchema(), new SortSpec[]{ new SortSpec(new Column("managerid", TajoDataTypes.Type.INT4)), assertTrue("prev: " + preVal + ", but cur: " + curVal, comparator.compare(preVal, curVal) <= 0); curVal = tuple; if (preVal != null) { assertTrue("prev: " + preVal + ", but cur: " + curVal, comparator.compare(preVal, curVal) <= 0);
public static TupleComparator [] getComparatorsFromJoinQual(EvalNode joinQual, Schema leftSchema, Schema rightSchema) { SortSpec[][] sortSpecs = PlannerUtil.getSortKeysFromJoinQual(joinQual, leftSchema, rightSchema); BaseTupleComparator[] comparators = new BaseTupleComparator[2]; comparators[0] = new BaseTupleComparator(leftSchema, sortSpecs[0]); comparators[1] = new BaseTupleComparator(rightSchema, sortSpecs[1]); return comparators; }
TupleRange [] ranges = partitioner.partition(4); assertTrue(4 <= ranges.length); BaseTupleComparator comp = new BaseTupleComparator(schema, PlannerUtil.schemaToSortSpecs(schema)); TupleRange prev = ranges[0]; for (int i = 1; i < ranges.length; i++) { assertTrue(comp.compare(prev.getStart(), ranges[i].getStart()) < 0); assertTrue(comp.compare(prev.getEnd(), ranges[i].getEnd()) < 0); prev = ranges[i];
public TupleRange(final SortSpec[] sortSpecs, final Tuple start, final Tuple end) { this.comp = new BaseTupleComparator(sortSpecsToSchema(sortSpecs), sortSpecs); // if there is only one value, start == end this.start = start; this.end = end; }
public TupleRange(final SortSpec[] sortSpecs, final Tuple start, final Tuple end) { this.comp = new BaseTupleComparator(sortSpecsToSchema(sortSpecs), sortSpecs); // if there is only one value, start == end this.start = start; this.end = end; }
this.comparator = new BaseTupleComparator(compProto.build());
this.comparator = new BaseTupleComparator(compProto.build());
public void init() throws IOException { keySchema = PlannerUtil.sortSpecsToSchema(sortSpecs); keyProjector = new KeyProjector(inSchema, keySchema.toArray()); BSTIndex bst = new BSTIndex(context.getConf()); this.comp = new BaseTupleComparator(keySchema, sortSpecs); Path storeTablePath = new Path(context.getWorkDir(), "output"); LOG.info("Output data directory: " + storeTablePath); FileSystem fs = new RawLocalFileSystem(); fs.mkdirs(storeTablePath); this.appender = (FileAppender) ((FileTablespace) TablespaceManager.getDefault()) .getAppender(meta, outSchema, new Path(storeTablePath, "output")); this.appender.enableStats(keySchema.getAllColumns()); this.appender.init(); this.indexWriter = bst.getIndexWriter(new Path(storeTablePath, "index"), BSTIndex.TWO_LEVEL_INDEX, keySchema, comp, true); this.indexWriter.init(); super.init(); }
public void init() throws IOException { keySchema = PlannerUtil.sortSpecsToSchema(sortSpecs); keyProjector = new KeyProjector(inSchema, keySchema.toArray()); BSTIndex bst = new BSTIndex(context.getConf()); this.comp = new BaseTupleComparator(keySchema, sortSpecs); Path storeTablePath = new Path(context.getWorkDir(), "output"); LOG.info("Output data directory: " + storeTablePath); FileSystem fs = new RawLocalFileSystem(); fs.mkdirs(storeTablePath); this.appender = (FileAppender) ((FileTablespace) TablespaceManager.getDefault()) .getAppender(meta, outSchema, new Path(storeTablePath, "output")); this.appender.enableStats(keySchema.getAllColumns()); this.appender.init(); this.indexWriter = bst.getIndexWriter(new Path(storeTablePath, "index"), BSTIndex.TWO_LEVEL_INDEX, keySchema, comp, true); this.indexWriter.init(); super.init(); }
SortNode sortNode = PlannerUtil.findTopNode(plan, NodeType.SORT); this.finalSchema = PlannerUtil.sortSpecsToSchema(sortNode.getSortKeys()); this.sortComp = new BaseTupleComparator(finalSchema, sortNode.getSortKeys());
SortNode sortNode = PlannerUtil.findTopNode(plan, NodeType.SORT); this.finalSchema = PlannerUtil.sortSpecsToSchema(sortNode.getSortKeys()); this.sortComp = new BaseTupleComparator(finalSchema, sortNode.getSortKeys());
public BSTIndexScanExec(TaskAttemptContext context, IndexScanNode plan, CatalogProtos.FragmentProto fragment, URI indexPrefix , Schema keySchema, SimplePredicate [] predicates) throws IOException { super(context, plan.getInSchema(), plan.getOutSchema()); this.plan = plan; this.qual = plan.getQual(); this.fragment = fragment; this.keySchema = keySchema; SortSpec[] keySortSpecs = new SortSpec[predicates.length]; Datum[] values = new Datum[predicates.length]; for (int i = 0; i < predicates.length; i++) { keySortSpecs[i] = predicates[i].getKeySortSpec(); values[i] = predicates[i].getValue(); } indexLookupKey = new VTuple(values); TupleComparator comparator = new BaseTupleComparator(keySchema, keySortSpecs); this.projector = new Projector(context, inSchema, outSchema, plan.getTargets()); Path indexPath = new Path(indexPrefix.toString(), IndexExecutorUtil.getIndexFileName(fragment)); this.reader = new BSTIndex(context.getConf()). getIndexReader(indexPath, keySchema, comparator); }