All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tarantool.driver.api.space.options.OperationWithBucketIdOptions Maven / Gradle / Ivy

Go to download

Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework

There is a newer version: 0.14.0
Show newest version
package io.tarantool.driver.api.space.options;

import java.util.Optional;

/**
 * Base interface for all operation options that may have a configurable bucket id.
 *
 * @author Artyom Dubinin
 */
public interface OperationWithBucketIdOptions>
    extends Options, Self {

    String BUCKET_ID = "bucket_id";

    /**
     * Specifies bucket id for an operation to perform it on storage with this bucket. It may be useful
     * if a non-default sharding function is used or in other specific cases.
     * By default, crud extracts primary key from a tuple and calculates a strcrc32 hash function value
     * and gets the remainder after dividing the value by the number of buckets.
     * You can use your own implementation of the sharding function. For retrieving the number of buckets
     * the {@code vshard.router.bucket_count} API method can be used.
     *
     * @param bucketId number determining the location in the cluster
     * @return this options instance
     * @see vshard
     * @see crud
     */
    default T withBucketId(Integer bucketId) {
        addOption(BUCKET_ID, bucketId);
        return self();
    }

    /**
     * Return bucket id that is used by operation to find storage location.
     *
     * @return bucket id
     */
    default Optional getBucketId() {
        return getOption(BUCKET_ID, Integer.class);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy