问:
more virtualizing stack panel height/slowness issues
I need a scrollviewer around a virtualizing stackpanel populated by an items control.  Clearly the height is infinity and that's why it's not virtualizing.  Why?

```<code><Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <ScrollViewer>
        <ItemsControl ItemsSource="{Binding InterestingHosts}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel IsItemsHost="True" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <TextBlock FontSize="14"><TextBlock Text="{Binding Host.HostName}" FontWeight="Bold" FontSize="18" /> (<TextBlock Text="{Binding Host.IPAddress}" />)</TextBlock>
                        <StackPanel>
                            <StackPanel.Style>
                                <Style TargetType="StackPanel">
                                    <Setter Property="Margin" Value="10" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding LoggedOnUsers.Count}" Value="0">
                                            <Setter Property="Visibility" Value="Collapsed" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </StackPanel.Style>
                            <TextBlock Text="The follow domain and/or enterprise admins are logged on to the host: "/>
                            <DataGrid AutoGenerateColumns="False" IsReadOnly="True" ItemsSource="{Binding LoggedOnUsers}">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Width="200" Binding="{Binding Domain}" Header="Domain"/>
                                    <DataGridTextColumn Width="200" Binding="{Binding Name}" Header="Username"/>
                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>
                        <StackPanel>
                            <StackPanel.Style>
                                <Style TargetType="StackPanel">
                                    <Setter Property="Margin" Value="10" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Processes.Count}" Value="0">
                                            <Setter Property="Visibility" Value="Collapsed" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </StackPanel.Style>
                            <TextBlock Text="The follow domain and/or enterprise admins are running processes on the host: "/>
                            <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Processes}" IsReadOnly="True">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Width="200" Header="Name" IsReadOnly="False" Binding="{Binding Name}"/>
                                    <DataGridTextColumn Width="200" Binding="{Binding Username}" Header="Username" />
                                    <DataGridTextColumn Binding="{Binding ID}" Header="ID" />
                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>
                        <StackPanel>
                            <StackPanel.Style>
                                <Style TargetType="StackPanel">
                                    <Setter Property="Margin" Value="10" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Services.Count}" Value="0">
                                            <Setter Property="Visibility" Value="Collapsed" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </StackPanel.Style>
                            <TextBlock Text="The follow domain and/or enterprise admins are authenticated for services on the host: "/>
                            <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Services}" IsReadOnly="True">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="Name" Binding="{Binding Name}" />
                                    <DataGridTextColumn Header="Username" Binding="{Binding Username}" />
                                    <DataGridTextColumn Header="Start Mode" Binding="{Binding StartMode}" />
                                    <DataGridTextColumn Header="State" Binding="{Binding State}" />
                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ScrollViewer>
</Grid>
</code>```

答:
Take a look at this answer. There's more to making an ItemsControl Virtualizing than just setting the VirtualizingStackPanel

Basically, put the ScrollViewer in your ItemsControl Template around your ItemsPresenter, and set VirtualizingStackPanel.IsVirtualizing="True" and ScrollViewer.CanContentScroll="True" on your ItemsControl

Body:
I need a scrollviewer around a virtualizing stackpanel populated by an items control.  Clearly the height is infinity and that's why it's not virtualizing.  Why?

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <ScrollViewer>
        <ItemsControl ItemsSource="{Binding InterestingHosts}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel IsItemsHost="True" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <TextBlock FontSize="14"><TextBlock Text="{Binding Host.HostName}" FontWeight="Bold" FontSize="18" /> (<TextBlock Text="{Binding Host.IPAddress}" />)</TextBlock>
                        <StackPanel>
                            <StackPanel.Style>

                                </Style>
                            </StackPanel.Style>
                            <TextBlock Text="The follow domain and/or enterprise admins are logged on to the host: "/>
                            <DataGrid AutoGenerateColumns="False" IsReadOnly="True" ItemsSource="{Binding LoggedOnUsers}">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Width="200" Binding="{Binding Domain}" Header="Domain"/>
                                    <DataGridTextColumn Width="200" Binding="{Binding Name}" Header="Username"/>
                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>
                        <StackPanel>
                            <StackPanel.Style>

                                </Style>
                            </StackPanel.Style>
                            <TextBlock Text="The follow domain and/or enterprise admins are running processes on the host: "/>
                            <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Processes}" IsReadOnly="True">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Width="200" Header="Name" IsReadOnly="False" Binding="{Binding Name}"/>
                                    <DataGridTextColumn Width="200" Binding="{Binding Username}" Header="Username" />
                                    <DataGridTextColumn Binding="{Binding ID}" Header="ID" />
                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>
                        <StackPanel>
                            <StackPanel.Style>

                                </Style>
                            </StackPanel.Style>
                            <TextBlock Text="The follow domain and/or enterprise admins are authenticated for services on the host: "/>
                            <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Services}" IsReadOnly="True">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="Name" Binding="{Binding Name}" />
                                    <DataGridTextColumn Header="Username" Binding="{Binding Username}" />
                                    <DataGridTextColumn Header="Start Mode" Binding="{Binding StartMode}" />
                                    <DataGridTextColumn Header="State" Binding="{Binding State}" />
                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ScrollViewer>
</Grid>


来源: stackexchange

问:
How to read 2 Kafka topics sequentially in one consumer class using spring boot?
I have 2 Kafka topics A and B. I want that every time when my consumer starts up, it goes to topic A first. Topic A contains information about topic B, and I'll depend on that information to fetch data from topic B.

So essentially I need to read topic A first before going to topic B, and I just need to do this once upon every restart of my program.

Things I can think of like:

```<code>@KafkaListener(topics = {"A" , "B"})
</code>```

Or:

```<code>@KafkaListener(topics = "A")
public void receive() {}

@KafkaListener(topics = "B")
public void receive() {}
</code>```

Both don't guarantee the sequence of reading.

How can I enforce my program to read topic A first, and only go to topic B after finishing the latest updates on topic A?

答:
Use something like this...

