/** * Writes a file to disk to be read for hashing. * * @throws IOException */ public static void generateHashFunctions() throws IOException { File hashFile = new File(hashFunctionsFileName); if (!hashFile.exists()) { ObjectOutputStream oos = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(hashFile))); oos.writeInt(bits); oos.writeInt(dimensions); oos.writeInt(numFunctionBundles); for (int c = 0; c < numFunctionBundles; c++) { for (int i = 0; i < bits; i++) { for (int j = 0; j < dimensions; j++) { oos.writeFloat((float) (Math.random() * w - w / 2)); } } } oos.close(); } else { System.err.println( "Hashes could not be written: " + hashFunctionsFileName + " already exists"); } }
private void writeObject(ObjectOutputStream out) throws IOException { out.writeShort(VERSION); out.writeFloat(value); }