Weiping Shi

125 papers A* 13A 11C 3Misc 5Journal 67Unranked 26
YearRankTypeTitle / Venue / Authors
2025 conf
ASAP
Zhenrui Wang, Jiang Hu, Weiping Shi
2025 J jnl
IEEE Open J. Commun. Soc.
Ke Yang, Rongen Dong, Wei Gao, Feng Shu, Weiping Shi, Yan Wang, Xuehui Wang, Jiangzhou Wang
2024 J jnl
IEEE Trans. Wirel. Commun.
Feng Shu, Rongen Dong, Yeqing Lin, Hangjia He, Weiping Shi, Yu Yao, Long Shi, Qiankun Cheng, Jun Li, Jiangzhou Wang
2024 J jnl
CoRR
Ke Yang, Rongen Dong, Wei Gao, Feng Shu, Weiping Shi, Yan Wang, Xuehui Wang, Jiangzhou Wang
2024 J jnl
IEEE Trans. Wirel. Commun.
Feng Shu, Yan Wang, Xuehui Wang, Guiyang Xia, Lili Yang, Weiping Shi, Chong Shen, Jiangzhou Wang
2024 J jnl
Sci. China Inf. Sci.
Weiping Shi, Cunhua Pan, Feng Shu, Yongpeng Wu, Jiangzhou Wang, Yongqiang Bao, Jin Tian
2023 J jnl
Axioms
Bowen Liu, Weiping Shi
2023 J jnl
Entropy
Bowen Liu, Weiping Shi
2023 J jnl
CoRR
Xuehui Wang, Feng Shu, Riqing Chen, Peng Zhang, Qi Zhang, Guiyang Xia, Weiping Shi, Jiangzhou Wang
2023 J jnl
Frontiers Inf. Technol. Electron. Eng.
Xuehui Wang, Feng Shu, Riqing Chen, Peng Zhang, Qi Zhang, Guiyang Xia, Weiping Shi, Jiangzhou Wang
2023 J jnl
IEEE Wirel. Commun. Lett.
Yeqing Lin, Feng Shu, Rongen Dong, Riqing Chen, Siling Feng, Weiping Shi, Jing Liu, Jiangzhou Wang
2023 J jnl
IEEE Trans. Veh. Technol.
Xuehui Wang, Peng Zhang, Feng Shu, Weiping Shi, Jiangzhou Wang
2023 J jnl
CoRR
Feng Shu, Lili Yang, Yan Wang, Xuehui Wang, Weiping Shi, Chong Shen, Jiangzhou Wang
2023 J jnl
CoRR
Baihua Shi, Yang Wang, Danqi Li, Wenlong Cai, Jinyong Lin, Shuo Zhang, Weiping Shi, Shihao Yan, Feng Shu
2022 J jnl
IEEE Trans. Green Commun. Netw.
Xuehui Wang, Feng Shu, Weiping Shi, Xiaopeng Liang, Rongen Dong, Jun Li, Jiangzhou Wang
2022 J jnl
IEEE J. Sel. Top. Signal Process.
Feng Shu, Lili Yang, Xinyi Jiang, Wenlong Cai, Weiping Shi, Mengxing Huang, Jiangzhou Wang, Xiaohu You
2022 J jnl
IEEE Trans. Veh. Technol.
Xin Cheng, Weiping Shi, Wenlong Cai, Weiqiang Zhu, Tong Shen, Feng Shu, Jiangzhou Wang
2022 J jnl
IEEE Trans. Veh. Technol.
Hangjia He, Ting Su, Hongjun Wang, Yin Teng, Weiping Shi, Feng Shu, Jiangzhou Wang
2022 J jnl
IEEE Trans. Veh. Technol.
Yang Wang, Weiping Shi, Mengxing Huang, Feng Shu, Jiangzhou Wang
2022 J jnl
IEEE Trans. Commun.
Xin Cheng, Yan Lin, Weiping Shi, Jiayu Li, Cunhua Pan, Feng Shu, Yongpeng Wu, Jiangzhou Wang
2022 J jnl
Secur. Saf.
Weiping Shi, Xinyi Jiang, Jinsong Hu, Abdeldime Mohamed Salih Abdelgader, Yin Teng, Yang Wang, Hangjia He, Rongen Dong, Feng Shu, Jiangzhou Wang
2022 J jnl
CoRR
Xuehui Wang, Peng Zhang, Feng Shu, Weiping Shi, Jiangzhou Wang
2022 J jnl
IEEE Trans. Commun.
Weiping Shi, Qingqing Wu, Fu Xiao, Feng Shu, Jiangzhou Wang
2021 J jnl
CoRR
Lu Zhang, Bin Wang, Vivek Sarin, Weiping Shi, P. R. Kumar, Le Xie
2021 J jnl
CoRR
Xuehui Wang, Feng Shu, Weiping Shi, Xiaopeng Liang, Rongen Dong, Jun Li, Jiangzhou Wang
2021 J jnl
CoRR
Feng Shu, Xinyi Jiang, Wenlong Cai, Weiping Shi, Mengxing Huang, Jiangzhou Wang, Xiaohu You
2021 J jnl
IEEE Trans. Commun.
Feng Shu, Yin Teng, Jiayu Li, Mengxing Huang, Weiping Shi, Jun Li, Yongpeng Wu, Jiangzhou Wang
2021 J jnl
IEEE Commun. Lett.
Weiping Shi, Xiaobo Zhou, Linqiong Jia, Yongpeng Wu, Feng Shu, Jiangzhou Wang
2021 J jnl
CoRR
Xin Cheng, Yan Lin, Weiping Shi, Jiayu Li, Cunhua Pan, Feng Shu, Yongpeng Wu, Jiangzhou Wang
2021 J jnl
CoRR
Hangjia He, Ting Su, Hongjun Wang, Yin Teng, Weiping Shi, Feng Shu, Jiangzhou Wang
2021 J jnl
CoRR
Weiping Shi, Xinyi Jiang, Jinsong Hu, Yin Teng, Yang Wang, Hangjia He, Rongen Dong, Feng Shu, Jiangzhou Wang
2020 J jnl
CoRR
Feng Shu, Jiayu Li, Mengxing Huang, Weiping Shi, Yin Teng, Jun Li, Yongpeng Wu, Jiangzhou Wang
2020 conf
ISQED
Zhixing Li, Weiping Shi
2019 J jnl
Bioinform.
Yang Shi, Mengqiao Wang, Weiping Shi, Ji-Hyun Lee, Huining Kang, Hui Jiang
2019 conf
ISGT
Lu Zhang, Bin Wang, Dongqi Wu, Le Xie, P. R. Kumar, Weiping Shi
2019 J jnl
Soft Comput.
Weiping Shi, ShengWen Yu
2018 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Yuhan Zhou, Robert D. Nevels, Weiping Shi
2016 J jnl
Appl. Math. Comput.
Fang Liu, Weiping Shi, Fangfang Wu
2016 C conf
ISCAS
Zhelun Yu, Jincheng Su, Fan Yang, Yangfeng Su, Xuan Zeng, Dian Zhou, Weiping Shi
2016 C conf
ISCAS
Xuan Zeng, Chenlei Fang, Qicheng Huang, Fan Yang, Dian Zhou, Wei Cai, Weiping Shi
2016 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Yuhan Zhou, Yong Zhang, Vivek Sarin, Wangqi Qiu, Weiping Shi
2016 J jnl
Wirel. Pers. Commun.
Dan Wang, Weiping Shi, Yu Liu, Yong Liao
2013 J jnl
J. Networks
Dan Wang, Weiping Shi, Xiaowen Li
2012 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Zhuo Li, Nancy Ying Zhou, Weiping Shi
2011 conf
ISPD
Yi-Le Huang, Jiang Hu, Weiping Shi
2011 J jnl
Comput. Math. Appl.
Lixia Ding, Weiping Shi, Hongwen Luo
2010 conf
ISPD
Zhuo Li, David A. Papa, Charles J. Alpert, Shiyan Hu, Weiping Shi, Cliff C. N. Sze, Nancy Ying Zhou
2009 conf
ISQED
Uday Doddannagari, Shiyan Hu, Weiping Shi
2009 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Yang Yi, R. Wenzel, Vivek Sarin, Weiping Shi
2009 conf
ISQED
Nancy Ying Zhou, Rouwaida Kanj, Kanak Agarwal, Zhuo Li, Rajiv V. Joshi, Sani R. Nassif, Weiping Shi
2008 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Yang Yi, Peng Li, Vivek Sarin, Weiping Shi
2008 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Yifang Liu, Jiang Hu, Weiping Shi
2008 A* conf
DAC
Zhanyuan Jiang, Weiping Shi
2008 J jnl
IET Comput. Digit. Tech.
Kanupriya Gulati, Mandar Waghmode, Sunil P. Khatri, Weiping Shi
2008 conf
ISPD
Yifang Liu, Jiang Hu, Weiping Shi
2008 A conf
ISLPED
Rouwaida Kanj, Rajiv V. Joshi, Zhuo Li, Jente B. Kuang, Hung C. Ngo, Nancy Ying Zhou, Weiping Shi, Sani R. Nassif
2007 conf
ASP-DAC
Nancy Ying Zhou, Zhuo Li, Yuxin Tian, Weiping Shi, Frank Liu
2007 A* conf
DAC
Zhanyuan Jiang, Shiyan Hu, Weiping Shi
2007 conf
ISQED
Zhanyuan Jiang, Shiyan Hu, Jiang Hu, Weiping Shi
2007 J jnl
CoRR
Zhuo Li, Weiping Shi
2007 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Shiyan Hu, Charles J. Alpert, Jiang Hu, Shrirang K. Karandikar, Zhuo Li, Weiping Shi, Chin Ngai Sze
2007 A* conf
DAC
Nancy Ying Zhou, Zhuo Li, Weiping Shi
2007 A conf
ICCAD
Yang Yi, Peng Li, Vivek Sarin, Weiping Shi
2007 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Chin Ngai Sze, Charles J. Alpert, Jiang Hu, Weiping Shi
2007 conf
ISQED
Zhuo Li, Charles J. Alpert, Stephen T. Quay, Sachin S. Sapatnekar, Weiping Shi
2007 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Zhuo Li, Nancy Ying Zhou, Weiping Shi
2006 A conf
ICCAD
Zhanyuan Jiang, Shiyan Hu, Jiang Hu, Zhuo Li, Weiping Shi
2006 conf
ASP-DAC
Zhuo Li, Weiping Shi
2006 C conf
ICCD
Mandar Waghmode, Kanupriya Gulati, Sunil P. Khatri, Weiping Shi
2006 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Zhuo Li, Weiping Shi
2006 A* conf
DAC
Mandar Waghmode, Zhuo Li, Weiping Shi
2006 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Shu Yan, Vivek Sarin, Weiping Shi
2006 A* conf
DAC
Shiyan Hu, Charles J. Alpert, Jiang Hu, Shrirang K. Karandikar, Zhuo Li, Weiping Shi, Cliff C. N. Sze
2006 A* conf
DAC
Peng Li, Weiping Shi
2005 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Weiping Shi, Zhuo Li
2005 A conf
ITC
Jing Wang, Ziding Yue, Xiang Lu, Wangqi Qiu, Weiping Shi, D. M. H. Walker
2005 A conf
DATE
Zhuo Li, Weiping Shi
2005 A conf
ITC
Yuxin Tian, Michael R. Grimaila, Weiping Shi, M. Ray Mercer
2005 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Xiang Lu, Zhuo Li, Wangqi Qiu, D. M. H. Walker, Weiping Shi
2005 conf
ASP-DAC
Zhuo Li, Cliff C. N. Sze, Charles J. Alpert, Jiang Hu, Weiping Shi
2005 A* conf
DAC
Cliff C. N. Sze, Charles J. Alpert, Jiang Hu, Weiping Shi
2005 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Shu Yan, Vivek Sarin, Weiping Shi
2005 Misc conf
VTS
Jing Wang, Xiang Lu, Wangqi Qiu, Ziding Yue, Steve Fancler, Weiping Shi, D. M. H. Walker
2005 J jnl
SIAM J. Comput.
Weiping Shi, Chen Su
2004 conf
MTV
Xiang Lu, Zhuo Li, Wangqi Qiu, D. M. H. Walker, Weiping Shi
2004 conf
ISQED
Fangqing Yu, Weiping Shi
2004 Misc conf
VTS
Wangqi Qiu, Xiang Lu, Jing Wang, Zhuo Li, D. M. H. Walker, Weiping Shi
2004 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Weiping Shi, Fangqing Yu
2004 conf
ASP-DAC
Weiping Shi, Zhuo Li, Charles J. Alpert
2004 A conf
ITC
Wangqi Qiu, Jing Wang, D. M. H. Walker, Divya Reddy, Zhuo Li, Weiping Shi, Hari Balachandran
2004 conf
ASP-DAC
Xiang Lu, Zhuo Li, Wangqi Qiu, D. M. H. Walker, Weiping Shi
2004 A* conf
SODA
Wangqi Qiu, Weiping Shi
2004 conf
ISQED
Xiang Lu, Zhuo Li, Wangqi Qiu, D. M. H. Walker, Weiping Shi
2004 A* conf
DAC
Shu Yan, Vivek Sarin, Weiping Shi
2003 Misc conf
VTS
Zhuo Li, Xiang Lu, Wangqi Qiu, Weiping Shi, D. M. H. Walker
2003 J jnl
ACM Trans. Design Autom. Electr. Syst.
Zhuo Li, Xiang Lu, Wangqi Qiu, Weiping Shi, D. M. H. Walker
2003 A* conf
DAC
Weiping Shi, Zhuo Li
2003 conf
DFT
Wangqi Qiu, Xiang Lu, Zhuo Li, D. M. H. Walker, Weiping Shi
2003 conf
ASP-DAC
Shu Yan, Jianguo Liu, Weiping Shi
2003 conf
Asian Test Symposium
Yuxin Tian, Michael R. Grimaila, Weiping Shi, M. Ray Mercer
2003 conf
ISCAS (4)
Zhuo Li, Xiang Lu, Weiping Shi
2003 conf
CARS
Qiushuang Wang, Beijie Luo, Guang Zhi, Dangsheng Huang, Yong Xu, Weiping Shi
2002 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Weiping Shi, Jianguo Liu, Naveen Kakani, Tiejun Yu
2002 A* conf
DAC
Hemant Mahawar, Vivek Sarin, Weiping Shi
2002 A conf
IPDPS
Hemant Mahawar, Vivek Sarin, Weiping Shi
2001 J jnl
SIAM J. Discret. Math.
Weiping Shi, Douglas B. West
2000 J jnl
J. Algorithms
Farhad Shahrokhi, Weiping Shi
2000 A* conf
SODA
Weiping Shi, Chen Su
1999 J jnl
SIAM J. Comput.
Weiping Shi, Douglas B. West
1998 A* conf
DAC
Weiping Shi, Jianguo Liu, Naveen Kakani, Tiejun Yu
1997 conf
FTCS
Weiping Shi, Douglas B. West
1996 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Weiping Shi
1996 J jnl
Algorithmica
Peichen Pan, Weiping Shi, C. L. Liu
1996 Misc conf
COCOON
Farhad Shahrokhi, Weiping Shi
1996 J jnl
IEEE Trans. Computers
Weiping Shi, Ming-Feng Chang, W. Kent Fuchs
1995 A conf
ICCAD
Weiping Shi
1995 Misc conf
COCOON
Weiping Shi, Douglas B. West
1995 J jnl
IEEE Trans. Very Large Scale Integr. Syst.
Weiping Shi, W. Kent Fuchs
1994 conf
DFT
Weiping Shi
1994 A conf
ICCAD
Peichen Pan, Weiping Shi, C. L. Liu
1992 J jnl
IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
Weiping Shi, W. Kent Fuchs
1992 conf
Theoretical Studies in Computer Science
Sheila A. Greibach, Weiping Shi, Shai Simonson
1991 J jnl
SIAM J. Comput.
Herbert Edelsbrunner, Weiping Shi
1990 J jnl
IEEE Trans. Computers
Ming-Feng Chang, Weiping Shi, W. Kent Fuchs
1989 A conf
ICCAD
Ming-Feng Chang, Weiping Shi, W. Kent Fuchs
docs/new-code-binja-schema.md
← Index docs/new-code-binja-schema.md markdown
#################################
###### CODE RELATED TABLES ######
#################################

