From 97eadc5acd14baf615376a47aca70ba739b88ab1 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Tue, 1 Oct 2013 22:57:05 +0000 Subject: [PATCH] minor updates and refactors git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@812 f203690c-595d-4dc9-a70b-905162fa7fd2 --- TODO.txt | 10 ------ .../jackcess/impl/ColumnImpl.java | 2 +- .../jackcess/impl/TableImpl.java | 33 ++++++++++--------- .../jackcess/impl/UsageMap.java | 9 +---- 4 files changed, 19 insertions(+), 35 deletions(-) diff --git a/TODO.txt b/TODO.txt index a88c41d..1966eba 100644 --- a/TODO.txt +++ b/TODO.txt @@ -6,8 +6,6 @@ Missing pieces: * MEDIUM - implement table creation w/ complex columns * MEDIUM -- implement (optional) foreign key enforcement - * MEDIUM - implement write support for properties * EASY - implement table, column, index renaming @@ -26,15 +24,7 @@ Refactor goals: - clean up javadocs - enhance public api classes * add @usage tags to util classes -* change CodecHandler usage to handle not-inline decoding - - pass filename to CodecHandler, enable pwd callbacks CallbackHandler - - pass custom context to CodecHandler? - - rework CryptCodecProvider to have custom - javax.security.auth.callback.CallbackHandler which is only invoked if - password is definitely required. - implement page buffering in PageChannel * need to implement logical flushing in update code (startUpdate/finishUpdate) -- refactor free-space handlers Table/Column? - implement "lazy" usage maps (load on first usage)? -- implement some OLE support - add typed getter methods to Row diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java index 7d26fd7..8f808cb 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java @@ -2170,7 +2170,7 @@ public class ColumnImpl implements Column, Comparable { if(TableImpl.rowFitsOnDataPage(dataLength, lvalPage, getFormat())) { // the current page has space return lvalPage; -} + } } // need new page diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java index 240ebf6..1d7e2e0 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java @@ -1792,28 +1792,29 @@ public class TableImpl implements Table TempPageHolder rowBufferH) throws IOException { - // find last data page (Not bothering to check other pages for free - // space.) + // find last data page (Not bothering to check other pages for free + // space.) UsageMap.PageCursor revPageCursor = ownedPages.cursor(); - revPageCursor.afterLast(); - while(true) { - int tmpPageNumber = revPageCursor.getPreviousPage(); - if(tmpPageNumber < 0) { - break; - } + revPageCursor.afterLast(); + while(true) { + int tmpPageNumber = revPageCursor.getPreviousPage(); + if(tmpPageNumber < 0) { + break; + } + // only use if actually listed in free space pages + if(!freeSpacePages.containsPageNumber(tmpPageNumber)) { + continue; + } ByteBuffer dataPage = rowBufferH.setPage(ownedPages.getPageChannel(), tmpPageNumber); - if(dataPage.get() == PageTypes.DATA) { - // found last data page, only use if actually listed in free space - // pages - if(freeSpacePages.containsPageNumber(tmpPageNumber)) { - return dataPage; - } - } + if(dataPage.get() == PageTypes.DATA) { + // found last data page with free space + return dataPage; } + } return null; - } + } /** * Updates the table definition after rows are modified. diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java b/src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java index ac49c44..5db2eac 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java @@ -327,13 +327,6 @@ public class UsageMap _handler.addOrRemovePageNumber(pageNumber, true, false); } - /** - * Remove a page number from this usage map - */ - public void removePageNumber(int pageNumber) throws IOException { - removePageNumber(pageNumber, false); - } - /** * Remove a page number from this usage map */ @@ -681,7 +674,7 @@ public class UsageMap } // lastly, remove the new page - removePageNumber(newPageNumber); + removePageNumber(newPageNumber, false); } } -- 2.39.5