org.junit.experimental.theories.DataPoints#com.carrotsearch.hppc.LongArrayList源码实例Demo

下面列出了org.junit.experimental.theories.DataPoints#com.carrotsearch.hppc.LongArrayList 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * Returns the list of adjacent vertex ids for this query. By reading those ids
 * from the entries directly (without creating objects) we get much better performance.
 *
 * @return
 */
public VertexList vertexIds() {
    LongArrayList list = new LongArrayList();
    long previousId = 0;
    for (Long id : Iterables.transform(this,new Function<Entry, Long>() {
        @Nullable
        @Override
        public Long apply(@Nullable Entry entry) {
            return edgeSerializer.readRelation(entry,true,tx).getOtherVertexId();
        }
    })) {
        list.add(id);
        if (id>=previousId && previousId>=0) previousId=id;
        else previousId=-1;
    }
    return new VertexLongList(tx,list,previousId>=0);
}
 
源代码2 项目: titan1withtp3.1   文件: AbstractLongListUtil.java
public static LongArrayList mergeSort(LongArrayList a, LongArrayList b) {
    int posa=0, posb=0;
    LongArrayList result = new LongArrayList(a.size()+b.size());
    while (posa<a.size() || posb<b.size()) {
        long next;
        if (posa>=a.size()) {
            next=b.get(posb++);
        } else if (posb>=b.size()) {
            next=a.get(posa++);
        } else if (a.get(posa)<=b.get(posb)) {
            next=a.get(posa++);
        } else {
            next=b.get(posb++);
        }
        Preconditions.checkArgument(result.isEmpty() || result.get(result.size()-1)<=next,
                "The input lists are not sorted");
        result.add(next);
    }
    return result;
}
 
源代码3 项目: spliceengine   文件: SimpleTxnOperationFactory.java
@Override
public byte[] encode(TxnView txn){
    MultiFieldEncoder encoder=MultiFieldEncoder.create(9)
            .encodeNext(txn.getTxnId())
            .encodeNext(txn.getBeginTimestamp())
            .encodeNext(txn.isAdditive())
            .encodeNext(txn.getIsolationLevel().encode())
            .encodeNext(txn.allowsWrites());

    TaskId taskId = txn.getTaskId();
    if (taskId != null) {
        encoder.encodeNext(taskId.getStageId()).encodeNext(taskId.getPartitionId()).encodeNext(taskId.getTaskAttemptNumber());
    } else {
        encoder.encodeNext(-1).encodeNext(-1).encodeNext(-1);
    }

    LongArrayList parentTxnIds= new LongArrayList();
    byte[] build=encodeParentIds(txn,parentTxnIds);
    encoder.setRawBytes(build);
    return encoder.build();
}
 
源代码4 项目: spliceengine   文件: SimpleTxnOperationFactory.java
private byte[] encodeParentIds(TxnView txn,LongArrayList parentTxnIds){
    /*
     * For both active reads AND active writes, we only need to know the
     * parent's transaction ids, since we'll use the information immediately
     * available to determine other properties (additivity, etc.) Thus,
     * by doing this bit of logic, we can avoid a network call on the server
     * for every parent on the transaction chain, at the cost of 2-10 bytes
     * per parent on the chain--a cheap trade.
     */
    TxnView parent=txn.getParentTxnView();
    while(!Txn.ROOT_TRANSACTION.equals(parent)){
        parentTxnIds.add(parent.getTxnId());
        parent=parent.getParentTxnView();
    }
    int parentSize=parentTxnIds.size();
    long[] parentIds=parentTxnIds.buffer;
    MultiFieldEncoder parents=MultiFieldEncoder.create(parentSize);
    for(int i=1;i<=parentSize;i++){
        parents.encodeNext(parentIds[parentSize-i]);
    }
    return parents.build();
}
 
源代码5 项目: spliceengine   文件: TestingTxnStore.java
private long[] findActiveTransactions(long minTimestamp,long maxId,byte[] table){
    LongArrayList activeTxns=new LongArrayList(txnMap.size());
    for(Map.Entry<Long, TxnHolder> txnEntry : txnMap.entrySet()){
        if(isTimedOut(txnEntry.getValue())) continue;
        Txn value=txnEntry.getValue().txn;
        if(value.getEffectiveState()==Txn.State.ACTIVE && value.getTxnId()<=maxId && value.getTxnId()>=minTimestamp){
            Iterator<ByteSlice> destinationTables=value.getDestinationTables();
            while(destinationTables.hasNext()){
                ByteSlice data=destinationTables.next();
                if(data.equals(table,0,table.length))
                    activeTxns.add(txnEntry.getKey());
            }
        }
    }
    return activeTxns.toArray();
}
 
