问:
Cascading join two files very slow
I am using cascading to do a HashJoin two 300MB files. I do the following cascading workflow:

```<code>// select the field which I need from the first file
Fields f1 = new Fields("id_1");
docPipe1 = new Each( docPipe1, scrubArguments, new ScrubFunction( f1 ), Fields.RESULTS );

// select the fields which I need from the second file
Fields f2 = new Fields("id_2","category");
docPipe2 = new Each( docPipe2, scrubArguments, new ScrubFunction( f2), Fields.RESULTS );

// hashJoin
Pipe tokenPipe = new HashJoin( docPipe1, new Fields("id_1"),
                     docPipe2, new Fields("id_2"), new LeftJoin());

// count the number of each "category" based on the id_1 matching id_2
Pipe pipe = new Pipe(tokenPipe );
pipe = new GroupBy( pipe , new Fields("category"));
pipe = new Every( pipe, Fields.ALL, new Count(), Fields.ALL );
</code>```

I am running this cascading program on a Hadoop Cluster which has 3 datanode, each is 8 RAM and 4 cores (I set mapred.child.java.opts to 4096MB.); but it takes me about 30 mins to get the final result. I think it is too slow, but I think there is no problem in my program and in the cluster. How can I make this cascading join faster?

答: It may be possible that your hadoop cluster might be busy or dedicated to some other job probably and hence the time taken. I dont think that replacing HashJoin with CoGroup will help you because CoGroup is a reduce-side join, while HashJoin does a map-side join and hence HashJoin is going to be more performant than ConGroup. I think you should try once again with a less busy cluster because your code also looks good.</p>

Title: Cascading join two files very slow

Body:
I am using cascading to do a HashJoin two 300MB files. I do the following cascading workflow:

// select the field which I need from the first file
Fields f1 = new Fields("id_1");
docPipe1 = new Each( docPipe1, scrubArguments, new ScrubFunction( f1 ), Fields.RESULTS );

// select the fields which I need from the second file
Fields f2 = new Fields("id_2","category");
docPipe2 = new Each( docPipe2, scrubArguments, new ScrubFunction( f2), Fields.RESULTS );

// hashJoin
Pipe tokenPipe = new HashJoin( docPipe1, new Fields("id_1"),
                     docPipe2, new Fields("id_2"), new LeftJoin());

// count the number of each "category" based on the id_1 matching id_2
Pipe pipe = new Pipe(tokenPipe );
pipe = new GroupBy( pipe , new Fields("category"));
pipe = new Every( pipe, Fields.ALL, new Count(), Fields.ALL );

I am running this cascading program on a Hadoop Cluster which has 3 datanode, each is 8 RAM and 4 cores (I set mapred.child.java.opts to 4096MB.); but it takes me about 30 mins to get the final result. I think it is too slow, but I think there is no problem in my program and in the cluster. How can I make this cascading join faster?


来源: stackexchange

问:
How to use connection pool with Tomcat 6 and MySQL?
i'm building a web application and i want to use "Connection Pooling" because of the benefits that came with it.
I read some tutorials but i really don't understand what i need to do.

If someone could give me a north, i appreciate.

I'm using JSP/Servlet, MySQL, Tomcat 6 and Netbeans 6.9.1.

Best regards,
Valter Henrique.

答:
Have you read http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example?
It shows you all the steps to access your database from a web app.

If you need to access the database from withing Java code (much better than from JSP), your code should look like this :

```<code>InitialContext initCtx = new InitialContext();
// getting the datasource declared in web.xml
DataSource dataSource = (DataSource) initCtx.lookup("java:comp/env/jdbc/TestDB");

// getting a connection from the dataSOurce/connection pool
Connection c = null;
try {
    c = dataSource.getConnection();
    // use c to get some data
}
finally {
    // always close the connection in a finally block in order to give it back to the pool
    if (c != null) {
        try {
            c.close();
        }
        catch (SQLException e) {
            // not much to do except perhaps log the exception
        }
    }
}
</code>```

Also, note that you should also close the resultsets and statements used inside the try block. See http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#Random_Connection_Closed_Exceptions for a more complete example.

ContentLicense: CC BY-SA 2.5

Body:
Have you read http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example?
It shows you all the steps to access your database from a web app.

If you need to access the database from withing Java code (much better than from JSP), your code should look like this :

InitialContext initCtx = new InitialContext();
// getting the datasource declared in web.xml
DataSource dataSource = (DataSource) initCtx.lookup("java:comp/env/jdbc/TestDB");

// getting a connection from the dataSOurce/connection pool
Connection c = null;
try {
    c = dataSource.getConnection();
    // use c to get some data
}
finally {
    // always close the connection in a finally block in order to give it back to the pool
    if (c != null) {
        try {
            c.close();
        }
        catch (SQLException e) {
            // not much to do except perhaps log the exception
        }
    }
}

Also, note that you should also close the resultsets and statements used inside the try block. See http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#Random_Connection_Closed_Exceptions for a more complete example.


问:
Why am I getting this syntax error: keyword can't be an expression
```<code>def multiply():
    number_1 = int (input ("Please insert the first number for multiplication:"))
    number_2 = int (input ("Please insert the second number for multiplication:"))
    result = str (number_1*number_2)
    return print (number_1*number_2=result)
multiply()
</code>```

I am getting the Following error when trying to execute the following function.

```<code>    return print (number_1*number_2=result)
                 ^
SyntaxError: keyword can't be an expression
</code>```

答:
You have two issues:

You are writing an expression inside a print statement. Instead you want to make a formatted string and substitute the values into the string:

print("%d*%d=%s" % (number_1, number_2, result))

Secondly, you don't need to return it.

ContentLicense: CC BY-SA 3.0

Body:
def multiply():
    number_1 = int (input ("Please insert the first number for multiplication:"))
    number_2 = int (input ("Please insert the second number for multiplication:"))
    result = str (number_1*number_2)
    return print (number_1*number_2=result)
multiply()

I am getting the Following error when trying to execute the following function.

    return print (number_1*number_2=result)
                 ^
SyntaxError: keyword can't be an expression


问:
How to remove a specific key from Firebase in Swift 3
How can I get the marked key then remove it from UITableView swift 3 ?

```<code>override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {

        if editingStyle == .delete {

            self.grocery.remove(at: indexPath.row)
            self.tableView.deleteRows(at: [indexPath], with: .automatic)
        }
    }
</code>```

答:
To remove you can simply set the value as nil to remove it from firebase. After you've called the remove function then make sure to remove the row from the tableView.</p>

```<code>func removeObjectFromFireBase(userKey: String, removeThisGrocery: String) {
    let ref = Database.database().reference()
    let groceryRef = ref.child("Users").child(userKey).child("Grocery")
    groceryRef.child(removeThisObject).setValue(nil)
}

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    let deleteAction = UITableViewRowAction(style: .destructive, title: "DELETE") { (rowAction, indexPath) in

        //Call the removeFromFirebase function with the required parameters
        removeObjectFromFirebase(userKey: userKey, removeThisGrocery: groceryKey)
        tableView.deleteRows(at: [indexPath], with: .automatic)
    }

    deleteAction.backgroundColor = UIColor.red
    return [deleteAction, addAction]
}
</code>```

Body:
How can I get the marked key then remove it from UITableView swift 3 ?

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {

        if editingStyle == .delete {

            self.grocery.remove(at: indexPath.row)
            self.tableView.deleteRows(at: [indexPath], with: .automatic)
        }
    }

Body:
To remove you can simply set the value as nil to remove it from firebase. After you've called the remove function then make sure to remove the row from the tableView.

func removeObjectFromFireBase(userKey: String, removeThisGrocery: String) {
    let ref = Database.database().reference()
    let groceryRef = ref.child("Users").child(userKey).child("Grocery")
    groceryRef.child(removeThisObject).setValue(nil)
}

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    let deleteAction = UITableViewRowAction(style: .destructive, title: "DELETE") { (rowAction, indexPath) in

        //Call the removeFromFirebase function with the required parameters
        removeObjectFromFirebase(userKey: userKey, removeThisGrocery: groceryKey)
        tableView.deleteRows(at: [indexPath], with: .automatic)
    }

    deleteAction.backgroundColor = UIColor.red
    return [deleteAction, addAction]
}


问:
Allocation failed in Azure and cannot delete VMs
I use the Microsoft Azure and I subscribed the HDInsight and its location is in Japan. A couple of days ago, I mistakenly removed all the VMs that I have been used and I determined to recover the VMs using the vhdl files. However, I changed my mind to create new VMs instead of restoring them. I successfully completed the installation of the new VMs and I installed the Hadoop and Spark and used them very well. However, a few days later, when I started my VMs, it was strangely slow to turn on and eventually it throw error indicating below message.

Provisioning failed. Allocation failed. Please try reducing the VM
  size or number of VMs, retry later, or try deploying to a different
  Availability Set or different Azure location.. AllocationFailed.

