method2testcases stringlengths 118 6.63k |
|---|
### Question:
CpGenco extends Broker { @ConfigurableValue(valueType = "Double", description = "minimum leadtime for first commitment, in hours") @StateChange public CpGenco withMinQuantity (double qty) { this.minQuantity = qty; return this; } CpGenco(String username); void init(BrokerProxy proxy, int seedId,
... |
### Question:
RegulationCapacity { public RegulationCapacity (TariffSubscription subscription, double upRegulationCapacity, double downRegulationCapacity) { super(); this.subscription = subscription; if (upRegulationCapacity < 0.0) { if (upRegulationCapacity < -epsilon) log.warn("upRegulationCapacity " + upRegulationCa... |
### Question:
EvCustomer { public void doActivities (int day, int hour) { TimeslotData timeslotData = todayMap[hour]; double intendedDistance = timeslotData.getIntendedDistance(); double neededCapacity = getNeededCapacity(intendedDistance); if (intendedDistance < distanceEpsilon) { return; } if (neededCapacity > curren... |
### Question:
EvSocialClass extends AbstractCustomer { int getMinCount () { return minCount; } EvSocialClass(); EvSocialClass(String name); @Override void initialize(); double getHomeChargerProbability(); @Override void saveBootstrapState(); @Override void evaluateTariffs(List<Tariff> tariffs); @Override void step(); ... |
### Question:
Activity { public Optional<double[]> getDailyProfileOptional () { return Optional.ofNullable(dailyProfile); } Activity(); Activity(String name); double getDayWeight(int day); int getId(); String getName(); double getChargerProbability(); void setChargerProbability(double prob); int getInterval(); double ... |
### Question:
Activity { public double getProbabilityForTimeslot (int slot) { double result = 1.0; if (slot < 0 || slot > 23) { log.error("bad slot {} in probabilityForTimeslot", slot); result = 0.0; } else if (getDailyProfileOptional().isPresent()) { result = getDailyProfileOptional().get()[slot]; } else { result = 1.... |
### Question:
Config { public synchronized static Config getInstance () { if (null == instance) { instance = new Config(); } return instance; } private Config(); double getEpsilon(); double getLambda(); double getTouFactor(); double getInterruptibilityFactor(); double getVariablePricingFactor(); double getTieredRateFa... |
### Question:
RegulationCapacity { public double getUpRegulationCapacity () { return upRegulationCapacity; } RegulationCapacity(TariffSubscription subscription,
double upRegulationCapacity,
double downRegulationCapacity); RegulationCapacity(); long getId(); Tar... |
### Question:
BrokerProxyService implements BrokerProxy { @Override public void sendMessage (Broker broker, Object messageObject) { if (broker.isEnabled()) visualizerProxyService.forwardMessage(messageObject); localSendMessage(broker, messageObject); } BrokerProxyService(); @Override void sendMessage(Broker broker, Obj... |
### Question:
BrokerProxyService implements BrokerProxy { @Override public void sendMessages (Broker broker, List<?> messageObjects) { for (Object message : messageObjects) { sendMessage(broker, message); } } BrokerProxyService(); @Override void sendMessage(Broker broker, Object messageObject); @Override void sendMessa... |
### Question:
BrokerProxyService implements BrokerProxy { @Override public void routeMessage (Object message) { if (router.route(message)) { if (!(message instanceof TariffSpecification)) { visualizerProxyService.forwardMessage(message); } } } BrokerProxyService(); @Override void sendMessage(Broker broker, Object messa... |
### Question:
RegulationCapacity { public double getDownRegulationCapacity () { return downRegulationCapacity; } RegulationCapacity(TariffSubscription subscription,
double upRegulationCapacity,
double downRegulationCapacity); RegulationCapacity(); long getId();... |
### Question:
CapacityControlService extends TimeslotPhaseProcessor implements CapacityControl, InitializationService { @Override public void postEconomicControl (EconomicControlEvent event) { int tsIndex = event.getTimeslotIndex(); int current = timeslotRepo.currentTimeslot().getSerialNumber(); if (tsIndex < current) ... |
### Question:
JobHistoryFileParserFactory { public static JobHistoryFileParser createJobHistoryFileParser( byte[] historyFileContents, Configuration jobConf) throws IllegalArgumentException { if (historyFileContents == null) { throw new IllegalArgumentException( "Job history contents should not be null"); } HadoopVersi... |
### Question:
JobHistoryFileParserBase implements JobHistoryFileParser { public static long getSubmitTimeMillisFromJobHistory(byte[] jobHistoryRaw) { long submitTimeMillis = 0; if (null == jobHistoryRaw) { return submitTimeMillis; } HadoopVersion hv = JobHistoryFileParserFactory.getVersion(jobHistoryRaw); switch (hv) {... |
### Question:
JobHistoryFileParserBase implements JobHistoryFileParser { public static double calculateJobCost(long mbMillis, double computeTco, long machineMemory) { if ((machineMemory == 0L) || (computeTco == 0.0)) { LOG.error("Unable to calculate job cost since machineMemory " + machineMemory + " or computeTco " + c... |
### Question:
FileLister { static String getJobIdFromPath(Path aPath) { String fileName = aPath.getName(); JobFile jf = new JobFile(fileName); String jobId = jf.getJobid(); if(jobId == null) { throw new ProcessingException("job id is null for " + aPath.toUri()); } return jobId; } FileLister(); static FileStatus[] listF... |
### Question:
JobHistoryFileParserFactory { public static HadoopVersion getVersion(byte[] historyFileContents) { if(historyFileContents.length > HADOOP2_VERSION_LENGTH) { String version2Part = new String(historyFileContents, 0, HADOOP2_VERSION_LENGTH); if (StringUtils.equalsIgnoreCase(version2Part, HADOOP2_VERSION_STRI... |
### Question:
JobHistoryFileParserHadoop2 extends JobHistoryFileParserBase { byte[] getValue(String key, int value) { byte[] valueBytes = null; Class<?> clazz = JobHistoryKeys.KEY_TYPES.get(JobHistoryKeys.valueOf(key)); if (clazz == null) { throw new IllegalArgumentException(" unknown key " + key + " encountered while ... |
### Question:
CounterMap implements Iterable<Counter> { @Override public Iterator<Counter> iterator() { return new Iterator<Counter>() { private Iterator<Map.Entry<String,Map<String,Counter>>> groupIter = internalMap.entrySet().iterator(); private Iterator<Map.Entry<String,Counter>> currentGroupIter = null; @Override p... |
### Question:
JobDescFactory { public static String getCluster(Configuration jobConf) { String jobtracker = jobConf.get(RESOURCE_MANAGER_KEY); if (jobtracker == null) { jobtracker = jobConf.get(JOBTRACKER_KEY); } String cluster = null; if (jobtracker != null) { int portIdx = jobtracker.indexOf(':'); if (portIdx > -1) {... |
### Question:
JobDetails implements Comparable<JobDetails> { Long getCounterValueAsLong(final CounterMap counters, final String counterGroupName, final String counterName) { Counter c1 = counters.getCounter(counterGroupName, counterName); if (c1 != null) { return c1.getValue(); } else { return 0L; } } @JsonCreator Job... |
### Question:
JobDescFactoryBase { public String getAppId(Configuration jobConf) { if (jobConf == null) { return Constants.UNKNOWN; } String appId = jobConf.get(Constants.APP_NAME_CONF_KEY); if (StringUtils.isBlank(appId)) { appId = jobConf.get(Constants.JOB_NAME_CONF_KEY); if (StringUtils.isNotBlank(appId)) { appId = ... |
### Question:
TaskKey extends JobKey implements Comparable<Object> { public String getTaskId() { return this.taskId; } @JsonCreator TaskKey(@JsonProperty("jobId") JobKey jobKey, @JsonProperty("taskId") String taskId); String getTaskId(); String toString(); @Override int compareTo(Object other); @Override boolean equal... |
### Question:
TaskKey extends JobKey implements Comparable<Object> { public String toString() { return super.toString() + Constants.SEP + getTaskId(); } @JsonCreator TaskKey(@JsonProperty("jobId") JobKey jobKey, @JsonProperty("taskId") String taskId); String getTaskId(); String toString(); @Override int compareTo(Obje... |
### Question:
ByteArrayWrapper extends ByteArrayInputStream implements PositionedReadable, Seekable, Closeable { public synchronized long getPos() throws IOException { return pos; } ByteArrayWrapper(byte[] buf); synchronized void seek(long position); synchronized long getPos(); boolean seekToNewSource(long targetPos); ... |
### Question:
ByteArrayWrapper extends ByteArrayInputStream implements PositionedReadable, Seekable, Closeable { public synchronized void seek(long position) throws IOException { if (position < 0 || position >= count) { throw new IOException("cannot seek position " + position + " as it is out of bounds"); } pos = (int)... |
### Question:
ByteArrayWrapper extends ByteArrayInputStream implements PositionedReadable, Seekable, Closeable { public boolean seekToNewSource(long targetPos) throws IOException { return false; } ByteArrayWrapper(byte[] buf); synchronized void seek(long position); synchronized long getPos(); boolean seekToNewSource(lo... |
### Question:
ByteArrayWrapper extends ByteArrayInputStream implements PositionedReadable, Seekable, Closeable { public synchronized int read(long position, byte[] buffer, int offset, int length) throws IOException { long oldPos = getPos(); int nread = -1; try { seek(position); nread = read(buffer, offset, length); } f... |
### Question:
ByteArrayWrapper extends ByteArrayInputStream implements PositionedReadable, Seekable, Closeable { public synchronized void readFully(long position, byte[] buffer, int offset, int length) throws IOException { int nread = 0; while (nread < length) { int nbytes = read(position + nread, buffer, offset + nrea... |
### Question:
HadoopConfUtil { public static boolean contains(Configuration jobConf, String name) { if (StringUtils.isNotBlank(jobConf.get(name))) { return true; } else { return false; } } static String getUserNameInConf(Configuration jobConf); static boolean contains(Configuration jobConf, String name); static String... |
### Question:
HadoopConfUtil { public static String getUserNameInConf(Configuration jobConf) throws IllegalArgumentException { String userName = jobConf.get(Constants.USER_CONF_KEY_HADOOP2); if (StringUtils.isBlank(userName)) { userName = jobConf.get(Constants.USER_CONF_KEY); if (StringUtils.isBlank(userName)) { throw ... |
### Question:
HadoopConfUtil { public static String getQueueName(Configuration jobConf) { String hRavenQueueName = jobConf.get(Constants.QUEUENAME_HADOOP2); if (StringUtils.isBlank(hRavenQueueName)) { hRavenQueueName = jobConf .get(Constants.FAIR_SCHEDULER_POOLNAME_HADOOP1); if (StringUtils.isBlank(hRavenQueueName)) { ... |
### Question:
ByteUtil { public static byte[][] split(byte[] source, byte[] separator) { return split(source, separator, -1); } static byte[][] split(byte[] source, byte[] separator); static byte[][] split(byte[] source, byte[] separator, int limit); static List<Range> splitRanges(byte[] source, byte[] separator); sta... |
### Question:
ByteUtil { public static List<Range> splitRanges(byte[] source, byte[] separator) { return splitRanges(source, separator, -1); } static byte[][] split(byte[] source, byte[] separator); static byte[][] split(byte[] source, byte[] separator, int limit); static List<Range> splitRanges(byte[] source, byte[] ... |
### Question:
ByteUtil { public static byte[] join(byte[] separator, byte[]... components) { if (components == null || components.length == 0) { return Constants.EMPTY_BYTES; } int finalSize = 0; if (separator != null) { finalSize = separator.length * (components.length - 1); } for (byte[] comp : components) { finalSiz... |
### Question:
ByteUtil { public static int indexOf(byte[] array, byte[] target, int fromIndex) { if (array == null || target == null) { return -1; } if (fromIndex < 0 || (fromIndex > (array.length - target.length))) { return -1; } if (target.length == 0) { return fromIndex; } firstbyte: for (int i = fromIndex; i < arra... |
### Question:
ByteUtil { public static long getValueAsLong(final byte[] key, final Map<byte[], byte[]> taskValues) { byte[] value = taskValues.get(key); if (value != null) { try { long retValue = Bytes.toLong(value); return retValue; } catch (NumberFormatException nfe) { LOG.error("Caught NFE while converting to long "... |
### Question:
ByteUtil { public static String getValueAsString(final byte[] key, final Map<byte[], byte[]> taskValues) { byte[] value = taskValues.get(key); if (value != null) { return Bytes.toString(value); } else { return ""; } } static byte[][] split(byte[] source, byte[] separator); static byte[][] split(byte[] so... |
### Question:
ByteUtil { public static double getValueAsDouble(byte[] key, NavigableMap<byte[], byte[]> infoValues) { byte[] value = infoValues.get(key); if (value != null) { return Bytes.toDouble(value); } else { return 0.0; } } static byte[][] split(byte[] source, byte[] separator); static byte[][] split(byte[] sour... |
### Question:
BatchUtil { public static boolean shouldRetain(int i, int maxRetention, int length) { int retentionCutoff = length - maxRetention; boolean retain = (i >= retentionCutoff) ? true : false; return retain; } static boolean shouldRetain(int i, int maxRetention, int length); static int getBatchCount(int length... |
### Question:
BatchUtil { public static int getBatchCount(int length, int batchSize) { if ((batchSize < 1) || (length < 1)) { return 0; } int remainder = length % batchSize; return (remainder > 0) ? (length / batchSize) + 1 : (length / batchSize); } static boolean shouldRetain(int i, int maxRetention, int length); sta... |
### Question:
BatchUtil { public static <E extends Comparable<E>> List<Range<E>> getRanges(Collection<E> collection, int batchSize) { List<Range<E>> rangeList = new LinkedList<Range<E>>(); E currentMin = null; if ((collection != null) && (collection.size() > 0) && (batchSize > 0)) { int index = 1; for (E element : coll... |
### Question:
MRJobDescFactory extends JobDescFactoryBase { @Override JobDesc create(QualifiedJobId qualifiedJobId, long submitTimeMillis, Configuration jobConf) { String appId = getAppId(jobConf); long appSubmitTimeMillis = jobConf.getLong(Constants.MR_RUN_CONF_KEY, submitTimeMillis); return create(qualifiedJobId, job... |
### Question:
PigJobDescFactory extends JobDescFactoryBase { @Override String getAppIdFromJobName(String jobName) { if (jobName == null) { return null; } Matcher matcher = scheduledJobnamePattern.matcher(jobName); if (matcher.matches()) { jobName = SCHEDULED_PREFIX + matcher.group(1); } return jobName; } @Override Job... |
### Question:
PigJobDescFactory extends JobDescFactoryBase { public static long getScriptStartTimeFromLogfileName(String pigLogfile) { long pigSubmitTimeMillis = 0; if (pigLogfile == null) { return pigSubmitTimeMillis; } Matcher matcher = pigLogfilePattern.matcher(pigLogfile); if (matcher.matches()) { String submitTime... |
### Question:
FlowKey extends AppKey implements Comparable<Object> { public String toString() { return super.toString() + Constants.SEP + this.getRunId(); } @JsonCreator FlowKey(@JsonProperty("cluster") String cluster,
@JsonProperty("userName") String userName,
@JsonProperty("appId") ... |
### Question:
HdfsStatsKey implements Comparable<Object> { public QualifiedPathKey getQualifiedPathKey() { return pathKey; } @JsonCreator HdfsStatsKey(@JsonProperty("cluster") String cluster,
@JsonProperty("path") String path,
@JsonProperty("encodedRunId") long encodedRunId); @JsonCreat... |
### Question:
HdfsStatsKey implements Comparable<Object> { public static long getRunId(long encodedRunId) { return Long.MAX_VALUE - encodedRunId; } @JsonCreator HdfsStatsKey(@JsonProperty("cluster") String cluster,
@JsonProperty("path") String path,
@JsonProperty("encodedRunId") long en... |
### Question:
HdfsStatsKey implements Comparable<Object> { @Override public int compareTo(Object other) { if (other == null) { return -1; } HdfsStatsKey otherKey = (HdfsStatsKey) other; return new CompareToBuilder() .append(this.pathKey, otherKey.getQualifiedPathKey()) .append(this.encodedRunId, otherKey.getEncodedRunI... |
### Question:
AppKey implements Comparable<Object> { public String toString() { return getCluster() + Constants.SEP + getUserName() + Constants.SEP + getAppId(); } @JsonCreator AppKey(@JsonProperty("cluster") String cluster, @JsonProperty("userName") String userName,
@JsonProperty("appId") String appId); String ... |
### Question:
JobId implements Comparable<JobId> { @Override public int compareTo(JobId o) { if (o == null) { return -1; } return new CompareToBuilder() .append(this.jobEpoch, o.getJobEpoch()) .append(this.jobSequence, o.getJobSequence()) .toComparison(); } @JsonCreator JobId(@JsonProperty("jobIdString") String jobId)... |
### Question:
ScaldingJobDescFactory extends JobDescFactoryBase { @Override JobDesc create(QualifiedJobId qualifiedJobId, long submitTimeMillis, Configuration jobConf) { String appId = getAppId(jobConf); if (Constants.UNKNOWN.equals(appId)) { appId = cleanAppId(jobConf.get(Constants.CASCADING_APP_ID_CONF_KEY)); } Strin... |
### Question:
ScaldingJobDescFactory extends JobDescFactoryBase { String stripAppId(String origId) { if (origId == null || origId.isEmpty()) { return ""; } Matcher m = stripBracketsPattern.matcher(origId); String cleanedAppId = m.replaceAll(""); Matcher tailMatcher = stripSequencePattern.matcher(cleanedAppId); if (tail... |
### Question:
HdfsStatsService { public static long getEncodedRunId(long now) { long lastHour = now - (now % 3600); return (Long.MAX_VALUE - lastHour); } HdfsStatsService(Configuration hbaseConf, Connection hbaseConnection); static long getEncodedRunId(long now); List<HdfsStats> getAllDirs(String cluster, String pathPr... |
### Question:
HdfsStatsService { public static long getOlderRunId(int i, long runId) { int randomizedHourInSeconds = (int) (Math.random() * 23) * 3600; if (i >= HdfsConstants.ageMult.length) { throw new ProcessingException("Can't look back in time that far " + i + ", only upto " + HdfsConstants.ageMult.length); } long ... |
### Question:
HdfsStatsService { public List<HdfsStats> getHdfsTimeSeriesStats(String cluster, String path, int limit, long starttime, long endtime) throws IOException { Scan scan = GenerateScanFuzzy(starttime, endtime, cluster, path); return createFromScanResults(cluster, path, scan, limit, Boolean.TRUE, starttime, en... |
### Question:
JobHistoryService { public JobDetails getJobByJobID(String cluster, String jobId) throws IOException { return getJobByJobID(cluster, jobId, false); } JobHistoryService(Configuration hbaseConf, Connection hbaseConnection); Flow getLatestFlow(String cluster, String user, String appId); Flow getLatestFlow(St... |
### Question:
AppSummaryService { long getTimestamp(long runId, AggregationConstants.AGGREGATION_TYPE aggType) { if (AggregationConstants.AGGREGATION_TYPE.DAILY.equals(aggType)) { long dayTimestamp = runId - (runId % Constants.MILLIS_ONE_DAY); return dayTimestamp; } else if (AggregationConstants.AGGREGATION_TYPE.WEEKLY... |
### Question:
AppSummaryService { long getNumberRunsScratch(Map<byte[], byte[]> rawFamily) { long numberRuns = 0L; if (rawFamily != null) { numberRuns = rawFamily.size(); } if (numberRuns == 0L) { LOG.error("Number of runs in scratch column family can't be 0," + " if processing within TTL"); throw new ProcessingExcepti... |
### Question:
AppSummaryService { String createQueueListValue(JobDetails jobDetails, String existingQueues) { String queue = jobDetails.getQueue(); queue = queue.concat(Constants.SEP); if (existingQueues == null) { return queue; } if (!existingQueues.contains(queue)) { existingQueues = existingQueues.concat(queue); } r... |
### Question:
AppVersionService { public List<VersionInfo> getDistinctVersions(String cluster, String user, String appId) throws IOException { Get get = new Get(getRowKey(cluster, user, appId)); List<VersionInfo> versions = Lists.newArrayList(); Long ts = 0L; Table versionsTable = null; try { versionsTable = hbaseConne... |
### Question:
JobHistoryRawService { public long getApproxSubmitTime(Result value) throws MissingColumnInResultException { if (value == null) { throw new IllegalArgumentException( "Cannot get last modification time from " + "a null hbase result"); } Cell cell = value.getColumnLatestCell(Constants.INFO_FAM_BYTES, Consta... |
### Question:
QualifiedPathKey implements Comparable<Object> { public String getNamespace() { return namespace; } QualifiedPathKey(String cluster, String path); QualifiedPathKey(String cluster, String path, String namespace); String getCluster(); String getPath(); String getNamespace(); @Override String toString(); @O... |
### Question:
JobHistoryFileParserBase implements JobHistoryFileParser { static String extractXmxValueStr(String javaChildOptsStr) { if (StringUtils.isBlank(javaChildOptsStr)) { LOG.info("Null/empty input argument to get xmxValue, returning " + Constants.DEFAULT_XMX_SETTING_STR); return Constants.DEFAULT_XMX_SETTING_ST... |
### Question:
QualifiedPathKey implements Comparable<Object> { @Override public int compareTo(Object other) { if (other == null) { return -1; } QualifiedPathKey otherKey = (QualifiedPathKey) other; if (StringUtils.isNotBlank(this.namespace)) { return new CompareToBuilder() .append(this.cluster, otherKey.getCluster()) .... |
### Question:
QualifiedPathKey implements Comparable<Object> { @Override public int hashCode() { return new HashCodeBuilder() .append(this.cluster) .append(this.path) .append(this.namespace) .toHashCode(); } QualifiedPathKey(String cluster, String path); QualifiedPathKey(String cluster, String path, String namespace);... |
### Question:
JobKey extends FlowKey implements Comparable<Object> { @Override public int compareTo(Object other) { if (other == null) { return -1; } JobKey otherKey = (JobKey)other; return new CompareToBuilder().appendSuper(super.compareTo(otherKey)) .append(this.jobId, otherKey.getJobId()) .toComparison(); } JobKey(S... |
### Question:
JobKey extends FlowKey implements Comparable<Object> { public String toString() { return super.toString() + Constants.SEP + this.jobId.getJobIdString(); } JobKey(String cluster, String userName, String appId, long runId,
String jobId); @JsonCreator JobKey(@JsonProperty("cluster") String cluster,
... |
### Question:
PardResultSet implements Serializable { public ResultStatus getStatus() { return resultStatus; } PardResultSet(); PardResultSet(ResultStatus resultStatus); PardResultSet(ResultStatus resultStatus, String msg); PardResultSet(ResultStatus resultStatus, List<Column> schema); PardResultSet(ResultStatus re... |
### Question:
SqlParser { public Statement createStatement(String sql) { return (Statement) invokeParser("statement", sql, PardSqlBaseParser::singleStatement); } Statement createStatement(String sql); Expression createExpression(String expression); }### Answer:
@Test public void testSelectJoin() { String sql = "SELEC... |
### Question:
PardClient { public static void main(String[] args) { if (args.length != 2) { System.out.println("PardClient <host> <port>"); System.exit(-1); } String host = args[0]; int port = Integer.parseInt(args[1]); System.out.println("Connecting to " + host + ":" + port); try { PardClient client = new PardClient(h... |
### Question:
SemanticAnalysis { public Plan analysis(Statement stmt) { return null; } Plan analysis(Statement stmt); }### Answer:
@Test public void analysis() { String sql = "SELECT * FROM test0"; Statement statement = parser.createStatement(sql); if (statement instanceof Query) { Query q = (Query) statement; System... |
### Question:
Expr implements Serializable { public static Expr generalReplace(Expr e1, Item from, Item to) { Expr e = Expr.clone(e1); if (e instanceof SingleExpr) { SingleExpr se = (SingleExpr) e; Item lv = se.getLvalue(); Item rv = se.getRvalue(); if (lv.equals(from)) { lv = Item.clone(to); } if (rv.equals(from)) { r... |
### Question:
PersistParser extends Parser { @Override public Definition parse(String processName, int processVersion) { DefinitionDO definitionDO; if (processVersion == 0) { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName) .... |
### Question:
PersistMachine extends Machine { public String getBizId() { return bizId; } protected PersistMachine(String bizId, String processName, int processVersion, ProcessDO processDO,
ProcessDOMapper processDOMapper
, StateDOMapper stateDOMapper
, PersistHelper persis... |
### Question:
State extends RunnableState { @Override public StateLike parse(Element elem) { super.parse(elem); if (elem.attributeValue(REPEATLIST_TAG) != null) { repeatList = elem.attributeValue(REPEATLIST_TAG); } if (elem.attributeValue(IGNOREWEEKEND_TAG) != null) { ignoreWeekend = Boolean.valueOf(elem.attributeValue... |
### Question:
Path implements PathLike { @Override public boolean can(Map<String, Object> vars) throws CoreModuleException { if (StringUtils.isBlank(expr)) { return true; } else { try { return MvelUtils.evalToBoolean(expr, vars); } catch (Exception e) { throw new CoreModuleException("未传入context中相应的表达式(expr)!\n" + e.get... |
### Question:
Parser implements BaseParser { public Document getXML(String processName, @SuppressWarnings("UnusedParameters") int processVersion) { SAXReader reader = new SAXReader(); URL url = this.getClass().getResource("/" + processName.replaceAll("\\.", "/") + ".xml"); Document document; try { document = reader.rea... |
### Question:
Parser implements BaseParser { @Override public Definition parse(String processName, int processVersion) { Document processXML = getXML(processName, processVersion); return parser0(processName, 1, processXML, true); } @Override boolean needRefresh(String processName, int processVersion, Definition oldDef... |
### Question:
CheckerWithException { public int checkValue(final int amount) { if (amount == 0) { throw new IllegalArgumentException("value is 0"); } return 0; } int checkValue(final int amount); }### Answer:
@Test public void checkValueTerseWay() throws Exception { try { checkerWithException.checkValue(0); fail("Exp... |
### Question:
XMLParser { List<BlockInfo> parseLine(String line) throws IOException { if (line.contains("<inode>")) { transitionTo(State.INODE); } if (line.contains("<type>FILE</type>")) { transitionTo(State.FILE); } List<String> replicationStrings = valuesFromXMLString(line, "replication"); if (!replicationStrings.isE... |
### Question:
AuditLogDirectParser implements AuditCommandParser { @Override public AuditReplayCommand parse(Text inputLine, Function<Long, Long> relativeToAbsolute) throws IOException { Matcher m = MESSAGE_ONLY_PATTERN.matcher(inputLine.toString()); if (!m.find()) { throw new IOException("Unable to find valid message ... |
### Question:
ParallelProcessor implements AutoCloseable, BatchIterator<R> { @Override public long skip(long count) { long skipped = 0; while (skipped < count) { try { if (!ensureBuffer()) { return skipped; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new UncheckedInterruptedException(... |
### Question:
VirtualExecutorService extends AbstractExecutorService { @Override public List<Runnable> shutdownNow() { synchronized (_pendingLock) { _stage = STAGE_SHUTDOWN_NOW; for (Thread pending : LinkedNode.values(_pendingThreads)) { pending.interrupt(); } return LinkedNode.values(_pendingRunnables); } } VirtualExe... |
### Question:
LockingBinaryTree extends BinaryTree<Integer> { public LockingBinaryTree(Integer data) { super(data); } LockingBinaryTree(Integer data); boolean isLocked(); boolean lock(); void unlock(); }### Answer:
@Test public void lockingBinaryTree() { LockingBinaryTree lockingBinaryTree = new LockingBinaryTree(0); ... |
### Question:
LRUCache { public LRUCache(int capacity) { this.capacity = capacity; map = new HashMap<>(); head = new Node(-1, -1); tail = new Node(-1, -1); head.next = tail; tail.prev = head; } LRUCache(int capacity); Integer lookup(Integer key); Integer insert(Integer key, Integer value); Integer remove(Integer key); ... |
### Question:
MySimilarity extends DefaultSimilarity { @Override public float lengthNorm(String fieldName, int numTerms) { if (numTerms < 20) { if (numTerms <= 0) return 0; return -0.00606f * numTerms + 0.35f; } return (float) (1.0 / Math.sqrt(numTerms)); } @Override float lengthNorm(String fieldName, int numTerms); ... |
### Question:
SparseArray2DImpl implements ISparseArray2D<T> { @Override public T getAt(int row, int col) throws ArrayIndexOutOfBoundsException { if (row>this.row || col>column){ throw new ArrayIndexOutOfBoundsException(); } else{ IndexNode current = rowLinkedList.head; while (current!=null){ if (row==current.index){ A... |
### Question:
CircularArraySequence implements Sequence { @Override public Object last() { CircularArraySequence<T> tempSequence = new CircularArraySequence<T>(this); T lastObj; if (rear == 0){ if (tempSequence.backingArray[tempSequence.backingArray.length-1]==null && tempSequence.backingArray[tempSequence.rear] != nul... |
### Question:
CircularArraySequence implements Sequence { @Override public Object peekHead() { return backingArray[front]; } CircularArraySequence(int size); CircularArraySequence(CircularArraySequence<T> seq); @Override Object head(); @Override Object last(); @Override Sequence front(); @Override Sequence tail(); @Ov... |
### Question:
CircularArraySequence implements Sequence { @Override public Object peekLast() { if (rear==0){ if (backingArray[backingArray.length-1]==null){ return backingArray[rear]; } else{ return backingArray[backingArray.length-1]; } } return backingArray[rear-1]; } CircularArraySequence(int size); CircularArraySe... |
### Question:
CircularArraySequence implements Sequence { @Override public void prepend(Object element) { if (backingArray[front] != null && front == 0){ backingArray[backingArray.length-1] = (T)element; front = backingArray.length-1; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] == nu... |
### Question:
CircularArraySequence implements Sequence { @Override public Sequence tail() { CircularArraySequence<T> tempSequence = new CircularArraySequence<T>(this); if (backingArray[front]!=null){ tempSequence.backingArray[front] = null; tempSequence.fillCount-=1; if (front == backingArray.length-1){ tempSequence.f... |
### Question:
CircularArraySequence implements Sequence { @Override public Iterator<T> iterator() { SequenceIterator<T> iterator = new SequenceIterator<T>(this); return iterator; } CircularArraySequence(int size); CircularArraySequence(CircularArraySequence<T> seq); @Override Object head(); @Override Object last(); @O... |
### Question:
CircularArraySequence implements Sequence { @Override public int length() { return fillCount; } CircularArraySequence(int size); CircularArraySequence(CircularArraySequence<T> seq); @Override Object head(); @Override Object last(); @Override Sequence front(); @Override Sequence tail(); @Override Sequence... |
### Question:
CircularArraySequence implements Sequence { public String toString(){ String stringSeq = ""; boolean halt = false; int index = front; while (halt == false){ if (index == backingArray.length){ index = 0; } if (index == rear){ halt = true; } else{ stringSeq = stringSeq + backingArray[index].toString(); inde... |
### Question:
CircularArraySequence implements Sequence { private void regrow(){ T[] tempArray = (T[])new Object[backingArray.length*2]; for (int i=0;i<backingArray.length;i++){ tempArray[i] = backingArray[i]; } int tempfillCount = fillCount; int index = front; int newIndex = 0; while (tempfillCount!=0){ if (index == b... |
### Question:
AVLTreeImpl implements IAVLBinaryTree<K, V> { @Override public boolean isEmpty() { if (root==null){ return true; } return false; } AVLTreeImpl(boolean rotate); void resetOpsCount(); int getOpsCount(); @Override boolean isEmpty(); @Override int size(); @Override void add(K key, V data); @Override boolean r... |
### Question:
SparseArray2DImpl implements ISparseArray2D<T> { @Override public List<T> getColumnFor(int col) throws ArrayIndexOutOfBoundsException { if (col>column || col<0){ throw new ArrayIndexOutOfBoundsException(); } ArrayList<T> list = new ArrayList<T>(); IndexNode current = colLinkedList.head; while (current!=nu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.