public Quota call() throws Exception { Quota quota = usedQuotaByTileSetId.get(null, tileSetId, LockMode.READ_COMMITTED); if (quota == null) { quota = new Quota(); } return quota; } }
private void addToUsedQuota( final Transaction tx, final TileSet tileSet, final Quota quotaDiff) { Quota usedQuota = usedQuotaByTileSetId.get(tx, tileSet.getId(), LockMode.DEFAULT); Quota globalQuota = usedQuotaByTileSetId.get(tx, GLOBAL_QUOTA_NAME, LockMode.DEFAULT); usedQuota.add(quotaDiff); globalQuota.add(quotaDiff); usedQuotaById.putNoReturn(tx, usedQuota); usedQuotaById.putNoReturn(tx, globalQuota); } }
public E get(Transaction txn, SK key, LockMode lockMode) throws DatabaseException { /* <!-- begin JE only --> */ if (DbCompat.IS_JE) { EntityResult<E> result = get( txn, key, Get.SEARCH, DbInternal.getReadOptions(lockMode)); return result != null ? result.value() : null; } /* <!-- end JE only --> */ DatabaseEntry keyEntry = new DatabaseEntry(); DatabaseEntry pkeyEntry = new DatabaseEntry(); DatabaseEntry dataEntry = new DatabaseEntry(); keyBinding.objectToEntry(key, keyEntry); OperationStatus status = secDb.get(txn, keyEntry, pkeyEntry, dataEntry, lockMode); if (status == OperationStatus.SUCCESS) { return entityBinding.entryToObject(pkeyEntry, dataEntry); } else { return null; } }
public WiktionaryPage getPageForWord(final String word) { ensureOpen(); if (word == null) return null; try { /*if (normalize) return loadPage(pageByNormalizedTitle.get( WiktionaryPage.normalizeTitle(word)), null); else*/ return loadPage(pageByTitle.get(word), null); } catch (DatabaseException e) { throw new WiktionaryException(e); } }
public WiktionaryPage getPageForWord(final String word) { ensureOpen(); if (word == null) return null; try { /*if (normalize) return loadPage(pageByNormalizedTitle.get( WiktionaryPage.normalizeTitle(word)), null); else*/ return loadPage(pageByTitle.get(word), null); } catch (DatabaseException e) { throw new WiktionaryException(e); } }
public IWiktionaryEntry getEntryForId(long entryId) { ensureOpen(); WiktionaryEntryProxy entry = entryById.get(entryId); return getEntryForId(entry.getPageId(), entry.getEntryIndex()); }
public IWiktionaryEntry getEntryForId(long entryId) { ensureOpen(); WiktionaryEntryProxy entry = entryById.get(entryId); return getEntryForId(entry.getPageId(), entry.getEntryIndex()); }
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 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 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); } }
try { if (null == usedQuotaByTileSetId.get( transaction, GLOBAL_QUOTA_NAME, LockMode.DEFAULT)) { log.debug("First time run: creating global quota object");
public PageStats call() throws Exception { Transaction tx = entityStore.getEnvironment().beginTransaction(null, null); try { PageStats pageStats = pageStatsByPageId.get(tx, tilePage.getId(), null); if (pageStats != null) { pageStats.setFillFactor(0f); pageStatsById.putNoReturn(tx, pageStats); } tx.commit(); return pageStats; } catch (Exception e) { tx.abort(); throw e; } } }
usedQuotaByTileSetId.get(transaction, oldTileSetId, LockMode.DEFAULT); newQuota = usedQuotaByTileSetId.get(transaction, newTileSetId, LockMode.DEFAULT); newQuota.setBytes(oldQuota.getBytes()); usedQuotaById.putNoReturn(transaction, newQuota); oldPage.getZoomLevel()); pageById.put(transaction, newPage); PageStats pageStats = pageStatsByPageId.get(oldPageId); if (pageStats != null) { pageStats.setPageId(newPage.getId());