I tried to follow the documents in Azure and changed the VMs size and delete the VMs that I made but deleting or changing the VMs failed throwing below message.

```<code>Provisioning failed. Delete/Deallocate operation on VM 'hadoop-master' failed because the remaining VMs in the Availability Set 'spark-avs' cannot be allocated together. Changes in Availability Set allocation need to be executed atomically. Please deallocate or delete some or all of these VMs before retrying the current operation.
 Please note that this VM is not allocated and won't accrue any charges.
 Details: {
 "resourceType": "Microsoft.WindowsAzure.ComputeResourceProvider.Core.Strings, CRP.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
 "ResourceCode": "ComputeAllocationFailure",
 "ResourceParameters": []
 }. CannotAllocateRemainingVMsInAvailabilitySet
</code>```

Note that all the VMs that I re-installed is in the same availability set and I selected the south-korea for the new region (previous one is japan).

I tried to start many times but failed.

How to resolve this issue?

答:
Note: When you create a VM, restart stopped (de-allocated) VMs, resize a VM, or when you add new instances, Microsoft Azure allocates compute resources to your subscription. You may occasionally receive errors when performing these operations even before you reach the Azure subscription limits.

This article “Troubleshoot allocation failures when you create, restart, or resize Linux VMs in Azure” explains the causes of some of the common allocation failures and suggests possible remediation.

If you assign Extra small, Small, and medium, you will receive validation failed error message.

Note: Head node recommended size is D3 v2, D4 v2, and D12 v2.

For more details, refer “Default node configuration and virtual machine sizes for clusters”.

Before deploying an HDInsight cluster, plan for the desired cluster capacity by determining the needed performance and scale. This planning helps optimize both usability and costs.

Some cluster capacity decisions cannot be changed after deployment. If the performance parameters change, a cluster can be dismantled and re-created without losing stored data.

For more details, refer “Capacity planning for HDInsight clusters”.

Body:
I use the Microsoft Azure and I subscribed the HDInsight and its location is in Japan. A couple of days ago, I mistakenly removed all the VMs that I have been used and I determined to recover the VMs using the vhdl files. However, I changed my mind to create new VMs instead of restoring them. I successfully completed the installation of the new VMs and I installed the Hadoop and Spark and used them very well. However, a few days later, when I started my VMs, it was strangely slow to turn on and eventually it throw error indicating below message.

Provisioning failed. Allocation failed. Please try reducing the VM
  size or number of VMs, retry later, or try deploying to a different
  Availability Set or different Azure location.. AllocationFailed.

I tried to follow the documents in Azure and changed the VMs size and delete the VMs that I made but deleting or changing the VMs failed throwing below message.

Provisioning failed. Delete/Deallocate operation on VM 'hadoop-master' failed because the remaining VMs in the Availability Set 'spark-avs' cannot be allocated together. Changes in Availability Set allocation need to be executed atomically. Please deallocate or delete some or all of these VMs before retrying the current operation.
 Please note that this VM is not allocated and won't accrue any charges.
 Details: {
 "resourceType": "Microsoft.WindowsAzure.ComputeResourceProvider.Core.Strings, CRP.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
 "ResourceCode": "ComputeAllocationFailure",
 "ResourceParameters": []
 }. CannotAllocateRemainingVMsInAvailabilitySet

Note that all the VMs that I re-installed is in the same availability set and I selected the south-korea for the new region (previous one is japan).

I tried to start many times but failed.

How to resolve this issue?


问:
linux bash count size of files in folder
i saw a few posts in forum but i cant manage to make them work for me

i have a script that runs in a folder and i want it to count the size only of the files in that folder but without the folders inside.

so if i have

```<code>file1.txt
folder1
file2.txt
</code>```

it will return the size in bytes of file1+file2 without folder1

find . -maxdepth 1 -type f
gives me a list of all the files i want to count but how can i get the size of all this files?

答:
The tool for this is xargs:

```<code>find "$dir" -maxdepth 1 -type f -print0 | xargs -0 wc -c
</code>```

Note that find -print0 and xargs -0 are GNU extensions, but if you know they are available, they are well worth using in your script - you don't know what characters might be present in the filenames in the target directory.

You will need to post-process the output of wc; alternatively, use cat to give it a single input stream, like this:

```<code>find "$dir" -maxdepth 1 -type f -print0 | xargs -0 cat | wc -c
</code>```

That gives you a single number you can use in following commands.

