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

Formatting / javadocs

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