我需要从元组列表中查找并删除重复项.基本上,我的结构是这样的:
List<Tuple<string, string>> myList = new List<Tuple<string, string>>();
****
private void FillStructure()
{
myList.Add(Tuple.Create<string, string>("A", "B"));
myList.Add(Tuple.Create<string, string>("A", "C"));
myList.Add(Tuple.Create<string, string>("C", "B"));
myList.Add(Tuple.Create<string, string>("C", "B")); // Duplicate
myList.Add(Tuple.Create<string, string>("A", "D"));
FindAndRemoveDuplicates(myList);
}
private void FindAndRemoveDuplicates(List<Tuple<string, string>> myList)
{
// how can I perform this ?
}
Run Code Online (Sandbox Code Playgroud)
我不能使用词典,因为我可以拥有相同的键但不同的值!先感谢您
我在使用s3-dist-cpAmazon EMR 上的命令时遇到问题。我想要实现的是在合并 S3 文件夹中的所有小文件时能够定义文件的名称。例子:
s3://bucket/event/v1/2017/11/06/10/event-1234.json
s3://bucket/event/v1/2017/11/06/10/event-4567.json
s3://bucket/event/v1/2017/11/06/10/event-7890.json
.... so on
Run Code Online (Sandbox Code Playgroud)
结果如下:
s3://test/test/event
Run Code Online (Sandbox Code Playgroud)
我能够合并上面的所有文件,但结果文件名是错误的。
命令是:
s3-dist-cp --src s3://bucket/event/v1/2017/11/06/10/ --dest s3://test/test/ --groupBy='.*(event).*' --targetSize=2048
Run Code Online (Sandbox Code Playgroud)
我想要达到的结果是:
s3://test/test/events.hourly.json
Run Code Online (Sandbox Code Playgroud)
如何更改目标文件名?
我是NAudio和C#的新手,我设法创建了一个简单的MP3播放器,你可以选择一个文件并播放它.它还有一个播放/暂停按钮.
我现在想添加一个搜索栏,但不知道如何做到这一点.波形样式的搜索条也可以吗?
openButton单击处理程序
private void openButton_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Audio File|*.mp3;";
if (open.ShowDialog() != DialogResult.OK)
return;
CloseWaveOut(); // disposes the waveOutDevice and audiofilereader
waveOutDevice = new WaveOut();
audioFileReader = new AudioFileReader(open.FileName);
waveOutDevice.Init(audioFileReader);
waveOutDevice.Play();
pauseButton.Enabled = true;
}
Run Code Online (Sandbox Code Playgroud) 我想为XAML实现一种工厂模式.我为WinRT创建了一个应用程序,我在其中定义了两个xaml样式文件.基本上,我想要实现的(如果可能的话)是在应用程序启动时加载两个xaml文件中的一个.在解决方案资源管理器中我有这个:

