Buggy code:
@ JsonTypeName ( "hbase-scan" ) public class HBaseGroupScan extends AbstractGroupScan implements DrillHBaseConstants { static final Logger logger = org . slf4j . LoggerFactory . getLogger ( HBaseGroupScan . class ) ; private static final Comparator < List < HBaseSubScanSpec > > LIST_SIZE_COMPARATOR = new Comparator < List < HBaseSubScanSpec > > ( ) { @ Override public int compare ( List < HBaseSubScanSpec > list1 , List < HBaseSubScanSpec > list2 ) { } } ; private static final Comparator < List < HBaseSubScanSpec > > LIST_SIZE_COMPARATOR_REV = Collections . reverseOrder ( HBaseGroupScan . LIST_SIZE_COMPARATOR ) ; private HBaseStoragePluginConfig storagePluginConfig ; private List < SchemaPath > columns ; private HBaseScanSpec hbaseScanSpec ; private HBaseStoragePlugin storagePlugin ; private Stopwatch watch = new Stopwatch ( ) ; private Map < Integer , List < HBaseSubScanSpec > > endpointFragmentMapping ; private NavigableMap < HRegionInfo , ServerName > regionsToScan ; private HTableDescriptor hTableDesc ; private boolean filterPushedDown = false ; private TableStatsCalculator statsCalculator ; private long scanSizeInBytes = 0 ; @ JsonCreator public HBaseGroupScan ( @ JsonProperty ( "hbaseScanSpec" ) HBaseScanSpec hbaseScanSpec , @ JsonProperty ( "storage" ) HBaseStoragePluginConfig storagePluginConfig , @ JsonProperty ( "columns" ) List < SchemaPath > columns , @ JacksonInject StoragePluginRegistry pluginRegistry ) throws IOException , ExecutionSetupException { } public HBaseGroupScan ( HBaseStoragePlugin storagePlugin , HBaseScanSpec scanSpec , List < SchemaPath > columns ) { } private HBaseGroupScan ( HBaseGroupScan that ) { } @ Override public GroupScan clone ( List < SchemaPath > columns ) { } private void init ( ) { } private void verifyColumns ( ) { } @ Override public List < EndpointAffinity > getOperatorAffinity ( ) { } @ Override public void applyAssignments ( List < DrillbitEndpoint > incomingEndpoints ) { } private HBaseSubScanSpec regionInfoToSubScanSpec ( HRegionInfo ri ) { } private boolean isNullOrEmpty ( byte [ ] key ) { } @ Override public HBaseSubScan getSpecificScan ( int minorFragmentId ) { } @ Override public int getMaxParallelizationWidth ( ) { } @ Override public ScanStats getScanStats ( ) { <START_BUG> int rowCount = ( ( int ) ( ( ( scanSizeInBytes ) // ( statsCalculator . getAvgRowSizeInBytes ( ) ) ) * ( ( hbaseScanSpec . getFilter ( ) ) != null ? 0.5 : 1 ) ) ) ; <END_BUG> float diskCost = ( scanSizeInBytes ) * ( ( ( columns ) == null ) || ( columns . isEmpty ( ) ) ? 1 : ( columns . size ( ) ) // ( statsCalculator . getColsPerRow ( ) ) ) ; return new ScanStats ( GroupScanProperty . NO_EXACT_ROW_COUNT , rowCount , 1 , diskCost ) ; } @ Override @ JsonIgnore public PhysicalOperator getNewWithChildren ( List < PhysicalOperator > children ) { } @ JsonIgnore public HBaseStoragePlugin getStoragePlugin ( ) { } @ JsonIgnore public Configuration getHBaseConf ( ) { } @ JsonIgnore public String getTableName ( ) { } @ Override public String getDigest ( ) { } @ Override public String toString ( ) { } @ JsonProperty ( "storage" ) public HBaseStoragePluginConfig getStorageConfig ( ) { } @ JsonProperty public List < SchemaPath > getColumns ( ) { } @ JsonProperty public HBaseScanSpec getHBaseScanSpec ( ) { } @ Override @ JsonIgnore public boolean canPushdownProjects ( List < SchemaPath > columns ) { } @ JsonIgnore public void setFilterPushedDown ( boolean b ) { } @ JsonIgnore public boolean isFilterPushedDown ( ) { } @ VisibleForTesting public HBaseGroupScan ( ) { } @ VisibleForTesting public void setHBaseScanSpec ( HBaseScanSpec hbaseScanSpec ) { } @ JsonIgnore @ VisibleForTesting public void setRegionsToScan ( NavigableMap < HRegionInfo , ServerName > regionsToScan ) { } }

Fix:
long rowCount = ( ( long ) ( ( ( scanSizeInBytes ) // ( statsCalculator . getAvgRowSizeInBytes ( ) ) ) * ( ( hbaseScanSpec . getFilter ( ) ) != null ? 0.5 : 1 ) ) ) ;