當前位置: 首頁>>代碼示例>>Java>>正文


Java Bytes類代碼示例

本文整理匯總了Java中org.apache.jena.atlas.lib.Bytes的典型用法代碼示例。如果您正苦於以下問題:Java Bytes類的具體用法?Java Bytes怎麽用?Java Bytes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Bytes類屬於org.apache.jena.atlas.lib包,在下文中一共展示了Bytes類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: iterator

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
@Override
public Iterator<Record> iterator(Record recordMin, Record recordMax) {
    try (RocksIterator iter = db.newIterator(colFamily)) {
        if ( recordMin == null )
            iter.seekToFirst();
        else
            iter.seek(recordMin.getKey());
        List<Record> x = new ArrayList<>(1000); 
        while(iter.isValid()) {
            byte[]k = iter.key();
            if ( recordMax != null ) {
                if ( Bytes.compare(k, recordMax.getKey()) >= 0 )
                    break;
            }
            byte[]v = iter.value();
            x.add(getRecordFactory().create(k,v));
            iter.next();
        }
        return x.iterator();
    }
}
 
開發者ID:afs,項目名稱:tdb3,代碼行數:22,代碼來源:RocksRangeIndex.java

示例2: scanFrom

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
/** Scan to find the largest in-use id.
 * Retrun -1 for no key found. */  
private long scanFrom(byte[] startBytes) {
    RocksIterator iter = db.newIterator(columnFamily);
    iter.seek(startBytes);
    // The "next id" key may be at the top of the key range, so scan carefully. 
    long seen = -1;
    while(iter.isValid()) {
        byte[] k = iter.key();
        // nextIdKey reached. Ignore.
        if ( Bytes.compare(nextIdKey, k) == 0 )
            break;
        seen = Bytes.getLong(k);
        iter.next();
    }
    return seen ;
}
 
開發者ID:afs,項目名稱:tdb3,代碼行數:18,代碼來源:RocksNodeTable.java

示例3: writeNodeToTable

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
@Override
protected NodeId writeNodeToTable(Node node) {
    // Alloc key.
    long id = nextId++;
    try {
        Bytes.setLong(id, key);
        byte[] bytes = codec.encode(node);
        db.put(columnFamily, key, bytes);
        // Record the counter every so often.
        if ( nextId % IdAllocSaveTick == 0 ) {
            Bytes.setLong(nextId, nextIdBytes);
            db.put(columnFamily, nextIdKey, nextIdBytes);
        }
    } catch (Exception e) { throw new TDBException(e); }
    return NodeIdFactory.createPtr(id);
}
 
開發者ID:afs,項目名稱:tdb3,代碼行數:17,代碼來源:RocksNodeTable.java

示例4: RocksNodeTable

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
public RocksNodeTable(RocksDB db, ColumnFamilyHandle columnFamily, Index nodeToId, ByteCodec<Node> codec) {
    super(nodeToId) ;
    this.codec = codec;
    this.columnFamily = columnFamily;
    this.db = db;
    // Get the id start.
    try {
        int rc = db.get(columnFamily, nextIdKey, nextIdBytes);
        if ( rc == RocksDB.NOT_FOUND ) {
            //System.err.println("Init counter");
            // Initalize.
            nextId = initialNextId;
        } else {
            // Scan forward.
            long x = Bytes.getLong(nextIdBytes);
            //System.err.println("Recover counter : "+x);
            long y = scanFrom(nextIdBytes);
            long y0 = scanFrom0(nextIdBytes);
            //System.err.println("Last id :    "+y);
            if ( y != y0 )
                throw new InternalErrorException();

            if ( y == -1) {
                // No other key found - the nextIdKey was the latest. 
                nextId = x;
            } else {
                // Set to one more than last key found. 
                nextId = y+1;
            }
        }
        //System.err.println("Set counter : "+nextId);
        Bytes.setLong(nextId, nextIdBytes);
        db.put(columnFamily, nextIdKey, nextIdBytes);
    }
    catch (RocksDBException e) { throw RocksException.wrap(e); }
}
 
開發者ID:afs,項目名稱:tdb3,代碼行數:37,代碼來源:RocksNodeTable.java

示例5: scanFrom0

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
private long scanFrom0(byte[] startBytes) throws RocksDBException {
    //Scan one-by-one.  
    long probe = Bytes.getLong(startBytes);
    long seen = -1;
    for(;;) {
        Bytes.setLong(probe, key);
        byte[] bytes = db.get(columnFamily,key);
        if ( bytes == null )
            break;
        seen = probe;
        probe = probe+1;
    }
    return seen ;
}
 
開發者ID:afs,項目名稱:tdb3,代碼行數:15,代碼來源:RocksNodeTable.java

示例6: fromBytes

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
/** Create a {@code Id}, according to byte.
 * @see #asBytes
 */ 
