_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21900 | ArrayQueue.readObject | train | private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
s.defaultReadObject();
// Read in size and allocate array
int size = s.readInt();
allocateElements(size);
head = 0;
tail = size;
// Read in all ... | java | {
"resource": ""
} |
q21901 | GraphAnalysisLoader.resolveType | train | private static TypeElement resolveType(Elements elements, String className, StringBuilder sb,
final int index) {
// We assume '$' should be converted to '.'. So we search for classes with dots first.
sb.setCharAt(index, '.');
int nextIndex = nextDollar(className, sb, index + 1);
TypeElement type ... | java | {
"resource": ""
} |
q21902 | CardinalitySpec.parse | train | public static List<PathElement> parse( String key ) {
if ( key.contains(AT) ) {
return Arrays.<PathElement>asList( new AtPathElement( key ) );
}
else if ( STAR.equals(key) ) {
return Arrays.<PathElement>asList( new StarAllPathElement( key ) );
}
else if ... | java | {
"resource": ""
} |
q21903 | Key.processSpec | train | private static Set<Key> processSpec( boolean parentIsArray, Map<String, Object> spec ) {
// TODO switch to List<Key> and sort before returning
Set<Key> result = new HashSet<>();
for ( String key : spec.keySet() ) {
Object subSpec = spec.get( key );
if ( parentIsArray )... | java | {
"resource": ""
} |
q21904 | Key.applyChildren | train | public void applyChildren( Object defaultee ) {
if ( defaultee == null ) {
throw new TransformException( "Defaultee should never be null when " +
"passed to the applyChildren method." );
}
// This has nothing to do with this being an ArrayKey or MapKey, instead ... | java | {
"resource": ""
} |
q21905 | Chainr.transform | train | @Override
public Object transform( Object input, Map<String, Object> context ) {
return doTransform( transformsList, input, context );
} | java | {
"resource": ""
} |
q21906 | Chainr.transform | train | public Object transform( int from, int to, Object input, Map<String, Object> context ) {
if ( from < 0 || to > transformsList.size() || to <= from ) {
throw new TransformException( "JOLT Chainr : invalid from and to parameters : from=" + from + " to=" + to );
}
return doTransform( ... | java | {
"resource": ""
} |
q21907 | CardinalityTransform.transform | train | @Override
public Object transform( Object input ) {
rootSpec.apply( ROOT_KEY, Optional.of( input ), new WalkedPath(), null, null );
return input;
} | java | {
"resource": ""
} |
q21908 | Objects.toNumber | train | public static Optional<? extends Number> toNumber(Object arg) {
if ( arg instanceof Number ) {
return Optional.of( ( (Number) arg ));
}
else if(arg instanceof String) {
try {
return Optional.of( (Number) Integer.parseInt( (String) arg ) );
}
... | java | {
"resource": ""
} |
q21909 | Objects.toInteger | train | public static Optional<Integer> toInteger(Object arg) {
if ( arg instanceof Number ) {
return Optional.of( ( (Number) arg ).intValue() );
}
else if(arg instanceof String) {
Optional<? extends Number> optional = toNumber( arg );
if ( optional.isPresent() ) {
... | java | {
"resource": ""
} |
q21910 | Objects.toLong | train | public static Optional<Long> toLong(Object arg) {
if ( arg instanceof Number ) {
return Optional.of( ( (Number) arg ).longValue() );
}
else if(arg instanceof String) {
Optional<? extends Number> optional = toNumber( arg );
if ( optional.isPresent() ) {
... | java | {
"resource": ""
} |
q21911 | Objects.toDouble | train | public static Optional<Double> toDouble(Object arg) {
if ( arg instanceof Number ) {
return Optional.of( ( (Number) arg ).doubleValue() );
}
else if(arg instanceof String) {
Optional<? extends Number> optional = toNumber( arg );
if ( optional.isPresent() ) {
... | java | {
"resource": ""
} |
q21912 | Objects.toBoolean | train | public static Optional<Boolean> toBoolean(Object arg) {
if ( arg instanceof Boolean ) {
return Optional.of( (Boolean) arg );
}
else if(arg instanceof String) {
if("true".equalsIgnoreCase( (String)arg )) {
return Optional.of( Boolean.TRUE );
}
... | java | {
"resource": ""
} |
q21913 | Objects.squashNulls | train | public static void squashNulls( Object input ) {
if ( input instanceof List ) {
List inputList = (List) input;
inputList.removeIf( java.util.Objects::isNull );
}
else if ( input instanceof Map ) {
Map<String,Object> inputMap = (Map<String,Object>) input;
... | java | {
"resource": ""
} |
q21914 | Objects.recursivelySquashNulls | train | public static void recursivelySquashNulls(Object input) {
// Makes two passes thru the data.
Objects.squashNulls( input );
if ( input instanceof List ) {
List inputList = (List) input;
inputList.forEach( i -> recursivelySquashNulls( i ) );
}
else if ( in... | java | {
"resource": ""
} |
q21915 | Math.max | train | public static Optional<Number> max( List<Object> args ) {
if(args == null || args.size() == 0) {
return Optional.empty();
}
Integer maxInt = Integer.MIN_VALUE;
Double maxDouble = -(Double.MAX_VALUE);
Long maxLong = Long.MIN_VALUE;
boolean found = false;
... | java | {
"resource": ""
} |
q21916 | Math.min | train | public static Optional<Number> min( List<Object> args ) {
if(args == null || args.size() == 0) {
return Optional.empty();
}
Integer minInt = Integer.MAX_VALUE;
Double minDouble = Double.MAX_VALUE;
Long minLong = Long.MAX_VALUE;
boolean found = false;
... | java | {
"resource": ""
} |
q21917 | Math.abs | train | public static Optional<Number> abs( Object arg ) {
if(arg instanceof Integer) {
return Optional.<Number>of( java.lang.Math.abs( (Integer) arg ));
}
else if(arg instanceof Double) {
return Optional.<Number>of( java.lang.Math.abs( (Double) arg ));
}
else if(... | java | {
"resource": ""
} |
q21918 | Math.avg | train | public static Optional<Double> avg (List<Object> args) {
double sum = 0d;
int count = 0;
for(Object arg: args) {
Optional<? extends Number> numberOptional = Objects.toNumber( arg );
if(numberOptional.isPresent()) {
sum = sum + numberOptional.get().doubleVa... | java | {
"resource": ""
} |
q21919 | CardinalityLeafSpec.applyCardinality | train | @Override
public boolean applyCardinality( String inputKey, Object input, WalkedPath walkedPath, Object parentContainer ) {
MatchedElement thisLevel = getMatch( inputKey, walkedPath );
if ( thisLevel == null ) {
return false;
}
performCardinalityAdjustment( inputKey, inp... | java | {
"resource": ""
} |
q21920 | RemovrLeafSpec.applyToMap | train | @Override
public List<String> applyToMap( Map<String, Object> inputMap ) {
if ( inputMap == null ) {
return null;
}
List<String> keysToBeRemoved = new LinkedList<>();
if ( pathElement instanceof LiteralPathElement ) {
// if we are a literal, check to see if... | java | {
"resource": ""
} |
q21921 | Defaultr.transform | train | @Override
public Object transform( Object input ) {
if ( input == null ) {
// if null, assume HashMap
input = new HashMap();
}
// TODO : Make copy of the defaultee or like shiftr create a new output object
if ( input instanceof List ) {
if ( arr... | java | {
"resource": ""
} |
q21922 | ShiftrCompositeSpec.apply | train | @Override
public boolean apply( String inputKey, Optional<Object> inputOptional, WalkedPath walkedPath, Map<String,Object> output, Map<String, Object> context )
{
MatchedElement thisLevel = pathElement.match( inputKey, walkedPath );
if ( thisLevel == null ) {
return false;
}
... | java | {
"resource": ""
} |
q21923 | ModifierSpec.setData | train | @SuppressWarnings( "unchecked" )
protected static void setData(Object parent, MatchedElement matchedElement, Object value, OpMode opMode) {
if(parent instanceof Map) {
Map source = (Map) parent;
String key = matchedElement.getRawKey();
if(opMode.isApplicable( source, key ... | java | {
"resource": ""
} |
q21924 | JoltCliUtilities.printJsonObject | train | public static boolean printJsonObject( Object output, Boolean uglyPrint, boolean suppressOutput ) {
try {
if ( uglyPrint ) {
printToStandardOut( JsonUtils.toJsonString( output ), suppressOutput );
} else {
printToStandardOut( JsonUtils.toPrettyJsonString( ... | java | {
"resource": ""
} |
q21925 | JoltCliUtilities.readJsonInput | train | public static Object readJsonInput( File file, boolean suppressOutput ) {
Object jsonObject;
if ( file == null ) {
try {
jsonObject = JsonUtils.jsonToMap( System.in );
} catch ( Exception e ) {
printToStandardOut( "Failed to process standard input.... | java | {
"resource": ""
} |
q21926 | SimpleTraversr.handleIntermediateGet | train | @Override
public Optional<DataType> handleIntermediateGet( TraversalStep traversalStep, Object tree, String key, TraversalStep.Operation op ) {
Optional<Object> optSub = traversalStep.get( tree, key );
Object sub = optSub.get();
if ( sub == null && op == TraversalStep.Operation.SET ) {
... | java | {
"resource": ""
} |
q21927 | TransposePathElement.parse | train | public static TransposePathElement parse( String key ) {
if ( key == null || key.length() < 2 ) {
throw new SpecException( "'Transpose Input' key '@', can not be null or of length 1. Offending key : " + key );
}
if ( '@' != key.charAt( 0 ) ) {
throw new SpecException( "... | java | {
"resource": ""
} |
q21928 | TransposePathElement.innerParse | train | private static TransposePathElement innerParse( String originalKey, String meat ) {
char first = meat.charAt( 0 );
if ( Character.isDigit( first ) ) {
// loop until we find a comma or end of string
StringBuilder sb = new StringBuilder().append( first );
for ( int ind... | java | {
"resource": ""
} |
q21929 | TransposePathElement.objectEvaluate | train | public Optional<Object> objectEvaluate( WalkedPath walkedPath ) {
// Grap the data we need from however far up the tree we are supposed to go
PathStep pathStep = walkedPath.elementFromEnd( upLevel );
if ( pathStep == null ) {
return Optional.empty();
}
Object treeRe... | java | {
"resource": ""
} |
q21930 | ShiftrLeafSpec.apply | train | @Override
public boolean apply( String inputKey, Optional<Object> inputOptional, WalkedPath walkedPath, Map<String,Object> output, Map<String, Object> context){
Object input = inputOptional.get();
MatchedElement thisLevel = pathElement.match( inputKey, walkedPath );
if ( thisLevel == null )... | java | {
"resource": ""
} |
q21931 | JoltCli.runJolt | train | protected static boolean runJolt( String[] args ) {
ArgumentParser parser = ArgumentParsers.newArgumentParser( "jolt" );
Subparsers subparsers = parser.addSubparsers().help( "transform: given a Jolt transform spec, runs the specified transforms on the input data.\n" +
"diffy: diff two JS... | java | {
"resource": ""
} |
q21932 | PathEvaluatingTraversal.write | train | public void write( Object data, Map<String, Object> output, WalkedPath walkedPath ) {
List<String> evaledPaths = evaluate( walkedPath );
if ( evaledPaths != null ) {
traversr.set( output, evaledPaths, data );
}
} | java | {
"resource": ""
} |
q21933 | PathEvaluatingTraversal.getCanonicalForm | train | public String getCanonicalForm() {
StringBuilder buf = new StringBuilder();
for ( PathElement pe : elements ) {
buf.append( "." ).append( pe.getCanonicalForm() );
}
return buf.substring( 1 ); // strip the leading "."
} | java | {
"resource": ""
} |
q21934 | JoltUtils.navigateSafe | train | @Deprecated
public static <T> T navigateSafe(final T defaultValue, final Object source, final Object... paths) {
return navigateOrDefault( defaultValue, source, paths );
} | java | {
"resource": ""
} |
q21935 | JoltUtils.isVacantJson | train | public static boolean isVacantJson(final Object obj) {
Collection values = null;
if(obj instanceof Collection) {
if(((Collection) obj).size() == 0) {
return true;
}
values = (Collection) obj;
}
if(obj instanceof Map) {
if(((... | java | {
"resource": ""
} |
q21936 | JoltUtils.listKeyChains | train | public static List<Object[]> listKeyChains(final Object source) {
List<Object[]> keyChainList = new LinkedList<>();
if(source instanceof Map) {
Map sourceMap = (Map) source;
for (Object key: sourceMap.keySet()) {
keyChainList.addAll(listKeyChains(key, sourceMap.... | java | {
"resource": ""
} |
q21937 | JoltUtils.toSimpleTraversrPath | train | public static String toSimpleTraversrPath(Object[] paths) {
StringBuilder pathBuilder = new StringBuilder();
for(int i=0; i<paths.length; i++) {
Object path = paths[i];
if(path instanceof Integer) {
pathBuilder.append("[").append(((Integer) path).intValue()).appen... | java | {
"resource": ""
} |
q21938 | JoltUtils.compactJson | train | @SuppressWarnings("unchecked")
public static Object compactJson(Object source) {
if (source == null) return null;
if (source instanceof List) {
for (Object item : (List) source) {
if (item instanceof List) {
compactJson(item);
}
... | java | {
"resource": ""
} |
q21939 | RemovrCompositeSpec.processChildren | train | private void processChildren( List<RemovrSpec> children, Object subInput ) {
if (subInput != null ) {
if( subInput instanceof List ) {
List<Object> subList = (List<Object>) subInput;
Set<Integer> indiciesToRemove = new HashSet<>();
// build a list ... | java | {
"resource": ""
} |
q21940 | JsonUtils.jsonTo | train | @Deprecated
public static <T> T jsonTo( String json, TypeReference<T> typeRef ) {
return util.stringToType( json, typeRef );
} | java | {
"resource": ""
} |
q21941 | JsonUtils.navigate | train | @SuppressWarnings("unchecked")
@Deprecated
public static <T> T navigate(Object source, Object... paths) throws NullPointerException, UnsupportedOperationException {
Object destination = source;
for (Object path : paths) {
if(destination == null) throw new NullPointerException("Naviga... | java | {
"resource": ""
} |
q21942 | StringTools.isBlank | train | public static boolean isBlank(CharSequence sourceSequence) {
int sequenceLength;
if (sourceSequence == null || (sequenceLength = sourceSequence.length()) == 0) {
return true;
}
for (int i = 0; i < sequenceLength; i++) {
if ((Character.isWhitespace(sourceSequence.c... | java | {
"resource": ""
} |
q21943 | SortCliProcessor.intializeSubCommand | train | @Override
public void intializeSubCommand( Subparsers subparsers ) {
Subparser sortParser = subparsers.addParser( "sort" )
.description( "Jolt CLI Sort Tool. This tool will ingest one JSON input (from a file or standard input) and " +
"perform the Jolt sort operation ... | java | {
"resource": ""
} |
q21944 | RemovrSpec.getNonNegativeIntegerFromLiteralPathElement | train | protected Integer getNonNegativeIntegerFromLiteralPathElement() {
Integer pathElementInt = null;
try {
pathElementInt = Integer.parseInt( pathElement.getRawKey() );
if ( pathElementInt < 0 ) {
return null;
}
}
catch( NumberFormatExce... | java | {
"resource": ""
} |
q21945 | TransformCliProcessor.intializeSubCommand | train | @Override
public void intializeSubCommand( Subparsers subparsers ) {
Subparser transformParser = subparsers.addParser( "transform" )
.description( "Jolt CLI Transform Tool. This tool will ingest a JSON spec file and an JSON input (from a file or " +
"standard input) a... | java | {
"resource": ""
} |
q21946 | TransformCliProcessor.process | train | @Override
public boolean process( Namespace ns ) {
Chainr chainr;
try {
chainr = ChainrFactory.fromFile((File) ns.get("spec"));
} catch ( Exception e ) {
JoltCliUtilities.printToStandardOut( "Chainr failed to load spec file.", SUPPRESS_OUTPUT );
e.printSt... | java | {
"resource": ""
} |
q21947 | ChainrFactory.fromClassPath | train | public static Chainr fromClassPath( String chainrSpecClassPath, ChainrInstantiator chainrInstantiator ) {
Object chainrSpec = JsonUtils.classpathToObject( chainrSpecClassPath );
return getChainr( chainrInstantiator, chainrSpec );
} | java | {
"resource": ""
} |
q21948 | ChainrFactory.fromFileSystem | train | public static Chainr fromFileSystem( String chainrSpecFilePath, ChainrInstantiator chainrInstantiator ) {
Object chainrSpec = JsonUtils.filepathToObject( chainrSpecFilePath );
return getChainr( chainrInstantiator, chainrSpec );
} | java | {
"resource": ""
} |
q21949 | ChainrFactory.fromFile | train | public static Chainr fromFile( File chainrSpecFile, ChainrInstantiator chainrInstantiator ) {
Object chainrSpec;
try {
FileInputStream fileInputStream = new FileInputStream( chainrSpecFile );
chainrSpec = JsonUtils.jsonToObject( fileInputStream );
} catch ( Exception e ) ... | java | {
"resource": ""
} |
q21950 | ChainrFactory.getChainr | train | private static Chainr getChainr( ChainrInstantiator chainrInstantiator, Object chainrSpec ) {
Chainr chainr;
if (chainrInstantiator == null ) {
chainr = Chainr.fromSpec( chainrSpec );
}
else {
chainr = Chainr.fromSpec( chainrSpec, chainrInstantiator );
}
... | java | {
"resource": ""
} |
q21951 | Removr.transform | train | @Override
public Object transform( Object input ) {
// Wrap the input in a map to fool the CompositeSpec to recurse itself.
Map<String,Object> wrappedMap = new HashMap<>();
wrappedMap.put(ROOT_KEY, input);
rootSpec.applyToMap( wrappedMap );
return input;
} | java | {
"resource": ""
} |
q21952 | Shiftr.transform | train | @Override
public Object transform( Object input ) {
Map<String,Object> output = new HashMap<>();
// Create a root LiteralPathElement so that # is useful at the root level
MatchedElement rootLpe = new MatchedElement( ROOT_KEY );
WalkedPath walkedPath = new WalkedPath();
walk... | java | {
"resource": ""
} |
q21953 | PathElementBuilder.buildMatchablePathElement | train | public static MatchablePathElement buildMatchablePathElement(String rawJsonKey) {
PathElement pe = PathElementBuilder.parseSingleKeyLHS( rawJsonKey );
if ( ! ( pe instanceof MatchablePathElement ) ) {
throw new SpecException( "Spec LHS key=" + rawJsonKey + " is not a valid LHS key." );
... | java | {
"resource": ""
} |
q21954 | PathElementBuilder.parseSingleKeyLHS | train | public static PathElement parseSingleKeyLHS( String origKey ) {
String elementKey; // the String to use to actually make Elements
String keyToInspect; // the String to use to determine which kind of Element to create
if ( origKey.contains( "\\" ) ) {
// only do the extra work of... | java | {
"resource": ""
} |
q21955 | PathElementBuilder.parseDotNotationRHS | train | public static List<PathElement> parseDotNotationRHS( String dotNotation ) {
String fixedNotation = fixLeadingBracketSugar( dotNotation );
List<String> pathStrs = parseDotNotation( new LinkedList<String>(), stringIterator( fixedNotation ), dotNotation );
return parseList( pathStrs, dotNotation )... | java | {
"resource": ""
} |
q21956 | DiffyCliProcessor.intializeSubCommand | train | @Override
public void intializeSubCommand( Subparsers subparsers ) {
Subparser diffyParser = subparsers.addParser( "diffy" )
.description( "Jolt CLI Diffy Tool. This tool will ingest two JSON inputs (from files or standard input) and " +
"perform the Jolt Diffy operat... | java | {
"resource": ""
} |
q21957 | DiffyCliProcessor.process | train | @Override
public boolean process( Namespace ns ) {
boolean suppressOutput = ns.getBoolean( "s" );
Object jsonObject1 = JoltCliUtilities.createJsonObjectFromFile( (File) ns.get( "filePath1" ), suppressOutput );
File file = ns.get( "filePath2" );
Object jsonObject2 = JoltCliUtilities.... | java | {
"resource": ""
} |
q21958 | SpecStringParser.parseDotNotation | train | public static List<String> parseDotNotation( List<String> pathStrings, Iterator<Character> iter,
String dotNotationRef ) {
if ( ! iter.hasNext() ) {
return pathStrings;
}
// Leave the forward slashes, unless it precedes a "."
... | java | {
"resource": ""
} |
q21959 | SpecStringParser.removeEscapeChars | train | public static String removeEscapeChars( String origKey ) {
StringBuilder sb = new StringBuilder();
boolean prevWasEscape = false;
for ( char c : origKey.toCharArray() ) {
if ( '\\' == c ) {
if ( prevWasEscape ) {
sb.append( c );
... | java | {
"resource": ""
} |
q21960 | AbstractOutputCollector.sendOutState | train | public void sendOutState(State<Serializable, Serializable> state,
String checkpointId,
boolean spillState,
String location) {
outputter.sendOutState(state, checkpointId, spillState, location);
} | java | {
"resource": ""
} |
q21961 | GeneralTopologyContext.getRawTopology | train | @SuppressWarnings("deprecation")
public StormTopology getRawTopology() {
StormTopology stormTopology = new StormTopology();
Map<String, SpoutSpec> spouts = new HashMap<>();
for (TopologyAPI.Spout spout : this.delegate.getRawTopology().getSpoutsList()) {
spouts.put(spout.getComp().getName(), new Spo... | java | {
"resource": ""
} |
q21962 | StreamExecutor.handleInstanceExecutor | train | public void handleInstanceExecutor() {
for (InstanceExecutor executor : taskIdToInstanceExecutor.values()) {
boolean isLocalSpout = spoutSets.contains(executor.getComponentName());
int taskId = executor.getTaskId();
int items = executor.getStreamOutQueue().size();
for (int i = 0; i < items;... | java | {
"resource": ""
} |
q21963 | StreamExecutor.isSendTuplesToInstance | train | protected boolean isSendTuplesToInstance(List<Integer> taskIds) {
for (Integer taskId : taskIds) {
if (taskIdToInstanceExecutor.get(taskId).getStreamInQueue().remainingCapacity() <= 0) {
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q21964 | StreamExecutor.copyDataOutBound | train | protected void copyDataOutBound(int sourceTaskId,
boolean isLocalSpout,
TopologyAPI.StreamId streamId,
HeronTuples.HeronDataTuple tuple,
List<Integer> outTasks) {
boolean firstIter... | java | {
"resource": ""
} |
q21965 | StreamExecutor.copyControlOutBound | train | protected void copyControlOutBound(int srcTaskId,
HeronTuples.AckTuple control,
boolean isSuccess) {
for (HeronTuples.RootId rootId : control.getRootsList()) {
HeronTuples.AckTuple t =
HeronTuples.AckTuple.newBuilder().
... | java | {
"resource": ""
} |
q21966 | StreamExecutor.processAcksAndFails | train | protected void processAcksAndFails(int srcTaskId, int taskId,
HeronTuples.HeronControlTupleSet controlTupleSet) {
HeronTuples.HeronTupleSet.Builder out = HeronTuples.HeronTupleSet.newBuilder();
out.setSrcTaskId(srcTaskId);
// First go over emits. This makes sure that ne... | java | {
"resource": ""
} |
q21967 | StreamExecutor.drainCache | train | protected void drainCache() {
// Route the tuples to correct places
Map<Integer, List<HeronTuples.HeronTupleSet>> cache = tupleCache.getCache();
if (!isSendTuplesToInstance(new LinkedList<Integer>(cache.keySet()))) {
// Check whether we could send tuples
return;
}
for (Map.Entry<Intege... | java | {
"resource": ""
} |
q21968 | StreamExecutor.sendInBound | train | protected void sendInBound(int taskId, HeronTuples.HeronTupleSet message) {
if (message.hasData()) {
sendMessageToInstance(taskId, message);
}
if (message.hasControl()) {
processAcksAndFails(message.getSrcTaskId(), taskId, message.getControl());
}
} | java | {
"resource": ""
} |
q21969 | StreamExecutor.sendMessageToInstance | train | protected void sendMessageToInstance(int taskId, HeronTuples.HeronTupleSet message) {
taskIdToInstanceExecutor.get(taskId).getStreamInQueue().offer(message);
} | java | {
"resource": ""
} |
q21970 | PackingUtils.getComponentResourceMap | train | public static Map<String, Resource> getComponentResourceMap(
Set<String> components,
Map<String, ByteAmount> componentRamMap,
Map<String, Double> componentCpuMap,
Map<String, ByteAmount> componentDiskMap,
Resource defaultInstanceResource) {
Map<String, Resource> componentResourceMap = ... | java | {
"resource": ""
} |
q21971 | PackingUtils.getComponentsToScale | train | public static Map<String, Integer> getComponentsToScale(Map<String,
Integer> componentChanges, ScalingDirection scalingDirection) {
Map<String, Integer> componentsToScale = new HashMap<String, Integer>();
for (String component : componentChanges.keySet()) {
int parallelismChange = componentChanges.g... | java | {
"resource": ""
} |
q21972 | PackingUtils.computeTotalResourceChange | train | public static Resource computeTotalResourceChange(TopologyAPI.Topology topology,
Map<String, Integer> componentChanges,
Resource defaultInstanceResources,
ScalingDi... | java | {
"resource": ""
} |
q21973 | RuntimeManagerMain.constructHelpOptions | train | private static Options constructHelpOptions() {
Options options = new Options();
Option help = Option.builder("h")
.desc("List all options and their description")
.longOpt("help")
.build();
options.addOption(help);
return options;
} | java | {
"resource": ""
} |
q21974 | RuntimeManagerMain.manageTopology | train | public void manageTopology()
throws TopologyRuntimeManagementException, TMasterException, PackingException {
String topologyName = Context.topologyName(config);
// 1. Do prepare work
// create an instance of state manager
String statemgrClass = Context.stateManagerClass(config);
IStateManager ... | java | {
"resource": ""
} |
q21975 | RuntimeManagerMain.validateExecutionState | train | protected void validateExecutionState(
String topologyName,
ExecutionEnvironment.ExecutionState executionState)
throws TopologyRuntimeManagementException {
String stateCluster = executionState.getCluster();
String stateRole = executionState.getRole();
String stateEnv = executionState.getEn... | java | {
"resource": ""
} |
q21976 | Fields.fieldIndex | train | public int fieldIndex(String field) {
Integer ret = mIndex.get(field);
if (ret == null) {
throw new IllegalArgumentException(field + " does not exist");
}
return ret;
} | java | {
"resource": ""
} |
q21977 | YarnLauncher.getClientConf | train | private Configuration getClientConf() {
return HeronClientConfiguration.CONF
.set(ClientConfiguration.ON_JOB_RUNNING, ReefClientSideHandlers.RunningJobHandler.class)
.set(ClientConfiguration.ON_JOB_FAILED, ReefClientSideHandlers.FailedJobHandler.class)
.set(ClientConfiguration.ON_RUNTIME_ERR... | java | {
"resource": ""
} |
q21978 | NIOLooper.handleSelectedKeys | train | private void handleSelectedKeys() {
Set<SelectionKey> selectedKeys = selector.selectedKeys();
Iterator<SelectionKey> keyIterator = selectedKeys.iterator();
while (keyIterator.hasNext()) {
SelectionKey key = keyIterator.next();
keyIterator.remove();
ISelectHandler callback = (ISelectHandle... | java | {
"resource": ""
} |
q21979 | NIOLooper.registerRead | train | public void registerRead(SelectableChannel channel, ISelectHandler callback)
throws ClosedChannelException {
assert channel.keyFor(selector) == null
|| (channel.keyFor(selector).interestOps() & SelectionKey.OP_CONNECT) == 0;
addInterest(channel, SelectionKey.OP_READ, callback);
} | java | {
"resource": ""
} |
q21980 | NIOLooper.removeInterest | train | private void removeInterest(SelectableChannel channel, int operation) {
SelectionKey key = channel.keyFor(selector);
// Exception would be thrown if key is null or key is inValid
// We do not need double check it ahead
key.interestOps(key.interestOps() & (~operation));
} | java | {
"resource": ""
} |
q21981 | NIOLooper.isInterestRegistered | train | private boolean isInterestRegistered(SelectableChannel channel, int operation) {
SelectionKey key = channel.keyFor(selector);
return key != null && (key.interestOps() & operation) != 0;
} | java | {
"resource": ""
} |
q21982 | LocalFileSystemUploader.uploadPackage | train | @Override
public URI uploadPackage() throws UploaderException {
// first, check if the topology package exists
boolean fileExists = new File(topologyPackageLocation).isFile();
if (!fileExists) {
throw new UploaderException(
String.format("Topology package does not exist at '%s'", topologyP... | java | {
"resource": ""
} |
q21983 | LocalFileSystemUploader.undo | train | @Override
public boolean undo() {
if (destTopologyFile != null) {
LOG.info("Clean uploaded jar");
File file = new File(destTopologyFile);
return file.delete();
}
return true;
} | java | {
"resource": ""
} |
q21984 | AbstractPacking.setPackingConfigs | train | private void setPackingConfigs(Config config) {
List<TopologyAPI.Config.KeyValue> topologyConfig = topology.getTopologyConfig().getKvsList();
// instance default resources are acquired from heron system level config
this.defaultInstanceResources = new Resource(
Context.instanceCpu(config),
... | java | {
"resource": ""
} |
q21985 | GeneralTopologyContextImpl.getComponentStreams | train | public Set<String> getComponentStreams(String componentId) {
if (outputs.containsKey(componentId)) {
Set<String> streams = new HashSet<>();
List<TopologyAPI.OutputStream> olist = outputs.get(componentId);
for (TopologyAPI.OutputStream ostream : olist) {
streams.add(ostream.getStream().getI... | java | {
"resource": ""
} |
q21986 | GeneralTopologyContextImpl.getSources | train | public Map<TopologyAPI.StreamId, TopologyAPI.Grouping> getSources(String componentId) {
if (inputs.containsKey(componentId)) {
Map<TopologyAPI.StreamId, TopologyAPI.Grouping> retVal =
new HashMap<>();
for (TopologyAPI.InputStream istream : inputs.get(componentId)) {
retVal.put(istream.... | java | {
"resource": ""
} |
q21987 | SubmitterMain.submitTopology | train | public void submitTopology() throws TopologySubmissionException {
// build primary runtime config first
Config primaryRuntime = Config.newBuilder()
.putAll(LauncherUtils.getInstance().createPrimaryRuntime(topology)).build();
// call launcher directly here if in dry-run mode
if (Context.dryRun(... | java | {
"resource": ""
} |
q21988 | HeronMasterDriver.scheduleHeronWorkers | train | void scheduleHeronWorkers(PackingPlan topologyPacking) throws ContainerAllocationException {
this.componentRamMap = topologyPacking.getComponentRamDistribution();
scheduleHeronWorkers(topologyPacking.getContainers());
} | java | {
"resource": ""
} |
q21989 | HeronMasterDriver.scheduleHeronWorkers | train | void scheduleHeronWorkers(Set<ContainerPlan> containers) throws ContainerAllocationException {
for (ContainerPlan containerPlan : containers) {
int id = containerPlan.getId();
if (containerPlans.containsKey(containerPlan.getId())) {
throw new ContainerAllocationException("Received duplicate allo... | java | {
"resource": ""
} |
q21990 | HeronMasterDriver.killWorkers | train | public void killWorkers(Set<ContainerPlan> containers) {
for (ContainerPlan container : containers) {
LOG.log(Level.INFO, "Find and kill container for worker {0}", container.getId());
Optional<HeronWorker> worker = multiKeyWorkerMap.lookupByWorkerId(container.getId());
if (worker.isPresent()) {
... | java | {
"resource": ""
} |
q21991 | WindowManager.restoreState | train | @SuppressWarnings("unchecked")
public void restoreState(Map<String, Serializable> state) {
LOG.info("Restoring window manager state");
//restore eviction policy state
if (state.get(EVICTION_STATE_KEY) != null) {
((EvictionPolicy) evictionPolicy).restoreState(state.get(EVICTION_STATE_KEY));
}
... | java | {
"resource": ""
} |
q21992 | WindowManager.getState | train | public Map<String, Serializable> getState() {
Map<String, Serializable> ret = new HashMap<>();
// get potential eviction policy state
if (evictionPolicy.getState() != null) {
ret.put(EVICTION_STATE_KEY, (Serializable) evictionPolicy.getState());
}
// get potential trigger policy state
if (... | java | {
"resource": ""
} |
q21993 | SchedulerUtils.schedulerCommand | train | public static String[] schedulerCommand(
Config config,
Config runtime,
List<Integer> freePorts) {
List<String> commands = new ArrayList<>();
// The java executable should be "{JAVA_HOME}/bin/java"
String javaExecutable = String.format("%s/%s", Context.clusterJavaHome(config), "bin/java")... | java | {
"resource": ""
} |
q21994 | SchedulerUtils.schedulerCommandArgs | train | public static String[] schedulerCommandArgs(
Config config, Config runtime, List<Integer> freePorts) {
// First let us have some safe checks
if (freePorts.size() < PORTS_REQUIRED_FOR_SCHEDULER) {
throw new RuntimeException("Failed to find enough ports for executor");
}
for (int port : freePo... | java | {
"resource": ""
} |
q21995 | SchedulerUtils.executorCommandArgs | train | public static String[] executorCommandArgs(
Config config, Config runtime, Map<ExecutorPort, String> ports, String containerIndex) {
List<String> args = new ArrayList<>();
addExecutorTopologyArgs(args, config, runtime);
addExecutorContainerArgs(args, ports, containerIndex);
return args.toArray(ne... | java | {
"resource": ""
} |
q21996 | SchedulerUtils.addExecutorContainerArgs | train | public static void addExecutorContainerArgs(
List<String> args,
Map<ExecutorPort, String> ports,
String containerIndex) {
String masterPort = ExecutorPort.getPort(ExecutorPort.MASTER_PORT, ports);
String tmasterControllerPort = ExecutorPort.getPort(
ExecutorPort.TMASTER_CONTROLLER_PORT... | java | {
"resource": ""
} |
q21997 | SchedulerUtils.setLibSchedulerLocation | train | public static boolean setLibSchedulerLocation(
Config runtime,
IScheduler scheduler,
boolean isService) {
// Dummy value since there is no scheduler running as service
final String endpoint = "scheduler_as_lib_no_endpoint";
return setSchedulerLocation(runtime, endpoint, scheduler);
} | java | {
"resource": ""
} |
q21998 | SchedulerUtils.setSchedulerLocation | train | public static boolean setSchedulerLocation(
Config runtime,
String schedulerEndpoint,
IScheduler scheduler) {
// Set scheduler location to host:port by default. Overwrite scheduler location if behind DNS.
Scheduler.SchedulerLocation.Builder builder = Scheduler.SchedulerLocation.newBuilder()
... | java | {
"resource": ""
} |
q21999 | SchedulerUtils.constructSchedulerResponse | train | public static Scheduler.SchedulerResponse constructSchedulerResponse(boolean isOK) {
Common.Status.Builder status = Common.Status.newBuilder();
if (isOK) {
status.setStatus(Common.StatusCode.OK);
} else {
status.setStatus(Common.StatusCode.NOTOK);
}
return Scheduler.SchedulerResponse.ne... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.