org.influxdb.dto.Query.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.influxdb.dto.Query.<init>方法的一些代码示例,展示了Query.<init>的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.<init>方法的具体详情如下:
包路径:org.influxdb.dto.Query
类名称:Query
方法名:<init>

Query.<init>介绍

暂无

代码示例

代码示例来源:origin: apache/nifi

protected List<QueryResult> executeQuery(final ProcessContext context, String database, String query, TimeUnit timeunit,
                     int chunkSize) throws InterruptedException {
  final CountDownLatch latch = new CountDownLatch(1);
  InfluxDB influx = getInfluxDB(context);
  Query influxQuery = new Query(query, database);
  if (chunkSize > 0) {
    List<QueryResult> results = new LinkedList<>();
    influx.query(influxQuery, chunkSize, result -> {
      if (isQueryDone(result.getError())) {
        latch.countDown();
      } else {
        results.add(result);
      }
    });
    latch.await();
    return results;
  } else {
    return Collections.singletonList(influx.query(influxQuery, timeunit));
  }
}

代码示例来源:origin: testcontainers/testcontainers-java

@Test
  public void queryForWriteAndRead() {
    InfluxDB influxDB = influxDBContainer.getNewInfluxDB();

    Point point = Point.measurement("cpu")
      .time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
      .addField("idle", 90L)
      .addField("user", 9L)
      .addField("system", 1L)
      .build();
    influxDB.write(point);

    Query query = new Query("SELECT idle FROM cpu", DATABASE);
    QueryResult actual = influxDB.query(query);

    assertThat(actual, notNullValue());
    assertThat(actual.getError(), nullValue());
    assertThat(actual.getResults(), notNullValue());
    assertThat(actual.getResults().size(), is(1));

  }
}

代码示例来源:origin: influxdata/influxdb-java

public <T> List<T> query(final Class<T> clazz) {
 throwExceptionIfMissingAnnotation(clazz);
 String measurement = getMeasurementName(clazz);
 String database = getDatabaseName(clazz);
 if ("[unassigned]".equals(database)) {
  throw new IllegalArgumentException(
    Measurement.class.getSimpleName()
      + " of class "
      + clazz.getName()
      + " should specify a database value for this operation");
 }
 QueryResult queryResult = influxDB.query(new Query("SELECT * FROM " + measurement, database));
 return toPOJO(queryResult, clazz);
}

代码示例来源:origin: sitewhere/sitewhere

/**
   * Count number of response for a command invocation.
   * 
   * @param originatingEventId
   * @param database
   * @return
   * @throws SiteWhereException
   */
  public static Query queryResponsesForInvocationCount(UUID originatingEventId, String database)
    throws SiteWhereException {
  return new Query("SELECT count(eid) FROM " + InfluxDbDeviceEvent.COLLECTION_EVENTS + " where type='"
    + DeviceEventType.CommandResponse + "' and " + InfluxDbDeviceCommandResponse.RSP_ORIGINATING_EVENT_ID
    + "='" + originatingEventId + "' GROUP BY " + InfluxDbDeviceEvent.EVENT_ASSIGNMENT, database);
  }
}

代码示例来源:origin: sitewhere/sitewhere

/**
 * Find the list of responses for a command invocation.
 * 
 * @param originatingEventId
 * @param database
 * @return
 * @throws SiteWhereException
 */
public static Query queryResponsesForInvocation(UUID originatingEventId, String database)
  throws SiteWhereException {
return new Query("SELECT * FROM " + InfluxDbDeviceEvent.COLLECTION_EVENTS + " where type='"
  + DeviceEventType.CommandResponse + "' and " + InfluxDbDeviceCommandResponse.RSP_ORIGINATING_EVENT_ID
  + "='" + originatingEventId + "' GROUP BY " + InfluxDbDeviceEvent.EVENT_ASSIGNMENT
  + " ORDER BY time DESC", database);
}

代码示例来源:origin: org.apereo.cas/cas-server-support-influxdb-core