(I've assumed you meant "size" in bytes; obviously substitute wc -m if you meant characters or wc -l if you meant lines).

Body:
i saw a few posts in forum but i cant manage to make them work for me

i have a script that runs in a folder and i want it to count the size only of the files in that folder but without the folders inside.

so if i have

file1.txt
folder1
file2.txt

it will return the size in bytes of file1+file2 without folder1

find . -maxdepth 1 -type f
gives me a list of all the files i want to count but how can i get the size of all this files?

Body:
The tool for this is xargs:

find "$dir" -maxdepth 1 -type f -print0 | xargs -0 wc -c

Note that find -print0 and xargs -0 are GNU extensions, but if you know they are available, they are well worth using in your script - you don't know what characters might be present in the filenames in the target directory.

You will need to post-process the output of wc; alternatively, use cat to give it a single input stream, like this:

find "$dir" -maxdepth 1 -type f -print0 | xargs -0 cat | wc -c

That gives you a single number you can use in following commands.

(I've assumed you meant "size" in bytes; obviously substitute wc -m if you meant characters or wc -l if you meant lines).


问:
how to only allow letters to be used python statment
I'm making a Morse code program:

```<code>def main ():

    morse_code = {"a":".-","b":"-...","c":"-.-.","d":"-..","e":".","f":"..-.","g":"--.","h":"....","i":"..","j":".---","k":"-.-","l":".-..",
                  "m":"--","n":"-.","o":"---","p":".--.","q":"--.-","r":".-.","s":"...","t":"-","u":"..-","v":"...-","w":".--","x":"-..-","y":"-.--","z":"--.."}

    phrase = input("please enter your word or words: ")
    for key in phrase:
        print("your word or sentence translated to morse code is : ")
        print(morse_code[key], end = " ")
    if phrase == int or float:
        print("try the input")

    retry()
def retry ():
    main()
retry()
main()
</code>```

How do I print an error if someone enters a number?

答:
You can check if the input is between a and z by doing:

```<code>try:
    index = ord(key.lower())
    if index >= 97 and index <= 122:
        # Do your thing
except TypeError:
    # Wrong input
</code>```

The TypeError shouldn't happen, it's just good practice to wrap code with errors handling.

Or, you can do:

```<code>if not key.isdigit():
    # Key isn't between 0 and 9. Can be uppercase or a symbol, though.
    if ord(key.lower()) >= 97 and ord(key.lower()) <= 122:
        # Do your thing. It's pretty much the same as before but with one more step.
</code>```

Body:
I'm making a Morse code program:

def main ():

    morse_code = {"a":".-","b":"-...","c":"-.-.","d":"-..","e":".","f":"..-.","g":"--.","h":"....","i":"..","j":".---","k":"-.-","l":".-..",
                  "m":"--","n":"-.","o":"---","p":".--.","q":"--.-","r":".-.","s":"...","t":"-","u":"..-","v":"...-","w":".--","x":"-..-","y":"-.--","z":"--.."}

    phrase = input("please enter your word or words: ")
    for key in phrase:
        print("your word or sentence translated to morse code is : ")
        print(morse_code[key], end = " ")
    if phrase == int or float:
        print("try the input")

    retry()
def retry ():
    main()
retry()
main()

How do I print an error if someone enters a number?

Body:
You can check if the input is between a and z by doing:

try:
    index = ord(key.lower())
    if index >= 97 and index <= 122:
        # Do your thing
except TypeError:
    # Wrong input

The TypeError shouldn't happen, it's just good practice to wrap code with errors handling.

Or, you can do:

if not key.isdigit():
    # Key isn't between 0 and 9. Can be uppercase or a symbol, though.
    if ord(key.lower()) >= 97 and ord(key.lower()) <= 122:
        # Do your thing. It's pretty much the same as before but with one more step.


问:
How can I securely implement a notification system using socket?
I am currently working on a web application using the MEAN stack. It has a social aspect to it so I want to be able to push notifications to users.

The way I do it now is when something happens that should be a notification it gets stored in a mongo database with an unread flag. Each client will send a get request to the server every 30 second and will receive every notification marked as unread, and will then mark it as read.

I want to switch to using a message queue and sockets so less network resources will be used, and also provide the user with a real-time experience. I've thought about using redis and its pubsub structure but I can't seem to figure out how to do this securely. If I push out notifications to the affected users, won't it be easy for someone malicious to subscribe to somebody else's channel and receive notifications not meant for them? Am I missing something or is it just the wrong approach for such a system?

Edit: Figure I update with the solution I went with if anyone else reading this is having the same problem.

Instead of using rabbitmq, as the answer suggested, I figured that a much more easy and elegant solution is to just use socket.io. When new sockets connects to the server I save a mapping from the userID to the socketId in a redis in-memory DB. (After I've validated their token) That way, if I need to push a notification to a user I just look up the socketId in the redis DB, and then send it to the correct socket.
<s>This way I don't need any security beyond that as socketIDs are unguessable, and the message is only sent across the single socket that belongs to the given user. </s>

This way it will only get sent through the connection of the given socket, as socketIDs are only used server side to keep track of all the connection. This means no one else can "listen" using someone else's socketID.

答:
you can use RabbitMQ for this. Also authentication is there. Please go through following link and try.

https://www.rabbitmq.com/access-control.html

also, you can apply authentication in existing structure using subscription auth tokens with all subscribed users only.
even redis has its security with topics. Please have a look in link below

https://redis.io/topics/security


问:
Jasper Subreport InputStream Header does not show the image
I have a main report and subreport, and I pass a parameter to subreport as inputstream. I will use this parameter as a logo(image) in my subreport header. If I add the image to subreport and use this parameter, subreport shows only first record of my datasource and the image. If I do not use this image, my subreport lists all records of my datasource. I tried to put the image in detail, header, and title, but it did not work. If I use an image directly from subreport, it works well, but I need to send this parameter(filepath) from Java.

What can be the problem?

Edit: I provide some code.

Main report:

```<code> <?xml version="1.0" encoding="UTF-8"?>
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="e-BordroIsciToplu" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a3c2690b-2af8-4210-8775-cb69cd6557f7">
    <property name="ireport.zoom" value="1.5394743546921228"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="ireport.background.image.properties" value="true,true,0.25,138,273,0,0,386,161"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["W:\\Projects\\modules\\common\\src\\resources\\report\\templates\\"]]></defaultValueExpression>
    </parameter>
    <parameter name="ANTET" class="java.io.InputStream"/>
    <parameter name="AY" class="java.lang.String"/>
    <field name="topluInfo" class="java.util.List"/>
    <detail>
        <band height="109" splitType="Stretch">
            <subreport runToBottom="false">
                <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="533" height="100" uuid="cd6571c7-c8da-4120-868f-82999376c3d3"/>
                <parametersMapExpression><![CDATA[]]></parametersMapExpression>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[]]>  </subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="AY">
                    <subreportParameterExpression><![CDATA[$P{AY}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="ANTET">
                    <subreportParameterExpression><![CDATA[$P{ANTET}]]></subreportParameterExpression>
                </subreportParameter>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{topluInfo})]]></dataSourceExpression>
                <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "e-topluSubreportTest.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>
</code>```

Subreport:

```<code><?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="e-topluSubreport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="545" leftMargin="20" rightMargin="30" topMargin="20" bottomMargin="20" uuid="a3c2690b-2af8-4210-8775-cb69cd6557f7">
    <property name="ireport.zoom" value="1.5394743546921228"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="ireport.background.image.properties" value="true,true,0.25,138,273,0,0,386,161"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["W:\\Projects\\modules\\common\\src\\resources\\report\\templates\\"]]></defaultValueExpression>
    </parameter>
    <parameter name="ANTET" class="java.io.InputStream"/>
    <parameter name="AY" class="java.lang.String"/>
    <detail>
        <band height="139" splitType="Stretch">
            <staticText>
                <reportElement x="5" y="105" width="185" height="15" uuid="023f69c4-13a4-419e-b64b-d41da9f937fa"/>
                <box>
                    <pen lineWidth="0.25"/>
                    <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font size="8" isBold="true" pdfEncoding="Cp1254"/>
                </textElement>
                <text><![CDATA[  BORDRO TÜRÜ  ]]></text>
            </staticText>
            <staticText>
                <reportElement x="5" y="120" width="185" height="15" uuid="e7aac3af-4436-4488-9b00-e93ed875119f"/>
                <box>
                    <pen lineWidth="0.25"/>
                    <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font size="8" isBold="true" pdfEncoding="Cp1254"/>
                </textElement>
                <text><![CDATA[  PARA BİRİMİ]]></text>
            </staticText>
            <staticText>
                <reportElement x="5" y="79" width="500" height="15" uuid="55328d4d-8ce4-44aa-9217-405be02338b6"/>
                <box>
                    <pen lineWidth="0.0"/>
                    <topPen lineWidth="0.0"/>
                    <leftPen lineWidth="0.0"/>
                    <bottomPen lineWidth="0.0"/>
                    <rightPen lineWidth="0.0"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font size="8" isBold="true" pdfEncoding="Cp1254"/>
                </textElement>
                <text><![CDATA[* test]]></text>
            </staticText>
            <image>
                <reportElement x="5" y="23" width="101" height="35" uuid="057a515d-61a7-4f54-9c5e-234acaede0e5"/>
                <imageExpression><![CDATA[$P{ANTET}]]></imageExpression>
            </image>
        </band>
        <band height="50"/>
    </detail>
</jasperReport>
</code>```

答:
Your original report showed the image only for the first record because an InputStream can only be read once.  If you use a single InputStream instance for an image element that prints several times, it will work fine the first time but then it won't be able to read any data from the stream.

There are two things that you can do.  One is to pass the image data as a byte array instead of a stream.

The second is to set isUsingCache="true" for the image element.  This would cache the image object when first rendering the element and then use the cached image when the image element is printed again.

The second approach would be better from a performance point of view since the image data would not be read several times.  You can also combine the solutions by passing the image data as a byte array and setting the isUsingCache flag as well.

Body:
I have a main report and subreport, and I pass a parameter to subreport as inputstream. I will use this parameter as a logo(image) in my subreport header. If I add the image to subreport and use this parameter, subreport shows only first record of my datasource and the image. If I do not use this image, my subreport lists all records of my datasource. I tried to put the image in detail, header, and title, but it did not work. If I use an image directly from subreport, it works well, but I need to send this parameter(filepath) from Java.

What can be the problem?

Edit: I provide some code.

Main report:

 <?xml version="1.0" encoding="UTF-8"?>
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="e-BordroIsciToplu" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a3c2690b-2af8-4210-8775-cb69cd6557f7">
    <property name="ireport.zoom" value="1.5394743546921228"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="ireport.background.image.properties" value="true,true,0.25,138,273,0,0,386,161"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["W:\\Projects\\modules\\common\\src\\resources\\report\\templates\\"]]></defaultValueExpression>
    </parameter>
    <parameter name="ANTET" class="java.io.InputStream"/>
    <parameter name="AY" class="java.lang.String"/>
    <field name="topluInfo" class="java.util.List"/>
    <detail>
        <band height="109" splitType="Stretch">
            <subreport runToBottom="false">
                <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="533" height="100" uuid="cd6571c7-c8da-4120-868f-82999376c3d3"/>
                <parametersMapExpression><![CDATA[]]></parametersMapExpression>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[]]>  </subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="AY">
                    <subreportParameterExpression><![CDATA[$P{AY}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="ANTET">
                    <subreportParameterExpression><![CDATA[$P{ANTET}]]></subreportParameterExpression>
                </subreportParameter>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{topluInfo})]]></dataSourceExpression>
                <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "e-topluSubreportTest.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>

Subreport:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="e-topluSubreport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="545" leftMargin="20" rightMargin="30" topMargin="20" bottomMargin="20" uuid="a3c2690b-2af8-4210-8775-cb69cd6557f7">
    <property name="ireport.zoom" value="1.5394743546921228"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="ireport.background.image.properties" value="true,true,0.25,138,273,0,0,386,161"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["W:\\Projects\\modules\\common\\src\\resources\\report\\templates\\"]]></defaultValueExpression>
    </parameter>
    <parameter name="ANTET" class="java.io.InputStream"/>
    <parameter name="AY" class="java.lang.String"/>
    <detail>
        <band height="139" splitType="Stretch">
            <staticText>
                <reportElement x="5" y="105" width="185" height="15" uuid="023f69c4-13a4-419e-b64b-d41da9f937fa"/>
                <box>
                    <pen lineWidth="0.25"/>
                    <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
                </box>
                <textElement verticalAlignment="Middle">

                </textElement>
                <text><![CDATA[  BORDRO TÜRÜ  ]]></text>
            </staticText>
            <staticText>
                <reportElement x="5" y="120" width="185" height="15" uuid="e7aac3af-4436-4488-9b00-e93ed875119f"/>
                <box>
                    <pen lineWidth="0.25"/>
                    <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
                </box>
                <textElement verticalAlignment="Middle">

                </textElement>
                <text><![CDATA[  PARA BİRİMİ]]></text>
            </staticText>
            <staticText>
                <reportElement x="5" y="79" width="500" height="15" uuid="55328d4d-8ce4-44aa-9217-405be02338b6"/>
                <box>
                    <pen lineWidth="0.0"/>
                    <topPen lineWidth="0.0"/>
                    <leftPen lineWidth="0.0"/>
                    <bottomPen lineWidth="0.0"/>
                    <rightPen lineWidth="0.0"/>
                </box>
                <textElement verticalAlignment="Middle">

                </textElement>
                <text><![CDATA[* test]]></text>
            </staticText>
            <image>
                <reportElement x="5" y="23" width="101" height="35" uuid="057a515d-61a7-4f54-9c5e-234acaede0e5"/>
                <imageExpression><![CDATA[$P{ANTET}]]></imageExpression>
            </image>
        </band>
        <band height="50"/>
    </detail>
