Azure 테이블 저장소의 일괄 저장 작업에서 이미 존재하는 엔티티의 특정 속성을 효율적으로 바꿀 수 있습니까? 새로운 엔티티의 모든 속성을 업데이트 하시겠습니까?Azure 저장소 및 조건부 대체/병합
여기에 내가 말하고있는 시나리오가 있습니다.
나는 주문라는 실체가
public class Order : TableEntity
{
public Order(String department, string orderId)
{
this.PartitionKey = department;
this.RowKey = orderId;
}
public DateTime CreatedOn {get; set;}
public String CreatedBy {get; set;}
public DateTime UpdatedOn {get; set;}
public String UpdatedBy {get; set;}
//Class contains other properties which could add up to 1MB
}
시나리오
- 푸른 표 스토리지 [0..100]
- 내 API는 대한 upsert 요청을 수신 RowKeys와 위해서 개체가 있습니다 RowKeys [50..150]로 주문.
- 일괄 트랜잭션에서 나는 주문 [50-100]의 특정 속성을 업데이트하고 하늘색에 새로운 주문 엔티티 [101-150]를 생성해야합니다.
- 참고 : 기존 주문 [50..100]에서 CreatedOn, CreatedBy, PartitionKey 및 RowKey를 제외한 모든 속성을 업데이트해야합니다.
테이블 스토어에서 내용을 읽지 않고 한 번에 할 수 있습니까? 여기
는function Upsert(Dictionary<String, Order> ordersInput)
{
//1. Read existing ordersInput from database
var existingOrders = Retrieve(ordersInput.Values);
//2. Update 'ordersInput' with existing data
foreach(var existingOrder in existingOrders)
{
if(ordersInput.ContainsKey(existingOrder.RowKey)
{
ordersInput[existingOrder.RowKey].CreatedOn = existingOrder.CreatedOn;
ordersInput[existingOrder.RowKey].CreatedBy = existingOrder.CreatedBy;
}
}
//Save all merged orders to Azure
SaveToAzure(existingOrders);
}
나는 위의 방법으로이 문제는 각 주문 개체의 크기가 1MB입니다 및 모든 엔티티를 읽는 것은 아래 습지 있다는 것입니다 그것을 할 수있는 한 가지 방법 (매우 거친 의사 코드)입니다 API 저장 조작.
조건부 병합을 완전히 하늘에서 수행하는보다 효율적인 방법이 있습니까?
나는 또한 다음과 같은 방법- 이전 단계는 "지정된 엔티티가 이미 존재"가 발생하면 모든 주문
- 에 배치 삽입를 수행에 배치 삽입을하고 생각했다
그런 다음 두 개의 새로운 배치 (기존 행 키와 다른 행 키를 각각 하나씩)를 만들고 각각을 개별적으로 처리하십시오.
ounds hacky와 나는 많은 동시성 문제를 야기 할 수 있다고 생각한다.)
해결 했습니까? –
쿼리 투영 및 insertormerge의 조합을 사용했습니다. – infinity