@KafkaListener(id = "bReceiver", autoStartup = "false, topics = "B")
public void receive() {}
```

<p>Set the <code>idleEventInterval</code> and add</p>

<pre class="lang-java prettyprint-override"><code>@Autowired
KafkaListenerEndpointRegistry registry;

@EventListener(condition = "event.listenerId == 'aReceiver`)
public void eventListener(ListenerContainerIdleEvent event) {
    this.registry.getListenerContainer("aReceiver").stop(() -> { });
    this.registry.getListenerContainer("bReceiver").start();
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have 2 Kafka topics A and B. I want that every time when my consumer starts up, it goes to topic A first. Topic A contains information about topic B, and I'll depend on that information to fetch data from topic B.

So essentially I need to read topic A first before going to topic B, and I just need to do this once upon every restart of my program.

Things I can think of like:

@KafkaListener(topics = {"A" , "B"})

Or:

@KafkaListener(topics = "A")
public void receive() {}

@KafkaListener(topics = "B")
public void receive() {}

Both don't guarantee the sequence of reading.

How can I enforce my program to read topic A first, and only go to topic B after finishing the latest updates on topic A?

Body:
Use something like this...

@KafkaListener(id = "bReceiver", autoStartup = "false, topics = "B")
public void receive() {}

Set the idleEventInterval and add

@Autowired
KafkaListenerEndpointRegistry registry;

@EventListener(condition = "event.listenerId == 'aReceiver`)
public void eventListener(ListenerContainerIdleEvent event) {
    this.registry.getListenerContainer("aReceiver").stop(() -> { });
    this.registry.getListenerContainer("bReceiver").start();
}


问:
How to change axis tick label spacing on python graph?
I have the following formula:

```<code>import matplotlib.pyplot as plt
import mplleaflet
import pandas as pd
import numpy as np

ax = plt.gca()
datamax.plot(kind='line',x='Date',y='Data_Value',color='red',ax=ax)
datamin.plot(kind='line',x='Date',y='Data_Value', color='blue',ax=ax)
plt.ylabel("Temperature (degrees C)",color='navy')
plt.xlabel("Date",color='navy')
plt.title('Record high and low temperatures by day (2005-2014)', alpha=1.0,color='brown')
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15),
          fancybox=False,labels=['Record high','Record low'])
#ax.set_xticks(ax.get_xticks()[::2])
plt.show()
</code>```

However, I want to change the spacing of the tick labels so that either all of the tick labels are on the X-axis (they are currently too crammed and overlapping!).

Another possibility would be to display only each year on the X-axis (2005-2014, thus with 10 axis labels).

My output currently looks like this:

The dataframe datamax looks like this:

```<code>  Date           ID Element  Data_Value
0     2005-01-01  USW00094889    TMAX         156
1     2005-01-02  USW00094889    TMAX         139
2     2005-01-03  USW00094889    TMAX         133
3     2005-01-04  USW00094889    TMAX          39
4     2005-01-05  USW00094889    TMAX          33
5     2005-01-06  USW00094889    TMAX           0
6     2005-01-07  USW00094889    TMAX           6
7     2005-01-08  USW00094889    TMAX          17
8     2005-01-09  USW00094889    TMAX          28
9     2005-01-10  USW00094889    TMAX          44
10    2005-01-11  USW00094889    TMAX          44
11    2005-01-12  USW00094889    TMAX         139
12    2005-01-13  USW00094889    TMAX         161
13    2005-01-14  USW00094889    TMAX         150
14    2005-01-15  USW00094889    TMAX         -33
15    2005-01-16  USW00094889    TMAX         -33
16    2005-01-17  USW00094889    TMAX         -50
17    2005-01-18  USW00094889    TMAX         -33
18    2005-01-19  USW00094889    TMAX          11
19    2005-01-20  USW00094889    TMAX          11
20    2005-01-21  USW00094889    TMAX         -39
21    2005-01-22  USW00094889    TMAX         -72
22    2005-01-23  USW00094889    TMAX         -44
23    2005-01-24  USW00094889    TMAX          11
24    2005-01-25  USW00094889    TMAX          28
25    2005-01-26  USW00094889    TMAX          28
26    2005-01-27  USW00094889    TMAX           6
27    2005-01-28  USW00094889    TMAX         -11
28    2005-01-29  USW00094889    TMAX          17
29    2005-01-30  USW00094889    TMAX          28
...          ...          ...     ...         ...
3603  2014-11-13  USW00094889    TMAX          39
3604  2014-11-14  USW00094889    TMAX          33
3605  2014-11-15  USW00094889    TMAX          28
3606  2014-11-16  USW00094889    TMAX          28
3607  2014-11-17  USW00094889    TMAX          17
3608  2014-11-18  USW00094889    TMAX          11
3609  2014-11-19  USW00094889    TMAX          11
3610  2014-11-20  USW00094889    TMAX           6
3611  2014-11-21  USW00094889    TMAX         -10
3612  2014-11-22  USW00094889    TMAX         106
3613  2014-11-23  USW00094889    TMAX         156
3614  2014-11-24  USW00094889    TMAX         172
3615  2014-11-25  USW00094889    TMAX         172
3616  2014-11-26  USW00094889    TMAX          28
3617  2014-11-27  USW00094889    TMAX          39
3618  2014-11-28  USW00094889    TMAX          22
3619  2014-11-29  USW00094889    TMAX         117
3620  2014-11-30  USW00094889    TMAX         178
3621  2014-12-01  USW00094889    TMAX         172
3622  2014-12-02  USW00094889    TMAX          33
3623  2014-12-03  USW00094889    TMAX          61
3624  2014-12-04  USW00094889    TMAX          50
3625  2014-12-05  USW00094889    TMAX          50
3626  2014-12-06  USW00094889    TMAX          67
3627  2014-12-07  USW00094889    TMAX          67
3628  2014-12-08  USW00094889    TMAX          72
3629  2014-12-09  USW00094889    TMAX          56
3630  2014-12-10  USW00094889    TMAX          50
3631  2014-12-11  USW00094889    TMAX          61
3632  2014-12-12  USW00094889    TMAX          50

[3631 rows x 4 columns]
</code>```

And the dataframe datamin like this:

```<code>     Date           ID Element  Data_Value
0     2005-01-01  USC00200032    TMIN         -56
1     2005-01-02  USC00200032    TMIN         -56
2     2005-01-03  USC00200032    TMIN           0
3     2005-01-04  USC00200032    TMIN         -39
4     2005-01-05  USC00200032    TMIN         -94
5     2005-01-06  USC00200032    TMIN        -106
6     2005-01-07  USC00200032    TMIN        -111
7     2005-01-08  USC00200032    TMIN        -100
8     2005-01-09  USC00200032    TMIN         -67
9     2005-01-10  USC00200032    TMIN         -56
10    2005-01-11  USC00200032    TMIN         -22
11    2005-01-12  USC00200032    TMIN         -17
12    2005-01-13  USC00200032    TMIN         -83
13    2005-01-14  USC00200032    TMIN        -128
14    2005-01-15  USC00200032    TMIN        -144
15    2005-01-16  USC00200032    TMIN        -150
16    2005-01-17  USC00200032    TMIN        -189
17    2005-01-18  USC00200032    TMIN        -217
18    2005-01-19  USC00200228    TMIN        -300
19    2005-01-20  USC00200032    TMIN        -156
20    2005-01-21  USC00200032    TMIN        -178
21    2005-01-22  USC00200032    TMIN        -178
22    2005-01-23  USC00200032    TMIN        -250
23    2005-01-24  USC00200032    TMIN        -267
24    2005-01-25  USC00200032    TMIN        -228
25    2005-01-26  USC00200032    TMIN        -206
26    2005-01-27  USC00200032    TMIN        -239
27    2005-01-28  USC00200032    TMIN        -250
28    2005-01-29  USC00200032    TMIN        -222
29    2005-01-30  USC00200228    TMIN        -217
...          ...          ...     ...         ...
3603  2014-11-13  USC00200032    TMIN         -71
3604  2014-11-14  USC00200032    TMIN         -78
3605  2014-11-15  USC00200032    TMIN         -94
3606  2014-11-16  USC00200032    TMIN         -72
3607  2014-11-17  USC00200032    TMIN        -106
3608  2014-11-18  USC00200032    TMIN        -144
3609  2014-11-19  USC00200032    TMIN        -128
3610  2014-11-20  USC00200032    TMIN        -122
3611  2014-11-21  USC00200032    TMIN        -182
3612  2014-11-22  USC00200032    TMIN        -172
3613  2014-11-23  USC00200032    TMIN        -100
3614  2014-11-24  USC00200032    TMIN          -5
3615  2014-11-25  USC00200032    TMIN         -33
3616  2014-11-26  USC00200032    TMIN         -67
3617  2014-11-27  USC00200032    TMIN         -82
3618  2014-11-28  USC00200032    TMIN        -133
3619  2014-11-29  USC00200032    TMIN        -106
3620  2014-11-30  USC00200032    TMIN         -56
3621  2014-12-01  USC00200032    TMIN         -88
3622  2014-12-02  USC00200032    TMIN         -99
3623  2014-12-03  USC00200032    TMIN         -71
3624  2014-12-04  USC00200032    TMIN         -77
3625  2014-12-05  USC00200032    TMIN         -61
3626  2014-12-06  USC00200032    TMIN         -50
3627  2014-12-07  USC00200032    TMIN         -78
3628  2014-12-08  USC00200032    TMIN         -78
3629  2014-12-09  USC00200032    TMIN         -39
3630  2014-12-10  USC00200032    TMIN         -72
3631  2014-12-11  USC00200032    TMIN         -88
3632  2014-12-12  USC00200032    TMIN         -78

[3631 rows x 4 columns]
</code>```

答:
Option 1: rotate the labels. In this way, you "gain" some space.

```<code>import matplotlib.pyplot as plt
import numpy as np

x=["Monday","Tuesday","Wednesday","Thursday","Fryday","Saturday","Sunday"]
y=np.linspace(1,100,7)

fig,ax = plt.subplots()
ax.plot(x,y)
ax.tick_params(axis='x', rotation=45)
</code>```

Option 2: personalize your labels.

```<code>ax.plot(x,y)
ax.set_xticklabels(['M','T','W','R','F','S','N'])
fig.savefig("/Users/Alessandro/Desktop/2.png")
</code>```

Option 3: diminish label frequency.

```<code>ax.plot(x,y)
ax.set_xticks([0,2,4,6])
ax.set_xticklabels(['M','W','F','N'])
</code>```

Option 4: diminish ticklabel size.

```<code>ax.plot(x,y)
ax.xaxis.set_tick_params(labelsize=8)
</code>```

Option 5: enlarge figure size.

```<code>fig,ax = plt.subplots(figsize=(8,4))

ax.plot(x,y)
</code>```

Body:
I have the following formula:

import matplotlib.pyplot as plt
import mplleaflet
import pandas as pd
import numpy as np

ax = plt.gca()
datamax.plot(kind='line',x='Date',y='Data_Value',color='red',ax=ax)
datamin.plot(kind='line',x='Date',y='Data_Value', color='blue',ax=ax)
plt.ylabel("Temperature (degrees C)",color='navy')
plt.xlabel("Date",color='navy')
plt.title('Record high and low temperatures by day (2005-2014)', alpha=1.0,color='brown')
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15),
          fancybox=False,labels=['Record high','Record low'])
#ax.set_xticks(ax.get_xticks()[::2])
plt.show()

However, I want to change the spacing of the tick labels so that either all of the tick labels are on the X-axis (they are currently too crammed and overlapping!).

Another possibility would be to display only each year on the X-axis (2005-2014, thus with 10 axis labels).

My output currently looks like this:

The dataframe datamax looks like this:

  Date           ID Element  Data_Value
0     2005-01-01  USW00094889    TMAX         156
1     2005-01-02  USW00094889    TMAX         139
2     2005-01-03  USW00094889    TMAX         133
3     2005-01-04  USW00094889    TMAX          39
4     2005-01-05  USW00094889    TMAX          33
5     2005-01-06  USW00094889    TMAX           0
6     2005-01-07  USW00094889    TMAX           6
7     2005-01-08  USW00094889    TMAX          17
8     2005-01-09  USW00094889    TMAX          28
9     2005-01-10  USW00094889    TMAX          44
10    2005-01-11  USW00094889    TMAX          44
11    2005-01-12  USW00094889    TMAX         139
12    2005-01-13  USW00094889    TMAX         161
13    2005-01-14  USW00094889    TMAX         150
14    2005-01-15  USW00094889    TMAX         -33
15    2005-01-16  USW00094889    TMAX         -33
16    2005-01-17  USW00094889    TMAX         -50
17    2005-01-18  USW00094889    TMAX         -33
18    2005-01-19  USW00094889    TMAX          11
19    2005-01-20  USW00094889    TMAX          11
20    2005-01-21  USW00094889    TMAX         -39
21    2005-01-22  USW00094889    TMAX         -72
22    2005-01-23  USW00094889    TMAX         -44
23    2005-01-24  USW00094889    TMAX          11
24    2005-01-25  USW00094889    TMAX          28
25    2005-01-26  USW00094889    TMAX          28
26    2005-01-27  USW00094889    TMAX           6
27    2005-01-28  USW00094889    TMAX         -11
28    2005-01-29  USW00094889    TMAX          17
29    2005-01-30  USW00094889    TMAX          28
...          ...          ...     ...         ...
3603  2014-11-13  USW00094889    TMAX          39
3604  2014-11-14  USW00094889    TMAX          33
3605  2014-11-15  USW00094889    TMAX          28
3606  2014-11-16  USW00094889    TMAX          28
3607  2014-11-17  USW00094889    TMAX          17
3608  2014-11-18  USW00094889    TMAX          11
3609  2014-11-19  USW00094889    TMAX          11
3610  2014-11-20  USW00094889    TMAX           6
3611  2014-11-21  USW00094889    TMAX         -10
3612  2014-11-22  USW00094889    TMAX         106
3613  2014-11-23  USW00094889    TMAX         156
3614  2014-11-24  USW00094889    TMAX         172
3615  2014-11-25  USW00094889    TMAX         172
3616  2014-11-26  USW00094889    TMAX          28
3617  2014-11-27  USW00094889    TMAX          39
3618  2014-11-28  USW00094889    TMAX          22
3619  2014-11-29  USW00094889    TMAX         117
3620  2014-11-30  USW00094889    TMAX         178
3621  2014-12-01  USW00094889    TMAX         172
3622  2014-12-02  USW00094889    TMAX          33
3623  2014-12-03  USW00094889    TMAX          61
3624  2014-12-04  USW00094889    TMAX          50
3625  2014-12-05  USW00094889    TMAX          50
3626  2014-12-06  USW00094889    TMAX          67
3627  2014-12-07  USW00094889    TMAX          67
3628  2014-12-08  USW00094889    TMAX          72
3629  2014-12-09  USW00094889    TMAX          56
3630  2014-12-10  USW00094889    TMAX          50
3631  2014-12-11  USW00094889    TMAX          61
3632  2014-12-12  USW00094889    TMAX          50

[3631 rows x 4 columns]

And the dataframe datamin like this:

     Date           ID Element  Data_Value
0     2005-01-01  USC00200032    TMIN         -56
1     2005-01-02  USC00200032    TMIN         -56
2     2005-01-03  USC00200032    TMIN           0
3     2005-01-04  USC00200032    TMIN         -39
4     2005-01-05  USC00200032    TMIN         -94
5     2005-01-06  USC00200032    TMIN        -106
6     2005-01-07  USC00200032    TMIN        -111
7     2005-01-08  USC00200032    TMIN        -100
8     2005-01-09  USC00200032    TMIN         -67
9     2005-01-10  USC00200032    TMIN         -56
10    2005-01-11  USC00200032    TMIN         -22
11    2005-01-12  USC00200032    TMIN         -17
12    2005-01-13  USC00200032    TMIN         -83
13    2005-01-14  USC00200032    TMIN        -128
14    2005-01-15  USC00200032    TMIN        -144
15    2005-01-16  USC00200032    TMIN        -150
16    2005-01-17  USC00200032    TMIN        -189
17    2005-01-18  USC00200032    TMIN        -217
18    2005-01-19  USC00200228    TMIN        -300
19    2005-01-20  USC00200032    TMIN        -156
20    2005-01-21  USC00200032    TMIN        -178
21    2005-01-22  USC00200032    TMIN        -178
22    2005-01-23  USC00200032    TMIN        -250
23    2005-01-24  USC00200032    TMIN        -267
24    2005-01-25  USC00200032    TMIN        -228
25    2005-01-26  USC00200032    TMIN        -206
26    2005-01-27  USC00200032    TMIN        -239
27    2005-01-28  USC00200032    TMIN        -250
28    2005-01-29  USC00200032    TMIN        -222
29    2005-01-30  USC00200228    TMIN        -217
...          ...          ...     ...         ...
3603  2014-11-13  USC00200032    TMIN         -71
3604  2014-11-14  USC00200032    TMIN         -78
3605  2014-11-15  USC00200032    TMIN         -94
3606  2014-11-16  USC00200032    TMIN         -72
3607  2014-11-17  USC00200032    TMIN        -106
3608  2014-11-18  USC00200032    TMIN        -144
3609  2014-11-19  USC00200032    TMIN        -128
3610  2014-11-20  USC00200032    TMIN        -122
3611  2014-11-21  USC00200032    TMIN        -182
3612  2014-11-22  USC00200032    TMIN        -172
3613  2014-11-23  USC00200032    TMIN        -100
3614  2014-11-24  USC00200032    TMIN          -5
3615  2014-11-25  USC00200032    TMIN         -33
3616  2014-11-26  USC00200032    TMIN         -67
3617  2014-11-27  USC00200032    TMIN         -82
3618  2014-11-28  USC00200032    TMIN        -133
3619  2014-11-29  USC00200032    TMIN        -106
3620  2014-11-30  USC00200032    TMIN         -56
3621  2014-12-01  USC00200032    TMIN         -88
3622  2014-12-02  USC00200032    TMIN         -99
3623  2014-12-03  USC00200032    TMIN         -71
3624  2014-12-04  USC00200032    TMIN         -77
3625  2014-12-05  USC00200032    TMIN         -61
3626  2014-12-06  USC00200032    TMIN         -50
3627  2014-12-07  USC00200032    TMIN         -78
3628  2014-12-08  USC00200032    TMIN         -78
3629  2014-12-09  USC00200032    TMIN         -39
3630  2014-12-10  USC00200032    TMIN         -72
3631  2014-12-11  USC00200032    TMIN         -88
3632  2014-12-12  USC00200032    TMIN         -78

[3631 rows x 4 columns]

Body:
Option 1: rotate the labels. In this way, you "gain" some space.

import matplotlib.pyplot as plt
import numpy as np

x=["Monday","Tuesday","Wednesday","Thursday","Fryday","Saturday","Sunday"]
y=np.linspace(1,100,7)

fig,ax = plt.subplots()
ax.plot(x,y)
ax.tick_params(axis='x', rotation=45)

Option 2: personalize your labels.

ax.plot(x,y)
ax.set_xticklabels(['M','T','W','R','F','S','N'])
fig.savefig("/Users/Alessandro/Desktop/2.png")

Option 3: diminish label frequency.

ax.plot(x,y)
ax.set_xticks([0,2,4,6])
ax.set_xticklabels(['M','W','F','N'])

Option 4: diminish ticklabel size.

ax.plot(x,y)
ax.xaxis.set_tick_params(labelsize=8)

Option 5: enlarge figure size.

fig,ax = plt.subplots(figsize=(8,4))

ax.plot(x,y)


问:
Is there any solution to save the space when use the docx-mailmerage?
I am using the Python docx-mailmerge library to create a docx.
But something is not like my hope.

My code:

```<code>from mailmerge import MailMerge

template='example.docx'
document_1 = MailMerge(template)
document_1.merge(misscount='>>> CSS Network Latencies\n    CRS-4678: Successful get misscount 30 for Cluster Synchronization Services.')
document_1.write('aaa.docx')
</code>```

The ouptput in the docx is:

But my hope is:

I want the second line start with 4 space. What should i do?

答: Have you tried to use '\t' after '\n' to tab the new line?</p>

Body:
I am using the Python docx-mailmerge library to create a docx.
But something is not like my hope.

My code:

from mailmerge import MailMerge

template='example.docx'
document_1 = MailMerge(template)
document_1.merge(misscount='>>> CSS Network Latencies\n    CRS-4678: Successful get misscount 30 for Cluster Synchronization Services.')
document_1.write('aaa.docx')

The ouptput in the docx is:

But my hope is:

I want the second line start with 4 space. What should i do?


问:
Hide Lanscape mode in Android phone in NativeScript Angular
Hide Lanscape mode in Android phone in NativeScript Angular

1.Allow both orientations in  Android tablet

2.Restrict Landscape and allow only portriat version in phone

答: Use deviceType from platforms to know which device type the app is running. If it's Tablet then use nativescript orientation plugin to lock the orientation to portrait.


问:
ValueError: invalid literal for int() with base 10: 'Mumbai to Dubai'
When i perform this command

```<code>valueReturned = int(request.form.get("name"))
</code>```

where this name is a select tag, i am getting a value error stating

ValueError: invalid literal for int() with base 10: 'Mumbai to Dubai'

This is my select code.

```<code><select name="name">
        {% for flight in flights %}
        <option id="{{flight.id}}">{{flight.origin}} to {{flight.destination}}</option>
        {% endfor %}
    </select>
</code>```

And what does the compiler selects from the  tag.

答:
Since your option doesn't contain a value attribute, the text of the option is used as the value. I think you meant meant to use value rather than id

```<code>        <option value="{{flight.id}}">{{flight.origin}} to {{flight.destination}}</option>
</code>```

Body:
When i perform this command

valueReturned = int(request.form.get("name"))

where this name is a select tag, i am getting a value error stating

ValueError: invalid literal for int() with base 10: 'Mumbai to Dubai'

This is my select code.

<select name="name">
        {% for flight in flights %}
        <option id="{{flight.id}}">{{flight.origin}} to {{flight.destination}}</option>
        {% endfor %}
    </select>

And what does the compiler selects from the  tag.

Body:
Since your option doesn't contain a value attribute, the text of the option is used as the value. I think you meant meant to use value rather than id

        <option value="{{flight.id}}">{{flight.origin}} to {{flight.destination}}</option>


问:
is it Possible to Disable input in teams app for my chatbot
I'm building a chatbot with microsofts bot framework, nodejs. There are features in the chatbot where at times api call is made to external systems and the user has to wait for about a minute.
I was wondering would it be possible to block/disable the input box of teams during such times.If not many users start talking to the bot when in the back-end API fetch is still running for the previous dialog,which produces undesirable results.

Any idea, disable or maybe block the user any other way???

答: There's no out of the box way to do this, that I know of, but middleware might help, like if you stored the state of the conversation, and rejected any messages earlier in the middleware pipeline during this period, or maybe sent an "error" message, something like that. Otherwise, have a look at the very latest release of bot framework (4.9), which has some better abilities for "adaptive dialogs" - see https://github.com/microsoft/botbuilder-dotnet/releases </p>


问:
Why do I get permission denied In my Firestore app code but the Firestore console test works?
I have been having some trouble understanding firestore rules.

I have wrote the following rules in my Firestore database. When I run a test in the console using an authenticated user ID to update a restaurant entity, the test passes with success. However when I try to make this call in Kotlin using the SDK, after authenticating with Google sign in, I get Permission Denied. What have I missed?

```<code>    function userIsAdmin(restaurantId) {
      return get(/databases/$(database)/documents/restaurants/$(restaurantId)/users/$(request.auth.uid)).data.role == "Owner";
    }

    match /restaurants/{restaurantId} {
        allow read: if true;
        allow write: if userIsAdmin(restaurantId);
    }

    match /restaurants/{restaurantId}/menus/{menuId} {
      allow read: if true;
      allow write: if true;
    }

    match /restaurants/{restaurantId}/users/{userId} {
      allow read: if true;
      allow write: if true;
    }
  }
}
</code>```

User entity on firestore:

Query in Kotlin:

```<code>firestore.collection(COLLECTION_RESTAURANT)
.document("aXTSlGphPbzAXRInHBIg")
.update(KEY_RESTAURANT_NAME, "New restaurant")
.await()
</code>```

答:
As mentioned by @DougStevenson on the comments, the problem is that you are storing native Google Auth IDs instead of Firebase Auth user IDs in your users collection, and Firebase Auth user IDs when querying, because of that the uid on the query will either come out as null or undefined and cause these permission issues.

If you change the firestore records to use Firebase Auth user Ids on your users collection, it will fix the issue.

Body:
I have been having some trouble understanding firestore rules.

I have wrote the following rules in my Firestore database. When I run a test in the console using an authenticated user ID to update a restaurant entity, the test passes with success. However when I try to make this call in Kotlin using the SDK, after authenticating with Google sign in, I get Permission Denied. What have I missed?

    function userIsAdmin(restaurantId) {
      return get(/databases/$(database)/documents/restaurants/$(restaurantId)/users/$(request.auth.uid)).data.role == "Owner";
    }

    match /restaurants/{restaurantId} {
        allow read: if true;
        allow write: if userIsAdmin(restaurantId);
    }

    match /restaurants/{restaurantId}/menus/{menuId} {
      allow read: if true;
      allow write: if true;
    }

    match /restaurants/{restaurantId}/users/{userId} {
      allow read: if true;
      allow write: if true;
    }
  }
}

