当前位置: 首页>>代码示例>>Java>>正文


Java Database类代码示例

本文整理汇总了Java中org.fusesource.lmdbjni.Database的典型用法代码示例。如果您正苦于以下问题:Java Database类的具体用法?Java Database怎么用?Java Database使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Database类属于org.fusesource.lmdbjni包,在下文中一共展示了Database类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: valuesOfKey

import org.fusesource.lmdbjni.Database; //导入依赖的package包/类
public Count valuesOfKey(final Key key, final long cost, final boolean isEstimateOk)
{
	index.checkOpen();
	if (cost == 0)
		return null;
	else
	{
		Ref<Long> counter = new Ref<Long>() {
		public Long get() {
			Database db = index.keyBucket(key) == 0 ? index.db : index.db2;
			try (Cursor cursor = db.openCursor(index.txn().getDbTransaction())) 
			{
				byte[] keyAsBytes = index.keyConverter.toByteArray(key);
				Entry entry = cursor.get(CursorOp.SET, keyAsBytes);
				if (entry != null)
					return cursor.count();
				else
					return 0l;
			}
			catch (LMDBException ex)
			{
				throw new HGException(ex);
			}
		}};
		return new Count(counter, false);
	}		
}
 
开发者ID:hypergraphdb,项目名称:hypergraphdb,代码行数:28,代码来源:LMDBIndexStats.java

示例2: checkIndexExisting

import org.fusesource.lmdbjni.Database; //导入依赖的package包/类
boolean checkIndexExisting(String name)
{
	if (openIndices.get(name) != null)
		return true;
	else
	{
		Database db = null;
		try
		{
			db = env.openDatabase(txn().getDbTransaction(), DefaultIndexImpl.DB_NAME_PREFIX + name, 0);
		}
		catch (Exception ex)
		{
		}
		if (db != null)
		{
			try
			{
				db.close();
			}
			catch (Throwable t)
			{
				t.printStackTrace();
			}
			return true;
		}
		else
			return false;
	}
}
 
开发者ID:hypergraphdb,项目名称:hypergraphdb,代码行数:31,代码来源:LmdbStorageImplementation.java

示例3: removeIndex

import org.fusesource.lmdbjni.Database; //导入依赖的package包/类
@Override
public void removeIndex(String name)
{
	indicesLock.writeLock().lock();
	try
	{
		HGIndex<?, ?> idx = openIndices.get(name);
		if (idx != null)
		{
			idx.close();
			openIndices.remove(name);
		}
		try
		{
			Database db = env.openDatabase(DefaultIndexImpl.DB_NAME_PREFIX + name);
			db.drop(true);
		}
		catch (Exception e)
		{
			throw new HGException(e);
		}
	}
	finally
	{
		indicesLock.writeLock().unlock();
	}
}
 
开发者ID:hypergraphdb,项目名称:hypergraphdb,代码行数:28,代码来源:LmdbStorageImplementation.java

示例4: query

import org.fusesource.lmdbjni.Database; //导入依赖的package包/类
/**
 * Optimized _linear_search_ for the best N documents by cosine similarity.
 * Be warned: This will be slow.
 */
public List<Passage> query(Question question) {
	// Convert the question to a vector.
	float[] query_vector = DenseVectors.mean(
			question.memo(Phrase.simpleTokens)
			.stream().map(DenseVectors::vectorFor)
			.filter(v -> v.isPresent())
			.map(v -> v.get())
			.collect(Collectors.toList()));
	
	// Now look for (almost) that vector!
	// This is a little ugly because we desperately avoid copying.
	byte[][] winners = new byte[LEN][];
	double[] sims = new double[LEN];
	/*try (Transaction tx = wiki_vectors_env.createReadTransaction();
			Database doc_vectors = wiki_vectors_env.openDatabase(tx, "wiki-vectors", 0);
			BufferCursor cursor = doc_vectors.bufferCursor(tx)) {
		cursor.first();
		while (cursor.next()) {
			double this_sim = sim(query_vector, cursor);
			bubble(sims, winners, this_sim, cursor);
		}
	}*/
	try (Transaction tx = wiki_vectors_env.createReadTransaction();
			Database doc_vectors = wiki_vectors_env.openDatabase(tx, "wiki-vectors", 0)) {
		for (Entry e : doc_vectors.iterate(tx).iterable()) {
			double this_sim = DenseVectors.sim(query_vector, KV.asVector(e.getValue()));
			if (Double.isFinite(this_sim))
				bubble(sims, winners, this_sim, e.getKey(), K);
		}
			
	}
	
	// Now get the passages for the top entries.
	List<Passage> passages = new ArrayList<>();
	for (int i=0; i<K; i++) {
		if (winners[i] != null) {
			String id = string(winners[i]);
			passages.add(new Passage("meandv", "", "", id));
			System.out.println("value is : " + id + " sim: " + sims[i]);
		}
	}
	
	/*try{
		Process p = Runtime.getRuntime().exec("python /home/sean/yeshvant/top100vectorSimilarDocs.py " + query );
		BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
		String line = "";
		while((line = in.readLine())!= null)
		{
			String[] sim_id = line.split(" "); 
			passages.add(new Passage("meandv", "", "", sim_id[1]));
			System.out.println("value is : "+sim_id[1]);
		}
	} catch(Exception e) {
		e.printStackTrace();
	}*/
	return fillFromSources(passages);
}
 
开发者ID:SeanTater,项目名称:uncc2014watsonsim,代码行数:62,代码来源:MeanDVSearch.java

示例5: LMDBMapSet

import org.fusesource.lmdbjni.Database; //导入依赖的package包/类
public LMDBMapSet(Env env, Database db)
{
  this.db = db;
  this.env = env;
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:6,代码来源:LMDBMapSet.java

示例6: LMDBMap

import org.fusesource.lmdbjni.Database; //导入依赖的package包/类
public LMDBMap(Env env, Database db)
{
  this.env = env;
  this.db = db;
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:6,代码来源:LMDBMap.java


注:本文中的org.fusesource.lmdbjni.Database类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。