Returns the number of provisioned write units for the table

    :type table_name: str
    :param table_name: Name of the DynamoDB table
    :type gsi_name: str
    :param gsi_name: Name of the GSI
    :returns: int -- Number of write units
351318
def get_provisioned_gsi_write_units(table_name, gsi_name):
    
    try:
        desc = DYNAMODB_CONNECTION.describe_table(table_name)
    except JSONResponseError:
        raise

    for gsi in desc[u'Table'][u'GlobalSecondaryIndexes']:
        if gsi[u'IndexName'] == gsi_name:
            write_units = int(
                gsi[u'ProvisionedThroughput'][u'WriteCapacityUnits'])
            break

    logger.debug(
        '{0} - GSI: {1} - Currently provisioned write units: {2:d}'.format(
            table_name, gsi_name, write_units))
    return write_units
1115533
def __get_table_size(self):
		
		length = ctypes.wintypes.DWORD()
		res = self.method(None, length, False)
		if res != errors.ERROR_INSUFFICIENT_BUFFER:
			raise RuntimeError("Error getting table length (%d)" % res)
		return length.value
176343
def table_stats(self, name, database=None):
        
        stmt = self._table_command('SHOW TABLE STATS', name, database=database)
        return self._exec_statement(stmt)
554357
protected String getTableName() {
        Class<T> entityClass = this.getEntityClass();
        if (!entityClass.isAnnotationPresent(DynamoDBTable.class)) {
            throw new IllegalStateException("Used getTableName on entity without @DynamoDBTable annotation");
        }
        return entityClass.getAnnotation(DynamoDBTable.class).tableName();
    }
787990
def size_on_disk(self):
        
        ret = self.connection.query(
            'SHOW TABLE STATUS FROM `{database}` WHERE NAME="{table}"'.format(
                database=self.database, table=self.table_name), as_dict=True).fetchone()
        return ret['Data_length'] + ret['Index_length']
784230
def do_capacity(self, line):
        ""
        args = self.getargs(line)

        table = self.get_table(args[0])
        read_units = int(args[1])
        write_units = int(args[2])

        desc = self.conn.describe_table(table.name)
        prov = desc['Table']['ProvisionedThroughput']

        current_read, current_write = prov['ReadCapacityUnits'], prov['WriteCapacityUnits']
        if read_units < current_read or write_units < current_write:
            table.update_throughput(read_units, write_units)
            print "%s: updating capacity to %d read units, %d write units" % (table.name, read_units, write_units)
            print ""
            self.do_refresh(table.name)

        else:
            print "%s: current capacity is %d read units, %d write units" % (table.name, current_read, current_write)
            # we can only double the current value at each call
            while current_read < read_units or current_write < write_units:
                if (read_units - current_read) > current_read:
                    current_read *= 2
                else:
                    current_read = read_units

                if (write_units - current_write) > current_write:
                    current_write *= 2
                else:
                    current_write = write_units

                print "%s: updating capacity to %d read units, %d write units" % (table.name, current_read, current_write)
                table.update_throughput(current_read, current_write)

                print ""
                self.do_refresh(table.name)
                print ""
1058635
def has_table(self, table_name, **kwargs):
        
        with self.connection(kwargs.get('connection', None)) as connection:
            kwargs['connection'] = connection
            tables = self.get_tables(table_name, **kwargs)
            return len(tables) > 0
736140
def GetNumberOfRows(self):
    
    if not self._database_object:
      raise IOError('Not opened.')

    if self._number_of_rows is None:
      self._number_of_rows = self._database_object.GetNumberOfRows(
          self._table_name)

    return self._number_of_rows
338504
def get_table_column_statistics(self, db_name, tbl_name, col_name):
    
    self.send_get_table_column_statistics(db_name, tbl_name, col_name)
    return self.recv_get_table_column_statistics()
1218460
def track_state(self, name, initial_state, description='', max_rows=None, **state_kw):
        
        if name in self._tables:
            raise TableConflictError(name)
        if max_rows is None:
            max_rows = AnonymousUsageTracker.MAX_ROWS_PER_TABLE
        self.register_table(name, self.uuid, 'State', description)
        self._tables[name] = State(name, self, initial_state, max_rows=max_rows, **state_kw)
