public static void main(String argv[]) { BMDriver bmt = new BMDriver(); boolean dbstatus; dbstatus = bmt.runTests(); if (dbstatus != true) { System.err.println("Error encountered during buffer manager tests:\n"); Runtime.getRuntime().exit(1); } Runtime.getRuntime().exit(0); }
public static void main(String[] args) { // set argument: // start lat, start lon, end lat, end lon, start time index, start day index setParam(34.199705, -117.3663704, 34.38999, -119.159022, 10, 0); // config OSMParam.paramConfig(); // input OSMInput.readNodeFile(); OSMInput.readEdgeFile(); // for both adjListHashMap and adjReverseListHashMap OSMInput.readAdjList(); OSMInput.readNodeLocationGrid(); OSMInput.addOnEdgeToNode(); // JVM memory usage System.out.println( "JVM total memory usage: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + " megabytes"); // test // OSMOutput.generateHighwayKML(edgeHashMap, nodeHashMap); // initial hierarchy level OSMParam.initialHierarchy(); // routing, turn by turn tdsp(); }
/** Constructor */ public STSDriver2() { System.out.print("Started STS tests2" + "\n"); // build ColaMarkets table colamarkets = new Vector(); double[] v = new double[] {1.0, 1.0, 2.0, 3.0}; colamarkets.addElement(new ColaMarkets(1, "cola_a", new Sdo_geometry(Sdo_gtype.RECTANGLE, v))); v = new double[] {2.5, 3.5, 3.5, 4.5}; colamarkets.addElement(new ColaMarkets(2, "cola_b", new Sdo_geometry(Sdo_gtype.RECTANGLE, v))); boolean status = OK; int numMarkets = 2; int numMarkets_attrs = 3; String dbpath = "/tmp/" + System.getProperty("user.name") + ".minibase.ststest2db"; String logpath = "/tmp/" + System.getProperty("user.name") + ".sts2log"; String remove_cmd = "/bin/rm -rf "; String remove_logcmd = remove_cmd + logpath; String remove_dbcmd = remove_cmd + dbpath; String remove_sts2cmd = remove_cmd + dbpath; try { Runtime.getRuntime().exec(remove_logcmd); Runtime.getRuntime().exec(remove_dbcmd); Runtime.getRuntime().exec(remove_sts2cmd); } catch (IOException e) { System.err.println("" + e); } /* ExtendedSystemDefs extSysDef = new ExtendedSystemDefs( "/tmp/minibase.jointestdb", "/tmp/joinlog", 1000,500,200,"Clock"); */ SystemDefs sysdef = new SystemDefs(dbpath, 1000, NUMBUF, "Clock"); // creating the sailors relation AttrType[] Mtypes = new AttrType[3]; Mtypes[0] = new AttrType(AttrType.attrInteger); Mtypes[1] = new AttrType(AttrType.attrString); Mtypes[2] = new AttrType(AttrType.attrSdogeometry); // SOS short[] Msizes = new short[1]; Msizes[0] = 30; // first elt. is 30 Tuple t = new Tuple(); try { t.setHdr((short) 3, Mtypes, Msizes); } catch (Exception e) { System.err.println("*** error in Tuple.setHdr() ***"); status = FAIL; e.printStackTrace(); } int size = t.size(); System.out.println("Size:" + size); // selecting the tuple into file "colamarkets" RID rid; Heapfile f = null; try { f = new Heapfile("colamarkets.in"); } catch (Exception e) { System.err.println("*** error in Heapfile constructor ***"); status = FAIL; e.printStackTrace(); } t = new Tuple(size); try { t.setHdr((short) 3, Mtypes, Msizes); } catch (Exception e) { System.err.println("*** error in Tuple.setHdr() ***"); status = FAIL; e.printStackTrace(); } for (int i = 0; i < numMarkets; i++) { try { t.setIntFld(1, ((ColaMarkets) colamarkets.elementAt(i)).marketId); t.setStrFld(2, ((ColaMarkets) colamarkets.elementAt(i)).name); t.setSdogeometryFld(3, ((ColaMarkets) colamarkets.elementAt(i)).shape); } catch (Exception e) { System.err.println("*** Heapfile error in Tuple.setStrFld() ***"); status = FAIL; e.printStackTrace(); } try { rid = f.insertRecord(t.returnTupleByteArray()); } catch (Exception e) { System.err.println("*** error in Heapfile.selectRecord() ***"); status = FAIL; e.printStackTrace(); } } if (status != OK) { // bail out System.err.println("*** Error creation relation for colamarkets"); Runtime.getRuntime().exit(1); } }
public void Query1() { System.out.print("**********************Query1 strating *********************\n"); boolean status = OK; System.out.print( "Query: Find the intersection of cola market cola_a and cola market cola_b" + "SELECT c.name, SDO_GEOM.SDO_AREA(c.shape, 0.005)" + " FROM cola_markets c_a, cola_markets c_b" + " WHERE c_a.name = 'cola_a' and c_b.name = 'cola_b'\n"); System.out.print("\n(Tests2 FileScan, Projection)\n"); CondExpr[] outFilter = new CondExpr[3]; outFilter[0] = new CondExpr(); outFilter[1] = new CondExpr(); outFilter[2] = new CondExpr(); Query1_CondExpr(outFilter); Tuple t = new Tuple(); t = null; AttrType[] Mtypes = new AttrType[3]; Mtypes[0] = new AttrType(AttrType.attrInteger); Mtypes[1] = new AttrType(AttrType.attrString); Mtypes[2] = new AttrType(AttrType.attrSdogeometry); // SOS short[] Msizes = new short[1]; Msizes[0] = 30; // first elt. is 30 FldSpec[] Mprojection = new FldSpec[2]; Mprojection[0] = new FldSpec(new RelSpec(RelSpec.outer), 2); Mprojection[1] = new FldSpec(new RelSpec(RelSpec.outer), 3); AttrType[] jtype = new AttrType[2]; jtype[0] = new AttrType(AttrType.attrString); jtype[1] = new AttrType(AttrType.attrSdogeometry); CondExpr[] selects = new CondExpr[1]; selects = null; FileScan am = null; try { am = new FileScan("colamarkets.in", Mtypes, Msizes, (short) 3, (short) 2, Mprojection, null); } catch (Exception e) { status = FAIL; System.err.println("" + e); e.printStackTrace(); } if (status != OK) { // bail out System.err.println("*** Error setting up scan for sailors"); Runtime.getRuntime().exit(1); } System.out.println("done"); Sdo_geometry x[] = new Sdo_geometry[2]; try { int i = 0; while ((t = am.get_next()) != null) { t.print(jtype); x[i++] = t.getSdogeometryFld(2); } Sdo_geometry sdoval = x[0].intersection(x[1]); if (sdoval != null) { String output = "SDO_GEOMETRY(" + (int) sdoval.shapeType.ordinal() + ",[ "; for (double d : sdoval.coordinatesOfShape) output += d + " "; System.out.print(output + "])"); } } catch (Exception e) { System.err.println("" + e); e.printStackTrace(); Runtime.getRuntime().exit(1); } }
/** calls the runTests function in TestDriver */ public boolean runTests() { System.out.print("\n" + "Running " + testName() + " tests...." + "\n"); try { SystemDefs sysdef = new SystemDefs(dbpath, NUMBUF + 20, NUMBUF, "Clock"); } catch (Exception e) { Runtime.getRuntime().exit(1); } // Kill anything that might be hanging around String newdbpath; String newlogpath; String remove_logcmd; String remove_dbcmd; String remove_cmd = "/bin/rm -rf "; newdbpath = dbpath; newlogpath = logpath; remove_logcmd = remove_cmd + logpath; remove_dbcmd = remove_cmd + dbpath; // Commands here is very machine dependent. We assume // user are on UNIX system here. If we need to port this // program to other platform, the remove_cmd have to be // modified accordingly. try { Runtime.getRuntime().exec(remove_logcmd); Runtime.getRuntime().exec(remove_dbcmd); } catch (IOException e) { System.err.println("" + e); } remove_logcmd = remove_cmd + newlogpath; remove_dbcmd = remove_cmd + newdbpath; // This step seems redundant for me. But it's in the original // C++ code. So I am keeping it as of now, just in case // I missed something try { Runtime.getRuntime().exec(remove_logcmd); Runtime.getRuntime().exec(remove_dbcmd); } catch (IOException e) { System.err.println("" + e); } // Run the tests. Return type different from C++ boolean _pass = runAllTests(); // Clean up again try { Runtime.getRuntime().exec(remove_logcmd); Runtime.getRuntime().exec(remove_dbcmd); } catch (IOException e) { System.err.println("" + e); } System.out.print("\n" + "..." + testName() + " tests "); System.out.print(_pass == OK ? "completely successfully" : "failed"); System.out.print(".\n\n"); return _pass; }