Skip to content

Commit 71eb0c2

Browse files
committed
fix #55 thanks to @ischtz
1 parent 0b6cc4f commit 71eb0c2

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

Assets/Testing/AWSDDBTest.unity

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,7 @@ PrefabInstance:
19491949
- target: {fileID: 2834388984357925155, guid: 0a3b6392f04558844bd340e68ced1ff9,
19501950
type: 3}
19511951
propertyPath: m_AnchoredPosition.y
1952-
value: 6175
1952+
value: 6500
19531953
objectReference: {fileID: 0}
19541954
- target: {fileID: 2896031059644693069, guid: 0a3b6392f04558844bd340e68ced1ff9,
19551955
type: 3}
@@ -1999,7 +1999,7 @@ PrefabInstance:
19991999
- target: {fileID: 4267567203292169432, guid: 0a3b6392f04558844bd340e68ced1ff9,
20002000
type: 3}
20012001
propertyPath: m_AnchoredPosition.y
2002-
value: 11400
2002+
value: 12000
20032003
objectReference: {fileID: 0}
20042004
- target: {fileID: 4298776666381973480, guid: 0a3b6392f04558844bd340e68ced1ff9,
20052005
type: 3}
@@ -2116,6 +2116,11 @@ PrefabInstance:
21162116
propertyPath: m_SizeDelta.y
21172117
value: 0
21182118
objectReference: {fileID: 0}
2119+
- target: {fileID: 7877499147840307632, guid: 0a3b6392f04558844bd340e68ced1ff9,
2120+
type: 3}
2121+
propertyPath: m_IsActive
2122+
value: 0
2123+
objectReference: {fileID: 0}
21192124
- target: {fileID: 8307715182677704244, guid: 0a3b6392f04558844bd340e68ced1ff9,
21202125
type: 3}
21212126
propertyPath: m_AnchorMax.x

Assets/UXF/Scripts/DataHandling/WebAWSDynamoDB.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@ public override string HandleDataTable(UXFDataTable table, string experiment, st
130130
item[primaryKey] = primaryKeyValue;
131131
return item;
132132
})
133-
.Cast<object>()
134-
.ToList();
133+
.Cast<object>();
135134

136-
string req = MiniJSON.Json.Serialize(dataList);
137-
DDB_BatchWriteItem(tableName, req, gameObject.name);
135+
// split the request into batches of 25 because of limit in DynamoDB BatchWriteItem
136+
var batches = dataList.Batch(25);
137+
foreach (var batch in batches)
138+
{
139+
string req = MiniJSON.Json.Serialize(batch.ToList());
140+
DDB_BatchWriteItem(tableName, req, gameObject.name);
141+
}
138142
return string.Format("dynamodb:{0}:{1}", tableName, primaryKeyValue);
139143
}
140144
else

Assets/UXF/Scripts/Etc/Extensions.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,31 @@ public static string ToLower(this UXFDataType dataType)
101101
return dataType.ToString().ToLower();
102102
}
103103

104+
public static IEnumerable<IEnumerable<TSource>> Batch<TSource>(
105+
this IEnumerable<TSource> source, int size)
106+
{
107+
TSource[] bucket = null;
108+
var count = 0;
109+
110+
foreach (var item in source)
111+
{
112+
if (bucket == null)
113+
bucket = new TSource[size];
114+
115+
bucket[count++] = item;
116+
if (count != size)
117+
continue;
118+
119+
yield return bucket;
120+
121+
bucket = null;
122+
count = 0;
123+
}
124+
125+
if (bucket != null && count > 0)
126+
yield return bucket.Take(count).ToArray();
127+
}
128+
104129
}
105130

106131
[System.Serializable]

0 commit comments

Comments
 (0)