问:
FileTable Delimited String Split

EDIT - To be clear I will put the goal sentence at the top. The test
  and my question is whether there is a way to get the same performance
  as a temp table without using a temp table.

I feel this should be an easy question but I am stuck.  I am experimenting with FileTables in SQL2014.  I know of a few alternatives that would work well but the goal is to establish feasibility of extracting substrings of text from a filetable.

This test has 35,000 text files with one line of text as follows with each file having an average of 100 bytes of non-unicode text.

```<code>Aaa|Bbb|Ccc|Ddd|Eee|Fff|Ggg
</code>```

The desired output is one row for each file and the delimited string to be split into seven columns.

I have found a quick string parser function, but running on the filestream has a significant performance impact compared to a varchar column.

This query takes 18 seconds to run.  I am trying to have the conversion from filestream to varchar execute only once but I think calling the UDF may be causing it to happen for every row(file).

```<code>Create View vAddresses As
Select file_type, Convert(Varchar(8000),file_stream) TextData /* Into #Temp */ From InputFiles Where file_type = 'adr'
Go
Select  --TextData,
        dbo.udf_StringSplit(TextData, 1, '|'), dbo.udf_StringSplit(TextData, 2, '|'), dbo.udf_StringSplit(TextData, 3, '|'),
        dbo.udf_StringSplit(TextData, 4, '|'), dbo.udf_StringSplit(TextData, 5, '|'), dbo.udf_StringSplit(TextData, 6, '|'),
        dbo.udf_StringSplit(TextData, 7, '|')--, TextData
    From vAddresses
</code>```

I have tried it as a view, a cte and a subquery.  The only thing that seems to help is creating a temp table.  Creating the temp table takes 1 second and the query takes one second.  So for 35k rows 2 seconds total query time vs. 18 seconds.

```<code>Drop Table #Temp
(Select file_type, Convert(Varchar(8000),file_stream) TextData Into #Temp From HumanaInputFiles Where file_type = 'adr')
Select  --TextData,
        dbo.udf_StringSplit(TextData, 1, '|'), dbo.udf_StringSplit(TextData, 2, '|'), dbo.udf_StringSplit(TextData, 3, '|'),
        dbo.udf_StringSplit(TextData, 4, '|'), dbo.udf_StringSplit(TextData, 5, '|'), dbo.udf_StringSplit(TextData, 6, '|'),
        dbo.udf_StringSplit(TextData, 7, '|')--, TextData
    From #Temp
</code>```

I have read many posts and blogs on both the topics of filetables and temp table vs single query performance but I cant seem to figure it out.  It might have something to do with sargable or statistics?  Any advice is much appreciated.

Here is the UDF, I found it on an MSDN blog / forum and is the best performer I have found so far.

```<code>ALTER FUNCTION [dbo].[udf_StringSplit](
 @TEXT      varchar(8000)
,@COLUMN    tinyint
,@SEPARATOR char(1)
)RETURNS varchar(8000)
AS
  BEGIN
       DECLARE @POS_START  int = 1
       DECLARE @POS_END    int = CHARINDEX(@SEPARATOR, @TEXT, @POS_START)

       WHILE (@COLUMN >1 AND @POS_END> 0)
         BEGIN
             SET @POS_START = @POS_END + 1
             SET @POS_END = CHARINDEX(@SEPARATOR, @TEXT, @POS_START)
             SET @COLUMN = @COLUMN - 1
         END

       IF @COLUMN > 1  SET @POS_START = LEN(@TEXT) + 1
       IF @POS_END = 0 SET @POS_END = LEN(@TEXT) + 1

       RETURN SUBSTRING (@TEXT, @POS_START, @POS_END - @POS_START)
  END
</code>```

This is the execution plan for the temp table.

```<code><?xml version="1.0" encoding="utf-16"?>
<ShowPlanXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.2" Build="12.0.4100.1" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">
  <BatchSequence>
    <Batch>
      <Statements>
        <StmtSimple StatementCompId="1" StatementEstRows="17486" StatementId="1" StatementOptmLevel="TRIVIAL" CardinalityEstimationModelVersion="120" StatementSubTreeCost="0.166487" StatementText="Select --TextData,
\n       dbo.udf_StringSplit(TextData, 1, '|'), dbo.udf_StringSplit(TextData, 2, '|'), dbo.udf_StringSplit(TextData, 3, '|'),
\n      dbo.udf_StringSplit(TextData, 4, '|'), dbo.udf_StringSplit(TextData, 5, '|'), dbo.udf_StringSplit(TextData, 6, '|'),
\n      dbo.udf_StringSplit(TextData, 7, '|')--, TextData
\n From #Temp" StatementType="SELECT" QueryHash="0xC4D6F0215D332F3D" QueryPlanHash="0xC50CFAF9494B5DBE" RetrievedFromCache="true">
          <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
          <QueryPlan DegreeOfParallelism="0" NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="24" CompileTime="1" CompileCPU="1" CompileMemory="168">
            <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />
            <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="838735" EstimatedPagesCached="419367" EstimatedAvailableDegreeOfParallelism="4" />
            <RelOp AvgRowSize="28023" EstimateCPU="0.0017486" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.166487">
              <OutputList>
                <ColumnReference Column="Expr1003" />
                <ColumnReference Column="Expr1004" />
                <ColumnReference Column="Expr1005" />
                <ColumnReference Column="Expr1006" />
                <ColumnReference Column="Expr1007" />
                <ColumnReference Column="Expr1008" />
                <ColumnReference Column="Expr1009" />
              </OutputList>
              <RunTimeInformation>
                <RunTimeCountersPerThread Thread="0" ActualRows="17486" ActualEndOfScans="1" ActualExecutions="1" />
              </RunTimeInformation>
              <ComputeScalar>
                <DefinedValues>
                  <DefinedValue>
                    <ColumnReference Column="Expr1003" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(1),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(1)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1004" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(2),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(2)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1005" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(3),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(3)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1006" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(4),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(4)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1007" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(5),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(5)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1008" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(6),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(6)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1009" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(7),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(7)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                </DefinedValues>
                <RelOp AvgRowSize="4011" EstimateCPU="0.0193131" EstimateIO="0.145426" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Table Scan" NodeId="1" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.164739" TableCardinality="17486">
                  <OutputList>
                    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                  </OutputList>
                  <RunTimeInformation>
                    <RunTimeCountersPerThread Thread="0" ActualRows="17486" ActualEndOfScans="1" ActualExecutions="1" />
                  </RunTimeInformation>
                  <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false" Storage="RowStore">
                    <DefinedValues>
                      <DefinedValue>
                        <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                      </DefinedValue>
                    </DefinedValues>
                    <Object Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" IndexKind="Heap" Storage="RowStore" />
                  </TableScan>
                </RelOp>
              </ComputeScalar>
            </RelOp>
          </QueryPlan>
        </StmtSimple>
      </Statements>
    </Batch>
  </BatchSequence>
</ShowPlanXML>
</code>```

This is the plan for the view.

