JetFormat format)
{
short value = buffer.getShort(position);
- byte version = buffer.get(position + 3);
+ byte version = 0;
+ if(format.SIZE_SORT_ORDER == 4) {
+ version = buffer.get(position + 3);
+ }
+
if(value == 0) {
// probably a file we wrote, before handling sort order
return format.DEFAULT_SORT_ORDER;
sortOrder = format.DEFAULT_SORT_ORDER;
}
buffer.putShort(sortOrder.getValue());
- buffer.put((byte)0x00); // unknown
- buffer.put(sortOrder.getVersion());
+ if(format.SIZE_SORT_ORDER == 4) {
+ buffer.put((byte)0x00); // unknown
+ buffer.put(sortOrder.getVersion());
+ }
}
/**
_format.MAX_COLUMNS_PER_TABLE + " columns");
}
+ Column.SortOrder dbSortOrder = null;
+ try {
+ dbSortOrder = getDefaultSortOrder();
+ } catch(IOException e) {
+ // ignored, just use the jet format default
+ }
+
Set<String> colNames = new HashSet<String>();
// next, validate the column definitions
for(Column column : columns) {
throw new IllegalArgumentException("duplicate column name: " +
column.getName());
}
+
+ // set the sort order to the db default (if unspecified)
+ if(column.getType().isTextual() && (column.getTextSortOrder() == null)) {
+ column.setTextSortOrder(dbSortOrder);
+ }
}
List<Column> autoCols = Table.getAutoNumberColumns(columns);
public final int OFFSET_PASSWORD;
public final int SIZE_PASSWORD;
public final int OFFSET_SORT_ORDER;
+ public final int SIZE_SORT_ORDER;
public final int OFFSET_ENCODING_KEY;
public final int OFFSET_NEXT_TABLE_DEF_PAGE;
public final int OFFSET_NUM_ROWS;
OFFSET_PASSWORD = defineOffsetPassword();
SIZE_PASSWORD = defineSizePassword();
OFFSET_SORT_ORDER = defineOffsetSortOrder();
+ SIZE_SORT_ORDER = defineSizeSortOrder();
OFFSET_ENCODING_KEY = defineOffsetEncodingKey();
OFFSET_NEXT_TABLE_DEF_PAGE = defineOffsetNextTableDefPage();
OFFSET_NUM_ROWS = defineOffsetNumRows();
protected abstract int defineOffsetPassword();
protected abstract int defineSizePassword();
protected abstract int defineOffsetSortOrder();
+ protected abstract int defineSizeSortOrder();
protected abstract int defineOffsetEncodingKey();
protected abstract int defineOffsetNextTableDefPage();
protected abstract int defineOffsetNumRows();
@Override
protected int defineOffsetSortOrder() { return 58; }
@Override
+ protected int defineSizeSortOrder() { return 2; }
+ @Override
protected int defineOffsetEncodingKey() { return 62; }
@Override
protected int defineOffsetNextTableDefPage() { return 4; }
@Override
protected int defineOffsetSortOrder() { return 110; }
@Override
+ protected int defineSizeSortOrder() { return 4; }
+ @Override
protected int defineOffsetEncodingKey() { return 62; }
@Override
protected int defineOffsetNextTableDefPage() { return 4; }