public WiktionaryIterator<IWiktionaryPage> getAllPages( final IWiktionaryPageFilter filter, boolean sortByTitle, boolean normalize) { ensureOpen(); try { EntityCursor<WiktionaryPage> cursor; if (sortByTitle) cursor = (normalize ? pageByNormalizedTitle.entities() : pageByTitle.entities()); else cursor = pageById.entities(); return new BerkeleyDBWiktionaryIterator<IWiktionaryPage, WiktionaryPage>( this, cursor){ @Override protected IWiktionaryPage loadEntity(final WiktionaryPage entity) { return loadPage(entity, filter); } }; } catch (DatabaseException e) { throw new WiktionaryException(e); } }
long entryId = 0; entryById = null; EntityCursor<WiktionaryPage> pageCursor = pageByTitle.entities(); while (pageCursor.next() != null) { WiktionaryPage page = pageCursor.current(); pageCursor.close(); commit(); pageCursor = pageByTitle.entities(lastKey, false, null, false); System.err.println("Indexed " + pageId + " pages");
long entryId = 0; entryById = null; EntityCursor<WiktionaryPage> pageCursor = pageByTitle.entities(); while (pageCursor.next() != null) { WiktionaryPage page = pageCursor.current(); pageCursor.close(); commit(); pageCursor = pageByTitle.entities(lastKey, false, null, false); System.err.println("Indexed " + pageId + " pages");
public Set getKeySet() { Set res = new HashSet(); Transaction txn = null; EntityCursor<Ref> cursor = null; try { txn = dbe.beginTransaction (null, null); cursor = sIndex.entities(txn, null); for (Ref ref : cursor) res.add(ref.getKey()); cursor.close(); cursor = null; txn.commit(); txn = null; } catch (IllegalStateException ex) { warn (ex); } finally { if (cursor != null) cursor.close (); if (txn != null) txn.abort(); } return res; }
public WiktionaryIterator<IWiktionaryPage> getAllPages( final IWiktionaryPageFilter filter, boolean sortByTitle, boolean normalize) { ensureOpen(); try { EntityCursor<WiktionaryPage> cursor; if (sortByTitle) cursor = (normalize ? pageByNormalizedTitle.entities() : pageByTitle.entities()); else cursor = pageById.entities(); return new BerkeleyDBWiktionaryIterator<IWiktionaryPage, WiktionaryPage>( this, cursor){ @Override protected IWiktionaryPage loadEntity(final WiktionaryPage entity) { return loadPage(entity, filter); } }; } catch (DatabaseException e) { throw new WiktionaryException(e); } }
return; txn = dbe.beginTransaction (null, null); cursor = gcsIndex.entities ( txn, 0L, true, System.currentTimeMillis(), false, null );
try { txn = dbe.beginTransaction (null, null); cursor = sIndex.entities(txn, null); String key = null; int keyCount = 0;
public List<IWiktionaryPage> getPagesForWord(final String word, final IWiktionaryPageFilter filter, boolean normalize) { ensureOpen(); if (word == null) return null; try { List<IWiktionaryPage> result = new ArrayList<>(); if (normalize) { String t = WiktionaryPage.normalizeTitle(word); EntityCursor<WiktionaryPage> cursor = pageByNormalizedTitle .entities(null, t, true, t, true, CursorConfig.DEFAULT); while (cursor.next() != null) { IWiktionaryPage page = loadPage(cursor.current(), filter); if (page != null) result.add(page); } cursor.close(); } else { IWiktionaryPage page = loadPage(pageByTitle.get(word), filter); if (page != null) result.add(page); // can be only one result! } return result; } catch (DatabaseException e) { throw new WiktionaryException(e); } }
public List<IWiktionaryPage> getPagesForWord(final String word, final IWiktionaryPageFilter filter, boolean normalize) { ensureOpen(); if (word == null) return null; try { List<IWiktionaryPage> result = new ArrayList<IWiktionaryPage>(); if (normalize) { String t = WiktionaryPage.normalizeTitle(word); EntityCursor<WiktionaryPage> cursor = pageByNormalizedTitle .entities(null, t, true, t, true, CursorConfig.DEFAULT); while (cursor.next() != null) { IWiktionaryPage page = loadPage(cursor.current(), filter); if (page != null) result.add(page); } cursor.close(); } else { IWiktionaryPage page = loadPage(pageByTitle.get(word), filter); if (page != null) result.add(page); // can be only one result! } return result; } catch (DatabaseException e) { throw new WiktionaryException(e); } }
public void call(Transaction transaction) { EntityCursor<TileSet> tileSets = tileSetsByLayer.entities(transaction, layerName, true, layerName, true, null); TileSet tileSet; Quota freed; Quota global; try { while (null != (tileSet = tileSets.next())) { if (shouldDelete.test(tileSet)) { freed = usedQuotaByTileSetId.get( transaction, tileSet.getId(), LockMode.DEFAULT); global = usedQuotaByTileSetId.get( transaction, GLOBAL_QUOTA_NAME, LockMode.DEFAULT); tileSets.delete(); global.subtract(freed.getBytes()); usedQuotaById.put(transaction, global); } } } finally { tileSets.close(); } } }
public Quota call() throws Exception { Quota aggregated = null; EntityCursor<TileSet> layerTileSetsIds; layerTileSetsIds = tileSetsByLayer.entities( null, layerName, true, layerName, true, CursorConfig.DEFAULT); TileSet tileSet; try { Quota tileSetUsedQuota; while (null != (tileSet = layerTileSetsIds.next())) { if (aggregated == null) { aggregated = new Quota(); } tileSetUsedQuota = new UsedQuotaByTileSetId(tileSet.getId()).call(); aggregated.add(tileSetUsedQuota); } } finally { layerTileSetsIds.close(); } if (aggregated == null) { aggregated = new Quota(); } return aggregated; } }