Skip to content

Conversation

@Xuxue1
Copy link
Contributor

@Xuxue1 Xuxue1 commented Jul 8, 2019

Add string function split_part. Just like postgresql

@imay imay closed this Jul 9, 2019
@imay imay reopened this Jul 9, 2019

StringVal StringFunctions::split_part(FunctionContext* context,const StringVal& content,
const StringVal& delimiter,const IntVal& field) {
if (field.val <= 0) return StringVal::null();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if content、delimiter or field is null?

}


StringVal StringFunctions::split_part(FunctionContext* context,const StringVal& content,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
StringVal StringFunctions::split_part(FunctionContext* context,const StringVal& content,
StringVal StringFunctions::split_part(FunctionContext* context, const StringVal& content,



StringVal StringFunctions::split_part(FunctionContext* context,const StringVal& content,
const StringVal& delimiter,const IntVal& field) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const StringVal& delimiter,const IntVal& field) {
const StringVal& delimiter, const IntVal& field) {

const StringVal& delimiter,const IntVal& field) {
if (field.val <= 0) return StringVal::null();
int find[field.val]; //store substring position
for(int i=0;i<=field.val;i++) find[i] = -1; // init
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for(int i=0;i<=field.val;i++) find[i] = -1; // init
for (int i=0;i<=field.val;i++) find[i] = -1; // init

int find[field.val]; //store substring position
for(int i=0;i<=field.val;i++) find[i] = -1; // init
int from = 0;
for(int i=1;i<=field.val;i++){ // find
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for(int i=1;i<=field.val;i++){ // find
for (int i=1; i<=field.val; i++) { // find

for(int i=0;i<=field.val;i++) find[i] = -1; // init
int from = 0;
for(int i=1;i<=field.val;i++){ // find
find[i-1] = indexOf(content.ptr,0,content.len, delimiter.ptr,0,delimiter.len,from);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
find[i-1] = indexOf(content.ptr,0,content.len, delimiter.ptr,0,delimiter.len,from);
find[i-1] = indexOf(content.ptr,0, content.len, delimiter.ptr, 0, delimiter.len, from);

You should add one space after punctuation

break;
}
}
if ((field.val>1 && find[field.val-2] == -1) || (field.val==1 && find[field.val-1] == -1)){ // not find
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ((field.val>1 && find[field.val-2] == -1) || (field.val==1 && find[field.val-1] == -1)){ // not find
if ((field.val > 1 && find[field.val-2] == -1) || (field.val == 1 && find[field.val-1] == -1)){ // not find

if ((field.val>1 && find[field.val-2] == -1) || (field.val==1 && find[field.val-1] == -1)){ // not find
return StringVal::null();
}
int start_pos,len;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define len when it is needed

return do_money_format(context, ss.str());
}

static int indexOf(const uint8_t* source, int sourceOffset, int sourceCount,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static int indexOf(const uint8_t* source, int sourceOffset, int sourceCount,
static int index_of(const uint8_t* source, int sourceOffset, int sourceCount,

@Xuxue1
Copy link
Contributor Author

Xuxue1 commented Jul 9, 2019

感谢指出问题, 我仔细修改下再提交。

@Xuxue1 Xuxue1 closed this Jul 9, 2019
swjtu-zhanglei pushed a commit to swjtu-zhanglei/incubator-doris that referenced this pull request Jul 25, 2023
… (apache#1445)

* (Enhancement)[load-json] support simdjson in new json reader (apache#16903)

be config:
enable_simdjson_reader=true

related PR apache#11665

* [Optimize](simd json reader) Cached search results for previous row (keyed as index in JSON object) - used as a hint. (apache#17124)

* [Optimize](simd json reader) Cached search results for previous row (keyed as index in JSON object) - used as a hint.

`_simdjson_set_column_value` could become a hot spot while parsing json in simdjson mode,
introduce `_prev_positions` to cache results for previous row (keyed as index in JSON object) due to the json name field order,
should be quite the same between each lines

* fix case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants