auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private int getSpillCycleMetricIndex(CoreOperatorType operatorType) { String metricName = null; switch (operatorType) { case EXTERNAL_SORT: metricName = "SPILL_COUNT"; break; case HASH_AGGREGATE: case HASH_JOIN: metricName = "SPILL_CYCLE"; break; default: return NO_SPILL_METRIC_INDEX; } int metricIndex = 0; //Default String[] metricNames = OperatorMetricRegistry.getMetricNames(operatorType.getNumber()); for (String name : metricNames) { if (name.equalsIgnoreCase(metricName)) { return metricIndex; } metricIndex++; } //Backward compatibility with rendering older profiles. Ideally we should never touch this if an expected metric is not there return NO_SPILL_METRIC_INDEX; }

Target:
private int getSpillCycleMetricIndex(CoreOperatorType operatorType) { String metricName; switch (operatorType) { case EXTERNAL_SORT: metricName = "SPILL_COUNT"; break; case HASH_AGGREGATE: case HASH_JOIN: metricName = "SPILL_CYCLE"; break; default: return NO_SPILL_METRIC_INDEX; } int metricIndex = 0; //Default String[] metricNames = OperatorMetricRegistry.getMetricNames(operatorType.getNumber()); for (String name : metricNames) { if (name.equalsIgnoreCase(metricName)) { return metricIndex; } metricIndex++; } //Backward compatibility with rendering older profiles. Ideally we should never touch this if an expected metric is not there return NO_SPILL_METRIC_INDEX; }
Source:
public void sortOneKeyAscending() throws Throwable { ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher) .configProperty(CodeCompiler.ENABLE_SAVE_CODE_FOR_DEBUG_TOPN, true); try (ClusterFixture cluster = builder.build(); ClientFixture client = cluster.clientFixture()) { TestBuilder testBuilder = new TestBuilder(new ClusterFixture.FixtureTestServices(client)); testBuilder.ordered() .physicalPlanFromFile("topN/one_key_sort.json") .baselineColumns("blue") .go(); } }

Target:
public void sortOneKeyAscending() throws Throwable { ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher); try (ClusterFixture cluster = builder.build(); ClientFixture client = cluster.clientFixture()) { TestBuilder testBuilder = new TestBuilder(new ClusterFixture.FixtureTestServices(client)); testBuilder.ordered() .physicalPlanFromFile("topN/one_key_sort.json") .baselineColumns("blue") .go(); } }
Source:
private BitRpcUtility() throws Exception { throw new UnsupportedOperationException("BitRpcUtility is a utility class and should not be instantiated."); }

Target:
private BitRpcUtility() { }
Source:
protected void log(final String name, final PhysicalPlan plan, final Logger logger) throws JsonProcessingException { if (logger.isDebugEnabled()) { PropertyFilter theFilter = new SimpleBeanPropertyFilter.SerializeExceptFilter(Sets.newHashSet("password")); String planText = plan.unparse(context.getLpPersistence().getMapper() .writer(new SimpleFilterProvider().addFilter("passwordFilter", theFilter))); logger.debug(name + " : \n" + planText); } }

Target:
protected void log(final String name, final PhysicalPlan plan, final Logger logger) throws JsonProcessingException { if (logger.isDebugEnabled()) { PropertyFilter filter = new SimpleBeanPropertyFilter.SerializeExceptFilter(Sets.newHashSet("password")); String planText = plan.unparse(context.getLpPersistence().getMapper() .writer(new SimpleFilterProvider().addFilter("passwordFilter", filter))); logger.debug(name + " : \n" + planText); } }
Source:
public void close() throws Exception { in.close(); }

Target:
public void close() throws Exception { if (in != null) { in.close(); in = null; } }
Source:
private ProjectedColumnInfo makeColumn(final String colName, final Column column) { TypeProtos.MajorType majorType = Types.optional(column.getMinorType()); MaterializedField field = MaterializedField.create(colName, majorType); ValueVector vector = getValueVector(column.getMinorType(), majorType, field, output); return new ProjectedColumnInfo(vector, column, colName); }

Target:
private ProjectedColumnInfo makeColumn(final String colName, final Column column) { MaterializedField field = MaterializedField.create(colName, column.getMinorType()); ValueVector vector = getValueVector(field, output); return new ProjectedColumnInfo(vector, column, colName); }
Source:
public int getPayloadByteCount(int valueCount) { if (valueCount == 0) { return 0; } int count = 0; int entryCount = offsets.getAccessor().get(valueCount); count += offsets.getPayloadByteCount(valueCount); for (final ValueVector v : getChildren()) { count += v.getPayloadByteCount(entryCount); } return count; }

