<commit_before>//
//  block_chain.h
//  Argos
//
//  Created by Windoze on 12-7-9.
//  Copyright (c) 2012 0d0a.<EMAIL>. All rights reserved.
//

#include <stddef.h>
#include <stdint.h>
#include <iterator>
#include "common/argos_consts.h"
#include "common/mem_pool.h"

#ifndef Argos_block_list_h
#define Argos_block_list_h

namespace argos {
    namespace common {
        const int BLOCK_ELEMENTS=60;

        /**
         * Template block_chain use to store doc vector
         */
        template<typename T>
        struct block_chain
        {
            // STL container compliance
            typedef T value_type;
            typedef block_chain<T> this_t;
            typedef size_t size_type;
            typedef value_type *pointer;
            typedef value_type &reference;
            typedef const value_type &const_reference;
            
            struct header {
                uint32_t size;
                uint32_t block_count;
                common::OFFSET head;
                common::OFFSET tail;
            };
            
            struct block {
                uint32_t size;
                value_type content[BLOCK_ELEMENTS];
                common::OFFSET next;
                bool empty() const { return size==0; }
                bool full() const { return size==BLOCK_ELEMENTS; }
                void push_back(value_type v) {
                    content[size]=v;
                    size++;
                }
            };
            
            typedef common::offptr_t<block> block_ptr_t;
            typedef common::offptr_t<header> header_ptr_t;
            
            struct iterator {
                typedef block_chain::value_type value_type;
                typedef block_chain::pointer pointer;
                typedef block_chain::reference reference;
                typedef block_chain::const_reference const_reference;
                typedef std::input_iterator_tag iterator_category;
                
                inline iterator()
                : pool_(0)
                , chain_(common::INVALID_OFFSET)
                , current_block_(common::INVALID_OFFSET)
                , idx_in_current_block_(0)
                , count_(0)
                , max_(0)
                {}
                
                inline iterator(const block_chain *chain)
                : pool_(chain->pool_)<commit_msg>A real world index indicates 60 is too big to be default block size<commit_after>//
//  block_chain.h
//  Argos
//
//  Created by Windoze on 12-7-9.
//  Copyright (c) 2012 0d0a.com. All rights reserved.
//

#include <stddef.h>
#include <stdint.h>
#include <iterator>
#include "common/argos_consts.h"
#include "common/mem_pool.h"

#ifndef Argos_block_list_h
#define Argos_block_list_h

namespace argos {
    namespace common {
        /**
         * Template block_chain use to store doc vector
         */
        template<typename T, int BLOCK_ELEMENTS=10>
        struct block_chain
        {
            // STL container compliance
            typedef T value_type;
            typedef block_chain<T> this_t;
            typedef size_t size_type;
            typedef value_type *pointer;
            typedef value_type &reference;
            typedef const value_type &const_reference;
            
            struct header {
                uint32_t size;
                uint32_t block_count;
                common::OFFSET head;
                common::OFFSET tail;
            };
            
            struct block {
                bool empty() const { return size==0; }
                bool full() const { return size==BLOCK_ELEMENTS; }
                void push_back(value_type v) {
                    content[size]=v;
                    size++;
                }
                uint32_t size;
                common::OFFSET next;
                value_type content[BLOCK_ELEMENTS];
            };
            
            typedef common::offptr_t<block> block_ptr_t;
            typedef common::offptr_t<header> header_ptr_t;
            
            struct iterator {
                typedef block_chain::value_type value_type;
                typedef block_chain::pointer pointer;
                typedef block_chain::reference reference;
                typedef block_chain::const_reference const_reference;
                typedef std::input_iterator_tag iterator_category;
                
                inline iterator()
                : pool_(0)
                , chain_(common::INVALID_OFFSET)
                , current_block_(common::INVALID_OFFSET)
                , idx_in_current_block_(0)
                , count_(0)
                , max_(0)
                {}
                
                inline iterator(const block_chain *chain)
                : pool_(chain->pool_)
{'fraction_non_alphanumeric': 0.07613469985358712, 'fraction_numerical': 0.010039740640033466, 'mean_word_length': 1.4323499491353, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6691280', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1195, 'n_words': 287}