Package com.datastax.driver.core

Examples of com.datastax.driver.core.BoundStatement


        Date insertTimeSlice = new Date(timeSlice.getTime() + 100);

        for (Row row : rows) {
            permits.acquire();
            int scheduleId = row.getInt(0);
            BoundStatement statement = updateCacheIndex.bind(ImmutableSet.of(scheduleId), bucket.text(), day,
                CACHE_INDEX_PARTITION, timeSlice, startId(scheduleId), insertTimeSlice);
            ResultSetFuture future = session.executeAsync(statement);
            Futures.addCallback(future, new CacheIndexUpdatedCallback(bucket, scheduleId, timeSlice, updatesFinished),
                tasks);
        }
View Full Code Here


            return date;
        }
    }

    private ResultSet getIndexTimeSlice(Bucket bucket, DateTime time) {
        BoundStatement statement = findIndexTimeSlice.bind(bucket.text(), time.toDate());
        return session.execute(statement);
    }
View Full Code Here

    private ResultSet fetch6HourIndexEntries(Date timeSlice) {
        return queryMetricsIndex(Bucket.TWENTY_FOUR_HOUR, timeSlice);
    }

    private ResultSet queryMetricsIndex(Bucket bucket, Date timeSlice) {
        BoundStatement statement = findIndexEntries.bind(bucket.text(), timeSlice);
        return session.execute(statement);
    }
View Full Code Here

        }

        @Override
        public void onSuccess(ResultSet result) {
            permits.acquire();
            BoundStatement statement = deleteIndexEntry.bind(bucket.text(), time, scheduleId);
            ResultSetFuture future = session.executeAsync(statement);
            Futures.addCallback(future, new IndexUpdatedCallback(bucket, scheduleId, updatesFinished), tasks);
        }
