本文整理汇总了Java中com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction.commit方法的典型用法代码示例。如果您正苦于以下问题:Java StoreTransaction.commit方法的具体用法?Java StoreTransaction.commit怎么用?Java StoreTransaction.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction
的用法示例。
在下文中一共展示了StoreTransaction.commit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExpiration
import com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction; //导入方法依赖的package包/类
private void testExpiration(Duration expirationTime) throws Exception {
final int numKeys = 100, numCols = 10;
loadStore(numKeys,numCols);
//Replace cache with proper times
cache = getCache(store,expirationTime, Duration.ZERO);
StaticBuffer key = BufferUtil.getIntBuffer(81);
List<StaticBuffer> keys = new ArrayList<StaticBuffer>();
keys.add(key);
keys.add(BufferUtil.getIntBuffer(37));
keys.add(BufferUtil.getIntBuffer(2));
SliceQuery query = getQuery(2,8);
verifyResults(key,keys,query,6);
//Modify store directly
StoreTransaction txs = getStoreTx();
store.mutate(key,KeyColumnValueStore.NO_ADDITIONS, Lists.newArrayList(BufferUtil.getIntBuffer(5)),txs);
txs.commit();
Instant utime = times.getTime();
//Should still see cached results
verifyResults(key,keys,query,6);
times.sleepPast(utime.plus(expirationTime.dividedBy(2))); //Sleep half way through expiration time
verifyResults(key, keys, query, 6);
times.sleepPast(utime.plus(expirationTime)); //Sleep past expiration time...
times.sleepFor(Duration.ofMillis(5)); //...and just a little bit longer
//Now the results should be different
verifyResults(key, keys, query, 5);
//If we modify through cache store...
CacheTransaction tx = getCacheTx();
cache.mutateEntries(key, KeyColumnValueStore.NO_ADDITIONS, Lists.newArrayList(getEntry(4, 4)), tx);
tx.commit();
store.resetCounter();
//...invalidation should happen and the result set is updated immediately
verifyResults(key, keys, query, 4);
}
示例2: testSimpleScan
import com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction; //导入方法依赖的package包/类
@Test
public void testSimpleScan()
throws InterruptedException, ExecutionException, IOException, BackendException {
int keys = 1000;
int cols = 40;
String[][] values = KeyValueStoreUtil.generateData(keys, cols);
//Make it only half the number of columns for every 2nd key
for (int i = 0; i < values.length; i++) {
if (i%2==0) values[i]= Arrays.copyOf(values[i], cols / 2);
}
log.debug("Loading values: " + keys + "x" + cols);
KeyColumnValueStoreManager mgr = new CassandraThriftStoreManager(GraphDatabaseConfiguration.buildGraphConfiguration());
KeyColumnValueStore store = mgr.openDatabase("edgestore");
StoreTransaction tx = mgr.beginTransaction(StandardBaseTransactionConfig.of(TimestampProviders.MICRO));
KeyColumnValueStoreUtil.loadValues(store, tx, values);
tx.commit(); // noop on Cassandra, but harmless
SimpleScanJobRunner runner = (ScanJob job, Configuration jobConf, String rootNSName) -> {
try {
return new CassandraHadoopScanRunner(job).scanJobConf(jobConf).scanJobConfRoot(rootNSName)
.partitionerOverride("org.apache.cassandra.dht.Murmur3Partitioner").run();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
};
SimpleScanJob.runBasicTests(keys, cols, runner);
}
示例3: execute
import com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction; //导入方法依赖的package包/类
public static<R> R execute(Transactional<R> exe, TransactionalProvider provider, TimestampProvider times) throws BackendException {
StoreTransaction txh = null;
try {
txh = provider.openTx();
if (!txh.getConfiguration().hasCommitTime()) txh.getConfiguration().setCommitTime(times.getTime());
return exe.call(txh);
} catch (BackendException e) {
if (txh!=null) txh.rollback();
txh=null;
throw e;
} finally {
if (txh!=null) txh.commit();
}
}
示例4: testExpiration
import com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction; //导入方法依赖的package包/类
private void testExpiration(Duration expirationTime) throws Exception {
final int numKeys = 100, numCols = 10;
loadStore(numKeys,numCols);
//Replace cache with proper times
cache = getCache(store,expirationTime,ZeroDuration.INSTANCE);
StaticBuffer key = BufferUtil.getIntBuffer(81);
List<StaticBuffer> keys = new ArrayList<StaticBuffer>();
keys.add(key);
keys.add(BufferUtil.getIntBuffer(37));
keys.add(BufferUtil.getIntBuffer(2));
SliceQuery query = getQuery(2,8);
verifyResults(key,keys,query,6);
//Modify store directly
StoreTransaction txs = getStoreTx();
store.mutate(key,KeyColumnValueStore.NO_ADDITIONS, Lists.newArrayList(BufferUtil.getIntBuffer(5)),txs);
txs.commit();
Timepoint utime = times.getTime();
//Should still see cached results
verifyResults(key,keys,query,6);
times.sleepPast(utime.add(expirationTime.multiply(0.5))); //Sleep half way through expiration time
verifyResults(key, keys, query, 6);
times.sleepPast(utime.add(expirationTime)); //Sleep past expiration time...
times.sleepFor(new StandardDuration(5,TimeUnit.MILLISECONDS)); //...and just a little bit longer
//Now the results should be different
verifyResults(key, keys, query, 5);
//If we modify through cache store...
CacheTransaction tx = getCacheTx();
cache.mutateEntries(key, KeyColumnValueStore.NO_ADDITIONS, Lists.newArrayList(getEntry(4, 4)), tx);
tx.commit();
store.resetCounter();
//...invalidation should happen and the result set is updated immediately
verifyResults(key, keys, query, 4);
}