By default we look at first 10 records
331229
@Override
  public int run() throws IOException {
    Preconditions.checkArgument(samplePaths != null && !samplePaths.isEmpty(),
        "Sample JSON path is required");
    Preconditions.checkArgument(samplePaths.size() == 1,
        "Only one JSON sample can be given");

    // assume fields are nullable by default, users can easily change this
    Schema sampleSchema = JsonUtil.inferSchema(
        open(samplePaths.get(0)), recordName, numRecords);

    if (sampleSchema != null) {
      output(sampleSchema.toString(!minimize), console, outputPath);
      return 0;
    } else {
      console.error("Sample file did not contain any records");
      return 1;
    }
  }
946913
def previous_row(self):
        """"""
        row = self.currentIndex().row()
        rows = self.proxy_model.rowCount()
        if row == 0:
            row = rows
        self.selectRow(row - 1)
1315078
def find(*args, **kwargs):
    
    # default end_at to now and start to 1 day from now
    end_at = kwargs.get('end_at', datetime.datetime.now())
    start_at = kwargs.get('start_at', end_at - datetime.timedelta(days=1))

    # default # of records to fetch to be 50
    limit = kwargs.get('limit', 50)

    # if no user is defined, fetch for ALL
    user = kwargs.get('user', None)
    if user:
        return request_log.find(start_at, end_at, limit, spec={'user': user})
    else:
        return request_log.find(start_at, end_at, limit)
725617
private void setIndex() {
		int DataCounter, PBASCounter, PLOCCounter, PCONCounter, NumRecords, indexBase;
		byte[] RecNameArray = new byte[4];
		String RecName;

		DataCounter = 0;
		PBASCounter = 0;
		PLOCCounter = 0;
		PCONCounter = 0;

		indexBase = getIntAt(absIndexBase + macJunk);
		NumRecords = getIntAt(absIndexBase - 8 + macJunk);

		for (int record = 0; record <= NumRecords - 1; record++) {
			getSubArray(RecNameArray, (indexBase + (record * 28)));
			RecName = new String(RecNameArray);
			if (RecName.equals("FWO_"))
				FWO = indexBase + (record * 28) + 20;
			if (RecName.equals("DATA")) {
				++DataCounter;
				if (DataCounter == 9)
					DATA9 = indexBase + (record * 28) + 20;
				if (DataCounter == 10)
					DATA10 = indexBase + (record * 28) + 20;
				if (DataCounter == 11)
					DATA11 = indexBase + (record * 28) + 20;
				if (DataCounter == 12)
					DATA12 = indexBase + (record * 28) + 20;
			}
			if (RecName.equals("PBAS")) {
				++PBASCounter;
				if (PBASCounter == 2)
					PBAS2 = indexBase + (record * 28) + 20;
			}
			if (RecName.equals("PLOC")) {
				++PLOCCounter;
				if (PLOCCounter == 2)
					PLOC = indexBase + (record * 28) + 20;
			}
			if (RecName.equals("PCON")) {
				++PCONCounter;
				if (PCONCounter == 2)
					PCON = indexBase + (record * 28) + 20;
			}

		} //next record
		traceLength = getIntAt(DATA12 - 8);
		seqLength = getIntAt(PBAS2 - 4);
		PLOC = getIntAt(PLOC) + macJunk;
		DATA9 = getIntAt(DATA9) + macJunk;
		DATA10 = getIntAt(DATA10) + macJunk;
		DATA11 = getIntAt(DATA11) + macJunk;
		DATA12 = getIntAt(DATA12) + macJunk;
		PBAS2 = getIntAt(PBAS2) + macJunk;
		PCON = getIntAt(PCON) + macJunk;
	}
826054
def history_forward(self, count=1):
        
        self._set_history_search()

        # Go forward in history.
        found_something = False

        for i in range(self.working_index + 1, len(self._working_lines)):
            if self._history_matches(i):
                self.working_index = i
                count -= 1
                found_something = True
            if count == 0:
                break

        # If we found an entry, move cursor to the end of the first line.
        if found_something:
            self.cursor_position = 0
            self.cursor_position += self.document.get_end_of_line_position()
