diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2016-06-21 02:30:17 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2016-06-21 02:30:17 +0000 |
commit | 523a31dad217c71e70f759893fa36becdfe08f8e (patch) | |
tree | 628e1d17bf07b0de0775e6f91ff0136bf9f5544e /src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java | |
parent | 01e9427fe979b0b2003399cccb9676cb6820c61d (diff) | |
download | jackcess-523a31dad217c71e70f759893fa36becdfe08f8e.tar.gz jackcess-523a31dad217c71e70f759893fa36becdfe08f8e.zip |
get add index def functional
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/mutateops@998 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java')
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java index 925d465..62093c1 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java @@ -1177,7 +1177,7 @@ public class TableImpl implements Table if(isLongVal) { // allocate usage maps for the long value col - Map.Entry<Integer,Integer> umapInfo = addUsageMaps(2); + Map.Entry<Integer,Integer> umapInfo = addUsageMaps(2, null); System.out.println("FOO created umap " + umapInfo); DBMutator.ColumnState colState = mutator.getColumnState(column); colState.setUmapPageNumber(umapInfo.getKey()); @@ -1309,8 +1309,16 @@ public class TableImpl implements Table ByteUtil.forward(tableBuffer, (_indexCount * format.SIZE_INDEX_COLUMN_BLOCK)); - // write index data def + // allocate usage maps and root page DBMutator.IndexDataState idxDataState = mutator.getIndexDataState(index); + int rootPageNumber = getPageChannel().allocateNewPage(); + Map.Entry<Integer,Integer> umapInfo = addUsageMaps(1, rootPageNumber); + System.out.println("FOO created umap " + umapInfo); + idxDataState.setRootPageNumber(rootPageNumber); + idxDataState.setUmapPageNumber(umapInfo.getKey()); + idxDataState.setUmapRowNumber(umapInfo.getValue().byteValue()); + + // write index data def int idxDataDefPos = tableBuffer.position(); ByteUtil.insertEmptyData(tableBuffer, format.SIZE_INDEX_COLUMN_BLOCK); IndexData.writeDefinition(mutator, tableBuffer, idxDataState, null); @@ -1388,6 +1396,7 @@ public class TableImpl implements Table format.SIZE_INDEX_INFO_BLOCK)); int idxDefPos = tableBuffer.position(); + ByteUtil.insertEmptyData(tableBuffer, format.SIZE_INDEX_INFO_BLOCK); IndexImpl.writeDefinition(mutator, index, tableBuffer); // skip existing index names and write new name @@ -1480,7 +1489,9 @@ public class TableImpl implements Table return tableBuffer; } - private Map.Entry<Integer,Integer> addUsageMaps(int numMaps) throws IOException + private Map.Entry<Integer,Integer> addUsageMaps( + int numMaps, Integer firstUsedPage) + throws IOException { JetFormat format = getFormat(); PageChannel pageChannel = getPageChannel(); @@ -1525,6 +1536,13 @@ public class TableImpl implements Table for(int i = 0; i < numMaps; ++i) { umapBuf.putShort(getRowStartOffset(umapRowNum, format), (short)rowStart); umapBuf.put(rowStart, UsageMap.MAP_TYPE_INLINE); + + if(firstUsedPage != null) { + // fill in the first used page of the usage map + umapBuf.putInt(rowStart + 1, firstUsedPage); + umapBuf.put(rowStart + 5, (byte)1); + } + rowStart -= umapRowLength; ++umapRowNum; } |