源代码6 项目: spliceengine   文件: ActiveTransactionTest.java
@Test
public void oldestActiveTransactionIgnoresCommitTimestampIds() throws IOException{
    final Txn t0=control.beginTransaction(DESTINATION_TABLE);
    transactorSetup.timestampSource.rememberTimestamp(t0.getTxnId());
    LongArrayList committedTxns=new LongArrayList();
    for(int i=0;i<4;i++){
        final Txn transactionId=control.beginTransaction(DESTINATION_TABLE);
        transactionId.commit();
        committedTxns.add(transactionId.getTxnId());
    }

    final Txn t1=control.beginTransaction(DESTINATION_TABLE);
    final long[] ids=txnStore.getActiveTransactionIds(t1,DESTINATION_TABLE);
    Assert.assertEquals(2,ids.length);
    Arrays.sort(ids);
    Assert.assertEquals(t0.getTxnId(),ids[0]);
    Assert.assertEquals(t1.getTxnId(),ids[1]);
    //this transaction should still be missing
}
 
源代码7 项目: spliceengine   文件: CorrelatedPushDown.java
public boolean pushdownPredWithColumn(ResultSetNode rsn, Predicate pred, ValueNode colRef)
        throws StandardException {
    try {
        ResultColumn rc = RSUtils.refToRC.apply(colRef);
        LongArrayList chain = rc.chain();
        long lastLink = chain.get(chain.size() - 1);
        List<ResultSetNode> subTree = RSUtils.getSelfAndDescendants(rsn);
        Map<Integer, ResultSetNode> nodeMap = zipMap(Iterables.transform(subTree, RSUtils.rsNum), subTree);
        int left = (int) (lastLink >> 32);
        int right = (int) lastLink;
        ResultSetNode targetRSN = nodeMap.get(left);
        rc.setResultSetNumber(left);
        rc.setVirtualColumnId(right);
        ((Optimizable)targetRSN).pushOptPredicate(pred);
    } catch (StandardException e) {
        LOG.warn("Exception pushing down topmost subquery predicate:", e);
        return false;
    }
    return true;
}
 
源代码8 项目: spliceengine   文件: ExhaustiveLongEncodingTest.java
@DataPoints public static long[] powersOf2(){
    LongArrayList dataPoints = new LongArrayList(100);
    long l = 1l;
    while(l>0){
        dataPoints.add(l);
        dataPoints.add(-l);
        dataPoints.add(3*l);
        dataPoints.add(-3*l);
        dataPoints.add(5*l);
        dataPoints.add(-5*l);
        dataPoints.add(7*l);
        dataPoints.add(-7*l);
        l<<=1;
    }

    return dataPoints.toArray();
}
 
源代码9 项目: spliceengine   文件: MemTxnStore.java
private long[] findActiveTransactions(long minTimestamp,long maxId,byte[] table){
    LongArrayList activeTxns=new LongArrayList(txnMap.size());
    for(Map.Entry<Long, TxnHolder> txnEntry : txnMap.entrySet()){
        if(isTimedOut(txnEntry.getValue())) continue;
        Txn value=txnEntry.getValue().txn;
        if(value.getEffectiveState()==Txn.State.ACTIVE && value.getTxnId()<=maxId && value.getTxnId()>=minTimestamp){
            Iterator<ByteSlice> destinationTables=value.getDestinationTables();
            while(destinationTables.hasNext()){
                ByteSlice data=destinationTables.next();
                if(data.equals(table,0,table.length))
                    activeTxns.add(txnEntry.getKey());
            }
        }
    }
    return activeTxns.toArray();
}
 
源代码10 项目: titan1withtp3.1   文件: VertexArrayList.java
/**
 * Utility method used to convert the list of vertices into a list of vertex ids (assuming all vertices have ids)
 *
 * @param vertices
 * @return
 */
private static final LongArrayList toLongList(List<TitanVertex> vertices) {
    LongArrayList result = new LongArrayList(vertices.size());
    for (TitanVertex n : vertices) {
        result.add(n.longId());
    }
    return result;
}
 
源代码11 项目: titan1withtp3.1   文件: StandardTitanGraph.java
public List<EntryList> edgeMultiQuery(LongArrayList vids, SliceQuery query, BackendTransaction tx) {
    Preconditions.checkArgument(vids != null && !vids.isEmpty());
    List<StaticBuffer> vertexIds = new ArrayList<StaticBuffer>(vids.size());
    for (int i = 0; i < vids.size(); i++) {
        Preconditions.checkArgument(vids.get(i) > 0);
        vertexIds.add(idManager.getKey(vids.get(i)));
    }
    Map<StaticBuffer,EntryList> result = tx.edgeStoreMultiQuery(vertexIds, query);
    List<EntryList> resultList = new ArrayList<EntryList>(result.size());
    for (StaticBuffer v : vertexIds) resultList.add(result.get(v));
    return resultList;
}
 
