Esempio n. 1
0
 /**
  * Convert an MVD to a string
  *
  * @param mvd the MVD to convert
  * @param rb database properties file
  * @param folderId id of the folder to contain it in
  * @throws Exception raised if an error occurred
  */
 public static String externalise(MVD mvd) throws Exception {
   int size = mvd.dataSize();
   byte[] data = new byte[size];
   int nBytes = mvd.serialise(data);
   assert nBytes == size : "MVD shorter than predicted";
   return Base64.encodeBytes(data, Base64.GZIP);
 }
Esempio n. 2
0
 /**
  * Save an MVD to a file
  *
  * @param mvd the MVD to save
  * @param dst the file to save it to
  * @param rb database properties file
  * @param folderId id of the folder to contain it in
  * @throws Exception raised if an error occurred
  */
 public static void externalise(MVD mvd, File dst, int folderId, Properties rb) throws Exception {
   long start = System.nanoTime() / 1000;
   System.gc();
   long startMem = Runtime.getRuntime().freeMemory();
   int size = mvd.dataSize();
   byte[] data = new byte[size];
   int nBytes = mvd.serialise(data);
   assert nBytes == size : "MVD shorter than predicted";
   String str = Base64.encodeBytes(data, Base64.GZIP);
   if (rb == null) writeToFile(dst, str);
   else writeToDatabase(dst.getName(), str, mvd.description, folderId, rb);
   long end = System.nanoTime() / 1000;
   long endMem = Runtime.getRuntime().freeMemory();
   System.out.println("internalise took " + (end - start) + " microseconds");
   System.out.println("Memory used " + (startMem - endMem) + " bytes");
 }