From: Bryan T. <tho...@us...> - 2007-02-21 20:17:34
|
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/rawstore In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5461/src/java/com/bigdata/rawstore Modified Files: SimpleMemoryRawStore.java IRawStore.java SimpleFileRawStore.java Log Message: Further work supporting transactional isolation. Index: SimpleFileRawStore.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/rawstore/SimpleFileRawStore.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SimpleFileRawStore.java 15 Feb 2007 20:59:21 -0000 1.3 --- SimpleFileRawStore.java 21 Feb 2007 20:17:21 -0000 1.4 *************** *** 55,59 **** import java.util.Set; ! import com.bigdata.journal.TemporaryStore; --- 55,59 ---- import java.util.Set; ! import com.bigdata.journal.TemporaryRawStore; *************** *** 63,67 **** * must code the offset into the file using {@link Addr#toLong(int, int)}. * ! * @see {@link TemporaryStore}, which provides a more solution for temporary * data that begins with the benefits of a memory-resident buffer and then * converts to a disk-based store on overflow. --- 63,67 ---- * must code the offset into the file using {@link Addr#toLong(int, int)}. * ! * @see {@link TemporaryRawStore}, which provides a more solution for temporary * data that begins with the benefits of a memory-resident buffer and then * converts to a disk-based store on overflow. *************** *** 128,131 **** --- 128,137 ---- } + public boolean isFullyBuffered() { + + return false; + + } + /** * This also releases the lock if any obtained by the constructor. *************** *** 149,153 **** } ! public ByteBuffer read(long addr, ByteBuffer dst) { if (addr == 0L) --- 155,159 ---- } ! public ByteBuffer read(long addr) { if (addr == 0L) *************** *** 165,172 **** } ! if(deleted.contains(addr)) { ! ! throw new IllegalArgumentException("Address was deleted in this session"); ! } --- 171,179 ---- } ! if (deleted.contains(addr)) { ! ! throw new IllegalArgumentException( ! "Address was deleted in this session"); ! } *************** *** 179,219 **** } ! if (dst != null && dst.remaining() >= nbytes) { ! ! // copy exactly this many bytes. ! ! dst.limit(dst.position() + nbytes); ! ! // copy into the caller's buffer. ! ! raf.getChannel().read(dst,(long)offset); ! ! // flip for reading. ! ! dst.flip(); ! ! // the caller's buffer. ! ! return dst; ! ! } else { ! ! // allocate a new buffer of the exact capacity. ! ! dst = ByteBuffer.allocate(nbytes); ! // copy the data into the buffer. ! raf.getChannel().read(dst,(long)offset); ! // flip for reading. ! dst.flip(); ! // return the buffer. ! return dst; ! } } catch (IOException ex) { --- 186,204 ---- } ! // allocate a new buffer of the exact capacity. ! ByteBuffer dst = ByteBuffer.allocate(nbytes); ! // copy the data into the buffer. ! raf.getChannel().read(dst, (long) offset); ! // flip for reading. ! dst.flip(); ! // return the buffer. ! return dst; } catch (IOException ex) { Index: IRawStore.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/rawstore/IRawStore.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IRawStore.java 12 Feb 2007 21:51:08 -0000 1.3 --- IRawStore.java 21 Feb 2007 20:17:21 -0000 1.4 *************** *** 150,169 **** * offset from which the data will be read and the #of bytes to * be read. - * @param dst - * The destination buffer (optional). This buffer will be used if - * it has sufficient {@link ByteBuffer#remaining()} capacity. - * When used, the data will be written into the offered buffer - * starting at {@link ByteBuffer#position()} and the - * {@link ByteBuffer#position()} will be advanced by the #of - * bytes read.<br> - * When <code>null</code> or when a buffer is offered without - * sufficient {@link ByteBuffer#remaining()} capacity the - * implementation is encouraged to return a read-only slice - * containing the data or, failing that, to allocate a new buffer - * with sufficient capacity.<br> - * Note that it is not an error to offer a buffer that is too - * small - it will simply be ignored.<br> - * Note that it is not an error to offer a buffer with excess - * remaining capacity. * * @return The data read. The buffer will be flipped to prepare for reading --- 150,153 ---- *************** *** 175,179 **** * deleted). Note that the address 0L is always invalid. */ ! public ByteBuffer read(long addr, ByteBuffer dst); /** --- 159,197 ---- * deleted). Note that the address 0L is always invalid. */ ! public ByteBuffer read(long addr); ! ! // /** ! // * Read the data (unisolated). ! // * ! // * @param addr ! // * A long integer formed using {@link Addr} that encodes both the ! // * offset from which the data will be read and the #of bytes to ! // * be read. ! // * @param dst ! // * The destination buffer (optional). This buffer will be used if ! // * it has sufficient {@link ByteBuffer#remaining()} capacity. ! // * When used, the data will be written into the offered buffer ! // * starting at {@link ByteBuffer#position()} and the ! // * {@link ByteBuffer#position()} will be advanced by the #of ! // * bytes read.<br> ! // * When <code>null</code> or when a buffer is offered without ! // * sufficient {@link ByteBuffer#remaining()} capacity the ! // * implementation is encouraged to return a read-only slice ! // * containing the data or, failing that, to allocate a new buffer ! // * with sufficient capacity.<br> ! // * Note that it is not an error to offer a buffer that is too ! // * small - it will simply be ignored.<br> ! // * Note that it is not an error to offer a buffer with excess ! // * remaining capacity. ! // * ! // * @return The data read. The buffer will be flipped to prepare for reading ! // * (the position will be zero and the limit will be the #of bytes ! // * read). ! // * ! // * @exception IllegalArgumentException ! // * If the address is known to be invalid (never written or ! // * deleted). Note that the address 0L is always invalid. ! // */ ! // public ByteBuffer read(long addr, ByteBuffer dst); /** *************** *** 194,199 **** --- 212,234 ---- /** * True iff backed by stable storage. + * + * @exception IllegalStateException + * if the store is not open. */ public boolean isStable(); + + /** + * True iff the store is fully buffered (all reads are against memory). + * Implementations MAY change the value returned by this method over the + * life cycle of the store, e.g., to conserve memory a store may drop or + * decrease its buffer if it is backed by disk. + * <p> + * Note: This does not guarentee that the OS will not swap the buffer onto + * disk. + * + * @exception IllegalStateException + * if the store is not open. + */ + public boolean isFullyBuffered(); /** Index: SimpleMemoryRawStore.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/rawstore/SimpleMemoryRawStore.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SimpleMemoryRawStore.java 15 Feb 2007 20:59:21 -0000 1.2 --- SimpleMemoryRawStore.java 21 Feb 2007 20:17:21 -0000 1.3 *************** *** 53,57 **** import java.util.Map; ! import com.bigdata.journal.TemporaryStore; /** --- 53,57 ---- import java.util.Map; ! import com.bigdata.journal.TemporaryRawStore; /** *************** *** 59,63 **** * buffered in memory. The writes are stored in an {@link ArrayList}. * ! * @see {@link TemporaryStore}, which provides a more scalable solution for temporary * data. * --- 59,63 ---- * buffered in memory. The writes are stored in an {@link ArrayList}. * ! * @see {@link TemporaryRawStore}, which provides a more scalable solution for temporary * data. * *************** *** 130,133 **** --- 130,139 ---- } + public boolean isFullyBuffered() { + + return true; + + } + public void close() { *************** *** 141,145 **** } ! public ByteBuffer read(long addr, ByteBuffer dst) { if (addr == 0L) --- 147,151 ---- } ! public ByteBuffer read(long addr) { if (addr == 0L) *************** *** 179,207 **** } ! if(dst != null && dst.remaining()>=nbytes) { ! ! // place limit on the #of valid bytes in dst. ! ! dst.limit(dst.position() + nbytes); ! ! // copy into the caller's buffer. ! ! dst.put(b,0,b.length); ! ! // flip for reading. ! ! dst.flip(); ! ! // the caller's buffer. ! ! return dst; ! ! } else { ! ! // return a read-only view onto the data in the store. ! ! return ByteBuffer.wrap(b).asReadOnlyBuffer(); ! } } --- 185,191 ---- } ! // return a read-only view onto the data in the store. ! return ByteBuffer.wrap(b).asReadOnlyBuffer(); } |