git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@278 f203690c-595d-4dc9-a70b-905162fa7fd2tags/rel_1_1_13
@@ -1200,7 +1200,7 @@ public abstract class Cursor implements Iterable<Map<String, Object>> | |||
new LinkedHashMap<String,Object>(); | |||
for(Index.ColumnDescriptor idxCol : index.getColumns()) { | |||
indexRowPattern.put(idxCol.getName(), | |||
rowValues[idxCol.getColumnNumber()]); | |||
rowValues[idxCol.getColumnIndex()]); | |||
} | |||
} | |||
@@ -757,9 +757,9 @@ public class Index implements Comparable<Index> { | |||
", expected " + _columns.size()); | |||
} | |||
int valIdx = 0; | |||
Object[] idxRow = new Object[getTable().getMaxColumnCount()]; | |||
Object[] idxRow = new Object[getTable().getColumnCount()]; | |||
for(ColumnDescriptor col : _columns) { | |||
idxRow[col.getColumnNumber()] = values[valIdx++]; | |||
idxRow[col.getColumnIndex()] = values[valIdx++]; | |||
} | |||
return idxRow; | |||
} | |||
@@ -789,9 +789,9 @@ public class Index implements Comparable<Index> { | |||
} | |||
} | |||
Object[] idxRow = new Object[getTable().getMaxColumnCount()]; | |||
Object[] idxRow = new Object[getTable().getColumnCount()]; | |||
for(ColumnDescriptor col : _columns) { | |||
idxRow[col.getColumnNumber()] = row.get(col.getName()); | |||
idxRow[col.getColumnIndex()] = row.get(col.getName()); | |||
} | |||
return idxRow; | |||
} | |||
@@ -833,11 +833,9 @@ public class Index implements Comparable<Index> { | |||
// annoyingly, the values array could come from different sources, one | |||
// of which will make it a different size than the other. we need to | |||
// handle both situations. | |||
boolean useColNumber = (values.length >= _table.getMaxColumnCount()); | |||
int nullCount = 0; | |||
for(ColumnDescriptor col : _columns) { | |||
Object value = values[ | |||
useColNumber ? col.getColumnNumber() : col.getColumnIndex()]; | |||
Object value = values[col.getColumnIndex()]; | |||
if(col.isNullValue(value)) { | |||
++nullCount; | |||
} | |||
@@ -860,10 +858,8 @@ public class Index implements Comparable<Index> { | |||
// annoyingly, the values array could come from different sources, one | |||
// of which will make it a different size than the other. we need to | |||
// handle both situations. | |||
boolean useColNumber = (values.length >= _table.getMaxColumnCount()); | |||
for(ColumnDescriptor col : _columns) { | |||
Object value = values[ | |||
useColNumber ? col.getColumnNumber() : col.getColumnIndex()]; | |||
Object value = values[col.getColumnIndex()]; | |||
col.writeValue(value, bout); | |||
} | |||
@@ -1121,10 +1117,6 @@ public class Index implements Comparable<Index> { | |||
return((getFlags() & ASCENDING_COLUMN_FLAG) != 0); | |||
} | |||
public int getColumnNumber() { | |||
return getColumn().getColumnNumber(); | |||
} | |||
public int getColumnIndex() { | |||
return getColumn().getColumnIndex(); | |||
} |
@@ -60,14 +60,15 @@ public class NullMask { | |||
public ByteBuffer wrap() { | |||
return ByteBuffer.wrap(_mask); | |||
} | |||
/** | |||
* @param columnNumber 0-based column number in this mask's row | |||
* @param column column to test for {@code null} | |||
* @return Whether or not the value for that column is null. For boolean | |||
* columns, returns the actual value of the column (where | |||
* non-{@code null} == {@code true}) | |||
*/ | |||
public boolean isNull(int columnNumber) { | |||
public boolean isNull(Column column) { | |||
int columnNumber = column.getColumnNumber(); | |||
int maskIndex = columnNumber / 8; | |||
// if new columns were added to the table, old null masks may not include | |||
// them (meaning the field is null) | |||
@@ -81,9 +82,10 @@ public class NullMask { | |||
/** | |||
* Indicate that the column with the given number is not {@code null} (or a | |||
* boolean value is {@code true}). | |||
* @param columnNumber 0-based column number in this mask's row | |||
* @param column column to be marked non-{@code null} | |||
*/ | |||
public void markNotNull(int columnNumber) { | |||
public void markNotNull(Column column) { | |||
int columnNumber = column.getColumnNumber(); | |||
int maskIndex = columnNumber / 8; | |||
_mask[maskIndex] = (byte) (_mask[maskIndex] | (byte) (1 << (columnNumber % 8))); | |||
} |
@@ -359,7 +359,7 @@ public class Table | |||
// deletion. note, most of the returned values are immutable, except | |||
// for binary data (returned as byte[]), but binary data shouldn't be | |||
// indexed anyway. | |||
rowState.setRowValue(column.getColumnNumber(), value); | |||
rowState.setRowValue(column.getColumnIndex(), value); | |||
return value; | |||
} | |||
@@ -407,7 +407,7 @@ public class Table | |||
// deletion. note, most of the returned values are immutable, except | |||
// for binary data (returned as byte[]), but binary data shouldn't be | |||
// indexed anyway. | |||
rowState.setRowValue(column.getColumnNumber(), value); | |||
rowState.setRowValue(column.getColumnIndex(), value); | |||
} | |||
} | |||
return rtn; | |||
@@ -421,7 +421,7 @@ public class Table | |||
Column column) | |||
throws IOException | |||
{ | |||
boolean isNull = nullMask.isNull(column.getColumnNumber()); | |||
boolean isNull = nullMask.isNull(column); | |||
if(column.getType() == DataType.BOOLEAN) { | |||
return Boolean.valueOf(!isNull); //Boolean values are stored in the null mask | |||
} else if(isNull) { | |||
@@ -1244,7 +1244,7 @@ public class Table | |||
if(Column.toBooleanValue(rowValue)) { | |||
//Booleans are stored in the null mask | |||
nullMask.markNotNull(col.getColumnNumber()); | |||
nullMask.markNotNull(col); | |||
} | |||
} else { | |||
@@ -1257,7 +1257,7 @@ public class Table | |||
if(rowValue != null) { | |||
// we have a value | |||
nullMask.markNotNull(col.getColumnNumber()); | |||
nullMask.markNotNull(col); | |||
//remainingRowLength is ignored when writing fixed length data | |||
buffer.position(fixedDataStart + col.getFixedDataOffset()); | |||
@@ -1292,7 +1292,7 @@ public class Table | |||
Object rowValue = row.get(varCol.getColumnIndex()); | |||
if (rowValue != null) { | |||
// we have a value | |||
nullMask.markNotNull(varCol.getColumnNumber()); | |||
nullMask.markNotNull(varCol); | |||
ByteBuffer varDataBuf = varCol.write(rowValue, maxRowSize); | |||
maxRowSize -= varDataBuf.remaining(); | |||
@@ -1582,7 +1582,7 @@ public class Table | |||
private RowState(boolean hardRowBuffer) { | |||
_headerRowBufferH = TempPageHolder.newHolder(hardRowBuffer); | |||
_rowValues = new Object[Table.this.getMaxColumnCount()]; | |||
_rowValues = new Object[Table.this.getColumnCount()]; | |||
_lastModCount = Table.this._modCount; | |||
} | |||