User entity on firestore:

Query in Kotlin:

firestore.collection(COLLECTION_RESTAURANT)
.document("aXTSlGphPbzAXRInHBIg")
.update(KEY_RESTAURANT_NAME, "New restaurant")
.await()


问:
I can`t enable dotfuscator in Xamarin.Android porject
I'm developing cross platform app using Xamarin.Forms and I'm having problems to use dotfuscator in my Xamarin.Android project. This is my development environment:

Windows 10 Pro

Visual Studio Professional 2017 (version 15.9.22)

Dotfuscator Community 5.44

Android project:

Application:

Compile using Android version: Android 9.0 (Pie)

Android Manifest:

Minimum Android version: Android 5.0 (API Level 21 - Lollipop)

Target Android version: Android 9.0 (API Level 28 - Pie)

Xamarin.Forms 4.6

I'm following this guide: Integrating Dotfuscator's Protection into Your Xamarin Apps in Visual Studio

Import the Targets File

In the Import the Targets File step I had to add an <Import> tag with the relative path to targets file. When I opened the project file, I could see that the tag already existed:

```<code><Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</code>```

I checked that the file existed in this path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.CSharp.targets. I didn't change this tag, because I thought it was a correct configuration.

Set MSBuild Properties

In the Set MSBuild Properties step I added a <PropertyGroup> tag. I added it as the first node of <Project> root node.

```<code><Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <DotfuscatorXamarinConfigFileName>DotfuscatorConfig.xml</DotfuscatorXamarinConfigFileName>
    <DotfuscatorXamarinCliPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe</DotfuscatorXamarinCliPath>
    <DotfuscatorXamarinGenerateNewConfigFile>true</DotfuscatorXamarinGenerateNewConfigFile>
    <!-- Enable Dotfuscator for Release -->
    <DotfuscatorXamarinEnabled Condition="'$(Configuration)' == 'Release'">true</DotfuscatorXamarinEnabled>
  </PropertyGroup>
  ...
