/*
(non-Javadoc)

@see com.impetus.kundera.client.Client#deleteByColumn(java.lang.String,
java.lang.String, java.lang.String, java.lang.Object)
356800
@Override
    public void deleteByColumn(String schemaName, String tableName, String columnName, Object columnValue)
    {
        Object connection = null;
        Pipeline pipeLine = null;
        try
        {

            connection = getConnection();

            if (isBoundTransaction())
            {
                pipeLine = ((Jedis) connection).pipelined();
            }

            String valueAsStr = PropertyAccessorHelper.getString(columnValue);
            Double score = getDouble(valueAsStr);
            Set<String> results = null;
            if (resource != null && resource.isActive())
            {
                Response response = ((Transaction) connection).zrangeByScore(getHashKey(tableName, valueAsStr), score,
                        score);
                // ((Transaction) connection).exec();
                ((RedisTransaction) resource).onExecute(((Transaction) connection));

                results = (Set<String>) response.get();
            }
            else
            {
                results = ((Jedis) connection).zrangeByScore(getHashKey(tableName, valueAsStr), score, score);
            }
            // Set<String> results =
            // connection.zrangeByScore(getHashKey(tableName, valueAsStr),
            // score, score);

            if (results != null)
            {
                for (String rowKey : results)
                {
                    // byte[] hashKey = getEncodedBytes(getHashKey(tableName,
                    // rowKey));

                    Map<byte[], byte[]> columns = null;
                    columns = getColumns(connection, rowKey, columns);

                    for (byte[] column : columns.keySet()) // delete each
                                                           // column(e.g.
                    // field)
                    {
                        // connection.get(key)
                        String colName = PropertyAccessorFactory.STRING.fromBytes(String.class, columns.get(column));

                        if (resource != null && resource.isActive())
                        {
                            ((Transaction) connection).hdel(getEncodedBytes(rowKey), column); // delete
                            // record
                            ((Transaction) connection).zrem(getHashKey(tableName, colName), rowKey); // delete
                            // inverted
                            // index.

                        }
                        else
                        {
                            ((Jedis) connection).hdel(getEncodedBytes(rowKey), column); // delete
                            // record
                            ((Jedis) connection).zrem(getHashKey(tableName, colName), rowKey); // delete
                            // inverted
                            // index.

                        }
                    }
                }

            }
        }
        finally
        {
            if (pipeLine != null)
            {
                pipeLine.sync();
            }
            onCleanup(connection);
        }
    }
1246130
@Override
    public void deleteByColumn(String schemaName, String tableName, String columnName, Object columnValue)
    {
        URI uri = null;
        HttpResponse response = null;
        try
        {
            String q = "key=" + CouchDBUtils.appendQuotes(columnValue);
            uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(),
                    CouchDBConstants.URL_SEPARATOR + schemaName.toLowerCase() + CouchDBConstants.URL_SEPARATOR
                            + CouchDBConstants.DESIGN + tableName + CouchDBConstants.VIEW + columnName, q, null);
            HttpGet get = new HttpGet(uri);
            get.addHeader("Accept", "application/json");
            response = httpClient.execute(get);

            InputStream content = response.getEntity().getContent();
            Reader reader = new InputStreamReader(content);

            JsonObject json = gson.fromJson(reader, JsonObject.class);

            JsonElement jsonElement = json.get("rows");

            closeContent(response);

            JsonArray array = jsonElement.getAsJsonArray();
            for (JsonElement element : array)
            {
                JsonObject jsonObject = element.getAsJsonObject().get("value").getAsJsonObject();

                JsonElement pkey = jsonObject.get("_id");

                onDelete(schemaName, pkey.getAsString(), response, jsonObject);
            }
        }
        catch (Exception e)
        {
            log.error("Error while deleting row by column where column name is " + columnName
                    + " and column value is {}, Caused by {}.", columnValue, e);
            throw new KunderaException(e);
        }
        finally
        {
            closeContent(response);
        }
    }
42256
private void validateColumn(final Column<?> newColumn) {
        Preconditions.checkNotNull(newColumn, "Attempted to add a null to the columns in table " + name);
        List<String> stringList = new ArrayList<>();
        for (String name : columnNames()) {
            stringList.add(name.toLowerCase());
        }
        if (stringList.contains(newColumn.name().toLowerCase())) {
            String message = String.format("Cannot add column with duplicate name %s to table %s", newColumn, name);
            throw new IllegalArgumentException(message);
        }

        checkColumnSize(newColumn);
    }
400275
@Override
    public <E> List<E> getColumnsById(String schemaName, String tableName, String pKeyColumnName, String columnName,
        Object pKeyColumnValue, Class columnJavaType) {
        // select columnName from tableName where pKeyColumnName =
        // pKeyColumnValue
        List results = new ArrayList();
        CQLTranslator translator = new CQLTranslator();
        String selectQuery = translator.SELECT_QUERY;
        selectQuery = StringUtils.replace(selectQuery, CQLTranslator.COLUMN_FAMILY,
            translator.ensureCase(new StringBuilder(), tableName, false).toString());
        selectQuery = StringUtils.replace(selectQuery, CQLTranslator.COLUMNS,
            translator.ensureCase(new StringBuilder(), columnName, false).toString());

        StringBuilder selectQueryBuilder = new StringBuilder(selectQuery);

        selectQueryBuilder.append(CQLTranslator.ADD_WHERE_CLAUSE);

        translator.buildWhereClause(selectQueryBuilder, columnJavaType, pKeyColumnName, pKeyColumnValue,
            CQLTranslator.EQ_CLAUSE, false);
        selectQueryBuilder.delete(selectQueryBuilder.lastIndexOf(CQLTranslator.AND_CLAUSE),
            selectQueryBuilder.length());

        ResultSet rSet = execute(selectQueryBuilder.toString(), null);

        Iterator<Row> rowIter = rSet.iterator();
        while (rowIter.hasNext()) {
            Row row = rowIter.next();
            DataType dataType = row.getColumnDefinitions().getType(columnName);
            Object columnValue =
                DSClientUtilities.assign(row, null, null, dataType.getName(), null, columnName, null, null);
            results.add(columnValue);
        }
        return results;
    }
292551
@Override
    public void delete(Object entity, Object pKey)
    {
        if (!isOpen())
        {
            throw new PersistenceException("PelopsClient is closed.");
        }
        EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entity.getClass());

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                metadata.getPersistenceUnit());
        AbstractManagedType managedType = (AbstractManagedType) metaModel.entity(metadata.getEntityClazz());
        // For secondary tables.
        List<String> secondaryTables = ((DefaultEntityAnnotationProcessor) managedType.getEntityAnnotation())
                .getSecondaryTablesName();
        secondaryTables.add(metadata.getTableName());

        for (String tableName : secondaryTables)
        {
            if (isCql3Enabled(metadata))
            {
                String deleteQuery = onDeleteQuery(metadata, tableName, metaModel, pKey);
                executeCQLQuery(deleteQuery, isCql3Enabled(metadata));
            }
            else
            {
                if (metadata.isCounterColumnType())
                {
                    deleteRecordFromCounterColumnFamily(pKey, tableName, metadata, getConsistencyLevel());
                }
                else
                {
                    RowDeletor rowDeletor = clientFactory.getRowDeletor(pool);
                    rowDeletor.deleteRow(tableName, Bytes.fromByteBuffer(CassandraUtilities.toBytes(pKey, metadata
                            .getIdAttribute().getJavaType())), getConsistencyLevel());

                }
            }
        }
        getIndexManager().remove(metadata, entity, pKey);

        // Delete from Inverted Index if applicable
        Object conn = getConnection();
        try
        {
            invertedIndexHandler.delete(entity, metadata, getConsistencyLevel(), kunderaMetadata);
        }
        finally
        {
            if (conn != null)
            {
                releaseConnection(conn);
            }
        }
    }
12405
public void deleteColumn(int column) throws BadElementException {
        float newWidths[] = new float[--columns];
        System.arraycopy(widths, 0, newWidths, 0, column);
        System.arraycopy(widths, column + 1, newWidths, column, columns - column);
        setWidths(newWidths);
        System.arraycopy(widths, 0, newWidths, 0, columns);
        widths = newWidths;
        Row row;
        int size = rows.size();
        for (int i = 0; i < size; i++) {
            row = (Row) rows.get(i);
            row.deleteColumn(column);
            rows.set(i, row);
        }
        if (column == columns) {
            curPosition.setLocation(curPosition.x+1, 0);
        }
    }
639858
public <T> int del(T pk) throws SQLException {
		if (pk == null) {
			return 0;
		}
		return this.del(Entity.create(tableName).set(primaryKeyField, pk));
	}
1249337
@Override
    public void deleteStoreIfPresent(String storeName) {
        DBConn dbConn = getDBConnection();
        try {
            synchronized (m_schemaLock) {
                if (m_schemaMgr.columnFamilyExists(dbConn, m_keyspace, storeName)) {
                    m_schemaMgr.deleteColumnFamily(dbConn, storeName);
                }
            }
        } finally {
            returnDBConnection(dbConn);
        }
    }
1126346
protected function dropColumn(string $tableName, string $column) : void
    {
        // Check for its existence before dropping
        if (! $this->schema->hasColumn($tableName, $column)) {
            return;
        }

        $this->schema->table($tableName, function (Blueprint $table) use ($column) {
            $table->dropColumn($column);
        });
    }
309239
@CheckResult protected Observable<Integer> delete(@NonNull final String table) {
    return delete(table, null);
  }
166458
public int deleteByExtension(String extensionName) throws SQLException {

		DeleteBuilder<Extensions, Void> db = deleteBuilder();
		db.where().eq(Extensions.COLUMN_EXTENSION_NAME, extensionName);

		int deleted = db.delete();

		return deleted;
	}
1111278
public void delete(String columnName, String... keys) {
    Mutator<String> m = createMutator(keyspace, serializer);
    for (String key: keys) {
      m.addDeletion(key, columnFamilyName,  columnName, serializer);
    }
    m.execute();
  }
379581
private void deleteColumn(String storeName, String rowKey, String colName) {
        Map<String, List<String>> rowMap = m_columnDeletes.get(storeName);
        if (rowMap == null) {
            rowMap = new HashMap<>();
            m_columnDeletes.put(storeName, rowMap);
        }
        List<String> colNames = rowMap.get(rowKey);
        if (colNames == null) {
            colNames = new ArrayList<>();
            rowMap.put(rowKey, colNames);
        }
        colNames.add(colName);
        m_totalUpdates++;
    }
442609
public static function deleteColumn(string $tableName, string $column)
    {
        if(Schema::hasTable($tableName)) {
            Schema::table(
                $tableName, function ($table) use ($tableName, $column) {
                    if(Schema::hasColumn($tableName, $column)) {
                        $table->dropColumn($column);
                    }
                }
            );
        }
    }
384535
@Override
	public int delete(DataColumnConstraints dataColumnConstraints)
			throws SQLException {

		DeleteBuilder<DataColumnConstraints, Void> db = deleteBuilder();

		setUniqueWhere(db.where(), dataColumnConstraints.getConstraintName(),
				dataColumnConstraints.getConstraintType(),
				dataColumnConstraints.getValue());

		int deleted = db.delete();

		return deleted;
	}
631415
public int deleteByTableName(String tableName) throws SQLException {
		DeleteBuilder<DataColumns, TableColumnKey> db = deleteBuilder();
		db.where().eq(DataColumns.COLUMN_TABLE_NAME, tableName);
		PreparedDelete<DataColumns> deleteQuery = db.prepare();
		int deleted = delete(deleteQuery);
		return deleted;
	}
265737
public <T> int del(String field, T value) throws SQLException {
		if (StrUtil.isBlank(field)) {
			return 0;
		}

		return this.del(Entity.create(tableName).set(field, value));
	}