com.devexperts.qd.ng.RecordCursor

Here are the examples of the java api com.devexperts.qd.ng.RecordCursor taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1049 Examples 7

19 Source : RemoveEventTimeTest.java
with Mozilla Public License 2.0
from devexperts

private void replacedertData(RecordBuffer buf, String symbol, int flags, int time, int sequence) {
    RecordCursor cursor = buf.next();
    replacedertEquals(0, cursor.getCipher());
    replacedertEquals(symbol, cursor.getSymbol());
    replacedertEquals(flags, cursor.getEventFlags());
    replacedertEquals(time, cursor.getInt(0));
    replacedertEquals(sequence, cursor.getInt(1));
}

19 Source : RemoveEventTimeTest.java
with Mozilla Public License 2.0
from devexperts

private void addData(RecordBuffer buf, String symbol, int flags, int time, int sequence) {
    RecordCursor cursor = buf.add(RECORD, 0, symbol);
    cursor.setEventFlags(flags);
    cursor.setInt(0, time);
    cursor.setInt(1, sequence);
}

19 Source : TextQTPComposer.java
with Mozilla Public License 2.0
from devexperts

@Override
protected void writeField(DataField field, RecordCursor cursor) {
    if (acceptField(field)) {
        separator();
        write(field.getString(cursor));
    }
}

19 Source : TextQTPComposer.java
with Mozilla Public License 2.0
from devexperts

@Override
protected void writeRecordPayload(RecordCursor cursor, int eventFlags) throws IOException {
    super.writeRecordPayload(cursor, eventFlags);
    if (eventFlags != 0) {
        String s = EventFlag.formatEventFlags(eventFlags, currentMessageType);
        if (!s.isEmpty()) {
            separator();
            write(BuiltinFields.EVENT_FLAGS_FIELD_NAME + "=" + s);
        }
    }
}

19 Source : CompareBuffer.java
with Mozilla Public License 2.0
from devexperts

public synchronized void add(long timestamp, RecordCursor cursor) {
    if (cursor.getRecord() != rf.getRecord())
        throw new IllegalArgumentException();
    if (ints.length < isize + ineed)
        ints = ArrayUtil.grow(ints, isize + ineed);
    if (objs.length < osize + oneed)
        objs = ArrayUtil.grow(objs, osize + oneed);
    ints[isize++] = (int) (timestamp >>> 32);
    ints[isize++] = (int) timestamp;
    for (int k = 0; k < rf.getIntFieldCount(); k++) ints[isize++] = cursor.getInt(rf.getIntIndex(k));
    for (int k = 0; k < rf.getObjFieldCount(); k++) objs[osize++] = cursor.getObj(rf.getObjIndex(k));
    size++;
}

19 Source : CollectorBufferTest.java
with Mozilla Public License 2.0
from devexperts

private void updateKnownTimes(RecordBuffer buf, ArrayList<SymbolObjectMap<Long>> known_times) {
    RecordCursor cur;
    while ((cur = buf.next()) != null) {
        Long known_time = known_times.get(cur.getRecord().getId()).get(cur.getCipher(), cur.getSymbol());
        known_times.get(cur.getRecord().getId()).put(cur.getCipher(), cur.getSymbol(), known_time == null ? cur.getTime() : Math.min(known_time, cur.getTime()));
    }
}

19 Source : CollectorBufferTest.java
with Mozilla Public License 2.0
from devexperts

private void tweakValue(RecordCursor cur) {
    for (int j = 2; j < cur.getIntCount(); j++) cur.setInt(j, cur.getInt(j) + j);
}

19 Source : CollectorBufferTest.java
with Mozilla Public License 2.0
from devexperts

private int computeCheckSum(RecordCursor cur) {
    int sum = 0;
    for (int i = 0; i < cur.getIntCount(); i++) sum ^= Integer.rotateLeft(cur.getInt(i), i);
    return sum;
}

19 Source : LoggedAgent.java
with Mozilla Public License 2.0
from devexperts