/**
 * Query result.
 *
 * @param fields      the fields
 * @param measurement the table
 * @param dbName      the db name
 * @return the query result
 */
public QueryResult query(final String fields, final String measurement, final String dbName) {
  val filter = String.format("SELECT %s FROM %s", fields, measurement);
  val query = new Query(filter, dbName);
  return this.influxDb.query(query);
}

代码示例来源:origin: org.apache.camel/camel-influxdb

private void doQuery(Exchange exchange, String dataBaseName, String retentionPolicy) {
  String query = calculateQuery(exchange);
  Query influxdbQuery = new Query(query, dataBaseName);
  QueryResult resultSet = connection.query(influxdbQuery);
  MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
  exchange.getOut().setBody(resultSet);
}

代码示例来源:origin: inspectIT/inspectIT

/**
 * Executes the given query on the database.
 *
 * @param query
 *            the query to execute
 * @return the result of this query
 */
public QueryResult query(String query) {
  if ((query == null) || !isConnected()) {
    return null;
  }
  if (log.isDebugEnabled()) {
    log.debug("Execute query on InfluxDB: {}", query);
  }
  return influxDB.query(new Query(query, database));
}

代码示例来源:origin: org.influxdb/influxdb-java

public <T> List<T> query(final Class<T> clazz) {
 throwExceptionIfMissingAnnotation(clazz);
 String measurement = getMeasurementName(clazz);
 String database = getDatabaseName(clazz);
 if ("[unassigned]".equals(database)) {
  throw new IllegalArgumentException(
    Measurement.class.getSimpleName()
      + " of class "
      + clazz.getName()
      + " should specify a database value for this operation");
 }
 QueryResult queryResult = influxDB.query(new Query("SELECT * FROM " + measurement, database));
 return toPOJO(queryResult, clazz);
}

代码示例来源:origin: org.apache.nifi/nifi-influxdb-processors

protected List<QueryResult> executeQuery(final ProcessContext context, String database, String query, TimeUnit timeunit,
                     int chunkSize) throws InterruptedException {
  final CountDownLatch latch = new CountDownLatch(1);
  InfluxDB influx = getInfluxDB(context);
  Query influxQuery = new Query(query, database);
  if (chunkSize > 0) {
    List<QueryResult> results = new LinkedList<>();
    influx.query(influxQuery, chunkSize, result -> {
      if (isQueryDone(result.getError())) {
        latch.countDown();
      } else {
        results.add(result);
      }
    });
    latch.await();
    return results;
  } else {
    return Collections.singletonList(influx.query(influxQuery, timeunit));
  }
}

代码示例来源:origin: inspectIT/inspectIT

/**
 * Executes a write operation to test the connection.
 *
 * @return <code>true</code> if the write operation was successful.
 */
private boolean executeWriteTest() {
  Point point = Point.measurement(DUMMY_MEASUREMENT).addField("write_check", true).build();
  try {
    influxDB.write(database, retentionPolicy, point);
    influxDB.query(new Query("DROP SERIES FROM " + DUMMY_MEASUREMENT, database));
  } catch (Exception ex) {
    if (log.isDebugEnabled()) {
      log.debug("Test-write failed with the following message: " + ex.getMessage());
    }
    return false;
  }
  return true;
}

代码示例来源:origin: sitewhere/sitewhere

/**
 * Get a query for counting events of a given type associated with one or more
 * entities for a given index and that meet the search criteria.
 * 
 * @param index
 * @param type
 * @param entityIds
 * @param criteria
 * @param database
 * @return
 * @throws SiteWhereException
 */
protected static Query queryEventsOfTypeForIndexCount(DeviceEventIndex index, DeviceEventType type,
  List<UUID> entityIds, ISearchCriteria criteria, String database) throws SiteWhereException {
return new Query(
  "SELECT count(" + EVENT_ID + ") FROM " + InfluxDbDeviceEvent.COLLECTION_EVENTS + " where type='"
    + type.name() + "' and " + buildInClause(index, entityIds) + buildDateRangeCriteria(criteria),
  database);
}

