aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2016-04-29 01:47:00 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2016-04-29 01:47:00 +0000
commitc1c9b4fec21a593e3d9982b5c8be831ac52e9ae7 (patch)
tree00e6dfa84a777b436c6090e4b9a713874a74bfe1
parent595044d1a5f38da203a83d7c870bb5001aea1a59 (diff)
downloadjackcess-c1c9b4fec21a593e3d9982b5c8be831ac52e9ae7.tar.gz
jackcess-c1c9b4fec21a593e3d9982b5c8be831ac52e9ae7.zip
begin adding umap support
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/mutateops@984 f203690c-595d-4dc9-a70b-905162fa7fd2
-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
*/