A .NET 6 application Upserts documents to CosmosDB.
I get many debug messages (not all writes)
DocDBTrace Error: 0 : DocumentClientException with status code 449, message: Message: {"Errors":["Conflicting request to resource has been attempted. Retry to avoid conflicts."]}
the ids of the documents are Guid instances and there are no unique keys in the container (so no conflicts).
What could it be?
EDIT
partitionKey = id
//F#
let write database container items =
let container = client.GetContainer(database, container)
items
|> Seq.map (fun item -> container.UpsertItemAsync(item))
|> Seq.toArray
|> Task.WhenAll
Data sample
{
"RESPONSE": [
{
"IntradayTickResponse": {
"CorrelationID": "ESM2 Index:intraday",
"TimeReceived": "2022-05-05T01:19:38.338794Z",
"tickData": {
"eidData": null,
"tickData": [
{
"time": {
"DayOfMonth": 5,
"Hour": 0,
"MicroSecond": 0,
"MilliSecond": 0,
"Minute": 37,
"Month": 5,
"NanoSecond": 0,
"Parts": 2046,
"PicoSecond": 0,
"Second": 7,
"TimezoneOffsetMinutes": 0,
"Year": 2022
},
"type": "TRADE",
"value": 4292.5,
"size": 2,
"conditionCodes": "TSUM"
},
{
"time": {
"DayOfMonth": 5,
"Hour": 0,
"MicroSecond": 0,
"MilliSecond": 0,
"Minute": 37,
"Month": 5,
"NanoSecond": 0,
"Parts": 2046,
"PicoSecond": 0,
"Second": 19,
"TimezoneOffsetMinutes": 0,
"Year": 2022
},
"type": "TRADE",
"value": 4292.75,
"size": 2,
"conditionCodes": "TSUM"
},
{
"time": {
"DayOfMonth": 5,
"Hour": 0,
"MicroSecond": 0,
"MilliSecond": 0,
"Minute": 37,
"Month": 5,
"NanoSecond": 0,
"Parts": 2046,
"PicoSecond": 0,
"Second": 19,
"TimezoneOffsetMinutes": 0,
"Year": 2022
},
"type": "TRADE",
"value": 4292.75,
"size": 1,
"conditionCodes": "TSUM"
},
{
"time": {
"DayOfMonth": 5,
"Hour": 0,
"MicroSecond": 0,
"MilliSecond": 0,
"Minute": 37,
"Month": 5,
"NanoSecond": 0,
"Parts": 2046,
"PicoSecond": 0,
"Second": 19,
"TimezoneOffsetMinutes": 0,
"Year": 2022
},
"type": "TRADE",
"value": 4292.75,
"size": 1,
"conditionCodes": "TSUM"
},
{
"time": {
"DayOfMonth": 5,
"Hour": 0,
"MicroSecond": 0,
"MilliSecond": 0,
"Minute": 37,
"Month": 5,
"NanoSecond": 0,
"Parts": 2046,
"PicoSecond": 0,
"Second": 19,
"TimezoneOffsetMinutes": 0,
"Year": 2022
},
"type": "TRADE",
"value": 4292.75,
"size": 1,
"conditionCodes": "TSUM"
},
...
"id": "87fdc18a-61f2-4c43-a7a8-2904b14e6596",
"_rid": "maszAOGSZkYwAgAAAAAAAA==",
"_self": "dbs/maszAA==/colls/maszAOGSZkY=/docs/maszAOGSZkYwAgAAAAAAAA==/",
"_etag": "\"00000000-0000-0000-601e-3057eca901d8\"",
"_attachments": "attachments/",
"_ts": 1651713578
}
Related
Could anyone helps me to add interactive highlight point on hover? I tried to add props from this example, but it did not work for me.
Here is my spec at Vega Lite Editor
The example is Vega-Lite but your spec is Vega. Try this - it gives a point and a tooltip for you.
{
"description": "Total Count line chart.",
"width": 1200,
"height": 450,
"padding": 5,
"signals": [{"name": "interpolate", "value": "linear"}],
"legends": [
{
"fill": "color",
"orient": "bottom",
"direction": "horizontal",
"symbolType": "square"
}
],
"data": [
{
"name": "table",
"values": [
{"x": 0, "y": 145, "c": "All"},
{"x": 1, "y": 153, "c": "All"},
{"x": 2, "y": 280, "c": "All"},
{"x": 3, "y": 150, "c": "All"},
{"x": 4, "y": 280, "c": "All"},
{"x": 5, "y": 140, "c": "All"},
{"x": 6, "y": 90, "c": "All"},
{"x": 0, "y": 30, "c": "Bulk carrier"},
{"x": 1, "y": 20, "c": "Bulk carrier"},
{"x": 2, "y": 90, "c": "Bulk carrier"},
{"x": 3, "y": 60, "c": "Bulk carrier"},
{"x": 4, "y": 50, "c": "Bulk carrier"},
{"x": 5, "y": 40, "c": "Bulk carrier"},
{"x": 6, "y": 10, "c": "Bulk carrier"},
{"x": 0, "y": 50, "c": "Tanker ship"},
{"x": 1, "y": 10, "c": "Tanker ship"},
{"x": 2, "y": 50, "c": "Tanker ship"},
{"x": 3, "y": 40, "c": "Tanker ship"},
{"x": 4, "y": 110, "c": "Tanker ship"},
{"x": 5, "y": 40, "c": "Tanker ship"},
{"x": 6, "y": 20, "c": "Tanker ship"},
{"x": 0, "y": 5, "c": "Dingy"},
{"x": 1, "y": 23, "c": "Dingy"},
{"x": 2, "y": 20, "c": "Dingy"},
{"x": 3, "y": 0, "c": "Dingy"},
{"x": 4, "y": 30, "c": "Dingy"},
{"x": 5, "y": 20, "c": "Dingy"},
{"x": 6, "y": 0, "c": "Dingy"},
{"x": 0, "y": 50, "c": "Carrier ship"},
{"x": 1, "y": 60, "c": "Carrier ship"},
{"x": 2, "y": 90, "c": "Carrier ship"},
{"x": 3, "y": 40, "c": "Carrier ship"},
{"x": 4, "y": 50, "c": "Carrier ship"},
{"x": 5, "y": 20, "c": "Carrier ship"},
{"x": 6, "y": 40, "c": "Carrier ship"},
{"x": 0, "y": 10, "c": "Other"},
{"x": 1, "y": 40, "c": "Other"},
{"x": 2, "y": 30, "c": "Other"},
{"x": 3, "y": 10, "c": "Other"},
{"x": 4, "y": 40, "c": "Other"},
{"x": 5, "y": 20, "c": "Other"},
{"x": 6, "y": 20, "c": "Other"}
]
}
],
"scales": [
{
"name": "x",
"type": "point",
"range": "width",
"domain": {"data": "table", "field": "x"}
},
{
"name": "y",
"type": "linear",
"range": "height",
"nice": true,
"zero": true,
"domain": {"data": "table", "field": "y"}
},
{
"name": "color",
"type": "ordinal",
"range": [
"#61c7f7",
"#BA20CE",
"#60cf85",
"#cd2c4f",
"#ceae39",
"#ffffff"
],
"domain": {"data": "table", "field": "c"}
}
],
"axes": [
{"orient": "bottom", "scale": "x"},
{"orient": "left", "scale": "y"}
],
"config": {
"style": {
"guide-label": {"fontSize": 14, "fill": "#cccccc", "fontWeight": 800}
},
"axis": {"grid": true, "gridColor": "#333333"}
},
"marks": [
{
"type": "group",
"from": {"facet": {"name": "series", "data": "table", "groupby": "c"}},
"marks": [
{
"type": "line",
"from": {"data": "series"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "x"},
"y": {"scale": "y", "field": "y"},
"stroke": {"scale": "color", "field": "c"},
"strokeWidth": {"value": 2}
},
"update": {
"interpolate": {"signal": "interpolate"},
"strokeOpacity": {"value": 1}
},
"hover": {"strokeOpacity": {"value": 0.5}}
}
},
{
"type": "symbol",
"from": {"data": "series"},
"encode": {
"update": {
"x": {"scale": "x", "field": "x"},
"y": {"scale": "y", "field": "y"},
"fillOpacity": {"value": 0}
},
"hover": {"fillOpacity": {"value": 1},
"tooltip": {
"signal": "{'c':datum.c }"
}
}
}
}
]
}
]
}
Suppose I have some json formatted something like this (I've removed the bits I'm not interested in, I can filter those out):
{
"name": "db1",
"size": 40000,
"items": 500,
"mutations": 2,
"tombstones": 4,
"views_count": 8,
"fts_count": 0,
"index_count": 0,
"analytics_count": 0
}
{
"name": "db2",
"size": 11,
"items": 900,
"mutations": 3,
"tombstones": 0,
"views_count": 0,
"fts_count": 0,
"index_count": 0,
"analytics_count": 0
}
{
"name": "db1",
"size": 10,
"items": 6,
"mutations": 5,
"tombstones": 0,
"views_count": 0,
"fts_count": 0,
"index_count": 1,
"analytics_count": 0
}
How can I get a summary of all the elements of the entry, but only for each name (here we can see db1 mentioned twice so I'd like something like this):
{
"name": "db1",
"size": 40010,
"items": 506,
"mutations": 8,
"tombstones": 4,
"views_count": 8,
"fts_count": 0,
"index_count": 1,
"analytics_count": 0
}
{
"name": "db2",
"size": 11,
"items": 900,
"mutations": 3,
"tombstones": 0,
"views_count": 0,
"fts_count": 0,
"index_count": 0,
"analytics_count": 0
}
This is a subset of the complete json which has around 18000 lines (but there's only 11 names).
--slurp the input to get an array and then use group_by to make groups (arrays) according to any criteria (.name in your case). If you want just one for each name, take one (e.g. the first) of each such group. Finally, apply [] to disassemble the surrounding array.
jq --slurp 'group_by(.name) | map(first)[]'
{
"name": "db1",
"size": 40000,
"items": 500,
"mutations": 2,
"tombstones": 4,
"views_count": 8,
"fts_count": 0,
"index_count": 0,
"analytics_count": 0
}
{
"name": "db2",
"size": 11,
"items": 900,
"mutations": 3,
"tombstones": 0,
"views_count": 0,
"fts_count": 0,
"index_count": 0,
"analytics_count": 0
}
Demo
Note: With a little bit of more effort, you could also --stream (and then reduce) the input (instead of using --slurp) but 18000 lines isn't that big for memories nowadays, so I thought this would be the more reasonable approach.
Good time of day!
all text - https://github.com/vega/vega-lite/issues/5697
When building data in a block, I would like to change the font size and position of the text in the block. Used the documentation -https://vega.github.io/vega-lite/docs/title.html, but it does not work.
block:
{
"mark": "text"
"encoding": {
"text": {"field": "z", "type": "quantitative"}
"color": {"value": "black"}
"fontSize": 40
}
Changing the position will allow for the addition of a second text:
full code:
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.4.3.json",
"config": {"view": {"height": 300, "width": 400}},
"data": {
"values": [
{"x": 0, "y": 0, "z": 0},
{"x": 1, "y": 0, "z": 1},
{"x": 2, "y": 0, "z": 4},
#{"x": 3, "y": 0, "z": 9},
{"x": 4, "y": 0, "z": 16},
#{"x": 5, "y": 0, "z": 25},
{"x": 0, "y": 1, "z": 1},
{"x": 1, "y": 1, "z": 2},
{"x": 2, "y": 1, "z": 5},
{"x": 3, "y": 1, "z": 10},
#{"x": 4, "y": 1, "z": 17},
{"x": 5, "y": 1, "z": 26}]
},
"encoding": {
"x": {"field": "x", "type": "ordinal", title: "X"}
"y": {"field": "y", "type": "ordinal", title: "Y"}
}
"layer": [
{
"mark": "rect"
from: {data: "values"}
"encoding": {
"color": {
"field": "z"
"scale": {"scheme": "redyellowgreen"}
"type": "quantitative"
}
}
}
{
"mark": "text"
"encoding": {
"text": {"field": "z", "type": "quantitative"}
"color": {"value": "black"}
"fontSize": 40
}
}
]
}
2 I'd like a temperature map without spaces. It is possible if create a variable to count all x by "groupby":[y]
Help me please.
There is no fontSize encoding, but you can set a fontSize mark property:
{
"mark": {"type": "text", "fontSize": 40},
"encoding": {
"text": {"field": "z", "type": "quantitative"},
"color": {"value": "black"}
}
}
To offset text vertically, you can use the dy mark property, which specifies a number of pixels by which to vertically offset the text:
{
"mark": {"type": "text", "fontSize": 20, "dy": -20},
"encoding": {
"text": {"value": "text"},
"color": {"value": "black"}
}
}
As for computing new x values to fill-in spaces, you can do this with a Window Transform.
Here is a modified version of your example that puts all of this together (view in vega editor):
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.4.3.json",
"config": {"view": {"height": 300, "width": 400}},
"data": {
"values": [
{"x": 0, "y": 0, "z": 0},
{"x": 1, "y": 0, "z": 1},
{"x": 2, "y": 0, "z": 4},
{"x": 4, "y": 0, "z": 16},
{"x": 0, "y": 1, "z": 1},
{"x": 1, "y": 1, "z": 2},
{"x": 2, "y": 1, "z": 5},
{"x": 3, "y": 1, "z": 10},
{"x": 5, "y": 1, "z": 26}
]
},
"transform": [
{"window": [{"op": "count", "field": "x", "as": "x2"}], "groupby": ["y"]}
],
"encoding": {
"x": {"field": "x2", "type": "ordinal", "title": "X"},
"y": {"field": "y", "type": "ordinal", "title": "Y"}
},
"layer": [
{
"mark": "rect",
"encoding": {
"color": {
"field": "z",
"scale": {"scheme": "redyellowgreen"},
"type": "quantitative"
}
}
},
{
"mark": {"type": "text", "fontSize": 20, "dy": -20},
"encoding": {
"text": {"value": "text"},
"color": {"value": "black"}
}
},
{
"mark": {"type": "text", "fontSize": 40, "dy": 20},
"encoding": {
"text": {"field": "z", "type": "quantitative"},
"color": {"value": "black"}
}
}
]
}
I am using AmChartXY to draw graph areas, here is the fiddle:
https://jsfiddle.net/ap60fhsu/1/
var chart = AmCharts.makeChart("chartdiv", {
"type": "xy",
"autoMarginOffset": 20,
"dataProvider": [{
"ax": 0,
"ay": 0,
"bx": 0,
"by": 0,
}, {
"ax": 8,
"ay": 1,
"bx": 12,
"by": -2,
},
{
"ax": 32,
"ay": 9,
"bx": 35,
"by": -1,
},
{
"ax": 45,
"ay": 6,
"bx": 45,
"by": -2,
},
{
"ax": 60,
"ay": 2,
"bx": 60,
"by": -2,
},
{
"ax": 70,
"ay": 0,
"bx": 70,
"by": 0,
},
{
"ax": 75,
"ay": 0,
"bx": 72,
"by": 0,
},
{
"ax": 85,
"ay": 6,
"bx": 80,
"by": -1,
},
{
"ax": 90,
"ay": 0,
"bx": 90,
"by": 0,
}],
"valueAxes": [ {
"position": "bottom",
"axisAlpha": 0,
"dashLength": 1,
"id": "x",
"title": "X Axis"
}, {
"axisAlpha": 0,
"dashLength": 1,
"position": "left",
"id": "y",
"title": "Y Axis"
}],
"plotAreaBorderAlpha": 1,
"startDuration": 1,
"graphs": [ {
"balloonText": "x:[[x]] y:[[y]]",
"fillAlphas": 0.3,
"fillToAxis": "x",
"lineAlpha": 1,
"xField": "ax",
"yField": "ay",
"lineColor": "#FF6600"
}, {
"balloonText": "x:[[x]] y:[[y]]",
"lineAlpha": 1,
"fillToAxis": "x",
"fillAlphas": 0.3,
"xField": "bx",
"yField": "by",
"lineColor": "#FCD202"
}],
"marginLeft": 64,
"marginBottom": 60,
"chartScrollbar": {},
"chartCursor": {},
"export": {
"enabled": true,
"position": "bottom-right"
}
});
As you see I have negative values for Y axis, this makes the X axis fall down from Y=0 to Y=-4 and when I use fillToAxis: x, expecting that the graph fill areas will be areas bounded with graphs and X axis corresponding to the value Y=0, I get another result. How can I move the X axis to the Y=0, or at least get the fill area result as I expect?
Thanks in advance
I have a string like this.
{
"type": "item",
"version": "3.10.3",
"basic": {
"name": "",
"rune": {
"isrune": false,
"tier": 1,
"type": "red"
},
"gold": {
"base": 0,
"total": 0,
"sell": 0,
"purchasable": false
},
"group": "",
"description": "",
"colloq": ";",
"plaintext": "",
"consumeable": false,
"stacks": 1,
"depth": 1,
"consumed": false,
"consumeOnFull": false,
"from": [],
"into": [],
"specialRecipe": 0,
"inStore": true,
"hideFromAll": false,
"requiredChampion": "",
"stats": {
"FlatHPPoolMod": 0,
"rFlatHPModPerLevel": 0,
"FlatMPPoolMod": 0,
"rFlatMPModPerLevel": 0,
"PercentHPPoolMod": 0,
"PercentMPPoolMod": 0,
"FlatHPRegenMod": 0,
"rFlatHPRegenModPerLevel": 0,
"PercentHPRegenMod": 0,
"FlatMPRegenMod": 0,
"rFlatMPRegenModPerLevel": 0,
"PercentMPRegenMod": 0,
"FlatArmorMod": 0,
"rFlatArmorModPerLevel": 0,
"PercentArmorMod": 0,
"rFlatArmorPenetrationMod": 0,
"rFlatArmorPenetrationModPerLevel": 0,
"rPercentArmorPenetrationMod": 0,
"rPercentArmorPenetrationModPerLevel": 0,
"FlatPhysicalDamageMod": 0,
"rFlatPhysicalDamageModPerLevel": 0,
"PercentPhysicalDamageMod": 0,
"FlatMagicDamageMod": 0,
"rFlatMagicDamageModPerLevel": 0,
"PercentMagicDamageMod": 0,
"FlatMovementSpeedMod": 0,
"rFlatMovementSpeedModPerLevel": 0,
"PercentMovementSpeedMod": 0,
"rPercentMovementSpeedModPerLevel": 0,
"FlatAttackSpeedMod": 0,
"PercentAttackSpeedMod": 0,
"rPercentAttackSpeedModPerLevel": 0,
"rFlatDodgeMod": 0,
"rFlatDodgeModPerLevel": 0,
"PercentDodgeMod": 0,
"FlatCritChanceMod": 0,
"rFlatCritChanceModPerLevel": 0,
"PercentCritChanceMod": 0,
"FlatCritDamageMod": 0,
"rFlatCritDamageModPerLevel": 0,
"PercentCritDamageMod": 0,
"FlatBlockMod": 0,
"PercentBlockMod": 0,
"FlatSpellBlockMod": 0,
"rFlatSpellBlockModPerLevel": 0,
"PercentSpellBlockMod": 0,
"FlatEXPBonus": 0,
"PercentEXPBonus": 0,
"rPercentCooldownMod": 0,
"rPercentCooldownModPerLevel": 0,
"rFlatTimeDeadMod": 0,
"rFlatTimeDeadModPerLevel": 0,
"rPercentTimeDeadMod": 0,
"rPercentTimeDeadModPerLevel": 0,
"rFlatGoldPer10Mod": 0,
"rFlatMagicPenetrationMod": 0,
"rFlatMagicPenetrationModPerLevel": 0,
"rPercentMagicPenetrationMod": 0,
"rPercentMagicPenetrationModPerLevel": 0
},
"tags": [],
"maps": {
"1": true,
"8": true,
"10": true,
"12": true
}
},
"data": {
"1001": {
"name": "Boots of Speed",
"group": "BootsNormal",
"description": "<groupLimit>Limited to 1.</groupLimit><br><br><unique>UNIQUE Passive - Enhanced Movement:</unique> +25 Movement Speed<br><br><i>(Unique Passives with the same name don't stack.)</i>",
"colloq": ";",
"plaintext": "Slightly increases Movement Speed",
"into": [
"3006",
"3047",
"3020",
"3158",
"3111",
"3117",
"3009"
],
"image": {
"full": "1001.png",
"sprite": "item0.png",
"group": "item",
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"gold": {
"base": 325,
"purchasable": true,
"total": 325,
"sell": 227
},
"tags": [
"MOVEMENT",
"BOOTS"
],
"stats": {
"FlatMovementSpeedMod": 25
}
},
"1004": {
"name": "Faerie Charm",
"description": "<stats>+3 Mana Regen per 5 seconds</stats>",
"colloq": ";",
"plaintext": "Slightly increases Mana Regen",
"into": [
"3037",
"3096",
"3028",
"3070",
"3073",
"1080",
"3165"
],
"image": {
"full": "1004.png",
"sprite": "item0.png",
"group": "item",
"x": 48,
"y": 0,
"w": 48,
"h": 48
},
"gold": {
"base": 180,
"purchasable": true,
"total": 180,
"sell": 126
},
"tags": [
"MANAREGEN"
],
"stats": {
"FlatMPRegenMod": 0.6
}
},
"1006": {
its going like this I'm trying to get 1006 from "1006: { but i cant
$iveri = $iresponse->body;
foreach($iveri->data as $esya)
{
print($esya);
}
Because it's object, but i want it's name but i cant find a way to get that can you help me, I'm building database from that like getting values insade it and they will their id's they are id's of items so they cant be auto assing they had to be like in array.
1006 in your example is a key value, you need to slightly modify your loop syntax:
foreach($ivery->data as $key=>$esya) {
print $key; // This will be '1006'
print $esya;
}