View Full Code Here

            .getPropertyNames();
        final Object[] values = new Object[propertyNames.length];
        for (int i = 0; i < propertyNames.length; ++i) {
          values[i] = insertBean.get(propertyNames[i]);
        }
        BoundStatement boundStatement = null;
        synchronized (_insertStatement) {
          boundStatement = _insertStatement.bind(values);
        }
        synchronized (_session) {
          _session.execute(boundStatement);
View Full Code Here

   * <strong>Note: This method is thread-safe.</strong>
   * </p>
   */
  @Override
  public Set<EventBean> lookup(Object[] keys, EventBean[] eventsPerStream) {
    final BoundStatement boundStatement = _statement.bind(keys);

    final ResultSet cassandraResultList = _session.execute(boundStatement);

    final Set<EventBean> esperResultSet = new HashSet<EventBean>();
    final Iterator<Row> it = cassandraResultList.iterator();
View Full Code Here

        byte[] rowkey = action.getRowKey();

        for (Column c : s) {
            try {
                PreparedStatement statement = session.prepare("INSERT INTO " + keys + "." + table + "(id, colname, colvalue) VALUES (?, ?, ?)");
                BoundStatement boundStatement = new BoundStatement(statement);
                String colName = StandardConverters.convertToString(c.getName());
                checkIfRowExsits(table, rowkey, colName);
                if (c.getValue() != null && c.getValue().length != 0) {
                    session.execute(boundStatement.bind(ByteBuffer.wrap(rowkey), colName, ByteBuffer.wrap(c.getValue())));
                } else {
                    session.execute(boundStatement.bind(ByteBuffer.wrap(rowkey), colName, ByteBuffer.wrap(new byte[0])));
                }

            } catch (Exception e) {
                System.out.println(c.getValue() + "Exception:" + e.getMessage());
            }
View Full Code Here

        try {
            Object keyObject = null;
            if (key != null) {
                PreparedStatement statement = session.prepare("INSERT INTO " + keys + "." + table + "(id, colname, colvalue) VALUES (?, ?, ?)");
                BoundStatement boundStatement = new BoundStatement(statement);
                if (indexCfName.equalsIgnoreCase("StringIndice")) {
                    keyObject = StandardConverters.convertFromBytes(String.class, key);
                } else if (indexCfName.equalsIgnoreCase("IntegerIndice")) {
                    keyObject = StandardConverters.convertFromBytes(Long.class, key);
                } else if (indexCfName.equalsIgnoreCase("DecimalIndice")) {
                    keyObject = StandardConverters.convertFromBytes(Float.class, key);
                }
                session.execute(boundStatement.bind(StandardConverters.convertFromBytes(String.class, rowKey), keyObject, ByteBuffer.wrap(value)));
            } else {
                PreparedStatement statement = session.prepare("INSERT INTO " + keys + "." + table + "(id, colname, colvalue) VALUES (?, ?, ?)");
                BoundStatement boundStatement = new BoundStatement(statement);
                if (indexCfName.equalsIgnoreCase("IntegerIndice")) {
                    boundStatement.setString("id", StandardConverters.convertFromBytes(String.class, rowKey));
                    boundStatement.setBytesUnsafe("colname", ByteBuffer.wrap(new byte[0]));
                    boundStatement.setBytes("colvalue", ByteBuffer.wrap(value));
                    session.execute(boundStatement);
                } else
                    session.execute(boundStatement.bind(StandardConverters.convertFromBytes(String.class, rowKey), "", ByteBuffer.wrap(value)));
          }
        } catch (Exception e) {
            System.out.println(indexCfName + " Exception:" + e.getMessage());
        }
View Full Code Here

        final Object[] values = new Object[propertyNames.length];
        for (EventBean insertBean : newData) {
          for (int i = 0; i < propertyNames.length; ++i) {
            values[i] = insertBean.get(propertyNames[i]);
          }
          BoundStatement boundStatement = null;
          synchronized (_insertStatement) {
            boundStatement = _insertStatement.bind(values);
          }
          synchronized (_session) {
            _session.execute(boundStatement);
          }
        }

        _log.debug("Finished insert...");
      }
    }
    // Delete events from window
    else if (newData == null) {
      if (oldData.length > 0) {
        _log.debug("Starting delete...");
        for (EventBean deleteBean : oldData) {
          BoundStatement boundStatement = null;
          synchronized (_deleteStatement) {
            boundStatement = _deleteStatement.bind(deleteBean
                .get(QueryStringBuilder.TABLE_ID));
          }
          synchronized (_session) {
            _session.execute(boundStatement);
          }
        }

        _log.debug("Finished delete...");
      }
    }
    // Update events in window
    else {
      if (newData.length > 0) {
        _log.debug("Starting update...");
        EventBean newDataFirst = newData[0];
        List<String> propertiesToUpdateList = new ArrayList<String>();
        for (String propertyName : propertyNames) {
          if (newDataFirst.get(propertyName) != null) {
            propertiesToUpdateList.add(propertyName);
          }
        }

        String propertiesToUpdate[] = propertiesToUpdateList
            .toArray(new String[propertiesToUpdateList.size()]);
        final String query = QueryStringBuilder.createUpdateQuery(
            _context, propertiesToUpdate);
        PreparedStatement _updateStatement = _session.prepare(query);
        Object primaryKeyValue = null;
        for (EventBean updateBean : newData) {
          final List<Object> values = new ArrayList<Object>();
          for (int i = 0; i < propertiesToUpdate.length; ++i) {
            if (QueryStringBuilder.TABLE_ID
                .equals(propertiesToUpdate[i])) {
              primaryKeyValue = updateBean
                  .get(propertiesToUpdate[i]);
            } else {
              values.add(updateBean.get(propertiesToUpdate[i]));
            }
          }
          values.add(primaryKeyValue);
          BoundStatement boundStatement = null;
          synchronized (_updateStatement) {
            boundStatement = _updateStatement
                .bind(values.toArray());
          }
          synchronized (_session) {
View Full Code Here

      // for(int i=0; i<columns.size(); ++i) {
      // Object key = keys[i];
      // columns.getType(i).
      // }

      final BoundStatement boundStatement = _statement.bind(Arrays
          .copyOfRange(keys, 0, _statement.getVariables().size()));

      final ResultSet cassandraResultList = _session
          .execute(boundStatement);
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.BoundStatement

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.