### CREATE FULL REDB DATABASE
def create_decompiled_binja_with_all_tables(client):
    create_phase1_decompiled_binja_tables(client)

#### CREATE FULL TABLES
def create_phase1_decompiled_binja_tables(client):
    create_function_analysis_error_dbtable(client)
    create_binja_decompiled_dbtable(client)
    create_binja_disassembly_dbtable(client)
    create_binja_cfg_dbtable(client)

#################################
### DECOMPILED BINJA INDIVIDUAL TABLES
#################################
def create_function_analysis_error_dbtable(client):
    client.command("""
    CREATE TABLE IF NOT EXISTS function_analysis_errors_binja (
        sha256 FixedString(64),
        function_name Nullable(String) CODEC(ZSTD(3)),
        function_address UInt64,
        error_location LowCardinality(String) CODEC(ZSTD(3)),
        error_message Nullable(String) CODEC(ZSTD(3)),
        error_details Nullable(String) CODEC(ZSTD(3)),
        error_type Nullable(String) CODEC(ZSTD(3)),
        error_hash FixedString(32), -- MD5, To help identify duplicate errors
        status Enum8('new' = 1, 'investigating' = 2, 'fixed' = 3, 'wontfix' = 4) DEFAULT 'new',
        analysis_date DateTime64(3, 'UTC'),
        PRIMARY KEY (sha256, function_address, error_location)
    )
    ENGINE = MergeTree()
    ORDER BY (sha256, function_address, error_location);
    """)

