### Google Cloud Setup Script Output Source: https://scalardb.scalar-labs.com/llms-full.txt Example output displayed in the Google Cloud Shell during the initial setup script execution. ```console ============================================= Google Cloud Setup Script ============================================= This script will configure your GCP project. ✔ Enable required GCP APIs ✔ Create & configure service accounts ✔ Assign IAM roles ✔ Setup Workload Identity Pool and OIDC Provider ----------------------------------------------- Do you want to proceed? (yes/no): ``` -------------------------------- ### Build and Start Microservices Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to build the application Docker images and start the microservice containers. ```console ./gradlew docker ``` ```console docker-compose up -d customer-service order-service ``` -------------------------------- ### Installing dependencies Source: https://scalardb.scalar-labs.com/llms-full.txt Installs necessary tools for building and managing the SDK. ```console apt update && apt install -y git curl unzip ``` -------------------------------- ### Register data source examples Source: https://scalardb.scalar-labs.com/llms-full.txt Examples of registering a data source using a file, inline JSON, or standard input. ```bash scalardb-analytics-cli data-source register --catalog my_catalog --data-source my_datasource --provider-file /path/to/provider.json ``` ```bash scalardb-analytics-cli data-source register --catalog my_catalog --data-source my_datasource --provider-json '{"type":"postgresql","host":"localhost","port":5432,"database":"mydb","user":"user","password":"pass"}' ``` ```bash cat provider.json | scalardb-analytics-cli data-source register --catalog my_catalog --data-source my_datasource --provider-stdin ``` -------------------------------- ### Start Sample Application Containers Source: https://scalardb.scalar-labs.com/llms-full.txt Command to start the Docker containers for the sample application in detached mode. ```console docker compose up -d --build ``` -------------------------------- ### Installing Dependencies Source: https://scalardb.scalar-labs.com/llms-full.txt Install necessary tools for repository management and network requests. ```console apt update && apt install -y git curl ``` -------------------------------- ### Start Minikube Source: https://scalardb.scalar-labs.com/llms-full.txt Initializes the minikube cluster. ```console minikube start ``` -------------------------------- ### Start microservices Source: https://scalardb.scalar-labs.com/llms-full.txt Launch the required microservices using Docker Compose. ```console docker-compose up -d customer-service order-service ``` -------------------------------- ### Start ScalarDL Ledger and Dependencies Source: https://scalardl.scalar-labs.com/docs/latest/getting-started Run the main command to start ScalarDL Ledger and all its dependent components. This command brings up the core services after the database and schema are ready. ```bash docker compose -f oracle/docker-compose-ledger.yml up -d ``` -------------------------------- ### Start microservices Source: https://scalardb.scalar-labs.com/llms-full.txt Starts the customer and order microservices in detached mode using Docker Compose. ```console docker compose up -d customer-service order-service ``` -------------------------------- ### Start TiDB locally Source: https://scalardb.scalar-labs.com/llms-full.txt Use the TiUP tool to start a local TiDB playground instance. ```console tiup playground v8.5 --without-monitor ``` -------------------------------- ### Start Databases with Docker Compose Source: https://scalardb.scalar-labs.com/llms-full.txt Launch the pre-configured MySQL and Cassandra containers. ```console docker-compose up -d mysql cassandra ``` -------------------------------- ### Configure MySQL provider Source: https://scalardb.scalar-labs.com/llms-full.txt Example configuration for connecting to a MySQL database. ```json { "type": "mysql", "host": "mysql.example.com", "port": 3306, "username": "analytics_user", "password": "secure_password", "database": "orders" // Optional - if omitted, all databases will be imported } ``` -------------------------------- ### Configure Oracle provider Source: https://scalardb.scalar-labs.com/llms-full.txt Example configuration for connecting to an Oracle database. ```json { "type": "oracle", "host": "oracle.example.com", "port": 1521, "username": "analytics_user", "password": "secure_password", "serviceName": "ORCL" } ``` -------------------------------- ### View user list output Source: https://scalardb.scalar-labs.com/llms-full.txt Example output from the SHOW USERS command. ```console +----------+-------------+-----------------------+ | username | isSuperuser | authenticationMethods | +----------+-------------+-----------------------+ | user1 | false | USERPASS | | admin | true | USERPASS | +----------+-------------+-----------------------+ ``` -------------------------------- ### Clone ScalarDL Samples Repository Source: https://scalardl.scalar-labs.com/docs/latest/getting-started Clone the ScalarDL samples repository to get started with the provided examples. Ensure you have Docker and Docker Compose installed. ```bash git clone https://github.com/scalar-labs/scalardl-samples.git cd scalardl-samples ``` -------------------------------- ### Clone and navigate to the sample repository Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to download the repository and enter the specific directory for the .NET cluster sample. ```console git clone https://github.com/scalar-labs/scalardb-samples ``` ```console cd scalardb-samples/scalardb-dotnet-samples/scalardb-cluster-sample ``` -------------------------------- ### Navigate to the sample application directory Source: https://scalardb.scalar-labs.com/llms-full.txt Change the current working directory to the location of the sample application. ```console cd scalardb-samples/scalardb-sample ``` -------------------------------- ### Clone and navigate to the samples repository Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to download the samples repository and enter the specific project directory. ```console git clone https://github.com/scalar-labs/scalardb-samples ``` ```console cd scalardb-samples/spring-data-multi-storage-transaction-sample ``` -------------------------------- ### Start Oracle Database Source: https://scalardl.scalar-labs.com/docs/latest/getting-started Initiate the Oracle Database instance in detached mode using Docker Compose. This command is part of the ScalarDL setup process. ```bash docker compose -f oracle/docker-compose-ledger.yml up -d oracle ``` -------------------------------- ### Configure ScalarDB Cluster for Backup Site Source: https://scalardb.scalar-labs.com/llms-full.txt Example properties file for a multi-storage ScalarDB Cluster setup. Ensure replication admin is enabled for Schema Loader operations. ```properties # Multi-storage configuration scalar.db.storage=multi-storage scalar.db.multi_storage.storages=default,coord,repl scalar.db.multi_storage.default_storage=default scalar.db.multi_storage.namespace_mapping=coordinator:coord,replication:repl # Backup site database scalar.db.multi_storage.storages.default.storage=jdbc scalar.db.multi_storage.storages.default.contact_points=jdbc:postgresql://backup-db:5432/ scalar.db.multi_storage.storages.default.username=postgres scalar.db.multi_storage.storages.default.password=postgres # Coordinator database (shared component - same configuration as primary site) scalar.db.multi_storage.storages.coord.storage=jdbc scalar.db.multi_storage.storages.coord.contact_points=jdbc:postgresql://coordinator-db:5432/ scalar.db.multi_storage.storages.coord.username=postgres scalar.db.multi_storage.storages.coord.password=postgres # Replication database (shared component - same configuration as primary site) scalar.db.multi_storage.storages.repl.storage=jdbc scalar.db.multi_storage.storages.repl.contact_points=jdbc:postgresql://replication-db:5432/ scalar.db.multi_storage.storages.repl.username=postgres scalar.db.multi_storage.storages.repl.password=postgres # Enable replication admin (required for Schema Loader to create replication tables) scalar.db.replication.admin.enabled=true # Enable SQL interface (if you want to test with SQL CLI) scalar.db.sql.enabled=true ``` -------------------------------- ### Create a data catalog Source: https://scalardb.scalar-labs.com/llms-full.txt Initializes a new catalog named 'sample_catalog' to organize data sources. ```console docker compose run --rm scalardb-analytics-cli catalog create --catalog sample_catalog ``` -------------------------------- ### Cloning and navigating the SDK Source: https://scalardb.scalar-labs.com/llms-full.txt Downloads the repository and sets the working directory. ```console git clone https://github.com/scalar-labs/scalardl-java-client-sdk.git ``` ```console cd scalardl-java-client-sdk/ ``` ```console pwd ``` ```console /scalardl-java-client-sdk ``` -------------------------------- ### Perform CRUD Operations in 2PC Transaction Source: https://scalardb.scalar-labs.com/docs/latest/two-phase-commit-transactions Execute Get and Put operations within a `TwoPhaseCommitTransaction`. This example demonstrates retrieving current balances and updating them for a fund transfer scenario. ```java TwoPhaseCommitTransaction tx = ... // Retrieve the current balances by ID. Get fromGet = Get.newBuilder() .namespace(NAMESPACE) .table(TABLE) .partitionKey(new Key(ID, fromId)) .build(); Get toGet = Get.newBuilder() .namespace(NAMESPACE) .table(TABLE) .partitionKey(new Key(ID, toId)) .build(); Optional fromResult = tx.get(fromGet); Optional toResult = tx.get(toGet); // Calculate the balances (assuming that both accounts exist). int newFromBalance = fromResult.get().getInt(BALANCE) - amount; int newToBalance = toResult.get().getInt(BALANCE) + amount; // Update the balances. Put fromPut = Put.newBuilder() .namespace(NAMESPACE) .table(TABLE) .partitionKey(new Key(ID, fromId)) .intValue(BALANCE, newFromBalance) .build(); Put toPut = Put.newBuilder() .namespace(NAMESPACE) .table(TABLE) .partitionKey(new Key(ID, toId)) .intValue(BALANCE, newToBalance) .build(); tx.put(fromPut); tx.put(toPut); ``` -------------------------------- ### Payment Function Example in Java Source: https://scalardl.scalar-labs.com/docs/latest/how-to-write-function This is a sample Java Function for handling money transfers. It demonstrates how to extend JacksonBasedFunction and use ScalarDB API for getting and updating account balances. Error handling for account existence and sufficient balance is crucial in production. ```java public class Payment extends JacksonBasedFunction { private final String FROM_KEY_NAME = "from"; private final String TO_KEY_NAME = "to"; private final String AMOUNT_KEY_NAME = "amount"; private final String NAMESPACE_KEY_NAME = "namespace"; private final String TABLE_KEY_NAME = "table"; @Nullable @Override public JsonNode invoke( Database database, @Nullable JsonNode functionArgument, JsonNode contractArgument, @Nullable JsonNode contractProperties) { // error handling is omitted String fromId = contractArgument.get(FROM_KEY_NAME).asText(); String toId = contractArgument.get(TO_KEY_NAME).asText(); int amount = contractArgument.get(AMOUNT_KEY_NAME).asInt(); String namespace = contractProperties.get(NAMESPACE_KEY_NAME).asText(); String table = contractProperties.get(TABLE_KEY_NAME).asText(); Key fromKey = Key.ofText("id", fromId); Key toKey = Key.ofText("id", toId); // get the account balances Optional account1 = database.get( Get.newBuilder().namespace(namespace).table(table).partitionKey(fromKey).build()); Optional account2 = database.get( Get.newBuilder().namespace(namespace).table(table).partitionKey(toKey).build()); // assumes that both accounts exist, but it should be checked in production code long balance1 = account1.get().getInt("balance"); long balance2 = account2.get().getInt("balance"); if (balance1 - amount < 0) { throw new ContractContextException( "The account " + fromId + " does not have enough account balance."); } // transfer amount balance1 -= amount; balance2 += amount; // update the account balances database.put( Put.newBuilder() .namespace(namespace) .table(table) .partitionKey(fromKey) .bigIntValue("balance", balance1) .build()); database.put( Put.newBuilder() .namespace(namespace) .table(table) .partitionKey(toKey) .bigIntValue("balance", balance2) .build()); return null; } } ``` -------------------------------- ### transactionManager.get(Get get) Source: https://scalardb.scalar-labs.com/llms-full.txt Executes a Get operation to retrieve a single record. ```APIDOC ## transactionManager.get(Get get) ### Description Retrieves a single record specified by a primary key. ScalarDB will automatically begin and commit a transaction if one is not already started. ### Method Optional get(Get get) ### Usage ```java Get get = Get.newBuilder() .namespace("ns") .table("tbl") .partitionKey(partitionKey) .clusteringKey(clusteringKey) .projections("c1", "c2", "c3", "c4") .build(); Optional result = transactionManager.get(get); ``` ``` -------------------------------- ### storage.get(Get get) Source: https://scalardb.scalar-labs.com/llms-full.txt Executes a Get operation to retrieve a single record from the database. ```APIDOC ## storage.get(Get get) ### Description Retrieves a single record specified by a primary key or index key. If the result contains more than one record, an exception is thrown. ### Method storage.get(Get get) ### Parameters - **get** (Get) - Required - The Get operation object constructed via Get.newBuilder(). ### Request Example ```java Key partitionKey = Key.ofInt("c1", 10); Key clusteringKey = Key.of("c2", "aaa", "c3", 100L); Get get = Get.newBuilder() .namespace("ns") .table("tbl") .partitionKey(partitionKey) .clusteringKey(clusteringKey) .projections("c1", "c2", "c3", "c4") .build(); Optional result = storage.get(get); ``` ### Response - **result** (Optional) - The retrieved record if found. ``` -------------------------------- ### transaction.get(Get get) Source: https://scalardb.scalar-labs.com/llms-full.txt Retrieves a single record from a table using a Get operation object. The Get object is constructed using a builder pattern to specify the namespace, table, primary keys, projections, and optional WHERE conditions. ```APIDOC ## transaction.get(Get get) ### Description Retrieves a single record specified by a primary key from a ScalarDB table. The operation supports projections to select specific columns and WHERE clauses for filtering results. ### Method SDK Method ### Parameters - **get** (Get) - Required - The Get operation object containing namespace, table, partition key, clustering key, projections, and conditions. ### Response - **Optional** - Returns an Optional containing the result if found, or Optional.empty() if no record matches the criteria. ``` -------------------------------- ### Create a catalog using CLI Source: https://scalardb.scalar-labs.com/llms-full.txt Initializes a new catalog. Replace with the desired identifier. ```shell scalardb-analytics-cli -c client.properties catalog create --catalog ``` -------------------------------- ### Start Transaction (Coordinator) Source: https://scalardb.scalar-labs.com/docs/latest/two-phase-commit-transactions Initiate a new two-phase commit transaction as the Coordinator using the `start()` method. This method is an alternative to `begin()` for starting a transaction. ```java // Start a transaction. TwoPhaseCommitTransaction tx = transactionManager.start(); ``` -------------------------------- ### Start sample databases Source: https://scalardb.scalar-labs.com/llms-full.txt Initializes the ScalarDB Analytics server and sample databases (PostgreSQL, Cassandra, MySQL) using Docker Compose. ```console docker compose up -d --wait ``` -------------------------------- ### Install gRPC Dependencies Source: https://scalardb.scalar-labs.com/llms-full.txt Installs the necessary gRPC packages required for client-server communication. ```console pip install grpcio grpcio-tools ``` -------------------------------- ### Execute Sample Application Commands Source: https://scalardb.scalar-labs.com/llms-full.txt Use these Gradle commands to interact with the sample application. Note that placing orders may trigger runtime exceptions if credit limits are exceeded. ```console ./gradlew run --args="GetCustomerInfo 1" ... {"id": 1, "name": "Yamada Taro", "credit_limit": 10000, "credit_total": 10000} ... ./gradlew run --args="PlaceOrder 1 3:1,4:1" ... java.lang.RuntimeException: Credit limit exceeded. limit:10000, total:17500 at sample.SampleService.placeOrder(SampleService.java:102) at sample.SampleService$$FastClassBySpringCGLIB$$1123c447.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) at sample.SampleService$$EnhancerBySpringCGLIB$$a94e1d9.placeOrder() at sample.command.PlaceOrderCommand.call(PlaceOrderCommand.java:37) at sample.command.PlaceOrderCommand.call(PlaceOrderCommand.java:13) at picocli.CommandLine.executeUserObject(CommandLine.java:2041) at picocli.CommandLine.access$1500(CommandLine.java:148) at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461) at picocli.CommandLine$RunLast.handle(CommandLine.java:2453) at picocli.CommandLine$RunLast.handle(CommandLine.java:2415) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273) at picocli.CommandLine$RunLast.execute(CommandLine.java:2417) at picocli.CommandLine.execute(CommandLine.java:2170) at sample.SampleApp.run(SampleApp.java:26) at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:768) at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:752) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) at sample.SampleApp.main(SampleApp.java:35) ... ``` ```console ./gradlew run --args="Repayment 1 8000" ... ./gradlew run --args="GetCustomerInfo 1" ... {"customer_id":1,"name":"Yamada Taro","credit_limit":10000,"credit_total":2000} ... ./gradlew run --args="PlaceOrder 1 3:1,4:1" ... {"order_id":"0350947a-9003-46f2-870e-6aa4b2df0f1f","customer_id":1,"timestamp":1677478728134} ... ``` -------------------------------- ### Navigate to the sample directory Source: https://scalardb.scalar-labs.com/llms-full.txt Changes the current working directory to the multi-storage transaction sample folder. ```console cd scalardb-samples/multi-storage-transaction-sample ``` -------------------------------- ### Clone and navigate to the ScalarDB samples repository Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to retrieve the sample project and enter the working directory. ```console git clone https://github.com/scalar-labs/scalardb-samples ``` ```console cd scalardb-samples/scalardb-sample ``` -------------------------------- ### Prepare Environment and Helm Repository Source: https://scalardb.scalar-labs.com/llms-full.txt Navigate to the working directory and add the Scalar Helm repository. ```console cd ~/scalardl-test/ ``` ```console helm repo add scalar-labs https://scalar-labs.github.io/helm-charts ``` -------------------------------- ### Start Spanner Omni Source: https://scalardb.scalar-labs.com/llms-full.txt Use Docker Compose to start the Spanner Omni container and initialize it. ```console docker compose up -d spanner spanner-init ``` -------------------------------- ### Verify tool installation Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to confirm that kubectl and helm are correctly installed on the bastion server. ```console kubectl version --client ``` ```console helm version ``` -------------------------------- ### Create working directory Source: https://scalardb.scalar-labs.com/llms-full.txt Initializes the directory structure for storing certificates. ```console mkdir -p ${HOME}/scalardl-test/certs/ ``` -------------------------------- ### Specify consistency level for Get Source: https://scalardb.scalar-labs.com/llms-full.txt Configures the consistency level for a Get operation using the builder pattern. ```java Get get = Get.newBuilder() .namespace("ns") .table("tbl") .partitionKey(partitionKey) .clusteringKey(clusteringKey) .consistency(Consistency.LINEARIZABLE) // Consistency level .build(); ``` -------------------------------- ### Execute a Get operation Source: https://scalardb.scalar-labs.com/llms-full.txt Constructs a Get object with partition and clustering keys and executes it against the storage instance. ```java // Create a `Get` operation. Key partitionKey = Key.ofInt("c1", 10); Key clusteringKey = Key.of("c2", "aaa", "c3", 100L); Get get = Get.newBuilder() .namespace("ns") .table("tbl") .partitionKey(partitionKey) .clusteringKey(clusteringKey) .projections("c1", "c2", "c3", "c4") .build(); // Execute the `Get` operation. Optional result = storage.get(get); ``` -------------------------------- ### Executing a Get Operation Source: https://scalardb.scalar-labs.com/llms-full.txt Create a Get object and execute it using transaction.get() to retrieve a single record. ```java // Create a `Get` operation. Key partitionKey = Key.ofInt("c1", 10); Key clusteringKey = Key.of("c2", "aaa", "c3", 100L); Get get = Get.newBuilder() .namespace("ns") .table("tbl") .partitionKey(partitionKey) .clusteringKey(clusteringKey) .projections("c1", "c2", "c3", "c4") .where(ConditionBuilder.column("c1").isNotEqualToInt(10)) .build(); // Execute the `Get` operation. Optional result = transaction.get(get); ``` -------------------------------- ### Build Docker images Source: https://scalardb.scalar-labs.com/llms-full.txt Build the Docker images for the sample application before starting the microservices. ```console ./gradlew docker ``` -------------------------------- ### Navigate to the Kotlin sample directory Source: https://scalardb.scalar-labs.com/llms-full.txt Change the current working directory to the location of the Kotlin sample application. ```console cd scalardb-samples/scalardb-kotlin-sample ``` -------------------------------- ### Create and List Catalogs Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to initialize a new catalog container and verify its existence. ```console scalardb-analytics-cli catalog create --catalog production ``` ```console scalardb-analytics-cli catalog list ``` -------------------------------- ### Start ScalarDB Cluster in standalone mode Source: https://scalardb.scalar-labs.com/llms-full.txt Execute the Docker Compose command to start the cluster node. ```console docker compose up -d scalardb-cluster-node ``` -------------------------------- ### Verify ScalarDB Cluster Data Loader installation Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to verify the installation of the ScalarDB Cluster Data Loader. ```console java -jar scalardb-cluster-data-loader--all.jar --help ``` ```console docker pull ghcr.io/scalar-labs/scalardb-cluster-data-loader-cli: ``` ```console docker run --rm ghcr.io/scalar-labs/scalardb-cluster-data-loader-cli: --help ``` -------------------------------- ### Executing Sample Applications Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to perform various transactions using the sample application. ```console ./gradlew run --args="-action charge -amount 1000 -to user1" ``` ```console ./gradlew run --args="-action charge -amount 0 -to merchant1" ``` ```console ./gradlew run --args="-action pay -amount 100 -from user1 -to merchant1" ``` ```console ./gradlew run --args="-action getBalance -id user1" ``` ```console ./gradlew run --args="-action getBalance -id merchant1" ``` -------------------------------- ### Execute Get by Secondary Index Source: https://scalardb.scalar-labs.com/llms-full.txt How to perform a Get operation using a secondary index key instead of a partition key. ```APIDOC ## Get Operation via Secondary Index ### Description Executes a Get operation using an indexed column. Note that if the query matches multiple records, an exception is thrown. ### Usage ```java Key indexKey = Key.ofFloat("c4", 1.23F); Get get = Get.newBuilder() .namespace("ns") .table("tbl") .indexKey(indexKey) .projections("c1", "c2", "c3", "c4") .where(ConditionBuilder.column("c1").isNotEqualToInt(10)) .build(); Optional result = transaction.get(get); ``` ``` -------------------------------- ### Start Blob Storage via Docker Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to initialize the Blob Storage service and create the required container. ```console docker compose up -d blobstorage ``` ```console docker compose up blobstorage-container-creator ``` -------------------------------- ### Verify Direct Access Data Loader installation Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to verify the installation of the Data Loader for direct database access. ```console java -jar scalardb-data-loader-.jar --help ``` ```console docker pull ghcr.io/scalar-labs/scalardb-data-loader-cli: ``` ```console docker run --rm ghcr.io/scalar-labs/scalardb-data-loader-cli: --help ``` -------------------------------- ### Open configuration file Source: https://scalardb.scalar-labs.com/llms-full.txt Command to edit the connection options for the sample application. ```console vim scalardb-options.json ``` -------------------------------- ### Building and downloading tools Source: https://scalardb.scalar-labs.com/llms-full.txt Compiles the contracts and retrieves the CLI binary. ```console ./gradlew assemble ``` ```console curl -OL https://github.com/scalar-labs/scalardl-java-client-sdk/releases/download/v${SCALAR_DL_VERSION}/scalardl-java-client-sdk-${SCALAR_DL_VERSION}.zip ``` ```console unzip ./scalardl-java-client-sdk-${SCALAR_DL_VERSION}.zip ``` -------------------------------- ### Set Operation Attributes in Get Operation Source: https://scalardb.scalar-labs.com/docs/latest/api-guide Demonstrates setting operation-scoped attributes on a Get operation using `attribute()` and `attributes()` methods. ```java Get get = Get.newBuilder() .namespace("ns") .table("tbl") .partitionKey(partitionKey) .clusteringKey(clusteringKey) .attribute("attribute1", "value1") .attributes(ImmutableMap.of("attribute2", "value2", "attribute3", "value3")) .build(); ``` -------------------------------- ### Create Database and User Source: https://scalardb.scalar-labs.com/llms-full.txt Initializes a new database and a corresponding user for the Cloud SQL instance. ```bash # Create a database gcloud sql databases create \ --instance= \ --project= # Create a user gcloud sql users create \ --instance= \ --password= \ --project= ``` -------------------------------- ### Execute Get Operation with Condition Sets Source: https://scalardb.scalar-labs.com/docs/latest/api-guide Construct a Get operation with complex conditions using ConditionSetBuilder for OR-wise and AND-wise junctions. ```java // Create a `Get` operation with condition sets. Get get = Get.newBuilder() .namespace("ns") .table("tbl") .partitionKey(partitionKey) .clusteringKey(clusteringKey) .where( ConditionSetBuilder.condition(ConditionBuilder.column("c1").isLessThanInt(10)) .or(ConditionBuilder.column("c1").isGreaterThanInt(20)) .build()) .and( ConditionSetBuilder.condition(ConditionBuilder.column("c2").isLikeText("a%")) .or(ConditionBuilder.column("c2").isLikeText("b%")) .build()) .build(); ``` -------------------------------- ### Place an Order Source: https://scalardb.scalar-labs.com/docs/latest/getting-started-with-scalardb Initiate an order for a customer, specifying items and quantities. The command format requires the customer ID followed by item IDs and their counts. Note the order format: `:,:,...`. ```bash ./gradlew run --args="PlaceOrder 1 1:3,2:2" ``` -------------------------------- ### Start ScalarDL Ledger Source: https://scalardl.scalar-labs.com/docs/latest/getting-started Run the command to start the ScalarDL Ledger service using Docker Compose. This command assumes the schema has already been loaded. ```bash docker compose -f cosmosdb/docker-compose-ledger.yml up -d ``` -------------------------------- ### Start ScalarDL Ledger and Components Source: https://scalardl.scalar-labs.com/docs/latest/getting-started Run ScalarDL Ledger and its dependent services using Docker Compose. This command starts the main ScalarDL services. ```bash docker compose -f dynamodb/docker-compose-ledger.yml up -d ``` -------------------------------- ### Create Working Directory Source: https://scalardb.scalar-labs.com/llms-full.txt Creates a local directory for storing configuration files, keys, and certificates. ```console mkdir -p ${HOME}/scalardl-test/ ``` -------------------------------- ### Run TiDB locally Source: https://scalardb.scalar-labs.com/docs/latest/getting-started-with-scalardb Start a TiDB instance locally using the TiUP playground command. This command starts TiDB without a monitoring interface. ```bash tiup playground v8.5 --without-monitor ``` -------------------------------- ### Start PostgreSQL and ScalarDB Cluster Source: https://scalardb.scalar-labs.com/docs/latest/scalardb-cluster/encrypt-data-at-rest Starts the PostgreSQL database and ScalarDB Cluster services using Docker Compose. Allow time for ScalarDB Cluster to initialize. ```bash docker compose up postgresql scalardb-cluster-standalone -d ``` -------------------------------- ### Create Working Directory Source: https://scalardb.scalar-labs.com/llms-full.txt Creates a local directory for storing configuration and certificate files. ```console mkdir -p ~/scalardl-test/certs/ ``` -------------------------------- ### Order History Output Example Source: https://scalardb.scalar-labs.com/docs/latest/getting-started-with-scalardb This is an example of the JSON output you might see when checking a customer's order history. It includes details about each order and its items. ```json ...{"order": [{"order_id": "dea4964a-ff50-4ecf-9201-027981a1566e","timestamp": 1650948340914,"customer_id": 1,"customer_name": "Yamada Taro","statement": [{"item_id": 1,"item_name": "Apple","price": 1000,"count": 3,"total": 3000},{"item_id": 2,"item_name": "Orange","price": 2000,"count": 2,"total": 4000}],"total": 7000},{"order_id": "bcc34150-91fa-4bea-83db-d2dbe6f0f30d","timestamp": 1650948412766,"customer_id": 1,"customer_name": "Yamada Taro","statement": [{"item_id": 5,"item_name": "Melon","price": 3000,"count": 1,"total": 3000}],"total": 3000}]}... ``` -------------------------------- ### Start a Client Container Source: https://scalardb.scalar-labs.com/llms-full.txt Deploys a new pod using the eclipse-temurin:8-jdk image with a sleep command to keep it running. ```console kubectl run scalardb-client --image eclipse-temurin:8-jdk --command sleep inf ``` -------------------------------- ### Run the SQL CLI Source: https://scalardb.scalar-labs.com/llms-full.txt Launch the SQL CLI using the provided configuration file. ```console java -jar /scalardb-cluster-sql-cli-${SCALAR_DB_CLUSTER_VERSION}-all.jar --config /database.properties ``` -------------------------------- ### Start ScalarDL Ledger and Dependencies Source: https://scalardl.scalar-labs.com/docs/latest/getting-started Launch the ScalarDL Ledger service along with its required components. This command starts all services defined in the docker-compose file in detached mode. ```bash docker compose -f postgres/docker-compose-ledger.yml up -d ``` -------------------------------- ### Build and Run Binary Source: https://scalardb.scalar-labs.com/llms-full.txt Alternative method to compile and execute the application. ```console go build ./emoney -action getBalance -id user1 ``` -------------------------------- ### Start Transaction with ID (Coordinator) Source: https://scalardb.scalar-labs.com/docs/latest/two-phase-commit-transactions Start a two-phase commit transaction as the Coordinator, specifying a transaction ID. This method allows for explicit control over the transaction's identifier. ```java // Start a transaction by specifying a transaction ID. TwoPhaseCommitTransaction tx = transactionManager.start(""); ``` -------------------------------- ### Initialize Go Module Source: https://scalardb.scalar-labs.com/llms-full.txt Commands to initialize the Go module for the project. ```console go mod init emoney go mod tidy ```