Java Code Examples for com.datastax.driver.core.BoundStatement#setBool()

The following examples show how to use com.datastax.driver.core.BoundStatement#setBool() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TraceDaoImpl.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private static void bindSlowPoint(BoundStatement boundStatement, String agentRollupId,
        String agentId, String traceId, Trace.Header header, int adjustedTTL, boolean overall,
        boolean partial, boolean cassandra2x) throws IOException {
    int i = bind(boundStatement, agentRollupId, agentId, traceId, header, overall,
            partial && !cassandra2x);
    if (partial) {
        if (cassandra2x) {
            // don't set real_capture_time, so this still looks like data prior to 0.13.1
            boundStatement.setToNull(i++);
        } else {
            boundStatement.setTimestamp(i++, new Date(header.getCaptureTime()));
        }
    }
    boundStatement.setLong(i++, header.getDurationNanos());
    boundStatement.setBool(i++, header.hasError());
    boundStatement.setString(i++, header.getHeadline());
    boundStatement.setString(i++, Strings.emptyToNull(header.getUser()));
    List<Trace.Attribute> attributes = header.getAttributeList();
    if (attributes.isEmpty()) {
        boundStatement.setToNull(i++);
    } else {
        boundStatement.setBytes(i++, Messages.toByteBuffer(attributes));
    }
    boundStatement.setInt(i++, adjustedTTL);
}
 
Example 2
Source File: SceneDaoImpl.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
protected Statement prepareUpsert(SceneDefinition sd, Date ts) {
   BoundStatement bs = upsert.bind();
   bs.setUUID(Column.PLACE_ID.columnName(), sd.getPlaceId());
   bs.setInt(Column.ID.columnName(), sd.getSequenceId());
   bs.setTimestamp(Column.CREATED.columnName(), sd.getCreated());
   bs.setTimestamp(Column.MODIFIED.columnName(), sd.getModified());
   bs.setString(Column.NAME.columnName(), sd.getName());
   bs.setString(Column.DESCRIPTION.columnName(), sd.getDescription());
   bs.setSet(Column.TAGS.columnName(), sd.getTags());
   bs.setString(SceneColumn.TEMPLATE.columnName(), sd.getTemplate());
   bs.setBool(SceneColumn.SATISFIABLE.columnName(), sd.isSatisfiable());
   bs.setBool(SceneColumn.NOTIFICATION.columnName(), sd.isNotification());
   bs.setTimestamp(SceneColumn.LAST_FIRE_TIME.columnName(), sd.getLastFireTime());
   bs.setString(SceneColumn.LAST_FIRE_STATE.columnName(), sd.getLastFireState());
   bs.setBool(SceneColumn.ENABLED.columnName(),sd.isEnabled());

   if(sd.getAction() != null) {
      bs.setBytes(ActionColumn.ACTION.columnName(), ByteBuffer.wrap(sd.getAction()));
   }
   else {
      bs.setBytes(ActionColumn.ACTION.columnName(), ByteBuffer.wrap(new byte [] {}));
   }
   return bs;
}
 
Example 3
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private void rewriteAgentConfigTablePart1() throws Exception {
    dropTableIfExists("agent_config_temp");
    session.updateSchemaWithRetry("create table if not exists agent_config_temp"
            + " (agent_rollup_id varchar, config blob, config_update boolean,"
            + " config_update_token uuid, primary key (agent_rollup_id))");
    PreparedStatement insertTempPS = session.prepare("insert into agent_config_temp"
            + " (agent_rollup_id, config, config_update, config_update_token) values"
            + " (?, ?, ?, ?)");
    ResultSet results = session.read("select agent_rollup_id, config, config_update,"
            + " config_update_token from agent_config");
    for (Row row : results) {
        BoundStatement boundStatement = insertTempPS.bind();
        boundStatement.setString(0, row.getString(0));
        boundStatement.setBytes(1, row.getBytes(1));
        boundStatement.setBool(2, row.getBool(2));
        boundStatement.setUUID(3, row.getUUID(3));
        session.write(boundStatement);
    }
}
 