def create_binja_decompiled_dbtable(client):
    # Create decompiled_functions_content table
    client.command("""
    CREATE TABLE IF NOT EXISTS code_binja_decompiled_functions_content (
        decompiled_function_hash FixedString(64),
        decompiled_function String CODEC(ZSTD(3)),
        decompiled_function_lower String MATERIALIZED lower(decompiled_function) CODEC(ZSTD(3)),
        function_type Enum8('USER'=1, 'LIBRARY'=2, 'THUNK'=3, 'EXTERNAL'=4, 'UNKNOWN'=5) DEFAULT 'UNKNOWN',  -- NOT NULL TODO: remove THUNK and EXTERNAL
        flattened_score Nullable(Float64),
        mba_score Nullable(Float64),
        analysis_date DateTime64(3, 'UTC'),

        INDEX idx_function_content_token lower(decompiled_function) TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 1,
        --- INDEX idx_text_decompiled_function decompiled_function TYPE text(tokenizer = 'splitByNonAlpha', preprocessor = lower(decompiled_function)) GRANULARITY 64,
        INDEX idx_func_hash decompiled_function_hash TYPE bloom_filter GRANULARITY 1,
    ) ENGINE = ReplacingMergeTree(analysis_date)
    PRIMARY KEY decompiled_function_hash -- TODO: remove is redundant
    ORDER BY decompiled_function_hash;
    """)

    # Create decompiled_functions_references table
    client.command("""
    CREATE TABLE IF NOT EXISTS code_binja_decompiled_functions_references (
        sha256 FixedString(64),
        sha1 FixedString(40),
        md5 FixedString(32),
        decompiled_function_hash FixedString(64),
        disassembled_function_hash Nullable(FixedString(64)),
        decompiled_function_name LowCardinality(String),
        decompiled_function_prototype LowCardinality(String),
        decompiled_function_address UInt64,
        functions_caller Array(String),
        functions_call Array(String),

        INDEX idx_sha256 sha256 TYPE bloom_filter GRANULARITY 1,
        INDEX idx_func_hash decompiled_function_hash TYPE bloom_filter GRANULARITY 1,
        INDEX idx_func_name decompiled_function_name TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 1,
        INDEX idx_func_addr decompiled_function_address TYPE minmax GRANULARITY 1,
        analysis_date DateTime64(3, 'UTC')
    ) ENGINE = ReplacingMergeTree(analysis_date)
    ORDER BY (sha256, decompiled_function_hash);
    """)

