本文整理汇总了Java中com.taobao.tddl.optimizer.core.expression.bean.OrderBy类的典型用法代码示例。如果您正苦于以下问题:Java OrderBy类的具体用法?Java OrderBy怎么用?Java OrderBy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OrderBy类属于com.taobao.tddl.optimizer.core.expression.bean包,在下文中一共展示了OrderBy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetOrderBysBeforeNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetOrderBysBeforeNext() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
IMerge merge = ASTNodeFactory.getInstance().createMerge();
merge.setSharded(true);
MergeCursor c = new MergeCursor(cursors, merge, null);
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例2: testGetOrderBysAfterNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetOrderBysAfterNext() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
IMerge merge = ASTNodeFactory.getInstance().createMerge();
merge.setSharded(true);
MergeCursor c = new MergeCursor(cursors, merge, null);
c.next();
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例3: testGetOrderBysBeforeNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetOrderBysBeforeNext() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
MergeSortedCursors c = new MergeSortedCursors(cursors, true);
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例4: testGetOrderBysAfterNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetOrderBysAfterNext() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
MergeSortedCursors c = new MergeSortedCursors(cursors, true);
c.next();
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例5: testGetReturnColumnsBeforeNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetReturnColumnsBeforeNext() throws TddlException {
RepositoryHolder repoHolder = new RepositoryHolder();
StaticSchemaManager sm = new StaticSchemaManager("test_schema.xml", null, null);
sm.init();
IRepository bdbRepo = repoHolder.getOrCreateRepository("BDB_JE", Collections.EMPTY_MAP, Collections.EMPTY_MAP);
ICursorFactory cf = new CursorFactoryDefaultImpl();
MockArrayCursor mockCursor = this.getCursor("T1", new Integer[] { 5, 5, 4, 3, 2, 1 });
SchematicCursor subCursor = new SchematicCursor(mockCursor);
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
TempTableSortCursor c = new TempTableSortCursor(cf,
bdbRepo,
subCursor,
orderBys,
true,
0,
new ExecutionContext());
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例6: testGetOrderBysBeforeNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetOrderBysBeforeNext() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
DistinctCursor c = new DistinctCursor(new MergeSortedCursors(cursors, true), orderBys);
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例7: testGetOrderBysAfterNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetOrderBysAfterNext() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
DistinctCursor c = new DistinctCursor(new MergeSortedCursors(cursors, true), orderBys);
c.next();
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例8: testLimit
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testLimit() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
LimitFromToCursor c = new LimitFromToCursor(new SchematicCursor(mockCursor1, orderBys), 2l, 3L);
Object[] expected = new Object[] { 4, 5, 6 };
List actual = new ArrayList();
IRowSet row = null;
while ((row = c.next()) != null) {
System.out.println(row);
actual.add(row.getObject(0));
}
c.close(new ArrayList());
Assert.assertArrayEquals(expected, actual.toArray());
Assert.assertTrue(mockCursor1.isClosed());
}
示例9: testGetOrderBysBeforeNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetOrderBysBeforeNext() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
MergeCursor c = new MergeCursor(cursors, null, null);
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例10: testGetOrderBysAfterNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetOrderBysAfterNext() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
MergeCursor c = new MergeCursor(cursors, null, null);
c.next();
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例11: testGetReturnColumnsBeforeNext
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testGetReturnColumnsBeforeNext() throws TddlException {
RepositoryHolder repoHolder = new RepositoryHolder();
StaticSchemaManager sm = new StaticSchemaManager("test_schema.xml", null, null);
sm.init();
IRepository bdbRepo = repoHolder.getOrCreateRepository("BDB_JE", Collections.EMPTY_MAP);
ICursorFactory cf = new CursorFactoryDefaultImpl();
MockArrayCursor mockCursor = this.getCursor("T1", new Integer[] { 5, 5, 4, 3, 2, 1 });
SchematicCursor subCursor = new SchematicCursor(mockCursor);
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
TempTableSortCursor c = new TempTableSortCursor(cf,
bdbRepo,
subCursor,
orderBys,
true,
0,
new ExecutionContext());
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例12: getOrderBy
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
public static List<IOrderBy> getOrderBy(IndexMeta meta) {
if (meta == null) return new ArrayList<IOrderBy>(0);
List<IOrderBy> _orderBys = new ArrayList<IOrderBy>();
for (ColumnMeta c : meta.getKeyColumns()) {
IColumn column = ASTNodeFactory.getInstance().createColumn();
column.setTableName(c.getTableName())
.setColumnName(c.getName())
.setDataType(c.getDataType())
.setAlias(c.getAlias());
IOrderBy orderBy = new OrderBy().setColumn(column).setDirection(true);
_orderBys.add(orderBy);
}
return _orderBys;
}
示例13: getOrderByFromColumnMetas
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
public static List<IOrderBy> getOrderByFromColumnMetas(List<ColumnMeta> columns) {
if (GeneralUtil.isEmpty(columns)) return new ArrayList<IOrderBy>(0);
List<IOrderBy> _orderBys = new ArrayList<IOrderBy>();
for (ColumnMeta c : columns) {
IColumn column = ASTNodeFactory.getInstance().createColumn();
column.setTableName(c.getTableName())
.setColumnName(c.getName())
.setDataType(c.getDataType())
.setAlias(c.getAlias());
IOrderBy orderBy = new OrderBy().setColumn(column).setDirection(true);
_orderBys.add(orderBy);
}
return _orderBys;
}
示例14: testMergeNormal
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testMergeNormal() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
IMerge merge = ASTNodeFactory.getInstance().createMerge();
merge.setSharded(true);
MergeCursor c = new MergeCursor(cursors, merge, null);
Object[] expected = new Object[] { 1, 3, 5, 8, 8, 9, 10, 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 };
List actual = new ArrayList();
IRowSet row = null;
while ((row = c.next()) != null) {
System.out.println(row);
actual.add(row.getObject(0));
}
c.close(new ArrayList());
Assert.assertArrayEquals(expected, actual.toArray());
Assert.assertTrue(mockCursor1.isClosed());
}
示例15: testSortDuplicated
import com.taobao.tddl.optimizer.core.expression.bean.OrderBy; //导入依赖的package包/类
@Test
public void testSortDuplicated() throws TddlException {
MockArrayCursor mockCursor1 = this.getCursor("T1", new Integer[] { 1, 3, 5, 8, 8, 9, 10 });
MockArrayCursor mockCursor2 = this.getCursor("T1", new Integer[] { 2, 2, 4, 5, 6, 7, 7, 9, 9, 10, 13 });
IOrderBy order = new OrderBy();
order.setColumn(new Column().setColumnName("ID").setTableName("T1").setDataType(DataType.IntegerType));
List<IOrderBy> orderBys = new ArrayList();
orderBys.add(order);
List<ISchematicCursor> cursors = new ArrayList();
cursors.add(new SchematicCursor(mockCursor1, orderBys));
cursors.add(new SchematicCursor(mockCursor2, orderBys));
MergeSortedCursors c = new MergeSortedCursors(cursors, true);
Object[] expected = new Object[] { 1, 2, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 13 };
List actual = new ArrayList();
IRowSet row = null;
while ((row = c.next()) != null) {
System.out.println(row);
actual.add(row.getObject(0));
}
c.close(new ArrayList());
Assert.assertArrayEquals(expected, actual.toArray());
Assert.assertTrue(mockCursor1.isClosed());
}