Copy attributes, reset index due because information about deleted
    documents has been lost, and power up for IFulltextIndexer so other code
    can find this item.
173399
def pyLuceneIndexer4to5(old):
    
    new = old.upgradeVersion(PyLuceneIndexer.typeName, 4, 5,
                             indexCount=old.indexCount,
                             installedOn=old.installedOn,
                             indexDirectory=old.indexDirectory)
    new.reset()
    new.store.powerUp(new, ixmantissa.IFulltextIndexer)
    return new
700928
@Override
    public boolean replaceRef(Object oldRef, Object newRef)
        throws IOException
    {
        if (_isUnshared) {
            return false;
        }

        int value = _refs.get(oldRef);

        if (value >= 0) {
            addRef(newRef, value, true);

            _refs.remove(oldRef);

            return true;
        }
        else
            return false;
    }
304735
def reset_index(self, **kwargs):
        
        drop = kwargs.get("drop", False)
        new_index = pandas.RangeIndex(len(self.index))
        if not drop:
            if isinstance(self.index, pandas.MultiIndex):
                # TODO (devin-petersohn) ensure partitioning is properly aligned
                new_column_names = pandas.Index(self.index.names)
                new_columns = new_column_names.append(self.columns)
                index_data = pandas.DataFrame(list(zip(*self.index))).T
                result = self.data.from_pandas(index_data).concat(1, self.data)
                return self.__constructor__(result, new_index, new_columns)
            else:
                new_column_name = (
                    self.index.name
                    if self.index.name is not None
                    else "index"
                    if "index" not in self.columns
                    else "level_0"
                )
                new_columns = self.columns.insert(0, new_column_name)
                result = self.insert(0, new_column_name, self.index)
                return self.__constructor__(result.data, new_index, new_columns)
        else:
            # The copies here are to ensure that we do not give references to
            # this object for the purposes of updates.
            return self.__constructor__(
                self.data.copy(), new_index, self.columns.copy(), self._dtype_cache
            )
227648
def go_to_index(self, index):
        
        return CompletionState(self.original_document, self.current_completions, complete_index=index)
369100
def search_update_index(self):
        
        doc_id = self.search_get_document_id(self.key)

        fields = [search.AtomField('class_name', name) for name in self.search_get_class_names()]

        index = self.search_get_index()

        if self.searchable_fields is None:
            searchable_fields = []

            for field, prop in self._properties.items():
                if field == 'class':
                    continue
                for class_, field_type in SEARCHABLE_PROPERTY_TYPES.items():
                    if isinstance(prop, class_):
                        searchable_fields.append(field)
        else:
            searchable_fields = self.searchable_fields

        for f in set(searchable_fields):
            prop = self._properties[f]
            value = getattr(self, f)
            field = None
            field_found = False
            for class_, field_type in SEARCHABLE_PROPERTY_TYPES.items():
                if isinstance(prop, class_):
                    field_found = True
                    if value is not None:
                        if isinstance(value, list) or isinstance(value, tuple) or isinstance(value, set):
                            for v in value:
                                field = field_type(name=f, value=v)
                        elif isinstance(value, ndb.Key):
                            field = field_type(name=f, value=value.urlsafe())
                        else:
                            field = field_type(name=f, value=value)
            if not field_found:
                raise ValueError('Cannot find field type for %r on %r' % (prop, self.__class__))

            if field is not None:
                fields.append(field)

        document = search.Document(doc_id, fields=fields)
        index.put(document)
675702
public void restoreAttributes()
    {
        String attrName = getScopedName( STORED_ATTRS_ATTR );
        Map savedAttrs = ( Map ) getSession().getAttribute( attrName );

        if ( savedAttrs != null )
        {
            setAttributeMap( savedAttrs );
        }
    }
911135
def replace(self, resource, id_, document):
        """"""
        args = self._es_args(resource, refresh=True)
        document.pop('_id', None)
        document.pop('_type', None)
        self._update_parent_args(resource, args, document)
        return self.elastic(resource).index(body=document, id=id_, **args)
30099
def _reset_docs(self):
        
        _LOGGER.debug("resetting documents")
        self.change_map.clear()
        self.resume_token = None

        # Mark each document as deleted. If documents are not deleted
        # they will be sent again by the server.
        for snapshot in self.doc_tree.keys():
            name = snapshot.reference._document_path
            self.change_map[name] = ChangeType.REMOVED

        self.current = False
474115
private void doUpdate() throws PageException, SearchException, IOException {
	// check attributes
	required("index", action, "collection", collection);
	required("index", action, "key", key);

	if (type == -1) type = (query == null) ? SearchIndex.TYPE_FILE : SearchIndex.TYPE_CUSTOM;

	if (type == SearchIndex.TYPE_CUSTOM) {
	    required("index", action, "body", body);
	    // required("index",action,"query",query);
	}
	IndexResult result;

	result = collection.index(pageContext, key, type, urlpath, title, body, language, extensions, query, recurse, categoryTree, category, timeout, custom1, custom2, custom3,
		custom4);
	if (!StringUtil.isEmpty(status)) pageContext.setVariable(status, toStruct(result));
    }