def create_binja_disassembly_dbtable(client):
    # Create disassembly_functions_content table
    client.command("""
    CREATE TABLE IF NOT EXISTS code_binja_disassembled_functions_content (
        -- Content hashes for each normalization level
        disassembled_function_hash FixedString(64),             -- This is the hash of the disassembled function without addresses
        
        -- The actual function content at different normalization levels
        disassembled_function String CODEC(ZSTD(3)),
        disassembled_function_no_addresses String CODEC(ZSTD(3)),

        -- Function 
        function_type Enum8('USER'=1, 'LIBRARY'=2, 'THUNK'=3, 'EXTERNAL'=4, 'UNKNOWN'=5) DEFAULT 'UNKNOWN',  -- NOT NULL TODO: remove THUNK and EXTERNAL

        -- Analysis fields
        instructions_count UInt32,
        instructions_types Array(LowCardinality(String)), -- Types of instructions used
        control_flow_count UInt32,                      -- Number of control flow instructions
        memory_access_pattern Array(LowCardinality(String)),  -- Patterns of memory access
        register_usage Array(LowCardinality(String)),         -- Types of registers used
        data_references_count UInt32,                   -- Number of data references
        opcode_frequency_vector Array(Float32),-- Not computed yet
        api_calls_vector Array(Float32),-- Not computed yet
        minhash_signature Array(UInt64),-- Not computed yet
        max_block_size Nullable(UInt32),
        num_calls Nullable(UInt32),
        stack_size Nullable(Int32),
        instruction_type_ratios Array(Float32), -- Not computed yet
        instruction_embedding Array(Float32), -- Not computed yet
        analysis_date DateTime64(3, 'UTC'),

        -- Indexes for each normalization level
        INDEX idx_disasm_ngram disassembled_function TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1,
        INDEX idx_function_type function_type TYPE set(10) GRANULARITY 1,
        INDEX idx_instr_count instructions_count TYPE minmax GRANULARITY 4

    ) ENGINE = ReplacingMergeTree(analysis_date)
    ORDER BY (disassembled_function_hash);
    """)

    client.command("""
    CREATE TABLE code_binja_disassembled_functions_references
    (
        -- Original fields
        sha256 FixedString(64),
        sha1 FixedString(40),
        md5 FixedString(32),
        disassembled_function_hash FixedString(64),
        decompiled_function_hash Nullable(FixedString(64)),

        disassembled_function_name LowCardinality(String),
        disassembled_function_address UInt64,
        analysis_date DateTime64(3, 'UTC'),
        
        -- New hash fields moved from content table
        ssdeep_disassembly Nullable(String),
        tlsh_disassembly Nullable(FixedString(72)),
        ssdeep_llil Nullable(String),
        tlsh_llil Nullable(FixedString(72)),
        
        -- OPTIMIZED INDEXES for all search patterns
        INDEX idx_func_addr disassembled_function_address TYPE minmax GRANULARITY 1,
        INDEX idx_sha256 sha256 TYPE bloom_filter GRANULARITY 1,
        INDEX idx_tlsh_disasm tlsh_disassembly TYPE bloom_filter GRANULARITY 1,
        INDEX idx_ssdeep_disasm ssdeep_disassembly TYPE bloom_filter GRANULARITY 1,
        INDEX idx_tlsh_llil tlsh_llil TYPE bloom_filter GRANULARITY 1,
        INDEX idx_ssdeep_norm ssdeep_llil TYPE bloom_filter GRANULARITY 1,
        INDEX idx_func_name disassembled_function_name TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 2
    )
    ENGINE = ReplacingMergeTree(analysis_date)
    -- OPTIMIZED ORDER BY: Primary query pattern first, then hash fields for locality
    ORDER BY (sha256, disassembled_function_hash)
    SETTINGS index_granularity = 8192
    """)

