Provides list-like handling of a record index with a clearer
        error message if the index is out of bounds.
491611
def __restrictIndex(self, i):
        """"""
        if self.numRecords:
            rmax = self.numRecords - 1
            if abs(i) > rmax:
                raise IndexError("Shape or Record index out of range.")
            if i < 0: i = range(self.numRecords)[i]
        return i
762091
protected void gotoEOR(ArchiveRecord record) throws IOException {
        if (record.available() != 0) {
            throw new IOException("Record should be exhausted before coming " +
                "in here");
        }

        // Records end in 2*CRLF.  Suck it up.
        readExpectedChar(getIn(), CRLF.charAt(0));
        readExpectedChar(getIn(), CRLF.charAt(1));
        readExpectedChar(getIn(), CRLF.charAt(0));
        readExpectedChar(getIn(), CRLF.charAt(1));
    }
141829
function recordCursor(records, id) {
  var record;
  id = coerceId(id);
  for (var i = 0, len = records.length; i < len; i++) {
    record = records[i];
    if (coerceId(record.id) === id) {
      return {record: record, index: i};
    }
  }
}
396036
function (index, count) {
        validateListIndex(this, index + count - 1);

        var len = this.length - count;

        for (; index < len; index++) {
            this[index] = this[index + count];
        }

        shrinkList(this, len);
    }
552141
@Override
    protected void onRangeChanged(HasData<RecordList.Record> display) {

        // Get the new range required.
        range = display.getVisibleRange();
        //if it is the last page don't load more results
        if(display.getRowCount()%range.getLength()!= 0 && display.getRowCount() > 0 && range.getStart() > previousRange.getStart()){
            display.setVisibleRange(previousRange.getStart(), previousRange.getLength());
        }

        updateResults(range.getStart(), range.getLength());
        previousRange = range;
    }
174888
function(index, range) {
        if(!lang.isNumber(range) || (range < 0)) {
            range = 1;
        }
        this._records.splice(index, range);
        //this._length = this._length - range;
    }
671103
function handleQueryError (err) {

        queryErrorCount++;

        // Something has gone terribly wrong. Break from loop.
        if (queryErrorCount > 1) {

            // Reset all filters.
            session.list.formData = {};

            // Notify the user that an error has occured.
            req.linz.notifications.push(linz.api.views.notification({
                text: 'One of the filters is repeatedly generating an error. All filters have been removed.',
                type: 'error'
            }));

            // Rerun the query at the last known working state.
            // eslint-disable-next-line no-use-before-define
            return getModelIndex();

        }

        // Reset the last known working state.
        session.list.formData = session.list.previous.formData;

        // If we're in development mode, return the error
        // so that the developers are aware of it and can fix it.
        if (isDevelopment) {
            return next(err);
        }

        // Notify the user that an error has occured.
        req.linz.notifications.push(linz.api.views.notification({
            text: 'An error has occured with one of the filters you added. It has been removed.',
            type: 'error'
        }));

        // Rerun the query at the last known working state.
        // eslint-disable-next-line no-use-before-define
        return getModelIndex();

    }
1218810
private Row convertAvroRecordToRow(Schema schema, RowTypeInfo typeInfo, IndexedRecord record) {
		final List<Schema.Field> fields = schema.getFields();
		final TypeInformation<?>[] fieldInfo = typeInfo.getFieldTypes();
		final int length = fields.size();
		final Row row = new Row(length);
		for (int i = 0; i < length; i++) {
			final Schema.Field field = fields.get(i);
			row.setField(i, convertAvroType(field.schema(), fieldInfo[i], record.get(i)));
		}
		return row;
	}
848603
def _get_recording(self, index):
        """"""
        assert index >= 0
        recs = np.nonzero((index - self.offsets[:-1]) >= 0)[0]
        if len(recs) == 0:  # pragma: no cover
            # If the index is greater than the total size,
            # return the last recording.
            return len(self.arrs) - 1
        # Return the last recording such that the index is greater than
        # its offset.
        return recs[-1]
166595
function (index, collection) {
        assertType(index, Number);
        assertNotNull(collection);

        if (index !== this.length) {
            validateListIndex(this, index);
        }

        var arr = buffer(collection),
            count = arr.length,
            len = this.length + count;

        this.length = len;

        while (len-- > index) {
            this[len] = this[len - count];
        }

        while (count-- > 0) {
            this[index + count] = arr[count];
        }
    }