896453
public void destroyIndexes() {
        InternalIndex[] indexesSnapshot = getIndexes();

        indexes = EMPTY_INDEXES;
        compositeIndexes = EMPTY_INDEXES;
        indexesByName.clear();
        attributeIndexRegistry.clear();
        converterCache.clear();

        for (InternalIndex index : indexesSnapshot) {
            index.destroy();
        }
    }
292151
def drop_index(self, keep_model=True):
        """"""
        modelstr = "" if keep_model else "and model "
        logger.info("deleting similarity index " + modelstr + "from %s" % self.basename)

        # delete indexes
        for index in [self.fresh_index, self.opt_index]:
            if index is not None:
                index.terminate()
        self.fresh_index, self.opt_index = None, None

        # delete payload
        if self.payload is not None:
            self.payload.close()

            fname = self.location('payload')
            try:
                if os.path.exists(fname):
                    os.remove(fname)
                    logger.info("deleted %s" % fname)
            except Exception, e:
                logger.warning("failed to delete %s" % fname)
        self.payload = SqliteDict(self.location('payload'), autocommit=True, journal_mode=JOURNAL_MODE)

        # optionally, delete the model as well
        if not keep_model and self.model is not None:
            self.model.close()
            fname = self.location('model')
            try:
                if os.path.exists(fname):
                    os.remove(fname)
                    logger.info("deleted %s" % fname)
            except Exception, e:
                logger.warning("failed to delete %s" % fname)
            self.model = None
        self.flush(save_index=True, save_model=True, clear_buffer=True)
233746
protected void doUpdateIndex(Set<String> removedNodes, Set<String> addedNodes, Set<String> parentRemovedNodes,
      Set<String> parentAddedNodes)
   {
      ChangesHolder changes = searchManager.getChanges(removedNodes, addedNodes);
      ChangesHolder parentChanges = parentSearchManager.getChanges(parentRemovedNodes, parentAddedNodes);

      if (changes == null && parentChanges == null)
      {
         return;
      }

      try
      {
         doUpdateIndex(new ChangesFilterListsWrapper(changes, parentChanges));
      }
      catch (RuntimeException e)
      {
         if (isTXAware())
         {
            // The indexing is part of the global tx so the error needs to be thrown to
            // allow to roll back other resources
            throw e;
         }
         getLogger().error(e.getLocalizedMessage(), e);
         logErrorChanges(handler, removedNodes, addedNodes);
         logErrorChanges(parentHandler, parentRemovedNodes, parentAddedNodes);
      }
   }
380956
def setdocument(self, doc):
        
        assert isinstance(doc, Document)

        if not self.doc:
            self.doc = doc
            if self.id:
                if self.id in doc:
                    raise DuplicateIDError(self.id)
                else:
                    self.doc.index[id] = self

        for e in self: #recursive for all children
            if isinstance(e,AbstractElement): e.setdocument(doc)
67153
private <X> void copy(X[] elementsCopy) {
		if (!isEmpty()) {
			if (firstIndex < lastIndex) {
				System.arraycopy(elements, firstIndex, elementsCopy, 0, lastIndex - firstIndex);
			} else {
				int firstSize = elements.length - firstIndex;
				System.arraycopy(elements, firstIndex, elementsCopy, 0, firstSize);
				System.arraycopy(elements, 0, elementsCopy, firstSize, lastIndex);
			}
		}
	}
1073240
def _reset_attr(self, name, func=None, doc=None, preload=False):
        ""

        keys = set(self)
        if name not in keys:
            try:
                data, funcs = zip(*[
                    (
                        (
                            key, (
                                getattr(self._attr_data_, key)
                                if hasattr(self._attr_data_, key)
                                else None
                            )
                        ),
                        (
                            key, (
                                getattr(self._attr_func_, key)
                                if hasattr(self._attr_func_, key)
                                else None
                            )
                        ),
                    )
                    for key in keys
                ])

                keys.add(name)
                self._attr_data_ = keys
                self._attr_func_ = keys

                [
                    setattr(self._attr_data_, key,  value)
                    for key, value in data
                    if value is not None
                ]
                [
                    setattr(self._attr_func_, key,  value)
                    for key, value in funcs
                    if value is not None
                ]

            except ValueError:
                keys.add(name)
                self._attr_data_ = keys
                self._attr_func_ = keys

        if hasattr(self._attr_data_, name):
            delattr(self._attr_data_, name)

        if func is not None:
            setattr(self._attr_func_, name, func)

        elif hasattr(self._attr_func_, name):
            delattr(self._attr_func_, name)

        self._set_attr(name, doc, preload)
991007
def replaceItemAtIndex(self, newItem, oldItemIndex):
        
        oldItem = self.getItem(oldItemIndex)
        childNumber = oldItem.childNumber()
        parentIndex = oldItemIndex.parent()
        self.deleteItemAtIndex(oldItemIndex)
        insertedIndex = self.insertItem(newItem, position=childNumber, parentIndex=parentIndex)
        return insertedIndex
818434
def reset(self):
        
        self.current_table = None
        self.tables = []
        self.data = [{}]
        self.additional_data = {}
        self.lines = []
        self.set_state('document')
        self.current_file = None
        self.set_of_energies = set()