Ejemplo n.º 1
0
  @PooledConnection
  public void deleteColumn(
      String keyspace,
      String column_family,
      String key,
      String column,
      ConsistencyLevel consistency_level,
      boolean purgeIndex)
      throws InvalidRequestException, UnavailableException, TimedOutException, TException,
          HttpException, IOException {
    ColumnPath path = new ColumnPath(column_family);
    path.setColumn(ByteBufferUtil.bytes(column));
    getConnection(keyspace)
        .remove(
            ByteBufferUtil.bytes(key), path, System.currentTimeMillis() * 1000, consistency_level);

    // TODO: Revisit deleting a single field because it requires a fetch
    // first.
    // Evidently it is impossible to remove just a field from a document in
    // SOLR
    // http://stackoverflow.com/questions/4802620/can-you-delete-a-field-from-a-document-in-solr-index
    if (config.isIndexingEnabled() && purgeIndex) {
      indexer.delete(column_family, key);
      JSONObject json = this.getSlice(keyspace, column_family, key, consistency_level);
      json.remove(column);
      indexer.index(column_family, key, json);
    }
  }
Ejemplo n.º 2
0
  @PooledConnection
  public long deleteRow(
      String keyspace,
      String column_family,
      String key,
      ConsistencyLevel consistency_level,
      boolean purgeIndex)
      throws InvalidRequestException, UnavailableException, TimedOutException, TException,
          HttpException, IOException {
    long deleteTime = System.currentTimeMillis() * 1000;
    ColumnPath path = new ColumnPath(column_family);
    getConnection(keyspace).remove(ByteBufferUtil.bytes(key), path, deleteTime, consistency_level);

    // Update Index
    if (config.isIndexingEnabled() && purgeIndex) {
      indexer.delete(column_family, key);
    }
    return deleteTime;
  }