From: James Ahlborn Date: Fri, 29 Apr 2016 01:47:00 +0000 (+0000) Subject: begin adding umap support X-Git-Tag: jackcess-2.1.5~7^2~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c1c9b4fec21a593e3d9982b5c8be831ac52e9ae7;p=jackcess.git begin adding umap support git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/mutateops@984 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java index 24c53ad..596bc35 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java @@ -33,6 +33,7 @@ import java.sql.Blob; import java.sql.Clob; import java.sql.SQLException; import java.util.Calendar; +import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; @@ -309,13 +310,17 @@ public class ColumnImpl implements Column, Comparable { return new ColumnImpl(args); } - /** + /** * Sets the usage maps for this column. */ void setUsageMaps(UsageMap ownedPages, UsageMap freeSpacePages) { // base does nothing } + void collectUsageMapPages(Collection pages) { + // base does nothing + } + /** * Secondary column initialization after the table is fully loaded. */ diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java b/src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java index 3cff2e7..e5e6dc7 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java @@ -21,6 +21,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -372,6 +373,10 @@ public class IndexData { _ownedPages.addPageNumber(pageNumber); } + void collectUsageMapPages(Collection pages) { + pages.add(_ownedPages.getTablePageNumber()); + } + /** * Used by unit tests to validate the internal status of the index. * @usage _advanced_method_ diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java index a42da54..b33c84a 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java @@ -17,8 +17,10 @@ limitations under the License. package com.healthmarketscience.jackcess.impl; import java.io.IOException; +import java.lang.reflect.Type; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.util.Collection; /** @@ -69,6 +71,10 @@ class LongValueColumnImpl extends ColumnImpl _lvalBufferH = new UmapLongValueBufferHolder(ownedPages, freeSpacePages); } + void collectUsageMapPages(Collection pages) { + // FIXME, writeme + } + @Override void postTableLoadInit() throws IOException { if(_lvalBufferH == null) { diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java index fd55628..4d27ed7 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java @@ -22,12 +22,14 @@ import java.io.StringWriter; import java.nio.BufferOverflowException; import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -1275,6 +1277,41 @@ public class TableImpl implements Table return tableBuffer; } + private Map.Entry addUsageMaps(int numMaps) + { + JetFormat format = getFormat(); + int umapRowLength = format.OFFSET_USAGE_MAP_START + + format.USAGE_MAP_TABLE_BYTE_LENGTH; + int totalUmapSpaceUsage = getRowSpaceUsage(umapRowLength, format) * numMaps; + int umapPageNumber = PageChannel.INVALID_PAGE_NUMBER; + int firstRowNum = -1; + ByteBuffer umapBuf = null; + int freeSpace = 0; + int rowStart = 0; + int umapRowNum = 0; + + // search currently known usage map buffers to find one with enough free + // space (the numMaps should always be small enough to put them all on one + // page) + Set knownPages = new HashSet(); + collectUsageMapPages(knownPages); + // FIXME + + + + return new AbstractMap.SimpleImmutableEntry( + umapPageNumber, firstRowNum); + } + + void collectUsageMapPages(Collection pages) { + pages.add(_ownedPages.getTablePageNumber()); + pages.add(_freeSpacePages.getTablePageNumber()); + + for(IndexData idx : _indexDatas) { + idx.collectUsageMapPages(pages); + } + } + /** * @param buffer Buffer to write to */