</jasperReport>


问:
Detecting characters and acting on them
```<code>    if what == "decode":
    dog_input = input("What would you like to decode?")
    letternumber = len(dog_input)
    a=(dog_input)
    for i in range(a):
        if dog_input[1] == "1":
            print("a")
        if dog_input[1] == "2":
            print("b")
        if dog_input[1] == "3":
            print("c")
        if dog_input[1] == "4":
            print("d")
        if dog_input[1] == "5":
            print("e")
        if dog_input[1] == "6":
            print("f")
        if dog_input[1] == "7":
            print("g")
        if dog_input[1] == "8":
            print("h")
        if dog_input[1] == "9":
            print("i")
        if dog_input[2] == "10":
            print("j")
        if dog_input[2] == "11":
            print("k")
        if dog_input[2] == "12":
            print("l")
        if dog_input[2] == "13":
            print("m")
        if dog_input[2] == "14":
            print("n")
        if dog_input[2] == "15":
            print("o")
        if dog_input[2] == "16":
            print("p")
        if dog_input[2] == "17":
            print("q")
        if dog_input[2] == "18":
            print("r")
        if dog_input[2] == "19":
            print("s")
        if dog_input[1] == "20":
            print("t")
        if dog_input[2] == "21":
            print("u")
        if dog_input[2] == "21":
            print("v")
        if dog_input[2] == "22":
            print("w")
        if dog_input[2] == "23":
            print("x")
        if dog_input[2] == "24":
            print("y")
        if dog_input[2] == "25":
            print("z")
        if dog_input[3] == "-64":
            print(" ")
</code>```

<p>This code does nothing- it will print a character a random three or four times. I would like a user to input numbers and get out letters, but it refuses to read. How do I get it to function? Also, is there a faster way of assigning numbers to letters? </p>

答:
Problem :

```<code>for i in range(a) :
</code>```

This will iterate the string or array letter by letter, so two digit inputs will not be detected. Example: input 12 will be taken as two seperate inputs 1 and 2.

Solution :

Take input as space seperated numbers and seperate it by considering space as delimeter. See the following snippet

```<code>dog_input_final = dog_input.split(" ")
</code>```

The following code (only loop part) solves the issue as well it is a better way to assign number to character.

```<code>dog_input_final = dog_input.split(" ")
for i in dog_input_final:
    if(i == "-64"):
        print " "
    else :
        print chr(97+int(i))
</code>```

Title: Detecting characters and acting on them

Body:
    if what == "decode":
    dog_input = input("What would you like to decode?")
    letternumber = len(dog_input)
    a=(dog_input)
    for i in range(a):
        if dog_input[1] == "1":
            print("a")
        if dog_input[1] == "2":
            print("b")
        if dog_input[1] == "3":
            print("c")
        if dog_input[1] == "4":
            print("d")
        if dog_input[1] == "5":
            print("e")
        if dog_input[1] == "6":
            print("f")
        if dog_input[1] == "7":
            print("g")
        if dog_input[1] == "8":
            print("h")
        if dog_input[1] == "9":
            print("i")
        if dog_input[2] == "10":
            print("j")
        if dog_input[2] == "11":
            print("k")
        if dog_input[2] == "12":
            print("l")
        if dog_input[2] == "13":
            print("m")
        if dog_input[2] == "14":
            print("n")
        if dog_input[2] == "15":
            print("o")
        if dog_input[2] == "16":
            print("p")
        if dog_input[2] == "17":
            print("q")
        if dog_input[2] == "18":
            print("r")
        if dog_input[2] == "19":
            print("s")
        if dog_input[1] == "20":
            print("t")
        if dog_input[2] == "21":
            print("u")
        if dog_input[2] == "21":
            print("v")
        if dog_input[2] == "22":
            print("w")
        if dog_input[2] == "23":
            print("x")
        if dog_input[2] == "24":
            print("y")
        if dog_input[2] == "25":
            print("z")
        if dog_input[3] == "-64":
            print(" ")

This code does nothing- it will print a character a random three or four times. I would like a user to input numbers and get out letters, but it refuses to read. How do I get it to function? Also, is there a faster way of assigning numbers to letters?

Body:
Problem :

for i in range(a) :

This will iterate the string or array letter by letter, so two digit inputs will not be detected. Example: input 12 will be taken as two seperate inputs 1 and 2.

Solution :

Take input as space seperated numbers and seperate it by considering space as delimeter. See the following snippet

dog_input_final = dog_input.split(" ")

The following code (only loop part) solves the issue as well it is a better way to assign number to character.

dog_input_final = dog_input.split(" ")
for i in dog_input_final:
    if(i == "-64"):
        print " "
    else :
        print chr(97+int(i))


问:
Scala - reducing a map based on changed key
Lets say have the following Map data

```<code>val testMap: Map[String, Int] = Map("AAA_abc" -> 1,
                                    "AAA_anghesh" -> 2,
                                    "BBB_wfejw" -> 3,
                                    "BBB_qgqwe" -> 4,
                                    "C_fkee" -> 5)
</code>```

Now I want to reduce the map by key.split("_").head and add all the values for the keys that became equal. So for this example the Map should result into:

```<code>Map(AAA -> 3, BBB -> 7, C -> 5)
</code>```

What would be the correct way to do so in Scala?
I tried constructions with groupBy and reduceLeft but could not find a solution.

答:
A variation in one pass: </p>

```<code>testMap.foldLeft(Map[String,Int]())( (map, kv) => {
  val key = kv._1.split("_").head
  val previous = map.getOrElse(key,0)
  map.updated(key, previous + kv._2) })
</code>```

Body:
Lets say have the following Map data

val testMap: Map[String, Int] = Map("AAA_abc" -> 1,
                                    "AAA_anghesh" -> 2,
                                    "BBB_wfejw" -> 3,
                                    "BBB_qgqwe" -> 4,
                                    "C_fkee" -> 5)

Now I want to reduce the map by key.split("_").head and add all the values for the keys that became equal. So for this example the Map should result into:

Map(AAA -> 3, BBB -> 7, C -> 5)

What would be the correct way to do so in Scala?
I tried constructions with groupBy and reduceLeft but could not find a solution.

Body:
A variation in one pass:

testMap.foldLeft(Map[String,Int]())( (map, kv) => {
  val key = kv._1.split("_").head
  val previous = map.getOrElse(key,0)
  map.updated(key, previous + kv._2) })


问:
Can I create a game for webgl without the Unity logo?
Can I create a game for webgl without the Unity logo when I download and without title "Unity webGL"?
 . example</p>

答:
According to the docs you need a Pro license to remove the splash screen. (the logo in the middle of the screen)

As for the frame around the game that's easy to change, just change the HTML as documented here. You can choose either one of the defaults or create your own template.

According to those docs you create folder in Assets called WebGLTemplates and inside that create a new folder for your template like BetterTemplate. Inside that put an index.html file and any other images, css, JavaScript files you want included with your game.

The index.html could look something like this

<!DOCTYPE html>

    <meta charset="utf-8">
    <title>%UNITY_WEB_NAME%</title>

