Package org.fusesource.hawtdb.api

Examples of org.fusesource.hawtdb.api.IOPagingException


    }
  }
 
    public ByteBuffer slice(boolean readOnly, long position, int length) {
        if( this.readOnly && !readOnly ) {
            throw new IOPagingException("read only");
        }
        int bufferIndex = (int) (position / bufferSize);
        int bufferOffset = (int) (position % bufferSize);
        ByteBuffer buffer = loadBuffer(bufferIndex);
        buffer = position(buffer, bufferOffset);
        int remaining = buffer.remaining();
        if (length > remaining) {
            try {
                buffer = channel.map( readOnly ? MapMode.READ_ONLY : MapMode.READ_WRITE, position, length);
                bounderyBuffers.add(buffer);
                return buffer;
            } catch (IOException e) {
                throw new IOPagingException(e);
            }
        }
        return ((ByteBuffer) buffer.limit(buffer.position()+length)).slice();
    }
View Full Code Here


    return new ChannelTransfer(channel, position, length);
  }
 
  public void writeChannelTansfer(long position, ChannelTransfer transfer) throws IOPagingException {
        if( this.readOnly ) {
            throw new IOPagingException("read only");
        }
    try {
            channel.position(position);
            transfer.writeTo(channel);
        } catch (IOException e) {
            throw new IOPagingException(e);
        }
  }
View Full Code Here

        }
  }
 
  public void write(long position, byte[] data) throws IOPagingException {
        if( this.readOnly ) {
            throw new IOPagingException("read only");
        }
    this.write(position, data, 0, data.length);
  }
View Full Code Here

    this.write(position, data, 0, data.length);
  }

  public void write(long position, Buffer data) throws IOPagingException {
        if( this.readOnly ) {
            throw new IOPagingException("read only");
        }
    this.write(position, data.data, data.offset, data.length);
  }
View Full Code Here

    this.write(position, data.data, data.offset, data.length);
  }

  public void write(long position, ByteBuffer data) throws IOPagingException {
        if( this.readOnly ) {
            throw new IOPagingException("read only");
        }
    int bufferIndex = (int) (position / bufferSize);
    int bufferOffset = (int) (position % bufferSize);
    ByteBuffer buffer = loadBuffer(bufferIndex);
    buffer = position(buffer, bufferOffset);
View Full Code Here

  }

  public void write(long position, byte[] data, int offset, int length)
      throws IOPagingException {
        if( this.readOnly ) {
            throw new IOPagingException("read only");
        }
    int bufferIndex = (int) (position / bufferSize);
    int bufferOffset = (int) (position % bufferSize);
    ByteBuffer buffer = loadBuffer(bufferIndex);
    buffer = position(buffer, bufferOffset);
View Full Code Here

    if (buffer == null) {
      try {
                long position = ((long)index)*bufferSize;
                buffer = channel.map(MapMode.READ_WRITE, position, bufferSize);
            } catch (IllegalArgumentException e) {
                throw new IOPagingException(e);
            } catch (IOException e) {
                throw new IOPagingException(e);
            }
      buffers.set(index, buffer);
    }
    return buffer;
  }
View Full Code Here

    return buffer;
  }

  public void sync() throws IOPagingException {
        if( this.readOnly ) {
            throw new IOPagingException("read only");
        }
    for (MappedByteBuffer buffer : buffers) {
      if (buffer != null) {
        buffer.force();
      }
    }
        try {
            IOHelper.sync(fd);
        } catch (IOException e) {
            throw new IOPagingException(e);
        }
  }
View Full Code Here

    }
    buffers.clear();
    try {
            channel.close();
        } catch (IOException e) {
            throw new IOPagingException(e);
        }
  }
View Full Code Here

       
        Buffer m = new Buffer(magic.length);
        buffer.get(m.data);
       
        if( !magic.equals(m) ) {
            throw new IOPagingException("Invalid extent read request.  The requested page was not an extent: "+page);
        }
       
        IntBuffer ib = buffer.asIntBuffer();
        length = ib.get();
        next = ib.get();
View Full Code Here

TOP

Related Classes of org.fusesource.hawtdb.api.IOPagingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.