本文整理了Java中com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery.setLimit()
方法的一些代码示例,展示了KeySliceQuery.setLimit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeySliceQuery.setLimit()
方法的具体详情如下:
包路径:com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery
类名称:KeySliceQuery
方法名:setLimit
暂无
代码示例来源:origin: thinkaurelius/titan
@Override
public KeySliceQuery updateLimit(int newLimit) {
return new KeySliceQuery(key,this).setLimit(newLimit);
}
代码示例来源:origin: thinkaurelius/titan
/**
* Retrieves the value for the specified column and key under the given transaction
* from the store if such exists, otherwise returns NULL
*
* @param store Store
* @param key Key
* @param column Column
* @param txh Transaction
* @return Value for key and column or NULL if such does not exist
*/
public static StaticBuffer get(KeyColumnValueStore store, StaticBuffer key, StaticBuffer column, StoreTransaction txh) throws BackendException {
KeySliceQuery query = new KeySliceQuery(key, column, BufferUtil.nextBiggerBuffer(column)).setLimit(2);
List<Entry> result = store.getSlice(query, txh);
if (result.size() > 1)
log.warn("GET query returned more than 1 result: store {} | key {} | column {}", new Object[]{store.getName(),
key, column});
if (result.isEmpty()) return null;
else return result.get(0).getValueAs(StaticBuffer.STATIC_FACTORY);
}
代码示例来源:origin: thinkaurelius/titan
public static boolean containsKey(KeyColumnValueStore store, StaticBuffer key, int maxColumnLength, StoreTransaction txh) throws BackendException {
StaticBuffer start = START, end = END;
if (maxColumnLength>32) {
end = BufferUtil.oneBuffer(maxColumnLength);
}
return !store.getSlice(new KeySliceQuery(key, START, END).setLimit(1),txh).isEmpty();
}
代码示例来源:origin: thinkaurelius/titan
StaticBuffer columnEnd = KeyColumnValueStoreUtil.longToByteBuffer(cols);
List<Entry> result =
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(cols), tx);
Assert.assertEquals(cols, result.size());
result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(cols + 10), tx);
Assert.assertEquals(cols, result.size());
Assert.assertEquals(entries, result);
result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(cols - 1), tx);
Assert.assertEquals(cols - 1, result.size());
entries.remove(entries.size() - 1);
Assert.assertEquals(entries, result);
result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(1), tx);
Assert.assertEquals(1, result.size());
List<Entry> firstEntrySingleton = Arrays.asList(entries.get(0));
代码示例来源:origin: thinkaurelius/titan
StaticBuffer columnEnd = KeyColumnValueStoreUtil.longToByteBuffer(ttls.length);
List<Entry> result =
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length, result.size());
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length - 1, result.size());
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length - 1, result.size());
tx.rollback();
result =
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length - 2, result.size());
tx.rollback();
result =
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length - 2, result.size());
代码示例来源:origin: thinkaurelius/titan
query.setLimit(maxReadMsg);
log.trace("Converted MessagePuller time window to {}", query);
代码示例来源:origin: thinkaurelius/titan
public void checkSlice(String[][] values, Set<KeyColumn> removed, int key,
int start, int end, int limit) throws BackendException {
tx.rollback();
tx = startTx();
List<Entry> entries;
if (limit <= 0)
entries = store.getSlice(new KeySliceQuery(KeyValueStoreUtil.getBuffer(key), KeyValueStoreUtil.getBuffer(start), KeyValueStoreUtil.getBuffer(end)), tx);
else
entries = store.getSlice(new KeySliceQuery(KeyValueStoreUtil.getBuffer(key), KeyValueStoreUtil.getBuffer(start), KeyValueStoreUtil.getBuffer(end)).setLimit(limit), tx);
int pos = 0;
for (int i = start; i < end; i++) {
if (removed.contains(new KeyColumn(key, i))) {
log.debug("Skipping deleted ({},{})", key, i);
continue;
}
if (limit <= 0 || pos < limit) {
log.debug("Checking k={}[c_start={},c_end={}](limit={}): column index={}/pos={}", key, start, end, limit, i, pos);
Assert.assertTrue(entries.size() > pos);
Entry entry = entries.get(pos);
int col = KeyValueStoreUtil.getID(entry.getColumn());
String str = KeyValueStoreUtil.getString(entry.getValueAs(StaticBuffer.STATIC_FACTORY));
Assert.assertEquals(i, col);
Assert.assertEquals(values[key][i], str);
}
pos++;
}
Assert.assertNotNull(entries);
if (limit > 0 && pos > limit) Assert.assertEquals(limit, entries.size());
else Assert.assertEquals(pos, entries.size());
}
代码示例来源:origin: thinkaurelius/titan
assertEquals(10,cache.getSlice(getQuery(i,0,numCols+1).setLimit(10),tx).size());
assertEquals(3,cache.getSlice(getQuery(i,2,5),tx).size());
代码示例来源:origin: org.hawkular.titan/titan-core
@Override
public KeySliceQuery updateLimit(int newLimit) {
return new KeySliceQuery(key,this).setLimit(newLimit);
}
代码示例来源:origin: com.thinkaurelius.titan/titan-core
@Override
public KeySliceQuery updateLimit(int newLimit) {
return new KeySliceQuery(key,this).setLimit(newLimit);
}
代码示例来源:origin: org.hawkular.titan/titan-core
/**
* Retrieves the value for the specified column and key under the given transaction
* from the store if such exists, otherwise returns NULL
*
* @param store Store
* @param key Key
* @param column Column
* @param txh Transaction
* @return Value for key and column or NULL if such does not exist
*/
public static StaticBuffer get(KeyColumnValueStore store, StaticBuffer key, StaticBuffer column, StoreTransaction txh) throws BackendException {
KeySliceQuery query = new KeySliceQuery(key, column, BufferUtil.nextBiggerBuffer(column)).setLimit(2);
List<Entry> result = store.getSlice(query, txh);
if (result.size() > 1)
log.warn("GET query returned more than 1 result: store {} | key {} | column {}", new Object[]{store.getName(),
key, column});
if (result.isEmpty()) return null;
else return result.get(0).getValueAs(StaticBuffer.STATIC_FACTORY);
}
代码示例来源:origin: com.thinkaurelius.titan/titan-core
/**
* Retrieves the value for the specified column and key under the given transaction
* from the store if such exists, otherwise returns NULL
*
* @param store Store
* @param key Key
* @param column Column
* @param txh Transaction
* @return Value for key and column or NULL if such does not exist
*/
public static StaticBuffer get(KeyColumnValueStore store, StaticBuffer key, StaticBuffer column, StoreTransaction txh) throws BackendException {
KeySliceQuery query = new KeySliceQuery(key, column, BufferUtil.nextBiggerBuffer(column)).setLimit(2);
List<Entry> result = store.getSlice(query, txh);
if (result.size() > 1)
log.warn("GET query returned more than 1 result: store {} | key {} | column {}", new Object[]{store.getName(),
key, column});
if (result.isEmpty()) return null;
else return result.get(0).getValueAs(StaticBuffer.STATIC_FACTORY);
}
代码示例来源:origin: org.hawkular.titan/titan-core
public static boolean containsKey(KeyColumnValueStore store, StaticBuffer key, int maxColumnLength, StoreTransaction txh) throws BackendException {
StaticBuffer start = START, end = END;
if (maxColumnLength>32) {
end = BufferUtil.oneBuffer(maxColumnLength);
}
return !store.getSlice(new KeySliceQuery(key, START, END).setLimit(1),txh).isEmpty();
}
代码示例来源:origin: com.thinkaurelius.titan/titan-core
public static boolean containsKey(KeyColumnValueStore store, StaticBuffer key, int maxColumnLength, StoreTransaction txh) throws BackendException {
StaticBuffer start = START, end = END;
if (maxColumnLength>32) {
end = BufferUtil.oneBuffer(maxColumnLength);
}
return !store.getSlice(new KeySliceQuery(key, START, END).setLimit(1),txh).isEmpty();
}
代码示例来源:origin: org.hawkular.titan/titan-test
StaticBuffer columnEnd = KeyColumnValueStoreUtil.longToByteBuffer(cols);
List<Entry> result =
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(cols), tx);
Assert.assertEquals(cols, result.size());
result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(cols + 10), tx);
Assert.assertEquals(cols, result.size());
Assert.assertEquals(entries, result);
result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(cols - 1), tx);
Assert.assertEquals(cols - 1, result.size());
entries.remove(entries.size() - 1);
Assert.assertEquals(entries, result);
result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(1), tx);
Assert.assertEquals(1, result.size());
List<Entry> firstEntrySingleton = Arrays.asList(entries.get(0));
代码示例来源:origin: com.thinkaurelius.titan/titan-test-jre6
StaticBuffer columnEnd = KeyColumnValueStoreUtil.longToByteBuffer(cols);
List<Entry> result =
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(cols), tx);
Assert.assertEquals(cols, result.size());
result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(cols + 10), tx);
Assert.assertEquals(cols, result.size());
Assert.assertEquals(entries, result);
result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(cols - 1), tx);
Assert.assertEquals(cols - 1, result.size());
entries.remove(entries.size() - 1);
Assert.assertEquals(entries, result);
result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(1), tx);
Assert.assertEquals(1, result.size());
List<Entry> firstEntrySingleton = Arrays.asList(entries.get(0));
代码示例来源:origin: org.hawkular.titan/titan-test
StaticBuffer columnEnd = KeyColumnValueStoreUtil.longToByteBuffer(ttls.length);
List<Entry> result =
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length, result.size());
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length - 1, result.size());
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length - 1, result.size());
tx.rollback();
result =
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length - 2, result.size());
tx.rollback();
result =
store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
Assert.assertEquals(ttls.length - 2, result.size());
代码示例来源:origin: org.hawkular.titan/titan-test
public void checkSlice(String[][] values, Set<KeyColumn> removed, int key,
int start, int end, int limit) throws BackendException {
tx.rollback();
tx = startTx();
List<Entry> entries;
if (limit <= 0)
entries = store.getSlice(new KeySliceQuery(KeyValueStoreUtil.getBuffer(key), KeyValueStoreUtil.getBuffer(start), KeyValueStoreUtil.getBuffer(end)), tx);
else
entries = store.getSlice(new KeySliceQuery(KeyValueStoreUtil.getBuffer(key), KeyValueStoreUtil.getBuffer(start), KeyValueStoreUtil.getBuffer(end)).setLimit(limit), tx);
int pos = 0;
for (int i = start; i < end; i++) {
if (removed.contains(new KeyColumn(key, i))) {
log.debug("Skipping deleted ({},{})", key, i);
continue;
}
if (limit <= 0 || pos < limit) {
log.debug("Checking k={}[c_start={},c_end={}](limit={}): column index={}/pos={}", key, start, end, limit, i, pos);
Assert.assertTrue(entries.size() > pos);
Entry entry = entries.get(pos);
int col = KeyValueStoreUtil.getID(entry.getColumn());
String str = KeyValueStoreUtil.getString(entry.getValueAs(StaticBuffer.STATIC_FACTORY));
Assert.assertEquals(i, col);
Assert.assertEquals(values[key][i], str);
}
pos++;
}
Assert.assertNotNull(entries);
if (limit > 0 && pos > limit) Assert.assertEquals(limit, entries.size());
else Assert.assertEquals(pos, entries.size());
}
代码示例来源:origin: com.thinkaurelius.titan/titan-test-jre6
public void checkSlice(String[][] values, Set<KeyColumn> removed, int key,
int start, int end, int limit) throws StorageException {
List<Entry> entries;
if (limit <= 0)
entries = store.getSlice(new KeySliceQuery(KeyValueStoreUtil.getBuffer(key), KeyValueStoreUtil.getBuffer(start), KeyValueStoreUtil.getBuffer(end)), tx);
else
entries = store.getSlice(new KeySliceQuery(KeyValueStoreUtil.getBuffer(key), KeyValueStoreUtil.getBuffer(start), KeyValueStoreUtil.getBuffer(end)).setLimit(limit), tx);
int pos = 0;
for (int i = start; i < end; i++) {
if (removed.contains(new KeyColumn(key, i))) continue;
if (limit <= 0 || pos < limit) {
Assert.assertTrue(entries.size() > pos);
Entry entry = entries.get(pos);
int col = KeyValueStoreUtil.getID(entry.getColumn());
String str = KeyValueStoreUtil.getString(entry.getValue());
Assert.assertEquals(i, col);
Assert.assertEquals(values[key][i], str);
}
pos++;
}
Assert.assertNotNull(entries);
if (limit > 0 && pos > limit) Assert.assertEquals(limit, entries.size());
else Assert.assertEquals(pos, entries.size());
}
代码示例来源:origin: org.hawkular.titan/titan-core
query.setLimit(maxReadMsg);
log.trace("Converted MessagePuller time window to {}", query);
内容来源于网络,如有侵权,请联系作者删除!