Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22fa00199
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22fa00199
Commits
cabcaef7
Unverified
Commit
cabcaef7
authored
2 years ago
by
reusee
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fileservice: add GetForETL (#4788)
fileservice: add GetForETL Approved by: @nnsgmsone
parent
45399d8f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/fileservice/get.go
+25
-0
25 additions, 0 deletions
pkg/fileservice/get.go
pkg/sql/colexec/external/external.go
+2
-44
2 additions, 44 deletions
pkg/sql/colexec/external/external.go
with
27 additions
and
44 deletions
pkg/fileservice/get.go
+
25
−
0
View file @
cabcaef7
...
...
@@ -16,6 +16,7 @@ package fileservice
import
(
"fmt"
"path/filepath"
"strings"
)
...
...
@@ -46,3 +47,27 @@ func Get[T any](fs FileService, name string) (res T, err error) {
}
return
}
func
GetForETL
(
fs
FileService
,
path
string
)
(
res
ETLFileService
,
readPath
string
,
err
error
)
{
fsPath
,
err
:=
ParsePath
(
path
)
if
err
!=
nil
{
return
nil
,
""
,
err
}
if
fsPath
.
Service
==
""
{
// no service, create local ETL fs
dir
,
file
:=
filepath
.
Split
(
path
)
res
,
err
=
NewLocalETLFS
(
"etl"
,
dir
)
if
err
!=
nil
{
return
nil
,
""
,
err
}
readPath
=
file
}
else
{
// get etl fs
res
,
err
=
Get
[
ETLFileService
](
fs
,
fsPath
.
Service
)
if
err
!=
nil
{
return
nil
,
""
,
err
}
readPath
=
fsPath
.
Full
}
return
}
This diff is collapsed.
Click to expand it.
pkg/sql/colexec/external/external.go
+
2
−
44
View file @
cabcaef7
...
...
@@ -27,7 +27,6 @@ import (
"io"
"math"
"path"
"path/filepath"
"strconv"
"strings"
"sync/atomic"
...
...
@@ -95,35 +94,15 @@ func Call(_ int, proc *process.Process, arg any) (bool, error) {
func
ReadDir
(
param
*
tree
.
ExternParam
)
(
fileList
[]
string
,
err
error
)
{
dir
,
pattern
:=
path
.
Split
(
param
.
Filepath
)
var
fs
fileservice
.
ETLFileService
var
readPath
string
fsPath
,
err
:=
fileservice
.
ParsePath
(
dir
)
fs
,
readPath
,
err
:=
fileservice
.
GetForETL
(
param
.
FileService
,
dir
+
"/"
)
if
err
!=
nil
{
return
nil
,
err
}
if
fsPath
.
Service
==
""
{
// no service, create ETL fs
fs
,
err
=
fileservice
.
NewLocalETLFS
(
"etl"
,
dir
)
if
err
!=
nil
{
return
nil
,
err
}
readPath
=
""
}
else
{
// get etl fs
fs
,
err
=
fileservice
.
Get
[
fileservice
.
ETLFileService
](
param
.
FileService
,
fsPath
.
Service
)
if
err
!=
nil
{
return
nil
,
err
}
readPath
=
dir
}
ctx
:=
context
.
TODO
()
entries
,
err
:=
fs
.
List
(
ctx
,
readPath
)
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
entry
:=
range
entries
{
matched
,
_
:=
path
.
Match
(
pattern
,
entry
.
Name
)
if
!
matched
{
...
...
@@ -131,35 +110,14 @@ func ReadDir(param *tree.ExternParam) (fileList []string, err error) {
}
fileList
=
append
(
fileList
,
path
.
Join
(
dir
,
entry
.
Name
))
}
return
}
func
ReadFile
(
param
*
tree
.
ExternParam
)
(
io
.
ReadCloser
,
error
)
{
var
fs
fileservice
.
ETLFileService
var
readPath
string
fsPath
,
err
:=
fileservice
.
ParsePath
(
param
.
Filepath
)
fs
,
readPath
,
err
:=
fileservice
.
GetForETL
(
param
.
FileService
,
param
.
Filepath
)
if
err
!=
nil
{
return
nil
,
err
}
if
fsPath
.
Service
==
""
{
// no service, create ETL fs
dir
,
file
:=
filepath
.
Split
(
param
.
Filepath
)
fs
,
err
=
fileservice
.
NewLocalETLFS
(
"etl"
,
dir
)
if
err
!=
nil
{
return
nil
,
err
}
readPath
=
file
}
else
{
// get etl fs
fs
,
err
=
fileservice
.
Get
[
fileservice
.
ETLFileService
](
param
.
FileService
,
fsPath
.
Service
)
if
err
!=
nil
{
return
nil
,
err
}
readPath
=
fsPath
.
Full
}
var
r
io
.
ReadCloser
vec
:=
fileservice
.
IOVector
{
FilePath
:
readPath
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment