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

Documentation / formatting

上级 bbb79bc6
...@@ -17,7 +17,8 @@ Change Log ...@@ -17,7 +17,8 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>Issue 579: Conditions on the "_rowid_" pseudo-column didn't use an index <ul><li>Descending indexes on MVStore tables did not work properly.
</li><li>Issue 579: Conditions on the "_rowid_" pseudo-column didn't use an index
when using the MVStore. when using the MVStore.
</li><li>Fixed documentation that "offset" and "fetch" are also keywords since version 1.4.x. </li><li>Fixed documentation that "offset" and "fetch" are also keywords since version 1.4.x.
</li><li>The Long.MIN_VALUE could not be parsed for auto-increment (identity) columns. </li><li>The Long.MIN_VALUE could not be parsed for auto-increment (identity) columns.
......
...@@ -179,7 +179,7 @@ public class Driver implements java.sql.Driver { ...@@ -179,7 +179,7 @@ public class Driver implements java.sql.Driver {
} }
/** /**
* INTERNAL * INTERNAL
* Sets, on a per-thread basis, the default-connection for * Sets, on a per-thread basis, the default-connection for
* user-defined functions. * user-defined functions.
*/ */
......
...@@ -22,7 +22,7 @@ Inserts a new row / new rows into a table." ...@@ -22,7 +22,7 @@ Inserts a new row / new rows into a table."
UPDATE tableName [ [ AS ] newTableAlias ] SET UPDATE tableName [ [ AS ] newTableAlias ] SET
{ { columnName = { DEFAULT | expression } } [,...] } | { { columnName = { DEFAULT | expression } } [,...] } |
{ ( columnName [,...] ) = ( select ) } { ( columnName [,...] ) = ( select ) }
[ WHERE expression ] [ LIMIT expression ] [ ORDER BY order [,...] ] [ WHERE expression ] [ ORDER BY order [,...] ] [ LIMIT expression ]
"," ","
Updates data in a table." Updates data in a table."
"Commands (DML)","DELETE"," "Commands (DML)","DELETE","
......
...@@ -774,7 +774,7 @@ public class Csv implements SimpleRowSource { ...@@ -774,7 +774,7 @@ public class Csv implements SimpleRowSource {
} }
/** /**
* Set the line separator. * Set the line separator used for writing.
* *
* @param lineSeparator the line separator * @param lineSeparator the line separator
*/ */
...@@ -783,7 +783,7 @@ public class Csv implements SimpleRowSource { ...@@ -783,7 +783,7 @@ public class Csv implements SimpleRowSource {
} }
/** /**
* Get the current line separator. * Get the line separator used for writing.
* *
* @return the line separator * @return the line separator
*/ */
......
...@@ -79,13 +79,13 @@ public class TestOptimizations extends TestBase { ...@@ -79,13 +79,13 @@ public class TestOptimizations extends TestBase {
testConvertOrToIn(); testConvertOrToIn();
deleteDb("optimizations"); deleteDb("optimizations");
} }
private void testFastRowIdCondition() throws Exception { private void testFastRowIdCondition() throws Exception {
Connection conn = getConnection("optimizations"); Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.executeUpdate("create table many(id int) " + stat.executeUpdate("create table many(id int) " +
"as select x from system_range(1, 10000)"); "as select x from system_range(1, 10000)");
ResultSet rs = stat.executeQuery("explain analyze select * from many " + ResultSet rs = stat.executeQuery("explain analyze select * from many " +
"where _rowid_ = 400"); "where _rowid_ = 400");
rs.next(); rs.next();
assertContains(rs.getString(1), "/* scanCount: 2 */"); assertContains(rs.getString(1), "/* scanCount: 2 */");
......
...@@ -35,7 +35,7 @@ public class TestPerfectHash extends TestBase { ...@@ -35,7 +35,7 @@ public class TestPerfectHash extends TestBase {
test.test(); test.test();
test.measure(); test.measure();
} }
private static void largeFile() throws IOException { private static void largeFile() throws IOException {
String fileName = System.getProperty("user.home") + "/temp/enwiki-20140811-all-titles.txt"; String fileName = System.getProperty("user.home") + "/temp/enwiki-20140811-all-titles.txt";
RandomAccessFile f = new RandomAccessFile(fileName, "r"); RandomAccessFile f = new RandomAccessFile(fileName, "r");
...@@ -47,7 +47,7 @@ public class TestPerfectHash extends TestBase { ...@@ -47,7 +47,7 @@ public class TestPerfectHash extends TestBase {
public int hashCode(Text o, int index, int seed) { public int hashCode(Text o, int index, int seed) {
return o.hashCode(index, seed); return o.hashCode(index, seed);
} }
}; };
HashSet<Text> set = new HashSet<Text>(); HashSet<Text> set = new HashSet<Text>();
Text t = new Text(data, 0); Text t = new Text(data, 0);
...@@ -86,18 +86,18 @@ public class TestPerfectHash extends TestBase { ...@@ -86,18 +86,18 @@ public class TestPerfectHash extends TestBase {
s = testMinimalWithString(size); s = testMinimalWithString(size);
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
System.out.println((double) s / size + System.out.println((double) s / size +
" bits/key (minimal; String keys) in " + " bits/key (minimal; String keys) in " +
time + " ms"); time + " ms");
time = System.currentTimeMillis(); time = System.currentTimeMillis();
s = test(size, true); s = test(size, true);
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
System.out.println((double) s / size + " bits/key (minimal old) in " + System.out.println((double) s / size + " bits/key (minimal old) in " +
time + " ms"); time + " ms");
time = System.currentTimeMillis(); time = System.currentTimeMillis();
s = test(size, false); s = test(size, false);
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
System.out.println((double) s / size + " bits/key (not minimal) in " + System.out.println((double) s / size + " bits/key (not minimal) in " +
time + " ms"); time + " ms");
} }
...@@ -119,7 +119,7 @@ public class TestPerfectHash extends TestBase { ...@@ -119,7 +119,7 @@ public class TestPerfectHash extends TestBase {
test(i, false); test(i, false);
} }
} }
private void testBrokenHashFunction() { private void testBrokenHashFunction() {
int size = 10000; int size = 10000;
Random r = new Random(10000); Random r = new Random(10000);
...@@ -138,7 +138,7 @@ public class TestPerfectHash extends TestBase { ...@@ -138,7 +138,7 @@ public class TestPerfectHash extends TestBase {
} }
return StringHash.getFastHash(o, index, seed); return StringHash.getFastHash(o, index, seed);
} }
}; };
byte[] desc = MinimalPerfectHash.generate(set, badHash); byte[] desc = MinimalPerfectHash.generate(set, badHash);
testMinimal(desc, set, badHash); testMinimal(desc, set, badHash);
...@@ -190,7 +190,7 @@ public class TestPerfectHash extends TestBase { ...@@ -190,7 +190,7 @@ public class TestPerfectHash extends TestBase {
assertEquals(size - 1, max); assertEquals(size - 1, max);
return desc.length * 8; return desc.length * 8;
} }
private int testMinimalWithString(int size) { private int testMinimalWithString(int size) {
Random r = new Random(size); Random r = new Random(size);
HashSet<String> set = new HashSet<String>(size); HashSet<String> set = new HashSet<String>(size);
...@@ -218,30 +218,30 @@ public class TestPerfectHash extends TestBase { ...@@ -218,30 +218,30 @@ public class TestPerfectHash extends TestBase {
} }
return max; return max;
} }
/** /**
* A text. * A text.
*/ */
static class Text { static class Text {
/** /**
* The byte data (may be shared, so must not be modified). * The byte data (may be shared, so must not be modified).
*/ */
final byte[] data; final byte[] data;
/** /**
* The start location. * The start location.
*/ */
final int start; final int start;
Text(byte[] data, int start) { Text(byte[] data, int start) {
this.data = data; this.data = data;
this.start = start; this.start = start;
} }
/** /**
* The hash code (using a universal hash function). * The hash code (using a universal hash function).
* *
* @param index the hash function index * @param index the hash function index
* @param seed the random seed * @param seed the random seed
* @return the hash code * @return the hash code
...@@ -257,7 +257,7 @@ public class TestPerfectHash extends TestBase { ...@@ -257,7 +257,7 @@ public class TestPerfectHash extends TestBase {
break; break;
} }
x = 31 + x * 0x9f3b; x = 31 + x * 0x9f3b;
result ^= x * (1 + c); result ^= x * (1 + c);
} }
return result; return result;
} }
...@@ -272,12 +272,12 @@ public class TestPerfectHash extends TestBase { ...@@ -272,12 +272,12 @@ public class TestPerfectHash extends TestBase {
} }
return end; return end;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return hashCode(0, 0); return hashCode(0, 0);
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other == this) { if (other == this) {
...@@ -299,7 +299,7 @@ public class TestPerfectHash extends TestBase { ...@@ -299,7 +299,7 @@ public class TestPerfectHash extends TestBase {
} }
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return new String(data, start, getEnd() - start); return new String(data, start, getEnd() - start);
......
...@@ -762,8 +762,6 @@ exploit noise ongoing disclaimers shrinks remedy party desirable timely construe ...@@ -762,8 +762,6 @@ exploit noise ongoing disclaimers shrinks remedy party desirable timely construe
deque synchronizers affero kevent nikolaj hohmuth grajcar jens fogh hostnames deque synchronizers affero kevent nikolaj hohmuth grajcar jens fogh hostnames
operate resized jni yjp ownable starvation reaper biased introduce epoll hangs operate resized jni yjp ownable starvation reaper biased introduce epoll hangs
compaction aggressive powerful traversing pietrzak michi karl rewriting consequences compaction aggressive powerful traversing pietrzak michi karl rewriting consequences
linearly patching perfect hole sip enwiki linearly patching perfect hole sip enwiki flooding uniformly recursions happening
flooding uniformly recursions happening
...@@ -66,7 +66,7 @@ import java.util.zip.Inflater; ...@@ -66,7 +66,7 @@ import java.util.zip.Inflater;
* theory, by patching the hash function description. With a small change, * theory, by patching the hash function description. With a small change,
* non-minimal perfect hash functions can be calculated (for example 1.22 bits * non-minimal perfect hash functions can be calculated (for example 1.22 bits
* per key at a fill rate of 81%). * per key at a fill rate of 81%).
* *
* @param <K> the key type * @param <K> the key type
*/ */
public class MinimalPerfectHash<K> { public class MinimalPerfectHash<K> {
...@@ -99,7 +99,7 @@ public class MinimalPerfectHash<K> { ...@@ -99,7 +99,7 @@ public class MinimalPerfectHash<K> {
* The minimum output value for a small bucket of a given size. * The minimum output value for a small bucket of a given size.
*/ */
private static final int[] SIZE_OFFSETS = new int[MAX_OFFSETS.length + 1]; private static final int[] SIZE_OFFSETS = new int[MAX_OFFSETS.length + 1];
/** /**
* A secure random generator. * A secure random generator.
*/ */
...@@ -113,7 +113,7 @@ public class MinimalPerfectHash<K> { ...@@ -113,7 +113,7 @@ public class MinimalPerfectHash<K> {
} }
SIZE_OFFSETS[SIZE_OFFSETS.length - 1] = last; SIZE_OFFSETS[SIZE_OFFSETS.length - 1] = last;
} }
/** /**
* The universal hash function. * The universal hash function.
*/ */
...@@ -124,7 +124,7 @@ public class MinimalPerfectHash<K> { ...@@ -124,7 +124,7 @@ public class MinimalPerfectHash<K> {
* key. * key.
*/ */
private final byte[] data; private final byte[] data;
/** /**
* The random seed. * The random seed.
*/ */
...@@ -141,7 +141,7 @@ public class MinimalPerfectHash<K> { ...@@ -141,7 +141,7 @@ public class MinimalPerfectHash<K> {
* speed up calculating the hash of a key. * speed up calculating the hash of a key.
*/ */
private final int[] rootPos; private final int[] rootPos;
/** /**
* The hash function level at the root of the tree. Typically 0, except if * The hash function level at the root of the tree. Typically 0, except if
* the hash function at that level didn't split the entries as expected * the hash function at that level didn't split the entries as expected
...@@ -158,9 +158,9 @@ public class MinimalPerfectHash<K> { ...@@ -158,9 +158,9 @@ public class MinimalPerfectHash<K> {
public MinimalPerfectHash(byte[] desc, UniversalHash<K> hash) { public MinimalPerfectHash(byte[] desc, UniversalHash<K> hash) {
this.hash = hash; this.hash = hash;
byte[] b = data = expand(desc); byte[] b = data = expand(desc);
seed = ((b[0] & 255) << 24) | seed = ((b[0] & 255) << 24) |
((b[1] & 255) << 16) | ((b[1] & 255) << 16) |
((b[2] & 255) << 8) | ((b[2] & 255) << 8) |
(b[3] & 255); (b[3] & 255);
if (b[4] == SPLIT_MANY) { if (b[4] == SPLIT_MANY) {
rootLevel = b[b.length - 1] & 255; rootLevel = b[b.length - 1] & 255;
...@@ -182,7 +182,7 @@ public class MinimalPerfectHash<K> { ...@@ -182,7 +182,7 @@ public class MinimalPerfectHash<K> {
rootPos = null; rootPos = null;
} }
} }
/** /**
* Calculate the hash value for the given key. * Calculate the hash value for the given key.
* *
...@@ -196,7 +196,7 @@ public class MinimalPerfectHash<K> { ...@@ -196,7 +196,7 @@ public class MinimalPerfectHash<K> {
/** /**
* Get the hash value for the given key, starting at a certain position and * Get the hash value for the given key, starting at a certain position and
* level. * level.
* *
* @param pos the start position * @param pos the start position
* @param x the key * @param x the key
* @param isRoot whether this is the root of the tree * @param isRoot whether this is the root of the tree
...@@ -234,10 +234,10 @@ public class MinimalPerfectHash<K> { ...@@ -234,10 +234,10 @@ public class MinimalPerfectHash<K> {
} }
return s + get(pos, x, false, level + 1); return s + get(pos, x, false, level + 1);
} }
/** /**
* Get the position of the next sibling. * Get the position of the next sibling.
* *
* @param pos the position of this branch * @param pos the position of this branch
* @return the position of the next sibling * @return the position of the next sibling
*/ */
...@@ -259,10 +259,10 @@ public class MinimalPerfectHash<K> { ...@@ -259,10 +259,10 @@ public class MinimalPerfectHash<K> {
} }
return pos; return pos;
} }
/** /**
* The sum of the sizes between the start and end position. * The sum of the sizes between the start and end position.
* *
* @param start the start position * @param start the start position
* @param end the end position (excluding) * @param end the end position (excluding)
* @return the sizes * @return the sizes
...@@ -331,7 +331,7 @@ public class MinimalPerfectHash<K> { ...@@ -331,7 +331,7 @@ public class MinimalPerfectHash<K> {
* @param seed the random seed * @param seed the random seed
* @param out the output stream * @param out the output stream
*/ */
static <K> void generate(ArrayList<K> list, UniversalHash<K> hash, static <K> void generate(ArrayList<K> list, UniversalHash<K> hash,
int level, int seed, ByteArrayOutputStream out) { int level, int seed, ByteArrayOutputStream out) {
int size = list.size(); int size = list.size();
if (size <= 1) { if (size <= 1) {
...@@ -339,7 +339,7 @@ public class MinimalPerfectHash<K> { ...@@ -339,7 +339,7 @@ public class MinimalPerfectHash<K> {
return; return;
} }
if (level > 32) { if (level > 32) {
throw new IllegalStateException("Too many recursions; " + throw new IllegalStateException("Too many recursions; " +
" incorrect universal hash function?"); " incorrect universal hash function?");
} }
if (size <= MAX_SIZE) { if (size <= MAX_SIZE) {
...@@ -381,7 +381,7 @@ public class MinimalPerfectHash<K> { ...@@ -381,7 +381,7 @@ public class MinimalPerfectHash<K> {
K x = list.get(i); K x = list.get(i);
ArrayList<K> l = lists.get(hash(x, hash, level, seed, 0, split)); ArrayList<K> l = lists.get(hash(x, hash, level, seed, 0, split));
l.add(x); l.add(x);
if (isRoot && split >= SPLIT_MANY && if (isRoot && split >= SPLIT_MANY &&
l.size() > 36 * DIVIDE * 10) { l.size() > 36 * DIVIDE * 10) {
// a bad hash function or attack was detected // a bad hash function or attack was detected
level++; level++;
...@@ -491,7 +491,7 @@ public class MinimalPerfectHash<K> { ...@@ -491,7 +491,7 @@ public class MinimalPerfectHash<K> {
x = (x >>> 16) ^ x; x = (x >>> 16) ^ x;
return Math.abs(x % size); return Math.abs(x % size);
} }
private static <K> int hash(int x, int level, int offset, int size) { private static <K> int hash(int x, int level, int offset, int size) {
x += level + offset * 16; x += level + offset * 16;
x = ((x >>> 16) ^ x) * 0x45d9f3b; x = ((x >>> 16) ^ x) * 0x45d9f3b;
...@@ -586,7 +586,7 @@ public class MinimalPerfectHash<K> { ...@@ -586,7 +586,7 @@ public class MinimalPerfectHash<K> {
} }
return out.toByteArray(); return out.toByteArray();
} }
/** /**
* An interface that can calculate multiple hash values for an object. The * An interface that can calculate multiple hash values for an object. The
* returned hash value of two distinct objects may be the same for a given * returned hash value of two distinct objects may be the same for a given
...@@ -594,14 +594,14 @@ public class MinimalPerfectHash<K> { ...@@ -594,14 +594,14 @@ public class MinimalPerfectHash<K> {
* those objects, the returned value must eventually be different. * those objects, the returned value must eventually be different.
* <p> * <p>
* The returned value does not need to be uniformly distributed. * The returned value does not need to be uniformly distributed.
* *
* @param <T> the type * @param <T> the type
*/ */
public interface UniversalHash<T> { public interface UniversalHash<T> {
/** /**
* Calculate the hash of the given object. * Calculate the hash of the given object.
* *
* @param o the object * @param o the object
* @param index the hash function index (index 0 is used first, so the * @param index the hash function index (index 0 is used first, so the
* method should be very fast with index 0; index 1 and so on * method should be very fast with index 0; index 1 and so on
...@@ -610,9 +610,9 @@ public class MinimalPerfectHash<K> { ...@@ -610,9 +610,9 @@ public class MinimalPerfectHash<K> {
* @return the hash value * @return the hash value
*/ */
int hashCode(T o, int index, int seed); int hashCode(T o, int index, int seed);
} }
/** /**
* A sample hash implementation for long keys. * A sample hash implementation for long keys.
*/ */
...@@ -633,7 +633,7 @@ public class MinimalPerfectHash<K> { ...@@ -633,7 +633,7 @@ public class MinimalPerfectHash<K> {
int shift = (index & 1) * 32; int shift = (index & 1) * 32;
return (int) (o.longValue() >>> shift); return (int) (o.longValue() >>> shift);
} }
} }
/** /**
...@@ -661,7 +661,7 @@ public class MinimalPerfectHash<K> { ...@@ -661,7 +661,7 @@ public class MinimalPerfectHash<K> {
/** /**
* A cryptographically weak hash function. It is supposed to be fast. * A cryptographically weak hash function. It is supposed to be fast.
* *
* @param o the string * @param o the string
* @param index the hash function index * @param index the hash function index
* @param seed the seed * @param seed the seed
...@@ -672,15 +672,15 @@ public class MinimalPerfectHash<K> { ...@@ -672,15 +672,15 @@ public class MinimalPerfectHash<K> {
int result = seed + o.length(); int result = seed + o.length();
for (int i = 0; i < o.length(); i++) { for (int i = 0; i < o.length(); i++) {
x = 31 + x * 0x9f3b; x = 31 + x * 0x9f3b;
result ^= x * (1 + o.charAt(i)); result ^= x * (1 + o.charAt(i));
} }
return result; return result;
} }
/** /**
* A cryptographically relatively secure hash function. It is supposed * A cryptographically relatively secure hash function. It is supposed
* to protected against hash-flooding denial-of-service attacks. * to protected against hash-flooding denial-of-service attacks.
* *
* @param o the string * @param o the string
* @param k0 key 0 * @param k0 key 0
* @param k1 key 1 * @param k1 key 1
...@@ -690,11 +690,11 @@ public class MinimalPerfectHash<K> { ...@@ -690,11 +690,11 @@ public class MinimalPerfectHash<K> {
byte[] b = o.getBytes(UTF8); byte[] b = o.getBytes(UTF8);
return getSipHash24(b, 0, b.length, k0, k1); return getSipHash24(b, 0, b.length, k0, k1);
} }
/** /**
* A cryptographically relatively secure hash function. It is supposed * A cryptographically relatively secure hash function. It is supposed
* to protected against hash-flooding denial-of-service attacks. * to protected against hash-flooding denial-of-service attacks.
* *
* @param b the data * @param b the data
* @param start the start position * @param start the start position
* @param end the end position plus one * @param end the end position plus one
...@@ -746,7 +746,7 @@ public class MinimalPerfectHash<K> { ...@@ -746,7 +746,7 @@ public class MinimalPerfectHash<K> {
} }
return (int) (v0 ^ v1 ^ v2 ^ v3); return (int) (v0 ^ v1 ^ v2 ^ v3);
} }
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论