Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement for GET_ROW/GET_COLUMN #544

Merged
merged 2 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 72 additions & 51 deletions src/zcl_excel_columns.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -5,83 +5,104 @@ class ZCL_EXCEL_COLUMNS definition

*"* public components of class ZCL_EXCEL_COLUMNS
*"* do not include other source files here!!!
public section.

methods ADD
importing
!IO_COLUMN type ref to ZCL_EXCEL_COLUMN .
methods CLEAR .
methods CONSTRUCTOR .
methods GET
importing
!IP_INDEX type I
returning
value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN .
methods GET_ITERATOR
returning
value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR .
methods IS_EMPTY
returning
value(IS_EMPTY) type FLAG .
methods REMOVE
importing
!IO_COLUMN type ref to ZCL_EXCEL_COLUMN .
methods SIZE
returning
value(EP_SIZE) type I .
public section.
types:
begin of MTY_S_HASHED_COLUMN,
COLUMN_INDEX type INT4,
COLUMN type ref to ZCL_EXCEL_COLUMN,
end of MTY_S_HASHED_COLUMN ,
MTY_TS_HASEHD_COLUMN type hashed table of MTY_S_HASHED_COLUMN with unique key COLUMN_INDEX.

methods ADD
importing
!IO_COLUMN type ref to ZCL_EXCEL_COLUMN .
methods CLEAR .
methods CONSTRUCTOR .
methods GET
importing
!IP_INDEX type I
returning
value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN .
methods GET_ITERATOR
returning
value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR .
methods IS_EMPTY
returning
value(IS_EMPTY) type FLAG .
methods REMOVE
importing
!IO_COLUMN type ref to ZCL_EXCEL_COLUMN .
methods SIZE
returning
value(EP_SIZE) type I .
*"* protected components of class ZABAP_EXCEL_WORKSHEETS
*"* do not include other source files here!!!
protected section.
protected section.
*"* private components of class ZABAP_EXCEL_RANGES
*"* do not include other source files here!!!
private section.
private section.

data COLUMNS type ref to CL_OBJECT_COLLECTION .
data COLUMNS type ref to CL_OBJECT_COLLECTION .
data COLUMNS_HASEHD type MTY_TS_HASEHD_COLUMN .
ENDCLASS.



CLASS ZCL_EXCEL_COLUMNS IMPLEMENTATION.


METHOD add.
columns->add( io_column ).
ENDMETHOD.
method ADD.
data: LS_HASHED_COLUMN type MTY_S_HASHED_COLUMN.

LS_HASHED_COLUMN-COLUMN_INDEX = IO_COLUMN->GET_COLUMN_INDEX( ).
LS_HASHED_COLUMN-COLUMN = IO_COLUMN.

METHOD clear.
columns->clear( ).
ENDMETHOD.
insert LS_HASHED_COLUMN into table COLUMNS_HASEHD .

COLUMNS->ADD( IO_COLUMN ).
endmethod.

METHOD constructor.

CREATE OBJECT columns.
method CLEAR.
clear COLUMNS_HASEHD.
COLUMNS->CLEAR( ).
endmethod.

ENDMETHOD.

method CONSTRUCTOR.

METHOD get.
eo_column ?= columns->if_object_collection~get( ip_index ).
ENDMETHOD.
create object COLUMNS.

endmethod.

METHOD get_iterator.
eo_iterator ?= columns->if_object_collection~get_iterator( ).
ENDMETHOD.

method GET.
field-symbols: <LS_HASHED_COLUMN> type MTY_S_HASHED_COLUMN.

METHOD is_empty.
is_empty = columns->if_object_collection~is_empty( ).
ENDMETHOD.
read table COLUMNS_HASEHD with key COLUMN_INDEX = IP_INDEX assigning <LS_HASHED_COLUMN>.
if SY-SUBRC = 0.
EO_COLUMN = <LS_HASHED_COLUMN>-COLUMN.
endif.
endmethod.


METHOD remove.
columns->remove( io_column ).
ENDMETHOD.
method GET_ITERATOR.
EO_ITERATOR ?= COLUMNS->IF_OBJECT_COLLECTION~GET_ITERATOR( ).
endmethod.


METHOD size.
ep_size = columns->if_object_collection~size( ).
ENDMETHOD.
method IS_EMPTY.
IS_EMPTY = COLUMNS->IF_OBJECT_COLLECTION~IS_EMPTY( ).
endmethod.


method REMOVE.
delete table COLUMNS_HASEHD with table key COLUMN_INDEX = IO_COLUMN->GET_COLUMN_INDEX( ) .
COLUMNS->REMOVE( IO_COLUMN ).
endmethod.


