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


Java StaticArrayBuffer类代码示例

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


StaticArrayBuffer类属于com.thinkaurelius.titan.diskstorage.util包,在下文中一共展示了StaticArrayBuffer类的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;
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:17,代码来源:CassandraEmbeddedKeyColumnValueStore.java

示例2: RowIterator

import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入依赖的package包/类
public RowIterator(Closeable table, ResultScanner rows, byte[] columnFamilyBytes) {
    this.table = table;
    this.columnFamilyBytes = Arrays.copyOf(columnFamilyBytes, columnFamilyBytes.length);
    this.rows = Iterators.filter(rows.iterator(), new Predicate<Result>() {
        @Override
        public boolean apply(@Nullable Result result) {
            if (result == null)
                return false;

            try {
                StaticBuffer id = StaticArrayBuffer.of(result.getRow());
                id.getLong(0);
            } catch (NumberFormatException e) {
                return false;
            }

            return true;
        }
    });
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:21,代码来源:HBaseKeyColumnValueStore.java

示例3: 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

示例4: RowIterator

import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入依赖的package包/类
public RowIterator(HTableInterface table, ResultScanner rows) {
    this.table = table;
    this.rows = Iterators.filter(rows.iterator(), new Predicate<Result>() {
        @Override
        public boolean apply(@Nullable Result result) {
            if (result == null)
                return false;

            try {
                StaticBuffer id = StaticArrayBuffer.of(result.getRow());
                id.getLong(0);
            } catch (NumberFormatException e) {
                return false;
            }

            return true;
        }
    });
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:20,代码来源:HBaseKeyColumnValueStore.java

示例5: next

import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入依赖的package包/类
@Override
public StaticBuffer next() {
    ensureOpen();

    currentRow = rows.next();
    return StaticArrayBuffer.of(currentRow.getKey());
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:8,代码来源:AstyanaxKeyColumnValueStore.java

示例6: testFuzzMessagesSerial

import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入依赖的package包/类
@Test
public void testFuzzMessagesSerial() 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);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:28,代码来源:LogTest.java

示例7: 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;
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:34,代码来源:SimpleScanJob.java

示例8: 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);
        }
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:31,代码来源:KeyColumnValueStoreUtil.java

示例9: 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);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:13,代码来源:KeyColumnValueStoreUtil.java

示例10: getCurrentKey

import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入依赖的package包/类
@Override
public StaticBuffer getCurrentKey() throws IOException, InterruptedException {
    ImmutableBytesWritable ibw = (ImmutableBytesWritable)reader.getCurrentKey();
    StaticArrayBuffer sab = StaticArrayBuffer.of(ibw.copyBytes());
    return sab;
    // return StaticArrayBuffer.of(trb.getCurrentKey().copyBytes());
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:8,代码来源:HBaseBinaryRecordReader.java

示例11: next

import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入依赖的package包/类
@Override
public Entry next() {
    final Map.Entry<byte[], NavigableMap<Long, byte[]>> entry = iterator.next();
    byte[] col = entry.getKey();
    byte[] val = entry.getValue().lastEntry().getValue();
    return StaticArrayEntry.of(new StaticArrayBuffer(col), new StaticArrayBuffer(val));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:8,代码来源:HBaseBinaryRecordReader.java

示例12: fromLockColumn

import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入依赖的package包/类
public TimestampRid fromLockColumn(StaticBuffer lockKey, TimestampProvider provider) {
    ReadBuffer r = lockKey.asReadBuffer();
    int len = r.length();
    long tsNS = r.getLong();
    len -= 8;
    byte[] curRid = new byte[len];
    for (int i = 0; r.hasRemaining(); i++) {
        curRid[i] = r.getByte();
    }
    StaticBuffer rid = new StaticArrayBuffer(curRid);
    Instant time = provider.getTime(tsNS);
    return new TimestampRid(time, rid);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:14,代码来源:ConsistentKeyLockerSerializer.java

示例13: next

import com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer; //导入依赖的package包/类
@Override
public StaticBuffer next() {
    ensureOpen();

    currentRow = rows.next();
    return StaticArrayBuffer.of(currentRow.getRow());
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:8,代码来源:HBaseKeyColumnValueStore.java

示例14: 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;
}
 
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:40,代码来源:CassandraBinaryRecordReader.java

示例15: 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);
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:28,代码来源:LogTest.java


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