private String logSubscription(RecordSource source) {
    StringBuilder sb = new StringBuilder();
    long savePosition = source.getPosition();
    RecordCursor cur;
    while ((cur = source.next()) != null) {
        if (sb.length() > 0)
            sb.append(", ");
        Logger.appendRecord(sb, cur.getRecord(), cur.getCipher(), cur.getSymbol());
        if (cur.hasTime() && cur.getInt(0) != 0)
            Logger.appendTime(sb, cur.getRecord(), cur.getInt(0));
        if (cur.getEventFlags() != 0)
            sb.append("[").append(EventFlag.formatEventFlags(cur.getEventFlags())).append("]");
    }
    source.setPosition(savePosition);
    return sb.toString();
}

19 Source : RecordBufferTest.java
with Mozilla Public License 2.0
from devexperts

public void testUnlink() {
    RecordBuffer buf = new RecordBuffer(RecordMode.DATA.withLink());
    RecordCursor cur;
    cur = buf.add(RECORD, 1, null);
    long pos1 = cur.getPosition();
    cur = buf.add(RECORD, 2, null);
    cur.setLinkTo(pos1);
    long pos2 = cur.getPosition();
    cur = buf.add(RECORD, 3, null);
    long pos3 = cur.getPosition();
    cur = buf.add(RECORD, 4, null);
    cur.setLinkTo(pos2);
    long pos4 = cur.getPosition();
    cur = buf.add(RECORD, 5, null);
    long pos5 = cur.getPosition();
    cur = buf.add(RECORD, 6, null);
    long pos6 = cur.getPosition();
    cur = buf.add(RECORD, 7, null);
    cur.setLinkTo(pos5);
    long pos7 = cur.getPosition();
    cur = buf.add(RECORD, 8, null);
    cur.setLinkTo(pos6);
    long pos8 = cur.getPosition();
    checkUnlinked(buf);
    buf.unlinkFrom(pos4);
    checkUnlinked(buf, 1, 2, 4);
    buf.unlinkFrom(pos8);
    checkUnlinked(buf, 1, 2, 4, 6, 8);
    buf.unlinkFrom(pos3);
    checkUnlinked(buf, 1, 2, 3, 4, 6, 8);
    buf.unlinkFrom(pos7);
    checkUnlinked(buf, 1, 2, 3, 4, 5, 6, 7, 8);
}

19 Source : OutputStreamComposer.java
with Mozilla Public License 2.0
from devexperts

@Override
public void append(RecordCursor cursor) {
    skipRecord = filter != null && !filter.acceptRecord(cursor.getRecord(), cursor.getCipher(), cursor.getSymbol());
    if (skipRecord)
        return;
    if (!inMessage())
        beginMessage(messageType);
    recordCounter++;
    super.append(cursor);
}

19 Source : BinaryRecordDesc.java
with Mozilla Public License 2.0
from devexperts

// Read only event fields and time
private void readRemoveEventFields(BufferedInput msg, RecordCursor cur) throws IOException {
    readFields(msg, cur, nDescEventFields);
    long time = readTime(msg);
    if (cur != null)
        cur.setTime(time);
}

19 Source : BinaryRecordDesc.java
with Mozilla Public License 2.0
from devexperts

// --------------------------- instance methods - reading ---------------------------
/**
 * Reads record from the specified input and adds it to the specified cursor.
 * @return the cursor to the record that was just read or {@code null} if nothing was read (the record was skipped).
 */
public RecordCursor readRecord(BufferedInput msg, RecordBuffer buffer, int cipher, String symbol, int eventFlags) throws IOException {
    RecordCursor cur = null;
    if (record != null) {
        cur = buffer.add(record, cipher, symbol);
        cur.setEventFlags(eventFlags);
    }
    if (EventFlag.REMOVE_EVENT.in(eventFlags)) {
        readRemoveEventFields(msg, cur);
    } else
        readFields(msg, cur, nDesc);
    return cur;
}

19 Source : BinaryRecordDesc.java
with Mozilla Public License 2.0
from devexperts

protected void setObjValue(RecordCursor cur, int index, Object value, BufferedInput msg) {
    cur.setObj(index, value);
}