109797
def _first(self, **spec):
        
        for record in self._entries(spec).order_by(model.Entry.local_date,
                                                   model.Entry.id)[:1]:
            return entry.Entry(record)
        return None
956285
def beginning_of_history(self): # (M-<)
        '''
        self.history_cursor = 0
        if len(self.history) > 0:
            self.l_buffer = self.history[0]
334644
def _list_records(self, rtype=None, name=None, content=None):
        """"""
        records = [
            {
                'id': record['id'],
                'type': record['type'],
                'name': self._full_name(record['hostname']),
                'content': record['destination'],
                'priority': record['priority'],
                'ttl': self.zone_ttl,
            }
            for record in self._raw_records(None, rtype, name, content)
        ]
        LOGGER.debug('list_records: %s', records)
        return records
678736
def first_where(pred, iterable, default=None):
    
    return next(six.moves.filter(pred, iterable), default)
634510
def record
      if @current_visit_seq
        track("visit_time", @t.to_i - @last_visit_end_time.to_i)
      else
        @current_visit_seq ||= counter("visits")
        track("visits", 1) # track core 'visit' metric
        if @first_visit_seq
          track("repeat_visits", 1)
        else
          @first_visit_seq ||= counter("unique_visits")
          track("first_visits", 1)
          track("unique_visits", 1)
        end
        exec_custom_methods('visit') # custom methods that are measured on a per-visit basis
      end
      exec_custom_methods('hit') # custom methods that are measured on a per-page-view (per-hit) basis
      track("page_views", 1) # track core 'page_view' metric
      track("second_page_views", 1) if @page_view_seq_no.to_i == 1 # @last_visit_start_time and (@last_visit_start_time.to_i == @last_visit_end_time.to_i)
      @rack_response
    end
1099735
def get_next_record(in_uid, kind='1'):
        '''
        
        '''
        current_rec = MPost.get_by_uid(in_uid)
        recs = TabPost.select().where(
            (TabPost.kind == kind) &
            (TabPost.time_create < current_rec.time_create)
        ).order_by(TabPost.time_create.desc())
        if recs.count():
            return recs.get()
        return None
716517
def first(self, count=1):
        
        if count == 0:
            raise QueryInvalid("Count cannot be zero.")
        self.limit_count = count
        records = self._do_query().fetchall()
        if not records:
            return None
        if count == 1:
            record = records[0]
            args = dict(zip(self.attributes, record))
            return self.model.from_dict(**args)
        return self
1148818
def list_records(self, file_const=None):
        """"""
        for r in self._dataset.files:
            if file_const and r.minor_type != file_const:
                continue
            yield self.instance_from_name(r.path)
1059869
def first
      reply = read_preference.with_node(cluster) do |node|
        node.query(
          operation.database,
          operation.collection,
          operation.selector,
          query_options(
            fields: operation.fields,
            flags: operation.flags,
            skip: operation.skip,
            limit: -1
          )
        )
      end
      reply.documents.first
    end
858015
def records_for_rebuild(batch_size = 1000)
      transaction do
        if use_fast_batches?
          offset = 0
          while (rows = where([ "#{table_name}.id > ?", offset ]).limit(batch_size).all).any?
            offset = rows.last.id
            yield rows, offset
          end
        else
          order = "#{primary_key} ASC" # fixes #212
          0.step(self.count, batch_size) do |offset|
            yield scoped.limit(batch_size).offset(offset).order(order).all, offset
          end
        end
      end
    end
955954
def reset(self):
        """"""
        if getattr(self, 'num', None) is None:
            self.num_inst = 0
            self.sum_metric = 0.0
        else:
            self.num_inst = [0] * self.num
            self.sum_metric = [0.0] * self.num
        self.records = dict()
        self.counts = dict()
193099
def count_records(self, record_counter, file):
        """"""
        counter = record_counter
        events_counter = 0
        for record in file.get_records():
            recid = record[2]
            counter[recid] = counter.get(recid, 0) + 1
            events_counter += 1

        self.stat['user_record_events'] = events_counter
        return counter