```

Then you pick Edit->Project Settings->Player from the menus and under the WebGL tab choose your template

Here's an example that provides a custom logo. The part that's not removable without a Pro license is the "Made with Unity" that appears just before the game starts.

Body:
According to the docs you need a Pro license to remove the splash screen. (the logo in the middle of the screen)

As for the frame around the game that's easy to change, just change the HTML as documented here. You can choose either one of the defaults or create your own template.

According to those docs you create folder in Assets called WebGLTemplates and inside that create a new folder for your template like BetterTemplate. Inside that put an index.html file and any other images, css, JavaScript files you want included with your game.

The index.html could look something like this

<!DOCTYPE html>
<html lang="en-us">

  <head>
    <meta charset="utf-8">
    <title>%UNITY_WEB_NAME%</title>
    <style>
      body { margin: 0; }
      #gameContainer { width: 100vw; height: 100vh; }
      canvas { width: 100%; height: 100%; }
    </style>
    <script src="Build/UnityLoader.js"></script>
    <script>
    var gameInstance = UnityLoader.instantiate("gameContainer", "Build/dist.json");
    </script>
  </head>

  <body>
    <div id="gameContainer"></div>
  </body>

</html>

Then you pick Edit->Project Settings->Player from the menus and under the WebGL tab choose your template

Here's an example that provides a custom logo. The part that's not removable without a Pro license is the "Made with Unity" that appears just before the game starts.


问:
Convert WM_CONCAT to Listagg
My DBA is upgrading my oracle db from v10 to v12.
I have some old SP's that uses wm_concat and I need to change it to listagg.
The problematic code is this:

```<code>Select  registration_id,package_set_id,
        REPLACE(REPLACE(WM_CONCAT(REPLACE( (case when ROW_NUMBER() over (partition by product_id,product_detail_set_id,registration_id,product_family_id,application_id,package_Set_id,
               legal_status order by packset_country)=1 then legal_status else null end), ',' , '#')) OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,
               REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID   ORDER BY Packset_country  ), ',' , ' | '), '#', ',') as legal_status,

        (REPLACE(REPLACE(WM_CONCAT(REPLACE(ev_code, ',' , '#')) OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,
               REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID   ORDER BY ev_code  ), ',' , ' | '), '#', ',')) EV_CODES,

         min(marketed_date) over (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID) as marketed_date,

         (REPLACE(REPLACE(WM_CONCAT(REPLACE(Packset_country, ',' , '#')) OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID, REGISTRATION_ID ,PRODUCT_FAMILY_ID,
                APPLICATION_ID,PACKAGE_SET_ID   ORDER BY Packset_country, reg_packset_country_id ), ',' , ' | '), '#', ',')) REGISTRATION_PACKSET_COUNTRIES,
         ROW_NUMBER() OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID
                ORDER BY Packset_country desc ,reg_packset_country_id)  ROW_NUM,
         REPLACE(REPLACE(WM_CONCAT(REPLACE( (case when currently_marketed_in_country='Y' then packset_country end), ',' , '#')) OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,
                REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID  ORDER BY packset_country ,currently_marketed_in_country,reg_packset_country_id ), ',' , ' | '), '#', ',') as CURRENTLY_MARKETED_COUNTRIES
from radw_dwh.dw202_fact_reg_pack_countries
</code>```

The expected result is:

I tried to change it but there is a problem when I'm trying to use "ROW_NUMBER()" in side "LISTAGG".

How can I fix this?

答:
Motivation for the following approach

We had several problems with wm_concat (known bugs) or wm_concat-to-list_agg-conversion-for-12c-use.

(Not to mention the nice compact/declarative usage using wm_concat in many scenarios where other solutions may be quite complicated to read.)

(Sometimes having to use xmlagg because of > 4000 chars/clob problems or regexp_replace workarounds for the wm_concat( distinct ... ) emulation), e.g. like here.

Strategy

So finally in my opinion a rather nice strategy (which may differ depending on your environment/needs/strategy) is, to

create two functions

create function  wm_concat_32767(... (working on varchar(32767) which is possible since Oracle 12c) and

depending on MAX_STRING_SIZE of your db you may want to adopt this to "4000" or others

create function  wm_concat_clob(... in your db in the sys-schema first.

They should be based on code like provided by the answer from Dart XKey (maybe copied from asktom/Tom Kyte)

create public synonym  wm_concat  for  sys.wm_concat_32767

(I would generally let the wm_concat point to the likely faster wm_concat_32767 rather than wm_concat_clob)

this allows the easy reuse/migration of existing wm_concat(varchar(4000)) based < 11.2g code/usage

one might already know the name of the function and thus easy to get use to

(the problem that online documentation about it may be misleading is what I could live with since the benefits would outweight the disadvantages for me in general)

it will even allow the use of wm_concat( distinct ... ) queries with compact declarative syntax

as opposed to the listagg/xmlagg/regexp_replace-based workarounds mentioned above

create public synonym  wm_concat_clob  for  sys.wm_concat_clob

give proper public execution rights to the wm_concat_*functions

Code

So finally the adopted code we use (maybe I'll update everything mentioned above over time):

wm_concat_32767(...) creation:

depending on MAX_STRING_SIZE of your db you may want to adopt this to "4000" or other values

_

```<code>create or replace type  string_agg_type  as object (
  total varchar2(32767),
  static function ODCIAggregateInitialize(sctx IN OUT string_agg_type ) return number,
  member function ODCIAggregateIterate(self IN OUT string_agg_type , value IN varchar2 ) return number,
  member function ODCIAggregateTerminate(self IN string_agg_type, returnValue OUT varchar2, flags IN number) return number,
  member function ODCIAggregateMerge(self IN OUT string_agg_type, ctx2 IN string_agg_type) return number
);
/
create or replace type body  string_agg_type  is static function odciaggregateinitialize(sctx IN OUT string_agg_type) return number is begin sctx := string_agg_type(null); return odciconst.success; end;
  member function odciaggregateiterate(self IN OUT string_agg_type, value IN varchar2) return number is begin self.total := self.total || ',' || value; return odciconst.success; end;
  member function odciaggregateterminate(self IN string_agg_type, returnvalue OUT varchar2, flags IN number) return number is begin returnvalue := ltrim(self.total, ','); return odciconst.success; end;
  member function odciaggregatemerge(self IN OUT string_agg_type, ctx2 IN string_agg_type) return number is begin self.total := self.total || ctx2.total; return odciconst.success; end;
end;
/
CREATE or replace FUNCTION  wm_concat_32767(input varchar2) RETURN varchar2 PARALLEL_ENABLE AGGREGATE USING string_agg_type;
/
</code>```

wm_concat_clob(...) creation based on this code from Michel Cadot:

```<code>create or replace type  stragg_type4  as object (
  result CLOB,
  static function ODCIAggregateInitialize (sctx IN OUT stragg_type4) return number,
  member function ODCIAggregateIterate (self IN OUT stragg_type4, value IN varchar2) return number,
  member function ODCIAggregateTerminate (self IN stragg_type4, returnValue OUT CLOB, flags IN number) return number,
  member function ODCIAggregateMerge (self IN OUT stragg_type4, ctx2 IN stragg_type4) return number
);
/

create or replace type body  stragg_type4  is

  static function ODCIAggregateInitialize (sctx IN OUT stragg_type4) return number is begin
    sctx := stragg_type4 (null);
    dbms_lob.createtemporary (lob_loc => sctx.result, cache   => TRUE, dur => dbms_lob.call);
    return ODCIConst.Success;
  end;

  member function ODCIAggregateIterate (self IN OUT stragg_type4, value IN varchar2) return number is begin
    self.result := self.result || ',' || value;
    return ODCIConst.Success;
  end;

  member function ODCIAggregateTerminate (self IN stragg_type4, returnValue OUT CLOB, flags IN number) return number is begin
    returnValue := ltrim (self.result, ',');
    return ODCIConst.Success;
  end;

  member function ODCIAggregateMerge (self IN OUT stragg_type4, ctx2 IN stragg_type4) return number is begin
    self.result := self.result || ctx2.result;
    return ODCIConst.Success;
  end;

end;
/

sho err

