use of com.persistit.Exchange in project sonarqube by SonarSource.
the class Storage method keySet.
/**
* Returns the set of keys associated with this cache.
*
* @return The set containing the keys for this cache.
*/
public Set<Object> keySet() {
try {
Set<Object> keys = Sets.newLinkedHashSet();
exchange.clear();
Exchange iteratorExchange = new Exchange(exchange);
iteratorExchange.append(Key.BEFORE);
while (iteratorExchange.next(false)) {
keys.add(iteratorExchange.getKey().indexTo(-1).decode());
}
return keys;
} catch (Exception e) {
throw new IllegalStateException("Fail to get keys from cache " + name, e);
}
}
use of com.persistit.Exchange in project sonarqube by SonarSource.
the class Storages method createCache.
public <V> Storage<V> createCache(String cacheName) {
Preconditions.checkState(volume != null && volume.isOpened(), "Caches are not initialized");
Preconditions.checkState(!cacheMap.containsKey(cacheName), "Cache is already created: %s", cacheName);
try {
Exchange exchange = persistit.getExchange(volume, cacheName, true);
exchange.setMaximumValueSize(Value.MAXIMUM_SIZE);
Storage<V> cache = new Storage<>(cacheName, exchange);
cacheMap.put(cacheName, exchange);
return cache;
} catch (Exception e) {
throw new IllegalStateException("Fail to create cache: " + cacheName, e);
}
}
use of com.persistit.Exchange in project xodus by JetBrains.
the class JMHPersistItTokyoCabinetWriteBenchmark method randomWrite.
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = WARMUP_ITERATIONS)
@Measurement(iterations = MEASUREMENT_ITERATIONS)
@Fork(FORKS)
public void randomWrite() throws PersistitException {
final Exchange exchange = createTestStore();
for (final ByteIterable key : randomKeys) {
exchange.clear();
for (int i = 0; i < key.getLength(); i++) {
exchange.append(key.getBytesUnsafe()[i]);
}
exchange.getValue().put(key.getBytesUnsafe());
exchange.store();
}
persistit.flush();
}
use of com.persistit.Exchange in project titan by thinkaurelius.
the class PersistitTransaction method getExchange.
public Exchange getExchange(String treeName, Boolean create) throws StorageException {
synchronized (this) {
Exchange exchange;
try {
assign();
exchange = db.getExchange(VOLUME_NAME, treeName, create);
return exchange;
} catch (PersistitException ex) {
throw new PermanentStorageException(ex);
}
}
}
use of com.persistit.Exchange in project sonarqube by SonarSource.
the class Storage method keySet.
/**
* Returns the set of cache keys associated with this group.
* TODO implement a lazy-loading equivalent with Iterator/Iterable
*
* @param group The group.
* @return The set of cache keys for this group.
*/
@SuppressWarnings("rawtypes")
public Set keySet(Object key) {
try {
Set<Object> keys = Sets.newLinkedHashSet();
exchange.clear();
Exchange iteratorExchange = new Exchange(exchange);
iteratorExchange.append(key);
iteratorExchange.append(Key.BEFORE);
while (iteratorExchange.next(false)) {
keys.add(iteratorExchange.getKey().indexTo(-1).decode());
}
return keys;
} catch (Exception e) {
throw new IllegalStateException("Fail to get keys from cache " + name, e);
}
}
Aggregations