Java Code Examples for org.skife.jdbi.v2.sqlobject.SqlUpdate

The following examples show how to use org.skife.jdbi.v2.sqlobject.SqlUpdate. These examples are extracted from open source projects. 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 Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 6 votes vote down vote up
@SqlUpdate("INSERT INTO tables (\n" +
        "  schema_name, table_name, compaction_enabled, organization_enabled, distribution_id,\n" +
        "  create_time, update_time, table_version,\n" +
        "  shard_count, row_count, compressed_size, uncompressed_size)\n" +
        "VALUES (\n" +
        "  :schemaName, :tableName, :compactionEnabled, :organizationEnabled, :distributionId,\n" +
        "  :createTime, :createTime, 0,\n" +
        "  0, 0, 0, 0)\n")
@GetGeneratedKeys
long insertTable(
        @Bind("schemaName") String schemaName,
        @Bind("tableName") String tableName,
        @Bind("compactionEnabled") boolean compactionEnabled,
        @Bind("organizationEnabled") boolean organizationEnabled,
        @Bind("distributionId") Long distributionId,
        @Bind("createTime") long createTime);
 
Example 2
Source Project: presto   Source File: SchemaDao.java    License: Apache License 2.0 6 votes vote down vote up
@SqlUpdate("CREATE TABLE IF NOT EXISTS tables (\n" +
        "  table_id BIGINT PRIMARY KEY AUTO_INCREMENT,\n" +
        "  schema_name VARCHAR(255) NOT NULL,\n" +
        "  table_name VARCHAR(255) NOT NULL,\n" +
        "  temporal_column_id BIGINT,\n" +
        "  compaction_enabled BOOLEAN NOT NULL,\n" +
        "  organization_enabled BOOLEAN NOT NULL,\n" +
        "  distribution_id BIGINT,\n" +
        "  create_time BIGINT NOT NULL,\n" +
        "  update_time BIGINT NOT NULL,\n" +
        "  table_version BIGINT NOT NULL,\n" +
        "  shard_count BIGINT NOT NULL,\n" +
        "  row_count BIGINT NOT NULL,\n" +
        "  compressed_size BIGINT NOT NULL,\n" +
        "  uncompressed_size BIGINT NOT NULL,\n" +
        "  maintenance_blocked DATETIME,\n" +
        "  UNIQUE (schema_name, table_name),\n" +
        "  UNIQUE (distribution_id, table_id),\n" +
        "  UNIQUE (maintenance_blocked, table_id),\n" +
        "  FOREIGN KEY (distribution_id) REFERENCES distributions (distribution_id)\n" +
        ")")
void createTableTables();
 
Example 3
Source Project: presto   Source File: SchemaDao.java    License: Apache License 2.0 6 votes vote down vote up
@SqlUpdate("CREATE TABLE IF NOT EXISTS columns (\n" +
        "  table_id BIGINT NOT NULL,\n" +
        "  column_id BIGINT NOT NULL,\n" +
        "  column_name VARCHAR(255) NOT NULL,\n" +
        "  ordinal_position INT NOT NULL,\n" +
        "  data_type VARCHAR(255) NOT NULL,\n" +
        "  sort_ordinal_position INT,\n" +
        "  bucket_ordinal_position INT,\n" +
        "  PRIMARY KEY (table_id, column_id),\n" +
        "  UNIQUE (table_id, column_name),\n" +
        "  UNIQUE (table_id, ordinal_position),\n" +
        "  UNIQUE (table_id, sort_ordinal_position),\n" +
        "  UNIQUE (table_id, bucket_ordinal_position),\n" +
        "  FOREIGN KEY (table_id) REFERENCES tables (table_id)\n" +
        ")")
void createTableColumns();
 
