Package com.flaptor.indextank.rpc

Examples of com.flaptor.indextank.rpc.LogRecord


    };
   
    public static List<LogRecord> compactAndSort(Iterator<LogRecord> source) {
        Map<String, LogRecord> target = Maps.newHashMap();
        while (source.hasNext()) {
            LogRecord record = source.next();
            LogRecord compacted = target.get(record.get_docid());
            if (compacted == null) {
                target.put(record.get_docid(), new LogRecord(record));
            } else {
                mergeRecordInto(record, compacted);
            }
        }
        List<LogRecord> records = Lists.newArrayList(target.values());
View Full Code Here


            protected LogRecord computeNext() {
                while (true) {
                    String docid = null;
                    for (PeekingIterator<LogRecord> it : cursors) {
                        if (it.hasNext()) {
                            LogRecord peek = it.peek();
                            if (docid == null || peek.get_docid().compareTo(docid) < 0) {
                                docid = peek.get_docid();
                            }
                        }
                    }
                    if (docid != null) {
                        LogRecord merged = null;
                        for (PeekingIterator<LogRecord> it : cursors) {
                            if (it.hasNext()) {
                                LogRecord peek = it.peek();
                                if (peek.get_docid().equals(docid)) {
                                    it.next();
                                    if (merged == null) {
                                        merged = peek;
                                    } else if (peek.is_deleted()) {
                                        if (peek.is_set_fields() || peek.is_set_variables() || peek.is_set_categories()) {
                                            merged = peek;
                                            merged.set_deleted(false);
                                        } else {
                                            merged = null;
                                        }
View Full Code Here

        LogPage page = new LogPage(new LogBatch(Lists.<LogRecord>newArrayList()));

        // iterate the portion and load the records in the returned page
        RecordIterator iterator = reader.iterator();
        while (iterator.hasNext()) {
            LogRecord next = iterator.next();
            if ((!next.is_set_index_code()) || next.get_index_code().equals(log.code)) {
                page.get_batch().add_to_records(next);
            }
        }
        page.set_next_page_token(token);
View Full Code Here

                    if (((id - start) % 1000) == 0 && id != start) {
                        System.out.println("sending " + id);
                        client.sendBatch(b);
                        b.get_records().clear();
                    }
                    LogRecord record = new LogRecord();
                    record.set_docid("d" + id);
                    record.set_timestamp_ms(System.currentTimeMillis());
                    record.set_index_code(code);
                    if (text != null) {
                        record.set_fields(ImmutableMap.of("text", text));
                    } else {
                        record.set_deleted(true);
                    }
                    b.add_to_records(record);
                }
                if (!b.get_records().isEmpty())
                    client.sendBatch(b);
View Full Code Here

        // exits before we move it or delete it.
        file.deleteOnExit();
        try {
            SegmentWriter writer = new SegmentWriter(file, false);
            while (records.hasNext()) {
                LogRecord record = records.next();
                writer.write(record);
                recordCount++;
            }
            writer.release();
            // update file to non-temp and with actual record count
View Full Code Here

                totalRead = transport.getBytesRead();
                transport.close();
            }
            return endOfData();
        }
        LogRecord record = new LogRecord();
        try {
            ((TBinaryProtocol)protocol).setReadLength(10000000);
            record.read(protocol);
            if (transport != null) {
                safelyRead = transport.getBytesRead();
            }
        } catch (TTransportException e) {
            switch (e.getType()) {
View Full Code Here

        }
        records = RecordMerger.compactAndSort(records.iterator());
        Map<String, LogRecord> map = Maps.newHashMap();
        Iterator<LogRecord> merged = RecordMerger.merge(ImmutableList.of(new PeekingIterator<LogRecord>(records.iterator())));
        while (merged.hasNext()) {
            LogRecord r = merged.next();
            map.put(r.get_docid(), r);
        }
        return map;
    }
View Full Code Here

            b.add_to_records(r);
        }
        return b;
    }
    static LogRecord addRecord(String docid, String code) {
        LogRecord r = new LogRecord();
        r.set_deleted(false);
        r.set_docid(docid);
        r.set_index_code(code);
        return r;
    }
View Full Code Here

        r.set_docid(docid);
        r.set_index_code(code);
        return r;
    }
    static LogRecord addRecord(String docid, long id) {
        LogRecord r = new LogRecord();
        r.set_deleted(false);
        r.set_docid(docid);
        r.set_id(id);
        return r;
    }
View Full Code Here

        r.set_id(id);
        return r;
    }
   
    static LogRecord deleteRecord(String docid) {
        LogRecord r = new LogRecord();
        r.set_deleted(true);
        r.set_docid(docid);
        return r;
    }
View Full Code Here

TOP

Related Classes of com.flaptor.indextank.rpc.LogRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.