/** returns the length of file f */ public static long length(File f) { return length(f.getPath()); }
/** returns the length of file f */ public static long length(File f) { return length(f.getPath()); }
/** Loads the entire file represented by filename into memory * @param filename Location of bit file to read into memory * @throws IOException if anything goes wrong reading the file */ public BitFileInMemory(String filename) throws IOException { this(Files.openFileStream(filename), Files.length(filename)); }
/** Loads the entire file represented by filename into memory * @param filename Location of bit file to read into memory * @throws IOException if anything goes wrong reading the file */ public BitFileInMemory(String filename) throws IOException { this(Files.openFileStream(filename), Files.length(filename)); }
/** Construct a new RandomDataInputMemory object, backed by the specified file */ public RandomDataInputMemory(String filename) throws IOException { this(new DataInputStream(Files.openFileStream(filename)), Files.length(filename)); }
/** Construct a new RandomDataInputMemory object, backed by the specified file */ public RandomDataInputMemory(String filename) throws IOException { this(new DataInputStream(Files.openFileStream(filename)), Files.length(filename)); }
/** * Constructs an instance of the class for a given filename * @param filename java.lang.String the name of the underlying file * @param bufSize how much of the file to buffer */ public BitFileBuffered(String filename, int bufSize) { buffer_size = bufSize; try { fileSize = Files.length(filename); file = Files.openFileRandom(filename); } catch (IOException ioe) { logger.error("Input/Output exception while creating BitFileBuffered object.", ioe); } }
/** * Constructs an instance of the class for a given filename * @param filename java.lang.String the name of the underlying file * @param bufSize how much of the file to buffer */ public BitFileBuffered(String filename, int bufSize) { buffer_size = bufSize; try { fileSize = Files.length(filename); file = Files.openFileRandom(filename); } catch (IOException ioe) { logger.error("Input/Output exception while creating BitFileBuffered object.", ioe); } }
public InMemoryLookup(String path, String prefix, String structureName, int size) throws IOException { String filename = constructFilename(structureName, path, prefix, ID_EXT); size = (int)(Files.length(filename) / (long)4); DataInputStream lexIdFile = new DataInputStream(Files.openFileStream(filename)); id2index = new int[size]; for(int i=0;i<size;i++) { id2index[i] = lexIdFile.readInt(); } lexIdFile.close(); }
public InMemoryLookup(String path, String prefix, String structureName, int size) throws IOException { String filename = constructFilename(structureName, path, prefix, ID_EXT); size = (int)(Files.length(filename) / (long)4); DataInputStream lexIdFile = new DataInputStream(Files.openFileStream(filename)); id2index = new int[size]; for(int i=0;i<size;i++) { id2index[i] = lexIdFile.readInt(); } lexIdFile.close(); }
/** constructor * * @param filename * @param _valueFactory * @throws IOException */ public ArrayFileIterator(String filename, FixedSizeWriteableFactory<V> _valueFactory) throws IOException { valueFactory = _valueFactory; dis = new DataInputStream(Files.openFileStream(filename)); numberOfEntries = (int) (Files.length(filename) / ((long) valueFactory.getSize())); } /**
/** constructor * * @param filename * @param _valueFactory * @throws IOException */ public ArrayFileIterator(String filename, FixedSizeWriteableFactory<V> _valueFactory) throws IOException { valueFactory = _valueFactory; dis = new DataInputStream(Files.openFileStream(filename)); numberOfEntries = (int) (Files.length(filename) / ((long) valueFactory.getSize())); } /**
/** Return number of entries * * @param filename * @param _keyFactory * @param _valueFactory * @return number of entries */ public static int numberOfEntries( String filename, FixedSizeWriteableFactory<?> _keyFactory, FixedSizeWriteableFactory<?> _valueFactory) { long length = Files.length(filename); long entrySize = _keyFactory.getSize() + _valueFactory.getSize(); return (int)(length/entrySize); } /**
/** Return number of entries * * @param filename * @param _keyFactory * @param _valueFactory * @return number of entries */ public static int numberOfEntries( String filename, FixedSizeWriteableFactory<?> _keyFactory, FixedSizeWriteableFactory<?> _valueFactory) { long length = Files.length(filename); long entrySize = _keyFactory.getSize() + _valueFactory.getSize(); return (int)(length/entrySize); } /**
/** constructor * * @param filename * @param _keyFactory * @param _valueFactory * @throws IOException */ public MapFileInMemory(String filename, FixedSizeWriteableFactory<IK> _keyFactory, FixedSizeWriteableFactory<IV> _valueFactory) throws IOException { this( new DataInputStream(Files.openFileStream(filename)), (int)(Files.length(filename)/( _keyFactory.getSize() + _valueFactory.getSize() )), _keyFactory, _valueFactory ); }
/** 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(); } /**
/** * constructor * @param filename * @param _keyFactory * @param _valueFactory * @throws IOException */ public EntryIterator(String filename, FixedSizeWriteableFactory<IK> _keyFactory, FixedSizeWriteableFactory<IV> _valueFactory) throws IOException { this( new DataInputStream(Files.openFileStream(filename)), (int)(Files.length(filename)/( _keyFactory.getSize() + _valueFactory.getSize() )), _keyFactory, _valueFactory ); }
/** constructor * * @param filename * @param _keyFactory * @param _valueFactory * @throws IOException */ public MapFileInMemory(String filename, FixedSizeWriteableFactory<IK> _keyFactory, FixedSizeWriteableFactory<IV> _valueFactory) throws IOException { this( new DataInputStream(Files.openFileStream(filename)), (int)(Files.length(filename)/( _keyFactory.getSize() + _valueFactory.getSize() )), _keyFactory, _valueFactory ); }
/** * constructor * @param filename * @param _keyFactory * @param _valueFactory * @throws IOException */ public EntryIterator(String filename, FixedSizeWriteableFactory<IK> _keyFactory, FixedSizeWriteableFactory<IV> _valueFactory) throws IOException { this( new DataInputStream(Files.openFileStream(filename)), (int)(Files.length(filename)/( _keyFactory.getSize() + _valueFactory.getSize() )), _keyFactory, _valueFactory ); }
/** Load a new run from files. * @param filename the filename of the file containing the posting lists * @param termsFile the filename of the file containing the term names * @param runNo the number of this run * @param _postingInRunClass the class that all postings in this class have */ public FileRunIterator(String filename, String termsFile, int runNo, Class<? extends PostingInRun> _postingInRunClass, int fieldCount) throws Exception{ super(_postingInRunClass, runNo, fieldCount); mbis = new BitInputStream(filename); stringDIS = new DataInputStream( Files.openFileStream(termsFile) ); if (Files.length(filename) > 0) { maxSize = mbis.readGamma(); size = mbis.readGamma(); } createPosting(); currentPosting = 0; }