Example 4
Source Project: presto   Source File: SchemaDao.java    License: Apache License 2.0 6 votes vote down vote up
@SqlUpdate("CREATE TABLE IF NOT EXISTS shards (\n" +
        "  shard_id BIGINT PRIMARY KEY AUTO_INCREMENT,\n" +
        "  shard_uuid BINARY(16) NOT NULL,\n" +
        "  table_id BIGINT NOT NULL,\n" +
        "  bucket_number INT,\n" +
        "  create_time DATETIME NOT NULL,\n" +
        "  row_count BIGINT NOT NULL,\n" +
        "  compressed_size BIGINT NOT NULL,\n" +
        "  uncompressed_size BIGINT NOT NULL,\n" +
        "  xxhash64 BIGINT NOT NULL,\n" +
        "  UNIQUE (shard_uuid),\n" +
        // include a covering index organized by table_id
        "  UNIQUE (table_id, bucket_number, shard_id, shard_uuid, create_time, row_count, compressed_size, uncompressed_size, xxhash64),\n" +
        "  FOREIGN KEY (table_id) REFERENCES tables (table_id)\n" +
        ")")
void createTableShards();
 
Example 5
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("UPDATE tables SET\n" +
        "  shard_count = shard_count + :shardCount \n" +
        ", row_count = row_count + :rowCount\n" +
        ", compressed_size = compressed_size + :compressedSize\n" +
        ", uncompressed_size = uncompressed_size + :uncompressedSize\n" +
        "WHERE table_id = :tableId")
void updateTableStats(
        @Bind("tableId") long tableId,
        @Bind("shardCount") long shardCount,
        @Bind("rowCount") long rowCount,
        @Bind("compressedSize") long compressedSize,
        @Bind("uncompressedSize") long uncompressedSize);
 
Example 6
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("INSERT INTO columns (table_id, column_id, column_name, ordinal_position, data_type, sort_ordinal_position, bucket_ordinal_position)\n" +
        "VALUES (:tableId, :columnId, :columnName, :ordinalPosition, :dataType, :sortOrdinalPosition, :bucketOrdinalPosition)")
void insertColumn(
        @Bind("tableId") long tableId,
        @Bind("columnId") long columnId,
        @Bind("columnName") String columnName,
        @Bind("ordinalPosition") int ordinalPosition,
        @Bind("dataType") String dataType,
        @Bind("sortOrdinalPosition") Integer sortOrdinalPosition,
        @Bind("bucketOrdinalPosition") Integer bucketOrdinalPosition);
 
Example 7
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("UPDATE tables SET\n" +
        "  schema_name = :newSchemaName\n" +
        ", table_name = :newTableName\n" +
        "WHERE table_id = :tableId")
void renameTable(
        @Bind("tableId") long tableId,
        @Bind("newSchemaName") String newSchemaName,
        @Bind("newTableName") String newTableName);
 
Example 8
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("INSERT INTO distributions (distribution_name, column_types, bucket_count)\n" +
        "VALUES (:distributionName, :columnTypes, :bucketCount)")
@GetGeneratedKeys
long insertDistribution(
        @Bind("distributionName") String distributionName,
        @Bind("columnTypes") String columnTypes,
        @Bind("bucketCount") int bucketCount);
 
Example 9
Source Project: cassandra-reaper   Source File: IStoragePostgreSql.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate(SQL_STORE_NODE_METRICS)
int storeNodeMetrics(
    @Bind("runId") long runId,
    @Bind("node") String node,
    @Bind("cluster") String cluster,
    @Bind("datacenter") String datacenter,
    @Bind("requested") Boolean requested,
    @Bind("pendingCompactions") int pendingCompactions,
    @Bind("hasRepairRunning") Boolean hasRepairRunning,
    @Bind("activeAntiCompactions") int activeAntiCompactions
);
 
Example 10
Source Project: presto   Source File: SchemaDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("CREATE TABLE IF NOT EXISTS views (\n" +
        "  schema_name VARCHAR(255) NOT NULL,\n" +
        "  table_name VARCHAR(255) NOT NULL,\n" +
        "  data TEXT NOT NULL,\n" +
        "  PRIMARY KEY (schema_name, table_name)\n" +
        ")")
void createTableViews();
 