CREATE or replace FUNCTION wm_concat_clob(input varchar2) RETURN CLOB PARALLEL_ENABLE AGGREGATE USING stragg_type4;
/
</code>```

Title: Convert WM_CONCAT to Listagg

Body:
My DBA is upgrading my oracle db from v10 to v12.
I have some old SP's that uses wm_concat and I need to change it to listagg.
The problematic code is this:

Select  registration_id,package_set_id,
        REPLACE(REPLACE(WM_CONCAT(REPLACE( (case when ROW_NUMBER() over (partition by product_id,product_detail_set_id,registration_id,product_family_id,application_id,package_Set_id,
               legal_status order by packset_country)=1 then legal_status else null end), ',' , '#')) OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,
               REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID   ORDER BY Packset_country  ), ',' , ' | '), '#', ',') as legal_status,

        (REPLACE(REPLACE(WM_CONCAT(REPLACE(ev_code, ',' , '#')) OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,
               REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID   ORDER BY ev_code  ), ',' , ' | '), '#', ',')) EV_CODES,

         min(marketed_date) over (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID) as marketed_date,

         (REPLACE(REPLACE(WM_CONCAT(REPLACE(Packset_country, ',' , '#')) OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID, REGISTRATION_ID ,PRODUCT_FAMILY_ID,
                APPLICATION_ID,PACKAGE_SET_ID   ORDER BY Packset_country, reg_packset_country_id ), ',' , ' | '), '#', ',')) REGISTRATION_PACKSET_COUNTRIES,
         ROW_NUMBER() OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID
                ORDER BY Packset_country desc ,reg_packset_country_id)  ROW_NUM,
         REPLACE(REPLACE(WM_CONCAT(REPLACE( (case when currently_marketed_in_country='Y' then packset_country end), ',' , '#')) OVER (PARTITION BY PRODUCT_ID,  PRODUCT_DETAIL_SET_ID,
                REGISTRATION_ID  ,PRODUCT_FAMILY_ID,APPLICATION_ID,PACKAGE_SET_ID  ORDER BY packset_country ,currently_marketed_in_country,reg_packset_country_id ), ',' , ' | '), '#', ',') as CURRENTLY_MARKETED_COUNTRIES
from radw_dwh.dw202_fact_reg_pack_countries

The expected result is:

I tried to change it but there is a problem when I'm trying to use "ROW_NUMBER()" in side "LISTAGG".

How can I fix this?

Body:
Motivation for the following approach

We had several problems with wm_concat (known bugs) or wm_concat-to-list_agg-conversion-for-12c-use.

(Not to mention the nice compact/declarative usage using wm_concat in many scenarios where other solutions may be quite complicated to read.)

(Sometimes having to use xmlagg because of > 4000 chars/clob problems or regexp_replace workarounds for the wm_concat( distinct ... ) emulation), e.g. like here.

Strategy

So finally in my opinion a rather nice strategy (which may differ depending on your environment/needs/strategy) is, to

create two functions

create function  wm_concat_32767(... (working on varchar(32767) which is possible since Oracle 12c) and

depending on MAX_STRING_SIZE of your db you may want to adopt this to "4000" or others

create function  wm_concat_clob(... in your db in the sys-schema first.

They should be based on code like provided by the answer from Dart XKey (maybe copied from asktom/Tom Kyte)

create public synonym  wm_concat  for  sys.wm_concat_32767

(I would generally let the wm_concat point to the likely faster wm_concat_32767 rather than wm_concat_clob)

this allows the easy reuse/migration of existing wm_concat(varchar(4000)) based < 11.2g code/usage

one might already know the name of the function and thus easy to get use to

(the problem that online documentation about it may be misleading is what I could live with since the benefits would outweight the disadvantages for me in general)

it will even allow the use of wm_concat( distinct ... ) queries with compact declarative syntax

as opposed to the listagg/xmlagg/regexp_replace-based workarounds mentioned above

create public synonym  wm_concat_clob  for  sys.wm_concat_clob

give proper public execution rights to the wm_concat_*functions

Code

So finally the adopted code we use (maybe I'll update everything mentioned above over time):

wm_concat_32767(...) creation:

depending on MAX_STRING_SIZE of your db you may want to adopt this to "4000" or other values

_

create or replace type  string_agg_type  as object (
  total varchar2(32767),
  static function ODCIAggregateInitialize(sctx IN OUT string_agg_type ) return number,
  member function ODCIAggregateIterate(self IN OUT string_agg_type , value IN varchar2 ) return number,
  member function ODCIAggregateTerminate(self IN string_agg_type, returnValue OUT varchar2, flags IN number) return number,
  member function ODCIAggregateMerge(self IN OUT string_agg_type, ctx2 IN string_agg_type) return number
);
/
create or replace type body  string_agg_type  is static function odciaggregateinitialize(sctx IN OUT string_agg_type) return number is begin sctx := string_agg_type(null); return odciconst.success; end;
  member function odciaggregateiterate(self IN OUT string_agg_type, value IN varchar2) return number is begin self.total := self.total || ',' || value; return odciconst.success; end;
  member function odciaggregateterminate(self IN string_agg_type, returnvalue OUT varchar2, flags IN number) return number is begin returnvalue := ltrim(self.total, ','); return odciconst.success; end;
  member function odciaggregatemerge(self IN OUT string_agg_type, ctx2 IN string_agg_type) return number is begin self.total := self.total || ctx2.total; return odciconst.success; end;
end;
/
CREATE or replace FUNCTION  wm_concat_32767(input varchar2) RETURN varchar2 PARALLEL_ENABLE AGGREGATE USING string_agg_type;
/

wm_concat_clob(...) creation based on this code from Michel Cadot:

create or replace type  stragg_type4  as object (
  result CLOB,
  static function ODCIAggregateInitialize (sctx IN OUT stragg_type4) return number,
  member function ODCIAggregateIterate (self IN OUT stragg_type4, value IN varchar2) return number,
  member function ODCIAggregateTerminate (self IN stragg_type4, returnValue OUT CLOB, flags IN number) return number,
  member function ODCIAggregateMerge (self IN OUT stragg_type4, ctx2 IN stragg_type4) return number
);
/

create or replace type body  stragg_type4  is

  static function ODCIAggregateInitialize (sctx IN OUT stragg_type4) return number is begin
    sctx := stragg_type4 (null);
    dbms_lob.createtemporary (lob_loc => sctx.result, cache   => TRUE, dur => dbms_lob.call);
    return ODCIConst.Success;
  end;

  member function ODCIAggregateIterate (self IN OUT stragg_type4, value IN varchar2) return number is begin
    self.result := self.result || ',' || value;
    return ODCIConst.Success;
  end;

  member function ODCIAggregateTerminate (self IN stragg_type4, returnValue OUT CLOB, flags IN number) return number is begin
    returnValue := ltrim (self.result, ',');
    return ODCIConst.Success;
  end;

  member function ODCIAggregateMerge (self IN OUT stragg_type4, ctx2 IN stragg_type4) return number is begin
    self.result := self.result || ctx2.result;
    return ODCIConst.Success;
  end;

end;
/

sho err

CREATE or replace FUNCTION wm_concat_clob(input varchar2) RETURN CLOB PARALLEL_ENABLE AGGREGATE USING stragg_type4;
/


问:
How to find current flow name in mule?
I need to capture current flow name into a variable.

I tried with #[flow.name] but no luck in mule 3.8.0

can anybody please assist me?

答:
In mule 3.8.5 using Groovy script component, </p>

```<code>flowVars.currentFlowName = eventContext.getFlowConstruct().getName();
</code>```

Title: How to find current flow name in mule?

Body:
In mule 3.8.5 using Groovy script component,

flowVars.currentFlowName = eventContext.getFlowConstruct().getName();


问:
InvocationTargetException when using JavaFX
I am trying to use Gluon/JavaFX for the first time, but I am receiving an InvocationTargetException at run-time. I have searched for answers on this site and others, but have received the same problem after trying each suggestion.

Main:

```<code>package Scenes;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class Main extends Application{

    public void start(Stage stage) throws Exception{

        Parent root = FXMLLoader.load(getClass().getResource("test.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("asdf");
        stage.show();
    }

    public static void main(String[] args) {

        launch(args);
    }

}
</code>```

Controller:

```<code>package Scenes;
import java.io.File;

import javax.swing.JButton;
import javax.swing.JFileChooser;

import javafx.scene.control.Button;

public class Controller {

    Button kButton;
    Button bpButton;

    public void initialize() {

    }

    public static void browseFileK() {
        JFileChooser jfc = new JFileChooser();
        int returnValue = jfc.showOpenDialog(null);
        if(returnValue == JFileChooser.APPROVE_OPTION)
        {
            File selectedFile = jfc.getSelectedFile();
        }
    }

        public static void browseFileBP() {
            JFileChooser jfc = new JFileChooser();
            int returnValue = jfc.showOpenDialog(null);
            if(returnValue == JFileChooser.APPROVE_OPTION)
            {
                File selectedFile = jfc.getSelectedFile();
            }
        }

}
</code>```

FXML file:

```<code><?xml version="1.0" encoding="UTF-8"?>

<?import com.gluonhq.charm.glisten.control.TextField?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/8.0.151" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
  <children>
    <AnchorPane cache="true" maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
      <children>
        <Label alignment="CENTER" layoutX="155.0" layoutY="177.0" style="
" textAlignment="CENTER" textFill="#9f9f9f" wrapText="false">
          <font>
            <Font size="18.0" />
          </font>
        </Label>
            <TextField layoutX="21.0" layoutY="47.0" prefHeight="26.0" prefWidth="237.0" text="Select location of Kasasa accounts file" />
            <TextField layoutX="21.0" layoutY="118.0" prefHeight="26.0" prefWidth="237.0" text="Select location of Bill Pay accounts file" />
            <Button layoutX="294.0" layoutY="48.0" mnemonicParsing="false" text="Browse..." />
            <Button layoutX="294.0" layoutY="115.0" mnemonicParsing="false" text="Browse..." />
            <Button layoutX="168.0" layoutY="269.0" mnemonicParsing="false" prefHeight="32.0" prefWidth="253.0" text="Generate refund document" />
      </children>
    </AnchorPane>
  </children>
</VBox>
</code>```

Stacktrace:

```<code>Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Location is required.
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
    at Scenes.Main.start(Main.java:14)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    ... 1 more
</code>```

It seems the most popular suggestions have been to add the fxml file to the same package as main, add "/" in front of the fxml file, or to change the file name to "Scenes/test.fxml", none of which have worked for me.

答:
The answer to your question depends quite a lot on what your build system is doing. Some build systems for example will not copy an .fxml file into the build directory if it's not in some resources folder instead of a source folder. Others will require explicitly specifying the file patterns that you want to copy to the build folder.

The fastest way to debug this would be to check your build folder (output directory) and see if the .fxml file is there.

Body:
I am trying to use Gluon/JavaFX for the first time, but I am receiving an InvocationTargetException at run-time. I have searched for answers on this site and others, but have received the same problem after trying each suggestion.

Main:

package Scenes;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class Main extends Application{

    public void start(Stage stage) throws Exception{

        Parent root = FXMLLoader.load(getClass().getResource("test.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("asdf");
        stage.show();
    }

    public static void main(String[] args) {

        launch(args);
    }

}

Controller:

package Scenes;
import java.io.File;

import javax.swing.JButton;
import javax.swing.JFileChooser;

import javafx.scene.control.Button;

public class Controller {

    Button kButton;
    Button bpButton;

    public void initialize() {

    }

    public static void browseFileK() {
        JFileChooser jfc = new JFileChooser();
        int returnValue = jfc.showOpenDialog(null);
        if(returnValue == JFileChooser.APPROVE_OPTION)
        {
            File selectedFile = jfc.getSelectedFile();
        }
    }

        public static void browseFileBP() {
            JFileChooser jfc = new JFileChooser();
            int returnValue = jfc.showOpenDialog(null);
            if(returnValue == JFileChooser.APPROVE_OPTION)
            {
                File selectedFile = jfc.getSelectedFile();
            }
        }

}

FXML file:

<?xml version="1.0" encoding="UTF-8"?>

<?import com.gluonhq.charm.glisten.control.TextField?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/8.0.151" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
  <children>
    <AnchorPane cache="true" maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
      <children>

            <TextField layoutX="21.0" layoutY="47.0" prefHeight="26.0" prefWidth="237.0" text="Select location of Kasasa accounts file" />
            <TextField layoutX="21.0" layoutY="118.0" prefHeight="26.0" prefWidth="237.0" text="Select location of Bill Pay accounts file" />
            <Button layoutX="294.0" layoutY="48.0" mnemonicParsing="false" text="Browse..." />
            <Button layoutX="294.0" layoutY="115.0" mnemonicParsing="false" text="Browse..." />
            <Button layoutX="168.0" layoutY="269.0" mnemonicParsing="false" prefHeight="32.0" prefWidth="253.0" text="Generate refund document" />
      </children>
    </AnchorPane>
  </children>
</VBox>

Stacktrace:

Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Location is required.
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
    at Scenes.Main.start(Main.java:14)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    ... 1 more

It seems the most popular suggestions have been to add the fxml file to the same package as main, add "/" in front of the fxml file, or to change the file name to "Scenes/test.fxml", none of which have worked for me.


问:
Xamarin forms - Load pages best practices
I want to create a "loader" which displayed when my ContentView will be loaded.

Like this in YouTube application:

As you can see, when I click on tab button, a loader appears.

But in Xamarin.Forms, I don't know how to do that, because ContentView have not OnAppearing to hide my loader. (And because my loader will be displayed at the same time of my ContentView).
When I click on my button, my app "froze" during 200ms approximately... Not good for user experience...

This is why I come here, what is the best practice to display my content?

Thanks

答: I used this plugin to achieve the loading screen, check it out  https://github.com/rotorgames/Rg.Plugins.Popup</p>


问:
Getting NullPointerException when running Spark Code in Zeppelin 0.7.1
I have installed Zeppelin 0.7.1. When I tried to execute the Example spark program(which was available with Zeppelin Tutorial notebook), I am getting the following error

```<code>java.lang.NullPointerException
    at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:38)
    at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:33)
    at org.apache.zeppelin.spark.SparkInterpreter.createSparkContext_2(SparkInterpreter.java:391)
    at org.apache.zeppelin.spark.SparkInterpreter.createSparkContext(SparkInterpreter.java:380)
    at org.apache.zeppelin.spark.SparkInterpreter.getSparkContext(SparkInterpreter.java:146)
    at org.apache.zeppelin.spark.SparkInterpreter.open(SparkInterpreter.java:828)
    at org.apache.zeppelin.interpreter.LazyOpenInterpreter.open(LazyOpenInterpreter.java:70)
    at org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:483)
    at org.apache.zeppelin.scheduler.Job.run(Job.java:175)
    at org.apache.zeppelin.scheduler.FIFOScheduler$1.run(FIFOScheduler.java:139)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