546071
def __check_table_rules(configuration):
    
    for table_name in configuration['tables']:
        table = configuration['tables'][table_name]
        # Check that increase/decrease units is OK
        valid_units = ['percent', 'units']
        if table['increase_reads_unit'] not in valid_units:
            print('increase-reads-unit must be set to either percent or units')
            sys.exit(1)
        if table['decrease_reads_unit'] not in valid_units:
            print('decrease-reads-unit must be set to either percent or units')
            sys.exit(1)
        if table['increase_writes_unit'] not in valid_units:
            print(
                'increase-writes-unit must be set to either percent or units')
            sys.exit(1)
        if table['decrease_writes_unit'] not in valid_units:
            print(
                'decrease-writes-unit must be set to either percent or units')
            sys.exit(1)
        if ('increase_consumed_reads_unit' in table
                and table['increase_consumed_reads_unit']
                and table['increase_consumed_reads_unit'] not in valid_units):
            print(
                'increase-consumed-reads-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_consumed_writes_unit' in table
                and table['increase_consumed_writes_unit']
                and table['increase_consumed_writes_unit'] not in valid_units):
            print(
                'increase-consumed-writes-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_throttled_by_consumed_reads_unit' in table
                and table['increase_throttled_by_consumed_reads_unit']
                and table['increase_throttled_by_consumed_reads_unit']
                not in valid_units):
            print(
                'increase-throttled-by-consumed-reads-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_throttled_by_consumed_writes_unit' in table
                and table['increase_throttled_by_consumed_writes_unit']
                and table['increase_throttled_by_consumed_writes_unit']
                not in valid_units):
            print(
                'increase-throttled-by-consumed-writes-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_throttled_by_provisioned_reads_unit' in table
                and table['increase_throttled_by_provisioned_reads_unit']
                and table['increase_throttled_by_provisioned_reads_unit']
                not in valid_units):
            print(
                'increase-throttled-by-provisioned-reads-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_throttled_by_provisioned_writes_unit' in table
                and table['increase_throttled_by_provisioned_writes_unit']
                and table['increase_throttled_by_provisioned_writes_unit']
                not in valid_units):
            print(
                'increase-throttled-by-provisioned-writes-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)

        # Check lookback-window start
        if table['lookback_window_start'] < 1:
            print(
                'lookback-window-start must be a value higher than 1, '
                'as DynamoDB sends CloudWatch data every minute')
            sys.exit(1)

        # Check sns-message-types
        valid_sns_message_types = [
            'scale-up',
            'scale-down',
            'high-throughput-alarm',
            'low-throughput-alarm']

        if table['sns_message_types']:
            for sns_type in table['sns_message_types']:
                if sns_type not in valid_sns_message_types:
                    print('Warning: Invalid sns-message-type: {0}'.format(
                        sns_type))
                    table['sns_message_types'].remove(sns_type)

        # Ensure values > 0 for some important configuration options
        options = [
            'reads_lower_threshold',
            'reads_upper_threshold',
            'increase_reads_with',
            'decrease_reads_with',
            'writes_lower_threshold',
            'writes_upper_threshold',
            'increase_writes_with',
            'decrease_writes_with',
            'min_provisioned_reads',
            'max_provisioned_reads',
            'min_provisioned_writes',
            'max_provisioned_writes',
            'num_read_checks_before_scale_down',
            'num_write_checks_before_scale_down',
            'increase_consumed_reads_with',
            'increase_consumed_writes_with'
        ]
        # Config options without a mandatory default
        # should be allowed a None value
        non_default = [
            'increase_consumed_reads_with',
            'increase_consumed_writes_with'
        ]

        for option in options:
            if (option in non_default
                    and option in table
                    and table[option] and table[option] < 1):
                print('{0} may not be lower than 1 for table {1}'.format(
                    option, table_name))
                sys.exit(1)

            if (option in table
                    and option not in non_default
                    and table[option] < 1):
                print('{0} may not be lower than 1 for table {1}'.format(
                    option, table_name))
                sys.exit(1)

        if (int(table['min_provisioned_reads']) >
                int(table['max_provisioned_reads'])):
            print(
                'min_provisioned_reads ({0}) may not be higher than '
                'max_provisioned_reads ({1}) for table {2}'.format(
                    table['min_provisioned_reads'],
                    table['max_provisioned_reads'],
                    table_name))
            sys.exit(1)
        elif (int(table['min_provisioned_writes']) >
                int(table['max_provisioned_writes'])):
            print(
                'min_provisioned_writes ({0}) may not be higher than '
                'max_provisioned_writes ({1}) for table {2}'.format(
                    table['min_provisioned_writes'],
                    table['max_provisioned_writes'],
                    table_name))
            sys.exit(1)
615428
def create_async_dynamodb_table(self, table_name, read_capacity, write_capacity):
        
        try:
            dynamodb_table = self.dynamodb_client.describe_table(TableName=table_name)
            return False, dynamodb_table

        # catch this exception (triggered if the table doesn't exist)
        except botocore.exceptions.ClientError:
            dynamodb_table = self.dynamodb_client.create_table(
                AttributeDefinitions=[
                    {
                        'AttributeName': 'id',
                        'AttributeType': 'S'
                    }
                ],
                TableName=table_name,
                KeySchema=[
                    {
                        'AttributeName': 'id',
                        'KeyType': 'HASH'
                    },
                ],
                ProvisionedThroughput = {
                    'ReadCapacityUnits': read_capacity,
                    'WriteCapacityUnits': write_capacity
                }
            )
            if dynamodb_table:
                try:
                    self._set_async_dynamodb_table_ttl(table_name)
                except botocore.exceptions.ClientError:
                    # this fails because the operation is async, so retry
                    time.sleep(10)
                    self._set_async_dynamodb_table_ttl(table_name)

        return True, dynamodb_table
458806
def namedb_get_num_history_rows( cur, history_id ):
    
    ret = []
    select_query = "SELECT COUNT(*) FROM history WHERE history_id = ? ORDER BY block_id ASC, vtxindex ASC;"
    args = (history_id,)

    count = namedb_select_count_rows( cur, select_query, args )
    return count
350565
def createDdbTable(region=None, table="credential-store", **kwargs):
    '''
    
    '''
    session = get_session(**kwargs)
    dynamodb = session.resource("dynamodb", region_name=region)
    if table in (t.name for t in dynamodb.tables.all()):
        print("Credential Store table already exists")
        return

    print("Creating table...")
    dynamodb.create_table(
        TableName=table,
        KeySchema=[
            {
                "AttributeName": "name",
                "KeyType": "HASH",
            },
            {
                "AttributeName": "version",
                "KeyType": "RANGE",
            }
        ],
        AttributeDefinitions=[
            {
                "AttributeName": "name",
                "AttributeType": "S",
            },
            {
                "AttributeName": "version",
                "AttributeType": "S",
            },
        ],
        ProvisionedThroughput={
            "ReadCapacityUnits": 1,
            "WriteCapacityUnits": 1,
        }
    )

    print("Waiting for table to be created...")
    client = session.client("dynamodb", region_name=region)

    response = client.describe_table(TableName=table)

    client.get_waiter("table_exists").wait(TableName=table)

    print("Adding tag...")

    client.tag_resource(
        ResourceArn=response["Table"]["TableArn"],
        Tags=[
            {
                'Key': "Name",
                'Value': "credstash"
            },
        ]
    )

    print("Table has been created. "
          "Go read the README about how to create your KMS key")
874154
def _parse_throttle(self, tablename, throttle):
        
        amount = []
        desc = self.describe(tablename)
        throughputs = [desc.read_throughput, desc.write_throughput]
        for value, throughput in zip(throttle[1:], throughputs):
            if value == "*":
                amount.append(0)
            elif value[-1] == "%":
                amount.append(throughput * float(value[:-1]) / 100.0)
            else:
                amount.append(float(value))
        cap = Capacity(*amount)  # pylint: disable=E1120
        return RateLimit(total=cap, callback=self._on_throttle)
505255
public static boolean createTable(String appid, long readCapacity, long writeCapacity) {
		if (StringUtils.isBlank(appid)) {
			return false;
		} else if (StringUtils.containsWhitespace(appid)) {
			logger.warn("DynamoDB table name contains whitespace. The name '{}' is invalid.", appid);
			return false;
		} else if (existsTable(appid)) {
			logger.warn("DynamoDB table '{}' already exists.", appid);
			return false;
		}
		try {
			String table = getTableNameForAppid(appid);
			getClient().createTable(new CreateTableRequest().withTableName(table).
					withKeySchema(new KeySchemaElement(Config._KEY, KeyType.HASH)).
					withSSESpecification(new SSESpecification().withEnabled(ENCRYPTION_AT_REST_ENABLED)).
					withAttributeDefinitions(new AttributeDefinition(Config._KEY, ScalarAttributeType.S)).
					withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity)));
			logger.info("Created DynamoDB table '{}'.", table);
		} catch (Exception e) {
			logger.error(null, e);
			return false;
		}
		return true;
	}
691987
def get_unit_name(self):
        
        if not self.unit:
            return None
        name = sorted(self.unit.names, key=len)[-1]
        return '%ss' % name