<commit_before>//$Id: Record.h 3513 2013-06-29 00:27:49Z jamshid.esmaelnezhad $

/*
 * The Software is made available solely for use according to the License Agreement. Any reproduction
 * or redistribution of the Software not in accordance with the License Agreement is expressly prohibited
 * by law, and may result in severe civil and criminal penalties. Violators will be prosecuted to the
 * maximum extent possible.
 *
 * THE SOFTWARE IS WARRANTED, IF AT ALL, ONLY ACCORDING TO THE TERMS OF THE LICENSE AGREEMENT. EXCEPT
 * AS WARRANTED IN THE LICENSE AGREEMENT, SRCH2 INC. HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS WITH
 * REGARD TO THE SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT.  IN NO EVENT SHALL SRCH2 INC. BE LIABLE FOR ANY
 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
 * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF SOFTWARE.

 * Copyright © 2010 SRCH2 Inc. All rights reserved
 */

#ifndef __RECORD_H__
#define __RECORD_H__

#include <instantsearch/platform.h>
#include <instantsearch/Constants.h>

#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
namespace srch2
{
namespace instantsearch
{
class Schema;

struct StoredRecordBuffer {
  boost::shared_ptr<const char> start;
  size_t length;
  StoredRecordBuffer() { start.reset(); length = 0; }
  StoredRecordBuffer(const char* s, size_t l) {
	  start.reset(s); length = l;
  }
  StoredRecordBuffer(const boost::shared_ptr<const char>& s, size_t l) {
  	  start = s; length = l;
  }
};

/**
 * This class defines a data record passed to the Indexer. The Schema
 * class defines the structure of the record.
 */
class MYLIB_EXPORT Record
{
public:

    /**<commit_msg>Fix the Freeing mismatched memory bug<commit_after>//$Id: Record.h 3513 2013-06-29 00:27:49Z jamshid.esmaelnezhad $

/*
 * The Software is made available solely for use according to the License Agreement. Any reproduction
 * or redistribution of the Software not in accordance with the License Agreement is expressly prohibited
 * by law, and may result in severe civil and criminal penalties. Violators will be prosecuted to the
 * maximum extent possible.
 *
 * THE SOFTWARE IS WARRANTED, IF AT ALL, ONLY ACCORDING TO THE TERMS OF THE LICENSE AGREEMENT. EXCEPT
 * AS WARRANTED IN THE LICENSE AGREEMENT, SRCH2 INC. HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS WITH
 * REGARD TO THE SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT.  IN NO EVENT SHALL SRCH2 INC. BE LIABLE FOR ANY
 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
 * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF SOFTWARE.

 * Copyright © 2010 SRCH2 Inc. All rights reserved
 */

#ifndef __RECORD_H__
#define __RECORD_H__

#include <instantsearch/platform.h>
#include <instantsearch/Constants.h>

#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
namespace srch2
{
namespace instantsearch
{
class Schema;

/*
 * This array_deleter is overwriting the destructor of the shared pointer.
 * The default destructor of shared pointer is "delete p" which is not
 * correct if the pointer points to an array.
 */
template< typename T >
struct array_deleter
{
  void operator ()( T const * p)
  {
    delete[] p;
  }
};

struct StoredRecordBuffer {
  boost::shared_ptr<const char> start;
  size_t length;
  StoredRecordBuffer() { start.reset(); length = 0; }
  StoredRecordBuffer(const char* s, size_t l) {
	  start.reset(s, array_deleter<const char>()); length = l;
  }
  StoredRecordBuffer(const boost::shared_ptr<const char>& s, size_t l) {
  	  start = s; length = l;
  }
};

/**
 * This class defines a data record passed to the Indexer. The Schema
 * class defines the structure of the record.
 */
class MYLIB_EXPORT Record
{
public:

    /**
{'fraction_non_alphanumeric': 0.07397653818530045, 'fraction_numerical': 0.012927938711994253, 'mean_word_length': 4.268600252206809, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5299937', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1179, 'n_words': 525}