def create_binja_llil_dbtable(client):
    # Create llil_functions_content table
    client.command("""
    CREATE TABLE IF NOT EXISTS code_binja_llil_functions_content (
        -- Content hashes for each normalization level
        llil_function_hash FixedString(64),             -- sha256_llil This is the hash of the disassembled function without addresses

        -- Function 
        function_type Enum8('USER'=1, 'LIBRARY'=2, 'THUNK'=3, 'EXTERNAL'=4, 'UNKNOWN'=5) DEFAULT 'UNKNOWN',  -- NOT NULL TODO: remove THUNK and EXTERNAL

        -- Analysis fields
        instructions_types_llil Array(LowCardinality(String)), -- Types of instructions used
        control_flow_count_llil UInt32,                      -- Number of control flow instructions
        memory_access_pattern_llil Array(LowCardinality(String)),  -- Patterns of memory access
        register_usage_llil Map(LowCardinality(String), Tuple(UInt32, UInt32)),         -- Types of registers used
        total_reg_reads UInt32,
        total_reg_written UInt32,
        data_references_count UInt32,                   -- Number of data references
        max_block_size Nullable(UInt32),
        num_calls Nullable(UInt32),
        stack_size Nullable(Int32),
        body_llil_vector Array(Tuple(UInt32, Array(UInt16))),
        analysis_date DateTime64(3, 'UTC'),

        -- Indexes for each normalization level
        INDEX function_type_idx function_type TYPE set(10) GRANULARITY 1,
        INDEX idx_reg_usage mapKeys(register_usage_llil) TYPE bloom_filter(0.01) GRANULARITY 1

    ) ENGINE = ReplacingMergeTree(analysis_date)
    ORDER BY llil_function_hash;
    """)

    client.command("""
    CREATE TABLE code_binja_llil_functions_references
    (
        -- Original fields
        sha256 FixedString(64),
        sha1 FixedString(40),
        md5 FixedString(32),
        llil_function_hash Nullable(FixedString(64)),
        disassembled_function_hash FixedString(64),
        
        -- New hash fields moved from content table
        ssdeep_disassembly Nullable(String),
        tlsh_disassembly Nullable(FixedString(72)),
        ssdeep_llil Nullable(String),
        tlsh_llil Nullable(FixedString(72)),

        analysis_date DateTime64(3, 'UTC'),
        
        -- OPTIMIZED INDEXES for all search patterns
        INDEX idx_sha256 sha256 TYPE bloom_filter GRANULARITY 1,
        INDEX idx_tlsh_disasm tlsh_disassembly TYPE bloom_filter GRANULARITY 1,
        INDEX idx_ssdeep_disasm ssdeep_disassembly TYPE bloom_filter GRANULARITY 1,
        INDEX idx_tlsh_llil tlsh_llil TYPE bloom_filter GRANULARITY 1,
        INDEX idx_ssdeep_llil ssdeep_llil TYPE bloom_filter GRANULARITY 1,
    )
    ENGINE = ReplacingMergeTree(analysis_date)
    -- OPTIMIZED ORDER BY: Primary query pattern first, then hash fields for locality
    ORDER BY (sha256, function_address)
    SETTINGS index_granularity = 8192
    """)