源代码12 项目: titan1withtp3.1   文件: AbstractLongListUtil.java
public static LongArrayList mergeJoin(LongArrayList a, LongArrayList b, final boolean unique) {
    assert isSorted(a) : a.toString();
    assert isSorted(b) : b.toString();
    int counterA = 0, counterB = 0;
    int sizeA = a.size();
    int sizeB = b.size();
    LongArrayList merge = new LongArrayList(Math.min(sizeA, sizeB));
    int resultSize = 0;
    while (counterA < sizeA && counterB < sizeB) {
        if (a.get(counterA) == b.get(counterB)) {
            long value = a.get(counterA);
            if (!unique) {
                merge.add(value);
                resultSize++;
            } else {
                if (resultSize <= 0 || merge.get(resultSize - 1) != value) {
                    merge.add(value);
                    resultSize++;
                }
            }
            counterA++;
            counterB++;
        } else if (a.get(counterA) < b.get(counterB)) {
            counterA++;
        } else {
            assert a.get(counterA) > b.get(counterB);
            counterB++;
        }
    }
    return merge;
}
 
源代码13 项目: spliceengine   文件: TestingTxnStore.java
private long[] getAllActiveTransactions(long minTimestamp,long maxId) throws IOException{

        LongArrayList activeTxns=new LongArrayList(txnMap.size());
        for(Map.Entry<Long, TxnHolder> txnEntry : txnMap.entrySet()){
            if(isTimedOut(txnEntry.getValue())) continue;
            Txn value=txnEntry.getValue().txn;
            if(value.getEffectiveState()==Txn.State.ACTIVE
                    && value.getTxnId()<=maxId
                    && value.getTxnId()>=minTimestamp)
                activeTxns.add(txnEntry.getKey());
        }
        return activeTxns.toArray();
    }
 
源代码14 项目: spliceengine   文件: ActiveTransactionTest.java
@Test
    @Ignore("This is subject to contamination failures when other tests are running concurrently")
    public void oldestActiveTransactionsManyActive() throws IOException{
        LongArrayList startedTxns=new LongArrayList();
        final Txn t0=control.beginTransaction(DESTINATION_TABLE);
        startedTxns.add(t0.getTxnId());
        transactorSetup.timestampSource.rememberTimestamp(t0.getTxnId());
//        long[] startIds = txnStore.getActiveTransactionIds(t0,DESTINATION_TABLE);
//        for(long sId:startIds){
//            startedTxns.add(sId);
//        }
        for(int i=0;i<4;i++){
            Txn transactionId=control.beginTransaction(DESTINATION_TABLE);
            startedTxns.add(transactionId.getTxnId());
        }
        final Txn t1=control.beginTransaction(DESTINATION_TABLE);
        startedTxns.add(t1.getTxnId());
        final long[] ids=txnStore.getActiveTransactionIds(t0.getTxnId(),t1.getTxnId(),DESTINATION_TABLE);
        System.out.println(startedTxns.toString());
        System.out.println(Arrays.toString(ids));

        Assert.assertEquals(startedTxns.size(),ids.length);
        Arrays.sort(ids);
        Assert.assertArrayEquals(startedTxns.toArray(),ids);
//        Assert.assertEquals(t0.getTxnId(), ids[0]);
//        Assert.assertEquals(t1.getTxnId(), result.get(ids.length - 1).getId());
    }
 
源代码15 项目: spliceengine   文件: RegionTxnStore.java
@Override
public long[] getActiveTxnIds(long afterTs,long beforeTs,byte[] destinationTable) throws IOException{
    if(LOG.isTraceEnabled())
        SpliceLogUtils.trace(LOG,"getActiveTxnIds beforeTs=%d, afterTs=%s, destinationTable=%s",beforeTs,afterTs,destinationTable);

    LongArrayList lal = new LongArrayList();
    try (Source<TxnMessage.Txn> activeTxn = getActiveTxns(afterTs, beforeTs, destinationTable)) {
        while (activeTxn.hasNext()) {
            TxnMessage.Txn next = activeTxn.next();
            TxnMessage.TxnInfo info = next.getInfo();
            lal.add(info.getTxnId());
        }
    }
    return lal.toArray();
}
 
源代码16 项目: spliceengine   文件: QueryTreeNode.java
/**
 * For a given ResultColumnList, return a map from
 * [resultSetNumber, virtualColumnId] => ResultColumn
 * where there is one entry for each ResultColumn down the chain of reference to
 * its source column on a table. This allows translation from a column reference at
 * any node below into the ResultColumn projected from the passed ResultColumnList.
 */