</code>```

Add Dotfuscator Config File to Project

In the Add Dotfuscator Config File to Project step I added this <ItemGroup> tag, after the last <ItemGroup> one:

```<code>  ...
  </ItemGroup>
  <ItemGroup>
    <None Include="DotfuscatorConfig.xml" />
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
</code>```

After these 3 steps, I saved the project file, closed it in the editor and reloaded the project. Then, I selected the Android project as StartUp project, and Release in the configuration combobox. After that I built the project and this is the output:

```<code>2>  MyApp.Android -> C:\..\MyApp\MyApp.Android\bin\Release\MyApp.Android.dll
2>  No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
</code>```

Nothing about the lines described in the 5th step of Build the Project with Dotfuscator's Protection:

```<code>2>  Running Dotfuscator with a new config file based on project references...
2>  Finished running Dotfuscator with a new config file.
2>C:\code\protected-bugsweeper\BugSweeper\BugSweeper.Android\BugSweeper.Android.csproj : warning : A new Dotfuscator config file was generated because it did not exist: 'DotfuscatorConfig.xml'.
</code>```

And DotfuscatorConfig.xml file was not created.

What am I doing wrong?

答:
The <Import> tag you mention in Import the Targets File is different than the one the instructions tell you to add. In other words, there should be multiple <Import> tags in your project file by the time you finish editing it.

The tag you mention is part of a normal Xamarin project file, and unrelated to Dotfuscator. It refers to a .targets file that is already part of your Visual Studio installation. Please do not remove or modify this tag.

The tag the instructions tell you to add is the one that imports Dotfuscator into your project. It refers to the PreEmptive.Dotfuscator.Xamarin.targets file you downloaded in an earlier step. For instance, if you extracted the ZIP file's contents into the same directory as your .csproj, then add:

```<code><Import Project="PreEmptive.Dotfuscator.Xamarin.targets" />
</code>```

immediately before the closing </Project> tag. If you extracted the ZIP contents into a different directory, then change the part between the " marks to be the relative path from your .csproj directory to the file.

(Note: I am a developer on Dotfuscator, and am answering this question in that capacity.)

Body:
I'm developing cross platform app using Xamarin.Forms and I'm having problems to use dotfuscator in my Xamarin.Android project. This is my development environment:

Windows 10 Pro

Visual Studio Professional 2017 (version 15.9.22)

Dotfuscator Community 5.44

Android project:

Application:

Compile using Android version: Android 9.0 (Pie)

Android Manifest:

Minimum Android version: Android 5.0 (API Level 21 - Lollipop)

Target Android version: Android 9.0 (API Level 28 - Pie)

Xamarin.Forms 4.6

I'm following this guide: Integrating Dotfuscator's Protection into Your Xamarin Apps in Visual Studio

Import the Targets File

In the Import the Targets File step I had to add an <Import> tag with the relative path to targets file. When I opened the project file, I could see that the tag already existed:

<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />

I checked that the file existed in this path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.CSharp.targets. I didn't change this tag, because I thought it was a correct configuration.

Set MSBuild Properties

In the Set MSBuild Properties step I added a <PropertyGroup> tag. I added it as the first node of <Project> root node.

<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <DotfuscatorXamarinConfigFileName>DotfuscatorConfig.xml</DotfuscatorXamarinConfigFileName>
    <DotfuscatorXamarinCliPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe</DotfuscatorXamarinCliPath>
    <DotfuscatorXamarinGenerateNewConfigFile>true</DotfuscatorXamarinGenerateNewConfigFile>

    <DotfuscatorXamarinEnabled Condition="'$(Configuration)' == 'Release'">true</DotfuscatorXamarinEnabled>
  </PropertyGroup>
  ...

Add Dotfuscator Config File to Project

In the Add Dotfuscator Config File to Project step I added this <ItemGroup> tag, after the last <ItemGroup> one:

  ...
  </ItemGroup>
  <ItemGroup>
    <None Include="DotfuscatorConfig.xml" />
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>

After these 3 steps, I saved the project file, closed it in the editor and reloaded the project. Then, I selected the Android project as StartUp project, and Release in the configuration combobox. After that I built the project and this is the output:

2>  MyApp.Android -> C:\..\MyApp\MyApp.Android\bin\Release\MyApp.Android.dll
2>  No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.

Nothing about the lines described in the 5th step of Build the Project with Dotfuscator's Protection:

2>  Running Dotfuscator with a new config file based on project references...
2>  Finished running Dotfuscator with a new config file.
2>C:\code\protected-bugsweeper\BugSweeper\BugSweeper.Android\BugSweeper.Android.csproj : warning : A new Dotfuscator config file was generated because it did not exist: 'DotfuscatorConfig.xml'.

And DotfuscatorConfig.xml file was not created.

What am I doing wrong?

Body:
The <Import> tag you mention in Import the Targets File is different than the one the instructions tell you to add. In other words, there should be multiple <Import> tags in your project file by the time you finish editing it.

The tag you mention is part of a normal Xamarin project file, and unrelated to Dotfuscator. It refers to a .targets file that is already part of your Visual Studio installation. Please do not remove or modify this tag.

The tag the instructions tell you to add is the one that imports Dotfuscator into your project. It refers to the PreEmptive.Dotfuscator.Xamarin.targets file you downloaded in an earlier step. For instance, if you extracted the ZIP file's contents into the same directory as your .csproj, then add:

<Import Project="PreEmptive.Dotfuscator.Xamarin.targets" />

immediately before the closing </Project> tag. If you extracted the ZIP contents into a different directory, then change the part between the " marks to be the relative path from your .csproj directory to the file.

(Note: I am a developer on Dotfuscator, and am answering this question in that capacity.)


问:
REACT TypeError: Class extends value undefined is not a constructor or null
I'm new to React and I'm trying to build a static web page to practice.
When I try to open the web page I get this error referring to the App.js file in src folder.

Error1-Image

App.js code below:

```<code>import React from 'react';
import Task from './task.js'
import Navbar from './js/Navbar';
import MainPage from './js/MainPage';
import './App.css';

const tasks = [];
tasks.push(new Task("finish lab07", 0, 1, "AWI", "2020-05-27", 0));
tasks.push(new Task("finish ", 1, 1, "AWI", "2020/05/30", 0));
tasks.push(new Task("start studyng", 0, 1, "FL", "2020/06/01", 0));

const projects = [{id: 0, projectName: "AWI"}, {id: 1, projectName: "FL"}];

class App extends React.Component() {
     constructor(props){
     super(props);
     this.state = {tasks: tasks};
     }

     render(){
          return (
               <>
                  <Navbar id="navbar" />
                  <MainPage projects={projects} tasks={tasks}/>
               </>
          );
     }
}

