本文整理汇总了Java中com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer.of方法的典型用法代码示例。如果您正苦于以下问题:Java StaticArrayBuffer.of方法的具体用法?Java StaticArrayBuffer.of怎么用?Java StaticArrayBuffer.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer
的用法示例。
在下文中一共展示了StaticArrayBuffer.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: next
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Override
public StaticBuffer next() {
ensureOpen();
if (!hasNext())
throw new NoSuchElementException();
currentRow = keys.next();
ByteBuffer currentKey = currentRow.key.getKey().duplicate();
try {
return StaticArrayBuffer.of(currentKey);
} finally {
lastSeenKey = currentKey;
}
}
示例2: next
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Override
public StaticBuffer next() {
ensureOpen();
if (!hasNext())
throw new NoSuchElementException();
currentRow = keys.next();
ByteBuffer currentKey = currentRow.key.key.duplicate();
try {
return StaticArrayBuffer.of(currentKey);
} finally {
lastSeenKey = currentKey;
}
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:17,代码来源:CassandraEmbeddedKeyColumnValueStore.java
示例3: stringToByteBuffer
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
public static StaticBuffer stringToByteBuffer(String s) {
byte[] b;
try {
b = s.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
ByteBuffer bb = ByteBuffer.allocate(b.length);
bb.put(b);
bb.flip();
return StaticArrayBuffer.of(bb);
}
示例4: completeNextKV
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
private KV completeNextKV() throws IOException {
KV completedKV = null;
boolean hasNext;
do {
hasNext = reader.nextKeyValue();
if (!hasNext) {
completedKV = incompleteKV;
incompleteKV = null;
} else {
StaticArrayBuffer key = StaticArrayBuffer.of(reader.getCurrentKey());
SortedMap<ByteBuffer, Cell> valueSortedMap = reader.getCurrentValue();
List<Entry> entries = new ArrayList<>(valueSortedMap.size());
for (Map.Entry<ByteBuffer, Cell> ent : valueSortedMap.entrySet()) {
ByteBuffer col = ent.getKey();
ByteBuffer val = ent.getValue().value();
entries.add(StaticArrayEntry.of(StaticArrayBuffer.of(col), StaticArrayBuffer.of(val)));
}
if (null == incompleteKV) {
// Initialization; this should happen just once in an instance's lifetime
incompleteKV = new KV(key);
} else if (!incompleteKV.key.equals(key)) {
// The underlying Cassandra reader has just changed to a key we haven't seen yet
// This implies that there will be no more entries for the prior key
completedKV = incompleteKV;
incompleteKV = new KV(key);
}
incompleteKV.addEntries(entries);
}
/* Loop ends when either
* A) the cassandra reader ran out of data
* or
* B) the cassandra reader switched keys, thereby completing a KV */
} while (hasNext && null == completedKV);
return completedKV;
}
示例5: next
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Override
public StaticBuffer next() {
ensureOpen();
currentRow = rows.next();
return StaticArrayBuffer.of(currentRow.getRow());
}
示例6: next
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Override
public StaticBuffer next() {
ensureOpen();
currentRow = rows.next();
return StaticArrayBuffer.of(currentRow.getKey());
}
示例7: testFuzzMessages
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Test
public void testFuzzMessages() throws Exception {
final int maxLen = 1024 * 4;
final int rounds = 32;
StoringReader reader = new StoringReader(rounds);
List<StaticBuffer> expected = new ArrayList<StaticBuffer>(rounds);
Log l = manager.openLog("fuzz");
l.registerReader(ReadMarker.fromNow(),reader);
Random rand = new Random();
for (int i = 0; i < rounds; i++) {
//int len = rand.nextInt(maxLen + 1);
int len = maxLen;
if (0 == len)
len = 1; // 0 would throw IllegalArgumentException
byte[] raw = new byte[len];
rand.nextBytes(raw);
StaticBuffer sb = StaticArrayBuffer.of(raw);
l.add(sb);
expected.add(sb);
Thread.sleep(50L);
}
reader.await(TIMEOUT_MS);
assertEquals(rounds, reader.msgCount);
assertEquals(expected, reader.msgs);
}
示例8: nextKeyValue
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
// Consume columns on one row until end of iterator or a new key appears
while (reader.nextKeyValue()) {
StaticBuffer key = StaticArrayBuffer.of(reader.getCurrentKey().duplicate()); // TODO check and remove duplication
Iterable<Entry> columns = new TitanCassandraHadoopGraph.CassandraMapIterable(reader.getCurrentValue());
if (null == vb) {
// Initialization on first iteration
vb = graph.newVertexBuilder(configuration, key);
Preconditions.checkArgument(vb.getKey().equals(key));
} else if (!vb.getKey().equals(key)) {
// Handle new row key
vertex = vb.build();
vertexQuery.filterRelationsOf(vertex);
vb = graph.newVertexBuilder(configuration, key);
// Vertex can be null if the system property representing lifecycle state (deletion) is set
if (null != vertex)
return true;
// Continue iterating if it was null
}
// Add (column, value) pairs from current row
vb.addEntries(columns);
}
// Iterator exhausted: check whether an unfinished vertex is ready for construction
if (null != vb) {
vertex = vb.build();
vertexQuery.filterRelationsOf(vertex);
vb = null;
// Vertex can be null if the system property representing lifecycle state (deletion) is set
return null != vertex;
}
return false;
}
示例9: workerIterationStart
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Override
public void workerIterationStart(Configuration config, Configuration graphConfig, ScanMetrics metrics) {
assertNotNull(config);
metrics.incrementCustom(SETUP_COUNT);
if (config.has(HEX_QUERIES)) {
String queryStrings[] = config.get(HEX_QUERIES).split(":");
List<SliceQuery> queries = new LinkedList<>();
for (String qString : queryStrings) {
String queryTokens[] = qString.split("/");
StaticBuffer start = StaticArrayBuffer.of(Hex.hexToBytes(queryTokens[0]));
StaticBuffer end = StaticArrayBuffer.of(Hex.hexToBytes(queryTokens[1]));
SliceQuery query = new SliceQuery(start, end);
int limit = Integer.valueOf(queryTokens[2]);
if (0 <= limit) {
query.setLimit(limit);
}
queries.add(query);
}
qs = queries;
}
if (config.has(KEY_FILTER_ID_MODULUS)) {
final long mod = config.get(KEY_FILTER_ID_MODULUS);
final long modVal;
if (config.has(KEY_FILTER_ID_MODULAR_VALUE)) {
modVal = config.get(KEY_FILTER_ID_MODULAR_VALUE);
} else {
modVal = 0;
}
keyFilter = k -> KeyValueStoreUtil.getID(k) % mod == modVal;
}
}
示例10: loadValues
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
public static void loadValues(KeyColumnValueStore store, StoreTransaction tx, String[][] values, int shiftEveryNthRow,
int shiftSliceLength) throws BackendException {
for (int i = 0; i < values.length; i++) {
List<Entry> entries = new ArrayList<Entry>();
for (int j = 0; j < values[i].length; j++) {
StaticBuffer col;
if (0 < shiftEveryNthRow && 0 == i/* +1 */ % shiftEveryNthRow) {
ByteBuffer bb = ByteBuffer.allocate(shiftSliceLength + 9);
for (int s = 0; s < shiftSliceLength; s++) {
bb.put((byte) -1);
}
bb.put(KeyValueStoreUtil.getBuffer(j + 1).asByteBuffer());
bb.flip();
col = StaticArrayBuffer.of(bb);
// col = KeyValueStoreUtil.getBuffer(j + values[i].length +
// 100);
} else {
col = KeyValueStoreUtil.getBuffer(j);
}
entries.add(StaticArrayEntry.of(col, KeyValueStoreUtil
.getBuffer(values[i][j])));
}
if (!entries.isEmpty()) {
store.mutate(KeyValueStoreUtil.getBuffer(i), entries,
KeyColumnValueStore.NO_DELETIONS, tx);
}
}
}
示例11: getValue
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Override
public StaticBuffer getValue(Map.Entry<Integer, Long> element) {
ByteBuffer b = ByteBuffer.allocate(8);
b.putLong(element.getValue());
return StaticArrayBuffer.of(b.array());
}
示例12: string2StaticBuffer
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
private StaticBuffer string2StaticBuffer(final String s) {
ByteBuffer out = ByteBuffer.wrap(s.getBytes(Charset.forName("UTF-8")));
return StaticArrayBuffer.of(out);
}
示例13: getColumn
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Override
public StaticBuffer getColumn(Map.Entry<Integer, Long> element) {
ByteBuffer b = ByteBuffer.allocate(4);
b.putInt(element.getKey());
return StaticArrayBuffer.of(b.array());
}
示例14: getCurrentKey
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
@Override
public StaticBuffer getCurrentKey() throws IOException, InterruptedException {
return StaticArrayBuffer.of(reader.getCurrentKey().copyBytes());
}
示例15: readHadoopVertex
import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入方法依赖的package包/类
public FaunusVertex readHadoopVertex(final Configuration configuration, final ByteBuffer key, final SortedMap<ByteBuffer, Column> value) {
return super.readHadoopVertex(configuration, StaticArrayBuffer.of(key), new CassandraMapIterable(value));
}