method SIZE.
EP_SIZE = COLUMNS->IF_OBJECT_COLLECTION~SIZE( ).
endmethod.
ENDCLASS.
124 changes: 73 additions & 51 deletions src/zcl_excel_rows.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -12,81 +12,103 @@ class ZCL_EXCEL_ROWS definition
*"* do not include other source files here!!!
*"* protected components of class ZABAP_EXCEL_WORKSHEETS
*"* do not include other source files here!!!
public section.

methods ADD
importing
!IO_ROW type ref to ZCL_EXCEL_ROW .
methods CLEAR .
methods CONSTRUCTOR .
methods GET
importing
!IP_INDEX type I
returning
value(EO_ROW) type ref to ZCL_EXCEL_ROW .
methods GET_ITERATOR
returning
value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR .
methods IS_EMPTY
returning
value(IS_EMPTY) type FLAG .
methods REMOVE
importing
!IO_ROW type ref to ZCL_EXCEL_ROW .
methods SIZE
returning
value(EP_SIZE) type I .
PROTECTED SECTION.
public section.
types:
begin of MTY_S_HASHED_ROW,
ROW_INDEX type INT4,
ROW type ref to ZCL_EXCEL_ROW,
end of MTY_S_HASHED_ROW ,
MTY_TS_HASEHD_ROW type hashed table of MTY_S_HASHED_ROW with unique key ROW_INDEX.

methods ADD
importing
!IO_ROW type ref to ZCL_EXCEL_ROW .
methods CLEAR .
methods CONSTRUCTOR .
methods GET
importing
!IP_INDEX type I
returning
value(EO_ROW) type ref to ZCL_EXCEL_ROW .
methods GET_ITERATOR
returning
value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR .
methods IS_EMPTY
returning
value(IS_EMPTY) type FLAG .
methods REMOVE
importing
!IO_ROW type ref to ZCL_EXCEL_ROW .
methods SIZE
returning
value(EP_SIZE) type I .
protected section.
*"* private components of class ZABAP_EXCEL_RANGES
*"* do not include other source files here!!!
PRIVATE SECTION.
private section.

data ROWS type ref to CL_OBJECT_COLLECTION .
data ROWS_HASEHD type MTY_TS_HASEHD_ROW .

DATA rows TYPE REF TO cl_object_collection .
ENDCLASS.



CLASS ZCL_EXCEL_ROWS IMPLEMENTATION.


METHOD add.
rows->add( io_row ).
ENDMETHOD. "ADD
method ADD.
data: LS_HASHED_ROW type MTY_S_HASHED_ROW.

LS_HASHED_ROW-ROW_INDEX = IO_ROW->GET_ROW_INDEX( ).
LS_HASHED_ROW-ROW = IO_ROW.

insert LS_HASHED_ROW into table ROWS_HASEHD.

ROWS->ADD( IO_ROW ).
endmethod. "ADD


method CLEAR.
clear ROWS_HASEHD.
ROWS->CLEAR( ).
endmethod. "CLEAR

METHOD clear.
rows->clear( ).
ENDMETHOD. "CLEAR

method CONSTRUCTOR.

METHOD constructor.
create object ROWS.

CREATE OBJECT rows.
endmethod. "CONSTRUCTOR

ENDMETHOD. "CONSTRUCTOR

method GET.
field-symbols: <LS_HASHED_ROW> type MTY_S_HASHED_ROW.

METHOD get.
eo_row ?= rows->if_object_collection~get( ip_index ).
ENDMETHOD. "GET
read table ROWS_HASEHD with key ROW_INDEX = IP_INDEX assigning <LS_HASHED_ROW>.
if SY-SUBRC = 0.
EO_ROW = <LS_HASHED_ROW>-ROW.
endif.
endmethod. "GET


METHOD get_iterator.
eo_iterator ?= rows->if_object_collection~get_iterator( ).
ENDMETHOD. "GET_ITERATOR
method GET_ITERATOR.
EO_ITERATOR ?= ROWS->IF_OBJECT_COLLECTION~GET_ITERATOR( ).
endmethod. "GET_ITERATOR


METHOD is_empty.
is_empty = rows->if_object_collection~is_empty( ).
ENDMETHOD. "IS_EMPTY
method IS_EMPTY.
IS_EMPTY = ROWS->IF_OBJECT_COLLECTION~IS_EMPTY( ).
endmethod. "IS_EMPTY


METHOD remove.
rows->remove( io_row ).
ENDMETHOD. "REMOVE
method REMOVE.
delete table ROWS_HASEHD with table key ROW_INDEX = IO_ROW->GET_ROW_INDEX( ) .
ROWS->REMOVE( IO_ROW ).
endmethod. "REMOVE


METHOD size.
ep_size = rows->if_object_collection~size( ).
ENDMETHOD. "SIZE
method SIZE.
EP_SIZE = ROWS->IF_OBJECT_COLLECTION~SIZE( ).
endmethod. "SIZE
ENDCLASS.
Loading