本文整理汇总了Java中com.taobao.tddl.executor.cursor.impl.TempTableSortCursor类的典型用法代码示例。如果您正苦于以下问题:Java TempTableSortCursor类的具体用法?Java TempTableSortCursor怎么用?Java TempTableSortCursor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TempTableSortCursor类属于com.taobao.tddl.executor.cursor.impl包,在下文中一共展示了TempTableSortCursor类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetReturnColumnsBeforeNext
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的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());
}
示例2: testGetReturnColumnsBeforeNext
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的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());
}
示例3: tempTableSortCursor
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Override
public ITempTableSortCursor tempTableSortCursor(ExecutionContext executionContext, ISchematicCursor cursor,
List<IOrderBy> orderBys, boolean sortedDuplicates, long requestID)
throws TddlException {
try {
if (GeneralUtil.getExtraCmdBoolean(executionContext.getExtraCmds(),
ConnectionProperties.ALLOW_TEMPORARY_TABLE,
false)) {
IRepository bdbRepo = ExecutorContext.getContext()
.getRepositoryHolder()
.getOrCreateRepository(Group.GroupType.BDB_JE.name(),
Collections.EMPTY_MAP,
executionContext.getExtraCmds());
return new TempTableSortCursor(this,
bdbRepo,
cursor,
orderBys,
sortedDuplicates,
requestID,
executionContext);
}
throw new IllegalStateException("not allow to use temporary table . allow first");
} catch (Exception e) {
closeParentCursor(cursor);
throw new TddlException(e);
}
}
示例4: testSort
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Test
public void testSort() 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());
Object[] expected = new Object[] { 1, 2, 3, 4, 5, 5 };
List actual = new ArrayList();
IRowSet row = null;
while ((row = c.next()) != null) {
System.out.println(row);
actual.add(row.getObject(0));
}
Assert.assertArrayEquals(expected, actual.toArray());
Assert.assertTrue(mockCursor.isClosed());
}
示例5: testNull
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Test
public void testNull() 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();
SchematicCursor subCursor = new SchematicCursor(this.getCursor("T1",
new Integer[] { 5, null, 4, 3, 2, null, 1 }));
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());
Object[] expected = new Object[] { 1, 2, 3, 4, 5, null, null };
List actual = new ArrayList();
IRowSet row = null;
while ((row = c.next()) != null) {
System.out.println(row);
actual.add(row.getObject(0));
}
Assert.assertArrayEquals(expected, actual.toArray());
}
示例6: testEmpty
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Test
public void testEmpty() 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();
SchematicCursor subCursor = new SchematicCursor(this.getCursor("T1", new Integer[] {}));
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());
Object[] expected = new Object[] {};
List actual = new ArrayList();
IRowSet row = null;
while ((row = c.next()) != null) {
System.out.println(row);
actual.add(row.getObject(0));
}
Assert.assertArrayEquals(expected, actual.toArray());
}
示例7: testGetReturnColumnsAfterNext
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Test
public void testGetReturnColumnsAfterNext() 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());
while (c.next() != null)
;
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}
示例8: tempTableSortCursor
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Override
public ITempTableSortCursor tempTableSortCursor(ExecutionContext executionContext, ISchematicCursor cursor,
List<IOrderBy> orderBys, boolean sortedDuplicates, long requestID)
throws TddlException {
try {
if ("True".equalsIgnoreCase(GeneralUtil.getExtraCmdString(executionContext.getExtraCmds(),
ExtraCmd.ALLOW_TEMPORARY_TABLE))) {
IRepository bdbRepo = ExecutorContext.getContext()
.getRepositoryHolder()
.getOrCreateRepository(Group.GroupType.BDB_JE.name(), Collections.EMPTY_MAP);
return new TempTableSortCursor(this,
bdbRepo,
cursor,
orderBys,
sortedDuplicates,
requestID,
executionContext);
}
throw new IllegalStateException("not allow to use temporary table . allow first ");
} catch (Exception e) {
closeParentCursor(cursor);
throw new TddlException(e);
}
}
示例9: testSort
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Test
public void testSort() 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());
Object[] expected = new Object[] { 1, 2, 3, 4, 5, 5 };
List actual = new ArrayList();
IRowSet row = null;
while ((row = c.next()) != null) {
System.out.println(row);
actual.add(row.getObject(0));
}
Assert.assertArrayEquals(expected, actual.toArray());
Assert.assertTrue(mockCursor.isClosed());
}
示例10: testNull
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Test
public void testNull() 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();
SchematicCursor subCursor = new SchematicCursor(this.getCursor("T1",
new Integer[] { 5, null, 4, 3, 2, null, 1 }));
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());
Object[] expected = new Object[] { 1, 2, 3, 4, 5, null, null };
List actual = new ArrayList();
IRowSet row = null;
while ((row = c.next()) != null) {
System.out.println(row);
actual.add(row.getObject(0));
}
Assert.assertArrayEquals(expected, actual.toArray());
}
示例11: testEmpty
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Test
public void testEmpty() 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();
SchematicCursor subCursor = new SchematicCursor(this.getCursor("T1", new Integer[] {}));
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());
Object[] expected = new Object[] {};
List actual = new ArrayList();
IRowSet row = null;
while ((row = c.next()) != null) {
System.out.println(row);
actual.add(row.getObject(0));
}
Assert.assertArrayEquals(expected, actual.toArray());
}
示例12: testGetReturnColumnsAfterNext
import com.taobao.tddl.executor.cursor.impl.TempTableSortCursor; //导入依赖的package包/类
@Test
public void testGetReturnColumnsAfterNext() 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());
while (c.next() != null)
;
Assert.assertEquals("[T1.ID, T1.NAME, T1.SCHOOL]", c.getReturnColumns().toString());
Assert.assertEquals("[OrderBy [columnName=T1.ID, direction=true]]", c.getOrderBy().toString());
}