export default App;
</code>```

If I try to import React, {Component} from 'react'
and I use "extends Component" instead of "extends React.Component" I get this error:

Error2-Image

Thank you for your help!

答:
This is how you should do:

```<code>class Welcome extends React.Component {
    render() {
        return <h1>Hello, {this.props.name}</h1>;
    }
}
</code>```

You are calling the Component with Component() class which is why it is causing the error.

Body:
I'm new to React and I'm trying to build a static web page to practice.
When I try to open the web page I get this error referring to the App.js file in src folder.

Error1-Image

App.js code below:

import React from 'react';
import Task from './task.js'
import Navbar from './js/Navbar';
import MainPage from './js/MainPage';
import './App.css';

const tasks = [];
tasks.push(new Task("finish lab07", 0, 1, "AWI", "2020-05-27", 0));
tasks.push(new Task("finish ", 1, 1, "AWI", "2020/05/30", 0));
tasks.push(new Task("start studyng", 0, 1, "FL", "2020/06/01", 0));

const projects = [{id: 0, projectName: "AWI"}, {id: 1, projectName: "FL"}];

class App extends React.Component() {
     constructor(props){
     super(props);
     this.state = {tasks: tasks};
     }

     render(){
          return (
               <>
                  <Navbar id="navbar" />
                  <MainPage projects={projects} tasks={tasks}/>
               </>
          );
     }
}

export default App;

If I try to import React, {Component} from 'react'
and I use "extends Component" instead of "extends React.Component" I get this error:

Error2-Image

Thank you for your help!

Body:
This is how you should do:

class Welcome extends React.Component {
    render() {
        return <h1>Hello, {this.props.name}</h1>;
    }
}

You are calling the Component with Component() class which is why it is causing the error.


问:
React router v4 asynchronous route handling
Consider the following two routes

```<code><Route path="/:username" component={Profile} />
<Route path="*" component={NotFound} />
</code>```

I'm aware the path /:username would always match even for a user that does not exist so I am trying the following

```<code><Route
  path="/:username"
  render={({ match }) => {
    return userExists(match.params.username) ?
      <Profile match={match} /> : <NotFound match={match} />;
  }}
