Save a position in this collection.

        :param mark: The position to save
        :type mark: Mark
        :raises: DBError, NoTrackingCollection
548756
def save(self, mark):
        
        self._check_exists()
        obj = mark.as_dict()
        try:
            # Make a 'filter' to find/update existing record, which uses
            # the field name and operation (but not the position).
            filt = {k: obj[k] for k in (mark.FLD_FLD, mark.FLD_OP)}
            _log.debug("save: upsert-spec={} upsert-obj={}".format(filt, obj))
            self._track.update(filt, obj, upsert=True)
        except pymongo.errors.PyMongoError as err:
            raise DBError("{}".format(err))
888528
def _save(self, objects, old_pos, new_pos):
        """"""
        to_shift = objects.exclude(pk=self.pk) if self.pk else objects

        # If not set, insert at end.
        if self.sort_order is None:
            self._move_to_end(objects)

        # New insert.
        elif not self.pk and not old_pos:
            # Increment `sort_order` on objects with:
            #     sort_order > new_pos.
            to_shift = to_shift.filter(sort_order__gte=self.sort_order)
            self._update(to_shift)
            self.sort_order = new_pos

        # self.sort_order decreased.
        elif old_pos and new_pos < old_pos:
            self._move_to_end(objects)
            super(Orderable, self).save()
            # Increment `sort_order` on objects with:
            #     sort_order >= new_pos and sort_order < old_pos
            to_shift = to_shift.filter(sort_order__gte=new_pos, sort_order__lt=old_pos)
            self._update(to_shift)
            self.sort_order = new_pos

        # self.sort_order increased.
        elif old_pos and new_pos > old_pos:
            self._move_to_end(objects)
            super(Orderable, self).save()
            # Decrement sort_order on objects with:
            #     sort_order <= new_pos and sort_order > old_pos.
            to_shift = to_shift.filter(sort_order__lte=new_pos, sort_order__gt=old_pos)
            to_shift.update(sort_order=models.F('sort_order') - 1)
            self.sort_order = new_pos
1003558
final private void addPositionFromToken(MtasToken token, Long ref)
      throws IOException {
    int prefixId = storePrefixAndTermRef ? token.getPrefixId() : 0;
    if (!closed && (token != null)) {
      if (token.checkPositionType(MtasPosition.POSITION_SINGLE)) {
        addSinglePoint(token.getPositionStart(), prefixId, token.getTermRef(),
            token.getId(), ref);
      } else if (token.checkPositionType(MtasPosition.POSITION_RANGE)) {
        addRange(token.getPositionStart(), token.getPositionEnd(), prefixId,
            token.getTermRef(), token.getId(), ref);
      } else if (token.checkPositionType(MtasPosition.POSITION_SET)) {
        // split set into minimum number of single points and ranges
        SortedMap<Integer, Integer> list = new TreeMap<>();
        int[] positions = token.getPositions();
        Integer lastPoint = null;
        Integer startPoint = null;
        for (int position : positions) {
          if (lastPoint == null) {
            startPoint = position;
            lastPoint = position;
          } else if ((position - lastPoint) != 1) {
            list.put(startPoint, lastPoint);
            startPoint = position;
          }
          lastPoint = position;
        }
        if (lastPoint != null) {
          list.put(startPoint, lastPoint);
        }
        for (Entry<Integer, Integer> entry : list.entrySet()) {
          if (entry.getKey().equals(entry.getValue())) {
            addSinglePoint(entry.getKey(), prefixId, token.getTermRef(),
                token.getId(), ref);
          } else {
            addRange(entry.getKey(), entry.getValue(), prefixId,
                token.getTermRef(), token.getId(), ref);
          }
        }
      }
    }
  }
388452
def set_marktype_cb(self, w, index):
        """"""
        self.marktype = self._mark_options[index]

        # Mark size is not used for point
        if self.marktype != 'point':
            self.w.mark_size.set_enabled(True)
        else:
            self.w.mark_size.set_enabled(False)
386135
def save(self, **edgeArgs) :
        """"""

        if not getattr(self, "_from") or not getattr(self, "_to") :
            raise AttributeError("You must specify '_from' and '_to' attributes before saving. You can also use the function 'links()'")

        payload = self._store.getStore()
        payload["_from"] = self._from
        payload["_to"] = self._to
        Document._save(self, payload, **edgeArgs)
902845
def _save_trace(self):
        
        stack_trace = stack()
        try:
            self.trace = []
            for frm in stack_trace[5:]: # eliminate our own overhead
                self.trace.insert(0, frm[1:])
        finally:
            del stack_trace