代码示例来源:origin: sitewhere/sitewhere

/**
 * Get an event by unique id.
 * 
 * @param eventId
 * @param client
 * @return
 * @throws SiteWhereException
 */
public static IDeviceEvent getEventById(UUID eventId, InfluxDbClient client) throws SiteWhereException {
Query query = new Query(
  "SELECT * FROM " + InfluxDbDeviceEvent.COLLECTION_EVENTS + " where " + EVENT_ID + "='" + eventId + "'",
  client.getDatabase().getValue());
QueryResult response = client.getInflux().query(query, TimeUnit.MILLISECONDS);
List<IDeviceEvent> results = InfluxDbDeviceEvent.eventsOfType(response, IDeviceEvent.class);
if (results.size() > 0) {
  return results.get(0);
}
return null;
}

代码示例来源:origin: sitewhere/sitewhere

/**
 * Get an event by alternate id.
 * 
 * @param alternateId
 * @param client
 * @return
 * @throws SiteWhereException
 */
public static IDeviceEvent getEventByAlternateId(String alternateId, InfluxDbClient client)
  throws SiteWhereException {
Query query = new Query("SELECT * FROM " + InfluxDbDeviceEvent.COLLECTION_EVENTS + " where " + ALTERNATE_ID
  + "='" + alternateId + "'", client.getDatabase().getValue());
QueryResult response = client.getInflux().query(query, TimeUnit.MILLISECONDS);
List<IDeviceEvent> results = InfluxDbDeviceEvent.eventsOfType(response, IDeviceEvent.class);
if (results.size() > 0) {
  return results.get(0);
}
return null;
}

代码示例来源:origin: sitewhere/sitewhere

/**
 * Get a query for events of a given type associated with one or more entities
 * for a given index and that meet the search criteria.
 * 
 * @param index
 * @param type
 * @param entityIds
 * @param criteria
 * @param database
 * @return
 * @throws SiteWhereException
 */
protected static Query queryEventsOfTypeForIndex(DeviceEventIndex index, DeviceEventType type, List<UUID> entityIds,
  ISearchCriteria criteria, String database) throws SiteWhereException {
return new Query("SELECT * FROM " + InfluxDbDeviceEvent.COLLECTION_EVENTS + " where type='" + type.name()
  + "' and " + buildInClause(index, entityIds) + buildDateRangeCriteria(criteria) + " ORDER BY time DESC"
  + buildPagingCriteria(criteria), database);
}

代码示例来源:origin: Scrin/RuuviCollector

BlockingQueue<LegacyMeasurement> batteryQueue = new LinkedBlockingQueue<>(QUEUE_SIZE);
BlockingQueue<LegacyMeasurement> rssiQueue = new LinkedBlockingQueue<>(QUEUE_SIZE);
Query temperatureQuery = new Query("select * from temperature order by time asc", Config.getInfluxDatabase());
Query humidityQuery = new Query("select * from humidity order by time asc", Config.getInfluxDatabase());
Query pressureQuery = new Query("select * from pressure order by time asc", Config.getInfluxDatabase());
Query accelerationXQuery = new Query("select * from acceleration where \"axis\"='x' order by time asc", Config.getInfluxDatabase());
Query accelerationYQuery = new Query("select * from acceleration where \"axis\"='y' order by time asc", Config.getInfluxDatabase());
Query accelerationZQuery = new Query("select * from acceleration where \"axis\"='z' order by time asc", Config.getInfluxDatabase());
Query batteryQuery = new Query("select * from batteryVoltage order by time asc", Config.getInfluxDatabase());
Query rssiQuery = new Query("select * from rssi order by time asc", Config.getInfluxDatabase());
AtomicBoolean temperatureDone = new AtomicBoolean(false);
AtomicBoolean humidityDone = new AtomicBoolean(false);

相关文章