</code>```

I have also setup the config file(zeppelin-env.sh) to point to my Spark installation & Hadoop configuration directory

```<code>export SPARK_HOME="/${homedir}/sk"
export HADOOP_CONF_DIR="/${homedir}/hp/etc/hadoop"
</code>```

The Spark version I am using is 2.1.0 & Hadoop is 2.7.3

Also I am using the default Spark Interpreter Configuration(so Spark is set to run in Local mode)

Am I missing something here?

PS : I am able to connect to spark from the Terminal using spark-shell

答:
solved it by adding this line at the top in file common.sh
 in dir  zeppelin-0.6.1  then bin

open common.sh
and add command in the top of file set :

unset CLASSPATH

Body:
I have installed Zeppelin 0.7.1. When I tried to execute the Example spark program(which was available with Zeppelin Tutorial notebook), I am getting the following error

java.lang.NullPointerException
    at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:38)
    at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:33)
    at org.apache.zeppelin.spark.SparkInterpreter.createSparkContext_2(SparkInterpreter.java:391)
    at org.apache.zeppelin.spark.SparkInterpreter.createSparkContext(SparkInterpreter.java:380)
    at org.apache.zeppelin.spark.SparkInterpreter.getSparkContext(SparkInterpreter.java:146)
    at org.apache.zeppelin.spark.SparkInterpreter.open(SparkInterpreter.java:828)
    at org.apache.zeppelin.interpreter.LazyOpenInterpreter.open(LazyOpenInterpreter.java:70)
    at org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:483)
    at org.apache.zeppelin.scheduler.Job.run(Job.java:175)
    at org.apache.zeppelin.scheduler.FIFOScheduler$1.run(FIFOScheduler.java:139)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

I have also setup the config file(zeppelin-env.sh) to point to my Spark installation & Hadoop configuration directory

export SPARK_HOME="/${homedir}/sk"
export HADOOP_CONF_DIR="/${homedir}/hp/etc/hadoop"

The Spark version I am using is 2.1.0 & Hadoop is 2.7.3

Also I am using the default Spark Interpreter Configuration(so Spark is set to run in Local mode)

Am I missing something here?

PS : I am able to connect to spark from the Terminal using spark-shell


问:
Android toolbar not getting its background transparent
I have a layout with a toolbar and a navigation drawer:

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@android:color/transparent"
          android:fitsSystemWindows="true"
          android:orientation="vertical"
          tools:context="com.my.app.GUI.MainActivity">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/mainBackground"
    android:contentInsetEnd="0dp"
    android:contentInsetLeft="0dp"
    android:contentInsetRight="0dp"
    android:contentInsetStart="0dp"
    app:contentInsetEnd="0dp"
    app:contentInsetLeft="0dp"
    app:contentInsetRight="0dp"
    app:contentInsetStart="0dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent">

        <FrameLayout
            android:id="@+id/frameLayoutTitleBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:padding="10dp">

            <ImageView
                android:id="@+id/imageViewHamburger"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:srcCompat="@drawable/icon_hamburger_menu"/>

            <TextView
                android:id="@+id/textViewToolbarTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/transparent"
                android:gravity="center"
                android:text="TITLE"
                android:textColor="@android:color/white"
                android:textSize="@dimen/very_large_font_size"/>

        </FrameLayout>

        <ImageView
            android:id="@+id/imageViewToolbarRightSide"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/frameLayoutTitleBar"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/frameLayoutTitleBar"
            android:layout_marginRight="10dp"
            android:visibility="invisible"
            app:srcCompat="@drawable/icon_hamburger_menu"/>

        <View
            android:id="@+id/viewTitleUnderLine"
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:layout_alignParentBottom="true"
            android:background="@color/secondaryBackground"/>

    </RelativeLayout>

</android.support.v7.widget.Toolbar>

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
</FrameLayout>
</LinearLayout>
</code>```

This all layout is later then added as an include to another layout which includes the layout for the navigation drawer.

In my code I'm setting the images, strings and also the toolbar's background.
The background is set like this:

```<code>public static void setTitleBarBackgroundColor(int color)
{
    if(toolBar != null)
    {
        toolBar.setBackgroundColor(color);
    }
}
...
MyToolBarClass.setTitleBarBackgroundColor(getResources().getColor(android.R.color.transparent));
</code>```

When invoking this, the color does change but instead of being transparent, the toolbar (or something else) is changing to some color similar to gray and I can also see 3 faded icons of 2 people like the old MSN messenger icon, a chat icon and a wheel settings icon, which probably came with the toolbar. If I'm setting the color of the toolbar to something else then there's no problem and it's being set to that color.

Why won't the toolbar background change to transparent so I can see what's below it?

答: I have finally realized that the toolbar is indeed getting transparent, but the problem is that the content window is below it as can be seen by the layout I've written.. the content window is below it as it's inside a LinearLayout. After changing the LinearLayout to a FrameLayout which means the tool bar is now on top of the content and not above it, everything worked

