/** * {@inheritDoc} */ @Override public void close() { if (randomFile != null) { try { randomFile.close(); } catch (IOException e) { // We cannot throw an exception within a release statement. LOG.log(Level.WARNING, "Unable to close random access file.", e); } randomFile = null; } } }
/** * Seeks to the specified location in the storage file. * * @param offset * The file offset to seek to. */ private void seek(long offset) { try { randomFile.seek(offset); } catch (IOException e) { throw new OsmosisRuntimeException("Unable to seek to position " + offset + " in the storage file.", e); } }
/** * Returns the length of data. * * @return The data length in bytes. */ public long length() { try { return randomFile.length(); } catch (IOException e) { throw new OsmosisRuntimeException("Unable to obtain the length of the storage file.", e); } }
/** * Creates a new reader capable of accessing the contents of this store. The * reader must be explicitly released when no longer required. Readers must * be released prior to this store. * * @return A store reader. */ public RandomAccessObjectStoreReader<T> createReader() { initializeReadingStage(); try { BufferedRandomAccessFileInputStream randomFileReader; randomFileReader = new BufferedRandomAccessFileInputStream(storageFile); return new RandomAccessObjectStoreReader<T>( randomFileReader, serializationFactory.createObjectReader( new DataInputStoreReader( new DataInputStream(randomFileReader)), storeClassRegister) ); } catch (FileNotFoundException e) { throw new OsmosisRuntimeException( "Unable to create object stream reading from file " + storageFile + ".", e); } }
/** * {@inheritDoc} */ @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
/** * Returns the current read position. * * @return The current offset offset in bytes. */ public long position() { try { return randomFile.position(); } catch (IOException e) { throw new OsmosisRuntimeException("Unable to obtain the current position in the storage file.", e); } }
/** * Creates a new reader capable of accessing the contents of this store. The * reader must be explicitly released when no longer required. Readers must * be released prior to this store. * * @return A store reader. */ public RandomAccessObjectStoreReader<T> createReader() { initializeReadingStage(); try { BufferedRandomAccessFileInputStream randomFileReader; randomFileReader = new BufferedRandomAccessFileInputStream(storageFile); return new RandomAccessObjectStoreReader<T>( randomFileReader, serializationFactory.createObjectReader( new DataInputStoreReader( new DataInputStream(randomFileReader)), storeClassRegister) ); } catch (FileNotFoundException e) { throw new OsmosisRuntimeException( "Unable to create object stream reading from file " + storageFile + ".", e); } }
/** * {@inheritDoc} */ @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
/** * Returns the current read position. * * @return The current offset offset in bytes. */ public long position() { try { return randomFile.position(); } catch (IOException e) { throw new OsmosisRuntimeException("Unable to obtain the current position in the storage file.", e); } }
/** * Seeks to the specified location in the storage file. * * @param offset * The file offset to seek to. */ private void seek(long offset) { try { randomFile.seek(offset); } catch (IOException e) { throw new OsmosisRuntimeException("Unable to seek to position " + offset + " in the storage file.", e); } }
/** * {@inheritDoc} */ @Override public void close() { if (randomFile != null) { try { randomFile.close(); } catch (IOException e) { // We cannot throw an exception within a release statement. LOG.log(Level.WARNING, "Unable to close random access file.", e); } randomFile = null; } } }
fileInStream = new BufferedRandomAccessFileInputStream(nodeStorageFile); dataInStream = new DataInputStream(fileInStream);
/** * Returns the length of data. * * @return The data length in bytes. */ public long length() { try { return randomFile.length(); } catch (IOException e) { throw new OsmosisRuntimeException("Unable to obtain the length of the storage file.", e); } }
byte validFlag; fileInStream.seek(offset); validFlag = dataInStream.readByte();
fileInStream.close(); } catch (Exception e) {
fileInStream = new BufferedRandomAccessFileInputStream(nodeStorageFile); dataInStream = new DataInputStream(fileInStream);
byte validFlag; fileInStream.seek(offset); validFlag = dataInStream.readByte();
fileInStream.close(); } catch (Exception e) {