コード例 #1
0
ファイル: CassandraDao.java プロジェクト: rgirodon/nosqlbench
  public PlayerMention retrievePlayerMentionForPlayerAndSelectioner(
      String player, String selectioner) {

    Select select = QueryBuilder.select().from("player_mention");
    select.where(QueryBuilder.eq("player", player));
    select.where(QueryBuilder.eq("selectioner_email", selectioner));

    return this.cassandraOperations.selectOne(select, PlayerMention.class);
  }
コード例 #2
0
  public List<LogEvent> findByAppIdContains(
      final String appId, String token, LogEvent lastRow, int limit, boolean isPrevPaging) {
    Select sel = QueryBuilder.select().from(table).limit(limit);
    Where w = sel.where(QueryBuilder.eq(pkCols[0], appId));

    w.and(
        QueryBuilder.eq(
            luceneCol,
            Builder.search()
                .filter(Builder.phrase(logTextCol, token))
                .sort(SortField.field(timeuuidCol).reverse(isPrevPaging))
                .build()));

    if (lastRow != null) {
      w.and(
          isPrevPaging
              ? QueryBuilder.gt(timeuuidCol, lastRow.getId().getTimestamp())
              : QueryBuilder.lt(timeuuidCol, lastRow.getId().getTimestamp()));
    }

    log.debug(">>>>>>>>> Firing select query: " + sel.toString());
    List<LogEvent> events = cassandraOperations.select(sel, LogEvent.class);
    if (isPrevPaging) {
      Collections.sort(
          events,
          new Comparator<LogEvent>() {

            @Override
            public int compare(LogEvent o1, LogEvent o2) {
              return o2.getId().getTimestamp().compareTo(o1.getId().getTimestamp());
            }
          });
    }
    return events;
  }
コード例 #3
0
  public List<LogEvent> findByAppId(
      final String appId, LogEvent lastRow, int limit, boolean isPrevPaging) {
    Select sel = QueryBuilder.select().from(table).limit(limit);
    Where w = sel.where(QueryBuilder.eq(pkCols[0], appId));
    if (lastRow != null) {
      w.and(
          isPrevPaging
              ? QueryBuilder.gt(timeuuidCol, lastRow.getId().getTimestamp())
              : QueryBuilder.lt(timeuuidCol, lastRow.getId().getTimestamp()));
    }

    if (isPrevPaging) sel.orderBy(QueryBuilder.asc(timeuuidCol));

    log.debug(">>>>>>>>> Firing select query: " + sel.toString());
    List<LogEvent> events = cassandraOperations.select(sel, LogEvent.class);
    if (isPrevPaging) {
      Collections.sort(
          events,
          new Comparator<LogEvent>() {

            @Override
            public int compare(LogEvent o1, LogEvent o2) {
              return o2.getId().getTimestamp().compareTo(o1.getId().getTimestamp());
            }
          });
    }
    return events;
  }
コード例 #4
0
ファイル: CassandraDao.java プロジェクト: rgirodon/nosqlbench
  public UserSelection retrieveUserSelectionForEmail(String email) {

    Select select = QueryBuilder.select().from("user_selection");
    select.where(QueryBuilder.eq("email", email));

    return this.cassandraOperations.selectOne(select, UserSelection.class);
  }
コード例 #5
0
ファイル: CassandraDao.java プロジェクト: rgirodon/nosqlbench
  public Collection<PlayerMention> retrievePlayerMentionsForPlayer(String player) {

    Select select = QueryBuilder.select().from("player_mention");
    select.where(QueryBuilder.eq("player", player));

    return this.cassandraOperations.select(select, PlayerMention.class);
  }
コード例 #6
0
  @Override
  public List<DocumentMetadata> searchByUploader(String uploader) {
    Select select = QueryBuilder.select().from("documents");
    select.where(QueryBuilder.eq("uploaded_by", uploader));

    return DocumentMetadataMapping.unwrapList(
        cassandraOperations.select(select, DocumentMetadataMapping.class));
  }
コード例 #7
0
  @Override
  public List<DocumentMetadata> searchByUploadTime(long from, long to) {
    Select select = QueryBuilder.select().from("documents");
    select.where(QueryBuilder.gte("upload_time", from)).and(QueryBuilder.lte("upload_time", to));
    select.allowFiltering();

    return DocumentMetadataMapping.unwrapList(
        cassandraOperations.select(select, DocumentMetadataMapping.class));
  }
コード例 #8
0
ファイル: HeartProcessor.java プロジェクト: srpraneeth/HMS
 @Override
 public void processMessage(Message message) throws MessageProcessingException {
   String payload = message.getPayload();
   String dttm = message.getHeader().getDttm();
   try {
     Map<String, String> payloadMap = mapper.readValue(payload, Map.class);
     Integer userId = Integer.valueOf(payloadMap.get("UserId"));
     String tracker = payloadMap.get("Tracker");
     HeartTracker heartTracker = null;
     Select select = QueryBuilder.select().from("heart_tracker");
     select.where(QueryBuilder.eq("user_id", userId));
     select.where(QueryBuilder.eq("httr_tracker", tracker));
     select.allowFiltering();
     List<HeartTracker> heartTrackers = cassandraTemplate.select(select, HeartTracker.class);
     if (heartTrackers.size() == 0) {
       heartTracker = new HeartTracker();
       heartTracker.setHttrId(UUID.randomUUID());
       heartTracker.setUserId(userId);
       heartTracker.setHttrTracker(tracker);
       heartTracker.setCreatedDttm(new Date());
       heartTracker.setDeleteFl(Boolean.FALSE);
       heartTracker.setPtnId(1);
       cassandraTemplate.insert(heartTracker);
     } else {
       heartTracker = heartTrackers.get(0);
     }
     HeartRate heartRate = new HeartRate();
     heartRate.setHtrtId(UUID.randomUUID());
     heartRate.setHttrId(heartTracker.getHttrId());
     heartRate.setHtrtDttm(formatter.parse(dttm));
     heartRate.setHtrtValue(Integer.valueOf(payloadMap.get("Value")));
     heartRate.setUserId(userId);
     heartRate.setCreatedDttm(new Date());
     heartRate.setDeleteFl(Boolean.FALSE);
     heartRate.setPtnId(1);
     cassandraTemplate.insert(heartRate);
   } catch (IOException e) {
     logger.error("Exception occured in Heart Rate Message Processing. ", e);
     throw new MessageProcessingException(e);
   } catch (ParseException e) {
     logger.error("Exception occured in Date Conversion. Invalid Date. " + dttm, e);
     throw new MessageProcessingException(e);
   }
 }
コード例 #9
0
 @SuppressWarnings("unchecked")
 protected <T extends Entity> T findEntity(T entity) {
   Select selection = select().all().from(tableName(entity));
   selection.where(eq("id", entity.getId()));
   return (T) template.selectOne(selection, entity.getClass());
 }