Example 4
Source File: CassandraBaseTimeseriesDao.java    From iotplatform with Apache License 2.0 6 votes vote down vote up
private static void addValue(KvEntry kvEntry, BoundStatement stmt, int column) {
    switch (kvEntry.getDataType()) {
        case BOOLEAN:
            stmt.setBool(column, kvEntry.getBooleanValue().get().booleanValue());
            break;
        case STRING:
            stmt.setString(column, kvEntry.getStrValue().get());
            break;
        case LONG:
            stmt.setLong(column, kvEntry.getLongValue().get().longValue());
            break;
        case DOUBLE:
            stmt.setDouble(column, kvEntry.getDoubleValue().get().doubleValue());
            break;
    }
}
 
Example 5
Source File: EnrichedCustomerServiceCassandraOutputOperator.java    From examples with Apache License 2.0 6 votes vote down vote up
@Override
protected Statement setStatementParameters(PreparedStatement updateCommand, EnrichedCustomerService tuple)
    throws DriverException
{
  final BoundStatement boundStmnt = new BoundStatement(updateCommand);
  boundStmnt.setLong(0, ++id);
  boundStmnt.setString(1, tuple.imsi);
  boundStmnt.setInt(2, tuple.totalDuration);
  boundStmnt.setInt(3, tuple.wait);
  boundStmnt.setString(4, tuple.zipCode);
  boundStmnt.setString(5, tuple.issueType.name());
  boundStmnt.setBool(6, tuple.satisfied);
  boundStmnt.setString(7, tuple.operatorCode);
  boundStmnt.setString(8, tuple.deviceBrand);
  boundStmnt.setString(9, tuple.deviceModel);

  //or boundStatement.bind();
  return boundStmnt;

}
 
Example 6
Source File: CustomerServiceCassandraOutputOperator.java    From examples with Apache License 2.0 6 votes vote down vote up
@Override
protected Statement setStatementParameters(PreparedStatement updateCommand, CustomerService tuple)
    throws DriverException
{
  final BoundStatement boundStmnt = new BoundStatement(updateCommand);
  boundStmnt.setLong(0, ++id);
  boundStmnt.setString(1, tuple.imsi);
  boundStmnt.setInt(2, tuple.totalDuration);
  boundStmnt.setInt(3, tuple.wait);
  boundStmnt.setString(4, tuple.zipCode);
  boundStmnt.setString(5, tuple.issueType.name());
  boundStmnt.setBool(6, tuple.satisfied);

  //or boundStatement.bind();
  return boundStmnt;

}
 
Example 7
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private void addDefaultGaugeNameToUiConfigs() throws Exception {
    PreparedStatement insertPS = session.prepare("insert into agent_config (agent_rollup_id,"
            + " config, config_update, config_update_token) values (?, ?, ?, ?)");
    ResultSet results = session.read("select agent_rollup_id, config from agent_config");
    for (Row row : results) {
        String agentRollupId = row.getString(0);
        AgentConfig oldAgentConfig;
        try {
            oldAgentConfig = AgentConfig.parseFrom(checkNotNull(row.getBytes(1)));
        } catch (InvalidProtocolBufferException e) {
            logger.error(e.getMessage(), e);
            continue;
        }
        AgentConfig agentConfig = oldAgentConfig.toBuilder()
                .setUiDefaultsConfig(oldAgentConfig.getUiDefaultsConfig().toBuilder()
                        .addAllDefaultGaugeName(ConfigDefaults.UI_DEFAULTS_GAUGE_NAMES))
                .build();
        BoundStatement boundStatement = insertPS.bind();
        int i = 0;
        boundStatement.setString(i++, agentRollupId);
        boundStatement.setBytes(i++, ByteBuffer.wrap(agentConfig.toByteArray()));
        boundStatement.setBool(i++, true);
        boundStatement.setUUID(i++, UUIDs.random());
        session.write(boundStatement);
    }
}
 
