/** * load compressed file into memory * @param filename * @throws IOException */ public BitFileInMemoryLarge(String filename) throws IOException { this(new RandomDataInputMemory(filename)); }
@Override public ByteIn readReset(long startByteOffset) throws IOException { try{ RandomDataInputMemory clone = (RandomDataInputMemory) rdim.clone(); clone.seek(startByteOffset); ByteIn in = new ByteInputStream(clone, startByteOffset); return in; } catch (CloneNotSupportedException e) { throw new WrappedIOException(e); } } }
/** * {@inheritDoc} */ public void close() throws IOException { rdim.close(); }
/** * Reads from the file from a specific offset. After this * call, a sequence of read calls may follow. * @param startByteOffset the starting byte to read from * @param startBitOffset the bit offset in the starting byte */ public BitIn readReset(long startByteOffset, byte startBitOffset) throws IOException { try{ RandomDataInput rdi = (RandomDataInput)rdim.clone(); rdi.seek(startByteOffset); BitIn in = new BitInputStream(rdi); in.skipBits(startBitOffset); return in; } catch (CloneNotSupportedException e) { throw new WrappedIOException(e); } } /**
/** Construct a new RandomDataInputMemory object, backed by the specified buffer */ public RandomDataInputMemory(DataInputStream in, long length) throws IOException { super(getSeekable(in, length)); buf = (Seekable)super.in; }
/** * Reads from the file from a specific offset. After this * call, a sequence of read calls may follow. * @param startByteOffset the starting byte to read from * @param startBitOffset the bit offset in the starting byte */ public BitIn readReset(long startByteOffset, byte startBitOffset) throws IOException { try{ RandomDataInput rdi = (RandomDataInput)rdim.clone(); rdi.seek(startByteOffset); BitIn in = new BitInputStream(rdi); in.skipBits(startBitOffset); return in; } catch (CloneNotSupportedException e) { throw new WrappedIOException(e); } } /**
/** Construct a new RandomDataInputMemory object, backed by the specified buffer */ public RandomDataInputMemory(DataInputStream in, long length) throws IOException { super(getSeekable(in, length)); buf = (Seekable)super.in; }
/** * load compressed file into memory * @param filename * @throws IOException */ public BitFileInMemoryLarge(String filename) throws IOException { this(new RandomDataInputMemory(filename)); }
@Override public ByteIn readReset(long startByteOffset) throws IOException { try{ RandomDataInputMemory clone = (RandomDataInputMemory) rdim.clone(); clone.seek(startByteOffset); ByteIn in = new ByteInputStream(clone, startByteOffset); return in; } catch (CloneNotSupportedException e) { throw new WrappedIOException(e); } } }
/** * {@inheritDoc} */ public void close() throws IOException { rdim.close(); }
public ByteFileInMemory(String dataFilename) throws IOException { this.rdim = new RandomDataInputMemory(dataFilename); }
@Override public void close() { try { rdim.close(); } catch (IOException ioe) { logger.error( "Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
public ByteFileInMemory(String dataFilename) throws IOException { this.rdim = new RandomDataInputMemory(dataFilename); }
@Override public void close() { try { rdim.close(); } catch (IOException ioe) { logger.error( "Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
protected BitIn getBitIn() throws Exception { return new BitFileBuffered(new RandomDataInputMemory(filename)).readReset((long)0, (byte)0, new File(filename).length()-1, (byte)7); } }
@Override public Object clone() throws CloneNotSupportedException { InputStream in = null; if (buf instanceof MultiSeeakableByteArrayInputStream) { in = new MultiSeeakableByteArrayInputStream( ((MultiSeeakableByteArrayInputStream)buf).data, ((MultiSeeakableByteArrayInputStream)buf).pos, ((MultiSeeakableByteArrayInputStream)buf).length); } else if (buf instanceof SeeakableByteArrayInputStream) { in = new SeeakableByteArrayInputStream(((SeeakableByteArrayInputStream)buf).getBuffer()); } try{ return new RandomDataInputMemory(in); } catch (IOException ioe) { throw new CloneNotSupportedException(ioe.getMessage()); } }
new RandomDataInputMemory(filename), filename, keyFactory,
/** constructor * * @param filename * @param updateable * @param factory * @throws IOException */ public FSArrayFileInMem(String filename, boolean updateable, FixedSizeWriteableFactory<V> factory) throws IOException { super(); this.valueFactory = factory; long len = Files.length(filename); if (len > Integer.MAX_VALUE) throw new IOException("ArrayFileInMem too big: > Integer.MAX_VALUE"); byte b[] = new byte[(int)len]; DataInputStream dis = new DataInputStream(Files.openFileStream(filename)); dis.readFully(b); dis.close(); this.dataFile = new RandomDataInputMemory(b); this.entrySize = factory.getSize(); this.numberOfEntries = (int)(len / (long)entrySize); //System.err.println("document index: "+ this.numberOfEntries + " entries of size "+ entrySize); value = factory.newInstance(); } /**
@Override public Object clone() throws CloneNotSupportedException { InputStream in = null; if (buf instanceof MultiSeeakableByteArrayInputStream) { in = new MultiSeeakableByteArrayInputStream( ((MultiSeeakableByteArrayInputStream)buf).data, ((MultiSeeakableByteArrayInputStream)buf).pos, ((MultiSeeakableByteArrayInputStream)buf).length); } else if (buf instanceof SeeakableByteArrayInputStream) { in = new SeeakableByteArrayInputStream(((SeeakableByteArrayInputStream)buf).getBuffer()); } try{ return new RandomDataInputMemory(in); } catch (IOException ioe) { throw new CloneNotSupportedException(ioe.getMessage()); } }
protected BitIn getBitIn() throws Exception { return new BitFileBuffered(new RandomDataInputMemory(filename)).readReset((long)0, (byte)0, new File(filename).length()-1, (byte)7); } }