/>
</code>```

userExists() being a function that returns true or false after making a call to the database to check if the user with the given username exists.

Am I handling this in the completely wrong way? It feels funny to have such a function in my route handler.

答: Since userExists is defined to be asynchronous, I don't see how the code is "correct" at all, that is, I don't think it will work, and I don't think the original question has yet been solved.

ContentLicense: CC BY-SA 3.0

Body:
Consider the following two routes

<Route path="/:username" component={Profile} />
<Route path="*" component={NotFound} />

I'm aware the path /:username would always match even for a user that does not exist so I am trying the following

<Route
  path="/:username"
  render={({ match }) => {
    return userExists(match.params.username) ?
      <Profile match={match} /> : <NotFound match={match} />;
  }}
/>

userExists() being a function that returns true or false after making a call to the database to check if the user with the given username exists.

Am I handling this in the completely wrong way? It feels funny to have such a function in my route handler.


答:
try using "\t" instead of 4 space. the effect is the same but this might work.
like so:

'>>> CSS Network Latencies\n\tCRS-4678: Successful get misscount 30 for Cluster Synchronization Services.'

Title: Is there any solution to save the space when use the docx-mailmerage?


问:
How to remove the first character of a variable
HI All,

In my js file i am getting an array of records (negetive values ) like this

```<code>deletedDetailIds = $.map(eformDetailIds, function(e) { return e < 0 ? e : null; });
</code>```

For example the deletedDetailIds = -1234,-1235,-1256 like this.

Now i have to create an array and add these values with out negetive symbols. like

newArray = 1234,1235,1256.

Please help me in this

答:
Try this</p>

```<code>deletedDetailIds = $.map(eformDetailIds, function(e) { return e < 0 ? e : null; });
var total = 0;
$.each(deletedDetailIds, function(a, b){
 total += Math.abs(b)
});
</code>```

Body:
HI All,

In my js file i am getting an array of records (negetive values ) like this

deletedDetailIds = $.map(eformDetailIds, function(e) { return e < 0 ? e : null; });

For example the deletedDetailIds = -1234,-1235,-1256 like this.

Now i have to create an array and add these values with out negetive symbols. like

newArray = 1234,1235,1256.

Please help me in this

Body:
Try this

deletedDetailIds = $.map(eformDetailIds, function(e) { return e < 0 ? e : null; });
var total = 0;
$.each(deletedDetailIds, function(a, b){
 total += Math.abs(b)
});


问:
binlog not recording DML statement in mysqlcluster
I have created a MySQL NDB Cluster consisting of 2 data node, 1 mgm node and 1 mysqld for testing. Also i have created a slave for NDB to INNODB replication. My binlog are not recording DML statement because of which i am not able to do Point in time recovery for NDB CLuster and also DML Statements are not replicating on slave, only the tables are being created with no row entries.

ndb_binlog_index table on master is empty with no entries.

Below is my.cnf file for ndb-cluster mysqld.

```<code>[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

log_bin=/home/binlog/ndbcluster-bin

log-bin-index=ndbcluster-bin.index

binlog_format=ROW

user=mysql

#NDB

ndbcluster

ndb-nodeid=101

default-storage-engine=NDB

ndb-connectstring=192.168.56.101,192.168.56.102

[mysql_cluster]

ndb-connectstring=192.168.56.101,192.168.56.102

[ndb_mgmd]

config-dir=/usr/mysql-cluster

config-file=/etc/config.ini
</code>```

Version Information

```<code> version                  | 8.0.20-cluster                       |

| version_comment          | MySQL Cluster Community Server - GPL |
</code>```

binlog variables as shown

```<code>mysql> show variables like '%bin%';

+------------------------------------------------+-------------------------------------+
| Variable_name                                  | Value                               |
+------------------------------------------------+-------------------------------------+
| bind_address                                   | *                                   |

| binlog_cache_size                              | 32768                               |

| binlog_checksum                                | CRC32                               |

| binlog_direct_non_transactional_updates        | OFF                                 |

| binlog_encryption                              | OFF                                 |

| binlog_error_action                            | ABORT_SERVER                        |

| binlog_expire_logs_seconds                     | 2592000                             |

| binlog_format                                  | ROW                                 |

| binlog_group_commit_sync_delay                 | 0                                   |

| binlog_group_commit_sync_no_delay_count        | 0                                   |

| binlog_gtid_simple_recovery                    | ON                                  |

| binlog_max_flush_queue_time                    | 0                                   |

| binlog_order_commits                           | ON                                  |

| binlog_rotate_encryption_master_key_at_startup | OFF                                 |

| binlog_row_event_max_size                      | 8192                                |

| binlog_row_image                               | FULL                                |

| binlog_row_metadata                            | MINIMAL                             |

| binlog_row_value_options                       |                                     |

| binlog_rows_query_log_events                   | OFF                                 |

| binlog_stmt_cache_size                         | 32768                               |

| binlog_transaction_compression                 | OFF                                 |

| binlog_transaction_compression_level_zstd      | 3                                   |

| binlog_transaction_dependency_history_size     | 25000                               |

| binlog_transaction_dependency_tracking         | COMMIT_ORDER                        |

| innodb_api_enable_binlog                       | OFF                                 |

| log_bin                                        | ON                                  |

| log_bin_basename                               | /home/binlog/ndbcluster-bin         |

| log_bin_index                                  | /var/lib/mysql/ndbcluster-bin.index |

| log_bin_trust_function_creators                | OFF                                 |

| log_bin_use_v1_row_events                      | OFF                                 |

| log_statements_unsafe_for_binlog               | ON                                  |

| max_binlog_cache_size                          | 18446744073709547520                |

| max_binlog_size                                | 1073741824                          |

| max_binlog_stmt_cache_size                     | 18446744073709547520                |

| mysqlx_bind_address                            | *                                   |

| ndb_log_bin                                    | OFF                                 |

| ndb_log_binlog_index                           | ON                                  |

| ndb_report_thresh_binlog_epoch_slip            | 10                                  |

| ndb_report_thresh_binlog_mem_usage             | 10                                  |

| ndbinfo_database                               | ndbinfo                             |

| ndbinfo_max_bytes                              | 0                                   |

| ndbinfo_max_rows                               | 10                                  |

| ndbinfo_offline                                | OFF                                 |

| ndbinfo_show_hidden                            | OFF                                 |

| ndbinfo_table_prefix                           | ndb$                                |

| ndbinfo_version                                | 524308                              |

| sql_log_bin                                    | ON                                  |

| sync_binlog                                    | 1                                   |

+------------------------------------------------+-------------------------------------+
48 rows in set (0.01 sec)

</code>```

Below a test for showing no entries being made in binlog.

```<code>mysql> show binlog events in 'ndbcluster-bin.000003';

+-----------------------+-----+----------------+-----------+-------------+-------------------------------------------+
| Log_name              | Pos | Event_type     | Server_id | End_log_pos | Info                                      |
+-----------------------+-----+----------------+-----------+-------------+-------------------------------------------+
| ndbcluster-bin.000003 |   4 | Format_desc    |         1 |         125 | Server ver: 8.0.20-cluster, Binlog ver: 4 |
| ndbcluster-bin.000003 | 125 | Previous_gtids |         1 |         156 |                                           |
+-----------------------+-----+----------------+-----------+-------------+-------------------------------------------+
2 rows in set (0.00 sec)

mysql>

mysql> create database test;

Query OK, 1 row affected (0.08 sec)

mysql> use test

Database changed

mysql>

mysql> create table employees (staff_no int(10));

Query OK, 0 rows affected, 1 warning (0.29 sec)

mysql>

mysql> show binlog events in 'ndbcluster-bin.000003';

+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
| Log_name              | Pos | Event_type     | Server_id | End_log_pos | Info                                                               |
+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
| ndbcluster-bin.000003 |   4 | Format_desc    |         1 |         125 | Server ver: 8.0.20-cluster, Binlog ver: 4                          |
| ndbcluster-bin.000003 | 125 | Previous_gtids |         1 |         156 |                                                                    |
| ndbcluster-bin.000003 | 156 | Anonymous_Gtid |         1 |         233 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                               |
| ndbcluster-bin.000003 | 233 | Query          |         1 |         341 | create database test /* xid=84 */                                  |
| ndbcluster-bin.000003 | 341 | Anonymous_Gtid |         1 |         418 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                               |
| ndbcluster-bin.000003 | 418 | Query          |         1 |         547 | use `test`; create table employees (staff_no int(10)) /* xid=92 */ |
+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
6 rows in set (0.00 sec)

mysql>

mysql> insert into employees values (1234), (3242);

Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> commit;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> select * from employees;

+----------+
| staff_no |
+----------+
|     3242 |
|     1234 |
+----------+
2 rows in set (0.00 sec)

mysql> show binlog events in 'ndbcluster-bin.000003';

+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
| Log_name              | Pos | Event_type     | Server_id | End_log_pos | Info                                                               |
+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
| ndbcluster-bin.000003 |   4 | Format_desc    |         1 |         125 | Server ver: 8.0.20-cluster, Binlog ver: 4                          |
| ndbcluster-bin.000003 | 125 | Previous_gtids |         1 |         156 |                                                                    |
| ndbcluster-bin.000003 | 156 | Anonymous_Gtid |         1 |         233 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                               |
| ndbcluster-bin.000003 | 233 | Query          |         1 |         341 | create database test /* xid=84 */                                  |
| ndbcluster-bin.000003 | 341 | Anonymous_Gtid |         1 |         418 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                               |
| ndbcluster-bin.000003 | 418 | Query          |         1 |         547 | use `test`; create table employees (staff_no int(10)) /* xid=92 */ |
+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
6 rows in set (0.00 sec)

mysql> use mysql

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql>

mysql> select * from ndb_binlog_index;

Empty set (0.00 sec)

</code>```

I have also checked binlog with mysqlbinlog  but it also doesnt show any insert entries.

```<code>{
[root@ndb-cluster-mysqld1 binlog]# mysqlbinlog -v --base64-output=DECODE-ROWS ndbcluster-bin.000003

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#200528 14:20:15 server id 1  end_log_pos 125 CRC32 0x3ad8779c  Start: binlog v 4, server v 8.0.20-cluster created 200528 14:20:15
# Warning: this binlog is either in use or was not closed properly.
# at 125
#200528 14:20:15 server id 1  end_log_pos 156 CRC32 0x71313f0a  Previous-GTIDs
# [empty]
# at 156
#200528 14:21:12 server id 1  end_log_pos 233 CRC32 0x0f5b463e  Anonymous_GTID  last_committed=0        sequence_number=1       rbr_only=no     original_committed_timestamp=1590655872244131   immediate_commit_timestamp=1590655872244131     transaction_length=185
# original_commit_timestamp=1590655872244131 (2020-05-28 14:21:12.244131 IST)
# immediate_commit_timestamp=1590655872244131 (2020-05-28 14:21:12.244131 IST)
/*!80001 SET @@session.original_commit_timestamp=1590655872244131*//*!*/;
/*!80014 SET @@session.original_server_version=80020*//*!*/;
/*!80014 SET @@session.immediate_server_version=80020*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 233
#200528 14:21:12 server id 1  end_log_pos 341 CRC32 0xb8313dcf  Query   thread_id=16    exec_time=0     error_code=0    Xid = 84
SET TIMESTAMP=1590655872/*!*/;
SET @@session.pseudo_thread_id=16/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1168113696/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb4 *//*!*/;
SET @@session.character_set_client=255,@@session.collation_connection=255,@@session.collation_server=255/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
/*!80011 SET @@session.default_collation_for_utf8mb4=255*//*!*/;
/*!80016 SET @@session.default_table_encryption=0*//*!*/;
create database test
/*!*/;
# at 341
#200528 14:22:35 server id 1  end_log_pos 418 CRC32 0x562df9ef  Anonymous_GTID  last_committed=1        sequence_number=2       rbr_only=no     original_committed_timestamp=1590655955983593   immediate_commit_timestamp=1590655955983593     transaction_length=206
# original_commit_timestamp=1590655955983593 (2020-05-28 14:22:35.983593 IST)
# immediate_commit_timestamp=1590655955983593 (2020-05-28 14:22:35.983593 IST)
/*!80001 SET @@session.original_commit_timestamp=1590655955983593*//*!*/;
/*!80014 SET @@session.original_server_version=80020*//*!*/;
/*!80014 SET @@session.immediate_server_version=80020*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 418
#200528 14:22:35 server id 1  end_log_pos 547 CRC32 0x8618cc05  Query   thread_id=16    exec_time=0     error_code=0    Xid = 92
use `test`/*!*/;
SET TIMESTAMP=1590655955/*!*/;
/*!80013 SET @@session.sql_require_primary_key=0*//*!*/;
create table employees (staff_no int(10))
/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

}
</code>```

Please help i am stuck on this since last 2 days.

Thanks.

答: This was resolved by adding ndb_log_bin=ON in my.cnf file since ndb_log_bin is disabled by default in mysql 8.0.16 and higher.</p>

Body:
I have created a MySQL NDB Cluster consisting of 2 data node, 1 mgm node and 1 mysqld for testing. Also i have created a slave for NDB to INNODB replication. My binlog are not recording DML statement because of which i am not able to do Point in time recovery for NDB CLuster and also DML Statements are not replicating on slave, only the tables are being created with no row entries.

ndb_binlog_index table on master is empty with no entries.

Below is my.cnf file for ndb-cluster mysqld.

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

log_bin=/home/binlog/ndbcluster-bin

log-bin-index=ndbcluster-bin.index

binlog_format=ROW

user=mysql

#NDB

ndbcluster

ndb-nodeid=101

default-storage-engine=NDB

ndb-connectstring=192.168.56.101,192.168.56.102

[mysql_cluster]

ndb-connectstring=192.168.56.101,192.168.56.102

[ndb_mgmd]

config-dir=/usr/mysql-cluster

config-file=/etc/config.ini

Version Information

 version                  | 8.0.20-cluster                       |

| version_comment          | MySQL Cluster Community Server - GPL |

binlog variables as shown

mysql> show variables like '%bin%';

+------------------------------------------------+-------------------------------------+
| Variable_name                                  | Value                               |
+------------------------------------------------+-------------------------------------+
| bind_address                                   | *                                   |

| binlog_cache_size                              | 32768                               |

| binlog_checksum                                | CRC32                               |

| binlog_direct_non_transactional_updates        | OFF                                 |

| binlog_encryption                              | OFF                                 |

| binlog_error_action                            | ABORT_SERVER                        |

| binlog_expire_logs_seconds                     | 2592000                             |

| binlog_format                                  | ROW                                 |

| binlog_group_commit_sync_delay                 | 0                                   |

| binlog_group_commit_sync_no_delay_count        | 0                                   |

| binlog_gtid_simple_recovery                    | ON                                  |

| binlog_max_flush_queue_time                    | 0                                   |

| binlog_order_commits                           | ON                                  |

| binlog_rotate_encryption_master_key_at_startup | OFF                                 |

| binlog_row_event_max_size                      | 8192                                |

| binlog_row_image                               | FULL                                |

| binlog_row_metadata                            | MINIMAL                             |

| binlog_row_value_options                       |                                     |

| binlog_rows_query_log_events                   | OFF                                 |

| binlog_stmt_cache_size                         | 32768                               |

| binlog_transaction_compression                 | OFF                                 |

| binlog_transaction_compression_level_zstd      | 3                                   |

| binlog_transaction_dependency_history_size     | 25000                               |

| binlog_transaction_dependency_tracking         | COMMIT_ORDER                        |

| innodb_api_enable_binlog                       | OFF                                 |

| log_bin                                        | ON                                  |

| log_bin_basename                               | /home/binlog/ndbcluster-bin         |

| log_bin_index                                  | /var/lib/mysql/ndbcluster-bin.index |

| log_bin_trust_function_creators                | OFF                                 |

| log_bin_use_v1_row_events                      | OFF                                 |

| log_statements_unsafe_for_binlog               | ON                                  |

| max_binlog_cache_size                          | 18446744073709547520                |

| max_binlog_size                                | 1073741824                          |

| max_binlog_stmt_cache_size                     | 18446744073709547520                |

| mysqlx_bind_address                            | *                                   |

| ndb_log_bin                                    | OFF                                 |

| ndb_log_binlog_index                           | ON                                  |

| ndb_report_thresh_binlog_epoch_slip            | 10                                  |

| ndb_report_thresh_binlog_mem_usage             | 10                                  |

| ndbinfo_database                               | ndbinfo                             |

| ndbinfo_max_bytes                              | 0                                   |

| ndbinfo_max_rows                               | 10                                  |

| ndbinfo_offline                                | OFF                                 |

| ndbinfo_show_hidden                            | OFF                                 |

| ndbinfo_table_prefix                           | ndb$                                |

| ndbinfo_version                                | 524308                              |

| sql_log_bin                                    | ON                                  |

| sync_binlog                                    | 1                                   |

+------------------------------------------------+-------------------------------------+
48 rows in set (0.01 sec)

Below a test for showing no entries being made in binlog.

mysql> show binlog events in 'ndbcluster-bin.000003';

+-----------------------+-----+----------------+-----------+-------------+-------------------------------------------+
| Log_name              | Pos | Event_type     | Server_id | End_log_pos | Info                                      |
+-----------------------+-----+----------------+-----------+-------------+-------------------------------------------+
| ndbcluster-bin.000003 |   4 | Format_desc    |         1 |         125 | Server ver: 8.0.20-cluster, Binlog ver: 4 |
| ndbcluster-bin.000003 | 125 | Previous_gtids |         1 |         156 |                                           |
+-----------------------+-----+----------------+-----------+-------------+-------------------------------------------+
2 rows in set (0.00 sec)

mysql>

mysql> create database test;

Query OK, 1 row affected (0.08 sec)

mysql> use test

Database changed

mysql>

mysql> create table employees (staff_no int(10));

Query OK, 0 rows affected, 1 warning (0.29 sec)

mysql>

mysql> show binlog events in 'ndbcluster-bin.000003';

+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
| Log_name              | Pos | Event_type     | Server_id | End_log_pos | Info                                                               |
+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
| ndbcluster-bin.000003 |   4 | Format_desc    |         1 |         125 | Server ver: 8.0.20-cluster, Binlog ver: 4                          |
| ndbcluster-bin.000003 | 125 | Previous_gtids |         1 |         156 |                                                                    |
| ndbcluster-bin.000003 | 156 | Anonymous_Gtid |         1 |         233 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                               |
| ndbcluster-bin.000003 | 233 | Query          |         1 |         341 | create database test /* xid=84 */                                  |
| ndbcluster-bin.000003 | 341 | Anonymous_Gtid |         1 |         418 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                               |
| ndbcluster-bin.000003 | 418 | Query          |         1 |         547 | use `test`; create table employees (staff_no int(10)) /* xid=92 */ |
+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
6 rows in set (0.00 sec)

mysql>

mysql> insert into employees values (1234), (3242);

Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> commit;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> select * from employees;

+----------+
| staff_no |
+----------+
|     3242 |
|     1234 |
+----------+
2 rows in set (0.00 sec)

mysql> show binlog events in 'ndbcluster-bin.000003';

+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
| Log_name              | Pos | Event_type     | Server_id | End_log_pos | Info                                                               |
+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
| ndbcluster-bin.000003 |   4 | Format_desc    |         1 |         125 | Server ver: 8.0.20-cluster, Binlog ver: 4                          |
| ndbcluster-bin.000003 | 125 | Previous_gtids |         1 |         156 |                                                                    |
| ndbcluster-bin.000003 | 156 | Anonymous_Gtid |         1 |         233 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                               |
| ndbcluster-bin.000003 | 233 | Query          |         1 |         341 | create database test /* xid=84 */                                  |
| ndbcluster-bin.000003 | 341 | Anonymous_Gtid |         1 |         418 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                               |
| ndbcluster-bin.000003 | 418 | Query          |         1 |         547 | use `test`; create table employees (staff_no int(10)) /* xid=92 */ |
+-----------------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------+
6 rows in set (0.00 sec)

mysql> use mysql

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql>

mysql> select * from ndb_binlog_index;

Empty set (0.00 sec)

I have also checked binlog with mysqlbinlog  but it also doesnt show any insert entries.

{
[root@ndb-cluster-mysqld1 binlog]# mysqlbinlog -v --base64-output=DECODE-ROWS ndbcluster-bin.000003

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#200528 14:20:15 server id 1  end_log_pos 125 CRC32 0x3ad8779c  Start: binlog v 4, server v 8.0.20-cluster created 200528 14:20:15
# Warning: this binlog is either in use or was not closed properly.
# at 125
#200528 14:20:15 server id 1  end_log_pos 156 CRC32 0x71313f0a  Previous-GTIDs
# [empty]
# at 156
#200528 14:21:12 server id 1  end_log_pos 233 CRC32 0x0f5b463e  Anonymous_GTID  last_committed=0        sequence_number=1       rbr_only=no     original_committed_timestamp=1590655872244131   immediate_commit_timestamp=1590655872244131     transaction_length=185
# original_commit_timestamp=1590655872244131 (2020-05-28 14:21:12.244131 IST)
# immediate_commit_timestamp=1590655872244131 (2020-05-28 14:21:12.244131 IST)
/*!80001 SET @@session.original_commit_timestamp=1590655872244131*//*!*/;
/*!80014 SET @@session.original_server_version=80020*//*!*/;
/*!80014 SET @@session.immediate_server_version=80020*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 233
#200528 14:21:12 server id 1  end_log_pos 341 CRC32 0xb8313dcf  Query   thread_id=16    exec_time=0     error_code=0    Xid = 84
SET TIMESTAMP=1590655872/*!*/;
SET @@session.pseudo_thread_id=16/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1168113696/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb4 *//*!*/;
SET @@session.character_set_client=255,@@session.collation_connection=255,@@session.collation_server=255/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
/*!80011 SET @@session.default_collation_for_utf8mb4=255*//*!*/;
/*!80016 SET @@session.default_table_encryption=0*//*!*/;
create database test
/*!*/;
# at 341
#200528 14:22:35 server id 1  end_log_pos 418 CRC32 0x562df9ef  Anonymous_GTID  last_committed=1        sequence_number=2       rbr_only=no     original_committed_timestamp=1590655955983593   immediate_commit_timestamp=1590655955983593     transaction_length=206
# original_commit_timestamp=1590655955983593 (2020-05-28 14:22:35.983593 IST)
# immediate_commit_timestamp=1590655955983593 (2020-05-28 14:22:35.983593 IST)
/*!80001 SET @@session.original_commit_timestamp=1590655955983593*//*!*/;
/*!80014 SET @@session.original_server_version=80020*//*!*/;
/*!80014 SET @@session.immediate_server_version=80020*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 418
#200528 14:22:35 server id 1  end_log_pos 547 CRC32 0x8618cc05  Query   thread_id=16    exec_time=0     error_code=0    Xid = 92
use `test`/*!*/;
SET TIMESTAMP=1590655955/*!*/;
/*!80013 SET @@session.sql_require_primary_key=0*//*!*/;
create table employees (staff_no int(10))
/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

}

Please help i am stuck on this since last 2 days.

Thanks.


问:
How do you pivot some columns into rows using sql or t-sql
Here is the table

```<code>Income|Expenses|Other|Department|Date

 2k   |      4k|  .5k|Marketing |2014-05-28
 52k  |      7k|  .1k|Sales     |2014-04-01
</code>```

Result

```<code>Description|Value|Department|Date

 Income    |   2k|Marketing |2014-05-28
 Expenses  |   4k|Marketing |2014-05-28
 Other     |  .5k|Marketing |2014-05-28
 Income    |  52k|Sales     |2014-04-01
 Expenses  |   7k|Sales     |2014-04-01
 Other     |  .1k|Sales     |2014-04-01
</code>```

Actually, I can use SELECT + UNION to get the result but the requirement is to use Pivot.

How to get this result using PIVOT function?

答:
you can use UNPIVOT

```<code>DECLARE @SampleData TABLE (Income VARCHAR(20), Expenses VARCHAR(20), Other VARCHAR(20), Department VARCHAR(20), Date [Date])
INSERT INTO @SampleData VALUES
('2k ', '4k','.5k','Marketing','2014-05-28'),
('52k', '7k','.1k','Sales    ','2014-04-01')

SELECT Description, Value, Department, Date
FROM @SampleData T
UNPIVOT ([Value] FOR [Description] IN ([Income], [Expenses], [Other])) AS UNPVT
</code>```

Result:

```<code>Description       Value                Department           Date
----------------- -------------------- -------------------- ----------
Income            2k                   Marketing            2014-05-28
Expenses          4k                   Marketing            2014-05-28
Other             .5k                  Marketing            2014-05-28
Income            52k                  Sales                2014-04-01
Expenses          7k                   Sales                2014-04-01
Other             .1k                  Sales                2014-04-01
</code>```

Body:
Here is the table

Income|Expenses|Other|Department|Date

 2k   |      4k|  .5k|Marketing |2014-05-28
 52k  |      7k|  .1k|Sales     |2014-04-01

Result

Description|Value|Department|Date

 Income    |   2k|Marketing |2014-05-28
 Expenses  |   4k|Marketing |2014-05-28
 Other     |  .5k|Marketing |2014-05-28
 Income    |  52k|Sales     |2014-04-01
 Expenses  |   7k|Sales     |2014-04-01
 Other     |  .1k|Sales     |2014-04-01

Actually, I can use SELECT + UNION to get the result but the requirement is to use Pivot.

How to get this result using PIVOT function?

Body:
you can use UNPIVOT

DECLARE @SampleData TABLE (Income VARCHAR(20), Expenses VARCHAR(20), Other VARCHAR(20), Department VARCHAR(20), Date [Date])
INSERT INTO @SampleData VALUES
('2k ', '4k','.5k','Marketing','2014-05-28'),
('52k', '7k','.1k','Sales    ','2014-04-01')

SELECT Description, Value, Department, Date
FROM @SampleData T
UNPIVOT ([Value] FOR [Description] IN ([Income], [Expenses], [Other])) AS UNPVT

Result:

Description       Value                Department           Date
----------------- -------------------- -------------------- ----------
Income            2k                   Marketing            2014-05-28
Expenses          4k                   Marketing            2014-05-28
Other             .5k                  Marketing            2014-05-28
Income            52k                  Sales                2014-04-01
Expenses          7k                   Sales                2014-04-01
Other             .1k                  Sales                2014-04-01


问:
Style / Satellite - Is it possible to have Two different aesthetics on different zoom levels?
I am using mapbox to develop a map for a project, the map is being programmed with a global zoom out view and markers that allow you to click and zoom into the area (unclick and zoom out), basically it toggles between two views or zoom distances.

I want the close up view to be the satellite imagery. But the satellite imagery is confusing on the global view - and it would be better to move from a Mapbox style (dark / light) then when you click on a pointer you zoom into the satellite imagery.

Do let me know if this functionality exists and if possible pointers on how to implent?

Thanks!
B

答: You can construct your style in Mapbox Studio as a non-satellite style, but then add Mapbox Satellite as a layer with min zoom set such that it only shows up once zoomed in.</p>


问:
how range functions works in creating ndarray?
How is this range function working here? It is generating an answer but I can't understand it it has created the resulted ndarray.

np.array([range(i, i + 3) for i in [2, 4, 6]])

答:
A range is a sequence of numbers. The function range normally accepts 1-3 params range(start, stop[, step]). In your case the step is ommited, thus the default 1 is applied. So it is creating ranges from a given number i to that number +3 → range(i, i + 3)

The list comprehension, makes that the given number i will iterate over the list [2,4,6], so you will create a list with 3 sublists: [range(2,2+3), range(4,4+3), range(6,6+3)] wich equals to [[2,3,4], [4,5,6], [6,7,8]].

Finally, all is wrapped as a numpy array and the output is → array([[2, 3, 4],[4, 5, 6],[6, 7, 8]])


问:
Configuring sessionAcknowledgeMode in DefaultMessageListenerContainer
I have a setup where I have to read a message from a queue in an ActiveMQ broker. Once the message is read I have to do a long-running operation on the message.

Due to this long-running operation on the message I want to acknowledge the message as soon as possible so the resources on the broker are released. The plan would be to execute the following steps once a message is received:

Get message from ActiveMQ

Insert message into DB

Acknowledge message

Do some long-running operation with the message

I've read about JMS and the different acknowledge modes, so before even trying to do that I decided to set up an application where I could try the different modes to understand how they are processes, unfortunately I cannot seem to get my desired output.

Following the information in this answer https://stackoverflow.com/a/10188078 as well as https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jms/listener/DefaultMessageListenerContainer.html I thought that by using AUTO_ACKNOWLEDGE the message would be acknowledged before my listener is even called, but if I throw an exception in the listener the message is redelivered.

I've tried both with and without setting the setSessionTransacted to true, but in both cases I get the same output. The message is redelivered when an exception is thrown in the JmsListener.

Configuration of JMS

```<code>    @Bean
    public ConnectionFactory connectionFactory() {
        ConnectionFactory connectionFactory =
                new ActiveMQConnectionFactory(jmsConfig.getBrokerUrl());

        return connectionFactory;
    }

    @Bean
    public JmsTemplate jmstemplate(){
        JmsTemplate jmsTemplate = new JmsTemplate();
        jmsTemplate.setConnectionFactory(connectionFactory());
        //jmsTemplate.setSessionTransacted(true);
        jmsTemplate.setDefaultDestinationName( jmsConfig.getQueueIn() );
        return jmsTemplate;
    }

    @Bean
    public JmsListenerContainerFactory jmsListenerContainerFactoryxxxx(
                    ConnectionFactory connectionFactory,
            DefaultJmsListenerContainerFactoryConfigurer configurer) {

        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        factory.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
        //factory.setConcurrency("1");
        factory.setSessionTransacted(true);

        configurer.configure(factory, connectionFactory);
        return factory;
    }
</code>```

JmsListener

```<code>@JmsListener(destination = "B1Q1", containerFactory = "jmsListenerContainerFactoryxxxx")
public  void receiveMessage(Message message) {
    try {
        TextMessage m = (TextMessage) message;
        String messageText = m.getText();

        int retryNum = message.getIntProperty("JMSXDeliveryCount");
        long s = message.getLongProperty("JMSTimestamp");

        Date d = new Date( s );

        String dbText = String.format("Retry %d. Message: %s", retryNum, messageText);

        if ( messageText.toLowerCase().contains("exception") ) {
            logger.info("Creating exception for retry: {}", retryNum);
            throw new RuntimeException();
        }
    } catch (JMSException e) {
        logger.error("Exception!!", e);
    }
}
</code>```

How should I change the code so that the message is not redelivered when an exception is thrown?

Going back to my application where I would be inserting the message into the DB. How could I acknowledge the message in by JmsListener after the message is inserted in the DB but before executing the long-running task?

答:
```<code>          factory.setSessionAcknowledgeMode(Tibjms.EXPLICIT_CLIENT_ACKNOWLEDGE);
          //factory.setSessionTransacted(false);// here it’s  not working
          factory.setTaskExecutor(new SimpleAsyncTaskExecutor("KDBMessageListener-"));
          configurer.configure(factory, connectionFactory);
          factory.setSessionTransacted(false); //post configure ,session transacted is working
</code>```

Body:
I have a setup where I have to read a message from a queue in an ActiveMQ broker. Once the message is read I have to do a long-running operation on the message.

Due to this long-running operation on the message I want to acknowledge the message as soon as possible so the resources on the broker are released. The plan would be to execute the following steps once a message is received:

Get message from ActiveMQ

Insert message into DB

Acknowledge message

Do some long-running operation with the message

I've read about JMS and the different acknowledge modes, so before even trying to do that I decided to set up an application where I could try the different modes to understand how they are processes, unfortunately I cannot seem to get my desired output.

Following the information in this answer https://stackoverflow.com/a/10188078 as well as https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jms/listener/DefaultMessageListenerContainer.html I thought that by using AUTO_ACKNOWLEDGE the message would be acknowledged before my listener is even called, but if I throw an exception in the listener the message is redelivered.

I've tried both with and without setting the setSessionTransacted to true, but in both cases I get the same output. The message is redelivered when an exception is thrown in the JmsListener.

Configuration of JMS

    @Bean
    public ConnectionFactory connectionFactory() {
        ConnectionFactory connectionFactory =
                new ActiveMQConnectionFactory(jmsConfig.getBrokerUrl());

        return connectionFactory;
    }

    @Bean
    public JmsTemplate jmstemplate(){
        JmsTemplate jmsTemplate = new JmsTemplate();
        jmsTemplate.setConnectionFactory(connectionFactory());
        //jmsTemplate.setSessionTransacted(true);
        jmsTemplate.setDefaultDestinationName( jmsConfig.getQueueIn() );
        return jmsTemplate;
    }

    @Bean
    public JmsListenerContainerFactory jmsListenerContainerFactoryxxxx(
                    ConnectionFactory connectionFactory,
            DefaultJmsListenerContainerFactoryConfigurer configurer) {

        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        factory.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
        //factory.setConcurrency("1");
        factory.setSessionTransacted(true);

        configurer.configure(factory, connectionFactory);
        return factory;
    }

JmsListener

@JmsListener(destination = "B1Q1", containerFactory = "jmsListenerContainerFactoryxxxx")
public  void receiveMessage(Message message) {
    try {
        TextMessage m = (TextMessage) message;
        String messageText = m.getText();

        int retryNum = message.getIntProperty("JMSXDeliveryCount");
        long s = message.getLongProperty("JMSTimestamp");

        Date d = new Date( s );

        String dbText = String.format("Retry %d. Message: %s", retryNum, messageText);

        if ( messageText.toLowerCase().contains("exception") ) {
            logger.info("Creating exception for retry: {}", retryNum);
            throw new RuntimeException();
        }
    } catch (JMSException e) {
        logger.error("Exception!!", e);
    }
}

How should I change the code so that the message is not redelivered when an exception is thrown?

Going back to my application where I would be inserting the message into the DB. How could I acknowledge the message in by JmsListener after the message is inserted in the DB but before executing the long-running task?


问:
How to check from which onResume the user is coming
I have a problem. The following Picture visualises my issue. We start in App 1 and press the button. Now we either get to see the screen of app2 or the setting screen. Now when i press the back button (marked as the red circle in app2 and settings) and we get back to the app1 screen. But what i wanna know is from what screen we get back to the app1 screen.

```<code>    @Override
        protected void onResume() {
            super.onResume();

        // if(from setting) {
            // do this
           }

            NfcManager manager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
            NfcAdapter adapter = manager.getDefaultAdapter();
            if (adapter != null && adapter.isEnabled()) {
                   Intent userHomeScreen = new Intent(getApplicationContext(), UserHomeActivity.class);
                    startActivity(userHomeScreen);

            }
        }

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nfc_setting);

        NfcManager manager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
        NfcAdapter adapter = manager.getDefaultAdapter();
        if (adapter != null && adapter.isEnabled()) {
            FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
            if (currentUser != null){
                Intent userHomeScreen = new Intent(getApplicationContext(), UserHomeActivity.class);
                startActivity(userHomeScreen);
            }else{
                Intent loginScreen = new Intent(getApplicationContext(), LoginActivity.class);
                startActivity(loginScreen);
            }
        }
        else {
            btn_nfc_navigate_setting = findViewById(R.id.btn_nfc_navigate_setting);

            btn_nfc_navigate_setting.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivity(new Intent(Settings.ACTION_NFC_SETTINGS));
                }
            });
        }
