I'd like to build a Flow such as represented in the following asciiFlow :
Custom Flow
+-------------------------------------------------------------+
| |
| +------------------+ |
| | | |
| | +---------------------------------------------->
| | | |
+---------> CustomFanOut2 | +--------------------+ |
| | | | | |
| | +-------> CustomSink | |
| +------------------+ | | |
| +--------------------+ |
| |
+-------------------------------------------------------------+
Of course, I can use GraphDSL, but it boils down to just putting a sink on one of the outlets for CustomFanOut2, so it seems that there could be a method
Graph[FanOutShape2[I, O0, O1], Mat1].to1(sink: Sink[O1, Any]: Flow[I, O0, Mat1]
or equivalents on other inlets and outlets, for other graphs than Source, Flow, Sink and Bidi.
Does such a method exist, or could it exist in some future version of akka-stream? In the case where it would not be possible, why is it so?
Related
I want to group a data in such a way that for particular record each array values also used to group for that record
I am able to group by name only. I am not able to figure out the way to this.
I have tried following query;
import pyspark.sql.functions as f
df.groupBy('name').agg(f.collect_list('data').alias('data_new')).show()
Following is the dataframe;
|-------|--------------------|
| name | data |
|-------|--------------------|
| a | [a,b,c,d,e,f,g,h,i]|
| b | [b,c,d,e,j,k] |
| c | [c,f,l,m] |
| d | [k,b,d] |
| n | [n,o,p,q] |
| p | [p,r,s,t] |
| u | [u,v,w,x] |
| b | [b,f,e,g] |
| c | [c,b,g,h] |
| a | [a,l,f,m] |
|----------------------------|
I am expecting following output;
|-------|----------------------------|
| name | data |
|-------|----------------------------|
| a | [a,b,c,d,e,f,g,h,i,j,k,l,m]|
| n | [n,o,p,q,r,s,t] |
| u | [u,v,w,x] |
|-------|----------------------------|
To come to my point, i need to explain the context:
I got a daemon process that opens a posix mq for communication. Clients are in the same group like that daemon to communicate with it. The clients also opens posix mq's and subscribe to the daemon. To be able to communicate, the client mq's must have the same group that the daemon can answer to them.
So far so good, i set the client set gid (chmod g+s client). On a Qt based Desktop (LXQT), the client starts and works as expected. On gtk+ based Desktop (Name LXDE on raspberry pi), it fails to start as gtk+ prevents a set uid/gid programs to use it's library.
As a result i extracted the creation of the mq_open() to a external executable that is set gid (chmod g+s) and uses setegid() to the saved set gid.
The client creates a socketpair(), fork(), execve() and sends the fd through the socketpair (AF_UNIX/SOCK_STREAM) to the client.
The requirements i need to fullfill:
mq's must be readable from all members of the mqclients group
Rights must be 0660 on the mq's
avoid set gid(chmod g+s) on the client
Keep the possible security impact of chmod g+sas small as possible.
Now my point/questions:
I would like to avoid to handle SIGCHLD and kill(), wait() for the mq-opener in the client and daemon. I would just like to readmsg() on the socketpair() and get an error if the mq-opener dies for whatever reason. Just write no signal handler for SIGCHLD?
The fork() procedure and connection with the mq-opener is pretty big. Is there a more simple way to do this?
Can the mq-opener (which starts as a unprivileged user) do the double fork() and drop its parent/child connection to the parent? At what point drops the parent/child relationship?
Would it be better to create a mq-opener daemon that just handle the creation of the mq`s?
To make it a little more clear: Here a diagram:
+-----------+ +------------+
|Daemon | |Client |
+-----------+ +------------+
|File | |File |
|User | |User |
|mqdaemon | |pi |
| | | |
|Group | |Group |
|mqdaemon | |pi |
| | | |
|Rights | +------------+ |Rights |
|a-s | |mq-opener | |a-s |
+-----------+ +------------+ +------------+
|Process | |File | |Process |
|User | |User | |User |
|mqdaemon | |mq-opener | |pi |
| | | | | |
|Group | |Group | |Group |
|mqclients | |mqclients | |pi |
+----+------+ | | +--+---------+
^ | |Rights | | ^
| | |g+s | | |
| | | | | |
| | +------------+ | |
| | fork() |Process | fork() | |
| +------------>|User |<---------+ |
| |(forked) | |
| send_fd() | | send_fd() |
+---------------+|Group |+------------+
|mqclients |
+------------+
I currently coding a fitness app that permits to record all the personal records for a user.
I'm really new with Cloud Firestore from Firebase, so I really don't know how I could structure the database.
In my mind, I have two options:
OPTION 1
Users
|
+--UserID
| |
| +--Name
| +--Phone
| +--etc..
|
|
Users-records
|
+--UserID
| |
| +--RecordName
| | |
| | +--recordValue
| | +--recordType
| |
| +--RecordName
| | +--recordValue
| | +--recordType
OPTION 2
Users
|
+--UserID
| |
| +--Name
| +--Phone
| +--etc..
| +--Records
| | |
| | +--RecordName
| | | |
| | | +--recordValue
| | | +--recordType
| | +--RecordName
| | | |
| | | +--recordValue
| | | +--recordType
The questions are: Do I have to split the collection for the user?
Do you think this architecture is well designed for the purpose (ie record personal records from users)?
Thank you very much
Your database structure really depends on how you are going to use it. Keep in mind that whenever you observe a node, you are also observing all of the children nodes.
So I'd probably go with something closer to Option two, maybe like this:
Users
|
+--UserID
| |
| +--UserInfo
| | |
| | +--Name
| | +--Phone
| | +--etc..
| |
| +--Records
| | |
| | +--RecordName
| | | |
| | | +--recordValue
| | | +--recordType
| | +--RecordName
| | | |
| | | +--recordValue
| | | +--recordType
I'd choose this, because I'd image you'd want to get all of the UserInfo at once, So we can observe that "UserInfo" node and get all of the children: name, phone, etc....
Then I'd think you'd also want to get all of the records at once, so we can observe that "Records" node and get all of that data.
Additionally, if you wanted, you could get everything at once by observing the UserID!
However, if you were maybe going to be getting a list of all the users, then you definitely don't want all this data in one spot and this design wouldn't work, because that is a lot of data to observe just to get all the users.
In summary: Choose an option which makes it easiest for you to get what you need, without getting extra data you don't want!
I am looking into the feasibility of converting a simple open source Android chart tool to Flutter. Looking at a few Android charting tools, I find they may use the following Android imports.
Next, I am trying to identify Flutter classes that would, very roughly and loosely, correspond to the Android classes. Mostly looking by names, I find this rough mapping.
Would someone be able to point me to Flutter classes on lines with questionmarks? (Comments on the filled up lines are also great)
| Android | Flutter | Comment | Android API | Flutter API |
|-------------------------------------+-----------------+---------+---------------------------------------------------------------------------------+------------------------------------------------------------|
| android.content.Context; | ? | | https://developer.android.com/reference/android/content/Context.html | ? |
| android.util.AttributeSet; | ? | | https://developer.android.com/reference/android/util/AttributeSet.html | ? |
| android.graphics.Color; | dart:ui.Color | | https://developer.android.com/reference/android/graphics/Color.html | https://docs.flutter.io/flutter/dart-ui/Color-class.html |
| android.graphics.Canvas; | dart:ui.Canvas | | https://developer.android.com/reference/android/graphics/Canvas.html | https://docs.flutter.io/flutter/dart-ui/Canvas-class.html |
| android.graphics.Rect; | dart:ui.Rect | | https://developer.android.com/reference/android/graphics/Rect.html | https://docs.flutter.io/flutter/dart-ui/Rect-class.html |
| android.graphics.Point; | dart:math.Point | | https://developer.android.com/reference/android/graphics/Point.html | https://docs.flutter.io/flutter/dart-math/Point-class.html |
| android.graphics.Paint; | dart:ui.Paint | | https://developer.android.com/reference/android/graphics/Paint.html | https://docs.flutter.io/flutter/dart-ui/Paint-class.html |
| android.graphics.Region; | ? | | https://developer.android.com/reference/android/graphics/Region.html | ? |
| android.graphics.drawable.Drawable; | ? Picture ? | | https://developer.android.com/reference/android/graphics/drawable/Drawable.html | ? |
| android.view.View; | ? Viewport ? | | https://developer.android.com/reference/android/view/View.html | ? |
During the Android->Flutter code conversion of a graphics application, I ended up using the following mapping of classes. Except of AttributeSet that I ended up not needing, each has more or less corresponding class.
| Android | Flutter | Comment |
|---------------------------------------+------------------------------------------+-----------------------------------------------------------------|
| android.content.Context; | package:flutter:widgets.BuildContext | somewhat equivalent |
| android.util.AttributeSet; | ? | |
| android.graphics.Color; | dart:ui.Color | import 'dart:ui' as ui; // in code: ui.Color |
| android.graphics.Canvas; | dart:ui.Canvas | |
| android.graphics.Rect; | dart:ui.Rect | For operations such as "contains(Offset)" etc |
| android.graphics.Point; | dart:ui.Offset (*not* dart:math.Point) | Offset in context of graphics |
| android.graphics.Paint; | dart:ui.Paint | |
| android.graphics.Region; | dart:ui.Rect | |
| android.graphics.drawable.Drawable; | used CustomPaint - see line below | |
| android.view.View; impl Drawable | package:flutter/widgets.dart.CustomPaint | import 'package:flutter/widgets.dart' as widgets; |
| - (continuation line) | - combined with CustomPainter | - in code: widgets.CustomPaint, widgets.CustomPainter |
| android.graphics.Path | dart:ui.Path | |
| android.graphics.PathEffect | Needed for dash-lines. | there is no dash-lines effect in Dart, intentional, performance |
| android.Text (when drawing on Canvas) | package:flutter/painting.dart.TextSpan | import package:flutter/painting.dart'; |
| - (continuation line) | - *not* widgets.Text | - there are multiple *Text* classes in Dart. |
| | | - TextSpan is for drawing text on Canvas. |
I can see that it is possible to add metadata to a Rackspace virtual machine instance.
I want to get a list of running instances, filtered by a particular metatag value.
I can't see how to do so in the documentation however.
is it possible?
You should be able to do so using the openstack client... but it depends on which metatag you're interested in.
You can get a list of all servers:
openstack server list
Will spit something like
+--------------------------------------+------------------+--------+-----------------------------------------------------------------------------------------------------------+
| ID | Name | Status | Networks |
+--------------------------------------+------------------+--------+-----------------------------------------------------------------------------------------------------------+
| 97606ae9-7f18-4a3c-903a-1583d446119b | trysmallwin | ERROR | |
| cb78b8d5-2f03-4a3f-ab26-f389acbd0b76 | Win-try again | ERROR | public=2607:f298:5:101d:f816:3eff:fe9e:5cd4, 208.113.133.90, 2607:f298:5:101d:f816:3eff:fe36:da45, |
| | | | 208.113.133.93, 2607:f298:5:101d:f816:3eff:fe40:57d5, 208.113.133.95 |
| 040751d1-c4c5-47aa-8dec-1d69a468be1c | hnxhdkwskrvwvdwr | ACTIVE | public=2607:f298:5:101d:f816:3eff:fe60:324, 208.113.130.52 |
+--------------------------------------+------------------+--------+-----------------------------------------------------------------------------------------------------------+
note the ID of the server and investigate deeper:
openstack server show 040751d1-c4c5-47aa-8dec-1d69a468be1c
+--------------------------------------+------------------------------------------------------------+
| Field | Value |
+--------------------------------------+------------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | iad-2 |
| OS-EXT-STS:power_state | Running |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2016-07-26T17:32:01.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | public=2607:f298:5:101d:f816:3eff:fe60:324, 208.113.130.52 |
| config_drive | True |
| created | 2016-07-26T17:31:51Z |
| flavor | gp1.semisonic (50) |
| hostId | e1efd75d1e8f6a7f5bb228a35db13647281996087d39c65af8ce83d9 |
| id | 040751d1-c4c5-47aa-8dec-1d69a468be1c |
| image | Ubuntu-14.04 (03f89ff2-d66e-49f5-ae61-656a006bbbe9) |
| key_name | stef |
| name | hnxhdkwskrvwvdwr |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| project_id | d2fb6996496044158cf977c2129c8660 |
| properties | |
| security_groups | [{u'name': u'default'}] |
| status | ACTIVE |
| updated | 2016-07-26T17:32:01Z |
| user_id | 5b2ca246f39a425f9a833460bf322603 |
+--------------------------------------+------------------------------------------------------------+
openstack --f json will output the same stuff but in json format that you can more easily manipulate programmatically.
HTH