Get the row count for a time range
184294
private int getCountForRange(TableCountProbingContext probingContext, StrSubstitutor sub,
      Map<String, String> subValues, long startTime, long endTime) {
    String startTimeStr = Utils.dateToString(new Date(startTime), SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);
    String endTimeStr = Utils.dateToString(new Date(endTime), SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);

    subValues.put("start", startTimeStr);
    subValues.put("end", endTimeStr);

    String query = sub.replace(PROBE_PARTITION_QUERY_TEMPLATE);

    log.debug("Count query: " + query);
    probingContext.probeCount++;

    JsonArray records = getRecordsForQuery(probingContext.connector, query);
    Iterator<JsonElement> elements = records.iterator();
    JsonObject element = elements.next().getAsJsonObject();

    return element.get("cnt").getAsInt();
  }
514280
def fetchone(self):
        """"""
        self._check_executed()
        if self._rows is None or self.rownumber >= len(self._rows):
            return None
        result = self._rows[self.rownumber]
        self.rownumber += 1
        return result
244302
def previous_row(self):
        """"""
        row = self.currentIndex().row()
        rows = self.source_model.rowCount()
        if row == 0:
            row = rows
        self.selectRow(row - 1)
673526
def GetCountStopTimes(self):
    """"""
    cursor = self._schedule._connection.cursor()
    cursor.execute(
        'SELECT count(*) FROM stop_times WHERE trip_id=?', (self.trip_id,))
    return cursor.fetchone()[0]
815062
def columnCount(self, row=None):
        
        if row is not None:
            wholerow = self._segments[row]
            return len(wholerow)
        else:
            column_lengths = [len(x) for x in self._segments]
            return max(column_lengths)
1359499
private int getTupleDataRowCount(List<DBBPool.BBContainer> outputBuffers) {
        if (outputBuffers == null || outputBuffers.size() != m_tableTasks.size()) return 0;
        int accumulator = 0;
        for (int i = 0; i < outputBuffers.size(); ++i) {
            SnapshotDataTarget target = m_tableTasks.get(i).m_target;
            int rowCount = target.getInContainerRowCount(outputBuffers.get(i));
            if (rowCount != SnapshotDataTarget.ROW_COUNT_UNSUPPORTED) {
                accumulator += target.getInContainerRowCount(outputBuffers.get(i));
            }
        }
        return accumulator;
    }
308376
def row_value(self, row):
        """"""
        irow = int(row)
        i = self._get_key_index(irow)
        if i == -1:
            return 0.0

        # Are we dealing with the last key?
        if i == len(self.keys) - 1:
            return self.keys[-1].value

        return TrackKey.interpolate(self.keys[i], self.keys[i + 1], row)
47429
def count_rows_distinct(self, table, cols='*'):
        """"""
        return self.fetch('SELECT COUNT(DISTINCT {0}) FROM {1}'.format(join_cols(cols), wrap(table)))
470211
private int seekRow(final long timestamp) {
    checkRowOrder();
    int row_index = 0;
    iRowSeq row = null;
    final int nrows = rows.size();
    for (int i = 0; i < nrows; i++) {
      row = rows.get(i);
      final int sz = row.size();
      if (sz < 1) {
        row_index++;
      } else if (row.timestamp(sz - 1) < timestamp) {
        row_index++;  // The last DP in this row is before 'timestamp'.
      } else {
        break;
      }
    }
    if (row_index == nrows) {  // If this timestamp was too large for the
      --row_index;             // last row, return the last row.
    }
    return row_index;
  }
387016
def nowrange_(self, col, timeframe):
        
        df = self._nowrange(col, timeframe)
        if df is None:
            self.err("Can not select range data from now")
            return
        return self._duplicate_(df)
515502
def GetSortedEvents(self, time_range=None):
    
    filter_expression = None
    if time_range:
      filter_expression = []

      if time_range.start_timestamp:
        filter_expression.append(
            '_timestamp >= {0:d}'.format(time_range.start_timestamp))

      if time_range.end_timestamp:
        filter_expression.append(
            '_timestamp <= {0:d}'.format(time_range.end_timestamp))

      filter_expression = ' AND '.join(filter_expression)

    event_generator = self._GetAttributeContainers(
        self._CONTAINER_TYPE_EVENT, filter_expression=filter_expression,
        order_by='_timestamp')

    for event in event_generator:
      if hasattr(event, 'event_data_row_identifier'):
        event_data_identifier = identifiers.SQLTableIdentifier(
            'event_data', event.event_data_row_identifier)
        event.SetEventDataIdentifier(event_data_identifier)

        del event.event_data_row_identifier

      yield event
210574
def get_stats_of_rows(rows):
    """"""
    count_true = count_false = max_score = 0
    for row in rows:
        if not row.properties:
            logging.info('Missing property for %s.', row.filename)
            continue
        if len(row.properties) > 1:
            # multiple properties not yet supported
            count_true = count_false = max_score = 0
            break
        expected_result = row.expected_results.get(row.properties[0].name)
        if not expected_result:
            continue
        if expected_result.result is True:
            count_true += 1
        elif expected_result.result is False:
            count_false += 1
        for prop in row.properties:
            max_score += prop.max_score(expected_result)

    return max_score, count_true, count_false
1139017
def parse_200_row(row: list) -> NmiDetails:
    
    return NmiDetails(row[1], row[2], row[3], row[4], row[5], row[6],
                         row[7], int(row[8]), parse_datetime(row[9]))
200618
def _rows_int2date(self, rows):
        
        for row in rows:
            if self._date_type == 'str':
                row[self._key_start_date] = datetime.date.fromordinal(row[self._key_start_date]).isoformat()
                row[self._key_end_date] = datetime.date.fromordinal(row[self._key_end_date]).isoformat()
            elif self._date_type == 'date':
                row[self._key_start_date] = datetime.date.fromordinal(row[self._key_start_date])
                row[self._key_end_date] = datetime.date.fromordinal(row[self._key_end_date])
            elif self._date_type == 'int':
                # Nothing to do.
                pass
            else:
                raise ValueError('Unexpected date type {0!s}'.format(self._date_type))
1239815
public static int getRowCount(Connection connection, String tableReference) throws SQLException {
        Statement st = connection.createStatement();
        int rowCount = 0;
        try {
            ResultSet rs = st.executeQuery(String.format("select count(*) rowcount from %s", TableLocation.parse(tableReference)));
            try {
                if(rs.next()) {
                    rowCount = rs.getInt(1);
                }
            } finally {
                rs.close();
            }
        }finally {
            st.close();
        }
        return rowCount;
    }
926035
protected function GetRemainingRowCount()
    {
        $aTableList = $this->aTablesToProcess;
        $iCount = 0;
        foreach ($aTableList as $iWorkId) {
            $oIndexQuery = TdbShopSearchQuery::GetNewInstance();
            /** @var $oIndexQuery TdbShopSearchQuery */
            if ($oIndexQuery->Load($iWorkId)) {
                $iCount = $iCount + $oIndexQuery->NumberOfRecordsLeftToIndex();
            }
        }

        return $iCount;
    }
544920
def get_row(self, row_index):
    """"""
    if self._raw_rows is None:
      self._raw_rows = list(self.raw_sheet.rows())
    return self._raw_rows[row_index]