Example 11
Source Project: presto   Source File: SchemaDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("CREATE TABLE IF NOT EXISTS shard_nodes (\n" +
        "  shard_id BIGINT NOT NULL,\n" +
        "  node_id INT NOT NULL,\n" +
        "  PRIMARY KEY (shard_id, node_id),\n" +
        "  UNIQUE (node_id, shard_id),\n" +
        "  FOREIGN KEY (shard_id) REFERENCES shards (shard_id),\n" +
        "  FOREIGN KEY (node_id) REFERENCES nodes (node_id)\n" +
        ")")
void createTableShardNodes();
 
Example 12
Source Project: cassandra-reaper   Source File: IStoragePostgreSql.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate(SQL_UPDATE_LEAD)
int updateLeaderEntry(
    @Bind("leaderId") UUID leaderId,
    @Bind("reaperInstanceId") UUID reaperInstanceId,
    @Bind("reaperInstanceHost") String reaperInstanceHost,
    @Bind("expirationTime") Instant expirationTime
);
 
Example 13
Source Project: presto   Source File: SchemaDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("CREATE TABLE IF NOT EXISTS created_shards (\n" +
        "  shard_uuid BINARY(16) NOT NULL,\n" +
        "  transaction_id BIGINT NOT NULL,\n" +
        "  PRIMARY KEY (shard_uuid),\n" +
        "  UNIQUE (transaction_id, shard_uuid),\n" +
        "  FOREIGN KEY (transaction_id) REFERENCES transactions (transaction_id)\n" +
        ")")
void createTableCreatedShards();
 
Example 14
Source Project: presto   Source File: SchemaDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("CREATE TABLE IF NOT EXISTS buckets (\n" +
        "  distribution_id BIGINT NOT NULL,\n" +
        "  bucket_number INT NOT NULL,\n" +
        "  node_id INT NOT NULL,\n" +
        "  PRIMARY KEY (distribution_id, bucket_number),\n" +
        "  UNIQUE (node_id, distribution_id, bucket_number),\n" +
        "  FOREIGN KEY (distribution_id) REFERENCES distributions (distribution_id),\n" +
        "  FOREIGN KEY (node_id) REFERENCES nodes (node_id)\n" +
        ")")
void createTableBuckets();
 
Example 15
Source Project: presto   Source File: MySqlShardDao.java    License: Apache License 2.0 5 votes vote down vote up
@Override
// 'order by' is needed in this statement in order to make it compatible with statement-based replication
@SqlUpdate("DELETE FROM transactions\n" +
        "WHERE end_time < :maxEndTime\n" +
        "  AND successful IN (TRUE, FALSE)\n" +
        "  AND transaction_id NOT IN (SELECT transaction_id FROM created_shards)\n" +
        "ORDER BY end_time, transaction_id\n" +
        "LIMIT " + CLEANUP_TRANSACTIONS_BATCH_SIZE)
int deleteOldCompletedTransactions(@Bind("maxEndTime") Timestamp maxEndTime);
 
Example 16
Source Project: presto   Source File: ShardDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("UPDATE buckets SET node_id = :nodeId\n" +
        "WHERE distribution_id = :distributionId\n" +
        "  AND bucket_number = :bucketNumber")
void updateBucketNode(
        @Bind("distributionId") long distributionId,
        @Bind("bucketNumber") int bucketNumber,
        @Bind("nodeId") int nodeId);
 
Example 17
Source Project: presto   Source File: ShardOrganizerDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("UPDATE shard_organizer_jobs SET last_start_time = :lastStartTime\n" +
        "   WHERE node_identifier = :nodeIdentifier\n" +
        "     AND table_id = :tableId")
void updateLastStartTime(
        @Bind("nodeIdentifier") String nodeIdentifier,
        @Bind("tableId") long tableId,
        @Bind("lastStartTime") long lastStartTime);
 
