public boolean processL3Snapshot()

in orderbook-core/src/main/java/com/epam/deltix/orderbook/core/impl/L3SingleExchangeQuoteProcessor.java [240:302]


    public boolean processL3Snapshot(final PackageHeaderInfo pck) {
        if (!isSnapshotAllowed(pck)) {
            return false;
        }
        clear();
        final ObjectList<BaseEntryInfo> entries = pck.getEntries();

        asksList.clear();
        bidsList.clear();
        final int len = entries.size();
        for (int i = 0; i < len; i++) {
            final BaseEntryInfo e = entries.get(i);
            if (e instanceof L3EntryNewInterface) {
                final L3EntryNewInterface entry = (L3EntryNewInterface) e;
                if (!validExchange(pck, entry.getExchangeId())) {
                    // We expect that exchangeId is valid and all entries have the same exchangeId
                    continue;
                }

                final QuoteSide side = entry.getSide();
                final L3MarketSide<Quote> marketSide = getMarketSide(side);

                // Both sides have the same max depth
                final int maxDepth = marketSide.getMaxDepth();
                if ((side == ASK && asksList.size() == maxDepth) || (side == BID && bidsList.size() == maxDepth)) {
                    continue;
                }

                // We don't check for duplicate quoteIds, we can do it with hashMap if necessary
                final EntryValidationCode errorCode =
                        marketSide.isInvalidInsert(entry.getInsertType(), entry.getQuoteId(), entry.getPrice(), entry.getSize(), side);
                if (errorCode != null) {
                    if (validationOptions.isQuoteInsert()) {
                        errorListener.onError(pck, errorCode);
                        eventHandler.onBroken();
                    }
                    return false;
                }

                final Quote quote = pool.borrow();
                quote.copyFrom(pck, entry);

                if (side == ASK) {
                    quote.setSequenceNumber(asksList.size());
                    asksList.add(quote);
                } else {
                    quote.setSequenceNumber(bidsList.size());
                    bidsList.add(quote);
                }

                if (asksList.size() == maxDepth && bidsList.size() == maxDepth) {
                    break;
                }
            }
        }
        // Bid and ask entries in each snapshot package should be sorted
        // from best to worst price, same-priced entries should be in FIFO order
        getMarketSide(ASK).buildFromSorted(asksList);
        getMarketSide(BID).buildFromSorted(bidsList);

        eventHandler.onSnapshot();
        return true;
    }