Target:
public int getPayloadByteCount(int valueCount) { if (valueCount == 0) { return 0; } int entryCount = offsets.getAccessor().get(valueCount); int count = offsets.getPayloadByteCount(valueCount); for (final ValueVector v : getChildren()) { count += v.getPayloadByteCount(entryCount); } return count; }
Source:
public FragmentContext getContext() { // Backward compatibility with the full server context. Awkward for testing FragmentContext fragmentContext = fragmentContext(); if (fragmentContext instanceof FragmentContext) { return (FragmentContext) fragmentContext; } else { return null; } }

Target:
public FragmentContext getContext() { return fragmentContext(); }
Source:
public ColumnDefn(String name, int index) { this.name = name; this.index = index; this.format = ""; }

Target:
public ColumnDefn(String name, int index) { this(name, index, null); }
Source:
public abstract void define(OutputMutator outputMutator) throws SchemaChangeException; public abstract void load(int rowIndex, String value); @Override //For testing public String toString() { return "Name: " + name + ", Index: " + index; }

Target:
public abstract void define(OutputMutator outputMutator) throws SchemaChangeException; public abstract void load(int rowIndex, String value); public String getName() { return this.name; }
Source:
public <T, X, E extends Throwable> T accept(PhysicalVisitor<T, X, E> physicalVisitor, X value) throws E { return physicalVisitor.visitExchange(this, value); }

Target:
public final <T, X, E extends Throwable> T accept(PhysicalVisitor<T, X, E> physicalVisitor, X value) throws E { return physicalVisitor.visitExchange(this, value); }
Source:
private static boolean isMuxEnabled(OptionManager options) { if (options.getOption(PlannerSettings.MUX_EXCHANGE.getOptionName()).bool_val || options.getOption(PlannerSettings.DEMUX_EXCHANGE.getOptionName()).bool_val || options.getOption(PlannerSettings.ORDERED_MUX_EXCHANGE.getOptionName()).bool_val) { return true; } return false; }

Target:
private static boolean isMuxEnabled(OptionManager options) { return (options.getOption(PlannerSettings.MUX_EXCHANGE.getOptionName()).bool_val || options.getOption(PlannerSettings.DEMUX_EXCHANGE.getOptionName()).bool_val || options.getOption(PlannerSettings.ORDERED_MUX_EXCHANGE.getOptionName()).bool_val); }
Source:
public void close() throws Exception { logger.debug("Partition sender stopping."); super.close(); ok = false; synchronized (this) { if (partitioner != null) { updateAggregateStats(); partitioner.clear(); } } if (closeIncoming) { ((CloseableRecordBatch) incoming).close(); } }

Target:
public void close() throws Exception { logger.debug("Partition sender stopping."); super.close(); if (partitioner != null) { updateAggregateStats(); partitioner.clear(); } if (closeIncoming) { ((CloseableRecordBatch) incoming).close(); } }
Source:
public MockPartitionSenderRootExec(FragmentContext context, RecordBatch incoming, HashPartitionSender operator) throws OutOfMemoryException { super(context, incoming, operator, false); }

Target:
public MockPartitionSenderRootExec(FragmentContext context, RecordBatch incoming, HashPartitionSender operator) throws OutOfMemoryException { super(context, incoming, operator); }
Source:
public void admit() { // No queueing by default foreman.moveToState(UserBitShared.QueryResult.QueryState.STARTING, null); }

Target:
public void admit() { // No queueing by default }
Source:
public UserIdentity login(final String username, final Object credentials) { UserIdentity identity = null; try { identity = loggedInUgi.doAs(new PrivilegedExceptionAction<UserIdentity>() { @Override public UserIdentity run() { return spnegoLogin(username, credentials); } }); } catch (Exception e) { logger.error("Failed to login using SPNEGO"); } return identity; }

Target:
public UserIdentity login(final String username, final Object credentials) { UserIdentity identity = null; try { identity = loggedInUgi.doAs(new PrivilegedExceptionAction<UserIdentity>() { @Override public UserIdentity run() { return spnegoLogin(credentials); } }); } catch (Exception e) { logger.error("Failed to login using SPNEGO", e); } return identity; }
Source:
public FileSystemSchemaFactory(FileSystemPlugin plugin, String schemaName, List<WorkspaceSchemaFactory> factories) { super(); this.plugin = plugin; this.schemaName = schemaName; this.factories = factories; }

Target:
public FileSystemSchemaFactory(FileSystemPlugin plugin, String schemaName, List<WorkspaceSchemaFactory> factories) { this.plugin = plugin; this.schemaName = schemaName; this.factories = factories; }
Source:
public void testQueryGoodStorageWithDefaultSchema() throws Exception { String use_dfs = "use dfs.tmp"; client.queryBuilder().sql(use_dfs).run(); String sql = "SELECT id_i, name_s10 FROM `mock_good`.`employees_5`"; client.queryBuilder().sql(sql).printCsv(); }

Target:
public void testQueryGoodStorageWithDefaultSchema() throws Exception { String use_dfs = "use dfs.tmp"; client.queryBuilder().sql(use_dfs).run(); String sql = "SELECT id_i, name_s10 FROM `mock_good`.`employees_5`"; client.queryBuilder().sql(sql).run(); }
Source:
public boolean supportsRead() { return Boolean.TRUE; }

Target:
public boolean supportsRead() { return true; }
Source:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } KafkaStoragePluginConfig other = (KafkaStoragePluginConfig) obj; if (kafkaConsumerProps == null) { if (other.kafkaConsumerProps != null) { return false; } } else if (!kafkaConsumerProps.equals(other.kafkaConsumerProps)) { return false; } return true; }

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } KafkaStoragePluginConfig other = (KafkaStoragePluginConfig) obj; if (kafkaConsumerProps == null && other.kafkaConsumerProps == null) { return true; } if (kafkaConsumerProps == null || other.kafkaConsumerProps == null) { return false; } return kafkaConsumerProps.equals(other.kafkaConsumerProps); }
Source:
public void testInvalidSetQueryTimeout() throws SQLException { PreparedStatement stmt = connection.prepareStatement(SYS_VERSION_SQL); //Setting negative value int valueToSet = -10; if (0L == valueToSet) { valueToSet--; } try { stmt.setQueryTimeout(valueToSet); } catch ( final Exception e) { // TODO: handle exception assertThat( e.getMessage(), containsString( "illegal timeout value") ); //Converting this to match expected Exception throw new InvalidParameterSqlException(e.getMessage()); } }

Target:
public void testInvalidSetQueryTimeout() throws SQLException { try (PreparedStatement stmt = connection.prepareStatement(SYS_VERSION_SQL)) { //Setting negative value int valueToSet = -10; try { stmt.setQueryTimeout(valueToSet); } catch ( final SQLException e) { assertThat( e.getMessage(), containsString( "illegal timeout value") ); } } }
Source:
public void testDefaultGetQueryTimeout() throws SQLException { Statement stmt = connection.createStatement(); int timeoutValue = stmt.getQueryTimeout(); assert( 0 == timeoutValue ); }

Target:
public void testDefaultGetQueryTimeout() throws SQLException { try(Statement stmt = connection.createStatement()) { int timeoutValue = stmt.getQueryTimeout(); assertEquals( 0 , timeoutValue ); } }
Source:
public void close() throws Exception { in.close(); fs.close(); }

Target:
public void close() throws Exception { in.close(); }
Source:
public void close() { if (closed) { logger.debug("Attempted to close Operator context for {}, but context is already closed", popConfig != null ? getName() : null); return; } logger.debug("Closing context for {}", popConfig != null ? getName() : null); closed = true; super.close(); }

Target:
public void close() { if (closed) { logger.debug("Attempted to close Operator context for {}, but context is already closed", popConfig != null ? getName() : null); return; } logger.debug("Closing context for {}", popConfig != null ? getName() : null); try { super.close(); } finally { closed = true; } }
Source:
private int getEstimatedRecordSize(MockColumn[] types) { int x = 0; for (int i = 0; i < (types == null ? 0 : types.length); i++) { x += TypeHelper.getSize(types[i].getMajorType()); } return x; }

Target:
private int getEstimatedRecordSize(MockColumn[] types) { if (types == null) { return 0; } int x = 0; for (int i = 0; i < types.length; i++) { x += TypeHelper.getSize(types[i].getMajorType()); } return x; }
Source:
public SSLConfig build() throws DrillException { if (config == null) { throw new DrillConfigurationException( "Cannot create SSL configuration from null Drill configuration."); } SSLConfig sslConfig; if (mode == SSLFactory.Mode.SERVER) { sslConfig = new SSLConfigServer(config, hadoopConfig); } else { sslConfig = new SSLConfigClient(config, hadoopConfig); } if(initializeSSLContext){ sslConfig.initContext(); } if(validateKeyStore){ sslConfig.validateKeyStore(); } return sslConfig; }

Target:
public SSLConfig build() throws DrillException { if (mode == SSLFactory.Mode.SERVER && config == null) { throw new DrillConfigurationException( "Cannot create SSL configuration from null Drill configuration."); } SSLConfig sslConfig; if (mode == SSLFactory.Mode.SERVER) { sslConfig = new SSLConfigServer(config, hadoopConfig); } else { sslConfig = new SSLConfigClient(properties); } if(validateKeyStore){ sslConfig.validateKeyStore(); } if(initializeSSLContext){ sslConfig.initContext(); } return sslConfig; }
Source:
private String getHadoopConfigParam(String name) { Preconditions.checkArgument(this.hadoopConfig != null); String value = ""; value = hadoopConfig.get(name, ""); value = value.trim(); return value; }

Target:
private String getHadoopConfigParam(String name) { Preconditions.checkArgument(this.hadoopConfig != null); String value = hadoopConfig.get(name, ""); value = value.trim(); return value; }
Source:
public void visitAbstractPlan(PhysicalPlan plan) { boolean replanMemory = ! plan.getProperties().hasResourcePlan; if (! replanMemory || plan == null) { return; } MemoryAllocationUtilities.setupBufferedOpsMemoryAllocations(plan, queryContext); }

Target:
public void visitAbstractPlan(PhysicalPlan plan) { if (plan == null || plan.getProperties().hasResourcePlan) { return; } MemoryAllocationUtilities.setupBufferedOpsMemoryAllocations(plan, queryContext); }
Source:
public String toString( ) { String msg = "Embedded queue lease for " + QueryIdHelper.getQueryId(queryId); if (released) { msg += " (released)"; } return msg; }

Target:
public String toString( ) { return new StringBuilder() .append("Embedded queue lease for ") .append(QueryIdHelper.getQueryId(queryId)) .append(released ? " (released)" : "") .toString(); }
Source:
public void waitForGracePeriod() { ExtendedLatch exitLatch = null; exitLatch = new ExtendedLatch(); exitLatch.awaitUninterruptibly(gracePeriod); }

Target:
public void waitForGracePeriod() { ExtendedLatch exitLatch = new ExtendedLatch(); exitLatch.awaitUninterruptibly(gracePeriod); }
Source:
public void closeDrillbit(final String drillbitName) throws Exception { Exception ex = null; for (Drillbit bit : drillbits()) { if(bit.equals(bits.get(drillbitName))) { bit.close(); } } if(ex != null) { throw ex; } }

Target:
public void closeDrillbit(final String drillbitName) throws Exception { Exception ex = null; for (Drillbit bit : drillbits()) { if (bit.equals(bits.get(drillbitName))) { try { bit.close(); } catch (Exception e) { ex = ex == null ? e :ex; } } } if (ex != null) { throw ex; } }
Source:
public void testTimeHoursMinutesSecondsFormat() { Locale.setDefault(Locale.US); int hours = 11; int minutes = 50; String seconds = "05"; DateTime date = parseDateFromPostgres(hours + ":" + minutes + ":" + seconds + " am", "hh12:mi:ss am"); Assert.assertTrue(date.getHourOfDay() == hours && date.getMinuteOfHour() == minutes && date.getSecondOfMinute() == Integer.parseInt(seconds)); }

Target:
public void testTimeHoursMinutesSecondsFormat() { int hours = 11; int minutes = 50; String seconds = "05"; DateTime date = parseDateFromPostgres(hours + ":" + minutes + ":" + seconds + " am", "hh12:mi:ss am"); Assert.assertTrue(date.getHourOfDay() == hours && date.getMinuteOfHour() == minutes && date.getSecondOfMinute() == Integer.parseInt(seconds)); }
Source:
public static boolean isScalarSubquery(RelNode root) { RelMetadataQuery relMetadataQuery = RelMetadataQuery.instance(); RelNode currentRel = root; while (currentRel != null) { if (currentRel instanceof RelSubset) { currentRel = ((RelSubset) currentRel).getBest(); continue; } Double rowCount = relMetadataQuery.getMaxRowCount(currentRel); if (rowCount != null && rowCount.equals(1.0)) { return true; } else { return false; } } return false; }

Target:
public static boolean isScalarSubquery(RelNode root) { RelMetadataQuery relMetadataQuery = RelMetadataQuery.instance(); RelNode currentRel = root; while (currentRel != null) { if (currentRel instanceof RelSubset) { currentRel = ((RelSubset) currentRel).getBest(); continue; } Double rowCount = relMetadataQuery.getMaxRowCount(currentRel); if (rowCount != null && rowCount <= 1.0) { return true; } else { return false; } } return false; }
Source:
protected static void copyMetaDataCacheToTempWithReplacements(String srcFileOnClassPath, String destFolderInTmp, String metaFileName, String customStringReplacement) throws IOException { String metadataFileContents = getFile(srcFileOnClassPath); Path rootMeta = new Path(dfsTestTmpSchemaLocation, destFolderInTmp); Path newMetaCache = new Path(rootMeta, metaFileName); FSDataOutputStream outSteam = fs.create(newMetaCache); if (customStringReplacement!=null) { metadataFileContents = metadataFileContents.replace("CUSTOM_STRING_REPLACEMENT", customStringReplacement); } outSteam.writeBytes(metadataFileContents.replace("REPLACED_IN_TEST", dfsTestTmpSchemaLocation)); outSteam.close(); }

Target:
protected static void copyMetaDataCacheToTempWithReplacements(String srcFileOnClassPath, String destFolderInTmp, String metaFileName, String customStringReplacement) throws IOException { String metadataFileContents = getFile(srcFileOnClassPath); Path rootMeta = new Path(dfsTestTmpSchemaLocation, destFolderInTmp); Path newMetaCache = new Path(rootMeta, metaFileName); try (FSDataOutputStream outSteam = fs.create(newMetaCache)) { if (customStringReplacement != null) { metadataFileContents = metadataFileContents.replace("CUSTOM_STRING_REPLACEMENT", customStringReplacement); } outSteam.writeBytes(metadataFileContents.replace("REPLACED_IN_TEST", dfsTestTmpSchemaLocation)); } }
Source:
public SystemOptionManager(LogicalPlanPersistence lpPersistence, final PersistentStoreProvider provider) { this.provider = provider; this.config = PersistentStoreConfig.newJacksonBuilder(lpPersistence.getMapper(), OptionValue.class) .name("sys.options") .build(); }

Target:
public SystemOptionManager(LogicalPlanPersistence lpPersistence, final PersistentStoreProvider provider) { this(lpPersistence,provider,null); }
Source:
public void populateDefaultValues() { // populate the options from the config final Map<String, OptionValidator> tmp = new HashMap<>(); for (OptionValidator validator: VALIDATORS.values()) { try { validator.loadDefault(bootConfig); } catch (ConfigException.Missing e) { throw new IllegalStateException("Config Option is missing"+e+ validator.getOptionName()); } } }

Target:
public void populateDefaultValues() { // populate the options from the config final Map<String, OptionValidator> tmp = new HashMap<>(); for (OptionValidator validator: VALIDATORS.values()) { try { validator.loadDefault(bootConfig); } catch (ConfigException.Missing e) { throw new IllegalStateException("Config Option is missing"+ validator.getOptionName()); } } }
Source:
public int computeMaxWidth(double cpuLoadAverage, long maxWidth) { // if maxwidth is already set return it if (maxWidth != 0) { return (int) maxWidth; } // else compute the value and return else { int maxWidthPerNode; int availProc = Runtime.getRuntime().availableProcessors(); maxWidthPerNode = (int) Math.max(1, Math.min(availProc, Math.round(availProc * cpuLoadAverage))); return maxWidthPerNode; } }

Target:
public int computeMaxWidth(double cpuLoadAverage, long maxWidth) { // if maxwidth is already set return it if (maxWidth != 0) { return (int) maxWidth; } // else compute the value and return else { int availProc = Runtime.getRuntime().availableProcessors(); long maxWidthPerNode = Math.max(1, Math.min(availProc, Math.round(availProc * cpuLoadAverage))); return (int) maxWidthPerNode; } }
Source:
public void testJDKClassCompiler() throws Exception { logger.debug("Testing JDKClassCompiler"); sessionOptions.setOption(OptionValue.createString(OptionType.SESSION, ClassCompilerSelector.JAVA_COMPILER_OPTION, ClassCompilerSelector.CompilerPolicy.JDK.name(), OptionScope.SESSION)); for (int i = 0; i < ITERATION_COUNT; i++) { compilationInnerClass(false); // Traditional byte-code manipulation compilationInnerClass(true); // Plain-old Java } }

Target:
public void testJDKClassCompiler() throws Exception { logger.debug("Testing JDKClassCompiler"); OptionType type = OptionType.SESSION; sessionOptions.setOption(OptionValue.createString(type, ClassCompilerSelector.JAVA_COMPILER_OPTION, ClassCompilerSelector.CompilerPolicy.JDK.name(), OptionScope.SESSION)); for (int i = 0; i < ITERATION_COUNT; i++) { compilationInnerClass(false); // Traditional byte-code manipulation compilationInnerClass(true); // Plain-old Java } }
Source:
public SchemaBuilder(BatchSchema baseSchema) { for (MaterializedField field : baseSchema) { columns.add(field); } }

Target:
public SchemaBuilder(BatchSchema baseSchema) { for (MaterializedField field : baseSchema) { add(field); } }
Source:
private void flush() throws IOException { if (recordCount > 0) { parquetFileWriter.startBlock(recordCount); consumer.flush(); store.flush(); pageStore.flushToFileWriter(parquetFileWriter); recordCount = 0; parquetFileWriter.endBlock(); // we are writing one single block per file parquetFileWriter.end(extraMetaData); parquetFileWriter = null; } store.close(); pageStore.close(); store = null; pageStore = null; index++; }

Target:
private void flush() throws IOException { try { if (recordCount > 0) { parquetFileWriter.startBlock(recordCount); consumer.flush(); store.flush(); pageStore.flushToFileWriter(parquetFileWriter); recordCount = 0; parquetFileWriter.endBlock(); // we are writing one single block per file parquetFileWriter.end(extraMetaData); parquetFileWriter = null; } } finally { store.close(); pageStore.close(); store = null; pageStore = null; index++; } }
Source:
protected boolean hasCapacity(int index, int fieldLength) { if (fieldLength < 0) { throw new IllegalArgumentException("length: " + fieldLength + " (expected: >= 0)"); } return (! (index < 0 || index > capacity() - fieldLength)); }

Target:
protected boolean hasCapacity(int index, int fieldLength) { assert fieldLength >= 0; return (! (index < 0 || index > capacity() - fieldLength)); }
Source:
public boolean setBytesBounded(int index, byte[] src, int srcIndex, int length) { if (! hasCapacity(index, length)) { return false; } if (length != 0) { PlatformDependent.copyMemory(src, srcIndex, addr(index), length); } return true; }

Target:
public boolean setBytesBounded(int index, byte[] src, int srcIndex, int length) { if (! hasCapacity(index, length)) { return false; } PlatformDependent.copyMemory(src, srcIndex, addr(index), length); return true; }
Source:
public PcapRecordReader(final String inputPath, final List<SchemaPath> projectedColumns) { try { this.in = new FileInputStream(inputPath); this.decoder = getPacketDecoder(); validBytes = in.read(buffer); } catch (IOException e) { throw new RuntimeException("File " + inputPath + " not Found"); } setColumns(projectedColumns); }

Target:
public PcapRecordReader(final String inputPath, final List<SchemaPath> projectedColumns) { this.inputPath = inputPath; this.projectedColumns = projectedColumns; }
Source:
private ValueVector getValueVector(final MinorType minorType, final MajorType majorType, final MaterializedField field) { try { final Class<? extends ValueVector> clazz = TypeHelper.getValueVectorClass( minorType, majorType.getMode()); ValueVector vector = output.addField(field, clazz); vector.allocateNew(); return vector; } catch (SchemaChangeException sce) { throw new NullPointerException("The addition of this field is incompatible with this OutputMutator's capabilities"); } }

Target:
private ValueVector getValueVector(final MinorType minorType, final MajorType majorType, final MaterializedField field) { try { final Class<? extends ValueVector> clazz = TypeHelper.getValueVectorClass( minorType, majorType.getMode()); ValueVector vector = output.addField(field, clazz); vector.allocateNew(); return vector; } catch (SchemaChangeException sce) { throw new IllegalStateException("The addition of this field is incompatible with this OutputMutator's capabilities"); } }
Source:
public QueryType getType() { QueryType type = QueryType.SQL; switch (queryType) { case "SQL": type = QueryType.SQL; break; case "LOGICAL": type = QueryType.LOGICAL; break; case "PHYSICAL": type = QueryType.PHYSICAL; break; } return type; }

Target:
public QueryType getType() { return QueryType.valueOf(queryType); }
Source:
public int extraMemoryNeededForResize() { if (tableSize == MAXIMUM_CAPACITY) { return 0; } // will not resize int newSize = roundUpToPowerOf2(2 * tableSize); if (newSize > MAXIMUM_CAPACITY) { newSize = MAXIMUM_CAPACITY; } return newSize * 4 /* sizeof(int) */; }

Target:
public long extraMemoryNeededForResize() { if (tableSize == MAXIMUM_CAPACITY) { return 0; } // will not resize int newSize = roundUpToPowerOf2(2 * tableSize); if (newSize > MAXIMUM_CAPACITY) { newSize = MAXIMUM_CAPACITY; } return newSize * 4 /* sizeof(int) */; }
Source:
private void reinitPartition(int part) throws SchemaChangeException, ClassTransformationException, IOException { assert htables[part] != null; htables[part].reset(); if ( batchHolders[part] != null) { for (BatchHolder bh : batchHolders[part]) { bh.clear(); } batchHolders[part].clear(); } batchHolders[part] = new ArrayList<BatchHolder>(); // First BatchHolder is created when the first put request is received. }

Target:
private void reinitPartition(int part) /* throws SchemaChangeException /*, IOException */ { assert htables[part] != null; htables[part].reset(); if ( batchHolders[part] != null) { for (BatchHolder bh : batchHolders[part]) { bh.clear(); } batchHolders[part].clear(); } batchHolders[part] = new ArrayList<BatchHolder>(); // First BatchHolder is created when the first put request is received. }
Source:
private void runPreparedStatement(final PreparedStatementHandle preparedStatementHandle) throws ExecutionSetupException { final ServerPreparedStatementState serverState; try { serverState = ServerPreparedStatementState.PARSER.parseFrom(preparedStatementHandle.getServerInfo()); } catch (final InvalidProtocolBufferException ex) { throw UserException.parseError(ex) .message("Failed to parse the prepared statement handle. " + "Make sure the handle is same as one returned from create prepared statement call.") .build(logger); } final String sql = serverState.getSqlQuery(); logger.info("Prepared statement query for QueryId : {}", queryId, sql); runSQL(sql); // keep a query text of the preparedStatement for the queryManager queryText = sql; }

Target:
private void runPreparedStatement(final PreparedStatementHandle preparedStatementHandle) throws ExecutionSetupException { final ServerPreparedStatementState serverState; try { serverState = ServerPreparedStatementState.PARSER.parseFrom(preparedStatementHandle.getServerInfo()); } catch (final InvalidProtocolBufferException ex) { throw UserException.parseError(ex) .message("Failed to parse the prepared statement handle. " + "Make sure the handle is same as one returned from create prepared statement call.") .build(logger); } queryText = serverState.getSqlQuery(); logger.info("Prepared statement query for QueryId : {}", queryId, queryText); runSQL(queryText); }
Source:
public static int getChildCount(PhysicalOperator popConfig) { Iterator<PhysicalOperator> iter = popConfig.iterator(); int i = 0; while (iter.hasNext()) { iter.next(); i++; } if (i == 0) { i = 1; } return i; }

Target:
public static int getChildCount(PhysicalOperator popConfig) { Iterator<PhysicalOperator> iter = popConfig.iterator(); int count = 0; while (iter.hasNext()) { iter.next(); count++; } if (count == 0) { count = 1; } return count; }
Source:
public void close() { metrics.updateWriteBytes(spilledRuns.getWriteBytes()); RuntimeException ex = null; try { spilledRuns.close(); } catch (RuntimeException e) { ex = e; } try { bufferedBatches.close(); } catch (RuntimeException e) { ex = e; } if (ex != null) { throw ex; } }

Target:
public void close() { metrics.updateWriteBytes(spilledRuns.getWriteBytes()); RuntimeException ex = null; try { spilledRuns.close(); } catch (RuntimeException e) { ex = e; } try { bufferedBatches.close(); } catch (RuntimeException e) { ex = ex == null ? e : ex; } if (ex != null) { throw ex; } }
Source:
public T get(String key) { Integer index = getIndex(key); if (index == -1) { return null; } return get(index); }

Target:
public T get(String key) { int index = getIndex(key); if (index == -1) { return null; } return get(index); }
Source:
String getConnection() { return connection; }

Target:
public String getConnection() { return connection; }
Source:
public OpenTSDBStoragePlugin(OpenTSDBStoragePluginConfig configuration, DrillbitContext context, String name) throws IOException { this.context = context; this.schemaFactory = new OpenTSDBSchemaFactory(this, name); this.engineConfig = configuration; this.db = new ServiceImpl("http://" + configuration.getConnection()); }

Target:
public OpenTSDBStoragePlugin(OpenTSDBStoragePluginConfig configuration, DrillbitContext context, String name) throws IOException { this.context = context; this.schemaFactory = new OpenTSDBSchemaFactory(this, name); this.engineConfig = configuration; this.db = new ServiceImpl(configuration.getConnection()); }
Source:
private void recordNewState(final QueryState newState) { state = newState; if (queryContext.getOptions().getOption(ExecConstants.ZK_QUERY_STATE_UPDATE)) { queryManager.updateEphemeralState(newState); } }

Target:
private void recordNewState(final QueryState newState) { state = newState; queryManager.updateEphemeralState(newState); }
Source:
ClusterFixture(FixtureBuilder builder) { String zkConnect = configureZk(builder); try { createConfig(builder, zkConnect); startDrillbits(builder); applyOptions(builder); } catch (Exception e) { // Translate exceptions to unchecked to avoid cluttering // tests. Failures will simply fail the test itself. throw new IllegalStateException( "Cluster fixture setup failed", e ); } // Some operations need an allocator. allocator = RootAllocatorFactory.newRoot(config); }

Target:
ClusterFixture(FixtureBuilder builder) { configureZk(builder); try { createConfig(builder); allocator = RootAllocatorFactory.newRoot(config); startDrillbits(builder); applyOptions(builder); } catch (Exception e) { // Translate exceptions to unchecked to avoid cluttering // tests. Failures will simply fail the test itself. throw new IllegalStateException( "Cluster fixture setup failed", e ); } }
Source:
private long determineSizesSerial(long recordsToReadInThisPass) throws IOException { int recordsReadInCurrentPass = 0; top: do { for (VarLengthColumn<?> columnReader : columns) { // Return status is "done reading", meaning stop if true. if (columnReader.determineSize(recordsReadInCurrentPass, 0 /* unused */ )) { break top; } } for (VarLengthColumn<?> columnReader : columns) { columnReader.updateReadyToReadPosition(); columnReader.currDefLevel = -1; } recordsReadInCurrentPass++; } while (recordsReadInCurrentPass < recordsToReadInThisPass); return recordsReadInCurrentPass; }

Target:
private long determineSizesSerial(long recordsToReadInThisPass) throws IOException { int recordsReadInCurrentPass = 0; top: do { for (VarLengthColumn<?> columnReader : columns) { // Return status is "done reading", meaning stop if true. if (columnReader.determineSize(recordsReadInCurrentPass)) { break top; } } for (VarLengthColumn<?> columnReader : columns) { columnReader.updateReadyToReadPosition(); columnReader.currDefLevel = -1; } recordsReadInCurrentPass++; } while (recordsReadInCurrentPass < recordsToReadInThisPass); return recordsReadInCurrentPass; }
Source:
public FragmentContext getContext() { return incoming.getContext(); }

Target:
public FragmentContext getContext() { return context; }
Source:
public ContextInformation(final UserCredentials userCredentials, final QueryContextInformation queryContextInfo) { this.queryUser = userCredentials.getUserName(); this.currentDefaultSchema = queryContextInfo.getDefaultSchemaName(); this.queryStartTime = queryContextInfo.getQueryStartTime(); this.rootFragmentTimeZone = queryContextInfo.getTimeZone(); this.sessionId = queryContextInfo.getSessionId(); this.hllAccuracy = queryContextInfo.getHllAccuracy(); }

Target:
public ContextInformation(final UserCredentials userCredentials, final QueryContextInformation queryContextInfo) { this.queryUser = userCredentials.getUserName(); this.currentDefaultSchema = queryContextInfo.getDefaultSchemaName(); this.queryStartTime = queryContextInfo.getQueryStartTime(); this.rootFragmentTimeZone = queryContextInfo.getTimeZone(); this.sessionId = queryContextInfo.getSessionId(); }
Source:
public MSorter createNewMSorter(VectorAccessible batch) { if (mSorter == null) { mSorter = createNewMSorter(popConfig.getOrderings(), batch, MAIN_MAPPING, LEFT_MAPPING, RIGHT_MAPPING); } return mSorter; }

Target:
public MSorter createNewMSorter(VectorAccessible batch) { return createNewMSorter(popConfig.getOrderings(), batch, MAIN_MAPPING, LEFT_MAPPING, RIGHT_MAPPING); }
Source:
public ColumnDef( MockColumn mockCol, int rep ) { this( mockCol ); name = name += Integer.toString(rep); }

Target:
public ColumnDef(MockColumn mockCol, int rep) { this(mockCol); name += Integer.toString(rep); }
Source:
public static void tearDownCluster() throws Exception { synchronized (MongoTestSuit.class) { if (initCount.decrementAndGet() == 0) { if (mongoClient != null) { mongoClient.dropDatabase(EMPLOYEE_DB); mongoClient.close(); } if (distMode) { DistributedMode.cleanup(); } else { SingleMode.cleanup(); } } } }

Target:
public static void tearDownCluster() throws Exception { if (mongoClient != null) { mongoClient.dropDatabase(EMPLOYEE_DB); mongoClient.close(); } synchronized (MongoTestSuit.class) { if (distMode) { DistributedMode.cleanup(); } else { SingleMode.cleanup(); } } }
Source:
public Writer getWriter(PhysicalOperator child) throws IOException { if (!(formatPlugin.supportsAutoPartitioning() || partitionColumns == null || partitionColumns.size() == 0)) { throw UserException.unsupportedError().message(String.format("%s format does not support auto-partitioning.", formatPlugin.getName())).build(logger); } AbstractWriter writer = formatPlugin.getWriter(child, location, partitionColumns); if (storageStrategy != null) { writer.setStorageStrategy(storageStrategy); } return writer; }

Target:
public Writer getWriter(PhysicalOperator child) throws IOException { if (!(formatPlugin.supportsAutoPartitioning() || partitionColumns == null || partitionColumns.size() == 0)) { throw UserException.unsupportedError().message(String.format("%s format does not support auto-partitioning.", formatPlugin.getName())).build(logger); } AbstractWriter writer = formatPlugin.getWriter(child, location, partitionColumns); writer.setStorageStrategy(storageStrategy); return writer; }
Source:
public void addClass( String fqcn, byte[] byteCodes ) { assert ! cache.containsKey( fqcn ); Class<?> newClass = defineClass(fqcn, byteCodes, 0, byteCodes.length); cache.put( fqcn, newClass ); }

Target:
public void addClass(String fqcn, byte[] byteCodes) { Class<?> newClass = defineClass(fqcn, byteCodes, 0, byteCodes.length); cache.put(fqcn, newClass); }
Source:
public void addClasses(Map<String, byte[]> results) { for ( String key : results.keySet() ) { addClass( key, results.get( key ) ); } }

Target:
public void addClasses(Map<String, byte[]> results) { for (Map.Entry<String, byte[]> result : results.entrySet()) { addClass(result.getKey(), result.getValue()); } }
Source:
public InvalidConnectionInfoException(String message) { this.message = message; }

Target:
public InvalidConnectionInfoException(String message) { super(message); }
Source:
private String getHostName() throws UnknownHostException{ // DRILL_HOST_NAME sets custom host name. See drill-env.sh for details. String customHost = System.getenv("DRILL_HOST_NAME"); if (customHost == null) { return useIP ? InetAddress.getLocalHost().getHostAddress() : InetAddress.getLocalHost().getCanonicalHostName(); } else { return customHost; } }

Target:
private String getHostName() throws UnknownHostException{ // DRILL_HOST_NAME sets custom host name. See drill-env.sh for details. String customHost = System.getenv("DRILL_HOST_NAME"); if (customHost != null) { return customHost; } return useIP ? InetAddress.getLocalHost().getHostAddress() : InetAddress.getLocalHost().getCanonicalHostName(); }
Source:
public RowGroupInfo(@JsonProperty("path") String path, @JsonProperty("start") long start, @JsonProperty("length") long length, @JsonProperty("rowGroupIndex") int rowGroupIndex, long rowCount) { super(path, start, length); this.rowGroupIndex = rowGroupIndex; this.rowCount = rowCount; this.numRecordsToRead = rowCount; this.preferredEndpoint = null; }

Target:
public RowGroupInfo(@JsonProperty("path") String path, @JsonProperty("start") long start, @JsonProperty("length") long length, @JsonProperty("rowGroupIndex") int rowGroupIndex, long rowCount) { super(path, start, length); this.rowGroupIndex = rowGroupIndex; this.rowCount = rowCount; this.numRecordsToRead = rowCount; }
Source:
public synchronized long skip(long n) throws IOException { checkInputStreamState(); long bytesAvailable = this.count - this.curPosInBuffer; long bytesSkipped = 0; if (n <= 0) { return 0; } if (bytesAvailable <= 0) { checkInputStreamState(); bytesAvailable = getNextBlock(); if (bytesAvailable <= 0) { // End of stream return 0; } } bytesSkipped = bytesAvailable < n ? bytesAvailable : n; this.curPosInBuffer += bytesSkipped; return bytesSkipped; }

Target:
@Override public synchronized long skip(long n) throws IOException { checkInputStreamState(); long bytesAvailable = this.count - this.curPosInBuffer; long bytesSkipped = 0; if (n <= 0) { return 0; } if (bytesAvailable <= 0) { checkInputStreamState(); bytesAvailable = getNextBlock(); if (bytesAvailable <= 0) { // End of stream return 0; } } bytesSkipped = bytesAvailable < n ? bytesAvailable : n; this.curPosInBuffer += bytesSkipped; return bytesSkipped; }
Source:
public static BooleanType get(String literal) { String value = literal.toLowerCase().trim(); BooleanType booleanType = allLiterals.get(value); if (booleanType == null) { throw new IllegalArgumentException("Invalid value for boolean: " + literal); } return booleanType; }

Target:
public static BooleanType get(String literal) { final String value = literal.trim(); final BooleanType booleanType = allLiterals.get(value); if (booleanType == null) { throw new IllegalArgumentException("Invalid value for boolean: " + literal); } return booleanType; }
Source:
private void connect(DrillbitEndpoint endpoint) throws RpcException { client.connect(endpoint, parameters, getUserCredentials()).checkedGet(); if (client.serverRequiresAuthentication()) { try { client.authenticate(null).checkedGet(); } catch (SaslException e) { throw new RpcException(e); } } }

Target:
private void connect(DrillbitEndpoint endpoint) throws RpcException { client.connect(endpoint, properties, getUserCredentials()); }
Source:
public V get(final String key) { return get(key, null); }

Target:
public V get(final String key) { return get(key, false, null); }
Source:
public long getVersion() { try (AutoCloseableLock lock = readLock.open()) { return version.get(); } }

Target:
public long getVersion() { try (AutoCloseableLock lock = readLock.open()) { return version; } }
Source:
public long getInSubqueryThreshold() { return options.getOption(IN_SUBQUERY_THRESHOLD.getOptionName()).num_val; }

Target:
public long getInSubqueryThreshold() { return options.getOption(IN_SUBQUERY_THRESHOLD); }
Source:
public List<SqlNode> getOperandList() { List<SqlNode> ops = Lists.newArrayList(); ops.add(tableName); ops.add(SqlLiteral.createBoolean(tableExistenceCheck, SqlParserPos.ZERO)); return ops; }

Target:
public List<SqlNode> getOperandList() { final List<SqlNode> ops = ImmutableList.of( tableName, SqlLiteral.createBoolean(tableExistenceCheck, SqlParserPos.ZERO) ); return ops; }
Source:
public void start() { if (started) { return; } synchronized (queuedEvents) { started = true; isProcessing = true; } processEvents(); }

Target:
public void start() { synchronized (queuedEvents) { if (started) { return; } started = true; isProcessing = true; } processEvents(); }
Source:
public FormatCreator getFormatCreator(final Configuration fsConf) { if (formatCreator == null) { formatCreator = new FormatCreator(dContext, fsConf, fsConfig, dContext.getClasspathScan()); } return formatCreator; }

Target:
public FormatCreator getFormatCreator(final Configuration fsConf) { return new FormatCreator(dContext, fsConf, fsConfig, dContext.getClasspathScan()); }
Source:
protected String getBaseTableLocation() { final FormatSelection origSelection = (FormatSelection) table.getSelection(); return origSelection.getSelection().selectionRoot; }

Target:
private String getBaseTableLocation() { final FormatSelection origSelection = (FormatSelection) table.getSelection(); return origSelection.getSelection().selectionRoot; }
Source:
public void testSubmitPlanSingleNode() throws Exception { startCluster(1); DrillClient client = DrillClient.newBuilder().build(); client.connect(); List<QueryDataBatch> results = client.runQuery(QueryType.LOGICAL, plan); for (QueryDataBatch result : results) { System.out.println(result); result.release(); } client.close(); }

Target:
public void testSubmitPlanSingleNode() throws Exception { startCluster(1); DrillClient client = new DrillClient(); client.connect(); List<QueryDataBatch> results = client.runQuery(QueryType.LOGICAL, plan); for (QueryDataBatch result : results) { System.out.println(result); result.release(); } client.close(); }
Source:
public boolean isTypeInferenceEnabled() { return options.getOption(TYPE_INFERENCE.getOptionName()).bool_val; }

Target:
public boolean isTypeInferenceEnabled() { return options.getOption(TYPE_INFERENCE); }
Source:
public void close() { if (hjHelper != null) { hjHelper.clear(); } // If we didn't receive any data, hyperContainer may be null, check before clearing if (hyperContainer != null) { hyperContainer.clear(); } if (hashTable != null) { hashTable.clear(); } container.clear(); outputAllocator.close(); super.close(); }

Target:
public void close() { if (hjHelper != null) { hjHelper.clear(); } // If we didn't receive any data, hyperContainer may be null, check before clearing if (hyperContainer != null) { hyperContainer.clear(); } if (hashTable != null) { hashTable.clear(); } container.clear(); if (outputAllocator != null) { outputAllocator.close(); } super.close(); }
Source:
protected FileSelection(final FileSelection selection) { Preconditions.checkNotNull(selection, "selection cannot be null"); this.statuses = selection.statuses; this.files = selection.files; this.selectionRoot = selection.selectionRoot; this.dirStatus = new BitSet(StatusType.values().length); }

Target:
protected FileSelection(final FileSelection selection) { Preconditions.checkNotNull(selection, "selection cannot be null"); this.statuses = selection.statuses; this.files = selection.files; this.selectionRoot = selection.selectionRoot; this.dirStatus = selection.dirStatus; }
Source:
public void close() throws Exception { profileStore.close(); transientProfiles.close(); }

Target:
public void close() throws Exception { }
Source:
public <V> TransientStore<V> getOrCreateTransientStore(final TransientStoreConfig<V> config) { final ZkEphemeralStore<V> store = (ZkEphemeralStore<V>)factory.getOrCreateStore(config); try { store.start(); } catch (final Exception e) { throw new DrillRuntimeException("unable to start zookeeper transient store", e); } return store; }

Target:
public <V> TransientStore<V> getOrCreateTransientStore(final TransientStoreConfig<V> config) { final ZkEphemeralStore<V> store = (ZkEphemeralStore<V>)factory.getOrCreateStore(config); return store; }
Source:
private void updatePeak() { final long currentMemory = locallyHeldMemory.get(); while (true) { final long previousPeak = peakAllocation.get(); if (currentMemory > previousPeak) { if (peakAllocation.compareAndSet(previousPeak, currentMemory)) { // if we're able to update peak, finish. return; } else { // peak allocation changed underneath us. try again. continue; } } else { return; } } }

Target:
private void updatePeak() { final long currentMemory = locallyHeldMemory.get(); long previousPeak; do { previousPeak = peakAllocation.get(); if (peakAllocation.compareAndSet(previousPeak, currentMemory)) { // if we're able to update peak, finish. return; } } while (currentMemory > previousPeak); }
Source:
private void childClosed(final BaseAllocator childAllocator) { if (DEBUG) { Preconditions.checkArgument(childAllocator != null, "child allocator can't be null"); synchronized (DEBUG_LOCK) { final Object object = childAllocators.remove(childAllocator); if (object == null) { childAllocator.historicalLog.logHistory(logger); throw new IllegalStateException("Child allocator[" + childAllocator.id + "] not found in parent allocator[" + id + "]'s childAllocators"); } } } }

Target:
private void childClosed(final BaseAllocator childAllocator) { if (DEBUG) { Preconditions.checkArgument(childAllocator != null, "child allocator can't be null"); synchronized (DEBUG_LOCK) { final Object object = childAllocators.remove(childAllocator); if (object == null) { childAllocator.historicalLog.logHistory(logger); throw new IllegalStateException("Child allocator[" + childAllocator.name + "] not found in parent allocator[" + name + "]'s childAllocators"); } } } }
Source:
public void eval() { org.apache.drill.exec.util.ByteBufUtil.checkBufferLength(in.buffer, in.start, in.end, 8); in.buffer.readerIndex(in.start); long epochMillis = Long.reverseBytes(in.buffer.readLong()); in.buffer.readerIndex(0); long millsOfDay = epochMillis % (24*3600*1000); out.value = epochMillis - millsOfDay; }

Target:
public void eval() { org.apache.drill.exec.util.ByteBufUtil.checkBufferLength(in.buffer, in.start, in.end, 8); in.buffer.readerIndex(in.start); long epochMillis = Long.reverseBytes(in.buffer.readLong()); long millsOfDay = epochMillis % (24*3600*1000); out.value = epochMillis - millsOfDay; }
Source:
public SequenceFileRecordReader(final FileSplit split, final DrillFileSystem dfs, final String queryUserName, final String opUserName) { final List<SchemaPath> columns = new ArrayList(); columns.add(keySchema); columns.add(valueSchema); setColumns(columns); this.dfs = dfs; this.split = split; this.queryUserName = queryUserName; this.opUserName = opUserName; }

Target:
public SequenceFileRecordReader(final FileSplit split, final DrillFileSystem dfs, final String queryUserName, final String opUserName) { final List<SchemaPath> columns = new ArrayList<>(); columns.add(keySchema); columns.add(valueSchema); setColumns(columns); this.dfs = dfs; this.split = split; this.queryUserName = queryUserName; this.opUserName = opUserName; }
Source:
public static boolean isUnion(MajorType toType) { if (toType.getMinorType() == MinorType.UNION) { return true; } return false; }

Target:
public static boolean isUnion(MajorType toType) { return toType.getMinorType() == MinorType.UNION; }
Source:
public void putChild(String name, ValueVector vector) { putVector(name, vector); field.addChild(vector.getField()); }

Target:
protected void putChild(String name, ValueVector vector) { putVector(name, vector); field.addChild(vector.getField()); }