comment
stringlengths
1
45k
method_body
stringlengths
23
281k
target_code
stringlengths
0
5.16k
method_body_after
stringlengths
12
281k
context_before
stringlengths
8
543k
context_after
stringlengths
8
543k
Could you have a test on setting request id?
public void canCreateAndListIndexerNames() { String indexName = createIndex(); String dataSourceName = createDataSource(); SearchIndexer indexer1 = createBaseTestIndexerObject(indexName, dataSourceName); indexer1.setName("a" + indexer1.getName()); SearchIndexer indexer2 = createBaseTestIndexerObject(indexName, dataSour...
Iterator<String> indexersRes = searchIndexerClient.listIndexerNames(Context.NONE)
public void canCreateAndListIndexerNames() { String indexName = createIndex(); String dataSourceName = createDataSource(); SearchIndexer indexer1 = createBaseTestIndexerObject(indexName, dataSourceName); mutateName(indexer1, "a" + indexer1.getName()); SearchIndexer indexer2 = createBaseTestIndexerObject(indexName, data...
class IndexersManagementSyncTests extends SearchTestBase { private static final String TARGET_INDEX_NAME = "indexforindexers"; private static final HttpPipelinePolicy MOCK_STATUS_PIPELINE_POLICY = new CustomQueryPipelinePolicy("mock_status", "inProgress"); private final List<String> dataSourcesToDelete = new ArrayList<...
class IndexersManagementSyncTests extends SearchTestBase { private static final String TARGET_INDEX_NAME = "indexforindexers"; private static final HttpPipelinePolicy MOCK_STATUS_PIPELINE_POLICY = new CustomQueryPipelinePolicy("mock_status", "inProgress"); private final List<String> dataSourcesToDelete = new ArrayList<...
I'll add an example of how to add per-request `x-ms-client-request-id` in the next commit.
private static void autoCompleteWithOneTermContext(SearchClient searchClient) { AutocompleteOptions params = new AutocompleteOptions().setAutocompleteMode( AutocompleteMode.ONE_TERM_WITH_CONTEXT); PagedIterableBase<AutocompleteItem, AutocompletePagedResponse> results = searchClient.autocomplete("coffee m", "sg", params...
PagedIterableBase<AutocompleteItem, AutocompletePagedResponse> results = searchClient.autocomplete("coffee m",
private static void autoCompleteWithOneTermContext(SearchClient searchClient) { AutocompleteOptions params = new AutocompleteOptions().setAutocompleteMode( AutocompleteMode.ONE_TERM_WITH_CONTEXT); PagedIterableBase<AutocompleteItem, AutocompletePagedResponse> results = searchClient.autocomplete("coffee m", "sg", params...
class AutoCompleteExample { /** * From the Azure portal, get your Azure Cognitive Search service URL and API key, * and set the values of these environment variables: */ private static final String ENDPOINT = Configuration.getGlobalConfiguration().get("AZURE_COGNITIVE_SEARCH_ENDPOINT"); private static final String API_...
class AutoCompleteExample { /** * From the Azure portal, get your Azure Cognitive Search service URL and API key, * and set the values of these environment variables: */ private static final String ENDPOINT = Configuration.getGlobalConfiguration().get("AZURE_COGNITIVE_SEARCH_ENDPOINT"); private static final String API_...
Will add a few tests. As a heads up we never validated the `x-ms-client-request-id` returned from the service match what was set in `RequestOptions` so this will be even more important to do.
public void canCreateAndListIndexerNames() { String indexName = createIndex(); String dataSourceName = createDataSource(); SearchIndexer indexer1 = createBaseTestIndexerObject(indexName, dataSourceName); indexer1.setName("a" + indexer1.getName()); SearchIndexer indexer2 = createBaseTestIndexerObject(indexName, dataSour...
Iterator<String> indexersRes = searchIndexerClient.listIndexerNames(Context.NONE)
public void canCreateAndListIndexerNames() { String indexName = createIndex(); String dataSourceName = createDataSource(); SearchIndexer indexer1 = createBaseTestIndexerObject(indexName, dataSourceName); mutateName(indexer1, "a" + indexer1.getName()); SearchIndexer indexer2 = createBaseTestIndexerObject(indexName, data...
class IndexersManagementSyncTests extends SearchTestBase { private static final String TARGET_INDEX_NAME = "indexforindexers"; private static final HttpPipelinePolicy MOCK_STATUS_PIPELINE_POLICY = new CustomQueryPipelinePolicy("mock_status", "inProgress"); private final List<String> dataSourcesToDelete = new ArrayList<...
class IndexersManagementSyncTests extends SearchTestBase { private static final String TARGET_INDEX_NAME = "indexforindexers"; private static final HttpPipelinePolicy MOCK_STATUS_PIPELINE_POLICY = new CustomQueryPipelinePolicy("mock_status", "inProgress"); private final List<String> dataSourcesToDelete = new ArrayList<...
The check doesn't match the documentation. This throws a NPE rather than IllegalArgumentExceptionwhen lockToken is null.
public Mono<Instant> renewMessageLock(String lockToken) { if (isDisposed.get()) { return monoError(logger, new IllegalStateException( String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock"))); } else if (Objects.isNull(lockToken)) { return monoError(logger, new NullPointerException("'lockToken' cannot be...
} else if (Objects.isNull(lockToken)) {
public Mono<Instant> renewMessageLock(String lockToken) { if (isDisposed.get()) { return monoError(logger, new IllegalStateException( String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock"))); } else if (Objects.isNull(lockToken)) { return monoError(logger, new NullPointerException("'lockToken' cannot be...
class ServiceBusReceiverAsyncClient implements AutoCloseable { private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions(); private static final String TRANSACTION_LINK_NAME = "coordinator"; private final AtomicBoolean isDisposed = new AtomicBoolean(); private final MessageLockContainer...
class ServiceBusReceiverAsyncClient implements AutoCloseable { private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions(); private static final String TRANSACTION_LINK_NAME = "coordinator"; private final AtomicBoolean isDisposed = new AtomicBoolean(); private final MessageLockContainer...
This isn't correct? It should be one or the other.
public static void main(String[] args) { final AtomicBoolean isRunning = new AtomicBoolean(true); Mono.delay(Duration.ofMinutes(2)).subscribe(index -> { System.out.println("2 minutes has elapsed, stopping receive loop."); isRunning.set(false); }); String connectionString = "Endpoint={fully-qualified-namespace};SharedAc...
receiver.complete(message.getLockToken());
public static void main(String[] args) { final AtomicBoolean isRunning = new AtomicBoolean(true); Mono.delay(Duration.ofMinutes(2)).subscribe(index -> { System.out.println("2 minutes has elapsed, stopping receive loop."); isRunning.set(false); }); String connectionString = "Endpoint={fully-qualified-namespace};SharedAc...
class ReceiveNamedSessionSample { /** * Main method to invoke this demo on how to receive messages from a session with id "greetings" in an Azure Service * Bus Queue. * * @param args Unused arguments to the program. */ private static boolean processMessage(ServiceBusReceivedMessage message) { System.out.println("Proces...
class ReceiveNamedSessionSample { /** * Main method to invoke this demo on how to receive messages from a session with id "greetings" in an Azure Service * Bus Queue. * * @param args Unused arguments to the program. */ private static boolean processMessage(ServiceBusReceivedMessage message) { System.out.println("Proces...
Should this throw `UnsupportedOperationException` if it isn't supported?
public boolean isSymbolicLink() { return false; }
return false;
public boolean isSymbolicLink() { return false; }
class AzureBasicFileAttributes implements BasicFileAttributes { private final ClientLogger logger = new ClientLogger(AzureBasicFileAttributes.class); static final Set<String> ATTRIBUTE_STRINGS; static { Set<String> set = new HashSet<>(); set.add("lastModifiedTime"); set.add("isRegularFile"); set.add("isDirectory"); set...
class AzureBasicFileAttributes implements BasicFileAttributes { private final ClientLogger logger = new ClientLogger(AzureBasicFileAttributes.class); static final Set<String> ATTRIBUTE_STRINGS; static { Set<String> set = new HashSet<>(); set.add("lastModifiedTime"); set.add("isRegularFile"); set.add("isDirectory"); set...
I'm not sure. In some sense it's just always false, right? But maybe it makes it more clear that sym links aren't supported if I throw?
public boolean isSymbolicLink() { return false; }
return false;
public boolean isSymbolicLink() { return false; }
class AzureBasicFileAttributes implements BasicFileAttributes { private final ClientLogger logger = new ClientLogger(AzureBasicFileAttributes.class); static final Set<String> ATTRIBUTE_STRINGS; static { Set<String> set = new HashSet<>(); set.add("lastModifiedTime"); set.add("isRegularFile"); set.add("isDirectory"); set...
class AzureBasicFileAttributes implements BasicFileAttributes { private final ClientLogger logger = new ClientLogger(AzureBasicFileAttributes.class); static final Set<String> ATTRIBUTE_STRINGS; static { Set<String> set = new HashSet<>(); set.add("lastModifiedTime"); set.add("isRegularFile"); set.add("isDirectory"); set...
I think returning always `false` is correct. Throwing `UnsupportedOperationException` would mean "I cannot check if file is symlink or not` in plain English. I believe our file system doesn't have symlinks so all files are real by definition, therefore we know how to check if they're symlinks or not.
public boolean isSymbolicLink() { return false; }
return false;
public boolean isSymbolicLink() { return false; }
class AzureBasicFileAttributes implements BasicFileAttributes { private final ClientLogger logger = new ClientLogger(AzureBasicFileAttributes.class); static final Set<String> ATTRIBUTE_STRINGS; static { Set<String> set = new HashSet<>(); set.add("lastModifiedTime"); set.add("isRegularFile"); set.add("isDirectory"); set...
class AzureBasicFileAttributes implements BasicFileAttributes { private final ClientLogger logger = new ClientLogger(AzureBasicFileAttributes.class); static final Set<String> ATTRIBUTE_STRINGS; static { Set<String> set = new HashSet<>(); set.add("lastModifiedTime"); set.add("isRegularFile"); set.add("isDirectory"); set...
Might want to add @throws to javadocs for unsupported apis.
public FileTime lastAccessTime() { throw new UnsupportedOperationException(); }
throw new UnsupportedOperationException();
public FileTime lastAccessTime() { throw new UnsupportedOperationException(); }
class AzureBasicFileAttributes implements BasicFileAttributes { private final ClientLogger logger = new ClientLogger(AzureBasicFileAttributes.class); static final Set<String> ATTRIBUTE_STRINGS; static { Set<String> set = new HashSet<>(); set.add("lastModifiedTime"); set.add("isRegularFile"); set.add("isDirectory"); set...
class AzureBasicFileAttributes implements BasicFileAttributes { private final ClientLogger logger = new ClientLogger(AzureBasicFileAttributes.class); static final Set<String> ATTRIBUTE_STRINGS; static { Set<String> set = new HashSet<>(); set.add("lastModifiedTime"); set.add("isRegularFile"); set.add("isDirectory"); set...
why are we defining new public property for something which is already available? I thought the plan was to reuse `TestConfiguration.HOST` and not redefine a constant for the same thing. 1) on the CI the value for `TestConfiguration.HOST` will be populated by the CI. 2) in local debugging that can be populated from a...
public void createAadTokenCredential() throws InterruptedException { CosmosAsyncDatabase db = null; CosmosAsyncClient cosmosAsyncClient = new CosmosClientBuilder() .endpoint(TestConfigurations.COSMOS_EMULATOR_HOST) .key(TestConfigurations.COSMOS_EMULATOR_KEY) .buildAsyncClient(); String containerName = UUID.randomUUID(...
.endpoint(TestConfigurations.COSMOS_EMULATOR_HOST)
public void createAadTokenCredential() throws InterruptedException { CosmosAsyncDatabase db = null; CosmosAsyncClient cosmosAsyncClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) .key(TestConfigurations.MASTER_KEY) .buildAsyncClient(); String containerName = UUID.randomUUID().toString(); try { Cosmo...
class AadAuthorizationTests extends TestSuiteBase { private final static Logger log = LoggerFactory.getLogger(AadAuthorizationTests.class); private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper(); private final static String PARTITION_KEY_PATH = "/mypk"; private final String databaseId = CosmosD...
class AadAuthorizationTests extends TestSuiteBase { private final static Logger log = LoggerFactory.getLogger(AadAuthorizationTests.class); private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper(); private final static String PARTITION_KEY_PATH = "/mypk"; private final String databaseId = CosmosD...
This is an emulator only test which it cannot be run against prod endpoint.
public void createAadTokenCredential() throws InterruptedException { CosmosAsyncDatabase db = null; CosmosAsyncClient cosmosAsyncClient = new CosmosClientBuilder() .endpoint(TestConfigurations.COSMOS_EMULATOR_HOST) .key(TestConfigurations.COSMOS_EMULATOR_KEY) .buildAsyncClient(); String containerName = UUID.randomUUID(...
.endpoint(TestConfigurations.COSMOS_EMULATOR_HOST)
public void createAadTokenCredential() throws InterruptedException { CosmosAsyncDatabase db = null; CosmosAsyncClient cosmosAsyncClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) .key(TestConfigurations.MASTER_KEY) .buildAsyncClient(); String containerName = UUID.randomUUID().toString(); try { Cosmo...
class AadAuthorizationTests extends TestSuiteBase { private final static Logger log = LoggerFactory.getLogger(AadAuthorizationTests.class); private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper(); private final static String PARTITION_KEY_PATH = "/mypk"; private final String databaseId = CosmosD...
class AadAuthorizationTests extends TestSuiteBase { private final static Logger log = LoggerFactory.getLogger(AadAuthorizationTests.class); private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper(); private final static String PARTITION_KEY_PATH = "/mypk"; private final String databaseId = CosmosD...
why do we make a copy of the user-provided options here?
private RecognizeOptions getRecognizeOptionsProperties(RecognizeOptions userProvidedOptions) { if (userProvidedOptions != null) { return new RecognizeOptions() .setPollInterval(userProvidedOptions.getPollInterval()) .setFormContentType(userProvidedOptions.getFormContentType()) .setIncludeTextContent(userProvidedOptions...
.setIncludeTextContent(userProvidedOptions.isIncludeTextContent());
private RecognizeOptions getRecognizeOptionsProperties(RecognizeOptions userProvidedOptions) { if (userProvidedOptions != null) { return userProvidedOptions; } else { return new RecognizeOptions(); } }
class FormRecognizerAsyncClient { private final ClientLogger logger = new ClientLogger(FormRecognizerAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormRecognizerAsyncClient} that sends requests to the Form Recognizer ...
class FormRecognizerAsyncClient { private final ClientLogger logger = new ClientLogger(FormRecognizerAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormRecognizerAsyncClient} that sends requests to the Form Recognizer ...
`subscribe` inside another `subscribe` looks a bit odd. Can we instead use reactor pattern here? ```java formRecognizerAsyncClient.beginRecognizeReceiptsFromUrl(...) .flatMap(recognizePollingOperation -> recognizePollingOperation.getFinalResult()) .subscribe(recognizedReceipts -> {...}); ```
public void beginRecognizeReceiptsFromUrlWithOptions() { String receiptUrl = "{file_source_url}"; boolean includeTextContent = true; formRecognizerAsyncClient.beginRecognizeReceiptsFromUrl(receiptUrl, new RecognizeOptions() .setIncludeTextContent(includeTextContent) .setPollInterval(Duration.ofSeconds(5))) .subscribe(r...
RecognizedReceipt recognizedReceipt = recognizedReceipts.get(i);
public void beginRecognizeReceiptsFromUrlWithOptions() { String receiptUrl = "{receiptUrl}"; boolean includeTextContent = true; formRecognizerAsyncClient.beginRecognizeReceiptsFromUrl(receiptUrl, new RecognizeOptions() .setIncludeFieldElements(includeTextContent) .setPollInterval(Duration.ofSeconds(5))) .flatMap(recogn...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
Use `forEach()` instead or you can also show the reactor pattern here: ```java formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(recognizePollingOperation -> recognizePollingOperation.getFinalResult()) .flatMap(recognizedReceipts -> Flux.fromIterable(recognizedReceipts)) ...
public void beginRecognizeReceipts() throws IOException { File receipt = new File("{file_source_url}"); Flux<ByteBuffer> buffer = toFluxByteBuffer(new ByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(recognizePollingOperatio...
for (int i = 0; i < recognizedReceipts.size(); i++) {
public void beginRecognizeReceipts() throws IOException { File receipt = new File("{file_source_url}"); Flux<ByteBuffer> buffer = toFluxByteBuffer(new ByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(recognizePollingOperatio...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
Yep, I am preparing a follow-up PR for sample and snippets update to follow reactor pattern more!
public void beginRecognizeReceipts() throws IOException { File receipt = new File("{file_source_url}"); Flux<ByteBuffer> buffer = toFluxByteBuffer(new ByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(recognizePollingOperatio...
for (int i = 0; i < recognizedReceipts.size(); i++) {
public void beginRecognizeReceipts() throws IOException { File receipt = new File("{file_source_url}"); Flux<ByteBuffer> buffer = toFluxByteBuffer(new ByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(recognizePollingOperatio...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
Wow.
public static Object[][] responseContinuationTokenLimitParamProvider() { CosmosQueryRequestOptions options1 = new CosmosQueryRequestOptions(); ModelBridgeInternal.setQueryRequestOptionsMaxItemCount(options1, 1); options1.setResponseContinuationTokenLimitInKb(5); options1.setPartitionKey(new PartitionKey("99")); String ...
options1.setResponseContinuationTokenLimitInKb(5);
new CosmosQueryRequestOptions(); ModelBridgeInternal.setQueryRequestOptionsMaxItemCount(options1, 1); options1.setResponseContinuationTokenLimitInKb(5); options1.setPartitionKey(new PartitionKey("99")); String query1 = "Select * from r"; boolean multiPartitionCollection1 = true; CosmosQueryRequestOptions options2 = new...
class DocumentQuerySpyWireContentTest extends TestSuiteBase { private Database createdDatabase; private DocumentCollection createdSinglePartitionCollection; private DocumentCollection createdMultiPartitionCollection; private List<Document> createdDocumentsInSinglePartitionCollection = new ArrayList<>(); private List<Do...
class DocumentQuerySpyWireContentTest extends TestSuiteBase { private Database createdDatabase; private DocumentCollection createdSinglePartitionCollection; private DocumentCollection createdMultiPartitionCollection; private List<Document> createdDocumentsInSinglePartitionCollection = new ArrayList<>(); private List<Do...
Should we just give the `ProvisioningState` object?
public String provisioningState() { return inner().provisioningState().toString(); }
return inner().provisioningState().toString();
public String provisioningState() { return inner().provisioningState().toString(); }
class ApplicationSecurityGroupImpl extends GroupableResourceImpl< ApplicationSecurityGroup, ApplicationSecurityGroupInner, ApplicationSecurityGroupImpl, NetworkManager> implements ApplicationSecurityGroup, ApplicationSecurityGroup.Definition, ApplicationSecurityGroup.Update { ApplicationSecurityGroupImpl( final String ...
class ApplicationSecurityGroupImpl extends GroupableResourceImpl< ApplicationSecurityGroup, ApplicationSecurityGroupInner, ApplicationSecurityGroupImpl, NetworkManager> implements ApplicationSecurityGroup, ApplicationSecurityGroup.Definition, ApplicationSecurityGroup.Update { ApplicationSecurityGroupImpl( final String ...
I prefer to return string. It looks a few interfaces just return the object. Maybe we can do in another PR to align such behavior.
public String provisioningState() { return inner().provisioningState().toString(); }
return inner().provisioningState().toString();
public String provisioningState() { return inner().provisioningState().toString(); }
class ApplicationSecurityGroupImpl extends GroupableResourceImpl< ApplicationSecurityGroup, ApplicationSecurityGroupInner, ApplicationSecurityGroupImpl, NetworkManager> implements ApplicationSecurityGroup, ApplicationSecurityGroup.Definition, ApplicationSecurityGroup.Update { ApplicationSecurityGroupImpl( final String ...
class ApplicationSecurityGroupImpl extends GroupableResourceImpl< ApplicationSecurityGroup, ApplicationSecurityGroupInner, ApplicationSecurityGroupImpl, NetworkManager> implements ApplicationSecurityGroup, ApplicationSecurityGroup.Definition, ApplicationSecurityGroup.Update { ApplicationSecurityGroupImpl( final String ...
I think object would be better for comparison. Since it is an enum.
public String provisioningState() { return inner().provisioningState().toString(); }
return inner().provisioningState().toString();
public String provisioningState() { return inner().provisioningState().toString(); }
class ApplicationSecurityGroupImpl extends GroupableResourceImpl< ApplicationSecurityGroup, ApplicationSecurityGroupInner, ApplicationSecurityGroupImpl, NetworkManager> implements ApplicationSecurityGroup, ApplicationSecurityGroup.Definition, ApplicationSecurityGroup.Update { ApplicationSecurityGroupImpl( final String ...
class ApplicationSecurityGroupImpl extends GroupableResourceImpl< ApplicationSecurityGroup, ApplicationSecurityGroupInner, ApplicationSecurityGroupImpl, NetworkManager> implements ApplicationSecurityGroup, ApplicationSecurityGroup.Definition, ApplicationSecurityGroup.Update { ApplicationSecurityGroupImpl( final String ...
`topic.getName() == null ` : NullPointerException ?
Mono<Response<TopicDescription>> updateTopicWithResponse(TopicDescription topic, Context context) { if (topic == null) { return monoError(logger, new NullPointerException("'topic' cannot be null")); } else if (topic.getName() == null || topic.getName().isEmpty()) { return monoError(logger, new IllegalArgumentException(...
return monoError(logger, new IllegalArgumentException("'topic.getName' cannot be null or empty."));
return monoError(logger, new NullPointerException("'topic' cannot be null")); } else if (context == null) { return monoError(logger, new NullPointerException("'context' cannot be null.")); }
class ServiceBusManagementAsyncClient { private static final String SERVICE_BUS_TRACING_NAMESPACE_VALUE = "Microsoft.ServiceBus"; private static final String CONTENT_TYPE = "application/xml"; private static final String QUEUES_ENTITY_TYPE = "queues"; private static final String TOPICS_ENTITY_TYPE = "topics"; private st...
class ServiceBusManagementAsyncClient { private static final String SERVICE_BUS_TRACING_NAMESPACE_VALUE = "Microsoft.ServiceBus"; private static final String CONTENT_TYPE = "application/xml"; private static final String QUEUES_ENTITY_TYPE = "queues"; private static final String TOPICS_ENTITY_TYPE = "topics"; private st...
nit: might need to consider local var `includeTextContent` to 'includeFieldElements' for the renaming as well.
public void beginRecognizeCustomFormsWithOptions() throws IOException { File form = new File("{local/file_path/fileName.jpg}"); String modelId = "{custom_trained_model_id}"; boolean includeTextContent = true; byte[] fileContent = Files.readAllBytes(form.toPath()); InputStream targetStream = new ByteArrayInputStream(fil...
.setIncludeFieldElements(includeTextContent).setPollInterval(Duration.ofSeconds(5))).getFinalResult()
public void beginRecognizeCustomFormsWithOptions() throws IOException { File form = new File("{local/file_path/fileName.jpg}"); String modelId = "{custom_trained_model_id}"; boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(form.toPath()); InputStream targetStream = new ByteArrayInputStream(f...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
updated!!
public void beginRecognizeCustomFormsWithOptions() throws IOException { File form = new File("{local/file_path/fileName.jpg}"); String modelId = "{custom_trained_model_id}"; boolean includeTextContent = true; byte[] fileContent = Files.readAllBytes(form.toPath()); InputStream targetStream = new ByteArrayInputStream(fil...
.setIncludeFieldElements(includeTextContent).setPollInterval(Duration.ofSeconds(5))).getFinalResult()
public void beginRecognizeCustomFormsWithOptions() throws IOException { File form = new File("{local/file_path/fileName.jpg}"); String modelId = "{custom_trained_model_id}"; boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(form.toPath()); InputStream targetStream = new ByteArrayInputStream(f...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
this should be `fieldElements`
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String filePath = "{analyze_file_path}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormP...
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String filePath = "{analyze_file_path}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormP...
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
same here
public static void main(String[] args) { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); String modelId = "{model_Id}"; String filePath = "{file_source_url}"; PollerFlux<OperationResult, List<RecognizedForm>> recogn...
public static void main(String[] args) { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); String modelId = "{model_Id}"; String filePath = "{file_source_url}"; PollerFlux<OperationResult, List<RecognizedForm>> recogn...
class GetBoundingBoxesAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
class GetBoundingBoxesAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
should we change this to fieldData?
public void beginRecognizeCustomFormsWithOptions() throws IOException { File form = new File("{local/file_path/fileName.jpg}"); String modelId = "{custom_trained_model_id}"; boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(form.toPath()); InputStream targetStream = new ByteArrayInputStream(f...
String fieldText = entry.getKey();
public void beginRecognizeCustomFormsWithOptions() throws IOException { File form = new File("{local/file_path/fileName.jpg}"); String modelId = "{custom_trained_model_id}"; boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(form.toPath()); InputStream targetStream = new ByteArrayInputStream(f...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
same here?
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String filePath = "{analyze_file_path}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormP...
recognizedForm.getFields().forEach((fieldText, fieldValue) -> System.out.printf("Field %s has value %s "
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String filePath = "{analyze_file_path}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormP...
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
formelement?
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String filePath = "{analyze_file_path}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormP...
formTableCell.getFieldElements().forEach(formContent -> {
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String filePath = "{analyze_file_path}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormP...
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
this needs to change too
public static void main(String[] args) throws IOException { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); File analyzeFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "forms/Form_...
public static void main(String[] args) throws IOException { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); File analyzeFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "forms/Form_...
class AdvancedDiffLabeledUnlabeledData { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
class AdvancedDiffLabeledUnlabeledData { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
@weidongxu-microsoft Silly question but why are we just disabling the assert and still bothering to get the callout count? With this disabled, are we missing a piece of verification that we should have for this scenario?
public void lroTimeout() { final Duration timeoutDuration = Duration.ofMillis(1000); final String resourceEndpoint = "/resource/1"; final AtomicInteger getCallCount = new AtomicInteger(0); ResponseTransformer provisioningStateLroService = new ResponseTransformer() { @Override public com.github.tomakehurst.wiremock.http...
public void lroTimeout() { final Duration timeoutDuration = Duration.ofMillis(1000); final String resourceEndpoint = "/resource/1"; final AtomicInteger getCallCount = new AtomicInteger(0); ResponseTransformer provisioningStateLroService = new ResponseTransformer() { @Override public com.github.tomakehurst.wiremock.http...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
You are correct. Ideally we should still do verification (maybe relax a bit on the condition for success). Due to the timing that the issue get called out (Alan notified that it blocking the release, and I've no idea if I relax the condition a bit will it still cause the issue), and the importance of the test (it is n...
public void lroTimeout() { final Duration timeoutDuration = Duration.ofMillis(1000); final String resourceEndpoint = "/resource/1"; final AtomicInteger getCallCount = new AtomicInteger(0); ResponseTransformer provisioningStateLroService = new ResponseTransformer() { @Override public com.github.tomakehurst.wiremock.http...
public void lroTimeout() { final Duration timeoutDuration = Duration.ofMillis(1000); final String resourceEndpoint = "/resource/1"; final AtomicInteger getCallCount = new AtomicInteger(0); ResponseTransformer provisioningStateLroService = new ResponseTransformer() { @Override public com.github.tomakehurst.wiremock.http...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
Maybe a `Mono.error` would be more proper? Generally we would like an error early than late.
public static Mono<byte[]> downloadFileAsync(String url, HttpPipeline httpPipeline) { FileService service = RestProxy.create(FileService.class, httpPipeline); try { return service.download(getHost(url), getPathAndQuery(url)) .flatMap(response -> FluxUtil.collectBytesInByteBufferStream(response.getValue())); } catch (Ma...
return Mono.empty();
public static Mono<byte[]> downloadFileAsync(String url, HttpPipeline httpPipeline) { FileService service = RestProxy.create(FileService.class, httpPipeline); try { return service.download(getHost(url), getPathAndQuery(url)) .flatMap(response -> FluxUtil.collectBytesInByteBufferStream(response.getValue())); } catch (Ma...
class Utils { private Utils() { } /** * Converts an object Boolean to a primitive boolean. * * @param value the Boolean value * @return false if the given Boolean value is null or false else true */ public static boolean toPrimitiveBoolean(Boolean value) { if (value == null) { return false; } return value.booleanValue(...
class Utils { private Utils() { } /** * Converts an object Boolean to a primitive boolean. * * @param value the Boolean value * @return false if the given Boolean value is null or false else true */ public static boolean toPrimitiveBoolean(Boolean value) { if (value == null) { return false; } return value.booleanValue(...
I think it should be `getRawPath` and `getRawQuery` due to you just do a string add.
public static String getPathAndQuery(String urlString) throws MalformedURLException { URL url = new URL(urlString); String path = url.getPath(); String query = url.getQuery(); if (query != null && !query.isEmpty()) { path = path + "?" + query; } return path; }
String query = url.getQuery();
public static String getPathAndQuery(String urlString) throws MalformedURLException { URL url = new URL(urlString); String path = url.getPath(); String query = url.getQuery(); if (query != null && !query.isEmpty()) { path = path + "?" + query; } return path; }
class Utils { private Utils() { } /** * Converts an object Boolean to a primitive boolean. * * @param value the Boolean value * @return false if the given Boolean value is null or false else true */ public static boolean toPrimitiveBoolean(Boolean value) { if (value == null) { return false; } return value.booleanValue(...
class Utils { private Utils() { } /** * Converts an object Boolean to a primitive boolean. * * @param value the Boolean value * @return false if the given Boolean value is null or false else true */ public static boolean toPrimitiveBoolean(Boolean value) { if (value == null) { return false; } return value.booleanValue(...
Not available for URL. Such methods are in URI.
public static String getPathAndQuery(String urlString) throws MalformedURLException { URL url = new URL(urlString); String path = url.getPath(); String query = url.getQuery(); if (query != null && !query.isEmpty()) { path = path + "?" + query; } return path; }
String query = url.getQuery();
public static String getPathAndQuery(String urlString) throws MalformedURLException { URL url = new URL(urlString); String path = url.getPath(); String query = url.getQuery(); if (query != null && !query.isEmpty()) { path = path + "?" + query; } return path; }
class Utils { private Utils() { } /** * Converts an object Boolean to a primitive boolean. * * @param value the Boolean value * @return false if the given Boolean value is null or false else true */ public static boolean toPrimitiveBoolean(Boolean value) { if (value == null) { return false; } return value.booleanValue(...
class Utils { private Utils() { } /** * Converts an object Boolean to a primitive boolean. * * @param value the Boolean value * @return false if the given Boolean value is null or false else true */ public static boolean toPrimitiveBoolean(Boolean value) { if (value == null) { return false; } return value.booleanValue(...
Could use a bit testing (send one to httpbin.org, or use your fiddler).
public static String getPathAndQuery(String urlString) throws MalformedURLException { URL url = new URL(urlString); String path = url.getPath(); String query = url.getQuery(); if (query != null && !query.isEmpty()) { path = path + "?" + query; } return path; }
String query = url.getQuery();
public static String getPathAndQuery(String urlString) throws MalformedURLException { URL url = new URL(urlString); String path = url.getPath(); String query = url.getQuery(); if (query != null && !query.isEmpty()) { path = path + "?" + query; } return path; }
class Utils { private Utils() { } /** * Converts an object Boolean to a primitive boolean. * * @param value the Boolean value * @return false if the given Boolean value is null or false else true */ public static boolean toPrimitiveBoolean(Boolean value) { if (value == null) { return false; } return value.booleanValue(...
class Utils { private Utils() { } /** * Converts an object Boolean to a primitive boolean. * * @param value the Boolean value * @return false if the given Boolean value is null or false else true */ public static boolean toPrimitiveBoolean(Boolean value) { if (value == null) { return false; } return value.booleanValue(...
I think this is in-correct. Don't we want to use `getIdleTcpConnectionTimeout` ?
public Builder(ConnectionPolicy connectionPolicy) { this.bufferPageSize = DEFAULT_OPTIONS.bufferPageSize; this.connectionAcquisitionTimeout = DEFAULT_OPTIONS.connectionAcquisitionTimeout; this.connectTimeout = connectionPolicy.getConnectTimeout(); this.idleChannelTimeout = connectionPolicy.getIdleConnectionTimeout(); t...
this.idleChannelTimeout = connectionPolicy.getIdleConnectionTimeout();
public Builder(ConnectionPolicy connectionPolicy) { this.bufferPageSize = DEFAULT_OPTIONS.bufferPageSize; this.connectionAcquisitionTimeout = DEFAULT_OPTIONS.connectionAcquisitionTimeout; this.connectTimeout = connectionPolicy.getConnectTimeout(); this.idleChannelTimeout = connectionPolicy.getIdleTcpConnectionTimeout()...
class Builder { private static final String DEFAULT_OPTIONS_PROPERTY_NAME = "azure.cosmos.directTcp.defaultOptions"; private static final Options DEFAULT_OPTIONS; static { Options options = null; try { final String string = System.getProperty(DEFAULT_OPTIONS_PROPERTY_NAME); if (string != null) { try { options = RntbdOb...
class Builder { private static final String DEFAULT_OPTIONS_PROPERTY_NAME = "azure.cosmos.directTcp.defaultOptions"; private static final Options DEFAULT_OPTIONS; static { Options options = null; try { final String string = System.getProperty(DEFAULT_OPTIONS_PROPERTY_NAME); if (string != null) { try { options = RntbdOb...
I am pretty sure it will not compile - because we don't have this method any more :)
public Builder(ConnectionPolicy connectionPolicy) { this.bufferPageSize = DEFAULT_OPTIONS.bufferPageSize; this.connectionAcquisitionTimeout = DEFAULT_OPTIONS.connectionAcquisitionTimeout; this.connectTimeout = connectionPolicy.getConnectTimeout(); this.idleChannelTimeout = connectionPolicy.getIdleConnectionTimeout(); t...
this.idleChannelTimeout = connectionPolicy.getIdleConnectionTimeout();
public Builder(ConnectionPolicy connectionPolicy) { this.bufferPageSize = DEFAULT_OPTIONS.bufferPageSize; this.connectionAcquisitionTimeout = DEFAULT_OPTIONS.connectionAcquisitionTimeout; this.connectTimeout = connectionPolicy.getConnectTimeout(); this.idleChannelTimeout = connectionPolicy.getIdleTcpConnectionTimeout()...
class Builder { private static final String DEFAULT_OPTIONS_PROPERTY_NAME = "azure.cosmos.directTcp.defaultOptions"; private static final Options DEFAULT_OPTIONS; static { Options options = null; try { final String string = System.getProperty(DEFAULT_OPTIONS_PROPERTY_NAME); if (string != null) { try { options = RntbdOb...
class Builder { private static final String DEFAULT_OPTIONS_PROPERTY_NAME = "azure.cosmos.directTcp.defaultOptions"; private static final Options DEFAULT_OPTIONS; static { Options options = null; try { final String string = System.getProperty(DEFAULT_OPTIONS_PROPERTY_NAME); if (string != null) { try { options = RntbdOb...
Sure we can, but we should not touch public surface implementations here as this PR should only target the tracing APIs. I have created a work item for this refactor work : https://github.com/Azure/azure-sdk-for-java/issues/13031
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) { return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context)); }
return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context));
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) { return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context)); }
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
Can this method call the method on L204
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) { return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context)); }
return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context));
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) { return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context)); }
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
I see we don't set the context object with nested data info for this method. I was wondering if it would be a better approach to always set the key but the value should determine if the call is nested or not. That should give us a more robust way to future developer don't miss this out.
private CosmosPagedFlux<CosmosDatabaseProperties> queryDatabasesInternal(SqlQuerySpec querySpec, CosmosQueryRequestOptions options){ return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null); setContinua...
pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null);
private CosmosPagedFlux<CosmosDatabaseProperties> queryDatabasesInternal(SqlQuerySpec querySpec, CosmosQueryRequestOptions options){ return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null); setContinua...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
I think this comment is misplaced, please clarify. This is query code and all tracer logic in query is [here](https://github.com/simplynaveen20/azure-sdk-for-java/blob/21c5743709725058254427079d898d2ad810da90/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/util/CosmosPagedFlux.java#L35)
private CosmosPagedFlux<CosmosDatabaseProperties> queryDatabasesInternal(SqlQuerySpec querySpec, CosmosQueryRequestOptions options){ return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null); setContinua...
pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null);
private CosmosPagedFlux<CosmosDatabaseProperties> queryDatabasesInternal(SqlQuerySpec querySpec, CosmosQueryRequestOptions options){ return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null); setContinua...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
We could do that, but avoiding nesting call in public api. Also it would be easier to read and debug. And our tracer goal getting fulfill with current design, so if you don't mind, can we keep current state?
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) { return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context)); }
return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context));
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) { return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context)); }
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
@kushagraThapar Could you clarify if this is a design decision to not reuse the methods here? And if it is, why is it followed in some files and not all the time? More context - https://github.com/Azure/azure-sdk-for-java/pull/12867#discussion_r452564457
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) { return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context)); }
return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context));
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id) { return withContext(context -> createDatabaseIfNotExistsInternal(getDatabase(id), null, context)); }
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
We will go by this approach,i.e adding nested data only on the api it needed , as this gave the best perf result, and adding data on all api might have an impact .
private CosmosPagedFlux<CosmosDatabaseProperties> queryDatabasesInternal(SqlQuerySpec querySpec, CosmosQueryRequestOptions options){ return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null); setContinua...
pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null);
private CosmosPagedFlux<CosmosDatabaseProperties> queryDatabasesInternal(SqlQuerySpec querySpec, CosmosQueryRequestOptions options){ return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null); setContinua...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
@samvaity - agreed, we can add nested / non-nested information on context always irrespective of the API if it doesn't result in a perf hit. Added it to this issue: https://github.com/Azure/azure-sdk-for-java/issues/13031
private CosmosPagedFlux<CosmosDatabaseProperties> queryDatabasesInternal(SqlQuerySpec querySpec, CosmosQueryRequestOptions options){ return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null); setContinua...
pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null);
private CosmosPagedFlux<CosmosDatabaseProperties> queryDatabasesInternal(SqlQuerySpec querySpec, CosmosQueryRequestOptions options){ return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { pagedFluxOptions.setTracerInformation(this.tracerProvider, "queryDatabases", this.serviceEndpoint, null); setContinua...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
class CosmosAsyncClient implements Closeable { private final Configs configs; private final AsyncDocumentClient asyncDocumentClient; private final String serviceEndpoint; private final String keyOrResourceToken; private final ConnectionPolicy connectionPolicy; private final ConsistencyLevel desiredConsistencyLevel; pri...
Does this mean we are expecting, there would be 5 spans for a single `readItem`?
public void cosmosAsyncContainer() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.d...
Mockito.verify(tracerProvider, Mockito.times(5)).startSpan(Matchers.anyString(), Matchers.anyString(),
public void cosmosAsyncContainer() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCapt...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
I thought we got rid of the span name `readUDF` and should be using the same public API name for user -API visibility concerns.
public void cosmosAsyncScripts() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doA...
verifyTracerAttributes(mockTracer, "readUDF." + cosmosAsyncContainer.getId(), context,
public void cosmosAsyncScripts() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCaptur...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
Suggestion can be updated to check for the span name here ``` Mockito.verify(tracerProvider, Mockito.times(1)).startSpan(eq("createContainerIfNotExists"), Matchers.anyString() ````
public void cosmosAsyncDatabase() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.do...
Mockito.verify(tracerProvider, Mockito.times(1)).startSpan(Matchers.anyString(), Matchers.anyString(),
public void cosmosAsyncDatabase() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCaptu...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
Mockito does not work with partial matching, it will give runtime error , and anyway we are checking span name on mock tracer so this does not needed
public void cosmosAsyncDatabase() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.do...
Mockito.verify(tracerProvider, Mockito.times(1)).startSpan(Matchers.anyString(), Matchers.anyString(),
public void cosmosAsyncDatabase() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCaptu...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
Not sure what you mean, an example of what I am suggesting https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClientTest.java#L426
public void cosmosAsyncDatabase() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.do...
Mockito.verify(tracerProvider, Mockito.times(1)).startSpan(Matchers.anyString(), Matchers.anyString(),
public void cosmosAsyncDatabase() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCaptu...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
No there will be only 1 span for readItem. This is to verify how many times this method is called in test function.
public void cosmosAsyncContainer() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.d...
Mockito.verify(tracerProvider, Mockito.times(5)).startSpan(Matchers.anyString(), Matchers.anyString(),
public void cosmosAsyncContainer() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCapt...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
Do we need the `spy` if we have a mock of tracer list for a valid tracerProvider object? nit: Consider adding static import for Mockito methods.
public void cosmosAsyncDatabase() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.do...
TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer)));
public void cosmosAsyncDatabase() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCaptu...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
we can do readUDF -> readUserDefinedFunction ?, but cant do just read() as we have hierarchy model in cosmos and all resources use read() api
public void cosmosAsyncScripts() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doA...
verifyTracerAttributes(mockTracer, "readUDF." + cosmosAsyncContainer.getId(), context,
public void cosmosAsyncScripts() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCaptur...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
Then that is an incorrect representation of the use case. As unit testing, the test should ideally be expecting 1 span for a single API call?
public void cosmosAsyncContainer() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.d...
Mockito.verify(tracerProvider, Mockito.times(5)).startSpan(Matchers.anyString(), Matchers.anyString(),
public void cosmosAsyncContainer() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCapt...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
@simplynaveen20 - we should an incrementing counter instead of using numeral literal values in `Mockito.times(1)` call - so that it is much clear to us.
public void cosmosAsyncDatabase() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.do...
Mockito.verify(tracerProvider, Mockito.times(1)).startSpan(Matchers.anyString(), Matchers.anyString(),
public void cosmosAsyncDatabase() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCaptu...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
we need spy to get the context from startSpan to verify attributes , and also we are checking on number of timer startSpan is called on provider
public void cosmosAsyncDatabase() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.do...
TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer)));
public void cosmosAsyncDatabase() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCaptu...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
added incremental variable instead of numeral literal
public void cosmosAsyncDatabase() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.do...
Mockito.verify(tracerProvider, Mockito.times(1)).startSpan(Matchers.anyString(), Matchers.anyString(),
public void cosmosAsyncDatabase() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCaptu...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
We are checking incremental invocation based on api calls in single test case , which is clubbed together as per our object model , like all container apis are under one test
public void cosmosAsyncContainer() { Tracer mockTracer = Mockito.mock(Tracer.class); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(getMockTracer(mockTracer))); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.d...
Mockito.verify(tracerProvider, Mockito.times(5)).startSpan(Matchers.anyString(), Matchers.anyString(),
public void cosmosAsyncContainer() { Tracer mockTracer = getMockTracer(); TracerProvider tracerProvider = Mockito.spy(new TracerProvider(mockTracer)); ReflectionUtils.setTracerProvider(client, tracerProvider); TracerProviderCapture tracerProviderCapture = new TracerProviderCapture(); Mockito.doAnswer(tracerProviderCapt...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
class CosmosTracerTest extends TestSuiteBase { private static final String ITEM_ID = "tracerDoc"; CosmosAsyncClient client; CosmosAsyncDatabase cosmosAsyncDatabase; CosmosAsyncContainer cosmosAsyncContainer; @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { client = new CosmosClie...
These shouldn't have to change. Input-output models should have setter overloads for both varargs and List.
public static AnalyzeTextOptions map(com.azure.search.documents.indexes.implementation.models.AnalyzeRequest obj) { if (obj == null) { return null; } AnalyzeTextOptions analyzeTextOptions = null; if (obj.getTokenizer() != null) { LexicalTokenizerName tokenizer = LexicalTokenizerNameConverter.map(obj.getTokenizer()); an...
.toArray(TokenFilterName[]::new);
public static AnalyzeTextOptions map(com.azure.search.documents.indexes.implementation.models.AnalyzeRequest obj) { if (obj == null) { return null; } AnalyzeTextOptions analyzeTextOptions = null; if (obj.getTokenizer() != null) { LexicalTokenizerName tokenizer = LexicalTokenizerNameConverter.map(obj.getTokenizer()); an...
class AnalyzeRequestConverter { /** * Maps from {@link com.azure.search.documents.indexes.implementation.models.AnalyzeRequest} to {@link AnalyzeTextOptions}. */ /** * Maps from {@link AnalyzeTextOptions} to {@link com.azure.search.documents.indexes.implementation.models.AnalyzeRequest}. */ public static com.azure.sear...
class AnalyzeRequestConverter { /** * Maps from {@link com.azure.search.documents.indexes.implementation.models.AnalyzeRequest} to {@link AnalyzeTextOptions}. */ /** * Maps from {@link AnalyzeTextOptions} to {@link com.azure.search.documents.indexes.implementation.models.AnalyzeRequest}. */ public static com.azure.sear...
NIT: final static "consts" as class level to avoid allocation for every execution
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
final String segmentSeparator = "
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
Reverted
public static AnalyzeTextOptions map(com.azure.search.documents.indexes.implementation.models.AnalyzeRequest obj) { if (obj == null) { return null; } AnalyzeTextOptions analyzeTextOptions = null; if (obj.getTokenizer() != null) { LexicalTokenizerName tokenizer = LexicalTokenizerNameConverter.map(obj.getTokenizer()); an...
.toArray(TokenFilterName[]::new);
public static AnalyzeTextOptions map(com.azure.search.documents.indexes.implementation.models.AnalyzeRequest obj) { if (obj == null) { return null; } AnalyzeTextOptions analyzeTextOptions = null; if (obj.getTokenizer() != null) { LexicalTokenizerName tokenizer = LexicalTokenizerNameConverter.map(obj.getTokenizer()); an...
class AnalyzeRequestConverter { /** * Maps from {@link com.azure.search.documents.indexes.implementation.models.AnalyzeRequest} to {@link AnalyzeTextOptions}. */ /** * Maps from {@link AnalyzeTextOptions} to {@link com.azure.search.documents.indexes.implementation.models.AnalyzeRequest}. */ public static com.azure.sear...
class AnalyzeRequestConverter { /** * Maps from {@link com.azure.search.documents.indexes.implementation.models.AnalyzeRequest} to {@link AnalyzeTextOptions}. */ /** * Maps from {@link AnalyzeTextOptions} to {@link com.azure.search.documents.indexes.implementation.models.AnalyzeRequest}. */ public static com.azure.sear...
Nice.
public void executeStoredProcedureWithScriptLoggingEnabled() throws Exception { CosmosStoredProcedureProperties storedProcedure = new CosmosStoredProcedureProperties( UUID.randomUUID().toString(), "function() {" + " var mytext = \"x\";" + " var myval = 1;" + " try {" + " console.log(\"Th...
assertThat(URLDecoder.decode(executeResponse.getScriptLog(), StandardCharsets.UTF_8)).isEqualTo(logResult);
public void executeStoredProcedureWithScriptLoggingEnabled() throws Exception { CosmosStoredProcedureProperties storedProcedure = new CosmosStoredProcedureProperties( UUID.randomUUID().toString(), "function() {" + " var mytext = \"x\";" + " var myval = 1;" + " try {" + " console.log(\"Th...
class CosmosSyncStoredProcTest extends TestSuiteBase { private String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private List<String> databases = new ArrayList<>(); private CosmosClient client; private CosmosContainer container; @Factory(dataProvider = "clientBuilders") public CosmosSyncStoredProcTest(...
class CosmosSyncStoredProcTest extends TestSuiteBase { private String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private List<String> databases = new ArrayList<>(); private CosmosClient client; private CosmosContainer container; @Factory(dataProvider = "clientBuilders") public CosmosSyncStoredProcTest(...
I wonder whose job it is to do the decoding? is it the SDK job to decode scriptLog or the user?
public void executeStoredProcedureWithScriptLoggingEnabled() throws Exception { CosmosStoredProcedureProperties storedProcedure = new CosmosStoredProcedureProperties( UUID.randomUUID().toString(), "function() {" + " var mytext = \"x\";" + " var myval = 1;" + " try {" + " console.log(\"Th...
assertThat(URLDecoder.decode(executeResponse.getScriptLog(), StandardCharsets.UTF_8)).isEqualTo(logResult);
public void executeStoredProcedureWithScriptLoggingEnabled() throws Exception { CosmosStoredProcedureProperties storedProcedure = new CosmosStoredProcedureProperties( UUID.randomUUID().toString(), "function() {" + " var mytext = \"x\";" + " var myval = 1;" + " try {" + " console.log(\"Th...
class CosmosSyncStoredProcTest extends TestSuiteBase { private String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private List<String> databases = new ArrayList<>(); private CosmosClient client; private CosmosContainer container; @Factory(dataProvider = "clientBuilders") public CosmosSyncStoredProcTest(...
class CosmosSyncStoredProcTest extends TestSuiteBase { private String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private List<String> databases = new ArrayList<>(); private CosmosClient client; private CosmosContainer container; @Factory(dataProvider = "clientBuilders") public CosmosSyncStoredProcTest(...
Can we use StringUtils.isEmpty here ?
public static String decodeAsUTF8String(String inputString) { if (inputString == null || inputString.isEmpty()) { return inputString; } try { return URLDecoder.decode(inputString, StandardCharsets.UTF_8.toString()); } catch (UnsupportedEncodingException e) { logger.warn("Error while decoding input string", e); return i...
if (inputString == null || inputString.isEmpty()) {
public static String decodeAsUTF8String(String inputString) { if (inputString == null || inputString.isEmpty()) { return inputString; } try { return URLDecoder.decode(inputString, StandardCharsets.UTF_8.toString()); } catch (UnsupportedEncodingException e) { logger.warn("Error while decoding input string", e); return i...
class Utils { private final static Logger logger = LoggerFactory.getLogger(Utils.class); private static final int ONE_KB = 1024; private static final ZoneId GMT_ZONE_ID = ZoneId.of("GMT"); public static final Base64.Encoder Base64Encoder = Base64.getEncoder(); public static final Base64.Decoder Base64Decoder = Base64.g...
class Utils { private final static Logger logger = LoggerFactory.getLogger(Utils.class); private static final int ONE_KB = 1024; private static final ZoneId GMT_ZONE_ID = ZoneId.of("GMT"); public static final Base64.Encoder Base64Encoder = Base64.getEncoder(); public static final Base64.Decoder Base64Decoder = Base64.g...
Yes, we can do that too. Since this is implementation detail, will change it in next PR .
public static String decodeAsUTF8String(String inputString) { if (inputString == null || inputString.isEmpty()) { return inputString; } try { return URLDecoder.decode(inputString, StandardCharsets.UTF_8.toString()); } catch (UnsupportedEncodingException e) { logger.warn("Error while decoding input string", e); return i...
if (inputString == null || inputString.isEmpty()) {
public static String decodeAsUTF8String(String inputString) { if (inputString == null || inputString.isEmpty()) { return inputString; } try { return URLDecoder.decode(inputString, StandardCharsets.UTF_8.toString()); } catch (UnsupportedEncodingException e) { logger.warn("Error while decoding input string", e); return i...
class Utils { private final static Logger logger = LoggerFactory.getLogger(Utils.class); private static final int ONE_KB = 1024; private static final ZoneId GMT_ZONE_ID = ZoneId.of("GMT"); public static final Base64.Encoder Base64Encoder = Base64.getEncoder(); public static final Base64.Decoder Base64Decoder = Base64.g...
class Utils { private final static Logger logger = LoggerFactory.getLogger(Utils.class); private static final int ONE_KB = 1024; private static final ZoneId GMT_ZONE_ID = ZoneId.of("GMT"); public static final Base64.Encoder Base64Encoder = Base64.getEncoder(); public static final Base64.Decoder Base64Decoder = Base64.g...
NIT: final
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
String sessionTokenLsn = feedResponse.getSessionToken();
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
Same for several of the local variables below
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
String sessionTokenLsn = feedResponse.getSessionToken();
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
using == instead of .equals()?
public void beginRecognizeReceipts() throws IOException { File receipt = new File("{file_source_url}"); Flux<ByteBuffer> buffer = toFluxByteBuffer(new ByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(recognizePollingOperatio...
if (FieldValueType.LIST.equals(receiptItemsField.getValueType())) {
public void beginRecognizeReceipts() throws IOException { File receipt = new File("{file_source_url}"); Flux<ByteBuffer> buffer = toFluxByteBuffer(new ByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(AsyncPollResponse::getFi...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
same to rest of files. Might be need to revisit CodeSnippets files again
public void beginRecognizeReceipts() throws IOException { File receipt = new File("{file_source_url}"); Flux<ByteBuffer> buffer = toFluxByteBuffer(new ByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(recognizePollingOperatio...
if (FieldValueType.LIST.equals(receiptItemsField.getValueType())) {
public void beginRecognizeReceipts() throws IOException { File receipt = new File("{file_source_url}"); Flux<ByteBuffer> buffer = toFluxByteBuffer(new ByteArrayInputStream(Files.readAllBytes(receipt.toPath()))); formRecognizerAsyncClient.beginRecognizeReceipts(buffer, receipt.length()) .flatMap(AsyncPollResponse::getFi...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
perfect place to use stream() method here. Great.
public void beginRecognizeReceiptsWithOptions() throws IOException { File receipt = new File("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(receipt.toPath()); InputStream targetStream = new ByteArrayInputStream(fileContent); for (RecognizedForm recognized...
.filter(receiptItem -> FieldValueType.MAP == receiptItem.getValueType())
public void beginRecognizeReceiptsWithOptions() throws IOException { File receipt = new File("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(receipt.toPath()); try (InputStream targetStream = new ByteArrayInputStream(fileContent)) { for (RecognizedForm rec...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
is possible to use stream again and filter here?
public void beginRecognizeReceiptsWithOptions() throws IOException { File receipt = new File("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(receipt.toPath()); InputStream targetStream = new ByteArrayInputStream(fileContent); for (RecognizedForm recognized...
if ("Quantity".equals(key)) {
public void beginRecognizeReceiptsWithOptions() throws IOException { File receipt = new File("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(receipt.toPath()); try (InputStream targetStream = new ByteArrayInputStream(fileContent)) { for (RecognizedForm rec...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
I guess I can. Just wanted to keep a method showing the non-stream way but thought that would be inconsistent. So kept all the sample files using `forEach`. I don't have a strong preference, what do you think, update all of them?
public void beginRecognizeReceiptsWithOptions() throws IOException { File receipt = new File("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(receipt.toPath()); InputStream targetStream = new ByteArrayInputStream(fileContent); for (RecognizedForm recognized...
if ("Quantity".equals(key)) {
public void beginRecognizeReceiptsWithOptions() throws IOException { File receipt = new File("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(receipt.toPath()); try (InputStream targetStream = new ByteArrayInputStream(fileContent)) { for (RecognizedForm rec...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
Personally I like to using stream() if possible.
public void beginRecognizeReceiptsWithOptions() throws IOException { File receipt = new File("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(receipt.toPath()); InputStream targetStream = new ByteArrayInputStream(fileContent); for (RecognizedForm recognized...
if ("Quantity".equals(key)) {
public void beginRecognizeReceiptsWithOptions() throws IOException { File receipt = new File("{local/file_path/fileName.jpg}"); boolean includeFieldElements = true; byte[] fileContent = Files.readAllBytes(receipt.toPath()); try (InputStream targetStream = new ByteArrayInputStream(fileContent)) { for (RecognizedForm rec...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
class FormRecognizerClientJavaDocCodeSnippets { private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient(); /** * Code snippet for creating a {@link FormRecognizerClient} */ public void createFormRecognizerClient() { FormRecognizerClient formRecognizerClient = new FormRecognizer...
good catch
public void beginRecognizeReceiptsFromUrl() { String receiptUrl = "{receiptUrl}"; formRecognizerAsyncClient.beginRecognizeReceiptsFromUrl(receiptUrl) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedReceipts -> { for (int i = 0; i < recognizedReceipts.size(); i++) { RecognizedForm recognizedForm = recog...
if (FieldValueType.PHONE_NUMBER == merchantPhoneNumberField.getValueType()) {
public void beginRecognizeReceiptsFromUrl() { String receiptUrl = "{receiptUrl}"; formRecognizerAsyncClient.beginRecognizeReceiptsFromUrl(receiptUrl) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(recognizedReceipts -> { for (int i = 0; i < recognizedReceipts.size(); i++) { RecognizedForm recognizedForm = recog...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
class FormRecognizerAsyncClientJavaDocCodeSnippets { FormRecognizerAsyncClient formRecognizerAsyncClient = new FormRecognizerClientBuilder().buildAsyncClient(); /** * Code snippet for creating a {@link FormRecognizerAsyncClient} */ public void createFormRecognizerAsyncClient() { FormRecognizerAsyncClient formRecognizer...
NIT: you are using two space here, but should be one.
public static void main(String[] args) throws IOException { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); File analyzeFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "forms/Form_...
System.out.printf("Field %s has label %s within bounding box %s with a confidence score "
public static void main(String[] args) throws IOException { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); File analyzeFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "forms/Form_...
class AdvancedDiffLabeledUnlabeledData { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
class AdvancedDiffLabeledUnlabeledData { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
nit: same here. extra space
public static void main(String[] args) throws IOException { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); File analyzeFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "f...
System.out.printf("Field %s has label %s within bounding box %s with a confidence score "
public static void main(String[] args) throws IOException { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); File analyzeFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "f...
class AdvancedDiffLabeledUnlabeledDataAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
class AdvancedDiffLabeledUnlabeledDataAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
like other change, change to flatMap()?
public void beginTraining() { String trainingFilesUrl = "{SAS-URL-of-your-container-in-blob-storage}"; boolean useTrainingLabels = true; formTrainingAsyncClient.beginTraining(trainingFilesUrl, useTrainingLabels) .subscribe(trainingPollingOperation -> { trainingPollingOperation.getFinalResult().subscribe(customFormModel...
.subscribe(trainingPollingOperation -> {
public void beginTraining() { String trainingFilesUrl = "{SAS-URL-of-your-container-in-blob-storage}"; boolean useTrainingLabels = true; formTrainingAsyncClient.beginTraining(trainingFilesUrl, useTrainingLabels) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(customFormModel -> { System.out.printf("Model Id: %s%...
class FormTrainingAsyncClientJavaDocCodeSnippets { private FormTrainingAsyncClient formTrainingAsyncClient = new FormTrainingClientBuilder().buildAsyncClient(); /** * Code snippet for {@link FormTrainingAsyncClient} initialization */ public void formTrainingAsyncClientInInitialization() { FormTrainingAsyncClient formTr...
class FormTrainingAsyncClientJavaDocCodeSnippets { private FormTrainingAsyncClient formTrainingAsyncClient = new FormTrainingClientBuilder().buildAsyncClient(); /** * Code snippet for {@link FormTrainingAsyncClient} initialization */ public void formTrainingAsyncClientInInitialization() { FormTrainingAsyncClient formTr...
We din't want two subscribes nested so changed for others.
public void beginTraining() { String trainingFilesUrl = "{SAS-URL-of-your-container-in-blob-storage}"; boolean useTrainingLabels = true; formTrainingAsyncClient.beginTraining(trainingFilesUrl, useTrainingLabels) .subscribe(trainingPollingOperation -> { trainingPollingOperation.getFinalResult().subscribe(customFormModel...
.subscribe(trainingPollingOperation -> {
public void beginTraining() { String trainingFilesUrl = "{SAS-URL-of-your-container-in-blob-storage}"; boolean useTrainingLabels = true; formTrainingAsyncClient.beginTraining(trainingFilesUrl, useTrainingLabels) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(customFormModel -> { System.out.printf("Model Id: %s%...
class FormTrainingAsyncClientJavaDocCodeSnippets { private FormTrainingAsyncClient formTrainingAsyncClient = new FormTrainingClientBuilder().buildAsyncClient(); /** * Code snippet for {@link FormTrainingAsyncClient} initialization */ public void formTrainingAsyncClientInInitialization() { FormTrainingAsyncClient formTr...
class FormTrainingAsyncClientJavaDocCodeSnippets { private FormTrainingAsyncClient formTrainingAsyncClient = new FormTrainingClientBuilder().buildAsyncClient(); /** * Code snippet for {@link FormTrainingAsyncClient} initialization */ public void formTrainingAsyncClientInInitialization() { FormTrainingAsyncClient formTr...
what is the purpose of using try() but without catch()?
public static void main(String[] args) throws IOException { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); File sourceFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "fo...
String modelId = "{modelId}";
public static void main(String[] args) throws IOException { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); File sourceFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "fo...
class RecognizeCustomFormsAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
class RecognizeCustomFormsAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
NIT: merge to one sentence: ``` new RecognizeOption().setIncludeFieldElements(true)); ```
public static void main(String[] args) { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); String modelId = "{model_Id}"; String formUrl = "{form_url}"; PollerFlux<OperationResult, List<RecognizedForm>> recognizeFormP...
.setIncludeFieldElements(true));
public static void main(String[] args) { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); String modelId = "{model_Id}"; String formUrl = "{form_url}"; PollerFlux<OperationResult, List<RecognizedForm>> recognizeFormP...
class GetBoundingBoxesAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
class GetBoundingBoxesAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
checkstyle issue? line too long?
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String formUrl = "{form_url}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormPoller = cl...
formWordElement.getBoundingBox().getPoints().forEach(point -> boundingBoxStr.append(String.format("[%.2f, %.2f]", point.getX(),
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String formUrl = "{form_url}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormPoller = cl...
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
it is in sample, should be fine
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String formUrl = "{form_url}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormPoller = cl...
formWordElement.getBoundingBox().getPoints().forEach(point -> boundingBoxStr.append(String.format("[%.2f, %.2f]", point.getX(),
public static void main(String[] args) { FormRecognizerClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildClient(); String modelId = "{model_Id}"; String formUrl = "{form_url}"; SyncPoller<OperationResult, List<RecognizedForm>> recognizeFormPoller = cl...
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
class GetBoundingBoxes { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. */ }
This is an auto closeable try block. This will make sure the stream is closed out of the block.
public static void main(String[] args) throws IOException { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); File sourceFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "fo...
String modelId = "{modelId}";
public static void main(String[] args) throws IOException { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); File sourceFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "fo...
class RecognizeCustomFormsAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
class RecognizeCustomFormsAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
NIT: assign local variable for feedResponse.getResults() to avoid repetitive invocation of the property getter
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
if (feedResponse.getResults() == null || feedResponse.getResults().size() == 0) {
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
Not sure - my style-preference would be changeFeedProcessorState .setEstimatedLag(0) .setContinuationToken(latestLsn); But feel free to ignore if the non-fluent style is what makes the code more consistent etc.
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
changeFeedProcessorState.setContinuationToken(latestLsn);
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
Wouldn't this indicate a critical failure - tracing as warning and ignoring unexpected backend response seems to make it harder than necessary to identify breaking changes / debug it?
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
} catch (NumberFormatException ex) {
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
Again - feel free to ignore for consistency etc. - I am still struggling with Java not having a clear way to distinguish ReadOnlyList in the contract. But form my intuition I would expect it to be clearly documented in the Api doc comments if a method returns an unmodifiable list - so would it make sense to add a comme...
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
.map(Collections::unmodifiableList);
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
Though these have one assignment, it will look a bit odd when compared with similar patterns in the rest of the implementation (not just CFP). And since they are not consumed by any Reactor code as arguments down the execution path which requires as such, they don't really need to be final...
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
String sessionTokenLsn = feedResponse.getSessionToken();
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
I agree, this should be fluent style - if changeFeedProcessorState supports it.
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
changeFeedProcessorState.setContinuationToken(latestLsn);
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
_ts should always be a long - right ?
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
} catch (NumberFormatException ex) {
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
yep, makes sense since these are also shared in the code above.
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
final String segmentSeparator = "
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
I'll keep it as such, it is easier to read the code. The property getter does not execute any particular complex operation, it just returns an internal member.
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
if (feedResponse.getResults() == null || feedResponse.getResults().size() == 0) {
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
In general I prefer the same "fluidity", especially after invoking the constructor :-)
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
changeFeedProcessorState.setContinuationToken(latestLsn);
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
The error though unexpected (_ts system property is an epoch), it is not fatal (there's a log warning capturing this). Setting the continuation token as "null" is an indicator that the document found is not valid; i.e. we initialized CFP leases but we are yet to process any changes in this particular scope/partition.
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
} catch (NumberFormatException ex) {
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
yep, I've updated the doc to capture this is a read only list.
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
.map(Collections::unmodifiableList);
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
also fixed the empty list early returned case (thanks for catching that up).
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
.map(Collections::unmodifiableList);
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
String.split uses regex underneath which is cpu intensive. use StringUtils.split instead.
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(Collections.unmodifiableList(earlyResult)); } return this.leaseStoreManager.getAllLeases() .flatMap(lea...
String[] segments = parsedSessionToken.split(SEGMENT_SEPARATOR);
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
also java compiler may inline these. so shouldn't be a perf hit.
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(earlyResult); } return this.leaseStoreManager.getAllLeases() .flatMap(lease -> { ChangeFeedOptions opti...
if (feedResponse.getResults() == null || feedResponse.getResults().size() == 0) {
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private final Duration sleepTime = Duration.ofSeco...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
```suggestion assertThat(totalLag).equalTo(FEED_COUNT).as("...") ```
public void getCurrentState() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); try { List<InternalObjectNode> createdDocuments = new ArrayList<>()...
assertThat(totalLag == FEED_COUNT).as("Change Feed Processor estimated total lag").isTrue();
public void getCurrentState() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); try { List<InternalObjectNode> createdDocuments = new ArrayList<>()...
class ChangeFeedProcessorTest extends TestSuiteBase { private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class); private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper(); private CosmosAsyncDatabase createdDatabase; private final String hostName = RandomStringUtils....
class ChangeFeedProcessorTest extends TestSuiteBase { private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class); private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper(); private CosmosAsyncDatabase createdDatabase; private final String hostName = RandomStringUtils....
fixed
public Mono<List<ChangeFeedProcessorState>> getCurrentState() { List<ChangeFeedProcessorState> earlyResult = new ArrayList<>(); if (this.leaseStoreManager == null || this.feedContextClient == null) { return Mono.just(Collections.unmodifiableList(earlyResult)); } return this.leaseStoreManager.getAllLeases() .flatMap(lea...
String[] segments = parsedSessionToken.split(SEGMENT_SEPARATOR);
new ChangeFeedOptions() .setMaxItemCount(1) .setPartitionKeyRangeId(lease.getLeaseToken()) .setStartFromBeginning(true) .setRequestContinuation(lease.getContinuationToken()); return this.feedContextClient.createDocumentChangeFeedQuery(this.feedContextClient.getContainerClient(), options) .take(1) .map(feedResponse -> {...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor, AutoCloseable { private static final String PK_RANGE_ID_SEPARATOR = ":"; private static final String SEGMENT_SEPARATOR = " private static final String PROPERTY_NAME_LSN = "_lsn"; private static final String PROPERTY_NAME_TS = "_ts"; private final Logg...
fixed
public void getCurrentState() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); try { List<InternalObjectNode> createdDocuments = new ArrayList<>()...
assertThat(totalLag == FEED_COUNT).as("Change Feed Processor estimated total lag").isTrue();
public void getCurrentState() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); try { List<InternalObjectNode> createdDocuments = new ArrayList<>()...
class ChangeFeedProcessorTest extends TestSuiteBase { private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class); private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper(); private CosmosAsyncDatabase createdDatabase; private final String hostName = RandomStringUtils....
class ChangeFeedProcessorTest extends TestSuiteBase { private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class); private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper(); private CosmosAsyncDatabase createdDatabase; private final String hostName = RandomStringUtils....