Example 8
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private void renameConfigTable() throws Exception {
    if (!tableExists("config")) {
        // previously failed mid-upgrade prior to updating schema version
        return;
    }
    session.createTableWithLCS("create table if not exists agent_config (agent_rollup_id"
            + " varchar, config blob, config_update boolean, config_update_token uuid,"
            + " primary key (agent_rollup_id))");
    ResultSet results = session.read("select agent_rollup_id, config,"
            + " config_update, config_update_token from config");
    PreparedStatement insertPS =
            session.prepare("insert into agent_config (agent_rollup_id, config, config_update,"
                    + " config_update_token) values (?, ?, ?, ?)");
    for (Row row : results) {
        BoundStatement boundStatement = insertPS.bind();
        boundStatement.setString(0, row.getString(0));
        boundStatement.setBytes(1, row.getBytes(1));
        boundStatement.setBool(2, row.getBool(2));
        boundStatement.setUUID(3, row.getUUID(3));
        session.write(boundStatement);
    }
    dropTableIfExists("config");
}
 
Example 9
Source File: UserDao.java    From glowroot with Apache License 2.0 5 votes vote down vote up
UserDao(Session session, ClusterManager clusterManager) throws Exception {
    this.session = session;

    boolean createAnonymousUser = session.getTable("user") == null;

    session.createTableWithLCS("create table if not exists user (username varchar, ldap"
            + " boolean, password_hash varchar, roles set<varchar>, primary key (username))");

    readPS = session.prepare("select username, ldap, password_hash, roles from user");
    insertIfNotExistsPS = session.prepare("insert into user (username, ldap, password_hash,"
            + " roles) values (?, ?, ?, ?) if not exists");
    insertPS = session.prepare(
            "insert into user (username, ldap, password_hash, roles) values (?, ?, ?, ?)");
    deletePS = session.prepare("delete from user where username = ?");

    if (createAnonymousUser) {
        // don't use "if not exists" here since it's not needed and has more chance to fail,
        // leaving the schema in a bad state (with the user table created, but no anonymous
        // user)
        BoundStatement boundStatement = insertPS.bind();
        int i = 0;
        boundStatement.setString(i++, "anonymous");
        boundStatement.setBool(i++, false);
        boundStatement.setString(i++, "");
        boundStatement.setSet(i++, ImmutableSet.of("Administrator"));
        session.write(boundStatement);
    }

    allUserConfigsCache = clusterManager.createSelfBoundedCache("allUserConfigsCache",
            new AllUsersCacheLoader());
}
 
Example 10
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private void rewriteAgentConfigTablePart2() throws Exception {
    if (!tableExists("agent_config_temp")) {
        // previously failed mid-upgrade prior to updating schema version
        return;
    }
    dropTableIfExists("agent_config");
    session.createTableWithLCS("create table if not exists agent_config (agent_rollup_id"
            + " varchar, config blob, config_update boolean, config_update_token uuid, primary"
            + " key (agent_rollup_id))");
    PreparedStatement insertPS = session.prepare("insert into agent_config"
            + " (agent_rollup_id, config, config_update, config_update_token) values"
            + " (?, ?, ?, ?)");
    Map<String, V09AgentRollup> v09AgentRollups = getV09AgentRollupsFromAgentRollupTable();
    ResultSet results = session.read("select agent_rollup_id, config, config_update,"
            + " config_update_token from agent_config_temp");
    for (Row row : results) {
        String v09AgentRollupId = row.getString(0);
        V09AgentRollup v09AgentRollup = v09AgentRollups.get(v09AgentRollupId);
        if (v09AgentRollup == null) {
            // v09AgentRollupId was manually deleted (via the UI) from the agent_rollup
            // table in which case its parent is no longer known and best to ignore
            continue;
        }
        BoundStatement boundStatement = insertPS.bind();
        boundStatement.setString(0, v09AgentRollup.agentRollupId());
        boundStatement.setBytes(1, row.getBytes(1));
        boundStatement.setBool(2, row.getBool(2));
        boundStatement.setUUID(3, row.getUUID(3));
        session.write(boundStatement);
    }
    dropTableIfExists("agent_config_temp");
}
 
