Package com.datastax.driver.core.querybuilder

Examples of com.datastax.driver.core.querybuilder.Clause$CompoundClause


            }

            if (list != null)
                list.beforeFetchingNextBatch();
            try {
                Clause inClause = QueryBuilder.in("id", keyStrings);
                //change the batchsize
                Query query = QueryBuilder.select().all().from(keys, cf.getColumnFamily()).where(inClause).limit(100);
                resultSet = session.execute(query);
            } catch (Exception e) {
                System.out.println(" Exception:" + e.getMessage());
View Full Code Here


            if (list != null)
                list.beforeFetchingNextBatch();
            try {
                // CHANGE THE BATCHSIZE
                Clause inClause = QueryBuilder.in("id", keyStrings);
                Query query = QueryBuilder.select().all().from(keys, cf.getColumnFamily()).where(inClause).limit(100);
                resultSet = session.execute(query);
            } catch (Exception e) {
                System.out.println(" Exception:" + e.getMessage());
            }
View Full Code Here

    return c;
  }

  public static Where createRowQuery(Key from, Key to, DboColumnMeta colMeta, Select selectQuery, String rowKey, String indTable) {
        Where selectWhere = selectQuery.where();
        Clause rkClause = QueryBuilder.eq("id", rowKey);
        selectWhere.and(rkClause);

        Object valFrom = null, valTo = null;
    if (colMeta != null) {
      if (from != null) {
        valFrom = colMeta.getStorageType().convertFromNoSql(from.getKey());
                valFrom = checkForBooleanAndNull(valFrom, indTable, colMeta);
      }
      if (to != null) {
        valTo = colMeta.getStorageType().convertFromNoSql(to.getKey());
                valTo = checkForBooleanAndNull(valTo, indTable, colMeta);
      }
    } else
      return selectWhere;

        if (from != null) {
            if (from.isInclusive()) {
                Clause gteClause = QueryBuilder.gte("colname", valFrom);
                selectWhere.and(gteClause);
            } else {
                Clause gtClause = QueryBuilder.gt("colname", valFrom);
                selectWhere.and(gtClause);
            }

        }
        if (to != null) {
            if (to.isInclusive()) {
                Clause lteClause = QueryBuilder.lte("colname", valTo);
                selectWhere.and(lteClause);
            }
            else {
                Clause ltClause = QueryBuilder.lt("colname", valTo);
                selectWhere.and(ltClause);
            }
    }
    return selectWhere;
  }
View Full Code Here

  }

    public static Where createRowQueryFromValues(List<byte[]> values, DboColumnMeta colMeta, Select selectQuery, String rowKey) {
        Where selectWhere = selectQuery.where();

        Clause rkClause = QueryBuilder.eq("id", rowKey);
        selectWhere.and(rkClause);

        Object[] valStrings = new Object[values.size()];
        int count = 0;
        for (byte[] value : values) {
            valStrings[count] = StandardConverters.convertFromBytes(String.class, value);
            count++;
        }
       
        Clause inClause = QueryBuilder.in("colname", valStrings);
        selectWhere.and(inClause);
        return selectWhere;
    }
View Full Code Here

        if (batchListener != null)
            batchListener.beforeFetchingNextBatch();

        columnNameType = sliceInfo.getColumnNameType();
        ResultSet resultSet = null;
        Clause rkClause = QueryBuilder.eq("id", ByteBuffer.wrap(rowKey));
        Query query = null;
        query = QueryBuilder.select().all().from(keys, table).where(rkClause).disableTracing();

        subList = new ArrayList<com.datastax.driver.core.Row>();
        try {
View Full Code Here

        String rowKeyString = StandardConverters.convertFromBytes(String.class, rowKey);

        for (byte[] val : values) {
            Select selectQuery = QueryBuilder.select().all().from(keySpace, indTable).allowFiltering();
            Where selectWhere = selectQuery.where();
            Clause rkClause = QueryBuilder.eq("id", rowKeyString);
            selectWhere.and(rkClause);

            Object value = null;
            value = columnMeta.getStorageType().convertFromNoSql(val);
            value = Cql3Util.checkForBooleanAndNull(value, indTable, columnMeta);

            Clause valClause = QueryBuilder.eq("colname", value);
            selectWhere.and(valClause);

            Query query = selectWhere.disableTracing();

            Future future = session.executeAsync(query);
View Full Code Here

        }

    }

    private void checkIfRowExsits(String table, byte[] rowKey, String colName) {
        Clause rkClause = QueryBuilder.eq("id", ByteBuffer.wrap(rowKey));
        Clause cnClause = QueryBuilder.eq("colname", colName);
        try {
            Query query = QueryBuilder.select().all().from(keys, table).where(rkClause).and(cnClause);
            ResultSet resultSet = session.execute(query);
            if (resultSet.isExhausted())
                return;
View Full Code Here

        String table = lookupOrCreate(colFamily, ormSession);
        if (action.getAction() == null)
            throw new IllegalArgumentException("action param is missing ActionEnum so we know to remove entire row or just columns in the row");
        switch (action.getAction()) {
        case REMOVE_ENTIRE_ROW:
            Clause eqClause = QueryBuilder.eq("id", ByteBuffer.wrap(action.getRowKey()));
            Query query = QueryBuilder.delete().from(keys, table).where(eqClause);
            session.execute(query);
            break;
        case REMOVE_COLUMNS_FROM_ROW:
            removeColumns(action, table);
View Full Code Here

            removeColumnImpl(action.getRowKey(), table, colName);
        }
    }

    private void removeColumnImpl(byte[] rowKey, String table, String colName) {
        Clause eqClause = QueryBuilder.eq("id",ByteBuffer.wrap(rowKey));
        Clause eqColClause = QueryBuilder.eq("colname", colName);
        Query query = QueryBuilder.delete().from(keys, table).where(eqClause).and(eqColClause);
        session.execute(query);
    }
View Full Code Here

        boolean exists = findIndexRow(table, rowKey, fk, indValue);
        if (!exists) {
            if (log.isInfoEnabled())
                log.info("Index: " + column.toString() + " already removed.");
        } else {
            Clause eqClause = QueryBuilder.eq("id", rowKey);
            Clause indClause = null;
            if (indValue != null) {
                indClause = QueryBuilder.eq("colname", indValue);
            } else {
                if (table.equalsIgnoreCase("IntegerIndice")) {
                    indClause = QueryBuilder.eq("colname", ByteBuffer.wrap(new byte[0]));
                } else {
                    indClause = QueryBuilder.eq("colname", "");
                }
            }
            Clause fkClause = QueryBuilder.eq("colvalue", ByteBuffer.wrap(fk));
            Query query = QueryBuilder.delete().from(keys, table).where(eqClause).and(indClause).and(fkClause);
            session.execute(query);
        }
    }
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.querybuilder.Clause$CompoundClause

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.