public int getIndex(int termid) throws IOException { lexIdFile.seek(SIZE_OF_INT * (long)termid); return lexIdFile.readInt(); }
public final byte[] read(long offset, int bytes) throws IOException { byte[] out = new byte[bytes]; dataSource.seek(offset); dataSource.readFully(out); return out; }
public int getIndex(int termid) throws IOException { lexIdFile.seek(SIZE_OF_INT * (long)termid); return lexIdFile.readInt(); }
public final byte[] read(long offset, int bytes) throws IOException { byte[] out = new byte[bytes]; dataSource.seek(offset); dataSource.readFully(out); return out; }
/** * {@inheritDoc} */ public V get(int entryNumber) { try{ if (entryNumber > numberOfEntries) throw new NoSuchElementException(); dataFile.seek((long)entryNumber * entrySize); value.readFields(dataFile); return value; } catch (Exception e) { throw new NoSuchElementException(e.getMessage()); } } }
/** * {@inheritDoc} */ public V get(int entryNumber) { try{ if (entryNumber > numberOfEntries) throw new NoSuchElementException(); dataFile.seek((long)entryNumber * entrySize); value.readFields(dataFile); return value; } catch (Exception e) { throw new NoSuchElementException(e.getMessage()); } } }
public ConcurrentBitInBuffered(RandomDataInput file, long startByteOffset, byte _bitOffset, int _bufLength) { super(); this.offset = startByteOffset; this.bitOffset= _bitOffset; this.parentFile = file; this.size = _bufLength; try{ synchronized (parentFile) { parentFile.seek(startByteOffset); inBuffer = new byte[size]; parentFile.readFully(inBuffer); } readByteOffset = 0; byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
public ConcurrentBitInBuffered(RandomDataInput file, long startByteOffset, byte _bitOffset, int _bufLength) { super(); this.offset = startByteOffset; this.bitOffset= _bitOffset; this.parentFile = file; this.size = _bufLength; try{ synchronized (parentFile) { parentFile.seek(startByteOffset); inBuffer = new byte[size]; parentFile.readFully(inBuffer); } readByteOffset = 0; byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
/** Move forward one byte */ protected void incrByte() { try{ readByteOffset++; offset++; if(readByteOffset == size) { readByteOffset=0; //Arrays.fill(inBuffer, (byte)0); parentFile.seek(offset); //logger.info("Reading 1024 bytes. pos="+parentFile.getFilePointer()); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
@Override protected void incrByte() { try{ readByteOffset++; offset++; if(readByteOffset == size) { readByteOffset=0; synchronized (parentFile) { parentFile.seek(offset); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
/** Move forward i bytes */ protected void incrByte(int i) { try{ //System.out.println("skypping"); offset += i; readByteOffset+=i; if( readByteOffset >= size ) // we go to the next block -- we skip only the begin of the block { parentFile.seek(offset); // we skip the first bytes of the next block //Arrays.fill(inBuffer, (byte)0); readByteOffset = 0; //logger.info("Reading 1024 bytes. pos="+parentFile.getFilePointer()); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
@Override protected void incrByte() { try{ readByteOffset++; offset++; if(readByteOffset == size) { readByteOffset=0; synchronized (parentFile) { parentFile.seek(offset); try{ parentFile.readFully(inBuffer); } catch (EOFException eofe) { /* ignore this */} } } byteRead = inBuffer[readByteOffset]; }catch(IOException ioe){ logger.error("Input/Output exception while reading from a random access file. Stack trace follows", ioe); } }
public BufferedFileByteIn(RandomDataInput file, int bufferSize, long startByteOffset, ByteFileBuffered father) throws IOException { this.file = file; this.father = father; try { file.seek(startByteOffset); this.di = new BufferedDataInput(file, file.length() - startByteOffset, bufferSize); this.byteOffset = startByteOffset; } catch (IOException e) { logger.error( "Input/Output exception while reading from a random access file. Stack trace follows", e); } } }
@Override public V get(int entryNumber) { try{ V value = valueFactory.newInstance(); if (entryNumber > numberOfEntries) throw new NoSuchElementException("Entry too big : " + entryNumber + " > " + numberOfEntries); dataFile.seek((long)entryNumber * entrySize); value.readFields(dataFile); return value; } catch (NoSuchElementException nsee) { throw nsee; } catch (Exception e) { throw new NoSuchElementException("For entry number "+entryNumber +" : " + e); } }
@Override public V get(int entryNumber) { try{ V value = valueFactory.newInstance(); if (entryNumber > numberOfEntries) throw new NoSuchElementException("Entry too big : " + entryNumber + " > " + numberOfEntries); dataFile.seek((long)entryNumber * entrySize); value.readFields(dataFile); return value; } catch (NoSuchElementException nsee) { throw nsee; } catch (Exception e) { throw new NoSuchElementException("For entry number "+entryNumber +" : " + e); } }
public BufferedFileByteIn(RandomDataInput file, int bufferSize, long startByteOffset, ByteFileBuffered father) throws IOException { this.file = file; this.father = father; try { file.seek(startByteOffset); this.di = new BufferedDataInput(file, file.length() - startByteOffset, bufferSize); this.byteOffset = startByteOffset; } catch (IOException e) { logger.error( "Input/Output exception while reading from a random access file. Stack trace follows", e); } } }
/** * {@inheritDoc} */ public Entry<K,V> get(int entryNumber) { synchronized(fileAccessLock) { K key = keyFactory.newInstance(); V value = valueFactory.newInstance(); if (entryNumber >= numberOfEntries) throw new NoSuchElementException("Entry number "+ entryNumber + " is larger than map size of "+ numberOfEntries); try{ dataFile.seek((long)entryNumber * entrySize); key.readFields(dataFile); value.readFields(dataFile); } catch (IOException ioe) { throw new NoSuchElementException( "IOException reading FSOrderedMapFile for entry number "+ entryNumber +" : "+ioe); } return new MapFileEntry<K,V>(key, value, entryNumber); } } /**
/** * {@inheritDoc} */ public Entry<K,V> get(int entryNumber) { synchronized(fileAccessLock) { K key = keyFactory.newInstance(); V value = valueFactory.newInstance(); if (entryNumber >= numberOfEntries) throw new NoSuchElementException("Entry number "+ entryNumber + " is larger than map size of "+ numberOfEntries); try{ dataFile.seek((long)entryNumber * entrySize); key.readFields(dataFile); value.readFields(dataFile); } catch (IOException ioe) { throw new NoSuchElementException( "IOException reading FSOrderedMapFile for entry number "+ entryNumber +" : "+ioe); } return new MapFileEntry<K,V>(key, value, entryNumber); } } /**
/** * 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); } } /**
/** * 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); } } /**