19 Source : BinaryRecordDesc.java
with Mozilla Public License 2.0
from devexperts

protected void setIntValue(RecordCursor cur, int index, int value, BufferedInput msg) {
    cur.setInt(index, value);
}

19 Source : BinaryQTPParser.java
with Mozilla Public License 2.0
from devexperts

// is overridden by ConnectionByteArrayParser to do the actual job
void updateCursorTimeMark(RecordCursor cursor) {
}

19 Source : BinaryQTPComposer.java
with Mozilla Public License 2.0
from devexperts

@Override
protected void writeField(DataField field, RecordCursor cursor) throws IOException {
    throw new UnsupportedOperationException("Legacy field-by-field writing is not supported, use 'append'");
}

19 Source : AgentAdapter.java
with Mozilla Public License 2.0
from devexperts

private RecordBuffer skipRemoveSubscription(RecordSource sub) {
    RecordBuffer buf = RecordBuffer.getInstance(sub.getMode());
    for (RecordCursor cur; (cur = sub.next()) != null; ) {
        if (!EventFlag.REMOVE_SYMBOL.in(cur.getEventFlags()))
            buf.append(cur);
    }
    return buf;
}

19 Source : AbstractQTPComposer.java
with Mozilla Public License 2.0
from devexperts

// ------------------------ helper methods for time sequences ------------------------
protected long getEventTimeSequence(RecordCursor cursor) {
    long eventTimeSequence = cursor.getEventTimeSequence();
    return eventTimeSequence != 0 ? eventTimeSequence : lastPayloadTimeSequence;
}

19 Source : VoidIntField.java
with Mozilla Public License 2.0
from devexperts

public final void setString(RecordCursor cursor, String value) {
// does not parse nor set anything
}

19 Source : VoidIntField.java
with Mozilla Public License 2.0
from devexperts

public final String getString(RecordCursor cursor) {
    // return plain integer string for debugging purposes
    return super.getString(cursor);
}

19 Source : VoidAgent.java
with Mozilla Public License 2.0
from devexperts

private void removeSubInternal(RecordCursor cur) {
    PayloadBitsSubMatrix sub = getOrCreateSub();
    int key = getKey(sub, cur.getCipher(), cur.getSymbol());
    int rid = getRid(cur.getRecord());
    int index = sub.getIndex(key, rid, 0);
    if (index == 0 || !sub.isPayload(index))
        // not subscribed
        return;
    if (hasAttachmentStrategy()) {
        Object attachment = updateAttachment(sub.getObj(index, ATTACHMENT), cur, true);
        sub.setObj(index, ATTACHMENT, attachment);
        if (// don't actually remove, but adjust attachment and return
        attachment != null)
            return;
    }
    sub.clearPayload(index);
}

19 Source : TickerStorage.java
with Mozilla Public License 2.0
from devexperts

// NOTE: There is a similar method called "putRecord"
// This method can try to allocate a lot of memory for rehash and die due to OutOfMemoryError.
// SYNC: global
boolean putRecordCursor(int key, int rid, RecordCursor cursor, RecordCursorKeeper keeper) {
    return rehashMatrixIfNeeded(rid).putRecordCursor(key, rid, cursor, keeper, stats);
}

19 Source : Ticker.java
with Mozilla Public License 2.0
from devexperts

private void removeGLocked(RecordSource source) {
    RecordCursor cur;
    while ((cur = source.next()) != null) {
        int rid = getRid(cur.getRecord());
        int key = getKey(cur.getCipher(), cur.getSymbol());
        storage.removeRecord(key, rid);
    }
}

19 Source : Stream.java
with Mozilla Public License 2.0
from devexperts

// SYNC: global+local
@Override
boolean keepInStreamBufferOnRefilter(Agent agent, RecordCursor cur) {
    // atomic read
    SubMatrix asub = agent.sub;
    int index = asub.getIndex(getKey(cur.getCipher(), cur.getSymbol()), getRid(cur.getRecord()), 0);
    return asub.isPayload(index);
}

