提交 91926786 authored 作者: Thomas Mueller's avatar Thomas Mueller

Formatting / javadocs

上级 d95318e6
......@@ -1273,7 +1273,7 @@ public class Select extends Query {
return false;
}
public SortOrder prepareOrder() {
public SortOrder getSortOrder() {
return sort;
}
......
......@@ -124,6 +124,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
*
* @param masks the search mask
* @param rowCount the number of rows in the index
* @param sortOrder the sort order
* @return the estimated cost
*/
protected long getCostRangeIndex(int[] masks, long rowCount, SortOrder sortOrder) {
......@@ -163,8 +164,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
break;
}
}
// If the query ORDER BY clause matches the ordering of this index, it will be cheaper
// than another index, so adjust the cost accordingly.
// if the ORDER BY clause matches the ordering of this index,
// it will be cheaper than another index, so adjust the cost accordingly
if (sortOrder != null) {
int[] columnIndexes = new int[ indexColumns.length ];
int[] columnSortTypes = new int[ indexColumns.length ];
......@@ -187,7 +188,9 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
coveringCount++;
}
if (sortOrderMatches) {
// "coveringCount" makes sure that when we have two or more covering indexes, we choose the one that covers more
// "coveringCount" makes sure that when we have two
// or more covering indexes, we choose the one
// that covers more
cost -= coveringCount;
}
}
......
......@@ -80,6 +80,7 @@ public interface Index extends SchemaObject {
* @param session the session
* @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition
* @param sortOrder the sort order
* @return the estimated cost
*/
double getCost(Session session, int[] masks, SortOrder sortOrder);
......
......@@ -159,7 +159,7 @@ public class TransactionStore {
return new Transaction(this, transactionId, status, null, 0);
}
void storeTransaction(Transaction t) {
private void storeTransaction(Transaction t) {
long transactionId = t.getId();
if (openTransactions.containsKey(transactionId)) {
return;
......@@ -812,6 +812,12 @@ public class TransactionStore {
return get(key, mapWrite);
}
/**
* Whether the map contains the key.
*
* @param key the key
* @return true if the map contains an entry for this key
*/
public boolean containsKey(K key) {
return get(key) != null;
}
......@@ -855,50 +861,102 @@ public class TransactionStore {
}
}
/**
* Rename the map.
*
* @param newMapName the new map name
*/
public void renameMap(String newMapName) {
// TODO rename maps transactionally
mapWrite.renameMap(newMapName);
}
/**
* Check whether this map is closed.
*
* @return true if closed
*/
public boolean isClosed() {
return mapWrite.isClosed();
}
/**
* Remove the map.
*/
public void removeMap() {
// TODO remove in a transaction
mapWrite.removeMap();
}
/**
* Clear the map.
*/
public void clear() {
// TODO truncate transactionally
mapWrite.clear();
}
/**
* Get the first key.
*
* @return the first key, or null if empty
*/
public K firstKey() {
// TODO transactional firstKey
return mapRead.firstKey();
}
/**
* Get the last key.
*
* @return the last key, or null if empty
*/
public K lastKey() {
// TODO transactional lastKey
return mapRead.lastKey();
}
/**
* Iterate over all keys.
*
* @param from the first key to return
* @return the iterator
*/
public Iterator<K> keyIterator(K from) {
// TODO transactional keyIterator
return mapRead.keyIterator(from);
}
/**
* Get the smallest key that is larger or equal to this key.
*
* @param key the key (may not be null)
* @return the result
*/
public K ceilingKey(K key) {
// TODO transactional ceilingKey
return mapRead.ceilingKey(key);
}
/**
* Get the smallest key that is larger than the given key, or null if no
* such key exists.
*
* @param key the key (may not be null)
* @return the result
*/
public K higherKey(K key) {
// TODO transactional higherKey
return mapRead.higherKey(key);
}
/**
* Get the largest key that is smaller than the given key, or null if no
* such key exists.
*
* @param key the key (may not be null)
* @return the result
*/
public K lowerKey(K key) {
// TODO Auto-generated method stub
return mapRead.lowerKey(key);
......
......@@ -626,6 +626,7 @@ public abstract class Table extends SchemaObjectBase {
* @param session the session
* @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition
* @param sortOrder the sort order
* @return the plan item
*/
public PlanItem getBestPlanItem(Session session, int[] masks, SortOrder sortOrder) {
......
......@@ -178,7 +178,7 @@ public class TableFilter implements ColumnResolver {
}
SortOrder sortOrder = null;
if (select != null) {
sortOrder = select.prepareOrder();
sortOrder = select.getSortOrder();
}
item = table.getBestPlanItem(s, masks, sortOrder);
// The more index conditions, the earlier the table.
......
......@@ -35,12 +35,14 @@ public class CompareMode {
public static final String ICU4J = "ICU4J_";
/**
* This constant means that the BINARY columns are sorted as if the bytes were signed.
* This constant means that the BINARY columns are sorted as if the bytes
* were signed.
*/
public static final String SIGNED = "SIGNED";
/**
* This constant means that the BINARY columns are sorted as if the bytes were unsigned.
* This constant means that the BINARY columns are sorted as if the bytes
* were unsigned.
*/
public static final String UNSIGNED = "UNSIGNED";
......@@ -78,6 +80,7 @@ public class CompareMode {
*
* @param name the collation name or null
* @param strength the collation strength
* @param binaryUnsigned whether to compare binaries as unsigned
* @return the compare mode
*/
public static synchronized CompareMode getInstance(String name, int strength, boolean binaryUnsigned) {
......
......@@ -783,7 +783,10 @@ public class TestOptimizations extends TestBase {
conn.close();
}
/** Where there are multiple indices, and we have an ORDER BY, select the index that already has the required ordering. */
/**
* Where there are multiple indices, and we have an ORDER BY, select the
* index that already has the required ordering.
*/
private void testOrderedIndexes() throws SQLException {
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
......@@ -797,7 +800,8 @@ public class TestOptimizations extends TestBase {
stat.execute("DROP TABLE my_table");
// where we have two covering indexes, make sure we choose the one that covers more
// where we have two covering indexes, make sure
// we choose the one that covers more
stat.execute("CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR)");
stat.execute("CREATE INDEX my_index1 ON my_table(K1,K2);");
stat.execute("CREATE INDEX my_index2 ON my_table(K1,K2,VAL);");
......@@ -807,4 +811,5 @@ public class TestOptimizations extends TestBase {
conn.close();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论