public static Id fromBytes(byte[] bytes) {
    if ( bytes.length == 2*Long.BYTES ) {
        long mostSig = Bytes.getLong(bytes, 0);
        long leastSig = Bytes.getLong(bytes, Long.BYTES);
        UUID uuid = new UUID(mostSig, leastSig);
        return fromUUID(uuid);
    }
    String str = new String(bytes, StandardCharsets.UTF_8);
    return new Id(str);
}
 
開發者ID:afs,項目名稱:rdf-delta,代碼行數:14,代碼來源:Id.java

示例7: asBytes

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
/** 
 * Encode as bytes (network order, 16 byte number). 
 * @see #fromBytes(byte[])
 */ 
public byte[] asBytes() {
    if ( uuid != null ) {
        byte[] bytes = new byte[2*Long.BYTES];
        // As a 16 byte number, network order - most significant byte in byte[0].
        Bytes.setLong(uuid.getMostSignificantBits(), bytes, 0);
        Bytes.setLong(uuid.getLeastSignificantBits(), bytes, Long.BYTES);
        return bytes;
    }
    return string.getBytes(StandardCharsets.UTF_8);
}
 
開發者ID:afs,項目名稱:rdf-delta,代碼行數:15,代碼來源:Id.java

示例8: pState_02

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
@Test public void pState_02() {
    PersistentState ps = new PersistentState(filename);
    byte[] b = new byte[4];
    Bytes.setInt(-99, b);
    ps.set(b);
    assertEquals(4, ps.get().length);
    PersistentState ps2 = new PersistentState(filename);
    assertEquals(4, ps2.get().length);
}
 
開發者ID:afs,項目名稱:rdf-delta,代碼行數:10,代碼來源:TestPersistentState.java

示例9: segment

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
private long segment(Node node) {
    // @@ Overly expensive
    Hash hash = new Hash(SystemTDB.LenNodeHash) ;
    NodeLib.setHash(hash, node) ;
    byte k[] = hash.getBytes() ;
    // Positive 
    int x = Bytes.getInt(k, 0) & 0x8FFFFFF ;
    // Range 1 to 15 - zero is kept as an error marker.
    x = (x%size)+1 ;
    return x ;
}
 
開發者ID:afs,項目名稱:lizard,代碼行數:12,代碼來源:DistributorNodesBySegment.java

示例10: performFind

import org.apache.jena.atlas.lib.Bytes; //導入依賴的package包/類
@Override
protected Iterator<Tuple<NodeId>> performFind(Tuple<NodeId> pattern) {
    byte[] keyMin = new byte[NodeId.SIZE*tupleLength];
    byte[] keyMax = new byte[NodeId.SIZE*tupleLength];
    
    // Pattern order 
    // Avoid copy.
    Tuple<NodeId> patternIndexOrder = tupleMap.map(pattern) ;
    NodeId[] pat = new NodeId[tupleLength];
    int i = 0 ; 
    for ( ; i < tupleLength; i++ ) {
        NodeId nid = patternIndexOrder.get(i);
        if ( nid == null ) {}
        if ( nid == NodeId.NodeIdAny) {}
        if ( nid == NodeId.NodeIdUndefined) {}
        if ( nid == NodeId.NodeIdDefined) {}
        if ( nid == NodeId.NodeIdInvalid) {}
        
        pat[i] = nid;
        NodeIdFactory.set(nid, keyMin, i);
        NodeIdFactory.set(nid, keyMax, i);
    }
    
    /*const*/
    NodeId min = NodeIdFactory.createPtr(0);
    NodeId max = null; //NodeIdFactory.createValue(null/*??*/,Long.MIN_VALUE);
    
    for ( int j = i * NodeId.SIZE ; j < tupleLength* NodeId.SIZE; j++ ) {
        keyMin[j] = 1 ;
        keyMax[j] = (byte)0xFF; 
    }
    
    RocksIterator rIter = rdb.newIterator((ColumnFamilyHandle)null);
    rIter.seek(keyMin);
    if ( ! rIter.isValid() )
        return Iter.nullIterator();

    //BatchingIterator<Tuple<NodeId>> batchingIter = new BatchingIterator<Tuple<NodeId>>(null, null, BATCHSIZE, null);
    
    // UNFINISHED
    // matches.
    // Avoid rIter.isValid()? Catch failure for rIter.next() for overrun.
    while(true) {
        rIter.next();
        // Not safe copy.
        byte[] k = rIter.key();
        // Not safe copy.
        byte v[] = rIter.value();
        
        // check v.
        if ( keyMax != null ) { 
            if ( Bytes.compare(k, keyMax) >= 0 )
                break;
        } else {
            if ( ! rIter.isValid() )
                break;
        }
        NodeId x = NodeIdFactory.get(k);
        // Yield x.
    }
    
    
    
    
    
    return null ;
}
 
開發者ID:afs,項目名稱:tdb3,代碼行數:68,代碼來源:TupleIndexR.java


注:本文中的org.apache.jena.atlas.lib.Bytes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。