Skip to content

Commit

Permalink
group by partition key
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jun 21, 2024
1 parent 4ea76f8 commit e963b6a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/AzureTackle/AzureTackle.fs
Original file line number Diff line number Diff line change
Expand Up @@ -451,17 +451,19 @@ module AzureTable =
try
let azureTable = getTable props

let chunks =
entities
|> Array.chunkBySize 100
for chunks in chunks do
let actions =
chunks
|> Array.map (fun entity ->
TableTransactionAction(TableTransactionActionType.UpsertReplace, entity))

let! _ = azureTable.SubmitTransactionAsync(actions)
return ()
for _key, entities in entities |> Array.groupBy (fun x -> x.PartitionKey) do
let chunks =
entities
|> Array.chunkBySize 100

for chunks in chunks do
let actions =
chunks
|> Array.map (fun entity ->
TableTransactionAction(TableTransactionActionType.UpsertReplace, entity))

let! _ = azureTable.SubmitTransactionAsync(actions)
()
with exn ->
return failwithf "UpsertBatch failed with exn: %s" exn.Message
}
Expand Down

0 comments on commit e963b6a

Please sign in to comment.