NOTE: This is my first stack question so i beg your pardon if i did something wrong here!
I am working on an e-commerce application, and i am using hive to function as cart storage if there is no account to store the items locally until account is added. I have worked wih hive multiple times and i looked in my previous problems to check if i'm wrong anywhere but in vain.
OfflineCartItem is an adapter, it is registered, hive is initialized and box named 'cart' is opened beforehand, no errors related that.
Adding an item
Hive.box<OfflineCartItem>('cart').add(
OfflineCartItem(...));
Listing the data
ValueListenableBuilder(
valueListenable:
Hive.box<OfflineCartItem>('cart').listenable(),
builder: (context, data, snapshot) {
print("length of box: ${data.length}");
log("keys: ${data.keys}");
log("Map: ${data.toMap()}");
List<CartItem> list = [];
data.toMap().forEach((key, value) {
list.add(CartItem(...));
});
log("keys: ${data.keys}");
log("Map: ${data.toMap()}");
return Column(
mainAxisSize: MainAxisSize.min,
children: list,
);
});
I checked the hive functionality in other projects of mine, upgraded hive related packages to the lastest version, and they are working fine.
Here's the output i am getting when listing the data using the code above
I/flutter (26340): length of box: 4
[log] keys: (22, 23, 24, 25)
[log] Map: {22: Instance of 'OfflineCartItem', 23: Instance of 'OfflineCartItem', 24: Instance of 'OfflineCartItem', 25: Instance of 'OfflineCartItem'}
[log] keys: ()
[log] Map: {}
I/flutter (26340): length of box: 0
[log] keys: ()
[log] Map: {}
[log] keys: ()
[log] Map: {}
I checked and the adding code is being executed!
Here the length of the box is 4, i used box.toMap() to print the contents, but after reading all the data using data.keys and data.toMap(), the values are gone and i am left with an empty page.
Removed the data.keys and toMap() so the forEach method would access the data first, the list now had the data. Got this response
I/flutter (26340): length of box: 3
I/flutter (26340): [CartItem, CartItem, CartItem]
[log] keys: ()
[log] Map: {}
I/flutter (26340): length of box: 0
I/flutter (26340): []
[log] keys: ()
[log] Map: {}
The valueListenable again removes all the data since the values in the box changed and i am again left with an empty list.
I am using a real device, Redmi 6 pro, MIUI 12.
Related
I have the following function which gives me an array called URLs
const storageRef = this.$fire.storage.ref().child(fileName)
try {
const snapshot = storageRef.put(element).then((snapshot) => {
snapshot.ref.getDownloadURL().then((url) => {
urls.push(url)
})
})
console.log('File uploaded.')
} catch (e) {
console.log(e.message)
}
});
console.log(urls)
console.log("about to run enter time with imageurls length " + urls.length)
When I run console.log(URLs) initially I do see the array like the following
[]
0: "testvalue"
length: 1
__proto__: Array(0)
However, there is a small information icon stating
This value was evaluated upon first expanding. The value may have changed since.
Because of this, when I try to get the length of URLs, I get zero, meaning the value is being updated.
Does anyone know what's happening? I am using Vue.JS/Nuxt.
I'm using Apache Ignite v.2.8.1 .Net on a Windows 10 machine.
I am trying to use affinity collocation on a query-enabled cache. The entities I store in cache have a primary key named "Id" and an affinity key named "PartnerId". Both keys are of the type Int32. I'm defining the cache as follows:
new CacheConfiguration("BespokeCharge")
{
KeyConfiguration = new[]
{
new CacheKeyConfiguration()
{
AffinityKeyFieldName = "PartnerId",
TypeName = typeof(BespokeCharge).Name
}
}
};
Next I use the following code to add the data:
var cache = Ignite.GetCache<AffinityKey, BespokeCharge>("BespokeCharge")
cache.Put(new AffinityKey(entity.Id, entity.PartnerId), entity)
So far so good. Since I want to be able to use SQL to search for bespoke charges, I also add a QueryEntity configuration:
new CacheConfiguration("BespokeCharge",
new QueryEntity(typeof(AffinityKey), typeof(BespokeCharge))
{
KeyFieldName = "Id",
TableName = "BespokeCharge"
})
{
KeyConfiguration = new[]
{
new CacheKeyConfiguration()
{
AffinityKeyFieldName = "PartnerId",
TypeName = typeof(BespokeCharge).Name
}
}
};
When I run the code, both Ignite and my app crash and the following error is logged:
JVM will be halted immediately due to the failure: [failureCtx=FailureContext [type=CRITICAL_ERROR, err=class o.a.i.i.processors.cache.persistence.tree.CorruptedTreeException: B+Tree is corrupted [pages(groupId, pageId)=[IgniteBiTuple [val1=1565129718, val2=844420635164729]], cacheId=-1278247946, cacheName=BESPOKECHARGES, indexName=BESPOKECHARGES_ID_ASC_IDX, msg=Runtime failure on row: Row#29db2fbe[ key: AffinityKey [idHash=8137191, hash=783909474, key=3, affKey=2], val: UtilityClick.BillValidation.Shared.InMemory.Model.BespokeCharge [idHash=889383506, hash=-399638125, BespokeChargeTypeId=4, ChargeValue=100.0000, ChargeValueIncCommission=100.0000, Id=3, PartnerId=2, QuoteRecordId=5] ][ 4, 100.0000, 100.0000, , 2, 5 ]]]]
When I tried to define QueryEntity with the key type of int instead of AffinityKey, I got a different error with the same outcome -- a crash.
JVM will be halted immediately due to the failure: [failureCtx=FailureContext [type=CRITICAL_ERROR, err=java.lang.ClassCastException: class o.a.i.cache.affinity.AffinityKey cannot be cast to class java.lang.Integer (o.a.i.cache.affinity.AffinityKey is in unnamed module of loader 'app'; java.lang.Integer is in module java.base of loader 'bootstrap')]]
What am I doing wrong? Thank you for your help!
KeyFieldName = "Id" setting is the problem. It sets Id field to be used as a cache key, which is int, but then we use AffinityKey as a cache key, which causes a type mismatch.
In this case I don't think we need KeyFieldName at all, removing it fixes the problem, and SELECT queries should not be affected by this change.
CreateJS (2015.11.26) via Animate CC (16.0.0.112)
Structure :
root
- myContainer
- frame 0 -> btn_0
- frame 1 -> btn_1
First frame of root contains following code :
var self = this;
createjs.Ticker.addEventListener("tick", initScreen);
function initScreen() {
createjs.Ticker.removeEventListener("tick", initScreen);
self.myContainer.gotoAndStop(1);
}
this.myContainer.addEventListener("click", function(e) {
console.log("Button 0 : "+self.myContainer.btn_0);
console.log("Button 1 : "+self.myContainer.btn_1);
});
The result is :
[Log] Button 0 : [MovieClip]
[Log] Button 1 : undefined
And when iterating through self.myContainer.children, only btn_0 exists.
So self.myContainer.children is not being updated when playing through the frames.
Seems like a bug, as I can't find any documentation around this... but I'm surprised that I can't find anyone else who's had this issue.
Any help much appreciated.
(Issue raised here : https://github.com/CreateJS/EaselJS/issues/848)
I believe this is because both buttons use the same symbol.
In AnimateCC, choose btn_1 and change its "instance of", by swapping-duplicating to a new symbol.
This logged for me:
Button 0 : [MovieClip (name=null)]
Button 1 : [MovieClip (name=null)]
the code:
this.sendOperations = function () {
var operation = {
deviceId: '12161',
com_cumulocity_model_WebCamDevice: {
name: 'take picture',
parameters: {
duration: '5s',
quality: 'HD'
}
}
};
c8yDeviceControl.create(operation);
Result:
a new operation will be created in cumulocity server, but in the meantime, the chrome brower on which the app is runing will report some errors, although it looks like the app is still runing after that:
angular.js:9997 TypeError: Cannot read property 'match' of null
at k (deviceControl.js:267)
at wrappedCallback (angular.js:11498)
at wrappedCallback (angular.js:11498)
at angular.js:11584
at Scope.$eval (angular.js:12608)
at Scope.$digest (angular.js:12420)
at Scope.$apply (angular.js:12712)
at done (angular.js:8315)
at completeRequest (angular.js:8527)
at XMLHttpRequest.xhr.onreadystatechange (angular.js:8466)
any suggestion? Thanks
D. Chen
I am using the below code and expecting to retrieve all the messages belonging to the same thread. However, it always returns only the selected message details. The message is already an hour old so indexing should be done. Also i tried this on multiple threads but same result. Please advise whats wrong here
this.query =
Gloda.getMessageCollectionForHeaders([msgHdr], {
onItemsAdded: function (aItems) {},
onItemsModified: function () {},
onItemsRemoved: function () {},
onQueryCompleted: function (aCollection) {
add("\t\t\t/---------------------------\\\n");
add("\t\t\t| vik Gloda results |\n");
add("\t\t\t\\---------------------------/\n\n");
add("Gloda found "+aCollection.items.length+" items\n");
// Iterator over the messages Gloda found...
for each (let [i, glodaMsg] in Iterator(aCollection.items)) {
add("This message is from: "+glodaMsg.from+"\n");
add("This message is to: "+glodaMsg.to+"\n");
add("This message is from lists: "+glodaMsg.mailingLists+"\n");
}
},
}, true)
;
See the last paragraph of https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Creating_a_Gloda_message_query?redirectlocale=en-US&redirectslug=Thunderbird%2FCreating_a_Gloda_message_query ; in your case, you need to launch a second query by doing glodaMsg.conversation.getMessageCollection. https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Gloda_examples?redirectlocale=en-US&redirectslug=Thunderbird%2FGloda_examples has a bigger example.