```<code><?xml version="1.0" encoding="utf-16"?>
<ShowPlanXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.2" Build="12.0.4100.1" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">
  <BatchSequence>
    <Batch>
      <Statements>
        <StmtSimple StatementCompId="1" StatementEstRows="17486" StatementId="1" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" CardinalityEstimationModelVersion="120" StatementSubTreeCost="0.905265" StatementText="Select    --TextData,
\n       dbo.udf_StringSplit(TextData, 1, '|'), dbo.udf_StringSplit(TextData, 2, '|'), dbo.udf_StringSplit(TextData, 3, '|'),
\n      dbo.udf_StringSplit(TextData, 4, '|'), dbo.udf_StringSplit(TextData, 5, '|'), dbo.udf_StringSplit(TextData, 6, '|'),
\n      dbo.udf_StringSplit(TextData, 7, '|')--, TextData
\n From vAddresses" StatementType="SELECT" QueryHash="0xB4F8A0B288802C4E" QueryPlanHash="0x28DA02D774B1AF53" RetrievedFromCache="true">
          <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
          <QueryPlan DegreeOfParallelism="0" NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="32" CompileTime="3" CompileCPU="3" CompileMemory="520">
            <Warnings>
              <PlanAffectingConvert ConvertIssue="Cardinality Estimate" Expression="CONVERT(varchar(8000),[DmProd01].[dbo].[HumanaInputFiles].[file_stream],0)" />
            </Warnings>
            <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />
            <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="838735" EstimatedPagesCached="419367" EstimatedAvailableDegreeOfParallelism="4" />
            <RelOp AvgRowSize="28023" EstimateCPU="0.0017486" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.905265">
              <OutputList>
                <ColumnReference Column="Expr1004" />
                <ColumnReference Column="Expr1005" />
                <ColumnReference Column="Expr1006" />
                <ColumnReference Column="Expr1007" />
                <ColumnReference Column="Expr1008" />
                <ColumnReference Column="Expr1009" />
                <ColumnReference Column="Expr1010" />
              </OutputList>
              <RunTimeInformation>
                <RunTimeCountersPerThread Thread="0" ActualRows="17486" ActualEndOfScans="1" ActualExecutions="1" />
              </RunTimeInformation>
              <ComputeScalar>
                <DefinedValues>
                  <DefinedValue>
                    <ColumnReference Column="Expr1004" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(1),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(1)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1005" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(2),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(2)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1006" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(3),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(3)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1007" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(4),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(4)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1008" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(5),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(5)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1009" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(6),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(6)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1010" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(7),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(7)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                </DefinedValues>
                <RelOp AvgRowSize="4019" EstimateCPU="0.0034972" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Compute Scalar" NodeId="1" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.88673">
                  <OutputList>
                    <ColumnReference Column="Expr1011" />
                  </OutputList>
                  <ComputeScalar>
                    <DefinedValues>
                      <DefinedValue>
                        <ColumnReference Column="Expr1011" />
                        <ScalarOperator ScalarString="CONVERT(varchar(8000),[DmProd01].[dbo].[HumanaInputFiles].[file_stream],0)">
                          <Convert DataType="varchar" Length="8000" Style="0" Implicit="false">
                            <ScalarOperator>
                              <Identifier>
                                <ColumnReference Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" Column="file_stream" />
                              </Identifier>
                            </ScalarOperator>
                          </Convert>
                        </ScalarOperator>
                      </DefinedValue>
                    </DefinedValues>
                    <RelOp AvgRowSize="4043" EstimateCPU="0.0386262" EstimateIO="0.844606" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Table Scan" NodeId="2" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.883233" TableCardinality="34972">
                      <OutputList>
                        <ColumnReference Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" Column="file_stream" />
                      </OutputList>
                      <RunTimeInformation>
                        <RunTimeCountersPerThread Thread="0" ActualRows="17486" ActualEndOfScans="1" ActualExecutions="1" />
                      </RunTimeInformation>
                      <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false" Storage="RowStore">
                        <DefinedValues>
                          <DefinedValue>
                            <ColumnReference Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" Column="file_stream" />
                          </DefinedValue>
                        </DefinedValues>
                        <Object Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" IndexKind="Heap" Storage="RowStore" />
                        <Predicate>
                          <ScalarOperator ScalarString="[DmProd01].[dbo].[HumanaInputFiles].[file_type]=N'adr'">
                            <Compare CompareOp="EQ">
                              <ScalarOperator>
                                <Identifier>
                                  <ColumnReference Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" Column="file_type" ComputedColumn="true" />
                                </Identifier>
                              </ScalarOperator>
                              <ScalarOperator>
                                <Const ConstValue="N'adr'" />
                              </ScalarOperator>
                            </Compare>
                          </ScalarOperator>
                        </Predicate>
                      </TableScan>
                    </RelOp>
                  </ComputeScalar>
                </RelOp>
              </ComputeScalar>
            </RelOp>
          </QueryPlan>
        </StmtSimple>
      </Statements>
    </Batch>
  </BatchSequence>
</ShowPlanXML>
</code>```

EDIT: Searched on this differently and found an answer is to use top and order by.  This got it down to 4 seconds.  Seems kind of hokey and still dont explain how looking at query plans helps figure this out, so not going to answer this myself, instead leave it open.

答:
There are recomendations in MSDN to not use FileTable in your case:

The FileTable feature builds on top of SQL Server FILESTREAM
technology.