Example 11
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private void upgradeAlertConfigs() throws Exception {
    PreparedStatement insertPS = session.prepare("insert into agent_config (agent_rollup_id,"
            + " config, config_update, config_update_token) values (?, ?, ?, ?)");
    ResultSet results = session.read("select agent_rollup_id, config from agent_config");
    for (Row row : results) {
        String agentRollupId = row.getString(0);
        AgentConfig oldAgentConfig;
        try {
            oldAgentConfig = AgentConfig.parseFrom(checkNotNull(row.getBytes(1)));
        } catch (InvalidProtocolBufferException e) {
            logger.error(e.getMessage(), e);
            continue;
        }
        List<OldAlertConfig> oldAlertConfigs = oldAgentConfig.getOldAlertConfigList();
        if (oldAlertConfigs.isEmpty()) {
            continue;
        }
        AgentConfig agentConfig = upgradeOldAgentConfig(oldAgentConfig);
        BoundStatement boundStatement = insertPS.bind();
        int i = 0;
        boundStatement.setString(i++, agentRollupId);
        boundStatement.setBytes(i++, ByteBuffer.wrap(agentConfig.toByteArray()));
        boundStatement.setBool(i++, true);
        boundStatement.setUUID(i++, UUIDs.random());
        session.write(boundStatement);
    }
}
 
Example 12
Source File: UserDao.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private static void bindInsert(BoundStatement boundStatement, UserConfig userConfig) {
    int i = 0;
    boundStatement.setString(i++, userConfig.username());
    boundStatement.setBool(i++, userConfig.ldap());
    boundStatement.setString(i++, userConfig.passwordHash());
    boundStatement.setSet(i++, userConfig.roles());
}
 
Example 13
Source File: CassandraAlarmIncidentDAO.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public void upsert(AlarmIncident incident) {
   PreparedStatement pStmt = incident.isCleared() ? upsertWithTtl : upsert;
   BoundStatement bound = new BoundStatement(pStmt);
   bound.setUUID(Column.placeid.name(), incident.getPlaceId());
   bound.setUUID(Column.incidentid.name(), incident.getId());
   bound.setString(Column.alertstate.name(), incident.getAlertState().name());
   if(incident.getPlatformAlertState() == null) {
      bound.setString(Column.platformstate.name(), incident.getAlertState().name());
   }
   else {
      bound.setString(Column.platformstate.name(), incident.getPlatformAlertState().name());
   }
   if(incident.getHubAlertState() == null) {
      bound.setToNull(Column.hubstate.name());
   }
   else {
      bound.setString(Column.hubstate.name(), incident.getHubAlertState().name());
   }
   bound.setSet(Column.activealerts.name(), incident.getActiveAlerts());
   bound.setSet(Column.additionalalerts.name(), incident.getAdditionalAlerts().stream().map(AlertType::name).collect(Collectors.toSet()));
   bound.setString(Column.alert.name(), incident.getAlert().name());
   bound.setString(Column.cancelledby.name(), incident.getCancelledBy() == null ? null : incident.getCancelledBy().getRepresentation());
   bound.setTimestamp(Column.prealertendtime.name(), incident.getPrealertEndTime());
   bound.setTimestamp(Column.endtime.name(), incident.getEndTime());
   bound.setString(Column.monitoringstate.name(), incident.getMonitoringState().name());
   bound.setList(Column.tracker.name(), incident.getTracker().stream().map((te) -> JSON.toJson(te.toMap())).collect(Collectors.toList()));
   bound.setBool(Column.mockincident.name(), incident.isMockIncident());
   bound.setBool(Column.monitored.name(), incident.isMonitored());
   bound.setBool(Column.confirmed.name(),  incident.isConfirmed());
   session.execute(bound);
}
 
Example 14
Source File: CassandraBaseAttributesDao.java    From iotplatform with Apache License 2.0 5 votes vote down vote up
@Override
public ListenableFuture<Void> save(EntityId entityId, String attributeType, AttributeKvEntry attribute) {
    BoundStatement stmt = getSaveStmt().bind();
    stmt.setString(0, entityId.getEntityType().name());
    stmt.setUUID(1, entityId.getId());
    stmt.setString(2, attributeType);
    stmt.setString(3, attribute.getKey());
    stmt.setLong(4, attribute.getLastUpdateTs());
    stmt.setString(5, attribute.getStrValue().orElse(null));
    if (attribute.getBooleanValue().isPresent()) {
        stmt.setBool(6, attribute.getBooleanValue().get());
    } else {
        stmt.setToNull(6);
    }
    if (attribute.getLongValue().isPresent()) {
        stmt.setLong(7, attribute.getLongValue().get());
    } else {
        stmt.setToNull(7);
    }
    if (attribute.getDoubleValue().isPresent()) {
        stmt.setDouble(8, attribute.getDoubleValue().get());
    } else {
        stmt.setToNull(8);
    }
    log.trace("Generated save stmt [{}] for entityId {} and attributeType {} and attribute", stmt, entityId, attributeType, attribute);
    return getFuture(executeAsyncWrite(stmt), rs -> null);
}
 