19 Source : AgentBuffer.java
with Mozilla Public License 2.0
from devexperts

private void makeDropped(RecordCursor cursor) {
    lastDroppedCipher = cursor.getCipher();
    lastDroppedSymbol = cursor.getSymbol();
    lastDroppedRecord = cursor.getRecord();
    droppedRecords++;
}

19 Source : AgentBuffer.java
with Mozilla Public License 2.0
from devexperts

public boolean dropNewRecord(RecordCursor cursor) {
    if (overflowStrategy != QDAgent.BufferOverflowStrategy.DROP_NEWEST)
        return false;
    if (buffer.size() < maxBufferSize)
        return false;
    makeDropped(cursor);
    return true;
}

19 Source : MDRTradeHistory.java
with Mozilla Public License 2.0
from devexperts

@Override
public void getInto(RecordCursor cursor) {
    cursor.setEventTimeSequence(TimeSequenceUtil.getTimeSequenceFromTimeMillis(eventTime));
    if (cursor.getRecord().getMapping(TradeHistoryMapping.clreplaced) != null) {
        getIntoTradeHistory(cursor, cursor.getRecord().getMapping(TradeHistoryMapping.clreplaced));
    } else {
        getIntoTimeAndSale(cursor, cursor.getRecord().getMapping(TimeAndSaleMapping.clreplaced));
    }
}

19 Source : MDRTradeHistory.java
with Mozilla Public License 2.0
from devexperts

private void setFromTradeHistory(RecordCursor cursor, TradeHistoryMapping mapping) {
    time = mapping.getTimeSeconds(cursor);
    sequence = mapping.getSequence(cursor);
    exchange = mapping.getExchange(cursor);
    price = mapping.getPriceDecimal(cursor);
    size = mapping.getSize(cursor);
    bid = mapping.getBidDecimal(cursor);
    ask = mapping.getAskDecimal(cursor);
}

19 Source : MDRTradeHistory.java
with Mozilla Public License 2.0
from devexperts

private void setFromTimeAndSale(RecordCursor cursor, TimeAndSaleMapping mapping) {
    time = mapping.getTimeSeconds(cursor);
    sequence = mapping.getSequence(cursor);
    exchange = mapping.getExchange(cursor);
    price = mapping.getPriceDecimal(cursor);
    size = mapping.getSize(cursor);
    bid = mapping.getBidPriceDecimal(cursor);
    ask = mapping.getAskPriceDecimal(cursor);
}

19 Source : MDRSummary.java
with Mozilla Public License 2.0
from devexperts

private void setFromSummary(RecordCursor cursor, SummaryMapping mapping) {
    highPrice = mapping.getDayHighPriceDecimal(cursor);
    lowPrice = mapping.getDayLowPriceDecimal(cursor);
    openPrice = mapping.getDayOpenPriceDecimal(cursor);
    closePrice = mapping.getPrevDayClosePriceDecimal(cursor);
    openInterest = mapping.getOpenInterest(cursor);
}

19 Source : MDRSummary.java
with Mozilla Public License 2.0
from devexperts

private void getIntoSummary(RecordCursor cursor, SummaryMapping mapping) {
    mapping.setDayHighPriceDecimal(cursor, highPrice);
    mapping.setDayLowPriceDecimal(cursor, lowPrice);
    mapping.setDayOpenPriceDecimal(cursor, openPrice);
    mapping.setPrevDayClosePriceDecimal(cursor, closePrice);
    mapping.setOpenInterest(cursor, openInterest);
}

19 Source : SchemeRemapTest.java
with Mozilla Public License 2.0
from devexperts