def create_binja_cfg_dbtable(client):
    client.command("""
    CREATE TABLE IF NOT EXISTS code_binja_cfg_blocks_content (
        block_instructions_hash FixedString(64), -- PK
        block_size UInt32,
        instructions_count UInt16,
        branch_type Enum8('DIRECT'=1, 'CONDITIONAL'=2, 'CALL'=3, 'RETURN'=4, 'FALLTHROUGH'=5, 'INDIRECT'=6, 'UNKNOWN'=7),
        block_type Enum8('CODE'=1, 'DATA'=2, 'THUNK'=3),
        flags Array(String),
        analysis_date DateTime64(3, 'UTC'),

        -- Indexes for filtering/analysis
        INDEX idx_branch_type branch_type TYPE set(10) GRANULARITY 4,
        INDEX idx_block_type block_type TYPE set(5) GRANULARITY 4,
        INDEX idx_instr_count instructions_count TYPE minmax GRANULARITY 4,
        INDEX idx_block_size block_size TYPE minmax GRANULARITY 4
    )
    ENGINE = ReplacingMergeTree(analysis_date)
    ORDER BY (block_instructions_hash);
    """)
  
    client.command("""
    CREATE TABLE IF NOT EXISTS code_binja_cfg_blocks_references (
        sha256 FixedString(64),
        sha1 FixedString(40),
        md5 FixedString(32),
        block_instructions_hash FixedString(64),
        disassembled_function_hash FixedString(64),
        
        -- Address information (for CFG traversal and debugging)
        function_address UInt64,
        block_start_address UInt64,
        block_end_address UInt64,
        
        -- CFG structure (addresses refer to block_start_address)
        predecessor_blocks Array(UInt64),
        successor_blocks Array(UInt64),
        depth UInt16,
        position UInt32,
        
        -- Dominator analysis
        dominators Array(UInt16),
        post_dominators Array(UInt16),
        
        analysis_date DateTime64(3, 'UTC'),
        
        -- OPTIMIZED INDEXES based on query patterns
        INDEX idx_sha256 sha256 TYPE bloom_filter GRANULARITY 1,
        INDEX idx_block_hash block_instructions_hash TYPE bloom_filter GRANULARITY 1,
        INDEX idx_func_hash disassembled_function_hash TYPE bloom_filter GRANULARITY 1,
        INDEX idx_func_addr function_address TYPE minmax GRANULARITY 1,
        INDEX idx_block_start block_start_address TYPE minmax GRANULARITY 1,
        INDEX idx_depth depth TYPE minmax GRANULARITY 4,
        INDEX idx_position position TYPE minmax GRANULARITY 4
    )
    ENGINE = ReplacingMergeTree(analysis_date)
    ORDER BY (sha256, function_address, block_start_address)
    SETTINGS index_granularity = 8192;
    """)