Example 15
Source File: HubDAOImpl.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
private void updateDisallowCell(String hubId, boolean disallow, String reason) {
   Preconditions.checkNotNull(hubId, "hubId is required");
   BoundStatement stmt = new BoundStatement(updateCellDisallow);
   stmt.setBool(HubEntityColumns.DISALLOW_CELL, disallow);
   stmt.setString(HubEntityColumns.DISALLOW_CELL_REASON, reason);
   stmt.setString(HubEntityColumns.ID, hubId);
   try(Context ctxt = updateDisallowCellTimer.time()) {
      session.execute(stmt);
   }
}
 
Example 16
Source File: RuleDaoImpl.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
protected Statement prepareUpsert(RuleDefinition definition, Date ts) {
   // note this method does not update lastExecuted
   BoundStatement bs = upsert.bind();
   bs.setUUID(Column.PLACE_ID.columnName(), definition.getPlaceId());
   bs.setInt(Column.ID.columnName(), definition.getSequenceId());
   bs.setTimestamp(Column.CREATED.columnName(), definition.getCreated());
   bs.setTimestamp(Column.MODIFIED.columnName(), definition.getModified());
   bs.setString(Column.NAME.columnName(), definition.getName());
   bs.setString(Column.DESCRIPTION.columnName(), definition.getDescription());
   bs.setSet(Column.TAGS.columnName(), definition.getTags());
   bs.setBool(RuleColumn.DISABLED.columnName(), definition.isDisabled());
   bs.setBool(RuleColumn.SUSPENDED.columnName(), definition.isSuspended());
   bs.setString(RuleColumn.TEMPLATE2.columnName(), definition.getRuleTemplate());
   bs.setString(RuleColumn.VARIABLES.columnName(), JSON.toJson(definition.getVariables()));

   if((definition instanceof StatefulRuleDefinition)) {
      StatefulRuleDefinition stateful = (StatefulRuleDefinition)definition;
      bs.setString(RuleColumn.ACTIONCONFIG.columnName(), JSON.toJson(stateful.getAction()));
      bs.setString(RuleColumn.CONDITIONCONFIG.columnName(),JSON.toJson(stateful.getCondition()));
      bs.setToNull(RuleColumn.EXPRESSIONS.columnName());
   }

   if((definition instanceof LegacyRuleDefinition)) {
      bs.setToNull(RuleColumn.ACTIONCONFIG.columnName());
      bs.setToNull(RuleColumn.CONDITIONCONFIG.columnName());
      bs.setString(RuleColumn.EXPRESSIONS.columnName(), JSON.toJson(((LegacyRuleDefinition) definition).getExpressions()));
   }

   return bs;
}
 