Body:
I have a layout with a toolbar and a navigation drawer:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@android:color/transparent"
          android:fitsSystemWindows="true"
          android:orientation="vertical"
          tools:context="com.my.app.GUI.MainActivity">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/mainBackground"
    android:contentInsetEnd="0dp"
    android:contentInsetLeft="0dp"
    android:contentInsetRight="0dp"
    android:contentInsetStart="0dp"
    app:contentInsetEnd="0dp"
    app:contentInsetLeft="0dp"
    app:contentInsetRight="0dp"
    app:contentInsetStart="0dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent">

        <FrameLayout
            android:id="@+id/frameLayoutTitleBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:padding="10dp">

            <ImageView
                android:id="@+id/imageViewHamburger"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:srcCompat="@drawable/icon_hamburger_menu"/>

            <TextView
                android:id="@+id/textViewToolbarTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/transparent"
                android:gravity="center"
                android:text="TITLE"
                android:textColor="@android:color/white"
                android:textSize="@dimen/very_large_font_size"/>

        </FrameLayout>

        <ImageView
            android:id="@+id/imageViewToolbarRightSide"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/frameLayoutTitleBar"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/frameLayoutTitleBar"
            android:layout_marginRight="10dp"
            android:visibility="invisible"
            app:srcCompat="@drawable/icon_hamburger_menu"/>

        <View
            android:id="@+id/viewTitleUnderLine"
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:layout_alignParentBottom="true"
            android:background="@color/secondaryBackground"/>

    </RelativeLayout>

</android.support.v7.widget.Toolbar>

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
</FrameLayout>
</LinearLayout>

This all layout is later then added as an include to another layout which includes the layout for the navigation drawer.

In my code I'm setting the images, strings and also the toolbar's background.
The background is set like this:

public static void setTitleBarBackgroundColor(int color)
{
    if(toolBar != null)
    {
        toolBar.setBackgroundColor(color);
    }
}
...
MyToolBarClass.setTitleBarBackgroundColor(getResources().getColor(android.R.color.transparent));

When invoking this, the color does change but instead of being transparent, the toolbar (or something else) is changing to some color similar to gray and I can also see 3 faded icons of 2 people like the old MSN messenger icon, a chat icon and a wheel settings icon, which probably came with the toolbar. If I'm setting the color of the toolbar to something else then there's no problem and it's being set to that color.

Why won't the toolbar background change to transparent so I can see what's below it?


问:
Can I have a UISearchBar be its own .inputAccessoryView?
I need simple text input to aid in data filtering.  Ideally I'd like to keep a strong reference to a UISearchBar, and when the user taps "Search", then this searchBar would becomeFirstResponder() and I would set

self.searchBar.inputAccessoryView = self.searchBar

But that doesn't seem to work.  The .searchBar is generally not in the view controller's view hierarchy, and is something I would just hope to attach to the keyboard.

Otherwise I'll think of another approach.  Ultimately I'm just trying to have text input that I can see while editing, and that should be attached to the toolbar.  Ideally with an .inputAccessoryView so I don't have to bother with keyboard notifications / animations

Does anyone know if this is possible?

答:
If I understand you correctly, you want to use the search bar both for triggering a keyboard and for showing the search term entered by the user, but do not want to always have the search bar on-screen but have it activated via a "Search" button.

That's not possible with a single UISearchBar, but you can just use two of them:

Add one as subview to your view controller and hide it (bar1), and use the second as inputAccessoryView (bar2); you should become delegate of both search bars.

When the user presses the "Search" button make bar1 become first responder, handle its events via the delegate protocol, and update the bar2 accordingly.

Prevent the user from directly entering text in bar2 by blocking it
with the shouldChangeTextIn delegate method. Other events that are
received in bar2 could be forwarded to bar1 where this makes sense for you.

To get you started, here's some code for the basic setup (which would go in e.g. viewDidLoad):

```<code>self.dummySearchBar = UISearchBar()
dummySearchBar.isHidden = true
dummySearchBar.delegate = self

self.visibleSearchBar = UISearchBar()
visibleSearchBar.delegate = self
dummySearchBar.inputAccessoryView = visibleSearchBar
</code>```

Then, in your "Search" button handler, let the keyboard with the attached search bar appear like this:

```<code>dummySearchBar.becomeFirstResponder()
</code>```

Note: I have a similar setup in a project but for simplicity I use  UITextFields instead of UISearchBars; still, I think the basic approach should work with UISearchBars as well.

Body:
If I understand you correctly, you want to use the search bar both for triggering a keyboard and for showing the search term entered by the user, but do not want to always have the search bar on-screen but have it activated via a "Search" button.

That's not possible with a single UISearchBar, but you can just use two of them:

Add one as subview to your view controller and hide it (bar1), and use the second as inputAccessoryView (bar2); you should become delegate of both search bars.

When the user presses the "Search" button make bar1 become first responder, handle its events via the delegate protocol, and update the bar2 accordingly.

Prevent the user from directly entering text in bar2 by blocking it
with the shouldChangeTextIn delegate method. Other events that are
received in bar2 could be forwarded to bar1 where this makes sense for you.

To get you started, here's some code for the basic setup (which would go in e.g. viewDidLoad):

self.dummySearchBar = UISearchBar()
dummySearchBar.isHidden = true
dummySearchBar.delegate = self

self.visibleSearchBar = UISearchBar()
visibleSearchBar.delegate = self
dummySearchBar.inputAccessoryView = visibleSearchBar

Then, in your "Search" button handler, let the keyboard with the attached search bar appear like this:

dummySearchBar.becomeFirstResponder()

Note: I have a similar setup in a project but for simplicity I use  UITextFields instead of UISearchBars; still, I think the basic approach should work with UISearchBars as well.


问:
How to GRANT permissions to a SQL role to create and manage temp tables
I'd like to grant permissions to a SQL role to create a temp table #foo and grant permissions to do anything with that table (SELECT, INSERT and DELETE). How is it possible if the table #foo is not created (the user that belongs to this role will create and manage it)?

Thanks

NOTE: If possible, the solution should work with both SQL 2008 and SQL Azure.

答:
I am not sure about Azure, but ...

If you explicitly create a table in the tempdb, it persists across sessions, but will be cleaned out upon server reboot.

```<code>create table tempdb..authors (au_id char(11))
</code>```

If you create a ##TempTable it is globally visible, but it also ends with the creator's session.

Body:
I am not sure about Azure, but ...

If you explicitly create a table in the tempdb, it persists across sessions, but will be cleaned out upon server reboot.

create table tempdb..authors (au_id char(11))

If you create a ##TempTable it is globally visible, but it also ends with the creator's session.


问:
Need script to run function over infinite rows
I tried to create an array formula to run a specific function over an infinite number of rows i.e. each time a new row is created in the google spreadsheet, the formula should run for that new line as well. However I have come the conclusion that I need script for this, and that an array function will not do the job.

My initial spreadsheet has a row on data and essentially what I need is the following: if colum BC="x" (starting on row 3) then find the largest value in the range of columns R:AI. I had tried the following as a formula:

=ArrayFormula(if(BC3:BC="x",MAX(R3:AI3),"")
)

However clearly this did not work and I can obviously see why - whilst the array does take into account all values in column BC starting with BC3, it will only ever return the max value from range R3:AI3.

I also tried:

=ArrayFormula(if(BC3:BC="x",MAX(R3:AI),"")
)

But this then returns the highest value for the entire range R3:AI, and again the same value in each row in column BC.

So I think an array formula is not suitable - could anybody help with a script to perform this function?

答:
You can still pull this off with an ArrayFormula you just have to make use of a few other functions, namely ROW() and INDIRECT()

```<code>=ARRAYFORMULA(IF(BC3:BC="x", MAX(INDIRECT("R" & ROW() & ":A" & ROW()))))
</code>```

EDIT

Apparently the above approach won't work as certain formulas such as INDIRECT operate independently of the ARRAYFORMULA they are nested in. The closest I was able to get to a solution was this:

```<code>=ARRAYFORMULA(IF(BC3:BC="x", "=MAXA(R"&ROW(BC3:BC)&":A"&ROW(BC3:BC)&")",""))
</code>```

I wasn't able to get it to work but its as far as I got. It looks like you may need a script after all.

Body:
You can still pull this off with an ArrayFormula you just have to make use of a few other functions, namely ROW() and INDIRECT()

=ARRAYFORMULA(IF(BC3:BC="x", MAX(INDIRECT("R" & ROW() & ":A" & ROW()))))

EDIT

Apparently the above approach won't work as certain formulas such as INDIRECT operate independently of the ARRAYFORMULA they are nested in. The closest I was able to get to a solution was this:

=ARRAYFORMULA(IF(BC3:BC="x", "=MAXA(R"&ROW(BC3:BC)&":A"&ROW(BC3:BC)&")",""))

I wasn't able to get it to work but its as far as I got. It looks like you may need a script after all.