Ejemplo n.º 1
0
  @Override
  public long deleteByQuery(Query<K, T> query) {
    try {
      long deletedRows = 0;
      Result<K, T> result = query.execute();

      while (result.next()) {
        if (delete(result.getKey())) deletedRows++;
      }
      return 0;
    } catch (Exception e) {
      return 0;
    }
  }
Ejemplo n.º 2
0
  private void readFlushed(Configuration conf) throws Exception {
    DataStore<Utf8, Flushed> flushedTable =
        DataStoreFactory.getDataStore(Utf8.class, Flushed.class, conf);

    Query<Utf8, Flushed> query = flushedTable.newQuery();
    Result<Utf8, Flushed> result = flushedTable.execute(query);

    ArrayList<String> flushedEntries = new ArrayList<String>();
    while (result.next()) {
      flushedEntries.add(result.getKey() + ":" + result.get().getCount());
    }

    conf.setStrings("goraci.verify.flushed", flushedEntries.toArray(new String[] {}));

    flushedTable.close();
  }
Ejemplo n.º 3
0
 @Override
 public long deleteByQuery(Query<K, T> query) {
   try {
     long deletedRows = 0;
     Result<K, T> result = query.execute();
     String[] fields = getFieldsToQuery(query.getFields());
     boolean isAllFields = Arrays.equals(fields, getFields());
     while (result.next()) {
       if (isAllFields) {
         if (delete(result.getKey())) {
           deletedRows++;
         }
       } else {
         ArrayList<String> excludedFields = new ArrayList<>();
         for (String field : getFields()) {
           if (!Arrays.asList(fields).contains(field)) {
             excludedFields.add(field);
           }
         }
         T newClonedObj =
             getPersistent(
                 result.get(), excludedFields.toArray(new String[excludedFields.size()]));
         if (delete(result.getKey())) {
           put(result.getKey(), newClonedObj);
           deletedRows++;
         }
       }
     }
     LOG.info("JCache Gora datastore deleled {} rows from Persistent datastore.", deletedRows);
     return deletedRows;
   } catch (Exception e) {
     LOG.error(
         "Exception occurred while deleting entries from JCache Gora datastore. Hence returning 0.",
         e);
     return 0;
   }
 }