/** * Synchronizes any changes that are cached in memory to disk. * * @exception IOException * If an I/O error occurred. */ public void sync() throws IOException { dataStore.sync(); }
/** * Closes the ValueStore, releasing any file references, etc. Once closed, the ValueStore can no longer be * used. * * @exception IOException * If an I/O error occurred. */ public void close() throws IOException { dataStore.close(); }
public DataStore(File dataDir, String filePrefix, boolean forceSync) throws IOException { dataFile = new DataFile(new File(dataDir, filePrefix + ".dat"), forceSync); idFile = new IDFile(new File(dataDir, filePrefix + ".id"), forceSync); hashFile = new HashFile(new File(dataDir, filePrefix + ".hash"), forceSync); }
/** * Gets the value for the specified ID. * * @param id * A value ID, should be larger than 0. * @return The value for the ID, or <tt>null</tt> if no such value could be found. * @exception IOException * If an I/O error occurred. */ public byte[] getData(int id) throws IOException { assert id > 0 : "id must be larger than 0, is: " + id; // Data not in cache or cache not used, fetch from file long offset = idFile.getOffset(id); if (offset != 0L) { return dataFile.getData(offset); } return null; }
/** * Returns the maximum value-ID that is in use. * * @return The largest ID, or <tt>0</tt> if the store does not contain any values. * @throws IOException * If an I/O error occurs. */ public int getMaxID() throws IOException { return idFile.getMaxID(); }
/** * Gets an iterator that iterates over the IDs with hash codes that match the specified hash code. */ public IDIterator getIDIterator(int hash) throws IOException { return new IDIterator(hash); }
/** * Gets an iterator that can be used to iterate over all stored data. * * @return a DataIterator. */ public DataIterator iterator() { return new DataIterator(); }
public DataStore(File dataDir, String filePrefix, boolean forceSync) throws IOException { dataFile = new DataFile(new File(dataDir, filePrefix + ".dat"), forceSync); idFile = new IDFile(new File(dataDir, filePrefix + ".id"), forceSync); hashFile = new HashFile(new File(dataDir, filePrefix + ".hash"), forceSync); }
/** * Gets the value for the specified ID. * * @param id * A value ID, should be larger than 0. * @return The value for the ID, or <tt>null</tt> if no such value could be found. * @exception IOException * If an I/O error occurred. */ public byte[] getData(int id) throws IOException { assert id > 0 : "id must be larger than 0, is: " + id; // Data not in cache or cache not used, fetch from file long offset = idFile.getOffset(id); if (offset != 0L) { return dataFile.getData(offset); } return null; }
/** * Synchronizes any changes that are cached in memory to disk. * * @exception IOException * If an I/O error occurred. */ public void sync() throws IOException { dataStore.sync(); }
/** * Closes the ValueStore, releasing any file references, etc. Once closed, the ValueStore can no longer be * used. * * @exception IOException * If an I/O error occurred. */ public void close() throws IOException { dataStore.close(); }
/** * Returns the maximum value-ID that is in use. * * @return The largest ID, or <tt>0</tt> if the store does not contain any values. * @throws IOException * If an I/O error occurs. */ public int getMaxID() throws IOException { return idFile.getMaxID(); }
/** * Gets an iterator that iterates over the IDs with hash codes that match the specified hash code. */ public IDIterator getIDIterator(int hash) throws IOException { return new IDIterator(hash); }
/** * Gets an iterator that can be used to iterate over all stored data. * * @return a DataIterator. */ public DataIterator iterator() { return new DataIterator(); }