def create_binja_strings_dbtable(client):
    # 1. Raw table - INSERT target
    client.command("""
    CREATE TABLE IF NOT EXISTS code_binja_strings_raw (
        sha256 FixedString(64),
        string String CODEC(ZSTD(3)),              -- Decoded UTF-8 string (for searching)
        string_raw String CODEC(ZSTD(3)),          -- Raw bytes from binary (ground truth)
        string_encoding LowCardinality(String),    -- Detected/guessed encoding by binja
        string_offset UInt64,
        string_length UInt32,                      -- Length of decoded string
        string_raw_length UInt32,                  -- Length of raw bytes
        string_entropy Float32
    )
    ENGINE = Null;
    """)
   
    # 3a. Target table for reverse lookup (with indexes)
    client.command("""
    CREATE TABLE IF NOT EXISTS code_binja_strings_by_binary (
        sha256 FixedString(64),
        string_offset UInt64,
        string String CODEC(ZSTD(3)),
        string_raw String CODEC(ZSTD(3)),
        string_encoding LowCardinality(String),
        string_length UInt32,
        string_raw_length UInt32,
        string_entropy Float32,
        
        INDEX idx_sha256 sha256 TYPE bloom_filter GRANULARITY 1,
        INDEX idx_string_ngram lower(string) TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1,
        --- INDEX idx_string string TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 1,
        --- INDEX idx_string_raw string_raw TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 1,
        INDEX idx_entropy string_entropy TYPE minmax GRANULARITY 4
    )
    ENGINE = ReplacingMergeTree()
    ORDER BY (sha256, string_offset);
    """)
    
    # 3b. Materialized view -> target table
    client.command("""
    CREATE MATERIALIZED VIEW IF NOT EXISTS code_binja_strings_by_binary_mv
    TO code_binja_strings_by_binary
    AS SELECT
        sha256,
        string_offset,
        string,
        string_raw,
        string_encoding,
        string_length,
        string_raw_length,
        string_entropy
    FROM code_binja_strings_raw;
    """)

    client.command("""
    -- 1. Create the new public-only popularity table
    CREATE TABLE mv_string_popularity_public_table (
        string_xxhash64 UInt64,
        sample_count AggregateFunction(uniq, FixedString(64))
    ) ENGINE = AggregatingMergeTree()
    ORDER BY string_xxhash64;
    """)

    client.command("""
    -- 2. Create the MV for new data going forward
    CREATE MATERIALIZED VIEW mv_string_popularity_public
    TO mv_string_popularity_public_table AS
    SELECT
        xxHash64(s.string) AS string_xxhash64,
        uniqState(s.sha256) AS sample_count
    FROM code_binja_strings_raw s
    INNER JOIN catalog_visibility_lookup_v2 v 
        ON s.sha256 = v.sha256 AND v.visibility_scope = 'public'
    GROUP BY string_xxhash64;
    """)

    # client.command("""
    # INSERT INTO mv_string_popularity_public_table
    # SELECT
    #     xxHash64(s.string) AS string_xxhash64,
    #     uniqState(s.sha256) AS sample_count
    # FROM code_binja_strings_by_binary s
    # INNER JOIN catalog_visibility_lookup_v2 v 
    #     ON s.sha256 = v.sha256 AND v.visibility_scope = 'public'
    # GROUP BY string_xxhash64;
    # """)

