// NewIndexWriter returns a new IndexWriter.
1810
func NewIndexWriter() IndexWriter {
	buf := bytes.NewBuffer(make([]byte, 0, 1024*1024))
	return &directIndex{buf: buf, w: bufio.NewWriter(buf)}
}
34622
func (excel *Excel) NewWriter(res *exchange.Resource, context *qor.Context) (exchange.Writer, error) {
	writer := &Writer{Excel: excel, Resource: res, context: context, sheetName: excel.config.SheetName}

	var metas []*exchange.Meta
	for _, meta := range res.Metas {
		if meta.HasPermission(roles.Read, context) {
			metas = append(metas, meta)
		}
	}

	writer.metas = metas

	excelWriter, err := excel.getWriter()

	if err == nil {
		if writer.sheetName == "" {
			writer.sheetName = "Sheet1"
		}

		if !excelWriter.GetSheetVisible(writer.sheetName) {
			idx := excelWriter.NewSheet(writer.sheetName)
			excelWriter.SetActiveSheet(idx)
		}

		writer.Writer = excelWriter
	}

	return writer, err
}
1273420
func NewWriter(w io.Writer) (io.Writer, error) {
	tr, err := toCp949()
	if err != nil {
		return nil, err
	}

	return &cp949Writer{w: w, tr: tr}, nil
}
695543
func NewNGramIndex(opts ...Option) (*NGramIndex, error) {
	ngram := new(NGramIndex)
	for _, opt := range opts {
		if err := opt(ngram); err != nil {
			return nil, err
		}
	}
	ngram.init()
	return ngram, nil
}
1063108
func NewWriter(w io.Writer, limiter Limiter) io.Writer {
	return &writer{w, limiter}
}
284614
func (s *S3) NewWriter(id string) (io.WriteCloser, error) {
	return s.bucket.PutWriter(s.Prefixed.Name(id), nil, nil)
}
134454
func (tf tFiles) newIndexIterator(tops *tOps, icmp *iComparer, slice *util.Range, ro *opt.ReadOptions) iterator.IteratorIndexer {
	if slice != nil {
		var start, limit int
		if slice.Start != nil {
			start = tf.searchMax(icmp, internalKey(slice.Start))
		}
		if slice.Limit != nil {
			limit = tf.searchMin(icmp, internalKey(slice.Limit))
		} else {
			limit = tf.Len()
		}
		tf = tf[start:limit]
	}
	return iterator.NewArrayIndexer(&tFilesArrayIndexer{
		tFiles: tf,
		tops:   tops,
		icmp:   icmp,
		slice:  slice,
		ro:     ro,
	})
}
58648
func newLiveIndexWriterConfig(analyzer analysis.Analyzer,
	matchVersion util.Version) *LiveIndexWriterConfigImpl {

	assert(DefaultSimilarity != nil)
	assert(DefaultCodec != nil)
	return &LiveIndexWriterConfigImpl{
		analyzer:                analyzer,
		matchVersion:            matchVersion,
		ramBufferSizeMB:         DEFAULT_RAM_BUFFER_SIZE_MB,
		maxBufferedDocs:         DEFAULT_MAX_BUFFERED_DOCS,
		maxBufferedDeleteTerms:  DEFAULT_MAX_BUFFERED_DELETE_TERMS,
		readerTermsIndexDivisor: DEFAULT_READER_TERMS_INDEX_DIVISOR,
		termIndexInterval:       DEFAULT_TERM_INDEX_INTERVAL, // TODO: this should be private to the codec, not settable here
		delPolicy:               DEFAULT_DELETION_POLICY,
		useCompoundFile:         DEFAULT_USE_COMPOUND_FILE_SYSTEM,
		openMode:                OPEN_MODE_CREATE_OR_APPEND,
		similarity:              DefaultSimilarity(),
		mergeScheduler:          NewConcurrentMergeScheduler(),
		writeLockTimeout:        WRITE_LOCK_TIMEOUT,
		_indexingChain:          defaultIndexingChain,
		codec:                   DefaultCodec(),
		infoStream:              util.DefaultInfoStream(),
		mergePolicy:             NewTieredMergePolicy(),
		_flushPolicy:            newFlushByRamOrCountsPolicy(),
		readerPooling:           DEFAULT_READER_POOLING,
		_indexerThreadPool:      NewDocumentsWriterPerThreadPool(DEFAULT_MAX_THREAD_STATES),
		perRoutineHardLimitMB:   DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB,
		checkIntegrityAtMerge:   DEFAULT_CHECK_INTEGRITY_AT_MERGE,
	}
}
54484
func NewErrWriter(w io.Writer) io.Writer {
	return errWriter{ansiterm.NewWriter(w)}
}
11539
func NewWriter(w io.Writer) *Writer {
	return &Writer{cw: &countWriter{w: bufio.NewWriter(w)}}
}
1280235
func NewWriter(w io.Writer, bo binary.ByteOrder) Writer {
	return &writer{
		w:  w,
		bo: bo,
	}
}
1218081
func NewIndex(physicalID int64, tblInfo *model.TableInfo, indexInfo *model.IndexInfo) table.Index {
	index := &index{
		idxInfo: indexInfo,
		tblInfo: tblInfo,
		// The prefix can't encode from tblInfo.ID, because table partition may change the id to partition id.
		prefix: tablecodec.EncodeTableIndexPrefix(physicalID, indexInfo.ID),
	}
	return index
}
54942
func NewWriter(w io.Writer) *Writer {
	enc := New()
	return &Writer{e: *enc, w: csv.NewWriter(w)}
}
621222
func NewWriter(writer io.WriteSeeker, hash func([]byte) uint32) (*Writer, error) {
	// Leave 256 * 8 bytes for the index at the head of the file.
	_, err := writer.Seek(0, os.SEEK_SET)
	if err != nil {
		return nil, err
	}

	_, err = writer.Write(make([]byte, indexSize))
	if err != nil {
		return nil, err
	}

	if hash == nil {
		hash = cdbHash
	}

	return &Writer{
		hash:           hash,
		writer:         writer,
		bufferedWriter: bufio.NewWriterSize(writer, 65536),
		bufferedOffset: indexSize,
	}, nil
}
60470
func (engine *Engine) CreateIndexes(bean interface{}) error {
	session := engine.NewSession()
	defer session.Close()
	return session.CreateIndexes(bean)
}
1039724
func NewIndex(path, name string) (*Index, error) {
	err := validateName(name)
	if err != nil {
		return nil, errors.Wrap(err, "validating name")
	}

	return &Index{
		path:   path,
		name:   name,
		fields: make(map[string]*Field),

		newAttrStore: newNopAttrStore,
		columnAttrs:  nopStore,

		broadcaster:    NopBroadcaster,
		Stats:          stats.NopStatsClient,
		logger:         logger.NopLogger,
		trackExistence: true,
	}, nil
}
1054277
func NewWriter(rc io.WriteCloser) io.WriteCloser {
	return bufWriteCloser{bufio.NewWriter(rc), rc}
}