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); }
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); }
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; }
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; }
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); }
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(context.getConf(), fragment)); this.reader = new BSTIndex(context.getConf()). getIndexReader(indexPath, keySchema, comparator); }
@Override public void init() throws IOException { super.init(); SortSpec[] sortSpecs = logicalPlan.getKeySortSpecs(); indexKeys = new int[sortSpecs.length]; keySchema = PlannerUtil.sortSpecsToSchema(sortSpecs); Column col; for (int i = 0 ; i < sortSpecs.length; i++) { col = sortSpecs[i].getSortKey(); indexKeys[i] = inSchema.getColumnId(col.getQualifiedName()); } // TODO: this line should be improved to allow multiple scan executors. ScanExec scanExec = PhysicalPlanUtil.findExecutor(this, ScanExec.class); if (scanExec == null) { throw new TajoInternalError("Cannot find scan executors."); } TajoConf conf = context.getConf(); Path indexPath = new Path(logicalPlan.getIndexPath().toString(), IndexExecutorUtil.getIndexFileName(scanExec.getFragments()[0])); // TODO: Create factory using reflection BSTIndex bst = new BSTIndex(conf); this.comparator = new BaseTupleComparator(keySchema, sortSpecs); this.indexWriter = bst.getIndexWriter(indexPath, BSTIndex.TWO_LEVEL_INDEX, keySchema, comparator); this.indexWriter.setLoadNum(100); this.indexWriter.init(); }
@Override public void init() throws IOException { super.init(); SortSpec[] sortSpecs = logicalPlan.getKeySortSpecs(); indexKeys = new int[sortSpecs.length]; keySchema = PlannerUtil.sortSpecsToSchema(sortSpecs); Column col; for (int i = 0 ; i < sortSpecs.length; i++) { col = sortSpecs[i].getSortKey(); indexKeys[i] = inSchema.getColumnId(col.getQualifiedName()); } // TODO: this line should be improved to allow multiple scan executors. ScanExec scanExec = PhysicalPlanUtil.findExecutor(this, ScanExec.class); if (scanExec == null) { throw new TajoInternalError("Cannot find scan executors."); } TajoConf conf = context.getConf(); Path indexPath = new Path(logicalPlan.getIndexPath().toString(), IndexExecutorUtil.getIndexFileName(conf, scanExec.getFragments()[0])); // TODO: Create factory using reflection BSTIndex bst = new BSTIndex(conf); this.comparator = new BaseTupleComparator(keySchema, sortSpecs); this.indexWriter = bst.getIndexWriter(indexPath, BSTIndex.TWO_LEVEL_INDEX, keySchema, comparator); this.indexWriter.setLoadNum(100); this.indexWriter.init(); }
BaseTupleComparator ascComp = new BaseTupleComparator(schema, new SortSpec[]{sortSpecAsc}); Collections.sort(tupleList, ascComp); BaseTupleComparator descComp = new BaseTupleComparator(schema, new SortSpec[]{sortSpecDesc}); Collections.sort(tupleList, descComp);
BaseTupleComparator ascComp = new BaseTupleComparator(schema, new SortSpec[]{sortSpecAsc}); BaseTupleComparator descComp = new BaseTupleComparator(schema, new SortSpec[]{sortSpecDesc});
@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));