def create_binja_function_similarity_metrics_dbtable(client):
    client.command("""
    CREATE TABLE IF NOT EXISTS code_binja_function_similarity_metrics (
        disassembled_function_hash FixedString(64),
        
        -- Complexity metrics
        cyclomatic_complexity Nullable(UInt16),
        
        -- Fuzzy hashes (duplicated from reference tables for performance)
        ssdeep_disassembly Nullable(String),
        tlsh_disassembly Nullable(FixedString(72)),
        ssdeep_llil Nullable(String),
        tlsh_llil Nullable(FixedString(72)),
        
        -- Similarity hashes
        minhash Array(UInt8),
        
        analysis_date DateTime64(3, 'UTC'),
        
        -- Indexes
        INDEX idx_complexity cyclomatic_complexity TYPE minmax GRANULARITY 4,
        INDEX idx_ssdeep_disasm ssdeep_disassembly TYPE bloom_filter GRANULARITY 1,
        INDEX idx_tlsh_disasm tlsh_disassembly TYPE bloom_filter GRANULARITY 1,
        INDEX idx_ssdeep_llil ssdeep_llil TYPE bloom_filter GRANULARITY 1,
        INDEX idx_tlsh_llil tlsh_llil TYPE bloom_filter GRANULARITY 1
    )
    ENGINE = ReplacingMergeTree(analysis_date)
    ORDER BY disassembled_function_hash;
    """)

def create_golang_metadata_dbtable(client):
    client.command("""
    CREATE TABLE IF NOT EXISTS redb_golang_metadata (
        sha256 FixedString(64),
        goresym JSON,
        analysis_date DateTime64(3, 'UTC')
    ) ENGINE = ReplacingMergeTree(analysis_date)
    ORDER BY sha256
    """)