当前位置: 首页>>代码示例>>Java>>正文


Java KeySliceQuery类代码示例

本文整理汇总了Java中com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery的典型用法代码示例。如果您正苦于以下问题:Java KeySliceQuery类的具体用法?Java KeySliceQuery怎么用?Java KeySliceQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KeySliceQuery类属于com.thinkaurelius.titan.diskstorage.keycolumnvalue包,在下文中一共展示了KeySliceQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMutateWithLockUsesConsistentTx

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
@Test
public void testMutateWithLockUsesConsistentTx() throws BackendException {
    final ImmutableList<Entry> adds = ImmutableList.of(StaticArrayEntry.of(DATA_COL, DATA_VAL));
    final ImmutableList<StaticBuffer> dels = ImmutableList.<StaticBuffer>of();
    final KeyColumn kc = new KeyColumn(LOCK_KEY, LOCK_COL);

    // 1. Acquire a lock
    backingLocker.writeLock(kc, consistentTx);

    // 2. Run a mutation
    // N.B. mutation coordinates do not overlap with the lock, but consistentTx should be used anyway
    // 2.1. Check locks & expected values before mutating data
    backingLocker.checkLocks(consistentTx);
    StaticBuffer nextBuf = BufferUtil.nextBiggerBuffer(kc.getColumn());
    KeySliceQuery expectedValueQuery = new KeySliceQuery(kc.getKey(), kc.getColumn(), nextBuf);
    expect(backingStore.getSlice(expectedValueQuery, consistentTx)) // expected value read must use strong consistency
        .andReturn(StaticArrayEntryList.of(StaticArrayEntry.of(LOCK_COL, LOCK_VAL)));
    // 2.2. Mutate data
    backingStore.mutate(DATA_KEY, adds, dels, consistentTx); // writes by txs with locks must use strong consistency

    ctrl.replay();
    // 1. Lock acquisition
    expectStore.acquireLock(LOCK_KEY, LOCK_COL, LOCK_VAL, expectTx);
    // 2. Mutate
    expectStore.mutate(DATA_KEY, adds, dels, expectTx);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:27,代码来源:ExpectedValueCheckingTest.java

示例2: getCurrentID

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
private long getCurrentID(final StaticBuffer partitionKey) throws BackendException {
    List<Entry> blocks = BackendOperation.execute(new BackendOperation.Transactional<List<Entry>>() {
        @Override
        public List<Entry> call(StoreTransaction txh) throws BackendException {
            return idStore.getSlice(new KeySliceQuery(partitionKey, LOWER_SLICE, UPPER_SLICE).setLimit(5), txh);
        }
    },this,times);

    if (blocks == null) throw new TemporaryBackendException("Could not read from storage");
    long latest = BASE_ID;

    for (Entry e : blocks) {
        long counterVal = getBlockValue(e);
        if (latest < counterVal) {
            latest = counterVal;
        }
    }
    return latest;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:20,代码来源:ConsistentKeyIDAuthority.java

示例3: runWithExceptions

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
private void runWithExceptions() throws BackendException {
    StaticBuffer lockKey = serializer.toLockKey(target.getKey(), target.getColumn());
    List<Entry> locks = store.getSlice(new KeySliceQuery(lockKey, LOCK_COL_START, LOCK_COL_END), tx); // TODO reduce LOCK_COL_END based on cutoff

    ImmutableList.Builder<StaticBuffer> b = ImmutableList.builder();

    for (Entry lc : locks) {
        TimestampRid tr = serializer.fromLockColumn(lc.getColumn(), times);
        if (tr.getTimestamp().isBefore(cutoff)) {
            log.info("Deleting expired lock on {} by rid {} with timestamp {} (before or at cutoff {})",
                    new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff });
            b.add(lc.getColumn());
        } else {
            log.debug("Ignoring lock on {} by rid {} with timestamp {} (timestamp is after cutoff {})",
                    new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff });
        }
    }

    List<StaticBuffer> dels = b.build();

    if (!dels.isEmpty()) {
        store.mutate(lockKey, ImmutableList.<Entry>of(), dels, tx);
        log.info("Deleted {} expired locks (before or at cutoff {})", dels.size(), cutoff);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:26,代码来源:StandardLockCleanerRunnable.java

示例4: runWithExceptions

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
private void runWithExceptions() throws BackendException {
    StaticBuffer lockKey = serializer.toLockKey(target.getKey(), target.getColumn());
    List<Entry> locks = store.getSlice(new KeySliceQuery(lockKey, LOCK_COL_START, LOCK_COL_END), tx); // TODO reduce LOCK_COL_END based on cutoff

    ImmutableList.Builder<StaticBuffer> b = ImmutableList.builder();

    for (Entry lc : locks) {
        TimestampRid tr = serializer.fromLockColumn(lc.getColumn());
        if (tr.getTimestamp() < cutoff) {
            log.info("Deleting expired lock on {} by rid {} with timestamp {} (before or at cutoff {})",
                    new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff });
            b.add(lc.getColumn());
        } else {
            log.debug("Ignoring lock on {} by rid {} with timestamp {} (timestamp is after cutoff {})",
                    new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff });
        }
    }

    List<StaticBuffer> dels = b.build();

    if (!dels.isEmpty()) {
        store.mutate(lockKey, ImmutableList.<Entry>of(), dels, tx);
        log.info("Deleted {} expired locks (before or at cutoff {})", dels.size(), cutoff);
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:26,代码来源:StandardLockCleanerRunnable.java

示例5: testMutateManyWithLockUsesConsistentTx

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
@Test
public void testMutateManyWithLockUsesConsistentTx() throws BackendException {
    final ImmutableList<Entry> adds = ImmutableList.of(StaticArrayEntry.of(DATA_COL, DATA_VAL));
    final ImmutableList<StaticBuffer> dels = ImmutableList.<StaticBuffer>of();

    Map<String, Map<StaticBuffer, KCVMutation>> mutations =
            ImmutableMap.<String, Map<StaticBuffer, KCVMutation>>of(STORE_NAME,
                    ImmutableMap.<StaticBuffer, KCVMutation>of(DATA_KEY, new KCVMutation(adds, dels)));
    final KeyColumn kc = new KeyColumn(LOCK_KEY, LOCK_COL);

    // Acquire a lock
    backingLocker.writeLock(kc, consistentTx);

    // 2. Run mutateMany
    // 2.1. Check locks & expected values before mutating data
    backingLocker.checkLocks(consistentTx);
    StaticBuffer nextBuf = BufferUtil.nextBiggerBuffer(kc.getColumn());
    KeySliceQuery expectedValueQuery = new KeySliceQuery(kc.getKey(), kc.getColumn(), nextBuf);
    expect(backingStore.getSlice(expectedValueQuery, consistentTx)) // expected value read must use strong consistency
        .andReturn(StaticArrayEntryList.of(StaticArrayEntry.of(LOCK_COL, LOCK_VAL)));
    // 2.2. Run mutateMany on backing manager to modify data
    backingManager.mutateMany(mutations, consistentTx); // writes by txs with locks must use strong consistency

    ctrl.replay();
    // Lock acquisition
    expectStore.acquireLock(LOCK_KEY, LOCK_COL, LOCK_VAL, expectTx);
    // Mutate
    expectManager.mutateMany(mutations, expectTx);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:30,代码来源:ExpectedValueCheckingTest.java

示例6: verifyResults

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
private void verifyResults(StaticBuffer key, List<StaticBuffer> keys, SliceQuery query, int expectedResults) throws Exception {
    CacheTransaction tx = getCacheTx();
    assertEquals(expectedResults,cache.getSlice(new KeySliceQuery(key,query),tx).size());
    Map<StaticBuffer,EntryList> results = cache.getSlice(keys,query,tx);
    assertEquals(keys.size(),results.size());
    assertEquals(expectedResults, results.get(key).size());
    tx.commit();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:9,代码来源:ExpirationCacheTest.java

示例7: edgeStoreQuery

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
public EntryList edgeStoreQuery(final KeySliceQuery query) {
    return executeRead(new Callable<EntryList>() {
        @Override
        public EntryList call() throws Exception {
            return cacheEnabled?edgeStore.getSlice(query, storeTx):
                                edgeStore.getSliceNoCache(query,storeTx);
        }

        @Override
        public String toString() {
            return "EdgeStoreQuery";
        }
    });
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:15,代码来源:BackendTransaction.java

示例8: SliceQueryRunner

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
private SliceQueryRunner(KeySliceQuery kq, CountDownLatch doneSignal, AtomicInteger failureCount,
                         Object[] resultArray, int resultPosition) {
    this.kq = kq;
    this.doneSignal = doneSignal;
    this.failureCount = failureCount;
    this.resultArray = resultArray;
    this.resultPosition = resultPosition;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:9,代码来源:BackendTransaction.java

示例9: indexQuery

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
public EntryList indexQuery(final KeySliceQuery query) {
    return executeRead(new Callable<EntryList>() {
        @Override
        public EntryList call() throws Exception {
            return cacheEnabled?indexStore.getSlice(query, storeTx):
                                indexStore.getSliceNoCache(query, storeTx);
        }

        @Override
        public String toString() {
            return "VertexIndexQuery";
        }
    });

}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:16,代码来源:BackendTransaction.java

示例10: execute

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
public List<EntryList> execute(final BackendTransaction tx) {
    int total = 0;
    List<EntryList> result = new ArrayList<EntryList>(4);
    for (KeySliceQuery ksq : queries) {
        EntryList next =tx.indexQuery(ksq.updateLimit(getLimit()-total));
        result.add(next);
        total+=next.size();
        if (total>=getLimit()) break;
    }
    return result;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:12,代码来源:MultiKeySliceQuery.java

示例11: getQuery

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
public MultiKeySliceQuery getQuery(final CompositeIndexType index, List<Object[]> values) {
    List<KeySliceQuery> ksqs = new ArrayList<KeySliceQuery>(values.size());
    for (Object[] value : values) {
        ksqs.add(new KeySliceQuery(getIndexKey(index,value), BufferUtil.zeroBuffer(1), BufferUtil.oneBuffer(1)));
    }
    return new MultiKeySliceQuery(ksqs);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:8,代码来源:IndexSerializer.java

示例12: testGracePeriod

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
private void testGracePeriod(Duration graceWait) throws Exception {
    final int minCleanupTriggerCalls = 5;
    final int numKeys = 100, numCols = 10;
    loadStore(numKeys,numCols);
    //Replace cache with proper times
    cache = getCache(store,Duration.ofDays(200),graceWait);

    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);
    //If we modify through cache store...
    CacheTransaction tx = getCacheTx();
    cache.mutateEntries(key,KeyColumnValueStore.NO_ADDITIONS, Lists.newArrayList(getEntry(4,4)),tx);
    tx.commit();
    Instant utime = times.getTime();
    store.resetCounter();
    //...invalidation should happen and the result set is updated immediately
    verifyResults(key, keys, query, 5);
    assertEquals(2,store.getSliceCalls());
    //however, the key is expired and hence repeated calls need to go through to the store
    verifyResults(key, keys, query, 5);
    assertEquals(4,store.getSliceCalls());

    //however, when we sleep past the grace wait time and trigger a cleanup...
    times.sleepPast(utime.plus(graceWait));
    for (int t=0; t<minCleanupTriggerCalls;t++) {
        assertEquals(5,cache.getSlice(new KeySliceQuery(key,query),tx).size());
        times.sleepFor(Duration.ofMillis(5));
    }
    //...the cache should cache results again
    store.resetCounter();
    verifyResults(key, keys, query, 5);
    assertEquals(0,store.getSliceCalls());
    verifyResults(key, keys, query, 5);
    assertEquals(0,store.getSliceCalls());
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:42,代码来源:ExpirationCacheTest.java

示例13: recordLockGetSlice

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
private void recordLockGetSlice(EntryList returnedEntries) throws BackendException {
    final KeySliceQuery ksq = new KeySliceQuery(defaultLockKey, LOCK_COL_START, LOCK_COL_END);
    expect(store.getSlice(eq(ksq), eq(defaultTx))).andReturn(returnedEntries);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:ConsistentKeyLockerTest.java

示例14: recordExceptionalLockGetSlice

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
private void recordExceptionalLockGetSlice(Throwable t) throws BackendException {
    final KeySliceQuery ksq = new KeySliceQuery(defaultLockKey, LOCK_COL_START, LOCK_COL_END);
    expect(store.getSlice(eq(ksq), eq(defaultTx))).andThrow(t);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:ConsistentKeyLockerTest.java

示例15: MultiKeySliceQuery

import com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery; //导入依赖的package包/类
public MultiKeySliceQuery(List<KeySliceQuery> queries) {
    Preconditions.checkArgument(queries!=null && !queries.isEmpty());
    this.queries = queries;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:MultiKeySliceQuery.java


注:本文中的com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。