CustomStyles foder包含样式文件.所以,基于我的App.xaml.cs文件中的枚举器
public enum Style
{
Style_1,
Style_2
}
Run Code Online (Sandbox Code Playgroud)
如果我选择Style_1,我想在运行时加载xaml文件Style_1.xaml else Style_2.xaml.两个样式文件都具有相同的Button样式,TextBlock样式等定义,具有不同的属性值.这是一个例子:
Style_1.xaml
<Style x:Key="Attribute_Label" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="Foreground" Value="#78CAB3" />
<Setter Property="FontSize" Value="15" />
<Setter Property="FontWeight" Value="Normal" />
</Style>
Run Code Online (Sandbox Code Playgroud)
Style_2.xaml
<Style x:Key="Attribute_Label" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="Foreground" Value="#606060" />
<Setter Property="FontSize" Value="30" />
<Setter Property="FontWeight" Value="Normal" />
</Style>
Run Code Online (Sandbox Code Playgroud)
有办法实现我想做的事情吗?先感谢您.
正如我所拥有的标题所示,我可以在其中插入我想要添加到占位符的文本框的数量.我可以添加文本框就好了问题是我无法在动态添加的文本框中插入值.这是我的代码
这段代码的目的是每当文本框中我可以介绍我想要的文本框的数量.它创建并将它们添加到我的页面中的占位符.
public void txtExtra_TextChanged(object sender, EventArgs e)
{
for (a = 1; a <= int.Parse(txtExtra.Text); a++)
{
TextBox txt = new TextBox();
txt.ID = "txtquestion" + a;
pholder.Controls.Add(txt);
}
}
Run Code Online (Sandbox Code Playgroud)
这是将提交和响应的按钮的代码.写入插入所有这些文本框中的值.
protected void btnConfirm_Click(object sender, EventArgs e)
{
foreach (Control ctr in pholder.Controls)
{
if (ctr is TextBox)
{
string value = ((TextBox)ctr).Text;
Response.Write(value);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我一直在网上搜索,我一直在得到这个代码很好的答案,它应该工作,但它没有.如果你们看到任何错误或有任何建议可以解决我的问题,我真的很感激
我有一个GRPC-java服务器代码的实现,但是我没有找到用于单元测试StreamObserver的示例代码。有谁知道对功能进行单元测试的正确方法?
public class RpcTrackDataServiceImpl implements TrackDataServiceGrpc.TrackDataService {
@Override
public void getTracks(GetTracksRequest request, StreamObserver < GetTracksResponse > responseObserver) {
GetTracksResponse reply = GetTracksResponse
.newBuilder()
.addTracks(TrackInfo.newBuilder()
.setOwner("test")
.setTrackName("test")
.build())
.build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
}
}
Run Code Online (Sandbox Code Playgroud) 在Airflow中,我面临的问题是我需要将其传递job_flow_id给我的一个emr步骤.我能够job_flow_id从运营商检索,但是当我要创建提交到集群的步骤时,task_instance值不正确.我有以下代码:
def issue_step(name, args):
return [
{
"Name": name,
"ActionOnFailure": "CONTINUE",
"HadoopJarStep": {
"Jar": "s3://....",
"Args": args
}
}
]
dag = DAG('example',
description='My dag',
schedule_interval='0 8 * * 6',
dagrun_timeout=timedelta(days=2))
try:
create_emr = EmrCreateJobFlowOperator(
task_id='create_job_flow',
aws_conn_id='aws_default',
dag=dag
)
load_data_steps = issue_step('load', ['arg1', 'arg2'])
load_data_steps[0]["HadoopJarStep"]["Args"].append('--cluster-id')
load_data_steps[0]["HadoopJarStep"]["Args"].append(
"{{ task_instance.xcom_pull('create_job_flow', key='return_value') }}") # the value here is not exchanged with the actual job_flow_id
load_data = EmrAddStepsOperator(
task_id='load_data',
job_flow_id="{{ task_instance.xcom_pull('create_job_flow', key='return_value') }}", # this is correctly exchanged …Run Code Online (Sandbox Code Playgroud) 前几天我对我的任务提出了这个问题,但我仍然不确定我是否正确.
for(int i =1; i <n; i++) //n is some size
{
for(j=1; j<i; j++)
{
int k=1;
while (k<n)
{
k=k+C; //where C is a constant and >=2
}
}
}
Run Code Online (Sandbox Code Playgroud)
我知道嵌套for循环是O(n ^ 2)但我不确定while循环.我假设整个代码都是O(n ^ 3).
我在Kubernetes上部署Airflow时遇到错误(准确地说是此版本的Airflow https://github.com/puckel/docker-airflow/blob/1.8.1/Dockerfile),涉及到向文件系统写入权限。
窗格的日志中显示的错误是:
sed: couldn't open temporary file /usr/local/airflow/sed18bPUH: Read-only file system
sed: -e expression #1, char 131: unterminated `s' command
sed: -e expression #1, char 118: unterminated `s' command
Initialize database...
sed: couldn't open temporary file /usr/local/airflow/sedouxZBL: Read-only file system
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/airflow/configuration.py", line 769, in
....
with open(TEST_CONFIG_FILE, 'w') as f:
IOError: [Errno 30] Read-only file system: '/usr/local/airflow/unittests.cfg'
Run Code Online (Sandbox Code Playgroud)
看来文件系统是只读的,但我不明白为什么会这样。我不确定这是否是Kubernetes的错误配置(我是否需要针对Pod的特殊RBAC?不知道)还是Dockerfile是否有问题。
部署文件如下所示:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: airflow
namespace: test …Run Code Online (Sandbox Code Playgroud) 我在气流中制作了以下DAG,在其中执行一组EMRStep以运行管道。
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2017, 07, 20, 10, 00),
'email': ['airflow@airflow.com'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 5,
'retry_delay': timedelta(minutes=2),
}
dag = DAG('dag_import_match_hourly',
default_args=default_args,
description='Fancy Description',
schedule_interval=timedelta(hours=1),
dagrun_timeout=timedelta(hours=2))
try:
merge_s3_match_step = EmrAddStepsOperator(
task_id='merge_s3_match_step',
job_flow_id=cluster_id,
aws_conn_id='aws_default',
steps=create_step('Merge S3 Match'),
dag=dag
)
mapreduce_step = EmrAddStepsOperator(
task_id='mapreduce_match_step',
job_flow_id=cluster_id,
aws_conn_id='aws_default',
steps=create_step('MapReduce Match Hourly'),
dag=dag
)
merge_hdfs_step = EmrAddStepsOperator(
task_id='merge_hdfs_step',
job_flow_id=cluster_id,
aws_conn_id='aws_default',
steps=create_step('Merge HDFS Match Hourly'),
dag=dag
)
## Sensors
check_merge_s3 = EmrStepSensor(
task_id='watch_merge_s3',
job_flow_id=cluster_id,
step_id="{{ task_instance.xcom_pull('merge_s3_match_step', key='return_value')[0] }}",
aws_conn_id='aws_default', …Run Code Online (Sandbox Code Playgroud) 我想读取excel文件中的每个单元格值,但即使在.NET中尝试不同的示例后,我也无法获取单元格值.我没有得到以下代码的结果,任何人都可以得到这个.我正在使用.net framework 2.0
string filePath = "F:/BulkTest.xlsx";
Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();
ExcelApp.Visible = true;
Microsoft.Office.Interop.Excel.Workbook wb = ExcelApp.Workbooks.Open(filePath, Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);
Microsoft.Office.Interop.Excel.Worksheet sh = (Microsoft.Office.Interop.Excel.Worksheet)wb.Sheets["Sheet1"];
Range excelRange = sh.UsedRange;
for (int i=2; i<= excelRange.Count + 1 ; i++)
{
string values = sh.Cells[i,2].ToString();
}
Run Code Online (Sandbox Code Playgroud) 我试图利用这个内核函数中的共享内存,但性能没有我预期的那么好。这个函数在我的应用程序中被调用很多次(大约1000次或更多),所以我想利用共享内存来避免内存延迟。但显然有些问题,因为我使用共享内存,我的应用程序变得非常慢。
这是内核:
__global__ void AndBitwiseOperation(int* _memory_device, int b1_size, int* b1_memory, int* b2_memory){
int j = 0;
// index GPU - Transaction-wise
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
unsigned int tid = threadIdx.x;
// shared variable
extern __shared__ int shared_memory_data[];
extern __shared__ int shared_b1_data[];
extern __shared__ int shared_b2_data[];
// copy from global memory into shared memory and sync threads
shared_b1_data[tid] = b1_memory[tid];
shared_b2_data[tid] = b2_memory[tid];
__syncthreads();
// AND each int bitwise
for(j = 0; j < b1_size; j++) …Run Code Online (Sandbox Code Playgroud) c# ×5
airflow ×3
emr ×2
python ×2
amazon-emr ×1
amazon-s3 ×1
asp.net ×1
big-o ×1
cuda ×1
deployment ×1
docker ×1
excel ×1
grpc ×1
kubernetes ×1
list ×1
merge ×1
naudio ×1
sed ×1
textbox ×1
tuples ×1
unit-testing ×1
winrt-xaml ×1
xaml ×1