java和数据库高手来看这个有挑战性的项目,是我一在英国计算机名校读研的朋友的作业,让我帮忙,现在看的我直头晕!谁能帮我分析一下这个
作业要求:http://www.inf.ed.ac.uk/teaching/courses/adbs/assignment1.html
attica DBMS说明:http://www.inf.ed.ac.uk/teaching/courses/adbs/attica/
从网页上可以下载这个系统的源代码。
我今天分析了一天,有这么几个问题没弄明白:
1。这个ExternalSort.java的功能到底是是完成对特定表的内容排序,然后输入一张新的表,还是完成sql语句中的order by解析?我分析的结果是后者。
2。如何在要完成的这个ExernalSort.java中的setup()方法进行order by后面的key word的传递?
3。PlanBuilder.java中如可以让ExernalSort.java的功能实现?
以下是我仅仅能写出的部分代码:
protected void initTempFiles () throws StorageManagerException {
////////////////////////////////////////////
//
// initialise the temporary files here
// make sure you throw the right exception
//
////////////////////////////////////////////
try{
inputFile = FileUtil.createTempFileName();
sm.createFile(inputFile);
outputFile = FileUtil.createTempFileName();
sm.createFile(outputFile);
}
catch (Exception e) {
StorageManagerException sme = new StorageManagerException("Could not initialise temporary files");
sme.setStackTrace(e.getStackTrace());
throw sme;
}
} // initTempFiles()
/**
* Set up this external sort operator
*
* @throws EngineException thrown whenever there is something wrong with
* setting this operator up
*/
public void setup () throws EngineException {
try {
////////////////////////////////////////////
//
// this is a blocking operator -- store the input
// in a temporary file and sort the file
//
////////////////////////////////////////////
Relation rel = getInputOperator().getOutputRelation();
inputMan = new RelationIOManager(sm, rel, inputFile);
boolean done = false;
while (! done) {
Tuple[] tuples = getInputOperator().getNext();
if (tuples != null) {
done = (tuples[0] instanceof EndOfStreamTuple);
if (! done) {
for (int i = 0; i < tuples.length; i++) {
inputMan.insertTuple(tuples[i]);
}
}
}
}
////////////////////////////////////////////
//
// the output should reside in the output file
//
////////////////////////////////////////////
outputMan = new RelationIOManager(sm, getOutputRelation(),
outputFile);
outputMan.openTupleCursor();
}
catch (StorageManagerException sme) {
EngineException ee = new EngineException("Could not store " +
"intermediate relations " +
"to files.");
ee.setStackTrace(sme.getStackTrace());
throw ee;
}
}
最关键的部分,如何来用传递进来的参数进行外部排序。。。。。晕死我。
想听听高手们的分析和提示。