990996
def set_last_position(self, last_position):
        
        if last_position:
            if isinstance(last_position, six.string_types):
                last_key = last_position
            else:
                last_key = last_position.get('last_key', '')
            self.last_position = dict(last_key=last_key)
            self.collection_scanner.set_startafter(last_key)
        else:
            self.last_position = {}
102136
def jump_to(self, mark, offset=0):
        """"""
        self._offset = self._bookmarks[mark] + offset
1341062
def save_excursion
      old_point = new_mark
      old_mark = @mark&.dup
      old_column = @goal_column
      begin
        yield
      ensure
        point_to_mark(old_point)
        old_point.delete
        if old_mark
          @mark.location = old_mark.location
          old_mark.delete
        end
        @goal_column = old_column
      end
    end
951483
def save_position(self):
        
        # save text cursor position:
        self.old_text_pos = self.index(tkinter.INSERT)
        # save scroll position:
        self.old_first, self.old_last = self.yview()
529671
def mark_bl(self) -> int:
        
        counter = 0
        stringy_lines = find_stringy_lines(self.node, self.first_line_no)
        for relative_line_number, line in enumerate(self.lines):
            if relative_line_number not in stringy_lines and line.strip() == '':
                counter += 1
                self.line_markers[relative_line_number] = LineType.blank_line

        return counter
473928
def store_catserrange   # :nodoc:
    record   = 0x1020     # Record identifier.
    length   = 0x0008     # Number of bytes to follow.
    catCross = 0x0001     # Value/category crossing.
    catLabel = 0x0001     # Frequency of labels.
    catMark  = 0x0001     # Frequency of ticks.
    grbit    = 0x0001     # Option flags.

    store_simple(record, length, catCross, catLabel, catMark, grbit)
  end
411628
def mark(self):
        
        self.reliableListener.lastRun = extime.Time()
        BatchProcessingError(
            store=self.reliableListener.store,
            processor=self.reliableListener.processor,
            listener=self.reliableListener.listener,
            item=self.workUnit,
            error=self.failure.getErrorMessage())
298501
async def save(self, db=None):
        '''
        
        '''
        self._db = db or self.db
        data = self.prepare_data()
        # validate object
        self.validate()
        # connect to DB to save the model
        for i in self.connection_retries():
            try:
                created = False if '_id' in data else True
                result = await self.db[self.get_collection_name()].insert_one(data)
                self._id = result.inserted_id
                # emit post save
                asyncio.ensure_future(post_save.send(
                    sender=self.__class__,
                    db=self.db,
                    instance=self,
                    created=created)
                )
                break
            except ConnectionFailure as ex:
                exceed = await self.check_reconnect_tries_and_wait(i, 'save')
                if exceed:
                    raise ex
1053203
def record(self, tags=None):
        
        if tags is None:
            tags = TagContext.get()
        if self._invalid:
            logger.warning("Measurement map has included negative value "
                           "measurements, refusing to record")
            return
        for measure, value in self.measurement_map.items():
            if value < 0:
                self._invalid = True
                logger.warning("Dropping values, value to record must be "
                               "non-negative")
                logger.info("Measure '{}' has negative value ({}), refusing "
                            "to record measurements from {}"
                            .format(measure.name, value, self))
                return

        self.measure_to_view_map.record(
                tags=tags,
                measurement_map=self.measurement_map,
                timestamp=utils.to_iso_str(),
                attachments=self.attachments
        )
321398
def save(self):
        

        api = Client.instance().api

        index_details = {
            'type': self.index_type_obj.type_name
        }

        extra_index_attributes = self.index_type_obj.get_extra_attributes()

        for extra_attribute_key in extra_index_attributes:
            extra_attribute_value = extra_index_attributes[extra_attribute_key]
            index_details[extra_attribute_key] = extra_attribute_value

        query_parameters = {
            'collection': self.collection.name,
        }

        result = api.index.post(data=index_details, **query_parameters)

        self.index_type_obj.is_new = result['isNewlyCreated']
        self.index_type_obj.id = result['id']
446267
def set_tag(self, key, value):
        
        with self.update_lock:
            if key == ext_tags.SAMPLING_PRIORITY and not self._set_sampling_priority(value):
                return self
            if self.is_sampled():
                tag = thrift.make_tag(
                    key=key,
                    value=value,
                    max_length=self.tracer.max_tag_value_length, )
                self.tags.append(tag)
        return self