</code>```

答:
Use startActivityForResult()

From App1 to App2 or Setting:

```<code>int FLAG_APP2 = 1
Intent i = new Intent(this, App2.class);
startActivityForResult(i, FLAG_APP2);
</code>```

Then in App2 button back tapped:

```<code>finish();
</code>```

Then in App1 override onActivityResult():

```<code>@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == FLAG_APP2) {
        //here you know this is from App2 Screen
    }
}
</code>```

Body:
I have a problem. The following Picture visualises my issue. We start in App 1 and press the button. Now we either get to see the screen of app2 or the setting screen. Now when i press the back button (marked as the red circle in app2 and settings) and we get back to the app1 screen. But what i wanna know is from what screen we get back to the app1 screen.

    @Override
        protected void onResume() {
            super.onResume();

        // if(from setting) {
            // do this
           }

            NfcManager manager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
            NfcAdapter adapter = manager.getDefaultAdapter();
            if (adapter != null && adapter.isEnabled()) {
                   Intent userHomeScreen = new Intent(getApplicationContext(), UserHomeActivity.class);
                    startActivity(userHomeScreen);

            }
        }

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nfc_setting);

        NfcManager manager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
        NfcAdapter adapter = manager.getDefaultAdapter();
        if (adapter != null && adapter.isEnabled()) {
            FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
            if (currentUser != null){
                Intent userHomeScreen = new Intent(getApplicationContext(), UserHomeActivity.class);
                startActivity(userHomeScreen);
            }else{
                Intent loginScreen = new Intent(getApplicationContext(), LoginActivity.class);
                startActivity(loginScreen);
            }
        }
        else {
            btn_nfc_navigate_setting = findViewById(R.id.btn_nfc_navigate_setting);

            btn_nfc_navigate_setting.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivity(new Intent(Settings.ACTION_NFC_SETTINGS));
                }
            });
        }

Body:
Use startActivityForResult()

From App1 to App2 or Setting:

int FLAG_APP2 = 1
Intent i = new Intent(this, App2.class);
startActivityForResult(i, FLAG_APP2);

Then in App2 button back tapped:

finish();

Then in App1 override onActivityResult():

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == FLAG_APP2) {
        //here you know this is from App2 Screen
    }
}