212041
private String limitString(int rowIndex){

        if(params.length != 2){
            throw new IllegalArgumentException("Wrong number of Parameters for limit string expression");
        }

        final RecordList.Record currentRecord = recordList.getRecords().get(rowIndex);
        final String field = currentRecord.getValueByFieldName(params[0]);
        int limit = Integer.parseInt(params[1]);

        if (field.isEmpty() || field.length() < limit){
            return field;
        }

        String result = field.substring(0, limit) + "...";
        return result;
    }
12622
public int moveToIndex(int index)
    {
        int index2 = index;
        int iErrorCode = DBConstants.NORMAL_RETURN;
        if (m_bIncludeBlankOption)
        {
            if (index == 0)
                iErrorCode = DBConstants.ERROR_RETURN;
            index2--; // Offset by one
        }
        if (index == -1)
            iErrorCode = DBConstants.ERROR_RETURN;
        if (iErrorCode == DBConstants.NORMAL_RETURN)
        {
            if (index2 != -1)
            {
                try
                {
                    Record record = (Record)m_gridTable.get(index2);    //?, DONT_DISPLAY);   // DON'T Display, or you will be caught in a loop
                    if (record == null)
                        iErrorCode = DBConstants.END_OF_FILE;
                }
                catch( DBException e )
                {
                    iErrorCode = e.getErrorCode();
                }
            }
            else
                iErrorCode = DBConstants.ERROR_RETURN;  // Do an addNew
        }
        else        // This is usually selecting index 0 or -1!
        {
            m_record.initRecord(DBConstants.DISPLAY);  // Clear the fields!
            iErrorCode = DBConstants.NORMAL_RETURN;   // Clear fields = record 0
        }
        return iErrorCode;
    }
577562
@Override
    protected void onRangeChanged(HasData<RecordList.Record> display) {
        // Get the new range required.
        range = display.getVisibleRange();
        updateResults(range.getStart(), range.getLength());
    }
1094648
def fix(source_key, rownum, line, source, sample_only_filter, sample_size):
    
    value = json2value(line)

    if rownum == 0:
        if len(line) > MAX_RECORD_LENGTH:
            _shorten(source_key, value, source)
        value = _fix(value)
        if sample_only_filter and Random.int(int(1.0/coalesce(sample_size, 0.01))) != 0 and jx.filter([value], sample_only_filter):
            # INDEX etl.id==0, BUT NO MORE
            if value.etl.id != 0:
                Log.error("Expecting etl.id==0")
            row = {"value": value}
            return row, True
    elif len(line) > MAX_RECORD_LENGTH:
        _shorten(source_key, value, source)
        value = _fix(value)
    elif '"resource_usage":' in line:
        value = _fix(value)

    row = {"value": value}
    return row, False
1219538
def limit_records(records)
      offset = self.offset
      limit  = self.limit
      size   = records.size

      if offset > size - 1
        []
      elsif (limit && limit != size) || offset > 0
        records[offset, limit || size] || []
      else
        records.dup
      end
    end
201616
def out_of_bounds(self, index):
        
        if type(index) is int:
            return self.int_out_of_bounds(index)

        elif type(index) is slice:
            return self.slice_out_of_bounds(index)

        elif type(index) is tuple:

            local_index = []

            for k, item in enumerate(index):

                if type(item) is slice:
                    temp_index = self.slice_out_of_bounds(item, k)

                elif type(item) is int:
                    temp_index = self.int_out_of_bounds(item, k)
                # FIXME: will fail if item is no int or slice!
                if temp_index is None:
                    return temp_index

                local_index.append(temp_index)

            return tuple(local_index)
978594
private void processRecordsWithRetries(List<Record> records) {
        for (Record record : records) {
            boolean processedSuccessfully = false;
            for (int i = 0; i < NUM_RETRIES; i++) {
                try {
                    //
                    // Logic to process record goes here.
                    //
                    processSingleRecord(record);

                    processedSuccessfully = true;
                    break;
                } catch (Throwable t) {
                    LOG.warn("Caught throwable while processing record " + record, t);
                }

                // backoff if we encounter an exception.
                try {
                    Thread.sleep(BACKOFF_TIME_IN_MILLIS);
                } catch (InterruptedException e) {
                    LOG.debug("Interrupted sleep", e);
                }
            }

            if (!processedSuccessfully) {
                LOG.error("Couldn't process record " + record + ". Skipping the record.");
            }
        }
    }