public LongObjectHashMap<ResultColumn> rsnChainMap()
        throws StandardException {
    LongObjectHashMap<ResultColumn> chain = new LongObjectHashMap<>();
    List<ResultColumn> cols = RSUtils.collectNodes(this, ResultColumn.class);
    for (ResultColumn rc : cols) {
        long top = rc.getCoordinates();
        chain.put(top, rc);
        LongArrayList list = rc.chain();
        for (int i = 0; i< list.size(); i++) {
            chain.put(list.buffer[i],rc);
        }
    }
    return chain;
}
 
源代码17 项目: spliceengine   文件: ExhaustiveLongEncodingTest.java
@DataPoints public static long[] powersOf7(){
    LongArrayList dataPoints = new LongArrayList(100);
    long l = 1l;
    while(l>0){
        dataPoints.add(l);
        dataPoints.add(-l);
        l*=7;
    }

    return dataPoints.toArray();
}
 
源代码18 项目: spliceengine   文件: MemTxnStore.java
private long[] getAllActiveTransactions(long minTimestamp,long maxId) throws IOException{

        LongArrayList activeTxns=new LongArrayList(txnMap.size());
        for(Map.Entry<Long, TxnHolder> txnEntry : txnMap.entrySet()){
            if(isTimedOut(txnEntry.getValue())) continue;
            Txn value=txnEntry.getValue().txn;
            if(value.getEffectiveState()==Txn.State.ACTIVE
                    && value.getTxnId()<=maxId
                    && value.getTxnId()>=minTimestamp)
                activeTxns.add(txnEntry.getKey());
        }
        return activeTxns.toArray();
    }
 
源代码19 项目: Elasticsearch   文件: NumberFieldMapper.java
public CustomLongNumericDocValuesField(String  name, long value) {
    super(name);
    values = new LongArrayList();
    add(value);
}
 
源代码20 项目: titan1withtp3.1   文件: VertexLongList.java
public VertexLongList(StandardTitanTx tx) {
    this(tx,new LongArrayList(10),true);
}
 
源代码21 项目: titan1withtp3.1   文件: VertexLongList.java
public VertexLongList(StandardTitanTx tx, LongArrayList vertices, boolean sorted) {
    assert !sorted || AbstractLongListUtil.isSorted(vertices);
    this.tx = tx;
    this.vertices = vertices;
    this.sorted = sorted;
}
 
源代码22 项目: titan1withtp3.1   文件: VertexLongList.java
@Override
public LongArrayList getIDs() {
    return vertices;
}
 
源代码23 项目: titan1withtp3.1   文件: VertexArrayList.java
@Override
public LongArrayList getIDs() {
    return toLongList(vertices);
}
 
源代码24 项目: titan1withtp3.1   文件: VertexArrayList.java
public VertexLongList toVertexLongList() {
    LongArrayList list = toLongList(vertices);
    return new VertexLongList(tx,list,sorted);
}
 
源代码25 项目: titan1withtp3.1   文件: AbstractLongListUtil.java
public static boolean isSorted(LongArrayList l, final boolean unique) {
    for (int i = 1; i < l.size(); i++) {
        if (l.get(i) < l.get(i - 1) || (unique && l.get(i) == l.get(i - 1))) return false;
    }
    return true;
}
 
源代码26 项目: titan1withtp3.1   文件: AbstractLongListUtil.java
public static boolean isSorted(LongArrayList l) {
    return isSorted(l, false);
}
 
源代码27 项目: titan1withtp3.1   文件: AbstractLongListUtil.java
public static LongArrayList singleton(long el) {
    LongArrayList l = new LongArrayList(1);
    l.add(el);
    return l;
}
 
源代码28 项目: sasi   文件: OnDiskIndexBuilder.java
protected void flushMetadata(LongArrayList longArrayList) throws IOException
{
    out.writeInt(longArrayList.size());
    for (int i = 0; i < longArrayList.size(); i++)
        out.writeLong(longArrayList.get(i));
}
 
源代码29 项目: more-lambdas-java   文件: MoreCollectors.java
public static Collector<Long, ?, LongArrayList> toLongList() {
    return new CollectorImpl<>(LongArrayList::new, LongArrayList::add, (left, right) -> {
        left.addAll(right);
        return left;
    }, CH_ID);
}
 
源代码30 项目: titan1withtp3.1   文件: VertexList.java
/**
 * Returns a list of ids of all vertices in this list of vertices in the same order of the original vertex list.
 * <p/>
 * Uses an efficient primitive variable-sized array.
 *
 * @return A list of idAuthorities of all vertices in this list of vertices in the same order of the original vertex list.
 * @see LongArrayList
 */
public LongArrayList getIDs();