package jnicli;
import java.lang.reflect.*;
import java.util.*;
/**
* Interface to database using Java native interface.
* This class should be used by applications accessing database locally
*/
public class DatabaseJNI implements Database {
public void open(int accessType, String databaseName, String databasePath, long initSize, int transactionCommitDelay) {
db = jniOpen(accessType, databaseName, databasePath, initSize, transactionCommitDelay);
String table;
classes = new Hashtable();
while ((table = jniNextTable(db)) != null) {
try {
Class c = Class.forName(table);
ClassDescriptor desc = new ClassDescriptor(c);
classes.put(c, desc);
desc.td = jniUpdateTable(db, table, getTableDescriptor(desc));
} catch (ClassNotFoundException x) {
new CliException("Class '" + table + "' not found");
} catch (Exception x) {
new CliException(x.getMessage());
}
}
}
public void close() {
jniClose(db);
classes = null;
}
public Cursor select(Class table, String condition, int flags) {
ClassDescriptor desc = (ClassDescriptor)classes.get(table);
if (desc == null) {
throw new CliException("Table not found: " + table);
}
long result = jniSelect(db, desc.td, condition);
Cursor cursor;
if (remote || (flags & AUTOCOMMIT) != 0) {
cursor = new PrefetchedCursor(this, result, desc);
if ((flags & AUTOCOMMIT) != 0) {
jniCommit(db);
}
} else {
cursor = (flags & FOR_UPDATE) != 0
? (Cursor)new IncrementalCursorForUpdate(this, result, desc)
: (Cursor)new IncrementalCursor(this, result, desc);
}
return cursor;
}
Object unswizzleObject(long cursor, ClassDescriptor desc) {
int[] types = desc.types;
Field[] fields = desc.fields;
try {
Object obj = desc.newInstance();
for (int i = 0; i < types.length; i++) {
Field f = fields[i];
switch (types[i]) {
case TP_BOOL:
f.setBoolean(obj, jniGetByte(cursor) != 0);
continue;
case TP_CHAR:
f.setChar(obj, (char)jniGetShort(cursor));
continue;
case TP_INT1:
f.setByte(obj, jniGetByte(cursor));
continue;
case TP_INT2:
f.setShort(obj, jniGetShort(cursor));
continue;
case TP_INT4:
f.setInt(obj, jniGetInt(cursor));
continue;
case TP_INT8:
f.setLong(obj, jniGetLong(cursor));
continue;
case TP_REAL4:
f.setFloat(obj, Float.intBitsToFloat(jniGetInt(cursor)));
continue;
case TP_REAL8:
f.setDouble(obj, Double.longBitsToDouble(jniGetLong(cursor)));
continue;
case TP_STRING:
f.set(obj, jniGetString(cursor));
continue;
case TP_DATE:
{
long timestamp = jniGetLong(cursor);
f.set(obj, timestamp < 0 ? null : new Date(timestamp));
continue;
}
case TP_BOOL_ARRAY:
f.set(obj, jniGetBoolArray(cursor));
continue;
case TP_CHAR_ARRAY:
f.set(obj, jniGetCharArray(cursor));
continue;
case TP_INT1_ARRAY:
f.set(obj, jniGetByteArray(cursor));
continue;
case TP_INT2_ARRAY:
f.set(obj, jniGetShortArray(cursor));
continue;
case TP_INT4_ARRAY:
f.set(obj, jniGetIntArray(cursor));
continue;
case TP_INT8_ARRAY:
f.set(obj, jniGetLongArray(cursor));
continue;
case TP_REAL4_ARRAY:
f.set(obj, jniGetFloatArray(cursor));
continue;
case TP_REAL8_ARRAY:
f.set(obj, jniGetDoubleArray(cursor));
continue;
case TP_STRING_ARRAY:
f.set(obj, jniGetStringArray(cursor));
continue;
default:
throw new CliException("Invalid field type: " + types[i]);
}
}
return obj;
} catch (Exception x) {
throw new CliException(x.getMessage());
}
}
private long swizzleObject(ClassDescriptor desc, Object obj) {
long buf = jniCreateBuffer();
int[] types = desc.types;
Field[] fields = desc.fields;
try {
for (int i = 0; i < types.length; i++) {
Field f = fields[i];
switch (types[i]) {
case TP_BOOL:
jniSetByte(buf, (byte)(f.getBoolean(obj) ? 1 : 0));
continue;
case TP_CHAR:
jniSetShort(buf, (short)f.getChar(obj));
continue;
case TP_INT1:
jniSetByte(buf, f.getByte(obj));
continue;
case TP_INT2:
jniSetShort(buf, f.getShort(obj));
continue;
case TP_INT4:
jniSetInt(buf, f.getInt(obj));
continue;
case TP_INT8:
jniSetLong(buf, f.getLong(obj));
continue;
case TP_REAL4:
jniSetInt(buf, Float.floatToIntBits(f.getFloat(obj)));
continue;
case TP_REAL8:
jniSetLong(buf, Double.doubleToLongBits(f.getDouble(obj)));
continue;
case TP_STRING:
jniSetString(buf, (String)f.get(obj));
continue;
case TP_DATE:
{
Date d = (Date)f.get(obj);
jniSetLong(buf, d != null ? d.getTime() : -1);
continue;
}
case TP_BOOL_ARRAY:
jniSetBoolArray(buf, (boolean[])f.get(obj));
continue;
case TP_CHAR_ARRAY:
jniSetCharArray(buf, (char[])f.get(obj));
continue;
case TP_INT1_ARRAY:
jniSetByteArray(buf, (byte[])f.get(obj));
continue;
case TP_INT2_ARRAY:
jniSetShortArray(buf, (short[])f.get(obj));
continue;
case TP_INT4_ARRAY:
jniSetIntArray(buf, (int[])f.get(obj));
continue;
case TP_INT8_ARRAY:
jniSetLongArray(buf, (long[])f.get(obj));
continue;
case TP_REAL4_ARRAY:
jniSetFloatArray(buf, (float[])f.get(obj));
continue;
case TP_REAL8_ARRAY:
jniSetDoubleArray(buf, (double[])f.get(obj));
continue;
case TP_STRING_ARRAY:
jniSetStringArray(buf, (String[])f.get(obj));
continue;
default:
throw new CliException("Invalid field type: " + types[i]);
}
}
} catch (Exception x)
没有合适的资源?快使用搜索试试~ 我知道了~
fastdb-3.36.tar.gz_实时内存数据_虚拟同步机
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 66 浏览量
2022-09-22
23:45:02
上传
评论
收藏 1.13MB GZ 举报
温馨提示
共449个文件
html:148个
cpp:75个
h:70个
FastDb是高效的内存数据库系统,具备实时能力及便利的C++接口。FastDB不支持client-server架构因而所有使用FastDB的应用程序必须运行在同一主机上。FastDB针对应用程序通过控制读访问模式作了优化。通过降低数据传输的开销和非常有效的锁机制提供了高速的查询。对每一个使用数据库的应用数据库文件被影射到虚拟内存空间中。因此查询在应用的上下文中执行而不需要切换上下文以及数据传输。fastdb中并发访问数据库的同步机制通过原子指令实现,几乎不增加查询的开销。fastdb假定整个数据库存在于RAM中,并且依据这个假定优化了查询算法和接口。此外,fastdb没有数据库缓冲管理开销,不需要在数据库文件和缓冲池之间传输数据。这就是fastdb运行速度明显快于把数据放在缓冲池中的传统数据库的原因。
资源推荐
资源详情
资源评论
收起资源包目录
fastdb-3.36.tar.gz_实时内存数据_虚拟同步机 (449个子文件)
makefile.acc 4KB
genparse.bat 458B
compile.bat 227B
runtests.bat 210B
make.bat 36B
makefile.bcc 6KB
FastDB.bpg 2KB
clitest.c 10KB
clitest2.c 7KB
testalter.c 4KB
testrect.c 4KB
doxygen.cfg 44KB
CHANGES 35KB
JniTestIndex.class 3KB
JniTestIndex$Record.class 482B
CONTENTS 515B
database.cpp 247KB
subsql.cpp 121KB
localcli.cpp 90KB
bugdb.cpp 78KB
compiler.cpp 60KB
wince_time.cpp 60KB
class.cpp 57KB
server.cpp 53KB
file.cpp 42KB
cli.cpp 40KB
scan.cpp 35KB
scan.cpp 35KB
scan.cpp 35KB
jnicli.cpp 33KB
clidb.cpp 33KB
ttree.cpp 31KB
w32sock.cpp 29KB
gram.tab.cpp 28KB
gram.tab.cpp 28KB
gram.tab.cpp 28KB
cursor.cpp 24KB
wwwapi.cpp 23KB
sync.cpp 18KB
unisock.cpp 17KB
rtree.cpp 14KB
testdb.cpp 14KB
hashtab.cpp 12KB
GiST.cpp 11KB
query.cpp 11KB
GiSTnode.cpp 9KB
testjoin.cpp 7KB
testtrav.cpp 7KB
repsock.cpp 6KB
testconc.cpp 6KB
testspat.cpp 5KB
testsync.cpp 5KB
RTnode.cpp 5KB
command.cpp 5KB
command.cpp 5KB
command.cpp 5KB
container.cpp 4KB
testiref.cpp 4KB
guess.cpp 4KB
testperf.cpp 4KB
testindex.cpp 4KB
guess_std.cpp 4KB
guess2.cpp 4KB
testraw.cpp 3KB
cgistub.cpp 3KB
testddl.cpp 3KB
testreplic.cpp 3KB
testfuzzy.cpp 3KB
GiSTfile.cpp 3KB
testleak.cpp 3KB
testharr.cpp 3KB
BTnode.cpp 3KB
RTnode.cpp 3KB
testpar.cpp 2KB
testidx.cpp 2KB
cleanupsem.cpp 2KB
BTentry.cpp 2KB
symtab.cpp 2KB
testfrag.cpp 2KB
testconcur.cpp 2KB
RT.cpp 2KB
RTentry.cpp 2KB
GiSTdb.cpp 1KB
forcerecovery.cpp 1KB
GiSTcursor.cpp 1KB
RTpredicate.cpp 1KB
RTpredicate.cpp 1KB
BTpredicate.cpp 984B
stdtp.cpp 675B
RTentry.cpp 638B
GiSTpredicate.cpp 547B
FastDbCli.cs 48KB
FastDbFields.cs 32KB
FastDbConnection.cs 18KB
FastDbCommand.cs 14KB
Test.cs 4KB
TestIndex.cs 4KB
AssemblyInfo.cs 2KB
FastDbNet.csproj 4KB
Test2.csproj 4KB
共 449 条
- 1
- 2
- 3
- 4
- 5
资源评论
我虽横行却不霸道
- 粉丝: 72
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功