For small objects perfomance of FileStream is not good. Filestream is designed to work with files about 1MB and more, but you have only 100 bytes(https://learn.microsoft.com/en-us/sql/relational-databases/blob/filestream-sql-server):

When to Use FILESTREAM In SQL Server, BLOBs can be standard
varbinary(max) data that stores the data in tables, or FILESTREAM
varbinary(max) objects that store the data in the file system. The
size and use of the data determines whether you should use database
storage or file system storage. If the following conditions are true,
you should consider using FILESTREAM:

Objects that are being stored are, on average, larger than 1 MB.

Fast read access is important.

You are developing applications that use a middle tier for application logic.

For smaller objects, storing varbinary(max) BLOBs in the
database often provides better streaming performance.

You can emulate persistent column - create another table and populate it with triggers. In this case you can receive bonuses from both cases

P.S. You can use inline TVF + union all to implement @TT 's comment

Title: FileTable Delimited String Split

Body:
EDIT - To be clear I will put the goal sentence at the top. The test
  and my question is whether there is a way to get the same performance
  as a temp table without using a temp table.

I feel this should be an easy question but I am stuck.  I am experimenting with FileTables in SQL2014.  I know of a few alternatives that would work well but the goal is to establish feasibility of extracting substrings of text from a filetable.

This test has 35,000 text files with one line of text as follows with each file having an average of 100 bytes of non-unicode text.

Aaa|Bbb|Ccc|Ddd|Eee|Fff|Ggg

The desired output is one row for each file and the delimited string to be split into seven columns.

I have found a quick string parser function, but running on the filestream has a significant performance impact compared to a varchar column.

This query takes 18 seconds to run.  I am trying to have the conversion from filestream to varchar execute only once but I think calling the UDF may be causing it to happen for every row(file).

Create View vAddresses As
Select file_type, Convert(Varchar(8000),file_stream) TextData /* Into #Temp */ From InputFiles Where file_type = 'adr'
Go
Select  --TextData,
        dbo.udf_StringSplit(TextData, 1, '|'), dbo.udf_StringSplit(TextData, 2, '|'), dbo.udf_StringSplit(TextData, 3, '|'),
        dbo.udf_StringSplit(TextData, 4, '|'), dbo.udf_StringSplit(TextData, 5, '|'), dbo.udf_StringSplit(TextData, 6, '|'),
        dbo.udf_StringSplit(TextData, 7, '|')--, TextData
    From vAddresses

I have tried it as a view, a cte and a subquery.  The only thing that seems to help is creating a temp table.  Creating the temp table takes 1 second and the query takes one second.  So for 35k rows 2 seconds total query time vs. 18 seconds.

Drop Table #Temp
(Select file_type, Convert(Varchar(8000),file_stream) TextData Into #Temp From HumanaInputFiles Where file_type = 'adr')
Select  --TextData,
        dbo.udf_StringSplit(TextData, 1, '|'), dbo.udf_StringSplit(TextData, 2, '|'), dbo.udf_StringSplit(TextData, 3, '|'),
        dbo.udf_StringSplit(TextData, 4, '|'), dbo.udf_StringSplit(TextData, 5, '|'), dbo.udf_StringSplit(TextData, 6, '|'),
        dbo.udf_StringSplit(TextData, 7, '|')--, TextData
    From #Temp

I have read many posts and blogs on both the topics of filetables and temp table vs single query performance but I cant seem to figure it out.  It might have something to do with sargable or statistics?  Any advice is much appreciated.

Here is the UDF, I found it on an MSDN blog / forum and is the best performer I have found so far.

ALTER FUNCTION [dbo].[udf_StringSplit](
 @TEXT      varchar(8000)
,@COLUMN    tinyint
,@SEPARATOR char(1)
)RETURNS varchar(8000)
AS
  BEGIN
       DECLARE @POS_START  int = 1
       DECLARE @POS_END    int = CHARINDEX(@SEPARATOR, @TEXT, @POS_START)

       WHILE (@COLUMN >1 AND @POS_END> 0)
         BEGIN
             SET @POS_START = @POS_END + 1
             SET @POS_END = CHARINDEX(@SEPARATOR, @TEXT, @POS_START)
             SET @COLUMN = @COLUMN - 1
         END

       IF @COLUMN > 1  SET @POS_START = LEN(@TEXT) + 1
       IF @POS_END = 0 SET @POS_END = LEN(@TEXT) + 1

       RETURN SUBSTRING (@TEXT, @POS_START, @POS_END - @POS_START)
  END

This is the execution plan for the temp table.

<?xml version="1.0" encoding="utf-16"?>
<ShowPlanXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.2" Build="12.0.4100.1" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">
  <BatchSequence>
    <Batch>
      <Statements>
        <StmtSimple StatementCompId="1" StatementEstRows="17486" StatementId="1" StatementOptmLevel="TRIVIAL" CardinalityEstimationModelVersion="120" StatementSubTreeCost="0.166487" StatementText="Select --TextData,
       dbo.udf_StringSplit(TextData, 1, '|'), dbo.udf_StringSplit(TextData, 2, '|'), dbo.udf_StringSplit(TextData, 3, '|'),
      dbo.udf_StringSplit(TextData, 4, '|'), dbo.udf_StringSplit(TextData, 5, '|'), dbo.udf_StringSplit(TextData, 6, '|'),
      dbo.udf_StringSplit(TextData, 7, '|')--, TextData
 From #Temp" StatementType="SELECT" QueryHash="0xC4D6F0215D332F3D" QueryPlanHash="0xC50CFAF9494B5DBE" RetrievedFromCache="true">
          <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
          <QueryPlan DegreeOfParallelism="0" NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="24" CompileTime="1" CompileCPU="1" CompileMemory="168">
            <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />
            <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="838735" EstimatedPagesCached="419367" EstimatedAvailableDegreeOfParallelism="4" />
            <RelOp AvgRowSize="28023" EstimateCPU="0.0017486" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.166487">
              <OutputList>
                <ColumnReference Column="Expr1003" />
                <ColumnReference Column="Expr1004" />
                <ColumnReference Column="Expr1005" />
                <ColumnReference Column="Expr1006" />
                <ColumnReference Column="Expr1007" />
                <ColumnReference Column="Expr1008" />
                <ColumnReference Column="Expr1009" />
              </OutputList>
              <RunTimeInformation>
                <RunTimeCountersPerThread Thread="0" ActualRows="17486" ActualEndOfScans="1" ActualExecutions="1" />
              </RunTimeInformation>
              <ComputeScalar>
                <DefinedValues>
                  <DefinedValue>
                    <ColumnReference Column="Expr1003" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(1),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(1)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1004" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(2),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(2)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1005" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(3),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(3)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1006" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(4),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(4)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1007" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(5),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(5)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1008" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(6),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(6)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1009" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([tempdb].[dbo].[#Temp].[TextData],(7),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(7)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                </DefinedValues>
                <RelOp AvgRowSize="4011" EstimateCPU="0.0193131" EstimateIO="0.145426" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Table Scan" NodeId="1" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.164739" TableCardinality="17486">
                  <OutputList>
                    <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                  </OutputList>
                  <RunTimeInformation>
                    <RunTimeCountersPerThread Thread="0" ActualRows="17486" ActualEndOfScans="1" ActualExecutions="1" />
                  </RunTimeInformation>
                  <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false" Storage="RowStore">
                    <DefinedValues>
                      <DefinedValue>
                        <ColumnReference Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" Column="TextData" />
                      </DefinedValue>
                    </DefinedValues>
                    <Object Database="[tempdb]" Schema="[dbo]" Table="[#Temp]" IndexKind="Heap" Storage="RowStore" />
                  </TableScan>
                </RelOp>
              </ComputeScalar>
            </RelOp>
          </QueryPlan>
        </StmtSimple>
      </Statements>
    </Batch>
  </BatchSequence>
</ShowPlanXML>

This is the plan for the view.

<?xml version="1.0" encoding="utf-16"?>
<ShowPlanXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.2" Build="12.0.4100.1" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">
  <BatchSequence>
    <Batch>
      <Statements>
        <StmtSimple StatementCompId="1" StatementEstRows="17486" StatementId="1" StatementOptmLevel="FULL" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" CardinalityEstimationModelVersion="120" StatementSubTreeCost="0.905265" StatementText="Select    --TextData,
       dbo.udf_StringSplit(TextData, 1, '|'), dbo.udf_StringSplit(TextData, 2, '|'), dbo.udf_StringSplit(TextData, 3, '|'),
      dbo.udf_StringSplit(TextData, 4, '|'), dbo.udf_StringSplit(TextData, 5, '|'), dbo.udf_StringSplit(TextData, 6, '|'),
      dbo.udf_StringSplit(TextData, 7, '|')--, TextData
 From vAddresses" StatementType="SELECT" QueryHash="0xB4F8A0B288802C4E" QueryPlanHash="0x28DA02D774B1AF53" RetrievedFromCache="true">
          <StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" />
          <QueryPlan DegreeOfParallelism="0" NonParallelPlanReason="CouldNotGenerateValidParallelPlan" CachedPlanSize="32" CompileTime="3" CompileCPU="3" CompileMemory="520">
            <Warnings>
              <PlanAffectingConvert ConvertIssue="Cardinality Estimate" Expression="CONVERT(varchar(8000),[DmProd01].[dbo].[HumanaInputFiles].[file_stream],0)" />
            </Warnings>
            <MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" />
            <OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="838735" EstimatedPagesCached="419367" EstimatedAvailableDegreeOfParallelism="4" />
            <RelOp AvgRowSize="28023" EstimateCPU="0.0017486" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Compute Scalar" NodeId="0" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.905265">
              <OutputList>
                <ColumnReference Column="Expr1004" />
                <ColumnReference Column="Expr1005" />
                <ColumnReference Column="Expr1006" />
                <ColumnReference Column="Expr1007" />
                <ColumnReference Column="Expr1008" />
                <ColumnReference Column="Expr1009" />
                <ColumnReference Column="Expr1010" />
              </OutputList>
              <RunTimeInformation>
                <RunTimeCountersPerThread Thread="0" ActualRows="17486" ActualEndOfScans="1" ActualExecutions="1" />
              </RunTimeInformation>
              <ComputeScalar>
                <DefinedValues>
                  <DefinedValue>
                    <ColumnReference Column="Expr1004" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(1),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(1)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1005" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(2),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(2)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1006" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(3),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(3)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1007" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(4),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(4)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1008" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(5),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(5)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1009" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(6),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(6)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                  <DefinedValue>
                    <ColumnReference Column="Expr1010" />
                    <ScalarOperator ScalarString="[DmProd01].[dbo].[udf_StringSplit]([Expr1011],(7),'|')">
                      <UserDefinedFunction FunctionName="[DmProd01].[dbo].[udf_StringSplit]">
                        <ScalarOperator>
                          <Identifier>
                            <ColumnReference Column="Expr1011" />
                          </Identifier>
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="(7)" />
                        </ScalarOperator>
                        <ScalarOperator>
                          <Const ConstValue="'|'" />
                        </ScalarOperator>
                      </UserDefinedFunction>
                    </ScalarOperator>
                  </DefinedValue>
                </DefinedValues>
                <RelOp AvgRowSize="4019" EstimateCPU="0.0034972" EstimateIO="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Compute Scalar" NodeId="1" Parallel="false" PhysicalOp="Compute Scalar" EstimatedTotalSubtreeCost="0.88673">
                  <OutputList>
                    <ColumnReference Column="Expr1011" />
                  </OutputList>
                  <ComputeScalar>
                    <DefinedValues>
                      <DefinedValue>
                        <ColumnReference Column="Expr1011" />
                        <ScalarOperator ScalarString="CONVERT(varchar(8000),[DmProd01].[dbo].[HumanaInputFiles].[file_stream],0)">
                          <Convert DataType="varchar" Length="8000" Style="0" Implicit="false">
                            <ScalarOperator>
                              <Identifier>
                                <ColumnReference Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" Column="file_stream" />
                              </Identifier>
                            </ScalarOperator>
                          </Convert>
                        </ScalarOperator>
                      </DefinedValue>
                    </DefinedValues>
                    <RelOp AvgRowSize="4043" EstimateCPU="0.0386262" EstimateIO="0.844606" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" EstimateRows="17486" LogicalOp="Table Scan" NodeId="2" Parallel="false" PhysicalOp="Table Scan" EstimatedTotalSubtreeCost="0.883233" TableCardinality="34972">
                      <OutputList>
                        <ColumnReference Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" Column="file_stream" />
                      </OutputList>
                      <RunTimeInformation>
                        <RunTimeCountersPerThread Thread="0" ActualRows="17486" ActualEndOfScans="1" ActualExecutions="1" />
                      </RunTimeInformation>
                      <TableScan Ordered="false" ForcedIndex="false" ForceScan="false" NoExpandHint="false" Storage="RowStore">
                        <DefinedValues>
                          <DefinedValue>
                            <ColumnReference Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" Column="file_stream" />
                          </DefinedValue>
                        </DefinedValues>
                        <Object Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" IndexKind="Heap" Storage="RowStore" />
                        <Predicate>
                          <ScalarOperator ScalarString="[DmProd01].[dbo].[HumanaInputFiles].[file_type]=N'adr'">
                            <Compare CompareOp="EQ">
                              <ScalarOperator>
                                <Identifier>
                                  <ColumnReference Database="[DmProd01]" Schema="[dbo]" Table="[HumanaInputFiles]" Column="file_type" ComputedColumn="true" />
                                </Identifier>
                              </ScalarOperator>
                              <ScalarOperator>
                                <Const ConstValue="N'adr'" />
                              </ScalarOperator>
                            </Compare>
                          </ScalarOperator>
                        </Predicate>
                      </TableScan>
                    </RelOp>
                  </ComputeScalar>
                </RelOp>
              </ComputeScalar>
            </RelOp>
          </QueryPlan>
        </StmtSimple>
      </Statements>
    </Batch>
  </BatchSequence>
</ShowPlanXML>

EDIT: Searched on this differently and found an answer is to use top and order by.  This got it down to 4 seconds.  Seems kind of hokey and still dont explain how looking at query plans helps figure this out, so not going to answer this myself, instead leave it open.


来源: stackexchange

问:
VSCode: Keyboard shortcuts for modifying user settings
I like the idea of CodeLens, VSCode's plugin that tells you reference counts on all your functions & variables. However, when I'm scanning code, the extra vertical margin added to include the "X references" line annoys me enough that I've disabled it. This is a shame, because it's useful information.

I'd like to be able to control whether CodeLens is active via keyboard shortcut. There seem to be no "editor.action.toggleCodeLens" in the keybindings, though, and trying

{ "key": "ctrl+l", "command": "editor.codeLens = false" }

or

{ "key": "ctrl+l", "command": "editor.codeLens = !editor.codeLens" }

produces the error command 'editor.codeLens = false' not found. Is there a way to do this?

答:
Try this extensions: https://marketplace.visualstudio.com/items?itemName=rebornix.toggle

It allows you to setup custom keybindings to toggle any VSCode setting

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 3.0


问:
How to give different Shape or image icon for different nodes
I am trying to give different shape or image icons for different nodes.
Like, for Target node i.e dark blue you can see in the js fiddle I want to give as a rectangle to an image icon and for a lighter circle with different shape or image icon.I have followed this Link also but cant able to make it work.
Here is the js fiddle like:
https://jsfiddle.net/AmitSah/bp6p3p92/

```<code>var svg = d3.select("svg"),
    width = +svg.attr("width"),
    height = +svg.attr("height"),
    radius = 10;

/*svg.call(d3.zoom().on("zoom", function () {
   svg.attr("transform", d3.event.transform);
}));*/
var color = d3.scaleOrdinal(d3.schemeCategory20);

var simulation = d3.forceSimulation()
    .force("link", d3.forceLink().id(function(d) { return d.node_id; }).strength(1) )
    //.force("charge", d3.forceManyBody())
    .force("collide", d3.forceCollide(radius + 1).iterations(4))
    .force("center", d3.forceCenter(width / 2, height / 2));

// projection definition
var projection = d3.geoAlbers()
    .scale(1280)
    .translate([width / 2, height / 2]);

// path generator definition for major cities, including point radius
var path = d3.geoPath()
    .projection(projection)
    .pointRadius(2);

// draws the states
d3.json("https://raw.githubusercontent.com/LogicalInsightscg/Web-Mobile-Dashboard/master/us_new.json", function(error, us_new) {
  if (error) return console.error(error);
svg.selectAll(".states")
    .data(topojson.feature(us_new, us_new.objects.states).features)
  .enter().append("path")
    .attr("class", function(d) { return "states " + d.id; })
    .attr("d", path);

// adding state boundaries
    svg.append("path")
    .datum(topojson.mesh(us_new, us_new.objects.states))
    .attr("d", path)
    .attr("class", "state-boundary");

d3.json("https://raw.githubusercontent.com/LogicalInsightscg/Web-Mobile-Dashboard/master/nodesandlinks.json", function(error, graph) {
  if (error) throw error;

// build the arrow.
svg.append("svg:defs").selectAll("marker")
    .data(["end"])      // Different link/path types can be defined here
  .enter().append("svg:marker")    // This section adds in the arrows
    .attr("id", String)
    .attr("viewBox", "0 -5 10 10")
    .attr("refX", 15)
    .attr("refY", -1.5)
    .attr("markerWidth", 6)
    .attr("markerHeight", 6)
    .attr("orient", "auto")
  .append("svg:line")
    .attr("d", "M0,-5L10,0L0,5");

   var link = svg.append("g")
      .attr("class", "links")
    .selectAll("line")
    .data(graph.links)
    .enter().append("line")
      .attr("stroke-width", function(d) { return Math.sqrt(d.referrals); })
       .attr("marker-end", "url(#end)");

  var node = svg.append("g")
      .attr("class", "nodes")
    .selectAll("circle")
    .data(graph.nodes)
    .enter().append("circle")
      .attr("r", 5)
      .attr("fill", function(d) { return color(d.group); })
      //.attr("fixed", true)
      .attr("cx", function(d) {
                   return projection([d.longitude, d.latitude])[0];
           })
           .attr("cy", function(d) {
                   return projection([d.longitude, d.latitude])[1];
           })
/*       .call(d3.drag()
          .on("end", dragended)); */
       .call(d3.drag()
          .on("start", dragstarted)
          .on("drag", dragged)
          .on("end", dragended));

   simulation
      .nodes(graph.nodes)
      .on("tick", ticked);

   simulation.force("link")
      .links(graph.links);

     node.attr('fx', function(d) { return projection([d.longitude, d.latitude])[0]; })
        .attr('fy', function(d) { return projection([d.longitude, d.latitude])[1]; });

     link.attr('x1', function(d) { return projection([d.source.longitude, d.source.latitude])[0]; })
        .attr('y1', function(d) { return projection([d.source.longitude, d.source.latitude])[1]; })
        .attr('x2', function(d) { return projection([d.target.longitude, d.target.latitude])[0]; })
        .attr('y2', function(d) { return projection([d.target.longitude, d.target.latitude])[1]; });

  node.append("title")
      .text(function(d) { return d.node_name; });

   function ticked() {
    link
        .attr("distance", 10)
//        .attr("x1", function(d) { return d.source.x; })
//        .attr("y1", function(d) { return d.source.y; })
        .attr('x1', function(d) { return projection([d.source.longitude, d.source.latitude])[0]; })
        .attr('y1', function(d) { return projection([d.source.longitude, d.source.latitude])[1]; })
        .attr('x2', function(d) { return projection([d.target.longitude, d.target.latitude])[0]; })
        .attr('y2', function(d) { return projection([d.target.longitude, d.target.latitude])[1]; });

    node.attr('cx', function(d) {if (d.group > 0) { return projection([d.longitude, d.latitude])[0]; }
                                             else  { return d.x; }})
        .attr('cy', function(d) {if (d.group > 0) { return projection([d.longitude, d.latitude])[1]; }
                                             else  { return d.y; }});

  }

/*   function ticked() {
     link.attr('x1', function(d) { return projection([d.source.longitude, d.source.latitude])[0]; })
        .attr('y1', function(d) { return projection([d.source.longitude, d.source.latitude])[1]; })
        .attr('x2', function(d) { return projection([d.target.longitude, d.target.latitude])[0]; })
        .attr('y2', function(d) { return projection([d.target.longitude, d.target.latitude])[1]; });

     node.attr('r', width/100)
        .attr('cx', function(d) { return projection([d.longitude, d.latitude])[0]; })
        .attr('cy', function(d) { return projection([d.longitude, d.latitude])[1]; });

  } */
 });
});

function dragstarted(d) {
if (!d3.event.active) simulation.alphaTarget(0.3).restart();
  d.fx = d.x;
  d.fy = d.y;
}

function dragged(d) {
  d.fx = d3.event.x;
  d.fy = d3.event.y;
}

function dragended(d) {
  if (!d3.event.active) simulation.alphaTarget(0);
  d.fx = null;
  d.fy = null;
}
</code>```

Can anyone help me to do this?

EDITED:
Kindly see this image:

Network Map

```<code>d3.selectAll(".company").append("rect")
    .attr("width", 20)
    .attr("height", 20)

.data(someData)
.attr("x", function(d) {
   if (d.cat == 2)
     {
                   return projection([d.longitude, d.latitude])[0];
     }
     })
           .attr("y", function(d) {
  if (d.cat == 2)
     {
                   return projection([d.longitude, d.latitude])[1];
     }
     });
</code>```

Thanks,
Amit Sah

答:
The easiest way would be to have something in the data that you can use to set the attributes, i.e.

```<code>.attr('stroke-color', function(){
if
</code>```

(d.dataAtt = someAttribute, return black)
else if
(d.dataAtt = otherAttribute, return white)

Or if you want to set the target nodes to a different colour, you could use d3.select to select all the node id's in the target link array, then change the attributes of only those nodes. Setting the node id might help select the correct nodes (see the bottom line):

```<code>var node = svg.append("g")
  .attr("class", "nodes")
.selectAll("circle")
.data(graph.nodes)
.enter().append("circle")
  .attr("r", 5)
.attr("id", d.graph.nodes.id)//or something
</code>```

Edit:

```<code>   var node = svg.append("g")
          .attr("class", function(){
    if
(d.dataAtt = someAttribute, return Aclass)
else if
(d.dataAtt = otherAttribute, return Bclass))//it would be easiest to separate the nodes by class
        .data(graph.nodes)
        .enter()
        .attr("id", d.graph.nodes.id)//or something

d3.selectAll(".Aclass")
    .append("rect")

d3.selectAll(".Bclass")
    .append("circle")
</code>```

You could use the source/target array to select the nodes where there id is in one or the other, but without seeing your data, I don't know if that would be appropriate.

Body:
I am trying to give different shape or image icons for different nodes.
Like, for Target node i.e dark blue you can see in the js fiddle I want to give as a rectangle to an image icon and for a lighter circle with different shape or image icon.I have followed this Link also but cant able to make it work.
Here is the js fiddle like:
https://jsfiddle.net/AmitSah/bp6p3p92/

var svg = d3.select("svg"),
    width = +svg.attr("width"),
    height = +svg.attr("height"),
    radius = 10;

/*svg.call(d3.zoom().on("zoom", function () {
   svg.attr("transform", d3.event.transform);
}));*/
var color = d3.scaleOrdinal(d3.schemeCategory20);

var simulation = d3.forceSimulation()
    .force("link", d3.forceLink().id(function(d) { return d.node_id; }).strength(1) )
    //.force("charge", d3.forceManyBody())
    .force("collide", d3.forceCollide(radius + 1).iterations(4))
    .force("center", d3.forceCenter(width / 2, height / 2));

// projection definition
var projection = d3.geoAlbers()
    .scale(1280)
    .translate([width / 2, height / 2]);

// path generator definition for major cities, including point radius
var path = d3.geoPath()
    .projection(projection)
    .pointRadius(2);

// draws the states
d3.json("https://raw.githubusercontent.com/LogicalInsightscg/Web-Mobile-Dashboard/master/us_new.json", function(error, us_new) {
  if (error) return console.error(error);
svg.selectAll(".states")
    .data(topojson.feature(us_new, us_new.objects.states).features)
  .enter().append("path")
    .attr("class", function(d) { return "states " + d.id; })
    .attr("d", path);

// adding state boundaries
    svg.append("path")
    .datum(topojson.mesh(us_new, us_new.objects.states))
    .attr("d", path)
    .attr("class", "state-boundary");

d3.json("https://raw.githubusercontent.com/LogicalInsightscg/Web-Mobile-Dashboard/master/nodesandlinks.json", function(error, graph) {
  if (error) throw error;

// build the arrow.
svg.append("svg:defs").selectAll("marker")
    .data(["end"])      // Different link/path types can be defined here
  .enter().append("svg:marker")    // This section adds in the arrows
    .attr("id", String)
    .attr("viewBox", "0 -5 10 10")
    .attr("refX", 15)
    .attr("refY", -1.5)
    .attr("markerWidth", 6)
    .attr("markerHeight", 6)
    .attr("orient", "auto")
  .append("svg:line")
    .attr("d", "M0,-5L10,0L0,5");

   var link = svg.append("g")
      .attr("class", "links")
    .selectAll("line")
    .data(graph.links)
    .enter().append("line")
      .attr("stroke-width", function(d) { return Math.sqrt(d.referrals); })
       .attr("marker-end", "url(#end)");

  var node = svg.append("g")
      .attr("class", "nodes")
    .selectAll("circle")
    .data(graph.nodes)
    .enter().append("circle")
      .attr("r", 5)
      .attr("fill", function(d) { return color(d.group); })
      //.attr("fixed", true)
      .attr("cx", function(d) {
                   return projection([d.longitude, d.latitude])[0];
           })
           .attr("cy", function(d) {
                   return projection([d.longitude, d.latitude])[1];
           })
/*       .call(d3.drag()
          .on("end", dragended)); */
       .call(d3.drag()
          .on("start", dragstarted)
          .on("drag", dragged)
          .on("end", dragended));

   simulation
      .nodes(graph.nodes)
      .on("tick", ticked);

   simulation.force("link")
      .links(graph.links);

     node.attr('fx', function(d) { return projection([d.longitude, d.latitude])[0]; })
        .attr('fy', function(d) { return projection([d.longitude, d.latitude])[1]; });

     link.attr('x1', function(d) { return projection([d.source.longitude, d.source.latitude])[0]; })
        .attr('y1', function(d) { return projection([d.source.longitude, d.source.latitude])[1]; })
        .attr('x2', function(d) { return projection([d.target.longitude, d.target.latitude])[0]; })
        .attr('y2', function(d) { return projection([d.target.longitude, d.target.latitude])[1]; });

  node.append("title")
      .text(function(d) { return d.node_name; });

   function ticked() {
    link
        .attr("distance", 10)
//        .attr("x1", function(d) { return d.source.x; })
//        .attr("y1", function(d) { return d.source.y; })
        .attr('x1', function(d) { return projection([d.source.longitude, d.source.latitude])[0]; })
        .attr('y1', function(d) { return projection([d.source.longitude, d.source.latitude])[1]; })
        .attr('x2', function(d) { return projection([d.target.longitude, d.target.latitude])[0]; })
        .attr('y2', function(d) { return projection([d.target.longitude, d.target.latitude])[1]; });

    node.attr('cx', function(d) {if (d.group > 0) { return projection([d.longitude, d.latitude])[0]; }
                                             else  { return d.x; }})
        .attr('cy', function(d) {if (d.group > 0) { return projection([d.longitude, d.latitude])[1]; }
                                             else  { return d.y; }});

  }

/*   function ticked() {
     link.attr('x1', function(d) { return projection([d.source.longitude, d.source.latitude])[0]; })
        .attr('y1', function(d) { return projection([d.source.longitude, d.source.latitude])[1]; })
        .attr('x2', function(d) { return projection([d.target.longitude, d.target.latitude])[0]; })
        .attr('y2', function(d) { return projection([d.target.longitude, d.target.latitude])[1]; });

     node.attr('r', width/100)
        .attr('cx', function(d) { return projection([d.longitude, d.latitude])[0]; })
        .attr('cy', function(d) { return projection([d.longitude, d.latitude])[1]; });

  } */
 });
});

function dragstarted(d) {
if (!d3.event.active) simulation.alphaTarget(0.3).restart();
  d.fx = d.x;
  d.fy = d.y;
}

function dragged(d) {
  d.fx = d3.event.x;
  d.fy = d3.event.y;
}

function dragended(d) {
  if (!d3.event.active) simulation.alphaTarget(0);
  d.fx = null;
  d.fy = null;
}

Can anyone help me to do this?

EDITED:
Kindly see this image:

Network Map

d3.selectAll(".company").append("rect")
    .attr("width", 20)
    .attr("height", 20)

.data(someData)
.attr("x", function(d) {
   if (d.cat == 2)
     {
                   return projection([d.longitude, d.latitude])[0];
     }
     })
           .attr("y", function(d) {
  if (d.cat == 2)
     {
                   return projection([d.longitude, d.latitude])[1];
     }
     });

Thanks,
Amit Sah

Body:
The easiest way would be to have something in the data that you can use to set the attributes, i.e.

.attr('stroke-color', function(){
if

(d.dataAtt = someAttribute, return black)
else if
(d.dataAtt = otherAttribute, return white)

Or if you want to set the target nodes to a different colour, you could use d3.select to select all the node id's in the target link array, then change the attributes of only those nodes. Setting the node id might help select the correct nodes (see the bottom line):

var node = svg.append("g")
  .attr("class", "nodes")
.selectAll("circle")
.data(graph.nodes)
.enter().append("circle")
  .attr("r", 5)
.attr("id", d.graph.nodes.id)//or something

Edit:

   var node = svg.append("g")
          .attr("class", function(){
    if
(d.dataAtt = someAttribute, return Aclass)
else if
(d.dataAtt = otherAttribute, return Bclass))//it would be easiest to separate the nodes by class
        .data(graph.nodes)
        .enter()
        .attr("id", d.graph.nodes.id)//or something

d3.selectAll(".Aclass")
    .append("rect")

d3.selectAll(".Bclass")
    .append("circle")

You could use the source/target array to select the nodes where there id is in one or the other, but without seeing your data, I don't know if that would be appropriate.


问:
span height width unable to change
trying to make one horizontal box.. inside that update limits.
if u see the below sample code, u can understand how i set limits.
those limit classes height, i am unable to decrease.
could please tel me what is reason..
i want to make it using div and span only</p>

```<code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" dir="ltr">
    <head>
    <style>
        .limitBlock
        {
            border-left: 1px solid black;
        }
        .limitRBlack
        {
            border-right: 1px solid black;
        }
        .horbox
        {
           background-color:#FFFFFF;
           height:4px;
           width:400px;
           margin-left:5px;
           border: 1px solid #AAAAAA;
        }
    </style>
    </head>
    <body>
        <div class="horbox">
            <div style="margin-top:-3px">
                <span style="margin-top: -4px;height: 9px;">
                    <span id="limit1" class="limitBlock" style="margin-left:-1px;"></span>
                    <span id="limit2" class="limitBlock" style="margin-left:100px;"></span>
                    <span id="limit3" class="limitBlock" style="margin-left:100px;"></span>
                    <span id="limit4" class="limitBlock" style="margin-left:100px;"></span>
                </span>
                <span id="limit5"class="limitRBlack" style="margin-left:96px;"></span>
            </div>
        </div>
    </body>
</html>
</code>```

答:
Your class is named limitBlock, but a span is not a block and do not respond to setting height the way a block does. I would choose for a floating div in this situation.

Also, set overflow:hidden to prevent elements to be scaled to the full height of the content (line height of text).

ContentLicense: CC BY-SA 2.5

Title: span height width unable to change

Body:
trying to make one horizontal box.. inside that update limits.
if u see the below sample code, u can understand how i set limits.
those limit classes height, i am unable to decrease.
could please tel me what is reason..
i want to make it using div and span only

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


问:
How to split string in ruby
I have a string:

```<code>"1 chocolate bar at 25"
</code>```

and I want to split this string into:

```<code> [1, "chocolate bar", 25]
</code>```

I don't know how to write a regex for this split. And I wanted to know whether there are any other functions to accomplish it.

答:
You may try returning captures property of match method on regex (\d+) ([\w ]+) at (\d+):

```<code>string.match(/(\d+) +(\D+) +at +(\d+)/).captures
</code>```

Live demo

Validating input string

If you didn't validate your input string to be within desired format already, then there may be a better approach in validating and capturing data. This solution also brings the idea of accepting any type of character in item_name field and decimal prices at the end:

```<code>string.match(/^(\d+) +(.*) +at +(\d+(?:\.\d+)?)$/).captures
</code>```

Title: How to split string in ruby

Body:
I have a string:

"1 chocolate bar at 25"

and I want to split this string into:

 [1, "chocolate bar", 25]

I don't know how to write a regex for this split. And I wanted to know whether there are any other functions to accomplish it.

Body:
You may try returning captures property of match method on regex (\d+) ([\w ]+) at (\d+):

string.match(/(\d+) +(\D+) +at +(\d+)/).captures

Live demo

Validating input string

If you didn't validate your input string to be within desired format already, then there may be a better approach in validating and capturing data. This solution also brings the idea of accepting any type of character in item_name field and decimal prices at the end:

string.match(/^(\d+) +(.*) +at +(\d+(?:\.\d+)?)$/).captures


问:
Different behavior in a job when execute it from the kitchen
I'm using Pentaho Data Integration 7.1 to copy some local files to a Hadoop 2.8.0 Cluster. I have created a Hadoop Cluster connection on Pentaho and I'm using a Hadoop Copy Files step. I can successfully upload the files when I execute my job from the GUI (spoon.sh), I can see the following line on the log:

Hadoop Copy Files - Processing row source File/folder source : [file:///home/etl/Desktop/users_full_20170620.csv] ... destination file/folder : [hdfs://hadoop:***@spark-master.cu:9000/value_iq]... wildcard : [null]

But when I attempt to run the same transformation using the kitchen.sh fails I got the following error:

Hadoop Copy Files - ERROR (version 7.1.0.0-12, build 1 from 2017-05-16 17.18.02 by buildguy) : Folder  file:///value_iq/bin/kettle/data-integration_7.1/hdfs:/hadoop:hadoop@spark-master.cu:9000/value_iq does not exist!

Somehow it's adding the path where the kitchen.sh is located in front of the hdfs url, assuming that the destinations enviroment is local.

This is a screenshot of my Hadoop Copy Files step

a JIRA report of this bug has been created: http://jira.pentaho.com/browse/PDI-16443

答: It`s an issue with UI dependency. Submit jira case please on  http://jira.pentaho.com</p>


问:
BackgroundWorker and instance variables
One thing that's always confused me is how a BackgroundWorker seems to have thread-safe access to the instance variables of the surrounding class.

Given a basic class:

```<code>public class BackgroundProcessor
{
    public List<int> Items { get; private set; }

    public BackgroundProcessor(IEnumerable<int> items)
    {
        Items = new List<int>(items);
    }

    public void DoWork()
    {
        BackgroundWorker worker = new BackgroundWorker();
        worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
        worker.DoWork += new DoWorkEventHandler(worker_DoWork);
        worker.RunWorkerAsync();
    }

    void worker_DoWork(object sender, DoWorkEventArgs e)
    {
        var processor = new ProcessingClass();

        processor.Process(this.Items); //Accessing the instance variable
    }

    void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        //Stuff goes here
    }
}
</code>```

Am I erroneous in my assumption the the call to processor.Process(this.Points); is a thread-safe call? How don't I get a cross-thread access violation?

I'm sure it's obvious, but it always has confused me.

答:
It's not thread-safe, it just looks that way.  You only get the cross-thread exception for GUI controls.  There is a hard requirement that GUI controls only be accessed from the thread that created them.  So the framework takes the time to check for calls from other threads.  Note that this is actually orthogonal to synchronization issues (at least from our point of view, not from the point of view of the USER subsystem) as you could still use locks to prevent multiple threads from accessing a control at the same time and still get a cross-thread violation.

Since the member variable is not a GUI control, there is no check for cross-thread calls, nor is there a check for race conditions.  You have to do that yourself with locking or some other mechanism.  You will get no exception unless the collection classes get corrupted.  I don't believe they are thread-safe, but I'm not sure what that ends up meaning, nor have I ever shared those kinds of variables between threads running at the same time, so I haven't actually had the problem.  Suffice it to say, it's better to do the right thing than to hope that the collection classes magically work.

Title: BackgroundWorker and instance variables

Body:
One thing that's always confused me is how a BackgroundWorker seems to have thread-safe access to the instance variables of the surrounding class.

Given a basic class:

public class BackgroundProcessor
{
    public List<int> Items { get; private set; }

    public BackgroundProcessor(IEnumerable<int> items)
    {
        Items = new List<int>(items);
    }

    public void DoWork()
    {
        BackgroundWorker worker = new BackgroundWorker();
        worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
        worker.DoWork += new DoWorkEventHandler(worker_DoWork);
        worker.RunWorkerAsync();
    }

    void worker_DoWork(object sender, DoWorkEventArgs e)
    {
        var processor = new ProcessingClass();

        processor.Process(this.Items); //Accessing the instance variable
    }

    void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        //Stuff goes here
    }
}

Am I erroneous in my assumption the the call to processor.Process(this.Points); is a thread-safe call? How don't I get a cross-thread access violation?

I'm sure it's obvious, but it always has confused me.


问:
How to find and modify specific rows using fields in that row in pandas dataframe?
I have this dataset

```<code>time_in     time_out     total_mins
8AM         10AM         120
6AM         8AM          120
6AM         8AM          -231
</code>```

What I am trying to do is get the wrong total_mins values, in this case the one that became negative. I wish to

identify the records with negative total_mins (Im ok with this)

recompute the timein and timeout difference and overwrite the existing total_mins value

I'm finding a lot of examples on how to use ix to get certain records based on a condition but what I am not sure about is how to use fields from that row, and use them to modify a certain field on a row. so basically, no. 2

only option that I can think of right now is to loop through the records, and perform test and modification but the documentation advises not to do this.

答:
I think you need difference by to_datetime, get total_seconds and divide by 60 for minutes.

Then change values by loc with mask:

```<code>mask = df['total_mins'] < 0

s = (pd.to_datetime(df.loc[mask, 'time_out'], format='%H%p') -
     pd.to_datetime(df.loc[mask, 'time_in'], format='%H%p'))
       .dt.total_seconds()
       .div(60)
       .astype(int)

print (s)
2    120
dtype: int32

df.loc[mask, 'total_mins'] = s
print (df)
  time_in time_out  total_mins
0     8AM     10AM         120
1     6AM      8AM         120
2     6AM      8AM         120
</code>```

Alternative solution with mask:

```<code>df['total_mins'] = df['total_mins'].mask(mask, s)
print (df)
  time_in time_out  total_mins
0     8AM     10AM         120
1     6AM      8AM         120
2     6AM      8AM         120
</code>```

Body:
I have this dataset

time_in     time_out     total_mins
8AM         10AM         120
6AM         8AM          120
6AM         8AM          -231

What I am trying to do is get the wrong total_mins values, in this case the one that became negative. I wish to

identify the records with negative total_mins (Im ok with this)

recompute the timein and timeout difference and overwrite the existing total_mins value

I'm finding a lot of examples on how to use ix to get certain records based on a condition but what I am not sure about is how to use fields from that row, and use them to modify a certain field on a row. so basically, no. 2

only option that I can think of right now is to loop through the records, and perform test and modification but the documentation advises not to do this.

Body:
I think you need difference by to_datetime, get total_seconds and divide by 60 for minutes.

Then change values by loc with mask:

mask = df['total_mins'] < 0

s = (pd.to_datetime(df.loc[mask, 'time_out'], format='%H%p') -
     pd.to_datetime(df.loc[mask, 'time_in'], format='%H%p'))
       .dt.total_seconds()
       .div(60)
       .astype(int)

print (s)
2    120
dtype: int32

df.loc[mask, 'total_mins'] = s
print (df)
  time_in time_out  total_mins
0     8AM     10AM         120
1     6AM      8AM         120
2     6AM      8AM         120

Alternative solution with mask:

df['total_mins'] = df['total_mins'].mask(mask, s)
print (df)
  time_in time_out  total_mins
0     8AM     10AM         120
1     6AM      8AM         120
2     6AM      8AM         120


问:
Rename Javascript Confirmation message box label from Yes to Proceed
Is there any way to rename the Javascript Confirmation message box label from Yes to Proceed?</p>

答: I think you can't, unless you use a library like jQueryUi which will provide an alternative : http://jqueryui.com/dialog/#modal-confirmation</p>


问:
Find next increment value in array JavaScript
I have array:

```<code>var array = [2,4,5,8,11];
</code>```

I need to get next increment value so in above example i need to get:

```<code> 1, 3, 6, 7, 9, 10, 12, 13 ....
</code>```

How can i do that in javascript?

答:
Try like this method using includes().its same as you like

Create the  number's with while loop without included array value

var array = [2, 4, 5, 8, 11];
var i = 0;
while (i < 20) {
  if (!array.includes(i)) {
    console.log(i)
  }
  i++
}```

Body:
I have array:

var array = [2,4,5,8,11];

I need to get next increment value so in above example i need to get:

 1, 3, 6, 7, 9, 10, 12, 13 ....

How can i do that in javascript?


问:
AWS Signature Error using Postman to access the AWS API Gateway when posting a binary
Works fine when doing a GET request or even a POST request with raw JSON. But sending a file returns this error:

"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. The Canonical String for this request should have been 'POST......."

Credentials are definitely correct.

答:
This is a known issue posted on 3rd July: https://github.com/postmanlabs/postman-app-support/issues/3232

Will wait for the update


问:
PHP MySQL : How to add data written into PHP into Mysql database
So ive got a little webserver going on with a phone-book.
You can click on "add a new member", but when you fill in everything from the web server and click on "save" the new row is not showing up in the show-phone-book file.
I translated it, but the files and comments and in german.

I don't think there is anything more needed than this file, adding new member.

When i execute it, i can fill everything in, click "save" , then it dies and i get to the error : Anfrage fehlgeschlagen.

```<code><?php

if ( $_GET['aktion'] == "speichern" )
{
$Nachname     = $_GET['Nachname'];
$Vorname      = $_GET['Vorname'];
$Anrede       = $_GET['Anrede'];
$Geburtsdatum = $_GET['Geburtsdatum'];
$Telefonnummer= $_GET['Telefonnummer'];
$Email        = $_GET['Email'];

$sql = "INSERT INTO Adressbuch SET ";
$sql .= " Nachname          = '$Nachname', ";
$sql .= " Vorname           = '$Vorname', ";
$sql .= " Anrede            = '$Anrede', ";
$sql .= " Geburtsdatum      = '$Geburtsdatum', ";
$sql .= " Telefonnummer     = '$Telefonnummer',";
$sql .= " Email             = '$Email'";

require_once ('konfiguration.php');
$db_erg = mysqli_query($db_con, $sql)
    or die(" Anfrage fehlgeschlagen");

exit;
}
?>

<form name="" action="" method="GET" enctype="text/html">
<p>Bitte geben Sie die Informationen von Ihrem neuen Kontakt ein<br>
</p>
<p>Nachname:<br>
<input type="text" name="Nachname" value="" size="60">
</p>

<p>Vorname:<br>
<input type="text" name="Vorname" value="" size="60">
</p>

<p>Anrede:<br>
<input type="radio" name="Anrede" value="w"> Frau
<input type="radio" name="Anrede" value="m"> Herr
</p>

<p>Geburtsdatum (YYYY-MM-DD):<br>
<input type="date" name="Geburtsdatum" value="" size="10">
</p>

<p>Telefonnummer:<br>
<input type="text" name="Telefonnummer" value="" size="60">
</p>

<p>E-Mail:<br>
<input type="text" name="Email" value="" size="60">
</p>

<input type="hidden" name="aktion" value="speichern">

<input type="Submit" name="" value="speichern">
</form>
</code>```

答:
You are using an UPDATE query syntax for an INSERT statement.

Try the following:

```<code>INSERT INTO Adressbuch (Nachname, Vorname, ...) VALUES ('$Nachname', '$Vorname',...);
</code>```

Body:
So ive got a little webserver going on with a phone-book.
You can click on "add a new member", but when you fill in everything from the web server and click on "save" the new row is not showing up in the show-phone-book file.
I translated it, but the files and comments and in german.

I don't think there is anything more needed than this file, adding new member.

When i execute it, i can fill everything in, click "save" , then it dies and i get to the error : Anfrage fehlgeschlagen.

<?php

if ( $_GET['aktion'] == "speichern" )
{
$Nachname     = $_GET['Nachname'];
$Vorname      = $_GET['Vorname'];
$Anrede       = $_GET['Anrede'];
$Geburtsdatum = $_GET['Geburtsdatum'];
$Telefonnummer= $_GET['Telefonnummer'];
$Email        = $_GET['Email'];

$sql = "INSERT INTO Adressbuch SET ";
$sql .= " Nachname          = '$Nachname', ";
$sql .= " Vorname           = '$Vorname', ";
$sql .= " Anrede            = '$Anrede', ";
$sql .= " Geburtsdatum      = '$Geburtsdatum', ";
$sql .= " Telefonnummer     = '$Telefonnummer',";
$sql .= " Email             = '$Email'";

require_once ('konfiguration.php');
$db_erg = mysqli_query($db_con, $sql)
    or die(" Anfrage fehlgeschlagen");

exit;
}
?>

<form name="" action="" method="GET" enctype="text/html">

Bitte geben Sie die Informationen von Ihrem neuen Kontakt ein

Nachname:

<input type="text" name="Nachname" value="" size="60">

Vorname:

<input type="text" name="Vorname" value="" size="60">

Anrede:

<input type="radio" name="Anrede" value="w"> Frau
<input type="radio" name="Anrede" value="m"> Herr

Geburtsdatum (YYYY-MM-DD):

<input type="date" name="Geburtsdatum" value="" size="10">

Telefonnummer:

<input type="text" name="Telefonnummer" value="" size="60">

E-Mail:

<input type="text" name="Email" value="" size="60">

<input type="hidden" name="aktion" value="speichern">

<input type="Submit" name="" value="speichern">
</form>

Body:
You are using an UPDATE query syntax for an INSERT statement.

Try the following:

INSERT INTO Adressbuch (Nachname, Vorname, ...) VALUES ('$Nachname', '$Vorname',...);


问:
Separate rows in multiple delete SQL server
I have a trigger. When i delete something in my table i want to create a row in other table named Archive with the row i deleted. All works fine. The problem is when i delete more than one row in the same time. It store just the first row in the table Archive. I think about creating a loop but how i separate them in subqueries to select every row. How do i solve that?</p>

```<code>ALTER TRIGGER [dbo].[trigArhiva]
   ON  [dbo].[student]
   AFTER DELETE
AS
SET NOCOUNT ON;
BEGIN
    declare @nume varchar(45);
    declare @anStudiu int;
    declare @prenume varchar(45);
    declare @CNP char(13);
    declare @grupa int;
    declare @idFacult int;
    declare @rowss int;
    declare @i int;
    select @rowss = count(*) from DELETED;
    set @i = 1;

    while (@i <= @rowss)
    begin

    select @nume = nume from DELETED;
    select @anStudiu = anStudiu from DELETED;
    select @prenume = prenume from DELETED;
    select @CNP = CNP from DELETED;
    select @grupa = idGrupa from DELETED;
    select @idFacult = idFacult from DELETED;

    insert into arhivaStud(nume, prenume, CNP, grupa, idFacult, anStudiu) values (@nume, @prenume, @CNP, @grupa, @idFacult, @anStudiu);

    set @i = @i+1;

    end
END
</code>```

答:
I think you should use something like this (deleted is an "internal" representation of all records deleted during the operation which recall the trigger):</p>

```<code>ALTER TRIGGER [dbo].[trigArhiva]
   ON  [dbo].[student]
   AFTER DELETE
AS
SET NOCOUNT ON;
BEGIN
INSERT INTO arhivaStud(nume, prenume, CNP, grupa, idFacult, anStudiu)
SELECT nume, prenume, CNP, idgrupa, idFacult, anStudiu FROM deleted
END
</code>```

Body:
I have a trigger. When i delete something in my table i want to create a row in other table named Archive with the row i deleted. All works fine. The problem is when i delete more than one row in the same time. It store just the first row in the table Archive. I think about creating a loop but how i separate them in subqueries to select every row. How do i solve that?

ALTER TRIGGER [dbo].[trigArhiva]
   ON  [dbo].[student]
   AFTER DELETE
AS
SET NOCOUNT ON;
BEGIN
    declare @nume varchar(45);
    declare @anStudiu int;
    declare @prenume varchar(45);
    declare @CNP char(13);
    declare @grupa int;
    declare @idFacult int;
    declare @rowss int;
    declare @i int;
    select @rowss = count(*) from DELETED;
    set @i = 1;

    while (@i <= @rowss)
    begin

    select @nume = nume from DELETED;
    select @anStudiu = anStudiu from DELETED;
    select @prenume = prenume from DELETED;
    select @CNP = CNP from DELETED;
    select @grupa = idGrupa from DELETED;
    select @idFacult = idFacult from DELETED;

    insert into arhivaStud(nume, prenume, CNP, grupa, idFacult, anStudiu) values (@nume, @prenume, @CNP, @grupa, @idFacult, @anStudiu);

    set @i = @i+1;

    end
END

Body:
I think you should use something like this (deleted is an "internal" representation of all records deleted during the operation which recall the trigger):

ALTER TRIGGER [dbo].[trigArhiva]
   ON  [dbo].[student]
   AFTER DELETE
AS
SET NOCOUNT ON;
BEGIN
INSERT INTO arhivaStud(nume, prenume, CNP, grupa, idFacult, anStudiu)
SELECT nume, prenume, CNP, idgrupa, idFacult, anStudiu FROM deleted
END


答:
For this you can create a new array where you can store the desired values. Then loop (in this case from 0 to 15) and check if the number is in the array-array. If it is not in the array, you can store the value in the values-array.

var array = [2, 4, 5, 8, 11];
var values = [];

for (var i = 0; i <= 15; i++) {
  if (!array.includes(i))
    values.push(i);
}

console.log(values); // Output: [0, 1, 3, 6, 7, 9, 10, 12, 13, 14, 15]```

Title: Find next increment value in array JavaScript


答:
I live in the country where prices might be float, hence the more sophisticated matcher for the price.</p>

```<code>"1 chocolate bar at 25".
  match(/\A(\d+)\s+(.*?)\s+at\s+(\d[.\d]*)\z/).
  captures
#⇒ ["1", "chocolate bar", "25"]
</code>```

Title: How to split string in ruby

Body:
I live in the country where prices might be float, hence the more sophisticated matcher for the price.

"1 chocolate bar at 25".
  match(/\A(\d+)\s+(.*?)\s+at\s+(\d[.\d]*)\z/).
  captures
#⇒ ["1", "chocolate bar", "25"]


问:
node.js: mailparser not working
I want to parse an email and found mailparser package. (installed it using "npm install mailparser").
i'm using windows 7.
i'm trying to run the simple example but the "end" event is not called and i don't see any logs.
this is what i run:

const MailParser = require("mailparser").MailParser;
const mailparser = new MailParser({debug: true});

let email = "From: 'Sender Name' <sender@example.com>\r\n"+
    "To: 'Receiver Name' <receiver@example.com>\r\n"+
    "Subject: Hello world!\r\n"+
    "\r\n"+
    "How are you today?";

// setup an event listener when the parsing finishes
mailparser.on("end", function(mail_object){
    console.log("From:", mail_object.from); //[{address:'sender@example.com',name:'Sender Name'}]
    console.log("Subject:", mail_object.subject); // Hello world!
    console.log("Text body:", mail_object.text); // How are you today?
});

// send the email source to the parser
mailparser.write(email);
mailparser.end();```

What am i doing wrong?
Thx

答:
According to the fine manual, there's only two events: headers and data.

Perhaps it's easiest to use the simpleParser instead of the lower-level (event-driven) MailParser:

```<code>const simpleParser = require('mailparser').simpleParser;
...
simpleParser(email).then(function(mail_object) {
  console.log("From:", mail_object.from.value);
  console.log("Subject:", mail_object.subject);
  console.log("Text body:", mail_object.text);
}).catch(function(err) {
  console.log('An error occurred:', err.message);
});
</code>```

Title: node.js: mailparser not working

Body:
I want to parse an email and found mailparser package. (installed it using "npm install mailparser").
i'm using windows 7.
i'm trying to run the simple example but the "end" event is not called and i don't see any logs.
this is what i run:

const MailParser = require("mailparser").MailParser;
const mailparser = new MailParser({debug: true});

let email = "From: 'Sender Name' <sender@example.com>\r\n"+
    "To: 'Receiver Name' <receiver@example.com>\r\n"+
    "Subject: Hello world!\r\n"+
    "\r\n"+
    "How are you today?";

// setup an event listener when the parsing finishes
mailparser.on("end", function(mail_object){
    console.log("From:", mail_object.from); //[{address:'sender@example.com',name:'Sender Name'}]
    console.log("Subject:", mail_object.subject); // Hello world!
    console.log("Text body:", mail_object.text); // How are you today?
});

// send the email source to the parser
mailparser.write(email);
mailparser.end();

What am i doing wrong?
Thx

Body:
According to the fine manual, there's only two events: headers and data.

Perhaps it's easiest to use the simpleParser instead of the lower-level (event-driven) MailParser:

const simpleParser = require('mailparser').simpleParser;
...
simpleParser(email).then(function(mail_object) {
  console.log("From:", mail_object.from.value);
  console.log("Subject:", mail_object.subject);
  console.log("Text body:", mail_object.text);
}).catch(function(err) {
  console.log('An error occurred:', err.message);
});