private void runDataProvider() {
    QDTicker ticker = QDFactory.getDefaultFactory().createTicker(SOURCE_SCHEME);
    final QDDistributor distributor = ticker.distributorBuilder().build();
    distributor.getAddedRecordProvider().setRecordListener(provider -> {
        RecordBuffer sub = RecordBuffer.getInstance(RecordMode.SUBSCRIPTION);
        provider.retrieve(sub);
        RecordCursor cursor;
        while ((cursor = sub.next()) != null) {
            if (cursor.getDecodedSymbol().equals(SYMBOL)) {
                RecordBuffer buf = RecordBuffer.getInstance();
                RecordCursor a = buf.add(TRADE_RECORD, CIPHER, null);
                // price
                a.setInt(0, Decimal.compose(95.47));
                // size
                a.setInt(1, Decimal.compose(123));
                distributor.process(buf);
                buf.release();
            }
        }
        sub.release();
    });
    connectors = MessageConnectors.createMessageConnectors(new AgentAdapter.Factory(ticker), ":" + PORT, QDStats.VOID);
    MessageConnectors.startMessageConnectors(connectors);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public long getPutCallRatioWideDecimal(RecordCursor cursor) {
    if (iPutCallRatio < 0)
        return 0;
    return getAsWideDecimal(cursor, iPutCallRatio);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public int getVolatilityDecimal(RecordCursor cursor) {
    if (iVolatility < 0)
        return 0;
    return getAsTinyDecimal(cursor, iVolatility);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public void setTimeMillis(RecordCursor cursor, long time) {
    if (iTime < 0)
        return;
    setInt(cursor, iTime, TimeUtil.getSecondsFromTime(time));
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public void setBackVolatilityWideDecimal(RecordCursor cursor, long backVolatility) {
    if (iBackVolatility < 0)
        return;
    setAsWideDecimal(cursor, iBackVolatility, backVolatility);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public void setFrontVolatilityWideDecimal(RecordCursor cursor, long frontVolatility) {
    if (iFrontVolatility < 0)
        return;
    setAsWideDecimal(cursor, iFrontVolatility, frontVolatility);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public void setCallVolumeDecimal(RecordCursor cursor, int callVolume) {
    if (iCallVolume < 0)
        return;
    setAsTinyDecimal(cursor, iCallVolume, callVolume);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public int getCallVolumeDecimal(RecordCursor cursor) {
    if (iCallVolume < 0)
        return 0;
    return getAsTinyDecimal(cursor, iCallVolume);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public void setFrontVolatility(RecordCursor cursor, double frontVolatility) {
    if (iFrontVolatility < 0)
        return;
    setAsDouble(cursor, iFrontVolatility, frontVolatility);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public void setPutCallRatioDecimal(RecordCursor cursor, int putCallRatio) {
    if (iPutCallRatio < 0)
        return;
    setAsTinyDecimal(cursor, iPutCallRatio, putCallRatio);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public void setPutVolume(RecordCursor cursor, double putVolume) {
    if (iPutVolume < 0)
        return;
    setAsDouble(cursor, iPutVolume, putVolume);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public int getFrontVolatilityDecimal(RecordCursor cursor) {
    if (iFrontVolatility < 0)
        return 0;
    return getAsTinyDecimal(cursor, iFrontVolatility);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public long getCallVolumeWideDecimal(RecordCursor cursor) {
    if (iCallVolume < 0)
        return 0;
    return getAsWideDecimal(cursor, iCallVolume);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public void setBackVolatilityDecimal(RecordCursor cursor, int backVolatility) {
    if (iBackVolatility < 0)
        return;
    setAsTinyDecimal(cursor, iBackVolatility, backVolatility);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public long getPutVolumeWideDecimal(RecordCursor cursor) {
    if (iPutVolume < 0)
        return 0;
    return getAsWideDecimal(cursor, iPutVolume);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public int getBackVolatilityDecimal(RecordCursor cursor) {
    if (iBackVolatility < 0)
        return 0;
    return getAsTinyDecimal(cursor, iBackVolatility);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public int getPutVolumeDecimal(RecordCursor cursor) {
    if (iPutVolume < 0)
        return 0;
    return getAsTinyDecimal(cursor, iPutVolume);
}

19 Source : UnderlyingMapping.java
with Mozilla Public License 2.0
from devexperts

public void setVolatilityDecimal(RecordCursor cursor, int volatility) {
    if (iVolatility < 0)
        return;
    setAsTinyDecimal(cursor, iVolatility, volatility);
}

See More Examples