hierarchical

Parent - Child sql query

好久不见. 提交于 2019-12-11 03:05:55
问题 id parent_id 1 0 2 0 3 2 4 0 5 1 6 0 I need a query that will return parent rows (parent_id=0) followed by its child rows: first parent all children of first parent second parent all children of second parent third parent fourth parent Expected result: ordered by id id parent_id ------------------------------------------- 1 0 (first parent) 5 1 (all children of first parent) 2 0 second parent 3 2 (all children of second parent) 4 0 third parent 6 0 fourth parent I can use union of parents

What strategy to use in Java for hierarchical reentrant read/write locking?

痴心易碎 提交于 2019-12-08 17:24:31
问题 I'm looking for en efficient system to have a series of read/write locks organized hierarchically to manage access to hierarchically organized resources. If a subtree is locked for write, then no other lock should be able to be obtained in the whole subtree until it is released; similarly, a write lock in a subtree should prevent locking in a parent. Here are the ideas I was contemplating: Use the Apache Commons Transaction . Unforunately, the project hasn't been updated since March 2008 and

Pandas pivot table to Bar Chart Preserving Hierarchy

。_饼干妹妹 提交于 2019-12-08 13:11:45
问题 Given the following pivot table: df=pd.DataFrame({'A':['a','a','a','a','a','b','b','b','b'], 'B':['x','y','z','x','y','z','x','y','z'], 'C':['a','b','a','b','a','b','a','b','a'], 'D':[7,5,3,4,1,6,5,3,1]}) table = pd.pivot_table(df, index=['A', 'B','C'],aggfunc='sum') table D A B C a x a 7 b 4 y a 1 b 5 z a 3 b x a 5 y b 3 z a 1 b 6 I'd like to create a horizontal bar chart which preserves the hierarchical layout of the indices. Currently, if I do this: %matplotlib inline a=table.plot(kind=

Trying to create and loop through matrix of unbalanced data in R

早过忘川 提交于 2019-12-08 13:06:02
问题 I am trying to conduct an hierarchical bayesian analysis but am having a little trouble with R and WinBUGS code. I don't have balanced data and am struggling with the coding. I have temperature data collected daily with iButtons (temperature recording devices) in transects and am trying to generate a model that relates this to remote sensing data. Unfortunately, each transect has a different number of iButtons so creating a 3D matrix of button(i), in transect(j), repeatedly "sampled" on day(t

Scrapy: how to populate hierarchic items with multipel requests

江枫思渺然 提交于 2019-12-08 12:23:27
问题 This one is extension of Multiple nested request with scrapy . Asking because presented solution have flaws: 1. It iliminates asynchrony, thus heavily reducing scraping efficiency 2. Should exception appeare while processing links "stack" and no item will be yelded 3. What if there is a huge amount of child items? To deal with (1) I considered this: class CatLoader(ItemLoader): def __int__(self, item=None, selector=None, response=None, parent=None, **context): super(self.__class__, self)._

Oracle SQL Hierarchical Query: Flatten Hierarchy and Perform Aggregation

為{幸葍}努か 提交于 2019-12-08 05:26:21
问题 I am trying to improve performance for a proof of concept I have already written and am having no luck. I think the approach is probably flawed, but I’m struggling to find another solution. I’ve covered all the Ask Tom articles and forum posts I can find. We’re running Oracle 10g R2. We have items arranged in a hierarchical structure. Quantities are defined on the relationships. There are two types of objects in the hierarchy: assemblies that are logical groupings, and items that represent an

What is the best way to group and aggregate and sum tree data?

二次信任 提交于 2019-12-08 01:03:47
问题 Given a self referencing table Item ------------- Id (pk) ParentId (fk) With a related table of associated values ItemValue ------------- ItemId (fk) Amount And some sample data Item ItemValues Id ParentId ItemId Amount -------------------- ---------------------- 1 null 1 10 2 1 3 40 3 1 3 20 4 2 4 10 5 2 5 30 6 null 7 6 8 7 I need a sproc to take Item.Id and return the direct children with sums of all ItemValue.Amounts for the them, their children and their children all the way down the tree

hierarchical cluster labeling with plots

妖精的绣舞 提交于 2019-12-08 00:04:12
问题 I have a distance matrix for ~20 elements, which I am using to do hierarchical clustering in R. Is there a way to label elements with a plot or a picture instead of just numbers, characters, etc? So, instead of the leaf nodes having numbers, it'd have small plots or pictures. Here is why I'm interested in this functionality. I have 2-D scatterplots like these (color indicates density) http://www.pnas.org/content/108/51/20455/F2.large.jpg (Note that this is not my own data) I have to analyze

Reading from file a hierarchical ascii table using Pandas

女生的网名这么多〃 提交于 2019-12-07 16:31:28
问题 My very-first post here, I hope it's not too long or detailed. I have an issue when I try to read and interpret the following ascii table (simple extract from a much bigger one). Let's say the file is called "test.txt": A B C D E 0 992 CEN/4 -2.657293E+00 -3.309567E+01 4.697218E-01 1291 -3.368449E+00 7.837483E+00 2.311393E+00 800 -3.530800E+00 -7.392188E+01 -1.401380E+00 801 -1.952177E+00 -7.392114E+01 -1.367195E+00 1290 -1.777301E+00 7.838229E+00 2.345850E+00 0 994 CEN/4 7.270955E+00 -6

Order of bean destruction in Spring context hierarchy

亡梦爱人 提交于 2019-12-07 15:44:40
问题 Is it correct to say that when a Spring context hierarchy is closed, there is no guaranteed order in which the beans will be destroyed? E.g. the beans in the child context will be destroyed before the parent context. From a minimal example the destruction of the contexts seems to be totally uncoordinated between the contexts (oddly enough). Both contexts registers a shutdown hook which later will be executed in different threads. @RunWith(SpringJUnit4ClassRunner.class) @ContextHierarchy({