Strabon
changeset 253:27949e4d9065 experiments
Cache files are created on init
author | Kostis Kyzirakos <kkyzir@di.uoa.gr> |
---|---|
date | Tue Jun 05 13:54:22 2012 +0300 (2012-06-05) |
parents | 22a08ab2694f |
children | |
files | evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/TripleTable.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTable.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java |
line diff
1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Mon Jun 04 23:45:02 2012 +0300 1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Tue Jun 05 13:54:22 2012 +0300 1.3 @@ -56,8 +56,8 @@ 1.4 private static final long serialVersionUID = 894529468109904724L; 1.5 1.6 public static String CACHEPATH = ""; 1.7 - public static String TABLE_COUNTS = "counts.bin"; 1.8 - public static String TABLE_SUBJ_OBJ_TYPES = "tableProperties.bin"; 1.9 + //public static String TABLE_COUNTS = "counts.bin"; 1.10 + //public static String TABLE_SUBJ_OBJ_TYPES = "tableProperties.bin"; 1.11 public static String TABLE_SHIFTING = "groupbys.bin"; 1.12 1.13
2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/TripleTable.java Mon Jun 04 23:45:02 2012 +0300 2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/TripleTable.java Tue Jun 05 13:54:22 2012 +0300 2.3 @@ -160,8 +160,10 @@ 2.4 } 2.5 } 2.6 } 2.7 + 2.8 + flushcache(false); 2.9 initialize = true; 2.10 - //System.out.println("["+this.getName()+"] Cache TRIPLETABLE file not found. Initialization took "+(System.nanoTime()-start)+" nanoseconds."); 2.11 + //System.out.println("["+this.getName()+"] Cache TRIPLETABLE file not found. Initialization took "+(System.nanoTime()-start)+" nanoseconds."); 2.12 } 2.13 else 2.14 { 2.15 @@ -226,38 +228,37 @@ 2.16 } 2.17 } 2.18 2.19 - public void close() 2.20 - throws SQLException 2.21 - { 2.22 - //XXX uncomment during 1st run in order to fill properties file 2.23 - //KKFile output = new File(StrabonPolyhedron.TABLE_SUBJ_OBJ_TYPES); 2.24 - File output = new File(StrabonPolyhedron.CACHEPATH+"tableProperties/"+this.getName()); 2.25 - //File existing = new File(StrabonPolyhedron.CACHEPATH+"initialized.bin"); 2.26 - if(!output.exists()&&subjAggregates!=null) 2.27 - { 2.28 - System.out.println("["+this.getName()+"] Cache TRIPLETABLE file not found. Storing cache details..."); 2.29 + public void flushcache(boolean force) throws SQLException { 2.30 + // XXX uncomment during 1st run in order to fill properties file 2.31 + // KKFile output = new File(StrabonPolyhedron.TABLE_SUBJ_OBJ_TYPES); 2.32 + File output = new File(StrabonPolyhedron.CACHEPATH + "tableProperties/"+ this.getName()); 2.33 + // File existing = new 2.34 + // File(StrabonPolyhedron.CACHEPATH+"initialized.bin"); 2.35 + if ((!output.exists() || force) && subjAggregates != null) { 2.36 + System.out 2.37 + .println("[" 2.38 + + this.getName() 2.39 + + "] Cache TRIPLETABLE file not found. Storing cache details..."); 2.40 FileOutputStream fstream = null; 2.41 DataOutputStream dos = null; 2.42 try { 2.43 - //KKfstream = new FileOutputStream(output,true); 2.44 - fstream = new FileOutputStream(output,false); 2.45 + // KKfstream = new FileOutputStream(output,true); 2.46 + fstream = new FileOutputStream(output, false); 2.47 2.48 dos = new DataOutputStream(fstream); 2.49 2.50 - //KKdos.writeUTF(table.getName()); 2.51 - //dos.writeChar(';'); 2.52 - for(int ii=0;ii<subjAggregates.length;ii++) 2.53 - { 2.54 + // KKdos.writeUTF(table.getName()); 2.55 + // dos.writeChar(';'); 2.56 + for (int ii = 0; ii < subjAggregates.length; ii++) { 2.57 dos.writeInt(subjAggregates[ii]); 2.58 } 2.59 2.60 - //dos.writeChar(';'); 2.61 - for(int ii=0;ii<objAggregates.length;ii++) 2.62 - { 2.63 + // dos.writeChar(';'); 2.64 + for (int ii = 0; ii < objAggregates.length; ii++) { 2.65 dos.writeInt(objAggregates[ii]); 2.66 } 2.67 2.68 - //KKdos.writeChar('\n'); 2.69 + // KKdos.writeChar('\n'); 2.70 dos.close(); 2.71 2.72 } catch (IOException e) { 2.73 @@ -265,8 +266,49 @@ 2.74 e.printStackTrace(); 2.75 } 2.76 } 2.77 + } 2.78 2.79 + public void close() 2.80 + throws SQLException 2.81 + { 2.82 +// //XXX uncomment during 1st run in order to fill properties file 2.83 +// //KKFile output = new File(StrabonPolyhedron.TABLE_SUBJ_OBJ_TYPES); 2.84 +// File output = new File(StrabonPolyhedron.CACHEPATH+"tableProperties/"+this.getName()); 2.85 +// //File existing = new File(StrabonPolyhedron.CACHEPATH+"initialized.bin"); 2.86 +// if(!output.exists()&&subjAggregates!=null) 2.87 +// { 2.88 +// System.out.println("["+this.getName()+"] Cache TRIPLETABLE file not found. Storing cache details..."); 2.89 +// FileOutputStream fstream = null; 2.90 +// DataOutputStream dos = null; 2.91 +// try { 2.92 +// //KKfstream = new FileOutputStream(output,true); 2.93 +// fstream = new FileOutputStream(output,false); 2.94 +// 2.95 +// dos = new DataOutputStream(fstream); 2.96 +// 2.97 +// //KKdos.writeUTF(table.getName()); 2.98 +// //dos.writeChar(';'); 2.99 +// for(int ii=0;ii<subjAggregates.length;ii++) 2.100 +// { 2.101 +// dos.writeInt(subjAggregates[ii]); 2.102 +// } 2.103 +// 2.104 +// //dos.writeChar(';'); 2.105 +// for(int ii=0;ii<objAggregates.length;ii++) 2.106 +// { 2.107 +// dos.writeInt(objAggregates[ii]); 2.108 +// } 2.109 +// 2.110 +// //KKdos.writeChar('\n'); 2.111 +// dos.close(); 2.112 +// 2.113 +// } catch (IOException e) { 2.114 +// 2.115 +// e.printStackTrace(); 2.116 +// } 2.117 +// } 2.118 2.119 + flushcache(false); 2.120 2.121 table.close(); 2.122 }
3.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTable.java Mon Jun 04 23:45:02 2012 +0300 3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTable.java Tue Jun 05 13:54:22 2012 +0300 3.3 @@ -176,15 +176,16 @@ 3.4 } 3.5 } 3.6 3.7 - public void close() 3.8 + public void flushcache(boolean force) 3.9 throws SQLException 3.10 { 3.11 //XXX uncomment during 1st run in order to fill properties file 3.12 //File will only have one line 3.13 3.14 File output = new File(StrabonPolyhedron.TABLE_SHIFTING); 3.15 - File existing = new File(StrabonPolyhedron.CACHEPATH+"initialized.bin"); 3.16 - if((!existing.exists()) || (!output.exists())) 3.17 + //File existing = new File(StrabonPolyhedron.CACHEPATH+"initialized.bin"); 3.18 + //if((!existing.exists()) || (!output.exists())) 3.19 + if((!output.exists()) || force ) 3.20 { 3.21 if(isHashTable) 3.22 { 3.23 @@ -203,11 +204,10 @@ 3.24 { 3.25 dos.writeLong(tmp); 3.26 } 3.27 - 3.28 + 3.29 //dos.writeChar('\n'); 3.30 dos.close(); 3.31 } catch (IOException e) { 3.32 - 3.33 e.printStackTrace(); 3.34 } 3.35 } 3.36 @@ -222,6 +222,54 @@ 3.37 } 3.38 table.close(); 3.39 } 3.40 + 3.41 + public void close() 3.42 + throws SQLException 3.43 + { 3.44 +// //XXX uncomment during 1st run in order to fill properties file 3.45 +// //File will only have one line 3.46 +// 3.47 +// File output = new File(StrabonPolyhedron.TABLE_SHIFTING); 3.48 +// File existing = new File(StrabonPolyhedron.CACHEPATH+"initialized.bin"); 3.49 +// if((!existing.exists()) || (!output.exists())) 3.50 +// { 3.51 +// if(isHashTable) 3.52 +// { 3.53 +// System.out.println("["+this.getName()+"] Cache VALUETABLE file not found. Storing cache details..."); 3.54 +// 3.55 +// FileOutputStream fstream = null; 3.56 +// DataOutputStream dos = null; 3.57 +// try { 3.58 +// fstream = new FileOutputStream(output,true); 3.59 +// 3.60 +// dos = new DataOutputStream(fstream); 3.61 +// 3.62 +// //dos.writeUTF(table.getName()); 3.63 +// 3.64 +// for(Long tmp : maxIds) 3.65 +// { 3.66 +// dos.writeLong(tmp); 3.67 +// } 3.68 +// 3.69 +// //dos.writeChar('\n'); 3.70 +// dos.close(); 3.71 +// } catch (IOException e) { 3.72 +// 3.73 +// e.printStackTrace(); 3.74 +// } 3.75 +// } 3.76 +// } 3.77 +// //end of addition 3.78 +// 3.79 +// if (insertSelect != null) { 3.80 +// insertSelect.close(); 3.81 +// } 3.82 +// if (temporary != null) { 3.83 +// temporary.close(); 3.84 +// } 3.85 + flushcache(false); 3.86 + table.close(); 3.87 + } 3.88 3.89 public synchronized void insert(Number id, String value) 3.90 throws SQLException, InterruptedException 3.91 @@ -314,7 +362,8 @@ 3.92 throws SQLException 3.93 { 3.94 3.95 - File existing = new File(StrabonPolyhedron.CACHEPATH+"initialized.bin"); 3.96 + //File existing = new File(StrabonPolyhedron.CACHEPATH+"initialized.bin"); 3.97 + File existing = new File(StrabonPolyhedron.TABLE_SHIFTING); 3.98 if(!existing.exists()) 3.99 { 3.100 String column = "id"; 3.101 @@ -344,7 +393,7 @@ 3.102 //XXX addition --> will use in close() 3.103 maxIds.addAll(result); 3.104 isHashTable = true; 3.105 - 3.106 + 3.107 return result; 3.108 } 3.109 3.110 @@ -354,6 +403,7 @@ 3.111 } 3.112 finally { 3.113 st.close(); 3.114 + flushcache(false); 3.115 } 3.116 } 3.117 else
4.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Mon Jun 04 23:45:02 2012 +0300 4.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Tue Jun 05 13:54:22 2012 +0300 4.3 @@ -118,9 +118,21 @@ 4.4 cachePath = cachePath+"/"; 4.5 } 4.6 StrabonPolyhedron.CACHEPATH = ""+cachePath; 4.7 - StrabonPolyhedron.TABLE_COUNTS = cachePath + "counts.bin"; 4.8 + //StrabonPolyhedron.TABLE_COUNTS = cachePath + "counts.bin"; 4.9 StrabonPolyhedron.TABLE_SHIFTING = cachePath + "groupbys.bin"; 4.10 - StrabonPolyhedron.TABLE_SUBJ_OBJ_TYPES = cachePath + "tableProperties.bin"; 4.11 + //StrabonPolyhedron.TABLE_SUBJ_OBJ_TYPES = cachePath + "tableProperties.bin"; 4.12 + 4.13 + File test; 4.14 + 4.15 + test = new File(StrabonPolyhedron.CACHEPATH + "counts"); 4.16 + if (!test.exists()) { 4.17 + test.mkdirs(); 4.18 + } 4.19 + 4.20 + test = new File(StrabonPolyhedron.CACHEPATH + "tableProperties"); 4.21 + if (!test.exists()) { 4.22 + test.mkdirs(); 4.23 + } 4.24 4.25 if (checkForLockTable == true) { 4.26 checkAndDeleteLock(databaseName, user, password, port, serverName);