id_within_dataset
int64 0
69.7k
| snippet
stringlengths 10
23k
| tokens
sequence | nl
stringlengths 15
2.45k
| split_within_dataset
stringclasses 1
value | is_duplicated
bool 2
classes |
---|---|---|---|---|---|
533 | public void exportTree(Tree tree){
Map<String,Integer> idMap=writeNexusHeader(tree);
out.println("\t\t;");
writeNexusTree(tree,treePrefix + 1,true,idMap);
out.println("End;");
}
| [
"public",
"void",
"exportTree",
"(",
"Tree",
"tree",
")",
"{",
"Map",
"<",
"String",
",",
"Integer",
">",
"idMap",
"=",
"writeNexusHeader",
"(",
"tree",
")",
";",
"out",
".",
"println",
"(",
"\"\\t\\t;\"",
")",
";",
"writeNexusTree",
"(",
"tree",
",",
"treePrefix",
"+",
"1",
",",
"true",
",",
"idMap",
")",
";",
"out",
".",
"println",
"(",
"\"End;\"",
")",
";",
"}"
] | export a tree with all its attributes .
| train | false |
534 | ArchivedDesktopComponent addDesktopComponent(final org.simbrain.workspace.gui.GuiComponent<?> dc){
return desktopComponent=new ArchivedDesktopComponent(this,dc);
}
| [
"ArchivedDesktopComponent",
"addDesktopComponent",
"(",
"final",
"org",
".",
"simbrain",
".",
"workspace",
".",
"gui",
".",
"GuiComponent",
"<",
"?",
">",
"dc",
")",
"{",
"return",
"desktopComponent",
"=",
"new",
"ArchivedDesktopComponent",
"(",
"this",
",",
"dc",
")",
";",
"}"
] | adds a desktop component to this component entry .
| train | false |
536 | private void extendColourMap(int highest){
for (int i=m_colorList.size(); i < highest; i++) {
Color pc=m_DefaultColors[i % 10];
int ija=i / 10;
ija*=2;
for (int j=0; j < ija; j++) {
pc=pc.brighter();
}
m_colorList.add(pc);
}
}
| [
"private",
"void",
"extendColourMap",
"(",
"int",
"highest",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"m_colorList",
".",
"size",
"(",
")",
";",
"i",
"<",
"highest",
";",
"i",
"++",
")",
"{",
"Color",
"pc",
"=",
"m_DefaultColors",
"[",
"i",
"%",
"10",
"]",
";",
"int",
"ija",
"=",
"i",
"/",
"10",
";",
"ija",
"*=",
"2",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"ija",
";",
"j",
"++",
")",
"{",
"pc",
"=",
"pc",
".",
"brighter",
"(",
")",
";",
"}",
"m_colorList",
".",
"add",
"(",
"pc",
")",
";",
"}",
"}"
] | add more colours to the colour map
| train | false |
537 | protected void processResult(final Operation operation,final Object result,final Command commandObj) throws BaseCollectionException {
Processor _processor=null;
_processor=operation.getProcessor();
if (null != _processor) {
List<Object> argsList=new ArrayList<Object>();
argsList.add(Util.normalizedReadArgs(_keyMap,commandObj.retreiveArguments()));
argsList.add(commandObj.getCommandIndex());
_processor.setPrerequisiteObjects(argsList);
_processor.processResult(operation,result,_keyMap);
}
else {
_LOGGER.debug("No Processors found to execute. ");
}
}
| [
"protected",
"void",
"processResult",
"(",
"final",
"Operation",
"operation",
",",
"final",
"Object",
"result",
",",
"final",
"Command",
"commandObj",
")",
"throws",
"BaseCollectionException",
"{",
"Processor",
"_processor",
"=",
"null",
";",
"_processor",
"=",
"operation",
".",
"getProcessor",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"_processor",
")",
"{",
"List",
"<",
"Object",
">",
"argsList",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"argsList",
".",
"add",
"(",
"Util",
".",
"normalizedReadArgs",
"(",
"_keyMap",
",",
"commandObj",
".",
"retreiveArguments",
"(",
")",
")",
")",
";",
"argsList",
".",
"add",
"(",
"commandObj",
".",
"getCommandIndex",
"(",
")",
")",
";",
"_processor",
".",
"setPrerequisiteObjects",
"(",
"argsList",
")",
";",
"_processor",
".",
"processResult",
"(",
"operation",
",",
"result",
",",
"_keyMap",
")",
";",
"}",
"else",
"{",
"_LOGGER",
".",
"debug",
"(",
"\"No Processors found to execute. \"",
")",
";",
"}",
"}"
] | move the result to processor . processor can be of type cimprocessor , directormetrics apply different types of decorators above the processed result multiple decorators can be applied on the processed result . multiple processors can be applied on the result got from executor .
| train | false |
539 | public Enumeration enumurateQueue(){
Vector elements=new Vector();
synchronized (LOCK) {
Enumeration e=pending.elements();
while (e.hasMoreElements()) {
elements.addElement(e.nextElement());
}
}
return elements.elements();
}
| [
"public",
"Enumeration",
"enumurateQueue",
"(",
")",
"{",
"Vector",
"elements",
"=",
"new",
"Vector",
"(",
")",
";",
"synchronized",
"(",
"LOCK",
")",
"{",
"Enumeration",
"e",
"=",
"pending",
".",
"elements",
"(",
")",
";",
"while",
"(",
"e",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"elements",
".",
"addElement",
"(",
"e",
".",
"nextElement",
"(",
")",
")",
";",
"}",
"}",
"return",
"elements",
".",
"elements",
"(",
")",
";",
"}"
] | this method returns all pending connectiorequest connections .
| train | false |
540 | public boolean hasPrevious(){
return iterator.hasPrevious();
}
| [
"public",
"boolean",
"hasPrevious",
"(",
")",
"{",
"return",
"iterator",
".",
"hasPrevious",
"(",
")",
";",
"}"
] | similar to getting the iterator and calling hasprevious on it
| train | false |
541 | private void captionPut(int value,String text){
captionMap.put(new Integer(value),text);
}
| [
"private",
"void",
"captionPut",
"(",
"int",
"value",
",",
"String",
"text",
")",
"{",
"captionMap",
".",
"put",
"(",
"new",
"Integer",
"(",
"value",
")",
",",
"text",
")",
";",
"}"
] | caption put . save a mouse caption ( string ) corresponding to a character value . do not include a character number in the caption ; that is added by captionget ( ) .
| train | false |
542 | public void sortLocations(){
if (l_locations.isEmpty()) return;
Collections.sort(l_locations);
PBLocation fst=l_locations.get(0), loc;
if (!fst.isType(StringConst.EMPTY)) {
for (int i=1; i < l_locations.size(); i++) {
loc=l_locations.get(i);
if (loc.isType(StringConst.EMPTY)) {
loc.setType(fst.getType());
break;
}
}
fst.setType(StringConst.EMPTY);
}
}
| [
"public",
"void",
"sortLocations",
"(",
")",
"{",
"if",
"(",
"l_locations",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"Collections",
".",
"sort",
"(",
"l_locations",
")",
";",
"PBLocation",
"fst",
"=",
"l_locations",
".",
"get",
"(",
"0",
")",
",",
"loc",
";",
"if",
"(",
"!",
"fst",
".",
"isType",
"(",
"StringConst",
".",
"EMPTY",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"l_locations",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"loc",
"=",
"l_locations",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"loc",
".",
"isType",
"(",
"StringConst",
".",
"EMPTY",
")",
")",
"{",
"loc",
".",
"setType",
"(",
"fst",
".",
"getType",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"fst",
".",
"setType",
"(",
"StringConst",
".",
"EMPTY",
")",
";",
"}",
"}"
] | sorts the locations of this argument by their terminal ids and heights .
| train | false |
544 | private void persistVolumeNativeID(DbClient dbClient,URI volumeId,String nativeID,Calendar creationTime) throws IOException {
Volume volume=dbClient.queryObject(Volume.class,volumeId);
volume.setCreationTime(creationTime);
volume.setNativeId(nativeID);
volume.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(dbClient,volume));
dbClient.updateObject(volume);
}
| [
"private",
"void",
"persistVolumeNativeID",
"(",
"DbClient",
"dbClient",
",",
"URI",
"volumeId",
",",
"String",
"nativeID",
",",
"Calendar",
"creationTime",
")",
"throws",
"IOException",
"{",
"Volume",
"volume",
"=",
"dbClient",
".",
"queryObject",
"(",
"Volume",
".",
"class",
",",
"volumeId",
")",
";",
"volume",
".",
"setCreationTime",
"(",
"creationTime",
")",
";",
"volume",
".",
"setNativeId",
"(",
"nativeID",
")",
";",
"volume",
".",
"setNativeGuid",
"(",
"NativeGUIDGenerator",
".",
"generateNativeGuid",
"(",
"dbClient",
",",
"volume",
")",
")",
";",
"dbClient",
".",
"updateObject",
"(",
"volume",
")",
";",
"}"
] | this method saves the native id info and creation time for the volume object . the native id is the key identifier for the volume instance on the smi - s side . we need to immediately persist it , so that if when further post - processing of the volume encounters some error , we would be able to have some reference to the volume and we could attempt to delete it .
| train | false |
545 | public Whitelist(){
this.patterns=Collections.emptyList();
this.statusCode=-1;
this.enabled=false;
}
| [
"public",
"Whitelist",
"(",
")",
"{",
"this",
".",
"patterns",
"=",
"Collections",
".",
"emptyList",
"(",
")",
";",
"this",
".",
"statusCode",
"=",
"-",
"1",
";",
"this",
".",
"enabled",
"=",
"false",
";",
"}"
] | creates an empty , disabled whitelist .
| train | false |
546 | protected Node conditionalExprPromotion(Node node,TypeMirror destType){
TypeMirror nodeType=node.getType();
if (types.isSameType(nodeType,destType)) {
return node;
}
if (TypesUtils.isPrimitive(nodeType) && TypesUtils.isBoxedPrimitive(destType)) {
return box(node);
}
boolean isBoxedPrimitive=TypesUtils.isBoxedPrimitive(nodeType);
TypeMirror unboxedNodeType=isBoxedPrimitive ? types.unboxedType(nodeType) : nodeType;
TypeMirror unboxedDestType=TypesUtils.isBoxedPrimitive(destType) ? types.unboxedType(destType) : destType;
if (TypesUtils.isNumeric(unboxedNodeType) && TypesUtils.isNumeric(unboxedDestType)) {
if (unboxedNodeType.getKind() == TypeKind.BYTE && destType.getKind() == TypeKind.SHORT) {
if (isBoxedPrimitive) {
node=unbox(node);
}
return widen(node,destType);
}
TypeKind destKind=destType.getKind();
if (destKind == TypeKind.BYTE || destKind == TypeKind.CHAR || destKind == TypeKind.SHORT) {
if (isBoxedPrimitive) {
return unbox(node);
}
else if (nodeType.getKind() == TypeKind.INT) {
return narrow(node,destType);
}
}
return binaryNumericPromotion(node,destType);
}
if (TypesUtils.isPrimitive(nodeType) && (destType.getKind() == TypeKind.DECLARED || destType.getKind() == TypeKind.UNION || destType.getKind() == TypeKind.INTERSECTION)) {
return box(node);
}
return node;
}
| [
"protected",
"Node",
"conditionalExprPromotion",
"(",
"Node",
"node",
",",
"TypeMirror",
"destType",
")",
"{",
"TypeMirror",
"nodeType",
"=",
"node",
".",
"getType",
"(",
")",
";",
"if",
"(",
"types",
".",
"isSameType",
"(",
"nodeType",
",",
"destType",
")",
")",
"{",
"return",
"node",
";",
"}",
"if",
"(",
"TypesUtils",
".",
"isPrimitive",
"(",
"nodeType",
")",
"&&",
"TypesUtils",
".",
"isBoxedPrimitive",
"(",
"destType",
")",
")",
"{",
"return",
"box",
"(",
"node",
")",
";",
"}",
"boolean",
"isBoxedPrimitive",
"=",
"TypesUtils",
".",
"isBoxedPrimitive",
"(",
"nodeType",
")",
";",
"TypeMirror",
"unboxedNodeType",
"=",
"isBoxedPrimitive",
"?",
"types",
".",
"unboxedType",
"(",
"nodeType",
")",
":",
"nodeType",
";",
"TypeMirror",
"unboxedDestType",
"=",
"TypesUtils",
".",
"isBoxedPrimitive",
"(",
"destType",
")",
"?",
"types",
".",
"unboxedType",
"(",
"destType",
")",
":",
"destType",
";",
"if",
"(",
"TypesUtils",
".",
"isNumeric",
"(",
"unboxedNodeType",
")",
"&&",
"TypesUtils",
".",
"isNumeric",
"(",
"unboxedDestType",
")",
")",
"{",
"if",
"(",
"unboxedNodeType",
".",
"getKind",
"(",
")",
"==",
"TypeKind",
".",
"BYTE",
"&&",
"destType",
".",
"getKind",
"(",
")",
"==",
"TypeKind",
".",
"SHORT",
")",
"{",
"if",
"(",
"isBoxedPrimitive",
")",
"{",
"node",
"=",
"unbox",
"(",
"node",
")",
";",
"}",
"return",
"widen",
"(",
"node",
",",
"destType",
")",
";",
"}",
"TypeKind",
"destKind",
"=",
"destType",
".",
"getKind",
"(",
")",
";",
"if",
"(",
"destKind",
"==",
"TypeKind",
".",
"BYTE",
"||",
"destKind",
"==",
"TypeKind",
".",
"CHAR",
"||",
"destKind",
"==",
"TypeKind",
".",
"SHORT",
")",
"{",
"if",
"(",
"isBoxedPrimitive",
")",
"{",
"return",
"unbox",
"(",
"node",
")",
";",
"}",
"else",
"if",
"(",
"nodeType",
".",
"getKind",
"(",
")",
"==",
"TypeKind",
".",
"INT",
")",
"{",
"return",
"narrow",
"(",
"node",
",",
"destType",
")",
";",
"}",
"}",
"return",
"binaryNumericPromotion",
"(",
"node",
",",
"destType",
")",
";",
"}",
"if",
"(",
"TypesUtils",
".",
"isPrimitive",
"(",
"nodeType",
")",
"&&",
"(",
"destType",
".",
"getKind",
"(",
")",
"==",
"TypeKind",
".",
"DECLARED",
"||",
"destType",
".",
"getKind",
"(",
")",
"==",
"TypeKind",
".",
"UNION",
"||",
"destType",
".",
"getKind",
"(",
")",
"==",
"TypeKind",
".",
"INTERSECTION",
")",
")",
"{",
"return",
"box",
"(",
"node",
")",
";",
"}",
"return",
"node",
";",
"}"
] | convert an operand of a conditional expression to the type of the whole expression .
| train | false |
547 | public void removeConnection(Connection conn){
int removalIndex=findConnection(conn);
if (removalIndex != -1) {
mConnections.remove(removalIndex);
}
}
| [
"public",
"void",
"removeConnection",
"(",
"Connection",
"conn",
")",
"{",
"int",
"removalIndex",
"=",
"findConnection",
"(",
"conn",
")",
";",
"if",
"(",
"removalIndex",
"!=",
"-",
"1",
")",
"{",
"mConnections",
".",
"remove",
"(",
"removalIndex",
")",
";",
"}",
"}"
] | remove the given connection from this list .
| train | false |
548 | public AttrSet read(java.security.Principal principal,Guid guid,String attrNames[]) throws UMSException {
String id=guid.getDn();
ConnectionEntryReader entryReader;
SearchRequest request=LDAPRequests.newSearchRequest(id,SearchScope.BASE_OBJECT,"(objectclass=*)",attrNames);
entryReader=readLDAPEntry(principal,request);
if (entryReader == null) {
throw new AccessRightsException(id);
}
Collection<Attribute> attrs=new ArrayList<>();
try (ConnectionEntryReader reader=entryReader){
while (reader.hasNext()) {
if (reader.isReference()) {
reader.readReference();
}
SearchResultEntry entry=entryReader.readEntry();
for ( Attribute attr : entry.getAllAttributes()) {
attrs.add(attr);
}
}
if (attrs.isEmpty()) {
throw new EntryNotFoundException(i18n.getString(IUMSConstants.ENTRY_NOT_FOUND,new String[]{id}));
}
return new AttrSet(attrs);
}
catch ( IOException e) {
throw new UMSException(i18n.getString(IUMSConstants.UNABLE_TO_READ_ENTRY,new String[]{id}),e);
}
}
| [
"public",
"AttrSet",
"read",
"(",
"java",
".",
"security",
".",
"Principal",
"principal",
",",
"Guid",
"guid",
",",
"String",
"attrNames",
"[",
"]",
")",
"throws",
"UMSException",
"{",
"String",
"id",
"=",
"guid",
".",
"getDn",
"(",
")",
";",
"ConnectionEntryReader",
"entryReader",
";",
"SearchRequest",
"request",
"=",
"LDAPRequests",
".",
"newSearchRequest",
"(",
"id",
",",
"SearchScope",
".",
"BASE_OBJECT",
",",
"\"(objectclass=*)\"",
",",
"attrNames",
")",
";",
"entryReader",
"=",
"readLDAPEntry",
"(",
"principal",
",",
"request",
")",
";",
"if",
"(",
"entryReader",
"==",
"null",
")",
"{",
"throw",
"new",
"AccessRightsException",
"(",
"id",
")",
";",
"}",
"Collection",
"<",
"Attribute",
">",
"attrs",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"try",
"(",
"ConnectionEntryReader",
"reader",
"=",
"entryReader",
")",
"{",
"while",
"(",
"reader",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"reader",
".",
"isReference",
"(",
")",
")",
"{",
"reader",
".",
"readReference",
"(",
")",
";",
"}",
"SearchResultEntry",
"entry",
"=",
"entryReader",
".",
"readEntry",
"(",
")",
";",
"for",
"(",
"Attribute",
"attr",
":",
"entry",
".",
"getAllAttributes",
"(",
")",
")",
"{",
"attrs",
".",
"add",
"(",
"attr",
")",
";",
"}",
"}",
"if",
"(",
"attrs",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"EntryNotFoundException",
"(",
"i18n",
".",
"getString",
"(",
"IUMSConstants",
".",
"ENTRY_NOT_FOUND",
",",
"new",
"String",
"[",
"]",
"{",
"id",
"}",
")",
")",
";",
"}",
"return",
"new",
"AttrSet",
"(",
"attrs",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"UMSException",
"(",
"i18n",
".",
"getString",
"(",
"IUMSConstants",
".",
"UNABLE_TO_READ_ENTRY",
",",
"new",
"String",
"[",
"]",
"{",
"id",
"}",
")",
",",
"e",
")",
";",
"}",
"}"
] | reads an ldap entry .
| train | false |
549 | protected int selectOperator(){
lastUpdate++;
if ((lastUpdate >= UPDATE_WINDOW) || (probabilities == null)) {
lastUpdate=0;
probabilities=getOperatorProbabilities();
}
double rand=PRNG.nextDouble();
double sum=0.0;
for (int i=0; i < operators.size(); i++) {
sum+=probabilities[i];
if (sum > rand) {
return i;
}
}
throw new IllegalStateException();
}
| [
"protected",
"int",
"selectOperator",
"(",
")",
"{",
"lastUpdate",
"++",
";",
"if",
"(",
"(",
"lastUpdate",
">=",
"UPDATE_WINDOW",
")",
"||",
"(",
"probabilities",
"==",
"null",
")",
")",
"{",
"lastUpdate",
"=",
"0",
";",
"probabilities",
"=",
"getOperatorProbabilities",
"(",
")",
";",
"}",
"double",
"rand",
"=",
"PRNG",
".",
"nextDouble",
"(",
")",
";",
"double",
"sum",
"=",
"0.0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"operators",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"sum",
"+=",
"probabilities",
"[",
"i",
"]",
";",
"if",
"(",
"sum",
">",
"rand",
")",
"{",
"return",
"i",
";",
"}",
"}",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"}"
] | returns the index of one of the available operators randomly selected using the probabilities .
| train | false |
550 | private Function<String,TagState> newTagRetriever(TaggingClient client){
return null;
}
| [
"private",
"Function",
"<",
"String",
",",
"TagState",
">",
"newTagRetriever",
"(",
"TaggingClient",
"client",
")",
"{",
"return",
"null",
";",
"}"
] | builds a function to retrieve tags given and endpoint .
| train | false |
551 | public static Map<String,List<DataFileFooter>> createDataFileFooterMappingForSegments(List<TableBlockInfo> tableBlockInfoList) throws IndexBuilderException {
Map<String,List<DataFileFooter>> segmentBlockInfoMapping=new HashMap<>();
for ( TableBlockInfo blockInfo : tableBlockInfoList) {
List<DataFileFooter> eachSegmentBlocks=new ArrayList<>();
String segId=blockInfo.getSegmentId();
DataFileFooter dataFileMatadata=null;
List<DataFileFooter> metadataList=segmentBlockInfoMapping.get(segId);
try {
dataFileMatadata=CarbonUtil.readMetadatFile(blockInfo.getFilePath(),blockInfo.getBlockOffset(),blockInfo.getBlockLength());
}
catch ( CarbonUtilException e) {
throw new IndexBuilderException(e);
}
if (null == metadataList) {
eachSegmentBlocks.add(dataFileMatadata);
segmentBlockInfoMapping.put(segId,eachSegmentBlocks);
}
else {
metadataList.add(dataFileMatadata);
}
}
return segmentBlockInfoMapping;
}
| [
"public",
"static",
"Map",
"<",
"String",
",",
"List",
"<",
"DataFileFooter",
">",
">",
"createDataFileFooterMappingForSegments",
"(",
"List",
"<",
"TableBlockInfo",
">",
"tableBlockInfoList",
")",
"throws",
"IndexBuilderException",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"DataFileFooter",
">",
">",
"segmentBlockInfoMapping",
"=",
"new",
"HashMap",
"<",
">",
"(",
")",
";",
"for",
"(",
"TableBlockInfo",
"blockInfo",
":",
"tableBlockInfoList",
")",
"{",
"List",
"<",
"DataFileFooter",
">",
"eachSegmentBlocks",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"String",
"segId",
"=",
"blockInfo",
".",
"getSegmentId",
"(",
")",
";",
"DataFileFooter",
"dataFileMatadata",
"=",
"null",
";",
"List",
"<",
"DataFileFooter",
">",
"metadataList",
"=",
"segmentBlockInfoMapping",
".",
"get",
"(",
"segId",
")",
";",
"try",
"{",
"dataFileMatadata",
"=",
"CarbonUtil",
".",
"readMetadatFile",
"(",
"blockInfo",
".",
"getFilePath",
"(",
")",
",",
"blockInfo",
".",
"getBlockOffset",
"(",
")",
",",
"blockInfo",
".",
"getBlockLength",
"(",
")",
")",
";",
"}",
"catch",
"(",
"CarbonUtilException",
"e",
")",
"{",
"throw",
"new",
"IndexBuilderException",
"(",
"e",
")",
";",
"}",
"if",
"(",
"null",
"==",
"metadataList",
")",
"{",
"eachSegmentBlocks",
".",
"add",
"(",
"dataFileMatadata",
")",
";",
"segmentBlockInfoMapping",
".",
"put",
"(",
"segId",
",",
"eachSegmentBlocks",
")",
";",
"}",
"else",
"{",
"metadataList",
".",
"add",
"(",
"dataFileMatadata",
")",
";",
"}",
"}",
"return",
"segmentBlockInfoMapping",
";",
"}"
] | to create a mapping of segment id and datafilefooter .
| train | false |
552 | public T add(T e){
T oldE=null;
while (!buffer.offerLast(e)) {
oldE=buffer.poll();
}
return oldE;
}
| [
"public",
"T",
"add",
"(",
"T",
"e",
")",
"{",
"T",
"oldE",
"=",
"null",
";",
"while",
"(",
"!",
"buffer",
".",
"offerLast",
"(",
"e",
")",
")",
"{",
"oldE",
"=",
"buffer",
".",
"poll",
"(",
")",
";",
"}",
"return",
"oldE",
";",
"}"
] | adding an element to the circular buffer implies adding the element to the tail of the deque . in doing so , if the capacity of the buffer has been exhausted , then the deque ' s head should be removed to preserve the circular nature of the buffer . a linkedblockingdeque is used because of its concurrent nature and the fact that adding to tail and removing from head are both o ( 1 ) operations . the removed head is returned to the caller for reuse .
| train | false |
553 | static ArrayList<String> loadImage(File file) throws FileNotFoundException, RuntimeException {
if (file == null) return null;
Scanner sc;
sc=new Scanner(file);
ArrayList<String> rows=new ArrayList<String>();
String s=sc.nextLine();
int len=s.length();
int idx=1;
rows.add(s);
while (sc.hasNext()) {
idx++;
s=sc.nextLine();
if (s.length() != len) {
sc.close();
throw new RuntimeException("Line " + idx + " only has "+ s.length()+ " characters (should have "+ len+ ")");
}
rows.add(s);
}
sc.close();
return rows;
}
| [
"static",
"ArrayList",
"<",
"String",
">",
"loadImage",
"(",
"File",
"file",
")",
"throws",
"FileNotFoundException",
",",
"RuntimeException",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"return",
"null",
";",
"Scanner",
"sc",
";",
"sc",
"=",
"new",
"Scanner",
"(",
"file",
")",
";",
"ArrayList",
"<",
"String",
">",
"rows",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"String",
"s",
"=",
"sc",
".",
"nextLine",
"(",
")",
";",
"int",
"len",
"=",
"s",
".",
"length",
"(",
")",
";",
"int",
"idx",
"=",
"1",
";",
"rows",
".",
"add",
"(",
"s",
")",
";",
"while",
"(",
"sc",
".",
"hasNext",
"(",
")",
")",
"{",
"idx",
"++",
";",
"s",
"=",
"sc",
".",
"nextLine",
"(",
")",
";",
"if",
"(",
"s",
".",
"length",
"(",
")",
"!=",
"len",
")",
"{",
"sc",
".",
"close",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Line \"",
"+",
"idx",
"+",
"\" only has \"",
"+",
"s",
".",
"length",
"(",
")",
"+",
"\" characters (should have \"",
"+",
"len",
"+",
"\")\"",
")",
";",
"}",
"rows",
".",
"add",
"(",
"s",
")",
";",
"}",
"sc",
".",
"close",
"(",
")",
";",
"return",
"rows",
";",
"}"
] | helper function to load up images .
| train | false |
554 | public static String cutpointsToString(double[] cutPoints,boolean[] cutAndLeft){
StringBuffer text=new StringBuffer("");
if (cutPoints == null) {
text.append("\n# no cutpoints found - attribute \n");
}
else {
text.append("\n#* " + cutPoints.length + " cutpoint(s) -\n");
for (int i=0; i < cutPoints.length; i++) {
text.append("# " + cutPoints[i] + " ");
text.append("" + cutAndLeft[i] + "\n");
}
text.append("# end\n");
}
return text.toString();
}
| [
"public",
"static",
"String",
"cutpointsToString",
"(",
"double",
"[",
"]",
"cutPoints",
",",
"boolean",
"[",
"]",
"cutAndLeft",
")",
"{",
"StringBuffer",
"text",
"=",
"new",
"StringBuffer",
"(",
"\"\"",
")",
";",
"if",
"(",
"cutPoints",
"==",
"null",
")",
"{",
"text",
".",
"append",
"(",
"\"\\n# no cutpoints found - attribute \\n\"",
")",
";",
"}",
"else",
"{",
"text",
".",
"append",
"(",
"\"\\n#* \"",
"+",
"cutPoints",
".",
"length",
"+",
"\" cutpoint(s) -\\n\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cutPoints",
".",
"length",
";",
"i",
"++",
")",
"{",
"text",
".",
"append",
"(",
"\"# \"",
"+",
"cutPoints",
"[",
"i",
"]",
"+",
"\" \"",
")",
";",
"text",
".",
"append",
"(",
"\"\"",
"+",
"cutAndLeft",
"[",
"i",
"]",
"+",
"\"\\n\"",
")",
";",
"}",
"text",
".",
"append",
"(",
"\"# end\\n\"",
")",
";",
"}",
"return",
"text",
".",
"toString",
"(",
")",
";",
"}"
] | returns a string representing the cutpoints
| train | false |
555 | private static int capacity(int expectedMaxSize){
return (expectedMaxSize > MAXIMUM_CAPACITY / 3) ? MAXIMUM_CAPACITY : (expectedMaxSize <= 2 * MINIMUM_CAPACITY / 3) ? MINIMUM_CAPACITY : Integer.highestOneBit(expectedMaxSize + (expectedMaxSize << 1));
}
| [
"private",
"static",
"int",
"capacity",
"(",
"int",
"expectedMaxSize",
")",
"{",
"return",
"(",
"expectedMaxSize",
">",
"MAXIMUM_CAPACITY",
"/",
"3",
")",
"?",
"MAXIMUM_CAPACITY",
":",
"(",
"expectedMaxSize",
"<=",
"2",
"*",
"MINIMUM_CAPACITY",
"/",
"3",
")",
"?",
"MINIMUM_CAPACITY",
":",
"Integer",
".",
"highestOneBit",
"(",
"expectedMaxSize",
"+",
"(",
"expectedMaxSize",
"<<",
"1",
")",
")",
";",
"}"
] | returns the appropriate capacity for the given expected maximum size . returns the smallest power of two between minimum_capacity and maximum_capacity , inclusive , that is greater than ( 3 expectedmaxsize ) / 2 , if such a number exists . otherwise returns maximum_capacity .
| train | true |
556 | private void resizeNameColumn(int diff,boolean resizeStatisticPanels){
if (diff != 0) {
if (nameDim == null) {
nameDim=new Dimension(DIMENSION_HEADER_ATTRIBUTE_NAME.width + diff,DIMENSION_HEADER_ATTRIBUTE_NAME.height);
}
else {
int newWidth=nameDim.width + diff;
int minWidth=RESIZE_MARGIN_SHRINK;
int maxWidth=columnHeaderPanel.getWidth() - (DIMENSION_HEADER_MISSINGS.width + DIMENSION_HEADER_TYPE.width + DIMENSION_SEARCH_FIELD.width+ RESIZE_MARGIN_ENLARGE);
if (newWidth > maxWidth) {
newWidth=maxWidth;
}
if (newWidth < minWidth) {
newWidth=minWidth;
}
nameDim=new Dimension(newWidth,nameDim.height);
}
sortingLabelAttName.setMinimumSize(nameDim);
sortingLabelAttName.setPreferredSize(nameDim);
columnHeaderPanel.revalidate();
columnHeaderPanel.repaint();
}
if (resizeStatisticPanels) {
revalidateAttributePanels();
}
}
| [
"private",
"void",
"resizeNameColumn",
"(",
"int",
"diff",
",",
"boolean",
"resizeStatisticPanels",
")",
"{",
"if",
"(",
"diff",
"!=",
"0",
")",
"{",
"if",
"(",
"nameDim",
"==",
"null",
")",
"{",
"nameDim",
"=",
"new",
"Dimension",
"(",
"DIMENSION_HEADER_ATTRIBUTE_NAME",
".",
"width",
"+",
"diff",
",",
"DIMENSION_HEADER_ATTRIBUTE_NAME",
".",
"height",
")",
";",
"}",
"else",
"{",
"int",
"newWidth",
"=",
"nameDim",
".",
"width",
"+",
"diff",
";",
"int",
"minWidth",
"=",
"RESIZE_MARGIN_SHRINK",
";",
"int",
"maxWidth",
"=",
"columnHeaderPanel",
".",
"getWidth",
"(",
")",
"-",
"(",
"DIMENSION_HEADER_MISSINGS",
".",
"width",
"+",
"DIMENSION_HEADER_TYPE",
".",
"width",
"+",
"DIMENSION_SEARCH_FIELD",
".",
"width",
"+",
"RESIZE_MARGIN_ENLARGE",
")",
";",
"if",
"(",
"newWidth",
">",
"maxWidth",
")",
"{",
"newWidth",
"=",
"maxWidth",
";",
"}",
"if",
"(",
"newWidth",
"<",
"minWidth",
")",
"{",
"newWidth",
"=",
"minWidth",
";",
"}",
"nameDim",
"=",
"new",
"Dimension",
"(",
"newWidth",
",",
"nameDim",
".",
"height",
")",
";",
"}",
"sortingLabelAttName",
".",
"setMinimumSize",
"(",
"nameDim",
")",
";",
"sortingLabelAttName",
".",
"setPreferredSize",
"(",
"nameDim",
")",
";",
"columnHeaderPanel",
".",
"revalidate",
"(",
")",
";",
"columnHeaderPanel",
".",
"repaint",
"(",
")",
";",
"}",
"if",
"(",
"resizeStatisticPanels",
")",
"{",
"revalidateAttributePanels",
"(",
")",
";",
"}",
"}"
] | called when resizing event occurs to resize the attribute name column . resizing is restricted to a mininmum and a maximum amount depending on the actual size of the header panel .
| train | false |
557 | public void copyCheckpointsFromInstallationDirectory(String destinationCheckpointsFilename) throws IOException {
if (destinationCheckpointsFilename == null) {
return;
}
File destinationCheckpoints=new File(destinationCheckpointsFilename);
if (!destinationCheckpoints.exists()) {
File directory=new File(".");
String currentWorkingDirectory=directory.getCanonicalPath();
String filePrefix=MultiBitService.getFilePrefix();
String checkpointsFilename=filePrefix + MultiBitService.CHECKPOINTS_SUFFIX;
String sourceCheckpointsFilename=currentWorkingDirectory + File.separator + checkpointsFilename;
File sourceBlockcheckpoints=new File(sourceCheckpointsFilename);
if (sourceBlockcheckpoints.exists() && !destinationCheckpointsFilename.equals(sourceCheckpointsFilename)) {
log.info("Copying checkpoints from '" + sourceCheckpointsFilename + "' to '"+ destinationCheckpointsFilename+ "'");
copyFile(sourceBlockcheckpoints,destinationCheckpoints);
long sourceLength=sourceBlockcheckpoints.length();
long destinationLength=destinationCheckpoints.length();
if (sourceLength != destinationLength) {
String errorText="Checkpoints were not copied to user's application data directory correctly.\nThe source checkpoints '" + sourceCheckpointsFilename + "' is of length "+ sourceLength+ "\nbut the destination checkpoints '"+ destinationCheckpointsFilename+ "' is of length "+ destinationLength;
log.error(errorText);
throw new FileHandlerException(errorText);
}
}
}
}
| [
"public",
"void",
"copyCheckpointsFromInstallationDirectory",
"(",
"String",
"destinationCheckpointsFilename",
")",
"throws",
"IOException",
"{",
"if",
"(",
"destinationCheckpointsFilename",
"==",
"null",
")",
"{",
"return",
";",
"}",
"File",
"destinationCheckpoints",
"=",
"new",
"File",
"(",
"destinationCheckpointsFilename",
")",
";",
"if",
"(",
"!",
"destinationCheckpoints",
".",
"exists",
"(",
")",
")",
"{",
"File",
"directory",
"=",
"new",
"File",
"(",
"\".\"",
")",
";",
"String",
"currentWorkingDirectory",
"=",
"directory",
".",
"getCanonicalPath",
"(",
")",
";",
"String",
"filePrefix",
"=",
"MultiBitService",
".",
"getFilePrefix",
"(",
")",
";",
"String",
"checkpointsFilename",
"=",
"filePrefix",
"+",
"MultiBitService",
".",
"CHECKPOINTS_SUFFIX",
";",
"String",
"sourceCheckpointsFilename",
"=",
"currentWorkingDirectory",
"+",
"File",
".",
"separator",
"+",
"checkpointsFilename",
";",
"File",
"sourceBlockcheckpoints",
"=",
"new",
"File",
"(",
"sourceCheckpointsFilename",
")",
";",
"if",
"(",
"sourceBlockcheckpoints",
".",
"exists",
"(",
")",
"&&",
"!",
"destinationCheckpointsFilename",
".",
"equals",
"(",
"sourceCheckpointsFilename",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Copying checkpoints from '\"",
"+",
"sourceCheckpointsFilename",
"+",
"\"' to '\"",
"+",
"destinationCheckpointsFilename",
"+",
"\"'\"",
")",
";",
"copyFile",
"(",
"sourceBlockcheckpoints",
",",
"destinationCheckpoints",
")",
";",
"long",
"sourceLength",
"=",
"sourceBlockcheckpoints",
".",
"length",
"(",
")",
";",
"long",
"destinationLength",
"=",
"destinationCheckpoints",
".",
"length",
"(",
")",
";",
"if",
"(",
"sourceLength",
"!=",
"destinationLength",
")",
"{",
"String",
"errorText",
"=",
"\"Checkpoints were not copied to user's application data directory correctly.\\nThe source checkpoints '\"",
"+",
"sourceCheckpointsFilename",
"+",
"\"' is of length \"",
"+",
"sourceLength",
"+",
"\"\\nbut the destination checkpoints '\"",
"+",
"destinationCheckpointsFilename",
"+",
"\"' is of length \"",
"+",
"destinationLength",
";",
"log",
".",
"error",
"(",
"errorText",
")",
";",
"throw",
"new",
"FileHandlerException",
"(",
"errorText",
")",
";",
"}",
"}",
"}",
"}"
] | to support multiple users on the same machine , the checkpoints file is installed into the program installation directory and is then copied to the user ' s application data directory when multibit is first used . thus each user has their own copy of the blockchain .
| train | false |
558 | public static boolean isValidBedGraphLine(String line){
String[] bdg=line.split("\t");
if (bdg.length < 4) {
return false;
}
try {
Integer.parseInt(bdg[1]);
Integer.parseInt(bdg[2]);
}
catch ( NumberFormatException e) {
return false;
}
return true;
}
| [
"public",
"static",
"boolean",
"isValidBedGraphLine",
"(",
"String",
"line",
")",
"{",
"String",
"[",
"]",
"bdg",
"=",
"line",
".",
"split",
"(",
"\"\\t\"",
")",
";",
"if",
"(",
"bdg",
".",
"length",
"<",
"4",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"Integer",
".",
"parseInt",
"(",
"bdg",
"[",
"1",
"]",
")",
";",
"Integer",
".",
"parseInt",
"(",
"bdg",
"[",
"2",
"]",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | return true if line looks like a valid bedgraph record
| train | false |
559 | public boolean checkArguments(List arguments){
boolean validArgs=true;
if (arguments != null && arguments.size() > 0) {
String specifiedArgs=formatArgs(arguments);
Debug.log("MigrateHandler: invalid argument(s) specified - " + specifiedArgs);
printConsoleMessage(LOC_HR_MSG_INVALID_OPTION,new Object[]{specifiedArgs});
validArgs=false;
}
return validArgs;
}
| [
"public",
"boolean",
"checkArguments",
"(",
"List",
"arguments",
")",
"{",
"boolean",
"validArgs",
"=",
"true",
";",
"if",
"(",
"arguments",
"!=",
"null",
"&&",
"arguments",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"String",
"specifiedArgs",
"=",
"formatArgs",
"(",
"arguments",
")",
";",
"Debug",
".",
"log",
"(",
"\"MigrateHandler: invalid argument(s) specified - \"",
"+",
"specifiedArgs",
")",
";",
"printConsoleMessage",
"(",
"LOC_HR_MSG_INVALID_OPTION",
",",
"new",
"Object",
"[",
"]",
"{",
"specifiedArgs",
"}",
")",
";",
"validArgs",
"=",
"false",
";",
"}",
"return",
"validArgs",
";",
"}"
] | to make sure that migrate has no additional parameter .
| train | false |
560 | public static final void initZK(ZooKeeper zkc,String selfBrokerUrl){
try {
LocalZooKeeperConnectionService.checkAndCreatePersistNode(zkc,OWNER_INFO_ROOT);
cleanupNamespaceNodes(zkc,OWNER_INFO_ROOT,selfBrokerUrl);
}
catch ( Exception e) {
LOG.error(e.getMessage(),e);
throw new RuntimeException(e);
}
}
| [
"public",
"static",
"final",
"void",
"initZK",
"(",
"ZooKeeper",
"zkc",
",",
"String",
"selfBrokerUrl",
")",
"{",
"try",
"{",
"LocalZooKeeperConnectionService",
".",
"checkAndCreatePersistNode",
"(",
"zkc",
",",
"OWNER_INFO_ROOT",
")",
";",
"cleanupNamespaceNodes",
"(",
"zkc",
",",
"OWNER_INFO_ROOT",
",",
"selfBrokerUrl",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | initzk is only called when the namespaceservice is initialized . so , no need for synchronization .
| train | false |
561 | public E peekForward(){
int nextPos=(pos + 1) % size;
if (nextPos >= data.size() || pos == end) {
return null;
}
return data.get(nextPos);
}
| [
"public",
"E",
"peekForward",
"(",
")",
"{",
"int",
"nextPos",
"=",
"(",
"pos",
"+",
"1",
")",
"%",
"size",
";",
"if",
"(",
"nextPos",
">=",
"data",
".",
"size",
"(",
")",
"||",
"pos",
"==",
"end",
")",
"{",
"return",
"null",
";",
"}",
"return",
"data",
".",
"get",
"(",
"nextPos",
")",
";",
"}"
] | return the next element ( if present ) , without moving the position in the history .
| train | false |
563 | public boolean isCellEditable(EventObject e){
if (e instanceof MouseEvent) {
for (int counter=getColumnCount() - 1; counter >= 0; counter--) {
if (getColumnClass(counter) == TreeTableModel.class) {
MouseEvent me=(MouseEvent)e;
MouseEvent newME=new MouseEvent(tree,me.getID(),me.getWhen(),me.getModifiers(),me.getX() - getCellRect(0,counter,true).x,me.getY(),me.getClickCount(),me.isPopupTrigger());
tree.dispatchEvent(newME);
break;
}
}
}
return false;
}
| [
"public",
"boolean",
"isCellEditable",
"(",
"EventObject",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"MouseEvent",
")",
"{",
"for",
"(",
"int",
"counter",
"=",
"getColumnCount",
"(",
")",
"-",
"1",
";",
"counter",
">=",
"0",
";",
"counter",
"--",
")",
"{",
"if",
"(",
"getColumnClass",
"(",
"counter",
")",
"==",
"TreeTableModel",
".",
"class",
")",
"{",
"MouseEvent",
"me",
"=",
"(",
"MouseEvent",
")",
"e",
";",
"MouseEvent",
"newME",
"=",
"new",
"MouseEvent",
"(",
"tree",
",",
"me",
".",
"getID",
"(",
")",
",",
"me",
".",
"getWhen",
"(",
")",
",",
"me",
".",
"getModifiers",
"(",
")",
",",
"me",
".",
"getX",
"(",
")",
"-",
"getCellRect",
"(",
"0",
",",
"counter",
",",
"true",
")",
".",
"x",
",",
"me",
".",
"getY",
"(",
")",
",",
"me",
".",
"getClickCount",
"(",
")",
",",
"me",
".",
"isPopupTrigger",
"(",
")",
")",
";",
"tree",
".",
"dispatchEvent",
"(",
"newME",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | overridden to return false , and if the event is a mouse event it is forwarded to the tree . < p > the behavior for this is debatable , and should really be offered as a property . by returning false , all keyboard actions are implemented in terms of the table . by returning true , the tree would get a chance to do something with the keyboard events . for the most part this is ok . but for certain keys , such as left / right , the tree will expand / collapse where as the table focus should really move to a different column . page up / down should also be implemented in terms of the table . by returning false this also has the added benefit that clicking outside of the bounds of the tree node , but still in the tree column will select the row , whereas if this returned true that wouldn ' t be the case . < p > by returning false we are also enforcing the policy that the tree will never be editable ( at least by a key sequence ) .
| train | false |
564 | protected static boolean isValidClassname(String classname){
return (classname.indexOf("$") == -1);
}
| [
"protected",
"static",
"boolean",
"isValidClassname",
"(",
"String",
"classname",
")",
"{",
"return",
"(",
"classname",
".",
"indexOf",
"(",
"\"$\"",
")",
"==",
"-",
"1",
")",
";",
"}"
] | checks whether the classname is a valid one , i . e . , from a public class
| train | false |
565 | public static InternalDistributedMember readEssentialData(DataInput in) throws IOException, ClassNotFoundException {
final InternalDistributedMember mbr=new InternalDistributedMember();
mbr._readEssentialData(in);
return mbr;
}
| [
"public",
"static",
"InternalDistributedMember",
"readEssentialData",
"(",
"DataInput",
"in",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"final",
"InternalDistributedMember",
"mbr",
"=",
"new",
"InternalDistributedMember",
"(",
")",
";",
"mbr",
".",
"_readEssentialData",
"(",
"in",
")",
";",
"return",
"mbr",
";",
"}"
] | this writes just the parts of the id that are needed for comparisons and communications
| train | false |
566 | private boolean eval(final int value,final int threshold){
LOGGER.debug("eval: " + value + ", "+ threshold);
if (threshold < 0) {
LOGGER.debug(value < Math.abs(threshold));
return value < Math.abs(threshold);
}
else {
LOGGER.debug(value >= Math.abs(threshold));
return value >= threshold;
}
}
| [
"private",
"boolean",
"eval",
"(",
"final",
"int",
"value",
",",
"final",
"int",
"threshold",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"eval: \"",
"+",
"value",
"+",
"\", \"",
"+",
"threshold",
")",
";",
"if",
"(",
"threshold",
"<",
"0",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"value",
"<",
"Math",
".",
"abs",
"(",
"threshold",
")",
")",
";",
"return",
"value",
"<",
"Math",
".",
"abs",
"(",
"threshold",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"debug",
"(",
"value",
">=",
"Math",
".",
"abs",
"(",
"threshold",
")",
")",
";",
"return",
"value",
">=",
"threshold",
";",
"}",
"}"
] | evaluates the given value against the provided threshold .
| train | false |
568 | public static String hex(float f){
return Integer.toHexString(Float.floatToIntBits(f));
}
| [
"public",
"static",
"String",
"hex",
"(",
"float",
"f",
")",
"{",
"return",
"Integer",
".",
"toHexString",
"(",
"Float",
".",
"floatToIntBits",
"(",
"f",
")",
")",
";",
"}"
] | print a float type ' s internal bit representation in hex
| train | false |
570 | public void testCompositeAttributeCanBeNull() throws Exception {
HtmlPage page=getPage("/faces/composite/defaultAttributeValueExpression_1986.xhtml");
assertElementAttributeEquals(page,"WithValueNull:Input","value","");
assertElementAttributeEquals(page,"WithValueEmpty:Input","value","");
}
| [
"public",
"void",
"testCompositeAttributeCanBeNull",
"(",
")",
"throws",
"Exception",
"{",
"HtmlPage",
"page",
"=",
"getPage",
"(",
"\"/faces/composite/defaultAttributeValueExpression_1986.xhtml\"",
")",
";",
"assertElementAttributeEquals",
"(",
"page",
",",
"\"WithValueNull:Input\"",
",",
"\"value\"",
",",
"\"\"",
")",
";",
"assertElementAttributeEquals",
"(",
"page",
",",
"\"WithValueEmpty:Input\"",
",",
"\"value\"",
",",
"\"\"",
")",
";",
"}"
] | test for issue # 1986
| train | false |
574 | static void importMap(InputStream is,Map<String,String> m) throws IOException, InvalidPreferencesFormatException {
try {
Document doc=loadPrefsDoc(is);
Element xmlMap=doc.getDocumentElement();
String mapVersion=xmlMap.getAttribute("MAP_XML_VERSION");
if (mapVersion.compareTo(MAP_XML_VERSION) > 0) throw new InvalidPreferencesFormatException("Preferences map file format version " + mapVersion + " is not supported. This java installation can read"+ " versions "+ MAP_XML_VERSION+ " or older. You may need"+ " to install a newer version of JDK.");
NodeList entries=xmlMap.getChildNodes();
for (int i=0, numEntries=entries.getLength(); i < numEntries; i++) {
Element entry=(Element)entries.item(i);
m.put(entry.getAttribute("key"),entry.getAttribute("value"));
}
}
catch ( SAXException e) {
throw new InvalidPreferencesFormatException(e);
}
}
| [
"static",
"void",
"importMap",
"(",
"InputStream",
"is",
",",
"Map",
"<",
"String",
",",
"String",
">",
"m",
")",
"throws",
"IOException",
",",
"InvalidPreferencesFormatException",
"{",
"try",
"{",
"Document",
"doc",
"=",
"loadPrefsDoc",
"(",
"is",
")",
";",
"Element",
"xmlMap",
"=",
"doc",
".",
"getDocumentElement",
"(",
")",
";",
"String",
"mapVersion",
"=",
"xmlMap",
".",
"getAttribute",
"(",
"\"MAP_XML_VERSION\"",
")",
";",
"if",
"(",
"mapVersion",
".",
"compareTo",
"(",
"MAP_XML_VERSION",
")",
">",
"0",
")",
"throw",
"new",
"InvalidPreferencesFormatException",
"(",
"\"Preferences map file format version \"",
"+",
"mapVersion",
"+",
"\" is not supported. This java installation can read\"",
"+",
"\" versions \"",
"+",
"MAP_XML_VERSION",
"+",
"\" or older. You may need\"",
"+",
"\" to install a newer version of JDK.\"",
")",
";",
"NodeList",
"entries",
"=",
"xmlMap",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"numEntries",
"=",
"entries",
".",
"getLength",
"(",
")",
";",
"i",
"<",
"numEntries",
";",
"i",
"++",
")",
"{",
"Element",
"entry",
"=",
"(",
"Element",
")",
"entries",
".",
"item",
"(",
"i",
")",
";",
"m",
".",
"put",
"(",
"entry",
".",
"getAttribute",
"(",
"\"key\"",
")",
",",
"entry",
".",
"getAttribute",
"(",
"\"value\"",
")",
")",
";",
"}",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"throw",
"new",
"InvalidPreferencesFormatException",
"(",
"e",
")",
";",
"}",
"}"
] | import map from the specified input stream , which is assumed to contain a map document as per the prefs dtd . this is used as the internal ( undocumented ) format for filesystemprefs . the key - value pairs specified in the xml document will be put into the specified map . ( if this map is empty , it will contain exactly the key - value pairs int the xml - document when this method returns . )
| train | false |
576 | @Deprecated protected void wait(int duration,Runnable callBack){
executor.schedule(callBack,duration,TimeUnit.MILLISECONDS);
}
| [
"@",
"Deprecated",
"protected",
"void",
"wait",
"(",
"int",
"duration",
",",
"Runnable",
"callBack",
")",
"{",
"executor",
".",
"schedule",
"(",
"callBack",
",",
"duration",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}"
] | unsafe method since not interruptible . use at own risk
| train | false |
577 | public synchronized void removeOFChannelHandler(OFChannelHandler h){
connectedChannelHandlers.remove(h);
}
| [
"public",
"synchronized",
"void",
"removeOFChannelHandler",
"(",
"OFChannelHandler",
"h",
")",
"{",
"connectedChannelHandlers",
".",
"remove",
"(",
"h",
")",
";",
"}"
] | remove ofchannelhandler . e . g . , due do disconnect .
| train | false |
578 | public void clearPieSegments(){
mPieSegmentList.clear();
}
| [
"public",
"void",
"clearPieSegments",
"(",
")",
"{",
"mPieSegmentList",
".",
"clear",
"(",
")",
";",
"}"
] | clears the pie segments list .
| train | false |
579 | public void clearCache(){
clearMemoryCache();
clearDiskCache();
}
| [
"public",
"void",
"clearCache",
"(",
")",
"{",
"clearMemoryCache",
"(",
")",
";",
"clearDiskCache",
"(",
")",
";",
"}"
] | clears both the memory and disk cache associated with this imagecache object . note that this includes disk access so this should not be executed on the main / ui thread .
| train | false |
582 | @SuppressWarnings("deprecation") protected boolean isFastClockTimeGE(int hr,int min){
Date now=fastClock.getTime();
nowHours=now.getHours();
nowMinutes=now.getMinutes();
if (((nowHours * 60) + nowMinutes) >= ((hr * 60) + min)) {
return true;
}
return false;
}
| [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"protected",
"boolean",
"isFastClockTimeGE",
"(",
"int",
"hr",
",",
"int",
"min",
")",
"{",
"Date",
"now",
"=",
"fastClock",
".",
"getTime",
"(",
")",
";",
"nowHours",
"=",
"now",
".",
"getHours",
"(",
")",
";",
"nowMinutes",
"=",
"now",
".",
"getMinutes",
"(",
")",
";",
"if",
"(",
"(",
"(",
"nowHours",
"*",
"60",
")",
"+",
"nowMinutes",
")",
">=",
"(",
"(",
"hr",
"*",
"60",
")",
"+",
"min",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | this method tests time assuming both times are on the same day ( ignoring midnight ) it also sets nowminutes and nowhours to the latest fast clock values
| train | false |
585 | public void removeRenamingCallback(OneSheeldRenamingCallback renamingCallback){
if (renamingCallback != null && renamingCallbacks.contains(renamingCallback)) renamingCallbacks.remove(renamingCallback);
}
| [
"public",
"void",
"removeRenamingCallback",
"(",
"OneSheeldRenamingCallback",
"renamingCallback",
")",
"{",
"if",
"(",
"renamingCallback",
"!=",
"null",
"&&",
"renamingCallbacks",
".",
"contains",
"(",
"renamingCallback",
")",
")",
"renamingCallbacks",
".",
"remove",
"(",
"renamingCallback",
")",
";",
"}"
] | remove a renaming callback .
| train | false |
587 | public boolean fillIfLive(long timeout) throws IOException {
StreamImpl source=_source;
byte[] readBuffer=_readBuffer;
if (readBuffer == null || source == null) {
_readOffset=0;
_readLength=0;
return false;
}
if (_readOffset > 0) {
System.arraycopy(readBuffer,_readOffset,readBuffer,0,_readLength - _readOffset);
_readLength-=_readOffset;
_readOffset=0;
}
if (_readLength == readBuffer.length) return true;
int readLength=source.readTimeout(_readBuffer,_readLength,_readBuffer.length - _readLength,timeout);
if (readLength >= 0) {
_readLength+=readLength;
_position+=readLength;
if (_isEnableReadTime) _readTime=CurrentTime.currentTime();
return true;
}
else if (readLength == READ_TIMEOUT) {
return true;
}
else {
return false;
}
}
| [
"public",
"boolean",
"fillIfLive",
"(",
"long",
"timeout",
")",
"throws",
"IOException",
"{",
"StreamImpl",
"source",
"=",
"_source",
";",
"byte",
"[",
"]",
"readBuffer",
"=",
"_readBuffer",
";",
"if",
"(",
"readBuffer",
"==",
"null",
"||",
"source",
"==",
"null",
")",
"{",
"_readOffset",
"=",
"0",
";",
"_readLength",
"=",
"0",
";",
"return",
"false",
";",
"}",
"if",
"(",
"_readOffset",
">",
"0",
")",
"{",
"System",
".",
"arraycopy",
"(",
"readBuffer",
",",
"_readOffset",
",",
"readBuffer",
",",
"0",
",",
"_readLength",
"-",
"_readOffset",
")",
";",
"_readLength",
"-=",
"_readOffset",
";",
"_readOffset",
"=",
"0",
";",
"}",
"if",
"(",
"_readLength",
"==",
"readBuffer",
".",
"length",
")",
"return",
"true",
";",
"int",
"readLength",
"=",
"source",
".",
"readTimeout",
"(",
"_readBuffer",
",",
"_readLength",
",",
"_readBuffer",
".",
"length",
"-",
"_readLength",
",",
"timeout",
")",
";",
"if",
"(",
"readLength",
">=",
"0",
")",
"{",
"_readLength",
"+=",
"readLength",
";",
"_position",
"+=",
"readLength",
";",
"if",
"(",
"_isEnableReadTime",
")",
"_readTime",
"=",
"CurrentTime",
".",
"currentTime",
"(",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"readLength",
"==",
"READ_TIMEOUT",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | fills the buffer with a timed read , testing for the end of file . used for cases like comet to test if the read stream has closed .
| train | true |
588 | public ThreadData(String threadName,String threadState,long cpuTimeInNanoSeconds){
this.threadName=threadName;
this.threadState=threadState;
this.cpuTimeInNanoSeconds=cpuTimeInNanoSeconds;
}
| [
"public",
"ThreadData",
"(",
"String",
"threadName",
",",
"String",
"threadState",
",",
"long",
"cpuTimeInNanoSeconds",
")",
"{",
"this",
".",
"threadName",
"=",
"threadName",
";",
"this",
".",
"threadState",
"=",
"threadState",
";",
"this",
".",
"cpuTimeInNanoSeconds",
"=",
"cpuTimeInNanoSeconds",
";",
"}"
] | instantiates a new thread data .
| train | false |
589 | private List<int[]> prepareExpectedData(){
List<int[]> indexList=new ArrayList<>(2);
int[] sortIndex={0,3,2,4,1};
int[] sortIndexInverted={0,2,4,1,2};
indexList.add(0,sortIndex);
indexList.add(1,sortIndexInverted);
return indexList;
}
| [
"private",
"List",
"<",
"int",
"[",
"]",
">",
"prepareExpectedData",
"(",
")",
"{",
"List",
"<",
"int",
"[",
"]",
">",
"indexList",
"=",
"new",
"ArrayList",
"<",
">",
"(",
"2",
")",
";",
"int",
"[",
"]",
"sortIndex",
"=",
"{",
"0",
",",
"3",
",",
"2",
",",
"4",
",",
"1",
"}",
";",
"int",
"[",
"]",
"sortIndexInverted",
"=",
"{",
"0",
",",
"2",
",",
"4",
",",
"1",
",",
"2",
"}",
";",
"indexList",
".",
"add",
"(",
"0",
",",
"sortIndex",
")",
";",
"indexList",
".",
"add",
"(",
"1",
",",
"sortIndexInverted",
")",
";",
"return",
"indexList",
";",
"}"
] | method return the list of sortindex and sortindexinverted array
| train | false |
590 | protected JFreeChart createChart(CategoryDataset dataset,String title,MUOM uom){
JFreeChart chart=ChartFactory.createBarChart3D(title," "," ",dataset,PlotOrientation.VERTICAL,true,true,false);
if (uom == null || uom.isHour()) {
chart=ChartFactory.createBarChart3D(title,Msg.translate(Env.getCtx(),"Days"),Msg.translate(Env.getCtx(),"Hours"),dataset,PlotOrientation.VERTICAL,true,true,false);
}
else {
chart=ChartFactory.createBarChart3D(title,Msg.translate(Env.getCtx(),"Days"),Msg.translate(Env.getCtx(),"Kilo"),dataset,PlotOrientation.VERTICAL,true,true,false);
}
return chart;
}
| [
"protected",
"JFreeChart",
"createChart",
"(",
"CategoryDataset",
"dataset",
",",
"String",
"title",
",",
"MUOM",
"uom",
")",
"{",
"JFreeChart",
"chart",
"=",
"ChartFactory",
".",
"createBarChart3D",
"(",
"title",
",",
"\" \"",
",",
"\" \"",
",",
"dataset",
",",
"PlotOrientation",
".",
"VERTICAL",
",",
"true",
",",
"true",
",",
"false",
")",
";",
"if",
"(",
"uom",
"==",
"null",
"||",
"uom",
".",
"isHour",
"(",
")",
")",
"{",
"chart",
"=",
"ChartFactory",
".",
"createBarChart3D",
"(",
"title",
",",
"Msg",
".",
"translate",
"(",
"Env",
".",
"getCtx",
"(",
")",
",",
"\"Days\"",
")",
",",
"Msg",
".",
"translate",
"(",
"Env",
".",
"getCtx",
"(",
")",
",",
"\"Hours\"",
")",
",",
"dataset",
",",
"PlotOrientation",
".",
"VERTICAL",
",",
"true",
",",
"true",
",",
"false",
")",
";",
"}",
"else",
"{",
"chart",
"=",
"ChartFactory",
".",
"createBarChart3D",
"(",
"title",
",",
"Msg",
".",
"translate",
"(",
"Env",
".",
"getCtx",
"(",
")",
",",
"\"Days\"",
")",
",",
"Msg",
".",
"translate",
"(",
"Env",
".",
"getCtx",
"(",
")",
",",
"\"Kilo\"",
")",
",",
"dataset",
",",
"PlotOrientation",
".",
"VERTICAL",
",",
"true",
",",
"true",
",",
"false",
")",
";",
"}",
"return",
"chart",
";",
"}"
] | create chart using the data set and uom
| train | false |
591 | private ValueGraphVertex findOrCreateVertex(Register r){
ValueGraphVertex v=getVertex(r);
if (v == null) {
v=new ValueGraphVertex(r);
v.setLabel(r,0);
graph.addGraphNode(v);
nameMap.put(r,v);
}
return v;
}
| [
"private",
"ValueGraphVertex",
"findOrCreateVertex",
"(",
"Register",
"r",
")",
"{",
"ValueGraphVertex",
"v",
"=",
"getVertex",
"(",
"r",
")",
";",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"v",
"=",
"new",
"ValueGraphVertex",
"(",
"r",
")",
";",
"v",
".",
"setLabel",
"(",
"r",
",",
"0",
")",
";",
"graph",
".",
"addGraphNode",
"(",
"v",
")",
";",
"nameMap",
".",
"put",
"(",
"r",
",",
"v",
")",
";",
"}",
"return",
"v",
";",
"}"
] | find or create an valuegraphvertex corresponding to a given register
| train | false |
592 | public RadiusGraphElementAccessor(){
this(Math.sqrt(Double.MAX_VALUE - 1000));
}
| [
"public",
"RadiusGraphElementAccessor",
"(",
")",
"{",
"this",
"(",
"Math",
".",
"sqrt",
"(",
"Double",
".",
"MAX_VALUE",
"-",
"1000",
")",
")",
";",
"}"
] | creates an instance with an effectively infinite default maximum distance .
| train | false |
593 | public void removeLatestUpdate(Password password) throws PageException {
_removeUpdate(password,true);
}
| [
"public",
"void",
"removeLatestUpdate",
"(",
"Password",
"password",
")",
"throws",
"PageException",
"{",
"_removeUpdate",
"(",
"password",
",",
"true",
")",
";",
"}"
] | run update from cfml engine
| train | false |
594 | public void notifyQueryRunning(final BoundEntity song){
synchronized (mRunningQueries) {
mRunningQueries.add(song);
}
}
| [
"public",
"void",
"notifyQueryRunning",
"(",
"final",
"BoundEntity",
"song",
")",
"{",
"synchronized",
"(",
"mRunningQueries",
")",
"{",
"mRunningQueries",
".",
"add",
"(",
"song",
")",
";",
"}",
"}"
] | notifies an async task has started processing the art for the provided entity
| train | false |
595 | public void testBooleanOptions() throws Exception {
DatabaseMetaData dbmd=con.getMetaData();
assertTrue("locatorsUpdateCopy",dbmd.locatorsUpdateCopy());
assertTrue("supportsGetGeneratedKeys",dbmd.supportsGetGeneratedKeys());
assertTrue("supportsMultipleOpenResults",dbmd.supportsMultipleOpenResults());
assertTrue("supportsNamedParameters",dbmd.supportsNamedParameters());
assertFalse("supportsResultSetHoldability",dbmd.supportsResultSetHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT));
assertFalse("supportsResultSetHoldability",dbmd.supportsResultSetHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT));
assertTrue("supportsSavepoints",dbmd.supportsSavepoints());
assertTrue("supportsStatementPooling",dbmd.supportsStatementPooling());
}
| [
"public",
"void",
"testBooleanOptions",
"(",
")",
"throws",
"Exception",
"{",
"DatabaseMetaData",
"dbmd",
"=",
"con",
".",
"getMetaData",
"(",
")",
";",
"assertTrue",
"(",
"\"locatorsUpdateCopy\"",
",",
"dbmd",
".",
"locatorsUpdateCopy",
"(",
")",
")",
";",
"assertTrue",
"(",
"\"supportsGetGeneratedKeys\"",
",",
"dbmd",
".",
"supportsGetGeneratedKeys",
"(",
")",
")",
";",
"assertTrue",
"(",
"\"supportsMultipleOpenResults\"",
",",
"dbmd",
".",
"supportsMultipleOpenResults",
"(",
")",
")",
";",
"assertTrue",
"(",
"\"supportsNamedParameters\"",
",",
"dbmd",
".",
"supportsNamedParameters",
"(",
")",
")",
";",
"assertFalse",
"(",
"\"supportsResultSetHoldability\"",
",",
"dbmd",
".",
"supportsResultSetHoldability",
"(",
"ResultSet",
".",
"HOLD_CURSORS_OVER_COMMIT",
")",
")",
";",
"assertFalse",
"(",
"\"supportsResultSetHoldability\"",
",",
"dbmd",
".",
"supportsResultSetHoldability",
"(",
"ResultSet",
".",
"CLOSE_CURSORS_AT_COMMIT",
")",
")",
";",
"assertTrue",
"(",
"\"supportsSavepoints\"",
",",
"dbmd",
".",
"supportsSavepoints",
"(",
")",
")",
";",
"assertTrue",
"(",
"\"supportsStatementPooling\"",
",",
"dbmd",
".",
"supportsStatementPooling",
"(",
")",
")",
";",
"}"
] | test meta data functions that return boolean values .
| train | false |
596 | private static Properties createProperties1(){
Properties props=new Properties();
props.setProperty(MCAST_PORT,"0");
props.setProperty(LOCATORS,"");
return props;
}
| [
"private",
"static",
"Properties",
"createProperties1",
"(",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"props",
".",
"setProperty",
"(",
"MCAST_PORT",
",",
"\"0\"",
")",
";",
"props",
".",
"setProperty",
"(",
"LOCATORS",
",",
"\"\"",
")",
";",
"return",
"props",
";",
"}"
] | create properties for a loner vm
| train | false |
597 | public void connected(){
final String methodName="connected";
log.fine(CLASS_NAME,methodName,"631");
this.connected=true;
pingSender.start();
}
| [
"public",
"void",
"connected",
"(",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"connected\"",
";",
"log",
".",
"fine",
"(",
"CLASS_NAME",
",",
"methodName",
",",
"\"631\"",
")",
";",
"this",
".",
"connected",
"=",
"true",
";",
"pingSender",
".",
"start",
"(",
")",
";",
"}"
] | called when the client has successfully connected to the broker
| train | false |
598 | protected final boolean tryAcquire(int acquires){
final Thread current=Thread.currentThread();
int c=getState();
if (c == 0) {
if (!hasQueuedPredecessors() && compareAndSetState(0,acquires)) {
setExclusiveOwnerThread(current);
return true;
}
}
else if (current == getExclusiveOwnerThread()) {
int nextc=c + acquires;
if (nextc < 0) throw new Error("Maximum lock count exceeded");
setState(nextc);
return true;
}
return false;
}
| [
"protected",
"final",
"boolean",
"tryAcquire",
"(",
"int",
"acquires",
")",
"{",
"final",
"Thread",
"current",
"=",
"Thread",
".",
"currentThread",
"(",
")",
";",
"int",
"c",
"=",
"getState",
"(",
")",
";",
"if",
"(",
"c",
"==",
"0",
")",
"{",
"if",
"(",
"!",
"hasQueuedPredecessors",
"(",
")",
"&&",
"compareAndSetState",
"(",
"0",
",",
"acquires",
")",
")",
"{",
"setExclusiveOwnerThread",
"(",
"current",
")",
";",
"return",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"current",
"==",
"getExclusiveOwnerThread",
"(",
")",
")",
"{",
"int",
"nextc",
"=",
"c",
"+",
"acquires",
";",
"if",
"(",
"nextc",
"<",
"0",
")",
"throw",
"new",
"Error",
"(",
"\"Maximum lock count exceeded\"",
")",
";",
"setState",
"(",
"nextc",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | fair version of tryacquire . don ' t grant access unless recursive call or no waiters or is first .
| train | false |
601 | private void dispatchOnThirdPartyRegistrationFailed(){
synchronized (this) {
for ( ThirdPartyRegistrationListener listener : mThirdPartyRegistrationListeners) {
try {
listener.onThirdPartyRegistrationFailed();
}
catch ( Exception e) {
Log.e(LOG_TAG,"onSessionsRegistrationFailed " + e.getLocalizedMessage());
}
}
mThirdPartyRegistrationListeners.clear();
}
}
| [
"private",
"void",
"dispatchOnThirdPartyRegistrationFailed",
"(",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"for",
"(",
"ThirdPartyRegistrationListener",
"listener",
":",
"mThirdPartyRegistrationListeners",
")",
"{",
"try",
"{",
"listener",
".",
"onThirdPartyRegistrationFailed",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"e",
"(",
"LOG_TAG",
",",
"\"onSessionsRegistrationFailed \"",
"+",
"e",
".",
"getLocalizedMessage",
"(",
")",
")",
";",
"}",
"}",
"mThirdPartyRegistrationListeners",
".",
"clear",
"(",
")",
";",
"}",
"}"
] | dispatch the onthirdpartyregistrationfailed to the listeners .
| train | false |
602 | public void removeCOSTemplates() throws UMSException {
ArrayList aList=(ArrayList)getCOSTemplates();
for (int i=0; i < aList.size(); i++) {
COSTemplate cosTemplate=(COSTemplate)aList.get(i);
cosTemplate.remove();
}
}
| [
"public",
"void",
"removeCOSTemplates",
"(",
")",
"throws",
"UMSException",
"{",
"ArrayList",
"aList",
"=",
"(",
"ArrayList",
")",
"getCOSTemplates",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"aList",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"COSTemplate",
"cosTemplate",
"=",
"(",
"COSTemplate",
")",
"aList",
".",
"get",
"(",
"i",
")",
";",
"cosTemplate",
".",
"remove",
"(",
")",
";",
"}",
"}"
] | removes all cos templates from this cos definition .
| train | false |
603 | private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
s.defaultWriteObject();
for (Node<K,V> n=findFirst(); n != null; n=n.next) {
V v=n.getValidValue();
if (v != null) {
s.writeObject(n.key);
s.writeObject(v);
}
}
s.writeObject(null);
}
| [
"private",
"void",
"writeObject",
"(",
"java",
".",
"io",
".",
"ObjectOutputStream",
"s",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"s",
".",
"defaultWriteObject",
"(",
")",
";",
"for",
"(",
"Node",
"<",
"K",
",",
"V",
">",
"n",
"=",
"findFirst",
"(",
")",
";",
"n",
"!=",
"null",
";",
"n",
"=",
"n",
".",
"next",
")",
"{",
"V",
"v",
"=",
"n",
".",
"getValidValue",
"(",
")",
";",
"if",
"(",
"v",
"!=",
"null",
")",
"{",
"s",
".",
"writeObject",
"(",
"n",
".",
"key",
")",
";",
"s",
".",
"writeObject",
"(",
"v",
")",
";",
"}",
"}",
"s",
".",
"writeObject",
"(",
"null",
")",
";",
"}"
] | save the state of this map to a stream .
| train | false |
604 | private void collectReferences(final IOperandTreeNode node,final Set<IAddress> references){
for ( final IReference reference : node.getReferences()) {
if (ReferenceType.isCodeReference(reference.getType())) {
references.add(reference.getTarget());
}
}
for ( final IOperandTreeNode child : node.getChildren()) {
collectReferences(child,references);
}
}
| [
"private",
"void",
"collectReferences",
"(",
"final",
"IOperandTreeNode",
"node",
",",
"final",
"Set",
"<",
"IAddress",
">",
"references",
")",
"{",
"for",
"(",
"final",
"IReference",
"reference",
":",
"node",
".",
"getReferences",
"(",
")",
")",
"{",
"if",
"(",
"ReferenceType",
".",
"isCodeReference",
"(",
"reference",
".",
"getType",
"(",
")",
")",
")",
"{",
"references",
".",
"add",
"(",
"reference",
".",
"getTarget",
"(",
")",
")",
";",
"}",
"}",
"for",
"(",
"final",
"IOperandTreeNode",
"child",
":",
"node",
".",
"getChildren",
"(",
")",
")",
"{",
"collectReferences",
"(",
"child",
",",
"references",
")",
";",
"}",
"}"
] | collects all code references from an operand tree node and all of its children .
| train | false |
605 | private ApplyDeletesResult closeSegmentStates(IndexWriter.ReaderPool pool,SegmentState[] segStates,boolean success,long gen) throws IOException {
int numReaders=segStates.length;
Throwable firstExc=null;
List<SegmentCommitInfo> allDeleted=null;
long totDelCount=0;
for (int j=0; j < numReaders; j++) {
SegmentState segState=segStates[j];
if (success) {
totDelCount+=segState.rld.getPendingDeleteCount() - segState.startDelCount;
segState.reader.getSegmentInfo().setBufferedDeletesGen(gen);
int fullDelCount=segState.rld.info.getDelCount() + segState.rld.getPendingDeleteCount();
assert fullDelCount <= segState.rld.info.info.maxDoc();
if (fullDelCount == segState.rld.info.info.maxDoc()) {
if (allDeleted == null) {
allDeleted=new ArrayList<>();
}
allDeleted.add(segState.reader.getSegmentInfo());
}
}
try {
segStates[j].finish(pool);
}
catch ( Throwable th) {
if (firstExc != null) {
firstExc=th;
}
}
}
if (success) {
IOUtils.reThrow(firstExc);
}
if (infoStream.isEnabled("BD")) {
infoStream.message("BD","applyDeletes: " + totDelCount + " new deleted documents");
}
return new ApplyDeletesResult(totDelCount > 0,gen,allDeleted);
}
| [
"private",
"ApplyDeletesResult",
"closeSegmentStates",
"(",
"IndexWriter",
".",
"ReaderPool",
"pool",
",",
"SegmentState",
"[",
"]",
"segStates",
",",
"boolean",
"success",
",",
"long",
"gen",
")",
"throws",
"IOException",
"{",
"int",
"numReaders",
"=",
"segStates",
".",
"length",
";",
"Throwable",
"firstExc",
"=",
"null",
";",
"List",
"<",
"SegmentCommitInfo",
">",
"allDeleted",
"=",
"null",
";",
"long",
"totDelCount",
"=",
"0",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"numReaders",
";",
"j",
"++",
")",
"{",
"SegmentState",
"segState",
"=",
"segStates",
"[",
"j",
"]",
";",
"if",
"(",
"success",
")",
"{",
"totDelCount",
"+=",
"segState",
".",
"rld",
".",
"getPendingDeleteCount",
"(",
")",
"-",
"segState",
".",
"startDelCount",
";",
"segState",
".",
"reader",
".",
"getSegmentInfo",
"(",
")",
".",
"setBufferedDeletesGen",
"(",
"gen",
")",
";",
"int",
"fullDelCount",
"=",
"segState",
".",
"rld",
".",
"info",
".",
"getDelCount",
"(",
")",
"+",
"segState",
".",
"rld",
".",
"getPendingDeleteCount",
"(",
")",
";",
"assert",
"fullDelCount",
"<=",
"segState",
".",
"rld",
".",
"info",
".",
"info",
".",
"maxDoc",
"(",
")",
";",
"if",
"(",
"fullDelCount",
"==",
"segState",
".",
"rld",
".",
"info",
".",
"info",
".",
"maxDoc",
"(",
")",
")",
"{",
"if",
"(",
"allDeleted",
"==",
"null",
")",
"{",
"allDeleted",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"}",
"allDeleted",
".",
"add",
"(",
"segState",
".",
"reader",
".",
"getSegmentInfo",
"(",
")",
")",
";",
"}",
"}",
"try",
"{",
"segStates",
"[",
"j",
"]",
".",
"finish",
"(",
"pool",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"if",
"(",
"firstExc",
"!=",
"null",
")",
"{",
"firstExc",
"=",
"th",
";",
"}",
"}",
"}",
"if",
"(",
"success",
")",
"{",
"IOUtils",
".",
"reThrow",
"(",
"firstExc",
")",
";",
"}",
"if",
"(",
"infoStream",
".",
"isEnabled",
"(",
"\"BD\"",
")",
")",
"{",
"infoStream",
".",
"message",
"(",
"\"BD\"",
",",
"\"applyDeletes: \"",
"+",
"totDelCount",
"+",
"\" new deleted documents\"",
")",
";",
"}",
"return",
"new",
"ApplyDeletesResult",
"(",
"totDelCount",
">",
"0",
",",
"gen",
",",
"allDeleted",
")",
";",
"}"
] | close segment states previously opened with opensegmentstates .
| train | false |
606 | @Override public double[][] rankedAttributes() throws Exception {
if (m_rankedAtts == null || m_rankedSoFar == -1) {
throw new Exception("Search must be performed before attributes " + "can be ranked.");
}
m_doRank=true;
search(m_ASEval,null);
double[][] final_rank=new double[m_rankedSoFar][2];
for (int i=0; i < m_rankedSoFar; i++) {
final_rank[i][0]=m_rankedAtts[i][0];
final_rank[i][1]=m_rankedAtts[i][1];
}
resetOptions();
m_doneRanking=true;
if (m_numToSelect > final_rank.length) {
throw new Exception("More attributes requested than exist in the data");
}
if (m_numToSelect <= 0) {
if (m_threshold == -Double.MAX_VALUE) {
m_calculatedNumToSelect=final_rank.length;
}
else {
determineNumToSelectFromThreshold(final_rank);
}
}
return final_rank;
}
| [
"@",
"Override",
"public",
"double",
"[",
"]",
"[",
"]",
"rankedAttributes",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"m_rankedAtts",
"==",
"null",
"||",
"m_rankedSoFar",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Search must be performed before attributes \"",
"+",
"\"can be ranked.\"",
")",
";",
"}",
"m_doRank",
"=",
"true",
";",
"search",
"(",
"m_ASEval",
",",
"null",
")",
";",
"double",
"[",
"]",
"[",
"]",
"final_rank",
"=",
"new",
"double",
"[",
"m_rankedSoFar",
"]",
"[",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m_rankedSoFar",
";",
"i",
"++",
")",
"{",
"final_rank",
"[",
"i",
"]",
"[",
"0",
"]",
"=",
"m_rankedAtts",
"[",
"i",
"]",
"[",
"0",
"]",
";",
"final_rank",
"[",
"i",
"]",
"[",
"1",
"]",
"=",
"m_rankedAtts",
"[",
"i",
"]",
"[",
"1",
"]",
";",
"}",
"resetOptions",
"(",
")",
";",
"m_doneRanking",
"=",
"true",
";",
"if",
"(",
"m_numToSelect",
">",
"final_rank",
".",
"length",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"More attributes requested than exist in the data\"",
")",
";",
"}",
"if",
"(",
"m_numToSelect",
"<=",
"0",
")",
"{",
"if",
"(",
"m_threshold",
"==",
"-",
"Double",
".",
"MAX_VALUE",
")",
"{",
"m_calculatedNumToSelect",
"=",
"final_rank",
".",
"length",
";",
"}",
"else",
"{",
"determineNumToSelectFromThreshold",
"(",
"final_rank",
")",
";",
"}",
"}",
"return",
"final_rank",
";",
"}"
] | produces a ranked list of attributes . search must have been performed prior to calling this function . search is called by this function to complete the traversal of the the search space . a list of attributes and merits are returned . the attributes a ranked by the order they are added to the subset during a forward selection search . individual merit values reflect the merit associated with adding the corresponding attribute to the subset ; because of this , merit values may initially increase but then decrease as the best subset is " passed by " on the way to the far side of the search space .
| train | false |
607 | private void handleYarnContainerChange(String containerCountAsString) throws IOException, YarnException {
String applicationId=yarnUtil.getRunningAppId(jobName,jobID);
int containerCount=Integer.valueOf(containerCountAsString);
int currentNumTask=getCurrentNumTasks();
int currentNumContainers=getCurrentNumContainers();
if (containerCount == currentNumContainers) {
log.error("The new number of containers is equal to the current number of containers, skipping this message");
return;
}
if (containerCount <= 0) {
log.error("The number of containers cannot be zero or less, skipping this message");
return;
}
if (containerCount > currentNumTask) {
log.error("The number of containers cannot be more than the number of task, skipping this message");
return;
}
log.info("Killing the current job");
yarnUtil.killApplication(applicationId);
coordinatorServerURL=null;
try {
String state=yarnUtil.getApplicationState(applicationId);
Thread.sleep(1000);
int countSleep=1;
while (!state.equals("KILLED")) {
state=yarnUtil.getApplicationState(applicationId);
log.info("Job kill signal sent, but job not killed yet for " + applicationId + ". Sleeping for another 1000ms");
Thread.sleep(1000);
countSleep++;
if (countSleep > 10) {
throw new IllegalStateException("Job has not been killed after 10 attempts.");
}
}
}
catch ( InterruptedException e) {
e.printStackTrace();
}
log.info("Killed the current job successfully");
log.info("Staring the job again");
skipUnreadMessages();
JobRunner jobRunner=new JobRunner(config);
jobRunner.run(false);
}
| [
"private",
"void",
"handleYarnContainerChange",
"(",
"String",
"containerCountAsString",
")",
"throws",
"IOException",
",",
"YarnException",
"{",
"String",
"applicationId",
"=",
"yarnUtil",
".",
"getRunningAppId",
"(",
"jobName",
",",
"jobID",
")",
";",
"int",
"containerCount",
"=",
"Integer",
".",
"valueOf",
"(",
"containerCountAsString",
")",
";",
"int",
"currentNumTask",
"=",
"getCurrentNumTasks",
"(",
")",
";",
"int",
"currentNumContainers",
"=",
"getCurrentNumContainers",
"(",
")",
";",
"if",
"(",
"containerCount",
"==",
"currentNumContainers",
")",
"{",
"log",
".",
"error",
"(",
"\"The new number of containers is equal to the current number of containers, skipping this message\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"containerCount",
"<=",
"0",
")",
"{",
"log",
".",
"error",
"(",
"\"The number of containers cannot be zero or less, skipping this message\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"containerCount",
">",
"currentNumTask",
")",
"{",
"log",
".",
"error",
"(",
"\"The number of containers cannot be more than the number of task, skipping this message\"",
")",
";",
"return",
";",
"}",
"log",
".",
"info",
"(",
"\"Killing the current job\"",
")",
";",
"yarnUtil",
".",
"killApplication",
"(",
"applicationId",
")",
";",
"coordinatorServerURL",
"=",
"null",
";",
"try",
"{",
"String",
"state",
"=",
"yarnUtil",
".",
"getApplicationState",
"(",
"applicationId",
")",
";",
"Thread",
".",
"sleep",
"(",
"1000",
")",
";",
"int",
"countSleep",
"=",
"1",
";",
"while",
"(",
"!",
"state",
".",
"equals",
"(",
"\"KILLED\"",
")",
")",
"{",
"state",
"=",
"yarnUtil",
".",
"getApplicationState",
"(",
"applicationId",
")",
";",
"log",
".",
"info",
"(",
"\"Job kill signal sent, but job not killed yet for \"",
"+",
"applicationId",
"+",
"\". Sleeping for another 1000ms\"",
")",
";",
"Thread",
".",
"sleep",
"(",
"1000",
")",
";",
"countSleep",
"++",
";",
"if",
"(",
"countSleep",
">",
"10",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Job has not been killed after 10 attempts.\"",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"Killed the current job successfully\"",
")",
";",
"log",
".",
"info",
"(",
"\"Staring the job again\"",
")",
";",
"skipUnreadMessages",
"(",
")",
";",
"JobRunner",
"jobRunner",
"=",
"new",
"JobRunner",
"(",
"config",
")",
";",
"jobRunner",
".",
"run",
"(",
"false",
")",
";",
"}"
] | this method handles setconfig messages that want to change the number of containers of a job
| train | false |
609 | public static boolean compareCellValue(Double v1,Double v2,double t,boolean ignoreNaN){
if (v1 == null) v1=0.0;
if (v2 == null) v2=0.0;
if (ignoreNaN && (v1.isNaN() || v1.isInfinite() || v2.isNaN()|| v2.isInfinite())) return true;
if (v1.equals(v2)) return true;
return Math.abs(v1 - v2) <= t;
}
| [
"public",
"static",
"boolean",
"compareCellValue",
"(",
"Double",
"v1",
",",
"Double",
"v2",
",",
"double",
"t",
",",
"boolean",
"ignoreNaN",
")",
"{",
"if",
"(",
"v1",
"==",
"null",
")",
"v1",
"=",
"0.0",
";",
"if",
"(",
"v2",
"==",
"null",
")",
"v2",
"=",
"0.0",
";",
"if",
"(",
"ignoreNaN",
"&&",
"(",
"v1",
".",
"isNaN",
"(",
")",
"||",
"v1",
".",
"isInfinite",
"(",
")",
"||",
"v2",
".",
"isNaN",
"(",
")",
"||",
"v2",
".",
"isInfinite",
"(",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"v1",
".",
"equals",
"(",
"v2",
")",
")",
"return",
"true",
";",
"return",
"Math",
".",
"abs",
"(",
"v1",
"-",
"v2",
")",
"<=",
"t",
";",
"}"
] | compares two double values regarding tolerance t . if one or both of them is null it is converted to 0 . 0 .
| train | false |
611 | public static int ping(String url) throws Exception {
URL u=new URL(url);
HttpURLConnection c=(HttpURLConnection)u.openConnection();
c.connect();
int code=c.getResponseCode();
log.debug("ping=" + url + ", response.code="+ code);
c.disconnect();
return code;
}
| [
"public",
"static",
"int",
"ping",
"(",
"String",
"url",
")",
"throws",
"Exception",
"{",
"URL",
"u",
"=",
"new",
"URL",
"(",
"url",
")",
";",
"HttpURLConnection",
"c",
"=",
"(",
"HttpURLConnection",
")",
"u",
".",
"openConnection",
"(",
")",
";",
"c",
".",
"connect",
"(",
")",
";",
"int",
"code",
"=",
"c",
".",
"getResponseCode",
"(",
")",
";",
"log",
".",
"debug",
"(",
"\"ping=\"",
"+",
"url",
"+",
"\", response.code=\"",
"+",
"code",
")",
";",
"c",
".",
"disconnect",
"(",
")",
";",
"return",
"code",
";",
"}"
] | ping the url , throw exception if occur error
| train | false |
612 | public static int secondaryIdentityHash(Object key){
return secondaryHash(System.identityHashCode(key));
}
| [
"public",
"static",
"int",
"secondaryIdentityHash",
"(",
"Object",
"key",
")",
"{",
"return",
"secondaryHash",
"(",
"System",
".",
"identityHashCode",
"(",
"key",
")",
")",
";",
"}"
] | computes an identity hash code and applies a supplemental hash function to defend against poor quality hash functions . this is critical because identity hash codes are currently implemented as object addresses , which will have been aligned by the underlying memory allocator causing all hash codes to have the same bottom bits .
| train | false |
613 | public Config loadInstalledCodenvyConfig(InstallType installType) throws IOException {
Map<String,String> properties=loadInstalledCodenvyProperties(installType);
return new Config(properties);
}
| [
"public",
"Config",
"loadInstalledCodenvyConfig",
"(",
"InstallType",
"installType",
")",
"throws",
"IOException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
"=",
"loadInstalledCodenvyProperties",
"(",
"installType",
")",
";",
"return",
"new",
"Config",
"(",
"properties",
")",
";",
"}"
] | loads appropriate codenvy config for given installation type .
| train | false |
615 | public GeoDistanceSortBuilder point(double lat,double lon){
points.add(new GeoPoint(lat,lon));
return this;
}
| [
"public",
"GeoDistanceSortBuilder",
"point",
"(",
"double",
"lat",
",",
"double",
"lon",
")",
"{",
"points",
".",
"add",
"(",
"new",
"GeoPoint",
"(",
"lat",
",",
"lon",
")",
")",
";",
"return",
"this",
";",
"}"
] | the point to create the range distance facets from .
| train | false |
617 | protected int indexFirstOf(final String s,final String delims,int offset){
if (s == null || s.length() == 0) {
return -1;
}
if (delims == null || delims.length() == 0) {
return -1;
}
if (offset < 0) {
offset=0;
}
else if (offset > s.length()) {
return -1;
}
int min=s.length();
final char[] delim=delims.toCharArray();
for (int i=0; i < delim.length; i++) {
final int at=s.indexOf(delim[i],offset);
if (at >= 0 && at < min) {
min=at;
}
}
return (min == s.length()) ? -1 : min;
}
| [
"protected",
"int",
"indexFirstOf",
"(",
"final",
"String",
"s",
",",
"final",
"String",
"delims",
",",
"int",
"offset",
")",
"{",
"if",
"(",
"s",
"==",
"null",
"||",
"s",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"delims",
"==",
"null",
"||",
"delims",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"offset",
"<",
"0",
")",
"{",
"offset",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"offset",
">",
"s",
".",
"length",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"int",
"min",
"=",
"s",
".",
"length",
"(",
")",
";",
"final",
"char",
"[",
"]",
"delim",
"=",
"delims",
".",
"toCharArray",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"delim",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"int",
"at",
"=",
"s",
".",
"indexOf",
"(",
"delim",
"[",
"i",
"]",
",",
"offset",
")",
";",
"if",
"(",
"at",
">=",
"0",
"&&",
"at",
"<",
"min",
")",
"{",
"min",
"=",
"at",
";",
"}",
"}",
"return",
"(",
"min",
"==",
"s",
".",
"length",
"(",
")",
")",
"?",
"-",
"1",
":",
"min",
";",
"}"
] | get the earlier index that to be searched for the first occurrance in one of any of the given string .
| train | true |
618 | public NamedColor(String[] namesArray,int r,int g,int b){
super(r,g,b);
names=new HashSet<>();
names.addAll(Arrays.asList(namesArray));
namesLowercase=new HashSet<>();
for ( String thisName : namesArray) {
namesLowercase.add(thisName.toLowerCase());
}
if (namesArray.length == 0) {
name="";
}
else {
name=namesArray[0];
}
}
| [
"public",
"NamedColor",
"(",
"String",
"[",
"]",
"namesArray",
",",
"int",
"r",
",",
"int",
"g",
",",
"int",
"b",
")",
"{",
"super",
"(",
"r",
",",
"g",
",",
"b",
")",
";",
"names",
"=",
"new",
"HashSet",
"<",
">",
"(",
")",
";",
"names",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"namesArray",
")",
")",
";",
"namesLowercase",
"=",
"new",
"HashSet",
"<",
">",
"(",
")",
";",
"for",
"(",
"String",
"thisName",
":",
"namesArray",
")",
"{",
"namesLowercase",
".",
"add",
"(",
"thisName",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"if",
"(",
"namesArray",
".",
"length",
"==",
"0",
")",
"{",
"name",
"=",
"\"\"",
";",
"}",
"else",
"{",
"name",
"=",
"namesArray",
"[",
"0",
"]",
";",
"}",
"}"
] | constructs a new color with the given names and rgb values . the first name in the array is used as the primary name .
| train | false |
619 | public void showContent(){
switchState(CONTENT,null,null,null,null,null,Collections.<Integer>emptyList());
}
| [
"public",
"void",
"showContent",
"(",
")",
"{",
"switchState",
"(",
"CONTENT",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"Collections",
".",
"<",
"Integer",
">",
"emptyList",
"(",
")",
")",
";",
"}"
] | hide all other states and show content
| train | false |
621 | public static boolean isValidTemplate(String template){
template=template.trim();
if (template.indexOf('{') == -1) {
return false;
}
String s=template.trim();
if (s.lastIndexOf('}') != s.length() - 1) {
return false;
}
if (getMethodSignature(template) == null) {
return false;
}
if (getMethodBody(template) == null) {
return false;
}
return true;
}
| [
"public",
"static",
"boolean",
"isValidTemplate",
"(",
"String",
"template",
")",
"{",
"template",
"=",
"template",
".",
"trim",
"(",
")",
";",
"if",
"(",
"template",
".",
"indexOf",
"(",
"'{'",
")",
"==",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"String",
"s",
"=",
"template",
".",
"trim",
"(",
")",
";",
"if",
"(",
"s",
".",
"lastIndexOf",
"(",
"'}'",
")",
"!=",
"s",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"getMethodSignature",
"(",
"template",
")",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"getMethodBody",
"(",
"template",
")",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | validates the provided template .
| train | false |
622 | private double[] prune(Tree tree,NodeRef node,ColourChangeMatrix mm){
double[] p=new double[colourCount];
if (tree.isExternal(node)) {
p[getColour(node)]=1.0;
}
else {
NodeRef leftChild=tree.getChild(node,0);
NodeRef rightChild=tree.getChild(node,1);
double[] left=prune(tree,leftChild,mm);
double[] right=prune(tree,rightChild,mm);
double nodeHeight=tree.getNodeHeight(node);
double leftTime=nodeHeight - tree.getNodeHeight(tree.getChild(node,0));
double rightTime=nodeHeight - tree.getNodeHeight(tree.getChild(node,1));
double maxp=0.0;
for (int i=0; i < colourCount; i++) {
double leftSum=0.0;
double rightSum=0.0;
for (int j=0; j < colourCount; j++) {
leftSum+=mm.forwardTimeEvolution(i,j,leftTime) * left[j];
rightSum+=mm.forwardTimeEvolution(i,j,rightTime) * right[j];
}
p[i]=leftSum * rightSum;
if (p[i] > maxp) {
maxp=p[i];
}
}
if (maxp < 1.0e-100) {
for (int i=0; i < colourCount; i++) {
p[i]*=1.0e+100;
}
logNodePartialsRescaling-=Math.log(1.0e+100);
}
}
nodePartials[node.getNumber()]=p;
if (debugNodePartials) {
prettyPrint("Node " + node.getNumber() + " prune=",p);
}
return p;
}
| [
"private",
"double",
"[",
"]",
"prune",
"(",
"Tree",
"tree",
",",
"NodeRef",
"node",
",",
"ColourChangeMatrix",
"mm",
")",
"{",
"double",
"[",
"]",
"p",
"=",
"new",
"double",
"[",
"colourCount",
"]",
";",
"if",
"(",
"tree",
".",
"isExternal",
"(",
"node",
")",
")",
"{",
"p",
"[",
"getColour",
"(",
"node",
")",
"]",
"=",
"1.0",
";",
"}",
"else",
"{",
"NodeRef",
"leftChild",
"=",
"tree",
".",
"getChild",
"(",
"node",
",",
"0",
")",
";",
"NodeRef",
"rightChild",
"=",
"tree",
".",
"getChild",
"(",
"node",
",",
"1",
")",
";",
"double",
"[",
"]",
"left",
"=",
"prune",
"(",
"tree",
",",
"leftChild",
",",
"mm",
")",
";",
"double",
"[",
"]",
"right",
"=",
"prune",
"(",
"tree",
",",
"rightChild",
",",
"mm",
")",
";",
"double",
"nodeHeight",
"=",
"tree",
".",
"getNodeHeight",
"(",
"node",
")",
";",
"double",
"leftTime",
"=",
"nodeHeight",
"-",
"tree",
".",
"getNodeHeight",
"(",
"tree",
".",
"getChild",
"(",
"node",
",",
"0",
")",
")",
";",
"double",
"rightTime",
"=",
"nodeHeight",
"-",
"tree",
".",
"getNodeHeight",
"(",
"tree",
".",
"getChild",
"(",
"node",
",",
"1",
")",
")",
";",
"double",
"maxp",
"=",
"0.0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"colourCount",
";",
"i",
"++",
")",
"{",
"double",
"leftSum",
"=",
"0.0",
";",
"double",
"rightSum",
"=",
"0.0",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"colourCount",
";",
"j",
"++",
")",
"{",
"leftSum",
"+=",
"mm",
".",
"forwardTimeEvolution",
"(",
"i",
",",
"j",
",",
"leftTime",
")",
"*",
"left",
"[",
"j",
"]",
";",
"rightSum",
"+=",
"mm",
".",
"forwardTimeEvolution",
"(",
"i",
",",
"j",
",",
"rightTime",
")",
"*",
"right",
"[",
"j",
"]",
";",
"}",
"p",
"[",
"i",
"]",
"=",
"leftSum",
"*",
"rightSum",
";",
"if",
"(",
"p",
"[",
"i",
"]",
">",
"maxp",
")",
"{",
"maxp",
"=",
"p",
"[",
"i",
"]",
";",
"}",
"}",
"if",
"(",
"maxp",
"<",
"1.0e-100",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"colourCount",
";",
"i",
"++",
")",
"{",
"p",
"[",
"i",
"]",
"*=",
"1.0e+100",
";",
"}",
"logNodePartialsRescaling",
"-=",
"Math",
".",
"log",
"(",
"1.0e+100",
")",
";",
"}",
"}",
"nodePartials",
"[",
"node",
".",
"getNumber",
"(",
")",
"]",
"=",
"p",
";",
"if",
"(",
"debugNodePartials",
")",
"{",
"prettyPrint",
"(",
"\"Node \"",
"+",
"node",
".",
"getNumber",
"(",
")",
"+",
"\" prune=\"",
",",
"p",
")",
";",
"}",
"return",
"p",
";",
"}"
] | calculate probability of data at descendants from node , given a color at the node ( ' partials ' ) , by a felsenstein - like pruning algorithm . ( first step in the color sampling algorithm ) side effect : updates nodepartials [ ] for this node and all its descendants .
| train | false |
623 | private void awaitOperationsAvailable() throws InterruptedException {
flushLock.lock();
try {
do {
if (writeCache.sizex() <= cacheMaxSize || cacheMaxSize == 0) {
if (cacheFlushFreq > 0) canFlush.await(cacheFlushFreq,TimeUnit.MILLISECONDS);
else canFlush.await();
}
}
while (writeCache.sizex() == 0 && !stopping.get());
}
finally {
flushLock.unlock();
}
}
| [
"private",
"void",
"awaitOperationsAvailable",
"(",
")",
"throws",
"InterruptedException",
"{",
"flushLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"do",
"{",
"if",
"(",
"writeCache",
".",
"sizex",
"(",
")",
"<=",
"cacheMaxSize",
"||",
"cacheMaxSize",
"==",
"0",
")",
"{",
"if",
"(",
"cacheFlushFreq",
">",
"0",
")",
"canFlush",
".",
"await",
"(",
"cacheFlushFreq",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"else",
"canFlush",
".",
"await",
"(",
")",
";",
"}",
"}",
"while",
"(",
"writeCache",
".",
"sizex",
"(",
")",
"==",
"0",
"&&",
"!",
"stopping",
".",
"get",
"(",
")",
")",
";",
"}",
"finally",
"{",
"flushLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | this method awaits until enough elements in map are available or given timeout is over .
| train | false |
624 | public static String sortCommonTokens(String column){
StringBuilder order=new StringBuilder();
order.append(" (CASE ");
for ( String token : commonTokens) {
order.append(" WHEN " + column + " LIKE '"+ token+ " %'"+ " THEN SUBSTR("+ column+ ","+ String.valueOf(token.length() + 2)+ ")"+ " || ', "+ token+ "' ");
}
order.append(" ELSE " + column + " END) ");
return order.toString();
}
| [
"public",
"static",
"String",
"sortCommonTokens",
"(",
"String",
"column",
")",
"{",
"StringBuilder",
"order",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"order",
".",
"append",
"(",
"\" (CASE \"",
")",
";",
"for",
"(",
"String",
"token",
":",
"commonTokens",
")",
"{",
"order",
".",
"append",
"(",
"\" WHEN \"",
"+",
"column",
"+",
"\" LIKE '\"",
"+",
"token",
"+",
"\" %'\"",
"+",
"\" THEN SUBSTR(\"",
"+",
"column",
"+",
"\",\"",
"+",
"String",
".",
"valueOf",
"(",
"token",
".",
"length",
"(",
")",
"+",
"2",
")",
"+",
"\")\"",
"+",
"\" || ', \"",
"+",
"token",
"+",
"\"' \"",
")",
";",
"}",
"order",
".",
"append",
"(",
"\" ELSE \"",
"+",
"column",
"+",
"\" END) \"",
")",
";",
"return",
"order",
".",
"toString",
"(",
")",
";",
"}"
] | given column create sqlite column expression to convert any sorttokens prefixes to suffixes eg . column = " title " , commontokens = { " the " , " an " , " a " } ; ( case when title like ' the % ' then substr ( title , 5 ) | | ' , the ' when title like ' an % ' then substr ( title , 4 ) | | ' , an ' when title like ' a % ' then substr ( title , 3 ) | | ' , a ' else title end ) this allows it to be used in sql where a column expression is expected ( select , order by )
| train | false |
625 | static boolean isFulfilling(int m){
return (m & FULFILLING) != 0;
}
| [
"static",
"boolean",
"isFulfilling",
"(",
"int",
"m",
")",
"{",
"return",
"(",
"m",
"&",
"FULFILLING",
")",
"!=",
"0",
";",
"}"
] | returns true if m has fulfilling bit set .
| train | false |
627 | public String toString(){
StringBuffer buf=new StringBuffer();
if (_isBoot || (_dataChars[0] == SprogMessage.STX)) {
for (int i=0; i < _nDataChars; i++) {
buf.append("<");
buf.append(_dataChars[i]);
buf.append(">");
}
}
else {
for (int i=0; i < _nDataChars; i++) {
buf.append((char)_dataChars[i]);
}
}
return buf.toString();
}
| [
"public",
"String",
"toString",
"(",
")",
"{",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"if",
"(",
"_isBoot",
"||",
"(",
"_dataChars",
"[",
"0",
"]",
"==",
"SprogMessage",
".",
"STX",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"_nDataChars",
";",
"i",
"++",
")",
"{",
"buf",
".",
"append",
"(",
"\"<\"",
")",
";",
"buf",
".",
"append",
"(",
"_dataChars",
"[",
"i",
"]",
")",
";",
"buf",
".",
"append",
"(",
"\">\"",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"_nDataChars",
";",
"i",
"++",
")",
"{",
"buf",
".",
"append",
"(",
"(",
"char",
")",
"_dataChars",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | returns a string representation of this sprogreply
| train | false |
628 | public static boolean isNativeCodeLoaded(){
return NativeCodeLoader.isNativeCodeLoaded();
}
| [
"public",
"static",
"boolean",
"isNativeCodeLoaded",
"(",
")",
"{",
"return",
"NativeCodeLoader",
".",
"isNativeCodeLoaded",
"(",
")",
";",
"}"
] | checks whether the native code has been successfully loaded for the platform .
| train | false |
629 | abstract void replay();
| [
"abstract",
"void",
"replay",
"(",
")",
";"
] | reapplies the change to prefscache .
| train | false |
630 | private boolean readyToConnect(){
long now=System.currentTimeMillis();
long lastExchangeMillis=mStore.getLong(LAST_EXCHANGE_TIME_KEY,-1);
boolean timeSinceLastOK;
if (lastExchangeMillis == -1) {
timeSinceLastOK=true;
}
else if (now - lastExchangeMillis < TIME_BETWEEN_EXCHANGES_MILLIS) {
timeSinceLastOK=false;
}
else {
timeSinceLastOK=true;
}
if (!USE_MINIMAL_LOGGING) {
log.info("Ready to connect? " + (timeSinceLastOK && (getConnecting() == null)));
log.info("Connecting: " + getConnecting());
log.info("timeSinceLastOK: " + timeSinceLastOK);
}
return timeSinceLastOK && (getConnecting() == null);
}
| [
"private",
"boolean",
"readyToConnect",
"(",
")",
"{",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"long",
"lastExchangeMillis",
"=",
"mStore",
".",
"getLong",
"(",
"LAST_EXCHANGE_TIME_KEY",
",",
"-",
"1",
")",
";",
"boolean",
"timeSinceLastOK",
";",
"if",
"(",
"lastExchangeMillis",
"==",
"-",
"1",
")",
"{",
"timeSinceLastOK",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"now",
"-",
"lastExchangeMillis",
"<",
"TIME_BETWEEN_EXCHANGES_MILLIS",
")",
"{",
"timeSinceLastOK",
"=",
"false",
";",
"}",
"else",
"{",
"timeSinceLastOK",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"USE_MINIMAL_LOGGING",
")",
"{",
"log",
".",
"info",
"(",
"\"Ready to connect? \"",
"+",
"(",
"timeSinceLastOK",
"&&",
"(",
"getConnecting",
"(",
")",
"==",
"null",
")",
")",
")",
";",
"log",
".",
"info",
"(",
"\"Connecting: \"",
"+",
"getConnecting",
"(",
")",
")",
";",
"log",
".",
"info",
"(",
"\"timeSinceLastOK: \"",
"+",
"timeSinceLastOK",
")",
";",
"}",
"return",
"timeSinceLastOK",
"&&",
"(",
"getConnecting",
"(",
")",
"==",
"null",
")",
";",
"}"
] | check whether we can connect , according to our policies . currently , checks that we ' ve waited time_between_exchanges_millis milliseconds since the last exchange and that we ' re not already connecting .
| train | false |
631 | public static void putDouble(long addr,double val){
if (UNALIGNED) UNSAFE.putDouble(addr,val);
else putLongByByte(addr,Double.doubleToLongBits(val),BIG_ENDIAN);
}
| [
"public",
"static",
"void",
"putDouble",
"(",
"long",
"addr",
",",
"double",
"val",
")",
"{",
"if",
"(",
"UNALIGNED",
")",
"UNSAFE",
".",
"putDouble",
"(",
"addr",
",",
"val",
")",
";",
"else",
"putLongByByte",
"(",
"addr",
",",
"Double",
".",
"doubleToLongBits",
"(",
"val",
")",
",",
"BIG_ENDIAN",
")",
";",
"}"
] | stores given double value . alignment aware .
| train | false |
633 | public DsnLayerStructure(Collection<DsnLayer> p_layer_list){
arr=new DsnLayer[p_layer_list.size()];
Iterator<DsnLayer> it=p_layer_list.iterator();
for (int i=0; i < arr.length; ++i) {
arr[i]=it.next();
}
}
| [
"public",
"DsnLayerStructure",
"(",
"Collection",
"<",
"DsnLayer",
">",
"p_layer_list",
")",
"{",
"arr",
"=",
"new",
"DsnLayer",
"[",
"p_layer_list",
".",
"size",
"(",
")",
"]",
";",
"Iterator",
"<",
"DsnLayer",
">",
"it",
"=",
"p_layer_list",
".",
"iterator",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"++",
"i",
")",
"{",
"arr",
"[",
"i",
"]",
"=",
"it",
".",
"next",
"(",
")",
";",
"}",
"}"
] | creates a new instance of layerstructure from a list of layers
| train | false |
635 | public double[] incomingInstanceToVectorFieldVals(double[] incoming) throws Exception {
double[] newInst=new double[m_vectorFields.size()];
for (int i=0; i < m_vectorFields.size(); i++) {
FieldRef fr=m_vectorFields.get(i);
newInst[i]=fr.getResult(incoming);
}
return newInst;
}
| [
"public",
"double",
"[",
"]",
"incomingInstanceToVectorFieldVals",
"(",
"double",
"[",
"]",
"incoming",
")",
"throws",
"Exception",
"{",
"double",
"[",
"]",
"newInst",
"=",
"new",
"double",
"[",
"m_vectorFields",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m_vectorFields",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"FieldRef",
"fr",
"=",
"m_vectorFields",
".",
"get",
"(",
"i",
")",
";",
"newInst",
"[",
"i",
"]",
"=",
"fr",
".",
"getResult",
"(",
"incoming",
")",
";",
"}",
"return",
"newInst",
";",
"}"
] | convert an incoming instance to an array of values that corresponds to the fields referenced by the support vectors in the vector dictionary
| train | false |
638 | private static void logNodeProperties(org.osgi.service.prefs.Preferences node){
if (node == null) {
return;
}
try {
LOG.info(node.name() + " properties: ");
logProperties(node);
String[] childrenNames=node.childrenNames();
for (int i=0; i < childrenNames.length; i++) {
logNodeProperties(node.node(childrenNames[i]));
}
}
catch ( Exception t) {
LOG.error("Error while logging preferences.",t);
}
}
| [
"private",
"static",
"void",
"logNodeProperties",
"(",
"org",
".",
"osgi",
".",
"service",
".",
"prefs",
".",
"Preferences",
"node",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"return",
";",
"}",
"try",
"{",
"LOG",
".",
"info",
"(",
"node",
".",
"name",
"(",
")",
"+",
"\" properties: \"",
")",
";",
"logProperties",
"(",
"node",
")",
";",
"String",
"[",
"]",
"childrenNames",
"=",
"node",
".",
"childrenNames",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"childrenNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"logNodeProperties",
"(",
"node",
".",
"node",
"(",
"childrenNames",
"[",
"i",
"]",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"t",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Error while logging preferences.\"",
",",
"t",
")",
";",
"}",
"}"
] | logs all properties of a preference node and calls lognodeproperties for all children of this node .
| train | false |
639 | public static <T extends DataObject>T findInCollection(Collection<T> col,T obj){
if (col != null && obj != null) {
return findInCollection(col,obj.getId());
}
return null;
}
| [
"public",
"static",
"<",
"T",
"extends",
"DataObject",
">",
"T",
"findInCollection",
"(",
"Collection",
"<",
"T",
">",
"col",
",",
"T",
"obj",
")",
"{",
"if",
"(",
"col",
"!=",
"null",
"&&",
"obj",
"!=",
"null",
")",
"{",
"return",
"findInCollection",
"(",
"col",
",",
"obj",
".",
"getId",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | finds an dataobject in a collection by matching it by id
| train | false |
640 | public CodeViewer(){
setHighlightColor(DEFAULT_HIGHLIGHT_COLOR);
initActions();
setLayout(new BorderLayout());
codeHighlightBar=createCodeHighlightBar();
codeHighlightBar.setVisible(false);
add(codeHighlightBar,BorderLayout.NORTH);
codePanel=createCodePanel();
add(codePanel,BorderLayout.CENTER);
applyDefaults();
}
| [
"public",
"CodeViewer",
"(",
")",
"{",
"setHighlightColor",
"(",
"DEFAULT_HIGHLIGHT_COLOR",
")",
";",
"initActions",
"(",
")",
";",
"setLayout",
"(",
"new",
"BorderLayout",
"(",
")",
")",
";",
"codeHighlightBar",
"=",
"createCodeHighlightBar",
"(",
")",
";",
"codeHighlightBar",
".",
"setVisible",
"(",
"false",
")",
";",
"add",
"(",
"codeHighlightBar",
",",
"BorderLayout",
".",
"NORTH",
")",
";",
"codePanel",
"=",
"createCodePanel",
"(",
")",
";",
"add",
"(",
"codePanel",
",",
"BorderLayout",
".",
"CENTER",
")",
";",
"applyDefaults",
"(",
")",
";",
"}"
] | creates a new instance of codeviewer
| train | false |
641 | @Override public boolean equals(Object obj){
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
IfdStructure other=(IfdStructure)obj;
if (count != other.count) return false;
if (offsetValue != other.offsetValue) return false;
if (tag != other.tag) return false;
if (type != other.type) return false;
return true;
}
| [
"@",
"Override",
"public",
"boolean",
"equals",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"this",
"==",
"obj",
")",
"return",
"true",
";",
"if",
"(",
"obj",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"getClass",
"(",
")",
"!=",
"obj",
".",
"getClass",
"(",
")",
")",
"return",
"false",
";",
"IfdStructure",
"other",
"=",
"(",
"IfdStructure",
")",
"obj",
";",
"if",
"(",
"count",
"!=",
"other",
".",
"count",
")",
"return",
"false",
";",
"if",
"(",
"offsetValue",
"!=",
"other",
".",
"offsetValue",
")",
"return",
"false",
";",
"if",
"(",
"tag",
"!=",
"other",
".",
"tag",
")",
"return",
"false",
";",
"if",
"(",
"type",
"!=",
"other",
".",
"type",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | returns whether this object is equal to the given object .
| train | false |
642 | public boolean isAbsoluteURI(){
return (_scheme != null);
}
| [
"public",
"boolean",
"isAbsoluteURI",
"(",
")",
"{",
"return",
"(",
"_scheme",
"!=",
"null",
")",
";",
"}"
] | tell whether or not this uri is absolute .
| train | false |
643 | public synchronized boolean isConsumer(ImageConsumer ic){
return ics.contains(ic);
}
| [
"public",
"synchronized",
"boolean",
"isConsumer",
"(",
"ImageConsumer",
"ic",
")",
"{",
"return",
"ics",
".",
"contains",
"(",
"ic",
")",
";",
"}"
] | determine if an imageconsumer is on the list of consumers currently interested in data for this image .
| train | false |
644 | public boolean isMandatory(){
return flags.contains(DiagnosticFlag.MANDATORY);
}
| [
"public",
"boolean",
"isMandatory",
"(",
")",
"{",
"return",
"flags",
".",
"contains",
"(",
"DiagnosticFlag",
".",
"MANDATORY",
")",
";",
"}"
] | check whether or not this diagnostic is required to be shown .
| train | false |
645 | public <T extends Number>double[] next(Collection<T> values,int numForecasts){
if (values.size() < period * 2) {
throw new AggregationExecutionException("Holt-Winters aggregation requires at least (2 * period == 2 * " + period + " == "+ (2 * period)+ ") data-points to function. Only ["+ values.size()+ "] were provided.");
}
double s=0;
double last_s;
double b=0;
double last_b=0;
double[] seasonal=new double[values.size()];
int counter=0;
double[] vs=new double[values.size()];
for ( T v : values) {
vs[counter]=v.doubleValue() + padding;
counter+=1;
}
for (int i=0; i < period; i++) {
s+=vs[i];
b+=(vs[i + period] - vs[i]) / period;
}
s/=(double)period;
b/=(double)period;
last_s=s;
if (Double.compare(s,0.0) == 0 || Double.compare(s,-0.0) == 0) {
Arrays.fill(seasonal,0.0);
}
else {
for (int i=0; i < period; i++) {
seasonal[i]=vs[i] / s;
}
}
for (int i=period; i < vs.length; i++) {
if (seasonalityType.equals(SeasonalityType.MULTIPLICATIVE)) {
s=alpha * (vs[i] / seasonal[i - period]) + (1.0d - alpha) * (last_s + last_b);
}
else {
s=alpha * (vs[i] - seasonal[i - period]) + (1.0d - alpha) * (last_s + last_b);
}
b=beta * (s - last_s) + (1 - beta) * last_b;
if (seasonalityType.equals(SeasonalityType.MULTIPLICATIVE)) {
seasonal[i]=gamma * (vs[i] / (last_s + last_b)) + (1 - gamma) * seasonal[i - period];
}
else {
seasonal[i]=gamma * (vs[i] - (last_s - last_b)) + (1 - gamma) * seasonal[i - period];
}
last_s=s;
last_b=b;
}
double[] forecastValues=new double[numForecasts];
for (int i=1; i <= numForecasts; i++) {
int idx=values.size() - period + ((i - 1) % period);
if (seasonalityType.equals(SeasonalityType.MULTIPLICATIVE)) {
forecastValues[i - 1]=(s + (i * b)) * seasonal[idx];
}
else {
forecastValues[i - 1]=s + (i * b) + seasonal[idx];
}
}
return forecastValues;
}
| [
"public",
"<",
"T",
"extends",
"Number",
">",
"double",
"[",
"]",
"next",
"(",
"Collection",
"<",
"T",
">",
"values",
",",
"int",
"numForecasts",
")",
"{",
"if",
"(",
"values",
".",
"size",
"(",
")",
"<",
"period",
"*",
"2",
")",
"{",
"throw",
"new",
"AggregationExecutionException",
"(",
"\"Holt-Winters aggregation requires at least (2 * period == 2 * \"",
"+",
"period",
"+",
"\" == \"",
"+",
"(",
"2",
"*",
"period",
")",
"+",
"\") data-points to function. Only [\"",
"+",
"values",
".",
"size",
"(",
")",
"+",
"\"] were provided.\"",
")",
";",
"}",
"double",
"s",
"=",
"0",
";",
"double",
"last_s",
";",
"double",
"b",
"=",
"0",
";",
"double",
"last_b",
"=",
"0",
";",
"double",
"[",
"]",
"seasonal",
"=",
"new",
"double",
"[",
"values",
".",
"size",
"(",
")",
"]",
";",
"int",
"counter",
"=",
"0",
";",
"double",
"[",
"]",
"vs",
"=",
"new",
"double",
"[",
"values",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"T",
"v",
":",
"values",
")",
"{",
"vs",
"[",
"counter",
"]",
"=",
"v",
".",
"doubleValue",
"(",
")",
"+",
"padding",
";",
"counter",
"+=",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"period",
";",
"i",
"++",
")",
"{",
"s",
"+=",
"vs",
"[",
"i",
"]",
";",
"b",
"+=",
"(",
"vs",
"[",
"i",
"+",
"period",
"]",
"-",
"vs",
"[",
"i",
"]",
")",
"/",
"period",
";",
"}",
"s",
"/=",
"(",
"double",
")",
"period",
";",
"b",
"/=",
"(",
"double",
")",
"period",
";",
"last_s",
"=",
"s",
";",
"if",
"(",
"Double",
".",
"compare",
"(",
"s",
",",
"0.0",
")",
"==",
"0",
"||",
"Double",
".",
"compare",
"(",
"s",
",",
"-",
"0.0",
")",
"==",
"0",
")",
"{",
"Arrays",
".",
"fill",
"(",
"seasonal",
",",
"0.0",
")",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"period",
";",
"i",
"++",
")",
"{",
"seasonal",
"[",
"i",
"]",
"=",
"vs",
"[",
"i",
"]",
"/",
"s",
";",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"period",
";",
"i",
"<",
"vs",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"seasonalityType",
".",
"equals",
"(",
"SeasonalityType",
".",
"MULTIPLICATIVE",
")",
")",
"{",
"s",
"=",
"alpha",
"*",
"(",
"vs",
"[",
"i",
"]",
"/",
"seasonal",
"[",
"i",
"-",
"period",
"]",
")",
"+",
"(",
"1.0d",
"-",
"alpha",
")",
"*",
"(",
"last_s",
"+",
"last_b",
")",
";",
"}",
"else",
"{",
"s",
"=",
"alpha",
"*",
"(",
"vs",
"[",
"i",
"]",
"-",
"seasonal",
"[",
"i",
"-",
"period",
"]",
")",
"+",
"(",
"1.0d",
"-",
"alpha",
")",
"*",
"(",
"last_s",
"+",
"last_b",
")",
";",
"}",
"b",
"=",
"beta",
"*",
"(",
"s",
"-",
"last_s",
")",
"+",
"(",
"1",
"-",
"beta",
")",
"*",
"last_b",
";",
"if",
"(",
"seasonalityType",
".",
"equals",
"(",
"SeasonalityType",
".",
"MULTIPLICATIVE",
")",
")",
"{",
"seasonal",
"[",
"i",
"]",
"=",
"gamma",
"*",
"(",
"vs",
"[",
"i",
"]",
"/",
"(",
"last_s",
"+",
"last_b",
")",
")",
"+",
"(",
"1",
"-",
"gamma",
")",
"*",
"seasonal",
"[",
"i",
"-",
"period",
"]",
";",
"}",
"else",
"{",
"seasonal",
"[",
"i",
"]",
"=",
"gamma",
"*",
"(",
"vs",
"[",
"i",
"]",
"-",
"(",
"last_s",
"-",
"last_b",
")",
")",
"+",
"(",
"1",
"-",
"gamma",
")",
"*",
"seasonal",
"[",
"i",
"-",
"period",
"]",
";",
"}",
"last_s",
"=",
"s",
";",
"last_b",
"=",
"b",
";",
"}",
"double",
"[",
"]",
"forecastValues",
"=",
"new",
"double",
"[",
"numForecasts",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"numForecasts",
";",
"i",
"++",
")",
"{",
"int",
"idx",
"=",
"values",
".",
"size",
"(",
")",
"-",
"period",
"+",
"(",
"(",
"i",
"-",
"1",
")",
"%",
"period",
")",
";",
"if",
"(",
"seasonalityType",
".",
"equals",
"(",
"SeasonalityType",
".",
"MULTIPLICATIVE",
")",
")",
"{",
"forecastValues",
"[",
"i",
"-",
"1",
"]",
"=",
"(",
"s",
"+",
"(",
"i",
"*",
"b",
")",
")",
"*",
"seasonal",
"[",
"idx",
"]",
";",
"}",
"else",
"{",
"forecastValues",
"[",
"i",
"-",
"1",
"]",
"=",
"s",
"+",
"(",
"i",
"*",
"b",
")",
"+",
"seasonal",
"[",
"idx",
"]",
";",
"}",
"}",
"return",
"forecastValues",
";",
"}"
] | calculate a doubly exponential weighted moving average
| train | false |
646 | public static AlarmCacheObject createTestAlarm1(){
AlarmCacheObject alarm1=new AlarmCacheObject();
alarm1.setId(Long.valueOf(1));
alarm1.setFaultFamily("fault family");
alarm1.setFaultMember("fault member");
alarm1.setFaultCode(0);
AlarmCondition condition=AlarmCondition.fromConfigXML("<AlarmCondition class=\"cern.c2mon.server.common.alarm.ValueAlarmCondition\">" + "<alarm-value type=\"String\">DOWN</alarm-value></AlarmCondition>");
alarm1.setCondition(condition);
alarm1.setInfo("alarm info");
alarm1.setState(AlarmCondition.TERMINATE);
alarm1.setTimestamp(new Timestamp(System.currentTimeMillis() - 2000));
alarm1.setDataTagId(100003L);
return alarm1;
}
| [
"public",
"static",
"AlarmCacheObject",
"createTestAlarm1",
"(",
")",
"{",
"AlarmCacheObject",
"alarm1",
"=",
"new",
"AlarmCacheObject",
"(",
")",
";",
"alarm1",
".",
"setId",
"(",
"Long",
".",
"valueOf",
"(",
"1",
")",
")",
";",
"alarm1",
".",
"setFaultFamily",
"(",
"\"fault family\"",
")",
";",
"alarm1",
".",
"setFaultMember",
"(",
"\"fault member\"",
")",
";",
"alarm1",
".",
"setFaultCode",
"(",
"0",
")",
";",
"AlarmCondition",
"condition",
"=",
"AlarmCondition",
".",
"fromConfigXML",
"(",
"\"<AlarmCondition class=\\\"cern.c2mon.server.common.alarm.ValueAlarmCondition\\\">\"",
"+",
"\"<alarm-value type=\\\"String\\\">DOWN</alarm-value></AlarmCondition>\"",
")",
";",
"alarm1",
".",
"setCondition",
"(",
"condition",
")",
";",
"alarm1",
".",
"setInfo",
"(",
"\"alarm info\"",
")",
";",
"alarm1",
".",
"setState",
"(",
"AlarmCondition",
".",
"TERMINATE",
")",
";",
"alarm1",
".",
"setTimestamp",
"(",
"new",
"Timestamp",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"2000",
")",
")",
";",
"alarm1",
".",
"setDataTagId",
"(",
"100003L",
")",
";",
"return",
"alarm1",
";",
"}"
] | does not set reference to tag id .
| train | false |
647 | public boolean justSerialized(){
return serialized.getAndSet(false);
}
| [
"public",
"boolean",
"justSerialized",
"(",
")",
"{",
"return",
"serialized",
".",
"getAndSet",
"(",
"false",
")",
";",
"}"
] | this is called on deserialization . you can only call it once to get a meaningful value as it resets the serialized state . in other words , this call is not idempotent .
| train | false |
648 | public Object read(String xml) throws Exception {
return fromXML(m_Document.read(xml));
}
| [
"public",
"Object",
"read",
"(",
"String",
"xml",
")",
"throws",
"Exception",
"{",
"return",
"fromXML",
"(",
"m_Document",
".",
"read",
"(",
"xml",
")",
")",
";",
"}"
] | parses the given xml string ( can be xml or a filename ) and returns an object generated from the representation
| train | false |
649 | protected T newInstance(final Class<? extends T> cls,final IIndexManager indexManager,final NT nt,final Properties properties){
if (cls == null) throw new IllegalArgumentException();
if (indexManager == null) throw new IllegalArgumentException();
if (nt == null) throw new IllegalArgumentException();
if (properties == null) throw new IllegalArgumentException();
final Constructor<? extends T> ctor;
try {
ctor=cls.getConstructor(new Class[]{IIndexManager.class,String.class,Long.class,Properties.class});
}
catch ( Exception e) {
throw new RuntimeException("No appropriate ctor?: cls=" + cls.getName() + " : "+ e,e);
}
final T r;
try {
r=ctor.newInstance(new Object[]{indexManager,nt.getName(),nt.getTimestamp(),properties});
r.init();
if (INFO) {
log.info("new instance: " + r);
}
return r;
}
catch ( Exception ex) {
throw new RuntimeException("Could not instantiate relation: " + ex,ex);
}
}
| [
"protected",
"T",
"newInstance",
"(",
"final",
"Class",
"<",
"?",
"extends",
"T",
">",
"cls",
",",
"final",
"IIndexManager",
"indexManager",
",",
"final",
"NT",
"nt",
",",
"final",
"Properties",
"properties",
")",
"{",
"if",
"(",
"cls",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"if",
"(",
"indexManager",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"if",
"(",
"nt",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"if",
"(",
"properties",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"final",
"Constructor",
"<",
"?",
"extends",
"T",
">",
"ctor",
";",
"try",
"{",
"ctor",
"=",
"cls",
".",
"getConstructor",
"(",
"new",
"Class",
"[",
"]",
"{",
"IIndexManager",
".",
"class",
",",
"String",
".",
"class",
",",
"Long",
".",
"class",
",",
"Properties",
".",
"class",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"No appropriate ctor?: cls=\"",
"+",
"cls",
".",
"getName",
"(",
")",
"+",
"\" : \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"final",
"T",
"r",
";",
"try",
"{",
"r",
"=",
"ctor",
".",
"newInstance",
"(",
"new",
"Object",
"[",
"]",
"{",
"indexManager",
",",
"nt",
".",
"getName",
"(",
")",
",",
"nt",
".",
"getTimestamp",
"(",
")",
",",
"properties",
"}",
")",
";",
"r",
".",
"init",
"(",
")",
";",
"if",
"(",
"INFO",
")",
"{",
"log",
".",
"info",
"(",
"\"new instance: \"",
"+",
"r",
")",
";",
"}",
"return",
"r",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not instantiate relation: \"",
"+",
"ex",
",",
"ex",
")",
";",
"}",
"}"
] | create a new view of the relation .
| train | false |
650 | public Builder(){
}
| [
"public",
"Builder",
"(",
")",
"{",
"}"
] | creates a new property . builder
| train | false |
651 | protected MapTile findCovering(int zoom,long i,long j){
while (zoom > 0) {
zoom--;
i=i / 2;
j=j / 2;
MapTile candidate=findTile(zoom,i,j);
if ((candidate != null) && (!candidate.loading())) {
return candidate;
}
}
return null;
}
| [
"protected",
"MapTile",
"findCovering",
"(",
"int",
"zoom",
",",
"long",
"i",
",",
"long",
"j",
")",
"{",
"while",
"(",
"zoom",
">",
"0",
")",
"{",
"zoom",
"--",
";",
"i",
"=",
"i",
"/",
"2",
";",
"j",
"=",
"j",
"/",
"2",
";",
"MapTile",
"candidate",
"=",
"findTile",
"(",
"zoom",
",",
"i",
",",
"j",
")",
";",
"if",
"(",
"(",
"candidate",
"!=",
"null",
")",
"&&",
"(",
"!",
"candidate",
".",
"loading",
"(",
")",
")",
")",
"{",
"return",
"candidate",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | find the " nearest " lower - zoom tile that covers a specific tile . this is used to find out what tile we have to show while a new tile is still loading
| train | false |
652 | @Override public String format(Object obj) throws IllegalArgumentException {
return format(obj,new StringBuffer());
}
| [
"@",
"Override",
"public",
"String",
"format",
"(",
"Object",
"obj",
")",
"throws",
"IllegalArgumentException",
"{",
"return",
"format",
"(",
"obj",
",",
"new",
"StringBuffer",
"(",
")",
")",
";",
"}"
] | format a given object .
| train | false |
653 | public boolean isEmpty(){
return ((values == null) || (values.isEmpty()));
}
| [
"public",
"boolean",
"isEmpty",
"(",
")",
"{",
"return",
"(",
"(",
"values",
"==",
"null",
")",
"||",
"(",
"values",
".",
"isEmpty",
"(",
")",
")",
")",
";",
"}"
] | obtiene si la lista de valores esta vacia
| train | false |
654 | private static String[] processObjectClasses(final String objectClass){
String[] objectClasses=null;
if (objectClass != null) {
objectClasses=objectClass.split(",");
}
if (objectClasses != null) {
String objClass=null;
for (int i=0; i < objectClasses.length; i++) {
objClass=objectClasses[i];
if (objClass != null) {
objectClasses[i]=objClass.trim();
}
}
}
return objectClasses;
}
| [
"private",
"static",
"String",
"[",
"]",
"processObjectClasses",
"(",
"final",
"String",
"objectClass",
")",
"{",
"String",
"[",
"]",
"objectClasses",
"=",
"null",
";",
"if",
"(",
"objectClass",
"!=",
"null",
")",
"{",
"objectClasses",
"=",
"objectClass",
".",
"split",
"(",
"\",\"",
")",
";",
"}",
"if",
"(",
"objectClasses",
"!=",
"null",
")",
"{",
"String",
"objClass",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"objectClasses",
".",
"length",
";",
"i",
"++",
")",
"{",
"objClass",
"=",
"objectClasses",
"[",
"i",
"]",
";",
"if",
"(",
"objClass",
"!=",
"null",
")",
"{",
"objectClasses",
"[",
"i",
"]",
"=",
"objClass",
".",
"trim",
"(",
")",
";",
"}",
"}",
"}",
"return",
"objectClasses",
";",
"}"
] | procesa un string con clases separadas por , para devolver un array
| train | false |
655 | public static String[] filterLightColors(String[] aPalette,int aThreshold){
List<String> filtered=new ArrayList<String>();
for ( String color : aPalette) {
if (!isTooLight(color,aThreshold)) {
filtered.add(color);
}
}
return (String[])filtered.toArray(new String[filtered.size()]);
}
| [
"public",
"static",
"String",
"[",
"]",
"filterLightColors",
"(",
"String",
"[",
"]",
"aPalette",
",",
"int",
"aThreshold",
")",
"{",
"List",
"<",
"String",
">",
"filtered",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"color",
":",
"aPalette",
")",
"{",
"if",
"(",
"!",
"isTooLight",
"(",
"color",
",",
"aThreshold",
")",
")",
"{",
"filtered",
".",
"add",
"(",
"color",
")",
";",
"}",
"}",
"return",
"(",
"String",
"[",
"]",
")",
"filtered",
".",
"toArray",
"(",
"new",
"String",
"[",
"filtered",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] | filter out too light colors from the palette - those that do not show propely on a ligth background . the threshold controls what to filter .
| train | false |
656 | synchronized int lookup(final Object tx,final boolean insert){
if (tx == null) {
throw new IllegalArgumentException("transaction object is null");
}
Integer index=(Integer)mapping.get(tx);
if (index == null) {
if (insert) {
final int capacity=capacity();
final int nvertices=mapping.size();
if (nvertices == capacity) {
throw new MultiprogrammingCapacityExceededException("capacity=" + capacity + ", nvertices="+ nvertices);
}
index=(Integer)indices.remove(0);
mapping.put(tx,index);
final int ndx=index.intValue();
if (transactions[ndx] != null) {
throw new AssertionError();
}
transactions[ndx]=tx;
}
else {
return -1;
}
}
return index.intValue();
}
| [
"synchronized",
"int",
"lookup",
"(",
"final",
"Object",
"tx",
",",
"final",
"boolean",
"insert",
")",
"{",
"if",
"(",
"tx",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"transaction object is null\"",
")",
";",
"}",
"Integer",
"index",
"=",
"(",
"Integer",
")",
"mapping",
".",
"get",
"(",
"tx",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"if",
"(",
"insert",
")",
"{",
"final",
"int",
"capacity",
"=",
"capacity",
"(",
")",
";",
"final",
"int",
"nvertices",
"=",
"mapping",
".",
"size",
"(",
")",
";",
"if",
"(",
"nvertices",
"==",
"capacity",
")",
"{",
"throw",
"new",
"MultiprogrammingCapacityExceededException",
"(",
"\"capacity=\"",
"+",
"capacity",
"+",
"\", nvertices=\"",
"+",
"nvertices",
")",
";",
"}",
"index",
"=",
"(",
"Integer",
")",
"indices",
".",
"remove",
"(",
"0",
")",
";",
"mapping",
".",
"put",
"(",
"tx",
",",
"index",
")",
";",
"final",
"int",
"ndx",
"=",
"index",
".",
"intValue",
"(",
")",
";",
"if",
"(",
"transactions",
"[",
"ndx",
"]",
"!=",
"null",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
")",
";",
"}",
"transactions",
"[",
"ndx",
"]",
"=",
"tx",
";",
"}",
"else",
"{",
"return",
"-",
"1",
";",
"}",
"}",
"return",
"index",
".",
"intValue",
"(",
")",
";",
"}"
] | lookup index assigned to transaction object .
| train | false |
659 | public int readLEInt() throws IOException {
int byte1, byte2, byte3, byte4;
synchronized (this) {
byte1=in.read();
byte2=in.read();
byte3=in.read();
byte4=in.read();
}
if (byte4 == -1) {
throw new EOFException();
}
return (byte4 << 24) + (byte3 << 16) + (byte2 << 8)+ byte1;
}
| [
"public",
"int",
"readLEInt",
"(",
")",
"throws",
"IOException",
"{",
"int",
"byte1",
",",
"byte2",
",",
"byte3",
",",
"byte4",
";",
"synchronized",
"(",
"this",
")",
"{",
"byte1",
"=",
"in",
".",
"read",
"(",
")",
";",
"byte2",
"=",
"in",
".",
"read",
"(",
")",
";",
"byte3",
"=",
"in",
".",
"read",
"(",
")",
";",
"byte4",
"=",
"in",
".",
"read",
"(",
")",
";",
"}",
"if",
"(",
"byte4",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"EOFException",
"(",
")",
";",
"}",
"return",
"(",
"byte4",
"<<",
"24",
")",
"+",
"(",
"byte3",
"<<",
"16",
")",
"+",
"(",
"byte2",
"<<",
"8",
")",
"+",
"byte1",
";",
"}"
] | translates a little endian int into a big endian int
| train | true |
660 | protected AbstractSimplex(final double[] steps){
if (steps == null) {
throw new NullArgumentException();
}
if (steps.length == 0) {
throw new MathIllegalArgumentException(LocalizedCoreFormats.ZERO_NOT_ALLOWED);
}
dimension=steps.length;
startConfiguration=new double[dimension][dimension];
for (int i=0; i < dimension; i++) {
final double[] vertexI=startConfiguration[i];
for (int j=0; j < i + 1; j++) {
if (steps[j] == 0) {
throw new MathIllegalArgumentException(LocalizedOptimFormats.EQUAL_VERTICES_IN_SIMPLEX);
}
System.arraycopy(steps,0,vertexI,0,j + 1);
}
}
}
| [
"protected",
"AbstractSimplex",
"(",
"final",
"double",
"[",
"]",
"steps",
")",
"{",
"if",
"(",
"steps",
"==",
"null",
")",
"{",
"throw",
"new",
"NullArgumentException",
"(",
")",
";",
"}",
"if",
"(",
"steps",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"MathIllegalArgumentException",
"(",
"LocalizedCoreFormats",
".",
"ZERO_NOT_ALLOWED",
")",
";",
"}",
"dimension",
"=",
"steps",
".",
"length",
";",
"startConfiguration",
"=",
"new",
"double",
"[",
"dimension",
"]",
"[",
"dimension",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"dimension",
";",
"i",
"++",
")",
"{",
"final",
"double",
"[",
"]",
"vertexI",
"=",
"startConfiguration",
"[",
"i",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"i",
"+",
"1",
";",
"j",
"++",
")",
"{",
"if",
"(",
"steps",
"[",
"j",
"]",
"==",
"0",
")",
"{",
"throw",
"new",
"MathIllegalArgumentException",
"(",
"LocalizedOptimFormats",
".",
"EQUAL_VERTICES_IN_SIMPLEX",
")",
";",
"}",
"System",
".",
"arraycopy",
"(",
"steps",
",",
"0",
",",
"vertexI",
",",
"0",
",",
"j",
"+",
"1",
")",
";",
"}",
"}",
"}"
] | the start configuration for simplex is built from a box parallel to the canonical axes of the space . the simplex is the subset of vertices of a box parallel to the canonical axes . it is built as the path followed while traveling from one vertex of the box to the diagonally opposite vertex moving only along the box edges . the first vertex of the box will be located at the start point of the optimization . as an example , in dimension 3 a simplex has 4 vertices . setting the steps to ( 1 , 10 , 2 ) and the start point to ( 1 , 1 , 1 ) would imply the start simplex would be : { ( 1 , 1 , 1 ) , ( 2 , 1 , 1 ) , ( 2 , 11 , 1 ) , ( 2 , 11 , 3 ) } . the first vertex would be set to the start point at ( 1 , 1 , 1 ) and the last vertex would be set to the diagonally opposite vertex at ( 2 , 11 , 3 ) .
| train | false |
663 | public void initializeAtomsForDP(List<Datum> data,String filename,Random random){
omega=new ArrayList<>(K);
dof=new double[K];
beta=new double[K];
if (filename != null) {
try {
loc=BatchMixtureModel.initializeClustersFromFile(filename,K);
log.debug("loc : {}",loc);
if (loc.size() < K) {
loc=BatchMixtureModel.gonzalezInitializeMixtureCenters(loc,data,K,random);
}
}
catch ( FileNotFoundException e) {
log.debug("failed to initialized from file");
e.printStackTrace();
loc=BatchMixtureModel.gonzalezInitializeMixtureCenters(data,K,random);
}
}
else {
loc=BatchMixtureModel.gonzalezInitializeMixtureCenters(data,K,random);
}
for (int i=0; i < K; i++) {
beta[i]=1;
dof[i]=baseNu;
omega.add(0,AlgebraUtils.invertMatrix(baseOmegaInverse));
}
}
| [
"public",
"void",
"initializeAtomsForDP",
"(",
"List",
"<",
"Datum",
">",
"data",
",",
"String",
"filename",
",",
"Random",
"random",
")",
"{",
"omega",
"=",
"new",
"ArrayList",
"<",
">",
"(",
"K",
")",
";",
"dof",
"=",
"new",
"double",
"[",
"K",
"]",
";",
"beta",
"=",
"new",
"double",
"[",
"K",
"]",
";",
"if",
"(",
"filename",
"!=",
"null",
")",
"{",
"try",
"{",
"loc",
"=",
"BatchMixtureModel",
".",
"initializeClustersFromFile",
"(",
"filename",
",",
"K",
")",
";",
"log",
".",
"debug",
"(",
"\"loc : {}\"",
",",
"loc",
")",
";",
"if",
"(",
"loc",
".",
"size",
"(",
")",
"<",
"K",
")",
"{",
"loc",
"=",
"BatchMixtureModel",
".",
"gonzalezInitializeMixtureCenters",
"(",
"loc",
",",
"data",
",",
"K",
",",
"random",
")",
";",
"}",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"log",
".",
"debug",
"(",
"\"failed to initialized from file\"",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"loc",
"=",
"BatchMixtureModel",
".",
"gonzalezInitializeMixtureCenters",
"(",
"data",
",",
"K",
",",
"random",
")",
";",
"}",
"}",
"else",
"{",
"loc",
"=",
"BatchMixtureModel",
".",
"gonzalezInitializeMixtureCenters",
"(",
"data",
",",
"K",
",",
"random",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"K",
";",
"i",
"++",
")",
"{",
"beta",
"[",
"i",
"]",
"=",
"1",
";",
"dof",
"[",
"i",
"]",
"=",
"baseNu",
";",
"omega",
".",
"add",
"(",
"0",
",",
"AlgebraUtils",
".",
"invertMatrix",
"(",
"baseOmegaInverse",
")",
")",
";",
"}",
"}"
] | initializes atom ( component ) distributions . this method works great with dp mixture model .
| train | false |