aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java7
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/IndexData.java5
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java6
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java37
4 files changed, 54 insertions, 1 deletions
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<ColumnImpl> {
return new ColumnImpl(args);
}
- /**
+ /**
* Sets the usage maps for this column.
*/
void setUsageMaps(UsageMap ownedPages, UsageMap freeSpacePages) {
// base does nothing
}
+ void collectUsageMapPages(Collection<Integer> 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<Integer> 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<Integer> 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<Integer,Integer> 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<Integer> knownPages = new HashSet<Integer>();
+ collectUsageMapPages(knownPages);
+ // FIXME
+
+
+
+ return new AbstractMap.SimpleImmutableEntry<Integer,Integer>(
+ umapPageNumber, firstRowNum);
+ }
+
+ void collectUsageMapPages(Collection<Integer> pages) {
+ pages.add(_ownedPages.getTablePageNumber());
+ pages.add(_freeSpacePages.getTablePageNumber());
+
+ for(IndexData idx : _indexDatas) {
+ idx.collectUsageMapPages(pages);
+ }
+ }
+
/**
* @param buffer Buffer to write to
*/