// // ------ // // SAVOT Sample // // Author: André Schaaff // Address: Centre de Donnees astronomiques de Strasbourg // 11 rue de l'Universite // 67000 STRASBOURG // FRANCE // Email: schaaff@astro.u-strasbg.fr, question@simbad.u-strasbg.fr // // ------- // // In accordance with the international conventions about intellectual // property rights this software and associated documentation files // (the "Software") is protected. The rightholder authorizes : // the reproduction and representation as a private copy or for educational // and research purposes outside any lucrative use, // subject to the following conditions: // // The above copyright notice shall be included. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON INFRINGEMENT, // LOSS OF DATA, LOSS OF PROFIT, LOSS OF BARGAIN OR IMPOSSIBILITY // TO USE SUCH SOFWARE. IN NO EVENT SHALL THE RIGHTHOLDER BE LIABLE // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // For any other exploitation contact the rightholder. // // ----------- // // Conformement aux conventions internationales relatives aux droits de // propriete intellectuelle ce logiciel et sa documentation sont proteges. // Le titulaire des droits autorise : // la reproduction et la representation a titre de copie privee ou des fins // d'enseignement et de recherche et en dehors de toute utilisation lucrative. // Cette autorisation est faite sous les conditions suivantes : // // La mention du copyright portee ci-dessus devra etre clairement indiquee. // // LE LOGICIEL EST LIVRE "EN L'ETAT", SANS GARANTIE D'AUCUNE SORTE. // LE TITULAIRE DES DROITS NE SAURAIT, EN AUCUN CAS ETRE TENU CONTRACTUELLEMENT // OU DELICTUELLEMENT POUR RESPONSABLE DES DOMMAGES DIRECTS OU INDIRECTS // (Y COMPRIS ET A TITRE PUREMENT ILLUSTRATIF ET NON LIMITATIF, // LA PRIVATION DE JOUISSANCE DU LOGICIEL, LA PERTE DE DONNEES, // LE MANQUE A GAGNER OU AUGMENTATION DE COUTS ET DEPENSES, LES PERTES // D'EXPLOITATION,LES PERTES DE MARCHES OU TOUTES ACTIONS EN CONTREFACON) // POUVANT RESULTER DE L'UTILISATION, DE LA MAUVAISE UTILISATION // OU DE L'IMPOSSIBILITE D'UTILISER LE LOGICIEL, ALORS MEME // QU'IL AURAIT ETE AVISE DE LA POSSIBILITE DE SURVENANCE DE TELS DOMMAGES. // // Pour toute autre utilisation contactez le titulaire des droits. // package cds.savot.samples; import java.io.IOException; import java.util.Date; import cds.savot.pull.*; import cds.savot.model.*; import java.io.FileWriter; import java.io.BufferedWriter; /** *
Title: Savot Pull Parser Tester
*Description: A sample designed to show the Pull usage of the parser
*Copyright: 2002-2003
*Company: CDS
* @author Andre Schaaff * @version 1.1 */ public class PullFullSample { static long freeMemory = 0; static long freeMemory2 = 0; public static boolean statistics = true; /** * Constructor * This example is just designed to make statistics about time and memory use to put a whole VOTable file * into memory * @param file * @param type */ public PullFullSample(String file, int type) { long begintime = 0; long endtime = 0; Date time = new Date(); try { begintime = time.getTime(); System.out.println("Total memory : " + Runtime.getRuntime().totalMemory()); freeMemory = Runtime.getRuntime().freeMemory(); System.out.println("Free memory (Begin) : " + freeMemory); // put the whole VOTable file into memory SavotPullParser sb = new SavotPullParser(file, type); time = new Date(); endtime = time.getTime(); if (statistics == true) { System.out.println(""); System.out.println("Execution statistics"); System.out.println("--------------------"); System.out.println("time delta (ms) : " + (endtime - begintime)); System.out.println("all resources counter : " + sb.getResourceCount()); System.out.println("table counter : " + sb.getTableCount()); System.out.println("table per resource : " + (float)sb.getTableCount() / (float)sb.getResourceCount()); System.out.println("row counter : " + sb.getTRCount()); System.out.println("row per table : " + (float)sb.getTRCount() / (float)sb.getTableCount()); System.out.println("data counter : " + sb.getDataCount()); System.out.println("data per raw : " + (float)sb.getDataCount() / (float)sb.getTRCount()); System.out.println("data per table : " + (float)sb.getDataCount() / (float)sb.getTableCount()); freeMemory2 = Runtime.getRuntime().freeMemory(); System.out.println("Free memory (End) : " + freeMemory2); System.out.println("memory delta (bytes) : " + (freeMemory - freeMemory2)); System.out.println("memory delta (Kbytes) : " + ((float)(freeMemory - freeMemory2) / 1024)); System.out.println("memory delta (Mbytes) : " + ((float)(freeMemory - freeMemory2) / (1024 * 1024))); System.out.println("memory per resource (bytes) : " + (float)(freeMemory - freeMemory2) / (float)sb.getResourceCount()); } // test System.out.println("1st level resource count : " + sb.getAllResources().getResources().getItemCount()); } catch(Exception e) {System.err.println("PullFullSample : " + e);}; } /** * Main method * @param argv * @throws IOException */ public static void main (String [] argv) throws IOException{ if (argv.length == 0) System.out.println("Usage: java PullFullSample