From 4e4963ca203b185a43fb196bb73908773c760c15 Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 28 Nov 2024 13:03:23 +0530 Subject: [PATCH] Remove unnecessary metadata objects for same strand calls --- .../datastore/GoogleSheetsProcessor.java | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/native/src/main/java/io/ballerina/stdlib/persist/googlesheets/datastore/GoogleSheetsProcessor.java b/native/src/main/java/io/ballerina/stdlib/persist/googlesheets/datastore/GoogleSheetsProcessor.java index 70db6b7..88341d3 100644 --- a/native/src/main/java/io/ballerina/stdlib/persist/googlesheets/datastore/GoogleSheetsProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/persist/googlesheets/datastore/GoogleSheetsProcessor.java @@ -19,7 +19,6 @@ package io.ballerina.stdlib.persist.googlesheets.datastore; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.values.BArray; @@ -31,8 +30,6 @@ import io.ballerina.runtime.api.values.BTypedesc; import io.ballerina.stdlib.persist.googlesheets.Utils; -import java.util.Map; - import static io.ballerina.stdlib.persist.Constants.KEY_FIELDS; import static io.ballerina.stdlib.persist.Constants.RUN_READ_QUERY_METHOD; import static io.ballerina.stdlib.persist.ErrorGenerator.wrapError; @@ -41,7 +38,6 @@ import static io.ballerina.stdlib.persist.Utils.getMetadata; import static io.ballerina.stdlib.persist.Utils.getPersistClient; import static io.ballerina.stdlib.persist.Utils.getRecordTypeWithKeyFields; -import static io.ballerina.stdlib.persist.Utils.getTransactionContextProperties; import static io.ballerina.stdlib.persist.googlesheets.Constants.RUN_READ_TABLE_AS_STREAM_METHOD; import static io.ballerina.stdlib.persist.googlesheets.Utils.getEntityFromStreamMethod; import static io.ballerina.stdlib.persist.googlesheets.Utils.getFieldTypes; @@ -74,8 +70,6 @@ public static BStream query(Environment env, BObject client, BTypedesc targetTyp BArray includes = metadata[1]; BArray typeDescriptions = metadata[2]; BMap typeMap = getFieldTypes(recordType); - - Map trxContextProperties = getTransactionContextProperties(); return env.yieldAndRun(() -> { try { Object result = env.getRuntime().callMethod( @@ -84,8 +78,7 @@ public static BStream query(Environment env, BObject client, BTypedesc targetTyp // string[] include = [] // )` // which returns `stream|persist:Error` - persistClient, RUN_READ_QUERY_METHOD, new StrandMetadata(false, trxContextProperties), - targetTypeWithIdFields, typeMap, fields, includes); + persistClient, RUN_READ_QUERY_METHOD, null, targetTypeWithIdFields, typeMap, fields, includes); if (result instanceof BStream bStream) { // stream return Utils.createPersistGSheetsStreamValue(bStream, targetType, fields, includes, typeDescriptions, persistClient, null); @@ -116,8 +109,6 @@ public static BStream queryStream(Environment env, BObject client, BTypedesc tar BArray includes = metadata[1]; BArray typeDescriptions = metadata[2]; BMap typeMap = getFieldTypes(recordType); - - Map trxContextProperties = getTransactionContextProperties(); return env.yieldAndRun(() -> { try { Object result = env.getRuntime().callMethod( @@ -126,8 +117,8 @@ public static BStream queryStream(Environment env, BObject client, BTypedesc tar // string[] include = [] // )` // which returns `stream|persist:Error` - persistClient, RUN_READ_TABLE_AS_STREAM_METHOD, new StrandMetadata(false, trxContextProperties), - targetTypeWithIdFields, typeMap, fields, includes); + persistClient, RUN_READ_TABLE_AS_STREAM_METHOD, null, targetTypeWithIdFields, typeMap, fields + , includes); if (result instanceof BStream bStream) { // stream return Utils.createPersistGSheetsStreamValue(bStream, targetType, fields, includes, typeDescriptions, persistClient, null); @@ -159,8 +150,6 @@ public static Object queryOne(Environment env, BObject client, BArray path, BTyp BArray typeDescriptions = metadata[2]; BMap typeMap = getFieldTypes(recordType); Object key = getKey(env, path); - - Map trxContextProperties = getTransactionContextProperties(); return env.yieldAndRun(() -> { try { return env.getRuntime().callMethod( @@ -169,8 +158,8 @@ public static Object queryOne(Environment env, BObject client, BArray path, BTyp // string[] include = [] // )` // which returns `stream|persist:Error` - persistClient, RUN_READ_TABLE_AS_STREAM_METHOD, new StrandMetadata(false, trxContextProperties), - targetType, targetTypeWithIdFields, typeMap, key, fields, includes, typeDescriptions); + persistClient, RUN_READ_TABLE_AS_STREAM_METHOD, null, targetType, targetTypeWithIdFields, + typeMap, key, fields, includes, typeDescriptions); } catch (BError bError) { return wrapError(bError); }