com.sleepycat.persist.EntityStore Java Examples
The following examples show how to use
com.sleepycat.persist.EntityStore.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BerkeleyManager.java From jstarcraft-core with Apache License 2.0 | 6 votes |
/** * 构造方法 * * @param entityInfo * @param accessor */ public BerkeleyManager(BerkeleyMetadata metadata, EntityStore store) { this.metadata = metadata; this.store = store; // 通过获取主键索引准备Berkeley环境(有意义,别删除) primaryIndex = this.store.getPrimaryIndex(metadata.getPrimaryClass(), metadata.getStoreClass()); for (String name : metadata.getIndexNames()) { Field field = metadata.getSecondaryField(name); Class<?> clazz = ClassUtility.primitiveToWrapper(field.getType()); SecondaryIndex secondaryIndex; if (metadata.getOrmClass() == metadata.getStoreClass()) { secondaryIndex = store.getSecondaryIndex(primaryIndex, clazz, name); } else { secondaryIndex = store.getSubclassIndex(getPrimaryIndex(), metadata.getOrmClass(), clazz, name); } secondaryIndexes.put(name, secondaryIndex); } }
Example #2
Source File: WebGraph.java From codes-scratch-crawler with Apache License 2.0 | 6 votes |
/** * 构造函数 */ public WebGraph(String dbDir) throws DatabaseException { File envDir = new File(dbDir); EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setTransactional(false); envConfig.setAllowCreate(true); Environment env = new Environment(envDir, envConfig); StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(true); storeConfig.setTransactional(false); store = new EntityStore(env, "classDb", storeConfig); outLinkIndex = store.getPrimaryIndex(String.class, Link.class); inLinkIndex = store.getSecondaryIndex(outLinkIndex, String.class, "toURL"); }
Example #3
Source File: WiktionaryEditionTest.java From dkpro-jwktl with Apache License 2.0 | 5 votes |
/***/ public void testClose() { // Multiple close. wkt = new BerkeleyDBWiktionaryEdition(wktDE.getParsedData()); assertFalse(wkt.isClosed()); wkt.close(); assertTrue(wkt.isClosed()); wkt.close(); assertTrue(wkt.isClosed()); // Null. wkt = new BerkeleyDBWiktionaryEdition(wktDE.getParsedData()); EntityStore store = wkt.store; wkt.store = null; wkt.close(); assertTrue(wkt.isClosed()); store.close(); // Invoke after close. wkt = new BerkeleyDBWiktionaryEdition(wktEN.getParsedData()); assertFalse(wkt.isClosed()); assertTrue(wkt.getAllPages().hasNext()); wkt.close(); assertTrue(wkt.isClosed()); try { wkt.getAllPages().next(); fail("IllegalStateException expected"); } catch (IllegalStateException e) {} }
Example #4
Source File: AbstractSearchStructure.java From multimedia-indexing with Apache License 2.0 | 5 votes |
/** * This method creates and/or opens the BDB databases with the appropriate parameters. * * @throws Exception */ private void createOrOpenBDBDbs() throws Exception { // configuration for the mapping dbs DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setAllowCreate(true); // db will be created if it does not exist dbConfig.setReadOnly(readOnly); dbConfig.setTransactional(transactional); // create/open mapping dbs using config iidToIdDB = dbEnv.openDatabase(null, "idToName", dbConfig); // if countSizeOnLoad is true, the id-name mappings are counted and the loadCounter is initialized if (countSizeOnLoad) { System.out.println(new Date() + " counting index size started "); int idToNameMappings = (int) iidToIdDB.count(); loadCounter = Math.min(idToNameMappings, maxNumVectors); System.out.println(new Date() + " counting index size ended "); System.out.println("Index size: " + loadCounter); } idToIidDB = dbEnv.openDatabase(null, "nameToId", dbConfig); if (useGeolocation) {// create/open geolocation db using config iidToGeolocationDB = dbEnv.openDatabase(null, "idToGeolocation", dbConfig); } if (useMetaData) { StoreConfig storeConfig = new StoreConfig(); // configuration of the entity store storeConfig.setAllowCreate(true); // store will be created if it does not exist storeConfig.setReadOnly(readOnly); storeConfig.setTransactional(transactional); iidToMetadataDB = new EntityStore(dbEnv, "idToMetadata", storeConfig); // int nameToMetadataMappings = (int) nameToMetadataBDB.getPrimaryIndex(String.class, // MediaFeedData.class).count(); // counting the size of an EntityStore } }
Example #5
Source File: BerkeleyDBWiktionaryEdition.java From dkpro-jwktl with Apache License 2.0 | 4 votes |
protected void connect(boolean isReadOnly, boolean allowCreateNew, boolean overwriteExisting, final Long cacheSize) throws DatabaseException { // Configure DB environment. EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setAllowCreate(allowCreateNew); envConfig.setReadOnly(isReadOnly); envConfig.setTransactional(false); if (cacheSize != null) envConfig.setCacheSize(cacheSize); env = new Environment(dbPath, envConfig); // Configure store. StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(allowCreateNew); storeConfig.setTransactional(false); storeConfig.setReadOnly(isReadOnly); store = new EntityStore(env, DATABASE_NAME, storeConfig); // Load properties. properties = new Properties(); File propFile = new File(dbPath, PROPERTY_FILE_NAME); if (propFile.exists()) { try { try (Reader reader = new InputStreamReader(new FileInputStream(propFile), "UTF-8")) { properties.load(reader); } } catch (IOException e) { throw new DatabaseException("Unable to load property file", e){}; } String lang = properties.getProperty("wiktionary.language"); if (lang == null) lang = properties.getProperty("entry_language"); language = Language.get(lang); } // Load index. pageById = store.getPrimaryIndex(Long.class, WiktionaryPage.class); pageByTitle = store.getSecondaryIndex(pageById, String.class, "title"); pageByNormalizedTitle = store.getSecondaryIndex(pageById, String.class, "normalizedTitle"); entryByKey = store.getPrimaryIndex(String.class, WiktionaryEntryProxy.class); entryById = store.getSecondaryIndex(entryByKey, Long.class, "entryId"); senseByKey = store.getPrimaryIndex(String.class, WiktionarySenseProxy.class); openCursors = new HashSet<>(); }