Example 18
Source Project: presto   Source File: TestingShardDao.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate("INSERT INTO shards (shard_uuid, table_id, bucket_number, create_time, row_count, compressed_size, uncompressed_size, xxhash64)\n" +
        "VALUES (:shardUuid, :tableId, :bucketNumber, CURRENT_TIMESTAMP, :rowCount, :compressedSize, :uncompressedSize, :xxhash64)")
@GetGeneratedKeys
long insertShard(
        @Bind("shardUuid") UUID shardUuid,
        @Bind("tableId") long tableId,
        @Bind("bucketNumber") Integer bucketNumber,
        @Bind("rowCount") long rowCount,
        @Bind("compressedSize") long compressedSize,
        @Bind("uncompressedSize") long uncompressedSize,
        @Bind("xxhash64") long xxhash64);
 
Example 19
Source Project: cassandra-reaper   Source File: IStoragePostgreSql.java    License: Apache License 2.0 5 votes vote down vote up
@SqlUpdate(SQL_INSERT_OPERATIONS)
int insertOperations(
    @Bind("cluster") String cluster,
    @Bind("type") String operationType,
    @Bind("host") String host,
    @Bind("data") String data
);
 
Example 20
Source Project: cassandra-reaper   Source File: IStoragePostgreSql.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate(SQL_UPDATE_SOURCE_NODE_TIMESTAMP)
int updateMetricSourceNodeTimestamp(
    @Bind("cluster") String cluster,
    @Bind("host") String host,
    @Bind("timestamp") Instant timestamp
);
 
Example 21
Source Project: cassandra-reaper   Source File: IStoragePostgreSql.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate(SQL_INSERT_REPAIR_UNIT)
@GetGeneratedKeys
long insertRepairUnit(
    @BindBean RepairUnit newRepairUnit);
 
Example 22
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate("DELETE FROM columns\n" +
        " WHERE table_id = :tableId\n" +
        "  AND column_id = :columnId")
void dropColumn(
        @Bind("tableId") long tableId,
        @Bind("columnId") long column);
 
Example 23
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate("INSERT INTO views (schema_name, table_name, data)\n" +
        "VALUES (:schemaName, :tableName, :data)")
void insertView(
        @Bind("schemaName") String schemaName,
        @Bind("tableName") String tableName,
        @Bind("data") String data);
 
Example 24
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate("DELETE FROM tables WHERE table_id = :tableId")
int dropTable(@Bind("tableId") long tableId);
 
Example 25
Source Project: cassandra-reaper   Source File: IStoragePostgreSql.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate(SQL_DELETE_REPAIR_UNITS)
int deleteRepairUnits(
    @Bind("clusterName") String clusterName);
 
Example 26
Source Project: cassandra-reaper   Source File: IStoragePostgreSql.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate(SQL_UPDATE_HEARTBEAT)
int updateHeartbeat(
    @Bind("reaperInstanceId") UUID reaperInstanceId,
    @Bind("reaperInstanceHost") String reaperInstanceHost
);
 
Example 27
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate("UPDATE tables SET\n" +
        "temporal_column_id = :columnId\n" +
        "WHERE table_id = :tableId")
void updateTemporalColumnId(
        @Bind("tableId") long tableId,
        @Bind("columnId") long columnId);
 
Example 28
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate("UPDATE tables SET maintenance_blocked = CURRENT_TIMESTAMP\n" +
        "WHERE table_id = :tableId\n" +
        "  AND maintenance_blocked IS NULL")
void blockMaintenance(@Bind("tableId") long tableId);
 
Example 29
Source Project: presto   Source File: MetadataDao.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate("UPDATE tables SET maintenance_blocked = NULL\n" +
        "WHERE maintenance_blocked IS NOT NULL")
void unblockAllMaintenance();
 
Example 30
Source Project: cassandra-reaper   Source File: IStoragePostgreSql.java    License: Apache License 2.0 4 votes vote down vote up
@SqlUpdate(SQL_DELETE_OLD_REAPERS)
int deleteOldReapers(
    @Bind("expirationTime") Instant expirationTime
);