Example 17
Source File: AgentConfigDao.java    From glowroot with Apache License 2.0 4 votes vote down vote up
void update(String agentRollupId, AgentConfigUpdater agentConfigUpdater, boolean centralOnly)
        throws Exception {
    for (int j = 0; j < 10; j++) {
        BoundStatement boundStatement = readPS.bind();
        boundStatement.setString(0, agentRollupId);
        ResultSet results = session.read(boundStatement);
        Row row = results.one();
        if (row == null) {
            throw new IllegalStateException("No config found: " + agentRollupId);
        }
        ByteString currValue = ByteString.copyFrom(checkNotNull(row.getBytes(0)));
        AgentConfig currAgentConfig = AgentConfig.parseFrom(currValue);
        if (!centralOnly && currAgentConfig.getConfigReadOnly()) {
            throw new IllegalStateException("This agent is running with config.readOnly=true so"
                    + " it does not allow config updates via the central collector");
        }
        AgentConfig updatedAgentConfig = agentConfigUpdater.updateAgentConfig(currAgentConfig);

        if (centralOnly) {
            boundStatement = updateCentralOnlyPS.bind();
        } else {
            boundStatement = updatePS.bind();
        }
        int i = 0;
        boundStatement.setBytes(i++, ByteBuffer.wrap(updatedAgentConfig.toByteArray()));
        if (!centralOnly) {
            boundStatement.setBool(i++, true);
            boundStatement.setUUID(i++, UUIDs.random());
        }
        boundStatement.setString(i++, agentRollupId);
        boundStatement.setBytes(i++, ByteBuffer.wrap(currValue.toByteArray()));
        results = session.update(boundStatement);
        row = checkNotNull(results.one());
        boolean applied = row.getBool("[applied]");
        if (applied) {
            agentConfigCache.invalidate(agentRollupId);
            String updatedDisplay = updatedAgentConfig.getGeneralConfig().getDisplay();
            String currDisplay = currAgentConfig.getGeneralConfig().getDisplay();
            if (!updatedDisplay.equals(currDisplay)) {
                agentDisplayDao.store(agentRollupId, updatedDisplay);
            }
            return;
        }
        MILLISECONDS.sleep(200);
    }
    throw new OptimisticLockException();
}
 
Example 18
Source File: CassandraPOJOOutputOperator.java    From attic-apex-malhar with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected Statement setStatementParameters(PreparedStatement updateCommand, Object tuple) throws DriverException
{
  final BoundStatement boundStmnt = new BoundStatement(updateCommand);
  final int size = columnDataTypes.size();
  for (int i = 0; i < size; i++) {
    final DataType type = columnDataTypes.get(i);
    switch (type.getName()) {
      case UUID:
        final UUID id = ((Getter<Object, UUID>)getters.get(i)).get(tuple);
        boundStmnt.setUUID(i, id);
        break;
      case ASCII:
      case VARCHAR:
      case TEXT:
        final String ascii = ((Getter<Object, String>)getters.get(i)).get(tuple);
        boundStmnt.setString(i, ascii);
        break;
      case BOOLEAN:
        final boolean bool = ((GetterBoolean<Object>)getters.get(i)).get(tuple);
        boundStmnt.setBool(i, bool);
        break;
      case INT:
        final int intValue = ((GetterInt<Object>)getters.get(i)).get(tuple);
        boundStmnt.setInt(i, intValue);
        break;
      case BIGINT:
      case COUNTER:
        final long longValue = ((GetterLong<Object>)getters.get(i)).get(tuple);
        boundStmnt.setLong(i, longValue);
        break;
      case FLOAT:
        final float floatValue = ((GetterFloat<Object>)getters.get(i)).get(tuple);
        boundStmnt.setFloat(i, floatValue);
        break;
      case DOUBLE:
        final double doubleValue = ((GetterDouble<Object>)getters.get(i)).get(tuple);
        boundStmnt.setDouble(i, doubleValue);
        break;
      case DECIMAL:
        final BigDecimal decimal = ((Getter<Object, BigDecimal>)getters.get(i)).get(tuple);
        boundStmnt.setDecimal(i, decimal);
        break;
      case SET:
        Set<?> set = ((Getter<Object, Set<?>>)getters.get(i)).get(tuple);
        boundStmnt.setSet(i, set);
        break;
      case MAP:
        final Map<?,?> map = ((Getter<Object, Map<?,?>>)getters.get(i)).get(tuple);
        boundStmnt.setMap(i, map);
        break;
      case LIST:
        final List<?> list = ((Getter<Object, List<?>>)getters.get(i)).get(tuple);
        boundStmnt.setList(i, list);
        break;
      case TIMESTAMP:
        final Date date = ((Getter<Object, Date>)getters.get(i)).get(tuple);
        boundStmnt.setDate(i, LocalDate.fromMillisSinceEpoch(date.getTime()));
        break;
      default:
        throw new RuntimeException("unsupported data type " + type.getName());
    }
  }
  return boundStmnt;
}
 
Example 19
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 4 votes vote down vote up
private static void copyBool(Row row, BoundStatement boundStatement, int i) {
    boundStatement.setBool(i, row.getBool(i));
}