proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/common/util/SortedProperties.java
SortedProperties
store
class SortedProperties extends Properties { private static final long serialVersionUID = 1L; @Override public synchronized Enumeration<Object> keys() { Vector<String> v = new Vector<String>(); for (Object o : keySet()) { v.add(o.toString()); } Collections.sort(v...
ByteArrayOutputStream out = new ByteArrayOutputStream(); store(out, null); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); InputStreamReader reader = new InputStreamReader(in, "ISO8859-1"); LineNumberReader r = new LineNumberReader(reader); Writer ...
589
218
807
<methods>public void <init>() ,public void <init>(int) ,public void <init>(java.util.Properties) ,public synchronized void clear() ,public synchronized java.lang.Object clone() ,public synchronized java.lang.Object compute(java.lang.Object, BiFunction<? super java.lang.Object,? super java.lang.Object,?>) ,public synchr...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/common/util/StatementBuilder.java
StatementBuilder
appendOnlyFirst
class StatementBuilder { private final StringBuilder builder = new StringBuilder(); private int index; /** * Create a new builder. */ public StatementBuilder() { // nothing to do } /** * Create a new builder. * * @param string the initial string */ pu...
if (index == 0) { builder.append(s); } return this;
556
28
584
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/common/util/Task.java
Task
getException
class Task implements Runnable { /** * A flag indicating the get() method has been called. */ protected volatile boolean stop; /** * The result, if any. */ protected Object result; private Thread thread; private Exception ex; /** * The method to be implemented. ...
stop = true; if (thread == null) { throw new IllegalStateException("Thread not started"); } try { thread.join(); } catch (InterruptedException e) { // ignore } if (ex != null) { return ex; } return n...
444
84
528
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/common/util/TempFileDeleter.java
TempFileDeleter
deleteUnused
class TempFileDeleter { private final ReferenceQueue<Object> queue = new ReferenceQueue<Object>(); private final HashMap<PhantomReference<?>, String> refMap = new HashMap<>(); private TempFileDeleter() { // utility class } public static TempFileDeleter getInstance() { return new T...
while (queue != null) { Reference<? extends Object> ref = queue.poll(); if (ref == null) { break; } deleteFile(ref, null); }
839
56
895
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/LocalDataHandler.java
LocalDataHandler
getLobStorage
class LocalDataHandler implements DataHandler { private final String cipher; private final byte[] fileEncryptionKey; private LobReader lobReader; private LobStorage lobStorage; public LocalDataHandler() { this(null); } public LocalDataHandler(String cipher) { this.cipher =...
if (lobStorage == null) { lobStorage = new LobLocalStorage(this, lobReader); } return lobStorage;
461
39
500
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/MemoryManager.java
MemoryManager
getFullGcThreshold
class MemoryManager { private static final MemoryManager globalMemoryManager = new MemoryManager(getGlobalMaxMemory()); private static final long fullGcThreshold = getFullGcThreshold(); public static boolean needFullGc() { return globalMemoryManager.getUsedMemory() > fullGcThreshold; } p...
long max = getGlobalMaxMemory(); long gcThreshold = max / 10 * 6; // 小于512M时把阈值调低一些 if (max < 512 * 1024 * 1024) gcThreshold = max / 10 * 3; return SystemPropertyUtils.getLong("lealone.memory.fullGcThreshold", gcThreshold);
588
112
700
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/PluginBase.java
PluginBase
init
class PluginBase implements Plugin { protected String name; protected Map<String, String> config; protected State state = State.NONE; public PluginBase() { } public PluginBase(String name) { this.name = name; } @Override public String getName() { return name; ...
if (!isInited()) { this.config = config; String pluginName = MapUtils.getString(config, "plugin_name", null); if (pluginName != null) setName(pluginName); // 使用create plugin创建插件对象时用命令指定的名称覆盖默认值 Class<Plugin> pluginClass = getPluginClass0(); ...
485
120
605
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/PluginManager.java
PluginManager
getPlugin
class PluginManager<T extends Plugin> { private static final Logger logger = LoggerFactory.getLogger(PluginManager.class); private final Class<T> pluginClass; private final Map<String, T> plugins = new ConcurrentHashMap<>(); private volatile boolean loaded = false; protected PluginManager(Class<T...
if (name == null) throw new NullPointerException("name is null"); if (!loaded) loadPlugins(); return plugins.get(name.toUpperCase());
1,060
50
1,110
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/async/AsyncCallback.java
AsyncCallback
handleTimeout
class AsyncCallback<T> implements Future<T> { public AsyncCallback() { } public void setDbException(DbException e, boolean cancel) { } public void run(NetInputStream in) { } protected void runInternal(NetInputStream in) throws Exception { } protected abstract T await(long timeou...
String msg = "ack timeout, request start time: " + new java.sql.Timestamp(startTime) // + ", network timeout: " + networkTimeout + "ms" // + ", request packet: " + packet; DbException e = DbException.get(ErrorCode.NETWORK_TIMEOUT_1, msg); setAsyncResult(e); ...
662
98
760
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/async/AsyncPeriodicTask.java
AsyncPeriodicTask
run
class AsyncPeriodicTask extends LinkableBase<AsyncPeriodicTask> implements AsyncTask { private final long delay; private Runnable runnable; private long last; private boolean canceled; public AsyncPeriodicTask(long delay, Runnable runnable) { this(delay, delay, runnable); } public...
if (canceled) return; long now = System.currentTimeMillis(); if (now > last) { last = now + delay; runnable.run(); }
365
54
419
<methods>public non-sealed void <init>() ,public com.lealone.db.async.AsyncPeriodicTask getNext() ,public void setNext(com.lealone.db.async.AsyncPeriodicTask) <variables>public com.lealone.db.async.AsyncPeriodicTask next
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/async/AsyncResult.java
AsyncResult
setResult
class AsyncResult<T> { protected T result; protected Throwable cause; protected boolean succeeded; protected boolean failed; public AsyncResult() { } public AsyncResult(T result) { setResult(result); } public AsyncResult(Throwable cause) { setCause(cause); } ...
this.result = result; failed = false; succeeded = true;
283
23
306
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/async/ConcurrentAsyncCallback.java
LatchObject
await
class LatchObject { final CountDownLatch latch; public LatchObject(CountDownLatch latch) { this.latch = latch; } } public ConcurrentAsyncCallback() { } @Override public void setDbException(DbException e, boolean cancel) { setAsyncResult(e); if (...
Scheduler scheduler = SchedulerThread.currentScheduler(); if (scheduler != null) scheduler.executeNextStatement(); if (latchObjectRef.compareAndSet(null, new LatchObject(new CountDownLatch(1)))) { CountDownLatch latch = latchObjectRef.get().latch; try { ...
252
296
548
<methods>public void <init>() ,public void checkTimeout(long) ,public static AsyncCallback<T> create(boolean) ,public static AsyncCallback<T> createConcurrentCallback() ,public static AsyncCallback<T> createSingleThreadCallback() ,public T get() ,public T get(long) ,public int getNetworkTimeout() ,public long getStartT...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/async/SingleThreadAsyncCallback.java
SingleThreadAsyncCallback
await
class SingleThreadAsyncCallback<T> extends AsyncCallback<T> { private AsyncHandler<AsyncResult<T>> completeHandler; private AsyncHandler<T> successHandler; private AsyncHandler<Throwable> failureHandler; private AsyncResult<T> asyncResult; public SingleThreadAsyncCallback() { } @Override ...
Scheduler scheduler = SchedulerThread.currentScheduler(); if (scheduler != null) { scheduler.executeNextStatement(); // 如果被锁住了,需要重试 if (asyncResult == null) { while (asyncResult == null) { try { Thread.sleep...
538
176
714
<methods>public void <init>() ,public void checkTimeout(long) ,public static AsyncCallback<T> create(boolean) ,public static AsyncCallback<T> createConcurrentCallback() ,public static AsyncCallback<T> createSingleThreadCallback() ,public T get() ,public T get(long) ,public int getNetworkTimeout() ,public long getStartT...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/link/LinkableList.java
LinkableList
remove
class LinkableList<E extends Linkable<E>> { private E head; private E tail; private int size; public E getHead() { return head; } public void setHead(E head) { this.head = head; } public E getTail() { return tail; } public void setTail(E tail) { ...
boolean found = false; if (head == e) { // 删除头 found = true; head = e.getNext(); if (head == null) tail = null; } else { E n = head; E last = n; while (n != null) { if (e == n) { ...
252
179
431
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/lock/Lock.java
Lock
tryLock
class Lock { static final NullLockOwner NULL = new NullLockOwner(); private final AtomicReference<LockOwner> ref = new AtomicReference<>(NULL); public abstract String getLockType(); public Transaction getTransaction() { return ref.get().getTransaction(); } public Object getOldValue(...
Session session = t.getSession(); while (true) { // 首次调用tryLock时为null if (ref.get() == NULL) { LockOwner owner = createLockOwner(t, oldValue); if (ref.compareAndSet(NULL, owner)) { addLock(session, t); retur...
402
219
621
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/scheduler/EmbeddedScheduler.java
SessionInfo
executeNextStatement
class SessionInfo extends LinkableBase<SessionInfo> { final Session session; public SessionInfo(Session session) { this.session = session; } } @Override public void addSession(Session session) { sessions.add(new SessionInfo(session)); session.init(); ...
int priority = PreparedSQLStatement.MIN_PRIORITY - 1; // 最小优先级减一,保证能取到最小的 YieldableCommand last = null; while (true) { YieldableCommand c; if (nextBestCommand != null) { c = nextBestCommand; nextBestCommand = null; } else { ...
215
319
534
<methods>public void <init>(int, java.lang.String, int, Map<java.lang.String,java.lang.String>) ,public void accept(java.nio.channels.SelectionKey) ,public void addPendingTransaction(com.lealone.transaction.PendingTransaction) ,public void addPeriodicTask(com.lealone.db.async.AsyncPeriodicTask) ,public void addSession(...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/scheduler/SchedulerFactoryBase.java
LoadBalanceFactory
createSchedulerFactory
class LoadBalanceFactory extends SchedulerFactoryBase { protected LoadBalanceFactory(Map<String, String> config, Scheduler[] schedulers) { super(config, schedulers); } @Override public Scheduler getScheduler() { long minLoad = Long.MAX_VALUE; int ind...
SchedulerFactory schedulerFactory; String sf = MapUtils.getString(config, "scheduler_factory", null); if (sf != null) { schedulerFactory = PluginManager.getPlugin(SchedulerFactory.class, sf); } else { Scheduler[] schedulers = createSchedulers(schedulerClassName, ...
599
144
743
<methods>public void <init>() ,public void <init>(java.lang.String) ,public synchronized void close() ,public Map<java.lang.String,java.lang.String> getConfig() ,public java.lang.String getName() ,public Class<? extends com.lealone.db.Plugin> getPluginClass() ,public com.lealone.db.Plugin.State getState() ,public synch...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/scheduler/SchedulerListener.java
SchedulerListener
createSchedulerListener
class SchedulerListener<R> implements AsyncHandler<AsyncResult<R>> { protected volatile R result; protected volatile DbException exception; protected boolean needWakeUp = true; public void setNeedWakeUp(boolean needWakeUp) { this.needWakeUp = needWakeUp; } public void setResult(R r) {...
Object object = SchedulerThread.currentObject(); if (object instanceof SchedulerListener.Factory) { return ((SchedulerListener.Factory) object).createSchedulerListener(); } else { // 创建一个同步阻塞监听器 return new SchedulerListener<R>() { private fin...
299
200
499
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/scheduler/SchedulerLock.java
SchedulerLock
unlock
class SchedulerLock { private static final AtomicReferenceFieldUpdater<SchedulerLock, Scheduler> // lockUpdater = AtomicReferenceFieldUpdater.newUpdater(SchedulerLock.class, // Scheduler.class, "lockOwner"); private volatile Scheduler lockOwner; public boolean tryLock(Scheduler newLockOwne...
if (lockOwner != null) { Scheduler owner = lockOwner; lockOwner = null; owner.wakeUpWaitingSchedulers(); }
366
47
413
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/scheduler/SchedulerThread.java
SchedulerThread
currentScheduler
class SchedulerThread extends Thread { private final static ThreadLocal<Scheduler> threadLocal = new ThreadLocal<>(); private final Scheduler scheduler; public SchedulerThread(Scheduler scheduler) { super(scheduler); this.scheduler = scheduler; } public Scheduler getScheduler() {...
Thread t = Thread.currentThread(); if (t instanceof SchedulerThread) { return ((SchedulerThread) t).getScheduler(); } else { return null; }
474
52
526
<methods>public void <init>() ,public void <init>(java.lang.Runnable) ,public void <init>(java.lang.String) ,public void <init>(java.lang.ThreadGroup, java.lang.Runnable) ,public void <init>(java.lang.ThreadGroup, java.lang.String) ,public void <init>(java.lang.Runnable, java.lang.String) ,public void <init>(java.lang....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/session/SessionBase.java
SessionBase
closeTraceSystem
class SessionBase implements Session { protected boolean autoCommit = true; protected boolean closed; protected boolean invalid; protected String targetNodes; protected RunMode runMode; protected String newTargetNodes; protected int consistencyLevel; protected TraceSystem traceSystem;...
if (traceSystem != null) { traceSystem.close(); traceSystem = null; }
1,544
31
1,575
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/BlobBase.java
BlobBase
getBytes
class BlobBase extends TraceObject implements Blob { protected Value value; public Value getValue() { return value; } /** * Returns the length. * * @return the length * @throws SQLException */ @Override public long length() throws SQLException { try { ...
try { if (isDebugEnabled()) { debugCode("getBytes(" + pos + ", " + length + ");"); } checkClosed(); ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream in = value.getInputStream(); try { IOU...
1,846
143
1,989
<methods>public non-sealed void <init>() ,public static int getNextTraceId(com.lealone.common.trace.TraceObjectType) ,public int getTraceId() ,public java.lang.String getTraceObjectName() <variables>private static final non-sealed java.util.concurrent.atomic.AtomicInteger[] ID,protected com.lealone.common.trace.Trace t...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ClobBase.java
ClobBase
length
class ClobBase extends TraceObject implements Clob, NClob { protected Value value; public Value getValue() { return value; } /** * Returns the length. * * @return the length */ @Override public long length() throws SQLException {<FILL_FUNCTION_BODY>} /** ...
try { debugCodeCall("length"); checkClosed(); if (value.getType() == Value.CLOB) { long precision = value.getPrecision(); if (precision > 0) { return precision; } } return IOUtils.cop...
1,346
114
1,460
<methods>public non-sealed void <init>() ,public static int getNextTraceId(com.lealone.common.trace.TraceObjectType) ,public int getTraceId() ,public java.lang.String getTraceObjectName() <variables>private static final non-sealed java.util.concurrent.atomic.AtomicInteger[] ID,protected com.lealone.common.trace.Trace t...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/CompareMode.java
CompareMode
getCollator
class CompareMode { /** * This constant means there is no collator set, and the default string * comparison is to be used. */ public static final String OFF = "OFF"; /** * This constant means the default collator should be used, even if ICU4J is * in the classpath. */ pub...
Collator result = null; if (name.startsWith(ICU4J)) { name = name.substring(ICU4J.length()); } else if (name.startsWith(DEFAULT)) { name = name.substring(DEFAULT.length()); } if (name.length() == 2) { Locale locale = new Locale(StringUtils.toL...
1,589
332
1,921
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/CompareModeDefault.java
CompareModeDefault
compareString
class CompareModeDefault extends CompareMode { private final Collator collator; private final SmallLRUCache<String, CollationKey> collationKeys; protected CompareModeDefault(String name, int strength, boolean binaryUnsigned) { super(name, strength, binaryUnsigned); collator = CompareMode.g...
if (ignoreCase) { // this is locale sensitive a = a.toUpperCase(); b = b.toUpperCase(); } int comp; if (collationKeys != null) { CollationKey aKey = getKey(a); CollationKey bKey = getKey(b); comp = aKey.compareTo(bK...
385
125
510
<methods>public int compareString(java.lang.String, java.lang.String, boolean) ,public boolean equalsChars(java.lang.String, int, java.lang.String, int, boolean) ,public static java.text.Collator getCollator(java.lang.String) ,public static synchronized com.lealone.db.value.CompareMode getInstance(java.lang.String, int...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/CompareModeIcu4J.java
CompareModeIcu4J
equalsChars
class CompareModeIcu4J extends CompareMode { private final Comparator<String> collator; protected CompareModeIcu4J(String name, int strength, boolean binaryUnsigned) { super(name, strength, binaryUnsigned); collator = getIcu4jCollator(name, strength); } @Override public int compar...
return compareString(a.substring(ai, ai + 1), b.substring(bi, bi + 1), ignoreCase) == 0;
689
38
727
<methods>public int compareString(java.lang.String, java.lang.String, boolean) ,public boolean equalsChars(java.lang.String, int, java.lang.String, int, boolean) ,public static java.text.Collator getCollator(java.lang.String) ,public static synchronized com.lealone.db.value.CompareMode getInstance(java.lang.String, int...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ReadonlyArray.java
ReadonlyArray
toString
class ReadonlyArray extends ArrayBase { { this.trace = Trace.NO_TRACE; } public ReadonlyArray(Value value) { this.value = value; } public ReadonlyArray(String value) { setValue(value); } public ReadonlyArray(Object value) { if (value instanceof List) { ...
if (value instanceof ValueArray) { ValueArray va = (ValueArray) value; StatementBuilder buff = new StatementBuilder("["); for (Value v : va.getList()) { buff.appendExceptFirst(", "); buff.append(v.getString()); } return...
292
97
389
<methods>public non-sealed void <init>() ,public void free() ,public java.lang.Object getArray() throws java.sql.SQLException,public java.lang.Object getArray(Map<java.lang.String,Class<?>>) throws java.sql.SQLException,public java.lang.Object getArray(long, int) throws java.sql.SQLException,public java.lang.Object get...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueArray.java
ValueArray
get
class ValueArray extends Value { private final Class<?> componentType; private final Value[] values; private int hash; private ValueArray(Class<?> componentType, Value[] list) { this.componentType = componentType; this.values = list; } private ValueArray(Value[] list) { ...
Object[] objArray; try { objArray = (Object[]) array.getArray(); int size = objArray.length; Value[] values = new Value[size]; for (int i = 0; i < size; i++) { values[i] = ValueString.get(objArray[i].toString()); } ...
1,825
121
1,946
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueBoolean.java
ValueBoolean
compareSecure
class ValueBoolean extends Value { /** * The precision in digits. */ public static final int PRECISION = 1; /** * The maximum display size of a boolean. * Example: FALSE */ public static final int DISPLAY_SIZE = 5; /** * Of type Object so that Tomcat doesn't set it t...
boolean v2 = ((ValueBoolean) o).value; boolean v = value; return (v == v2) ? 0 : (v ? 1 : -1);
865
46
911
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueByte.java
ValueByte
divide
class ValueByte extends Value { /** * The precision in digits. */ static final int PRECISION = 3; /** * The display size for a byte. * Example: -127 */ static final int DISPLAY_SIZE = 4; private final byte value; private ValueByte(byte value) { this.value = v...
ValueByte other = (ValueByte) v; if (other.value == 0) { throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getSQL()); } return ValueByte.get((byte) (value / other.value));
1,126
74
1,200
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueBytes.java
ValueBytes
getNoCopy
class ValueBytes extends Value { private static final ValueBytes EMPTY = new ValueBytes(Utils.EMPTY_BYTES); /** * The value. */ protected byte[] value; /** * The hash code. */ protected int hash; protected ValueBytes(byte[] v) { this.value = v; } /** ...
if (b.length == 0) { return EMPTY; } ValueBytes obj = new ValueBytes(b); if (b.length > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } return (ValueBytes) Value.cache(obj);
853
86
939
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueDate.java
ValueDate
appendDate
class ValueDate extends Value { /** * The precision in digits. */ public static final int PRECISION = 8; /** * The display size of the textual representation of a date. * Example: 2000-01-02 */ public static final int DISPLAY_SIZE = 10; private final long dateValue; ...
int y = DateTimeUtils.yearFromDateValue(dateValue); int m = DateTimeUtils.monthFromDateValue(dateValue); int d = DateTimeUtils.dayFromDateValue(dateValue); if (y > 0 && y < 10000) { StringUtils.appendZeroPadded(buff, 4, y); } else { buff.append(y); ...
1,167
151
1,318
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueDouble.java
ValueDouble
get
class ValueDouble extends Value { /** * The precision in digits. */ public static final int PRECISION = 17; /** * The maximum display size of a double. * Example: -3.3333333333333334E-100 */ public static final int DISPLAY_SIZE = 24; /** * Double.doubleToLongBits(0.0...
if (d == 1.0) { return ONE; } else if (d == 0.0) { // unfortunately, -0.0 == 0.0, but we don't want to return // 0.0 in this case if (Double.doubleToLongBits(d) == ZERO_BITS) { return ZERO; } } else if (Double.isNaN(d))...
1,751
139
1,890
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueEnum.java
ValueEnum
multiply
class ValueEnum extends Value { private String label; private final int value; private ValueEnum(String label, int value) { this.label = label; this.value = value; } private ValueEnum(int value) { this.label = null; this.value = value; } public static Valu...
ValueEnum other = (ValueEnum) v; return checkRange(value * (long) other.value);
986
30
1,016
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueFloat.java
ValueFloat
compare
class ValueFloat extends Value { /** * Float.floatToIntBits(0.0F). */ public static final int ZERO_BITS = Float.floatToIntBits(0.0F); /** * The precision in digits. */ static final int PRECISION = 7; /** * The maximum display size of a float. * Example: -1.12345676E-...
Float a = (Float) aObj; Float b = (Float) bObj; return a.compareTo(b);
1,811
37
1,848
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueInt.java
ValueInt
write0
class ValueInt extends Value { /** * The precision in digits. */ public static final int PRECISION = 10; /** * The maximum display size of an int. * Example: -2147483648 */ public static final int DISPLAY_SIZE = 11; private static final int STATIC_SIZE = 128; // must ...
if (x < 0) { // -Integer.MIN_VALUE is smaller than 0 if (-x < 0 || -x > DataUtils.COMPRESSED_VAR_INT_MAX) { buff.put((byte) TAG_INTEGER_FIXED).putInt(x); } else { buff.put((byte) TAG_INTEGER_NEGATIVE).putVarInt(-x); ...
1,605
211
1,816
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueJavaObject.java
NotSerialized
compareSecure
class NotSerialized extends ValueJavaObject { private Object javaObject; private int displaySize = -1; NotSerialized(Object javaObject, byte[] v) { super(v); this.javaObject = javaObject; } @Override public void set(PreparedStatement prep, int ...
Object o1 = getObject(); Object o2 = v.getObject(); boolean o1Comparable = o1 instanceof Comparable; boolean o2Comparable = o2 instanceof Comparable; if (o1Comparable && o2Comparable && Utils.haveCommonComparableSuperclass(o1.getClass(),...
579
339
918
<methods>public com.lealone.db.value.Value convertPrecision(long, boolean) ,public boolean equals(java.lang.Object) ,public static com.lealone.db.value.ValueBytes get(byte[]) ,public byte[] getBytes() ,public byte[] getBytesNoCopy() ,public int getDisplaySize() ,public int getMemory() ,public static com.lealone.db.valu...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueList.java
ValueList
convertPrecision
class ValueList extends Value { private final Class<?> componentType; private final List<Value> values; private int hash; private ValueList(Class<?> componentType, List<?> list) { this.componentType = componentType; this.values = new ArrayList<>(list.size()); int type = getColl...
if (!force) { return this; } int length = values.size(); Value[] newValues = new Value[length]; int i = 0; boolean modified = false; for (; i < length; i++) { Value old = values.get(i); Value v = old.convertPrecision(precision,...
1,688
239
1,927
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueNull.java
ValueNull
compare
class ValueNull extends Value { /** * The main NULL instance. */ public static final ValueNull INSTANCE = new ValueNull(); /** * This special instance is used as a marker for deleted entries in a map. * It should not be used anywhere else. */ public static final ValueNull DELE...
if (aObj == null && bObj == null) { return 0; } else if (aObj == null) { return -1; } else { return 1; }
983
56
1,039
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueResultSet.java
ValueResultSet
getCopy
class ValueResultSet extends Value { private final ResultSet result; private ValueResultSet(ResultSet rs) { this.result = rs; } /** * Create a result set value for the given result set. * The result set will be wrapped. * * @param rs the result set * @return the value...
try { ResultSetMetaData meta = rs.getMetaData(); int columnCount = meta.getColumnCount(); SimpleResultSet simple = new SimpleResultSet(); simple.setAutoClose(false); ValueResultSet val = new ValueResultSet(simple); for (int i = 0; i < colu...
853
281
1,134
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueSet.java
ValueSet
compareSecure
class ValueSet extends Value { private final Class<?> componentType; private final Set<Value> values; private int hash; private ValueSet(Class<?> componentType, Set<?> set) { this.componentType = componentType; this.values = new HashSet<>(set.size()); int type = getCollectionCo...
ValueSet v = (ValueSet) o; if (values == v.values) { return 0; } int l = values.size(); int ol = v.values.size(); int len = Math.min(l, ol); for (int i = 0; i < len; i++) { // Value v1 = values.get(i); // Value v2 = v.values.ge...
1,675
174
1,849
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueShort.java
ValueShort
checkRange
class ValueShort extends Value { /** * The precision in digits. */ static final int PRECISION = 5; /** * The maximum display size of a short. * Example: -32768 */ static final int DISPLAY_SIZE = 6; private final short value; private ValueShort(short value) { ...
if (x < Short.MIN_VALUE || x > Short.MAX_VALUE) { throw DbException.get(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, Integer.toString(x)); } return ValueShort.get((short) x);
1,135
72
1,207
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueString.java
StringDataType
write0
class StringDataType extends StorageDataTypeBase { private StringDataType() { } @Override public int getType() { return STRING; } @Override public int compare(Object aObj, Object bObj) { return aObj.toString().compareTo(bObj.toString());...
if (s == null) { buff.put((byte) STRING).putVarInt((byte) 0); return; } int len = s.length(); if (len <= 15) { buff.put((byte) (TAG_STRING_0_15 + len)); } else { buff.put((byte) STRING).putVarInt...
372
115
487
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueStringFixed.java
ValueStringFixed
get
class ValueStringFixed extends ValueString { private static final ValueStringFixed EMPTY = new ValueStringFixed(""); protected ValueStringFixed(String value) { super(value); } private static String trimRight(String s) { int endIndex = s.length() - 1; int i = endIndex; ...
s = trimRight(s); if (s.length() == 0) { return EMPTY; } ValueStringFixed obj = new ValueStringFixed(StringUtils.cache(s)); if (s.length() > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } return (ValueStringFixed) Value.c...
282
105
387
<methods>public com.lealone.db.value.Value convertPrecision(long, boolean) ,public boolean equals(java.lang.Object) ,public static com.lealone.db.value.ValueString get(java.lang.String) ,public static com.lealone.db.value.Value get(java.lang.String, boolean) ,public int getDisplaySize() ,public int getMemory() ,public ...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueStringIgnoreCase.java
ValueStringIgnoreCase
get
class ValueStringIgnoreCase extends ValueString { private static final ValueStringIgnoreCase EMPTY = new ValueStringIgnoreCase(""); private int hash; protected ValueStringIgnoreCase(String value) { super(value); } @Override public int getType() { return Value.STRING_IGNORECASE...
if (s.length() == 0) { return EMPTY; } ValueStringIgnoreCase obj = new ValueStringIgnoreCase(StringUtils.cache(s)); if (s.length() > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } ValueStringIgnoreCase cache = (ValueStringIgnoreC...
400
162
562
<methods>public com.lealone.db.value.Value convertPrecision(long, boolean) ,public boolean equals(java.lang.Object) ,public static com.lealone.db.value.ValueString get(java.lang.String) ,public static com.lealone.db.value.Value get(java.lang.String, boolean) ,public int getDisplaySize() ,public int getMemory() ,public ...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/db/value/ValueTime.java
ValueTime
writeValue
class ValueTime extends Value { /** * The precision in digits. */ public static final int PRECISION = 6; /** * The display size of the textual representation of a time. * Example: 10:00:00 */ static final int DISPLAY_SIZE = 8; private final long nanos; private ValueT...
ValueTime t = (ValueTime) v; long nanos = t.getNanos(); long millis = nanos / 1000000; nanos -= millis * 1000000; buff.put((byte) TIME).putVarLong(millis).putVarLong(nanos);
1,773
89
1,862
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/net/NetNode.java
NetNode
hashCode
class NetNode implements Comparable<NetNode> { private static NetNode localTcpNode = new NetNode(Constants.DEFAULT_HOST, Constants.DEFAULT_TCP_PORT); private static NetNode localP2pNode = new NetNode(Constants.DEFAULT_HOST, Constants.DEFAULT_P2P_PORT); public static void setLocalTc...
final int prime = 31; int result = 1; result = prime * result + ((inetAddress == null) ? 0 : inetAddress.hashCode()); result = prime * result + port; return result;
1,654
58
1,712
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/ProtocolServerEngineBase.java
ProtocolServerEngineBase
getProtocolServer
class ProtocolServerEngineBase extends PluginBase implements ProtocolServerEngine { protected ProtocolServer protocolServer; public ProtocolServerEngineBase(String name) { super(name); } protected abstract ProtocolServer createProtocolServer(); @Override public ProtocolServer getProt...
if (protocolServer == null) protocolServer = createProtocolServer(); return protocolServer;
249
27
276
<methods>public void <init>() ,public void <init>(java.lang.String) ,public synchronized void close() ,public Map<java.lang.String,java.lang.String> getConfig() ,public java.lang.String getName() ,public Class<? extends com.lealone.db.Plugin> getPluginClass() ,public com.lealone.db.Plugin.State getState() ,public synch...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/batch/BatchStatementPreparedUpdate.java
Decoder
decode
class Decoder implements PacketDecoder<BatchStatementPreparedUpdate> { @Override public BatchStatementPreparedUpdate decode(NetInputStream in, int version) throws IOException {<FILL_FUNCTION_BODY>} }
int commandId = in.readInt(); int size = in.readInt(); ArrayList<Value[]> batchParameters = new ArrayList<>(size); for (int i = 0; i < size; i++) { int len = in.readInt(); Value[] values = new Value[len]; for (int j = 0; j ...
60
138
198
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/batch/BatchStatementUpdate.java
Decoder
decode
class Decoder implements PacketDecoder<BatchStatementUpdate> { @Override public BatchStatementUpdate decode(NetInputStream in, int version) throws IOException {<FILL_FUNCTION_BODY>} }
int size = in.readInt(); ArrayList<String> batchStatements = new ArrayList<>(size); for (int i = 0; i < size; i++) batchStatements.add(in.readString()); return new BatchStatementUpdate(size, batchStatements);
54
73
127
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/batch/BatchStatementUpdateAck.java
Decoder
decode
class Decoder implements PacketDecoder<BatchStatementUpdateAck> { @Override public BatchStatementUpdateAck decode(NetInputStream in, int version) throws IOException {<FILL_FUNCTION_BODY>} }
int size = in.readInt(); int[] results = new int[size]; for (int i = 0; i < size; i++) results[i] = in.readInt(); return new BatchStatementUpdateAck(size, results);
58
67
125
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/ps/PreparedStatementGetMetaDataAck.java
PreparedStatementGetMetaDataAck
encode
class PreparedStatementGetMetaDataAck implements AckPacket { public final Result result; public final int columnCount; public final NetInputStream in; public PreparedStatementGetMetaDataAck(Result result) { this.result = result; columnCount = result.getVisibleColumnCount(); in ...
out.writeInt(columnCount); for (int i = 0; i < columnCount; i++) { writeColumn(out, result, i); }
531
45
576
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/ps/PreparedStatementPrepare.java
Decoder
decode
class Decoder implements PacketDecoder<PreparedStatementPrepare> { @Override public PreparedStatementPrepare decode(NetInputStream in, int version) throws IOException {<FILL_FUNCTION_BODY>} }
int commandId = in.readInt(); String sql = in.readString(); return new PreparedStatementPrepare(commandId, sql);
60
40
100
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/ps/PreparedStatementPrepareReadParams.java
Decoder
decode
class Decoder implements PacketDecoder<PreparedStatementPrepareReadParams> { @Override public PreparedStatementPrepareReadParams decode(NetInputStream in, int version) throws IOException {<FILL_FUNCTION_BODY>} }
int commandId = in.readInt(); String sql = in.readString(); return new PreparedStatementPrepareReadParams(commandId, sql);
66
42
108
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/ps/PreparedStatementPrepareReadParamsAck.java
ClientCommandParameter
checkSet
class ClientCommandParameter implements CommandParameter { private final int index; private Value value; private int dataType = Value.UNKNOWN; private long precision; private int scale; private int nullable = ResultSetMetaData.columnNullableUnknown; public Clien...
if (value == null) { throw DbException.get(ErrorCode.PARAMETER_NOT_SET_1, "#" + (index + 1)); }
466
45
511
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/ps/PreparedStatementQuery.java
PreparedStatementQuery
encode
class PreparedStatementQuery extends QueryPacket { public final int commandId; public final Value[] parameters; public PreparedStatementQuery(int resultId, int maxRows, int fetchSize, boolean scrollable, int commandId, Value[] parameters) { super(resultId, maxRows, fetchSize, scrollabl...
super.encode(out, version); out.writeInt(commandId); int size = parameters.length; out.writeInt(size); for (int i = 0; i < size; i++) { out.writeValue(parameters[i]); }
378
72
450
<methods>public void <init>(int, int, int, boolean) ,public void <init>(com.lealone.net.NetInputStream, int) throws java.io.IOException,public void encode(com.lealone.net.NetOutputStream, int) throws java.io.IOException<variables>public final non-sealed int fetchSize,public final non-sealed int maxRows,public final non...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/ps/PreparedStatementUpdate.java
PreparedStatementUpdate
encode
class PreparedStatementUpdate implements Packet { public final int commandId; public final Value[] parameters; public PreparedStatementUpdate(int commandId, Value[] parameters) { this.commandId = commandId; this.parameters = parameters; } public PreparedStatementUpdate(NetInputStr...
int size = parameters.length; out.writeInt(commandId); out.writeInt(size); for (int i = 0; i < size; i++) { out.writeValue(parameters[i]); }
327
62
389
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/result/ResultFetchRowsAck.java
Decoder
writeRow
class Decoder implements PacketDecoder<ResultFetchRowsAck> { @Override public ResultFetchRowsAck decode(NetInputStream in, int version) throws IOException { return new ResultFetchRowsAck(in); } } public static void writeRow(NetOutputStream out, Result result, int count) thro...
try { int visibleColumnCount = result.getVisibleColumnCount(); for (int i = 0; i < count; i++) { if (result.next()) { out.writeBoolean(true); Value[] v = result.currentRow(); for (int j = 0; j < visibleColumnCou...
96
197
293
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/session/SessionInit.java
SessionInit
encode
class SessionInit implements Packet { public final ConnectionInfo ci; public final int clientVersion; public SessionInit(ConnectionInfo ci) { this.ci = ci; this.clientVersion = 0; } public SessionInit(ConnectionInfo ci, int clientVersion) { this.ci = ci; this.clien...
out.setSSL(ci.isSSL()); out.writeInt(Constants.TCP_PROTOCOL_VERSION_MIN); // minClientVersion out.writeInt(Constants.TCP_PROTOCOL_VERSION_MAX); // maxClientVersion out.writeString(ci.getDatabaseName()); out.writeString(ci.getURL()); // 不带参数的URL out.writeString(ci.getUser...
736
207
943
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/session/SessionInitAck.java
SessionInitAck
encode
class SessionInitAck implements AckPacket { public final int clientVersion; public final boolean autoCommit; public final String targetNodes; public final RunMode runMode; public final boolean invalid; public final int consistencyLevel; public SessionInitAck(int clientVersion, boolean auto...
out.writeInt(clientVersion); out.writeBoolean(autoCommit); if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_6) { out.writeString(targetNodes); out.writeString(runMode.toString()); out.writeBoolean(invalid); out.writeInt(consistencyLevel); ...
459
91
550
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/server/protocol/statement/StatementQueryAck.java
StatementQueryAck
encode
class StatementQueryAck implements AckPacket { public final Result result; public final int rowCount; public final int columnCount; public final int fetchSize; public final NetInputStream in; public StatementQueryAck(Result result, int rowCount, int fetchSize) { this.result = result; ...
out.writeInt(rowCount); out.writeInt(columnCount); out.writeInt(fetchSize); encodeExt(out, version); for (int i = 0; i < columnCount; i++) { PreparedStatementGetMetaDataAck.writeColumn(out, result, i); } ResultFetchRowsAck.writeRow(out, result, fetchS...
396
102
498
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/StorageBase.java
StorageBase
closeImmediately
class StorageBase implements Storage { protected static final String TEMP_NAME_PREFIX = Constants.NAME_SEPARATOR + "temp" + Constants.NAME_SEPARATOR; protected final Map<StorageEventListener, StorageEventListener> listeners = new ConcurrentHashMap<>(); protected final Map<String, StorageMap<?,...
closed = true; for (StorageMap<?, ?> map : maps.values()) map.close(); maps.clear();
1,583
39
1,622
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/StorageMapBase.java
StorageMapBase
setMaxKey
class StorageMapBase<K, V> implements StorageMap<K, V> { protected final String name; protected final StorageDataType keyType; protected final StorageDataType valueType; protected final Storage storage; protected final AtomicLong maxKey = new AtomicLong(0); protected StorageMapBase(String nam...
if (key instanceof ValueLong) { setMaxKey(((ValueLong) key).getLong()); } else if (key instanceof Number) { setMaxKey(((Number) key).longValue()); }
564
56
620
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/fs/FileStorageInputStream.java
FileStorageInputStream
read
class FileStorageInputStream extends InputStream { private FileStorage fileStorage; private final boolean alwaysClose; private final CompressTool compress; private final DataBuffer page; private final boolean raw; private int remainingInBuffer; private boolean endOfFile; public FileSto...
fillBuffer(); if (endOfFile) { return -1; } int i = page.readByte() & 0xff; remainingInBuffer--; return i;
1,220
54
1,274
<methods>public void <init>() ,public int available() throws java.io.IOException,public void close() throws java.io.IOException,public synchronized void mark(int) ,public boolean markSupported() ,public static java.io.InputStream nullInputStream() ,public abstract int read() throws java.io.IOException,public int read(b...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/fs/FileStorageOutputStream.java
FileStorageOutputStream
write
class FileStorageOutputStream extends OutputStream { private FileStorage fileStorage; private final CompressTool compress; private final String compressionAlgorithm; private final DataBuffer page; private final byte[] buffer = { 0 }; public FileStorageOutputStream(FileStorage fs, DataHandler h...
if (len > 0) { page.reset(); if (compress != null) { if (off != 0 || len != buff.length) { byte[] b2 = new byte[len]; System.arraycopy(buff, off, b2, 0, len); buff = b2; off = 0; ...
346
216
562
<methods>public void <init>() ,public void close() throws java.io.IOException,public void flush() throws java.io.IOException,public static java.io.OutputStream nullOutputStream() ,public abstract void write(int) throws java.io.IOException,public void write(byte[]) throws java.io.IOException,public void write(byte[], in...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/fs/impl/FileBase.java
FileBase
write
class FileBase extends FileChannel { @Override public abstract long size() throws IOException; @Override public abstract long position() throws IOException; @Override public abstract FileChannel position(long newPosition) throws IOException; @Override public abstract int read(ByteBuf...
long oldPos = position(); position(position); int len = write(src); position(oldPos); return len;
533
38
571
<methods>public abstract void force(boolean) throws java.io.IOException,public final java.nio.channels.FileLock lock() throws java.io.IOException,public abstract java.nio.channels.FileLock lock(long, long, boolean) throws java.io.IOException,public abstract java.nio.MappedByteBuffer map(java.nio.channels.FileChannel.Ma...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/fs/impl/FileChannelInputStream.java
FileChannelInputStream
read
class FileChannelInputStream extends InputStream { private final FileChannel channel; private final boolean closeChannel; private ByteBuffer buffer; private long pos; /** * Create a new file object input stream from the file channel. * * @param channel the file channel * @para...
if (buffer == null) { buffer = ByteBuffer.allocate(1); } buffer.rewind(); int len = channel.read(buffer, pos++); if (len < 0) { return -1; } return buffer.get(0) & 0xff;
310
81
391
<methods>public void <init>() ,public int available() throws java.io.IOException,public void close() throws java.io.IOException,public synchronized void mark(int) ,public boolean markSupported() ,public static java.io.InputStream nullInputStream() ,public abstract int read() throws java.io.IOException,public int read(b...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/fs/impl/FilePathWrapper.java
FilePathWrapper
wrap
class FilePathWrapper extends FilePath { private FilePath base; @Override public FilePathWrapper getPath(String path) { return create(path, unwrap(path)); } /** * Create a wrapped path instance for the given base path. * * @param base the base path * @return the wrappe...
return base == null ? null : create(getPrefix() + base.name, base);
923
24
947
<methods>public non-sealed void <init>() ,public abstract boolean canWrite() ,public abstract void createDirectory() ,public abstract boolean createFile() ,public com.lealone.storage.fs.FilePath createTempFile(java.lang.String, boolean, boolean) throws java.io.IOException,public abstract void delete() ,public abstract ...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/fs/impl/disk/FileDisk.java
FileDisk
read
class FileDisk extends FileBase { private final RandomAccessFile file; private final String name; private final boolean readOnly; FileDisk(String fileName, String mode) throws FileNotFoundException { this.file = new RandomAccessFile(fileName, mode); this.name = fileName; this.r...
int len = file.read(dst.array(), dst.arrayOffset() + dst.position(), dst.remaining()); if (len > 0) { dst.position(dst.position() + len); } return len;
599
67
666
<methods>public non-sealed void <init>() ,public void force(boolean) throws java.io.IOException,public java.nio.channels.FileLock lock(long, long, boolean) throws java.io.IOException,public java.nio.MappedByteBuffer map(java.nio.channels.FileChannel.MapMode, long, long) throws java.io.IOException,public abstract long p...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/fs/impl/encrypt/FileEncrypt.java
XTS
xorTweak
class XTS { /** * Galois field feedback. */ private static final int GF_128_FEEDBACK = 0x87; /** * The AES encryption block size. */ private static final int CIPHER_BLOCK_SIZE = 16; private final BlockCipher cipher; XTS(BlockCipher ...
for (int i = 0; i < CIPHER_BLOCK_SIZE; i++) { data[pos + i] ^= tweak[i]; }
1,255
45
1,300
<methods>public non-sealed void <init>() ,public void force(boolean) throws java.io.IOException,public java.nio.channels.FileLock lock(long, long, boolean) throws java.io.IOException,public java.nio.MappedByteBuffer map(java.nio.channels.FileChannel.MapMode, long, long) throws java.io.IOException,public abstract long p...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/fs/impl/encrypt/FilePathEncrypt.java
FilePathEncrypt
parse
class FilePathEncrypt extends FilePathWrapper { private static final String SCHEME = "encrypt"; /** * Register this file system. */ public static void register() { FilePath.register(new FilePathEncrypt()); } @Override public String getScheme() { return SCHEME; } ...
if (!fileName.startsWith(getScheme())) { throw new IllegalArgumentException(fileName + " doesn't start with " + getScheme()); } fileName = fileName.substring(getScheme().length() + 1); int idx = fileName.indexOf(':'); String password; if (idx < 0) { ...
690
157
847
<methods>public non-sealed void <init>() ,public boolean canWrite() ,public void createDirectory() ,public boolean createFile() ,public com.lealone.storage.fs.FilePath createTempFile(java.lang.String, boolean, boolean) throws java.io.IOException,public void delete() ,public boolean exists() ,public com.lealone.storage....
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/fs/impl/nio/FileNio.java
FileNio
truncate
class FileNio extends FileBase { private final String fileName; private final RandomAccessFile file; private final FileChannel channel; FileNio(String fileName, String mode) throws IOException { this.fileName = fileName; file = new RandomAccessFile(fileName, mode); channel = fi...
long size = channel.size(); if (newLength < size) { long pos = channel.position(); channel.truncate(newLength); long newPos = channel.position(); if (pos < newLength) { // position should stay // in theory, this should not ...
504
160
664
<methods>public non-sealed void <init>() ,public void force(boolean) throws java.io.IOException,public java.nio.channels.FileLock lock(long, long, boolean) throws java.io.IOException,public java.nio.MappedByteBuffer map(java.nio.channels.FileChannel.MapMode, long, long) throws java.io.IOException,public abstract long p...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/lob/LobLocalStorage.java
LobLocalStorage
createBlob
class LobLocalStorage implements LobStorage { private final DataHandler handler; private final LobReader lobReader; public LobLocalStorage(DataHandler handler, LobReader lobReader) { this.handler = handler; this.lobReader = lobReader; } @Override public ValueLob createBlob(Inp...
// need to use a temp file, because the input stream could come from // the same database, which would create a weird situation (trying // to read a block while writing something) return ValueLob.createTempBlob(in, maxLength, handler);
985
66
1,051
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/type/BigIntegerType.java
BigIntegerType
read
class BigIntegerType extends StorageDataTypeBase { @Override public int getType() { return TYPE_BIG_INTEGER; } @Override public int compare(Object aObj, Object bObj) { BigInteger a = (BigInteger) aObj; BigInteger b = (BigInteger) bObj; return a.compareTo(b); } ...
switch (tag) { case TAG_BIG_INTEGER_0: return BigInteger.ZERO; case TAG_BIG_INTEGER_1: return BigInteger.ONE; case TAG_BIG_INTEGER_SMALL: return BigInteger.valueOf(DataUtils.readVarLong(buff)); } int len = DataUtils.readVarInt(buff); ...
371
140
511
<methods>public non-sealed void <init>() ,public abstract int getType() ,public java.lang.Object read(java.nio.ByteBuffer) ,public java.lang.Object read(java.nio.ByteBuffer, int) ,public com.lealone.db.value.Value readValue(java.nio.ByteBuffer) ,public com.lealone.db.value.Value readValue(java.nio.ByteBuffer, int) ,pub...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/type/CharacterType.java
CharacterType
compare
class CharacterType extends StorageDataTypeBase { @Override public int getType() { return TYPE_CHAR; } @Override public int compare(Object aObj, Object bObj) {<FILL_FUNCTION_BODY>} @Override public int getMemory(Object obj) { return 16; } @Override public void...
Character a = (Character) aObj; Character b = (Character) bObj; return a.compareTo(b);
177
35
212
<methods>public non-sealed void <init>() ,public abstract int getType() ,public java.lang.Object read(java.nio.ByteBuffer) ,public java.lang.Object read(java.nio.ByteBuffer, int) ,public com.lealone.db.value.Value readValue(java.nio.ByteBuffer) ,public com.lealone.db.value.Value readValue(java.nio.ByteBuffer, int) ,pub...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/type/ObjectDataType.java
ObjectDataType
getTypeId
class ObjectDataType implements StorageDataType { private StorageDataTypeBase last = ValueString.type; @Override public int compare(Object a, Object b) { switchType(a); return last.compare(a, b); } @Override public int getMemory(Object obj) { switchType(obj); r...
if (obj instanceof Integer) { return TYPE_INT; } else if (obj instanceof String) { return TYPE_STRING; } else if (obj instanceof Long) { return TYPE_LONG; } else if (obj instanceof Double) { return TYPE_DOUBLE; } else if (obj insta...
1,263
357
1,620
<no_super_class>
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/storage/type/SerializedObjectType.java
SerializedObjectType
getMemory
class SerializedObjectType extends StorageDataTypeBase { private int averageSize = 10000; private final ObjectDataType base = new ObjectDataType(); @Override public int getType() { return TYPE_SERIALIZED_OBJECT; } @Override @SuppressWarnings("unchecked") public int compare(Obj...
StorageDataType t = getType(obj); if (t.getClass() == this.getClass()) { return averageSize; } return t.getMemory(obj);
965
50
1,015
<methods>public non-sealed void <init>() ,public abstract int getType() ,public java.lang.Object read(java.nio.ByteBuffer) ,public java.lang.Object read(java.nio.ByteBuffer, int) ,public com.lealone.db.value.Value readValue(java.nio.ByteBuffer) ,public com.lealone.db.value.Value readValue(java.nio.ByteBuffer, int) ,pub...
lealone_Lealone
Lealone/lealone-common/src/main/java/com/lealone/transaction/PendingTransaction.java
PendingTransaction
setSynced
class PendingTransaction extends LinkableBase<PendingTransaction> { private final Transaction transaction; private final Object redoLogRecord; private final long logId; private CountDownLatch latch; private boolean synced; private boolean completed; public PendingTransaction(Transaction tr...
if (transaction != null) transaction.onSynced(); this.synced = synced; if (latch != null) latch.countDown();
326
48
374
<methods>public non-sealed void <init>() ,public com.lealone.transaction.PendingTransaction getNext() ,public void setNext(com.lealone.transaction.PendingTransaction) <variables>public com.lealone.transaction.PendingTransaction next
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/Comment.java
Comment
getCreateSQL
class Comment extends DbObjectBase { private final DbObjectType objectType; private final String objectName; private String commentText; public Comment(Database database, int id, DbObject obj) { super(database, id, getKey(obj)); this.objectType = obj.getType(); this.objectName ...
StringBuilder buff = new StringBuilder("COMMENT ON "); buff.append(getTypeName(objectType)).append(' ').append(objectName).append(" IS "); if (commentText == null) { buff.append("NULL"); } else { buff.append(StringUtils.quoteStringSQL(commentText)); } ...
436
92
528
<methods>public void checkRename() ,public List<? extends com.lealone.db.DbObject> getChildren() ,public java.lang.String getComment() ,public com.lealone.db.Database getDatabase() ,public java.lang.String getDropSQL() ,public int getId() ,public long getModificationId() ,public java.lang.String getName() ,public java....
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/DbObjectBase.java
DbObjectBase
toString
class DbObjectBase implements DbObject { protected Database database; protected int id; protected String name; protected boolean temporary; protected String comment; protected long modificationId; /** * Initialize some attributes of this object. * * @param db the database ...
return name + ":" + id + ":" + super.toString();
700
20
720
<no_super_class>
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/LealoneDatabase.java
LealoneDatabase
closeDatabase
class LealoneDatabase extends Database implements com.lealone.transaction.TransactionEngine.GcTask { // ID固定为0 public static final int ID = 0; public static final String NAME = Constants.PROJECT_NAME; // 仅用于支持qinsql项目 private static final CaseInsensitiveMap<String> UNSUPPORTED_SCHEMA_MAP =...
Database db = findDatabase(dbName); if (db != null) { synchronized (CLOSED_DATABASES) { getDatabasesMap().remove(dbName); // 要放到同步块中 CLOSED_DATABASES.put(dbName, new Object[] { db.getCreateSQL(), db.getId() }); } }
1,666
97
1,763
<methods>public void <init>(int, java.lang.String, Map<java.lang.String,java.lang.String>) ,public void addDataHandler(int, com.lealone.db.DataHandler) ,public void addDatabaseObject(com.lealone.db.session.ServerSession, com.lealone.db.DbObject, com.lealone.db.lock.DbObjectLock) ,public synchronized boolean addWaitingS...
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/MetaRecord.java
MetaRecord
execute
class MetaRecord implements Comparable<MetaRecord> { public static Row getRow(Table metaTable, DbObject obj) { Row Row = metaTable.getTemplateRow(); Row.setValue(0, ValueInt.get(obj.getId())); Row.setValue(1, ValueInt.get(obj.getType().value)); Row.setValue(2, ValueString.get(obj.ge...
try { PreparedSQLStatement command = systemSession.prepareStatementLocal(sql); // 设置好数据库对象id,这样在执行create语句创建数据库对象时就能复用上一次得到的id了 command.setObjectId(id); systemSession.executeUpdateLocal(command); } catch (DbException e) { e = e.addSQL(sql); ...
523
177
700
<no_super_class>
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/PluginObject.java
PluginObject
getCreateSQL
class PluginObject extends DbObjectBase { private final String implementBy; private final String classPath; private final CaseInsensitiveMap<String> parameters; private Plugin plugin; private URLClassLoader classLoader; private String state = "inited"; public PluginObject(Database database...
StatementBuilder sql = new StatementBuilder("CREATE PLUGIN "); sql.append("IF NOT EXISTS "); sql.append(getSQL()); sql.append(" IMPLEMENT BY '").append(implementBy).append("'"); if (classPath != null) { sql.append(" CLASS PATH '").append(classPath).append("'"); ...
419
142
561
<methods>public void checkRename() ,public List<? extends com.lealone.db.DbObject> getChildren() ,public java.lang.String getComment() ,public com.lealone.db.Database getDatabase() ,public java.lang.String getDropSQL() ,public int getId() ,public long getModificationId() ,public java.lang.String getName() ,public java....
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/TransactionalDbObjects.java
TransactionalDbObjects
find
class TransactionalDbObjects { private HashMap<String, DbObject> dbObjects; private TransactionalDbObjects old; private long version; private boolean needGc; public TransactionalDbObjects() { this.dbObjects = new CaseInsensitiveMap<>(); } public HashMap<String, DbObject> getDbObje...
if (session == null) { if (version <= 0) return dbObjects.get(dbObjectName); else if (old != null) { return old.find(session, dbObjectName); } else { return dbObjects.get(dbObjectName); } } Transacti...
760
356
1,116
<no_super_class>
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/auth/PasswordHash.java
PasswordHash
setPasswordLealone
class PasswordHash { public static void setPassword(User user, String password) { setPasswordLealone(user, password); setPasswordMongo(user, password); setPasswordMySQL(user, password); setPasswordPostgreSQL(user, password); } private static void setPasswordLealone(User use...
char[] passwordChars = password == null ? new char[0] : password.toCharArray(); byte[] userPasswordHash = ConnectionInfo.createUserPasswordHash(user.getName(), passwordChars); user.setUserPasswordHash(userPasswordHash);
1,208
64
1,272
<no_super_class>
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/auth/Right.java
Right
getRights
class Right extends DbObjectBase { /** * The right bit mask that means: selecting from a table is allowed. */ public static final int SELECT = 1; /** * The right bit mask that means: deleting rows from a table is allowed. */ public static final int DELETE = 2; /** * The r...
StringBuilder buff = new StringBuilder(); if (grantedRight == ALL) { buff.append("ALL"); } else { boolean comma = false; comma = appendRight(buff, grantedRight, SELECT, "SELECT", comma); comma = appendRight(buff, grantedRight, DELETE, "DELETE", co...
1,248
184
1,432
<methods>public void checkRename() ,public List<? extends com.lealone.db.DbObject> getChildren() ,public java.lang.String getComment() ,public com.lealone.db.Database getDatabase() ,public java.lang.String getDropSQL() ,public int getId() ,public long getModificationId() ,public java.lang.String getName() ,public java....
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/auth/RightOwner.java
RightOwner
isRightGrantedRecursive
class RightOwner extends DbObjectBase { /** * The map of granted roles. */ private HashMap<Role, Right> grantedRoles; /** * The map of granted rights. */ private HashMap<DbObject, Right> grantedRights; protected RightOwner(Database database, int id, String name) { supe...
Right right; if (grantedRights != null) { if (schemaObject != null) { right = grantedRights.get(schemaObject.getSchema()); if (right != null) { if ((right.getRightMask() & rightMask) == rightMask) { return true; ...
1,047
216
1,263
<methods>public void checkRename() ,public List<? extends com.lealone.db.DbObject> getChildren() ,public java.lang.String getComment() ,public com.lealone.db.Database getDatabase() ,public java.lang.String getDropSQL() ,public int getId() ,public long getModificationId() ,public java.lang.String getName() ,public java....
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/auth/Role.java
Role
removeChildrenAndResources
class Role extends RightOwner { private final boolean system; public Role(Database database, int id, String roleName, boolean system) { super(database, id, roleName); this.system = system; } @Override public DbObjectType getType() { return DbObjectType.ROLE; } /**...
for (User user : database.getAllUsers()) { Right right = user.getRightForRole(this); if (right != null) { database.removeDatabaseObject(session, right, lock); } } for (Role r2 : database.getAllRoles()) { Right right = r2.getRightFo...
287
185
472
<methods>public com.lealone.db.auth.Right getRightForObject(com.lealone.db.DbObject) ,public com.lealone.db.auth.Right getRightForRole(com.lealone.db.auth.Role) ,public void grantRight(com.lealone.db.DbObject, com.lealone.db.auth.Right) ,public void grantRole(com.lealone.db.auth.Role, com.lealone.db.auth.Right) ,public...
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/auth/scram/ScramPasswordHash.java
ScramPasswordHash
generateSaltedPassword
class ScramPasswordHash { public static void setPasswordMongo(User user, String password) { setPasswordMongo(user, password, 256); } public static void setPasswordMongo(User user, String password, int mechanism) { try { SecureRandom random = new SecureRandom(); byte...
if (password.isEmpty()) return new byte[0]; Mac mac = createHmac(password.getBytes(StandardCharsets.US_ASCII), hmacName); mac.update(salt); mac.update(INT_1); byte[] result = mac.doFinal(); byte[] previous = null; for (int i = 1; i < iterations; i++...
1,189
170
1,359
<no_super_class>
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/constraint/Constraint.java
Constraint
compareTo
class Constraint extends SchemaObjectBase implements Comparable<Constraint> { /** * The constraint type name for check constraints. */ public static final String CHECK = "CHECK"; /** * The constraint type name for referential constraints. */ public static final String REFERENTIAL =...
if (this == other) { return 0; } int thisType = getConstraintTypeOrder(); int otherType = other.getConstraintTypeOrder(); return thisType - otherType;
1,028
54
1,082
<methods>public java.lang.String getSQL() ,public com.lealone.db.schema.Schema getSchema() ,public boolean isHidden() <variables>protected final non-sealed com.lealone.db.schema.Schema schema
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/constraint/ConstraintCheck.java
ConstraintCheck
getCreateSQL
class ConstraintCheck extends Constraint { private IExpression.Evaluator exprEvaluator; private IExpression expr; public ConstraintCheck(Schema schema, int id, String name, Table table) { super(schema, id, name, table); } @Override public String getConstraintType() { return Co...
StringBuilder buff = new StringBuilder("ALTER TABLE "); buff.append(table.getSQL()).append(" ADD CONSTRAINT "); if (table.isHidden()) { buff.append("IF NOT EXISTS "); } buff.append(getSQL()); if (comment != null) { buff.append(" COMMENT ").append(...
902
136
1,038
<methods>public abstract void checkExistingData(com.lealone.db.session.ServerSession) ,public abstract void checkRow(com.lealone.db.session.ServerSession, com.lealone.db.table.Table, com.lealone.db.result.Row, com.lealone.db.result.Row) ,public int compareTo(com.lealone.db.constraint.Constraint) ,public abstract java.l...
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/constraint/ConstraintUnique.java
ConstraintUnique
getReferencedColumns
class ConstraintUnique extends Constraint { private Index index; private boolean indexOwner; private IndexColumn[] columns; private final boolean primaryKey; public ConstraintUnique(Schema schema, int id, String name, Table table, boolean primaryKey) { super(schema, id, name, table); ...
HashSet<Column> result = new HashSet<>(columns.length); for (IndexColumn c : columns) { result.add(c.column); } return result;
964
50
1,014
<methods>public abstract void checkExistingData(com.lealone.db.session.ServerSession) ,public abstract void checkRow(com.lealone.db.session.ServerSession, com.lealone.db.table.Table, com.lealone.db.result.Row, com.lealone.db.result.Row) ,public int compareTo(com.lealone.db.constraint.Constraint) ,public abstract java.l...
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/index/IndexColumn.java
IndexColumn
getSQL
class IndexColumn { /** * The column name. */ public String columnName; /** * The column, or null if not set. */ public Column column; /** * The sort type. Ascending (the default) and descending are supported; * nulls can be sorted first or last. */ public i...
StringBuilder buff = new StringBuilder(column.getSQL()); if ((sortType & SortOrder.DESCENDING) != 0) { buff.append(" DESC"); } if ((sortType & SortOrder.NULLS_FIRST) != 0) { buff.append(" NULLS FIRST"); } else if ((sortType & SortOrder.NULLS_LAST) != 0) {...
434
126
560
<no_super_class>
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/index/IndexRebuilder.java
IndexRebuilder
rebuild
class IndexRebuilder implements Runnable { private final ServerSession session; private final Table table; private final Index index; public IndexRebuilder(ServerSession session, Table table, Index index) { this.session = session; this.table = table; this.index = index; } ...
session.setUndoLogEnabled(false); try { Index scan = table.getScanIndex(session); int rowCount = MathUtils.convertLongToInt(scan.getRowCount(session)); long i = 0; String n = table.getName() + ":" + index.getName(); Database database = table.g...
120
338
458
<no_super_class>
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/index/IndexType.java
IndexType
createScan
class IndexType { private boolean primaryKey; private boolean unique; private boolean hash; private boolean scan; private boolean delegate; private boolean belongsToConstraint; /** * Create a primary key index. * * @param hash if a hash index should be used * @return th...
IndexType type = new IndexType(); type.scan = true; return type;
969
26
995
<no_super_class>
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/index/MetaIndex.java
MetaIndex
getColumnIndex
class MetaIndex extends IndexBase { private final MetaTable meta; private final boolean scan; public MetaIndex(MetaTable meta, IndexColumn[] columns, boolean scan) { super(meta, 0, null, IndexType.createNonUnique(), columns); this.meta = meta; this.scan = scan; } @Override...
if (scan) { // the scan index cannot use any columns return -1; } return super.getColumnIndex(col);
574
40
614
<methods>public boolean canGetFirstOrLast() ,public boolean canScan() ,public void checkRename() ,public void close(com.lealone.db.session.ServerSession) ,public int compareRows(com.lealone.db.result.SearchRow, com.lealone.db.result.SearchRow) ,public com.lealone.db.index.Cursor find(com.lealone.db.session.ServerSessio...
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/index/RangeIndex.java
RangeCursor
next
class RangeCursor implements Cursor { private final long start, end, step; private boolean beforeFirst; private long current; private Row currentRow; RangeCursor(long start, long end, long step) { this.start = start; this.end = end; this.step...
if (beforeFirst) { beforeFirst = false; current = start; } else { current += step; } currentRow = new Row(new Value[] { ValueLong.get(current) }, 1); return step > 0 ? current <= end : current >= end;
138
76
214
<methods>public boolean canGetFirstOrLast() ,public boolean canScan() ,public void checkRename() ,public void close(com.lealone.db.session.ServerSession) ,public int compareRows(com.lealone.db.result.SearchRow, com.lealone.db.result.SearchRow) ,public com.lealone.db.index.Cursor find(com.lealone.db.session.ServerSessio...
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/index/hash/HashIndex.java
HashIndex
getCost
class HashIndex extends IndexBase { /** * The index of the indexed column. */ protected final int indexColumn; protected HashIndex(Table table, int id, String indexName, IndexType indexType, IndexColumn[] columns) { super(table, id, indexName, indexType, columns); thi...
if (masks == null) { return Long.MAX_VALUE; } for (Column column : columns) { int index = column.getColumnId(); int mask = masks[index]; if ((mask & IndexConditionType.EQUALITY) != IndexConditionType.EQUALITY) { return Long.MAX_VAL...
516
104
620
<methods>public boolean canGetFirstOrLast() ,public boolean canScan() ,public void checkRename() ,public void close(com.lealone.db.session.ServerSession) ,public int compareRows(com.lealone.db.result.SearchRow, com.lealone.db.result.SearchRow) ,public com.lealone.db.index.Cursor find(com.lealone.db.session.ServerSessio...
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/index/hash/NonUniqueHashIndex.java
NonUniqueHashIndex
add
class NonUniqueHashIndex extends HashIndex { private final ReadWriteLock lock = new ReentrantReadWriteLock(true); private ValueHashMap<ArrayList<Long>> rows; private long rowCount; public NonUniqueHashIndex(Table table, int id, String indexName, IndexType indexType, IndexColumn[] columns) ...
lock.writeLock().lock(); try { Value key = getKey(row); ArrayList<Long> positions = rows.get(key); if (positions == null) { positions = Utils.newSmallArrayList(); rows.put(key, positions); } positions.add(row.ge...
825
127
952
<methods>public boolean canGetFirstOrLast() ,public boolean canScan() ,public void checkRename() ,public void close(com.lealone.db.session.ServerSession) ,public com.lealone.db.result.SearchRow findFirstOrLast(com.lealone.db.session.ServerSession, boolean) ,public double getCost(com.lealone.db.session.ServerSession, in...
lealone_Lealone
Lealone/lealone-db/src/main/java/com/lealone/db/index/hash/UniqueHashIndex.java
UniqueHashIndex
find
class UniqueHashIndex extends HashIndex { private ConcurrentHashMap<Value, Long> rows; public UniqueHashIndex(Table table, int id, String indexName, IndexType indexType, IndexColumn[] columns) { super(table, id, indexName, indexType, columns); reset(); } @Override prot...
checkSearchKey(first, last); Row result; Long pos = rows.get(getKey(first)); if (pos == null) { result = null; } else { result = table.getRow(session, pos.intValue()); } return new SingleRowCursor(result);
532
81
613
<methods>public boolean canGetFirstOrLast() ,public boolean canScan() ,public void checkRename() ,public void close(com.lealone.db.session.ServerSession) ,public com.lealone.db.result.SearchRow findFirstOrLast(com.lealone.db.session.ServerSession, boolean) ,public double getCost(com.lealone.db.session.ServerSession, in...