repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
hpsa/hpe-application-automation-tools-plugin
src/main/java/com/hp/application/automation/tools/results/LrGraphUtils.java
LrGraphUtils.constructTotalHitsGraph
static void constructTotalHitsGraph(Map.Entry<String, LrProjectScenarioResults> scenarioResults, JSONObject scenarioGraphData) { Map<Integer, WholeRunResult> totalHitsResults = scenarioResults.getValue().getTotalHitsResults(); JSONObject totalHitsGraphSet = extractWholeRunSlaResult(totalHitsResults, "Hits"); if (!totalHitsGraphSet.getJSONArray(LABELS).isEmpty()) { totalHitsGraphSet.put(TITLE, "Total Hits"); totalHitsGraphSet.put(X_AXIS_TITLE, "Build number"); totalHitsGraphSet.put(Y_AXIS_TITLE, "Hits"); totalHitsGraphSet.put(DESCRIPTION, "Displays the number of hits made on the Web server by Vusers " + "during each second of the load test. This graph helps you evaluate the amount of load " + "Vusers" + " " + "generate, in terms of the number of hits."); scenarioGraphData.put("totalHits", totalHitsGraphSet); } }
java
static void constructTotalHitsGraph(Map.Entry<String, LrProjectScenarioResults> scenarioResults, JSONObject scenarioGraphData) { Map<Integer, WholeRunResult> totalHitsResults = scenarioResults.getValue().getTotalHitsResults(); JSONObject totalHitsGraphSet = extractWholeRunSlaResult(totalHitsResults, "Hits"); if (!totalHitsGraphSet.getJSONArray(LABELS).isEmpty()) { totalHitsGraphSet.put(TITLE, "Total Hits"); totalHitsGraphSet.put(X_AXIS_TITLE, "Build number"); totalHitsGraphSet.put(Y_AXIS_TITLE, "Hits"); totalHitsGraphSet.put(DESCRIPTION, "Displays the number of hits made on the Web server by Vusers " + "during each second of the load test. This graph helps you evaluate the amount of load " + "Vusers" + " " + "generate, in terms of the number of hits."); scenarioGraphData.put("totalHits", totalHitsGraphSet); } }
[ "static", "void", "constructTotalHitsGraph", "(", "Map", ".", "Entry", "<", "String", ",", "LrProjectScenarioResults", ">", "scenarioResults", ",", "JSONObject", "scenarioGraphData", ")", "{", "Map", "<", "Integer", ",", "WholeRunResult", ">", "totalHitsResults", "=...
Construct total hits graph. @param scenarioResults the scenario results @param scenarioGraphData the scenario graph data
[ "Construct", "total", "hits", "graph", "." ]
987536f5551bc76fd028d746a951d1fd72c7567a
https://github.com/hpsa/hpe-application-automation-tools-plugin/blob/987536f5551bc76fd028d746a951d1fd72c7567a/src/main/java/com/hp/application/automation/tools/results/LrGraphUtils.java#L356-L372
train
hpsa/hpe-application-automation-tools-plugin
src/main/java/com/hp/application/automation/tools/sse/sdk/HttpRequestDecorator.java
HttpRequestDecorator.digestToString
private static String digestToString(byte[] b) { StringBuilder result = new StringBuilder(128); for (byte aB : b) { result.append(Integer.toString((aB & 0xff) + 0x100, 16).substring(1)); } return result.toString(); }
java
private static String digestToString(byte[] b) { StringBuilder result = new StringBuilder(128); for (byte aB : b) { result.append(Integer.toString((aB & 0xff) + 0x100, 16).substring(1)); } return result.toString(); }
[ "private", "static", "String", "digestToString", "(", "byte", "[", "]", "b", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", "128", ")", ";", "for", "(", "byte", "aB", ":", "b", ")", "{", "result", ".", "append", "(", "Integer", ...
This method convert byte array to string regardless the charset @param b byte array input @return the corresponding string
[ "This", "method", "convert", "byte", "array", "to", "string", "regardless", "the", "charset" ]
987536f5551bc76fd028d746a951d1fd72c7567a
https://github.com/hpsa/hpe-application-automation-tools-plugin/blob/987536f5551bc76fd028d746a951d1fd72c7567a/src/main/java/com/hp/application/automation/tools/sse/sdk/HttpRequestDecorator.java#L56-L64
train
hpsa/hpe-application-automation-tools-plugin
src/main/java/com/hp/application/automation/tools/results/PerformanceProjectAction.java
PerformanceProjectAction.getScenarioList
@JavaScriptMethod public JSONArray getScenarioList() { JSONArray scenarioList = new JSONArray(); for (String scenarioName : _projectResult.getScenarioResults().keySet()) { JSONObject scenario = new JSONObject(); scenario.put("ScenarioName", scenarioName); scenarioList.add(scenario); } return scenarioList; }
java
@JavaScriptMethod public JSONArray getScenarioList() { JSONArray scenarioList = new JSONArray(); for (String scenarioName : _projectResult.getScenarioResults().keySet()) { JSONObject scenario = new JSONObject(); scenario.put("ScenarioName", scenarioName); scenarioList.add(scenario); } return scenarioList; }
[ "@", "JavaScriptMethod", "public", "JSONArray", "getScenarioList", "(", ")", "{", "JSONArray", "scenarioList", "=", "new", "JSONArray", "(", ")", ";", "for", "(", "String", "scenarioName", ":", "_projectResult", ".", "getScenarioResults", "(", ")", ".", "keySet"...
Gets scenario list. @return the scenario list
[ "Gets", "scenario", "list", "." ]
987536f5551bc76fd028d746a951d1fd72c7567a
https://github.com/hpsa/hpe-application-automation-tools-plugin/blob/987536f5551bc76fd028d746a951d1fd72c7567a/src/main/java/com/hp/application/automation/tools/results/PerformanceProjectAction.java#L103-L112
train
hpsa/hpe-application-automation-tools-plugin
src/main/java/com/hp/application/automation/tools/results/PerformanceProjectAction.java
PerformanceProjectAction.getGraphData
@JavaScriptMethod public JSONObject getGraphData() { JSONObject projectDataSet = new JSONObject(); if (_projectResult == null) { // getUpdatedData(); return new JSONObject(); } for (SortedMap.Entry<String, LrProjectScenarioResults> scenarioResults : _projectResult.getScenarioResults() .entrySet()) { JSONObject scenarioData = new JSONObject(); JSONObject scenarioStats = new JSONObject(); // LrGraphUtils // .constructVuserSummary(scenarioResults.getValue().getvUserSummary(), scenarioStats, _workedBuilds // .size()); // LrGraphUtils.constructDurationSummary(scenarioResults.getValue().getDurationData(), scenarioStats); // LrGraphUtils.constructConnectionSummary(scenarioResults.getValue().getMaxConnectionsCount(), scenarioStats); // LrGraphUtils.constructTransactionSummary(scenarioResults.getValue().getTransactionSum(), scenarioStats, // _workedBuilds.size()); scenarioData.put("scenarioStats", scenarioStats); JSONObject scenarioGraphData = new JSONObject(); //Scenario data graphs // LrGraphUtils.constructVuserGraph(scenarioResults, scenarioGraphData); // LrGraphUtils.constructConnectionsGraph(scenarioResults, scenarioGraphData); //Scenario SLA graphs LrGraphUtils.constructTotalHitsGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructAvgHitsGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructTotalThroughputGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructAverageThroughput(scenarioResults, scenarioGraphData); LrGraphUtils.constructErrorGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructAvgTransactionGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructPercentileTransactionGraph(scenarioResults, scenarioGraphData); scenarioData.put("scenarioData", scenarioGraphData); String scenarioName = scenarioResults.getKey(); projectDataSet.put(scenarioName, scenarioData); } return projectDataSet; }
java
@JavaScriptMethod public JSONObject getGraphData() { JSONObject projectDataSet = new JSONObject(); if (_projectResult == null) { // getUpdatedData(); return new JSONObject(); } for (SortedMap.Entry<String, LrProjectScenarioResults> scenarioResults : _projectResult.getScenarioResults() .entrySet()) { JSONObject scenarioData = new JSONObject(); JSONObject scenarioStats = new JSONObject(); // LrGraphUtils // .constructVuserSummary(scenarioResults.getValue().getvUserSummary(), scenarioStats, _workedBuilds // .size()); // LrGraphUtils.constructDurationSummary(scenarioResults.getValue().getDurationData(), scenarioStats); // LrGraphUtils.constructConnectionSummary(scenarioResults.getValue().getMaxConnectionsCount(), scenarioStats); // LrGraphUtils.constructTransactionSummary(scenarioResults.getValue().getTransactionSum(), scenarioStats, // _workedBuilds.size()); scenarioData.put("scenarioStats", scenarioStats); JSONObject scenarioGraphData = new JSONObject(); //Scenario data graphs // LrGraphUtils.constructVuserGraph(scenarioResults, scenarioGraphData); // LrGraphUtils.constructConnectionsGraph(scenarioResults, scenarioGraphData); //Scenario SLA graphs LrGraphUtils.constructTotalHitsGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructAvgHitsGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructTotalThroughputGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructAverageThroughput(scenarioResults, scenarioGraphData); LrGraphUtils.constructErrorGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructAvgTransactionGraph(scenarioResults, scenarioGraphData); LrGraphUtils.constructPercentileTransactionGraph(scenarioResults, scenarioGraphData); scenarioData.put("scenarioData", scenarioGraphData); String scenarioName = scenarioResults.getKey(); projectDataSet.put(scenarioName, scenarioData); } return projectDataSet; }
[ "@", "JavaScriptMethod", "public", "JSONObject", "getGraphData", "(", ")", "{", "JSONObject", "projectDataSet", "=", "new", "JSONObject", "(", ")", ";", "if", "(", "_projectResult", "==", "null", ")", "{", "// getUpdatedData();", "return", "new", "JSONO...
Collates graph data per scenario per build for the whole project. Adds the respected graphs with scenario as the key @return the graph data
[ "Collates", "graph", "data", "per", "scenario", "per", "build", "for", "the", "whole", "project", ".", "Adds", "the", "respected", "graphs", "with", "scenario", "as", "the", "key" ]
987536f5551bc76fd028d746a951d1fd72c7567a
https://github.com/hpsa/hpe-application-automation-tools-plugin/blob/987536f5551bc76fd028d746a951d1fd72c7567a/src/main/java/com/hp/application/automation/tools/results/PerformanceProjectAction.java#L120-L164
train
hpsa/hpe-application-automation-tools-plugin
src/main/java/com/hp/application/automation/tools/results/PerformanceProjectAction.java
PerformanceProjectAction.isVisible
boolean isVisible() { List<? extends Run<?, ?>> builds = currentProject.getBuilds(); for (Run run : builds) { if (run.getAction(PerformanceJobReportAction.class) != null) { return true; } } return false; }
java
boolean isVisible() { List<? extends Run<?, ?>> builds = currentProject.getBuilds(); for (Run run : builds) { if (run.getAction(PerformanceJobReportAction.class) != null) { return true; } } return false; }
[ "boolean", "isVisible", "(", ")", "{", "List", "<", "?", "extends", "Run", "<", "?", ",", "?", ">", ">", "builds", "=", "currentProject", ".", "getBuilds", "(", ")", ";", "for", "(", "Run", "run", ":", "builds", ")", "{", "if", "(", "run", ".", ...
Is visible boolean. @return the boolean
[ "Is", "visible", "boolean", "." ]
987536f5551bc76fd028d746a951d1fd72c7567a
https://github.com/hpsa/hpe-application-automation-tools-plugin/blob/987536f5551bc76fd028d746a951d1fd72c7567a/src/main/java/com/hp/application/automation/tools/results/PerformanceProjectAction.java#L214-L222
train
hpsa/hpe-application-automation-tools-plugin
src/main/java/com/hp/application/automation/tools/results/PerformanceProjectAction.java
PerformanceProjectAction.getUpdatedData
public synchronized void getUpdatedData() { if (!isUpdateDataNeeded()) { return; } this._projectResult = new ProjectLrResults(); _workedBuilds = new ArrayList<Integer>(); RunList<? extends Run> projectBuilds = currentProject.getBuilds(); // updateLastBuild(); for (Run run : projectBuilds) { PerformanceJobReportAction performanceJobReportAction = run.getAction(PerformanceJobReportAction.class); if (performanceJobReportAction == null) { continue; } if (run.isBuilding()) { continue; } int runNumber = run.getNumber(); if (_workedBuilds.contains(runNumber)) { continue; } _workedBuilds.add(runNumber); LrJobResults jobLrResult = performanceJobReportAction.getLrResultBuildDataset(); // get all the ran scenario results from this run and insert them into the project for (Map.Entry<String, JobLrScenarioResult> runResult : jobLrResult.getLrScenarioResults().entrySet()) { // add the scenario if it's the first time it's ran in this build (allows scenarios to be also added // at diffrent time) if (!_projectResult.getScenarioResults().containsKey(runResult.getKey())) { _projectResult.addScenario(new LrProjectScenarioResults(runResult.getKey())); } // Join the SLA rule results LrProjectScenarioResults lrProjectScenarioResults = _projectResult.getScenarioResults().get(runResult.getKey()); if(lrProjectScenarioResults.getBuildCount() > MAX_DISPLAY_BUILDS) { continue; } lrProjectScenarioResults.incBuildCount(); JobLrScenarioResult scenarioRunResult = runResult.getValue(); for (GoalResult goalResult : scenarioRunResult.scenarioSlaResults) { scenarioGoalResult(runNumber, lrProjectScenarioResults, goalResult); } // Join sceanrio stats joinSceanrioConnectionsStats(runNumber, lrProjectScenarioResults, scenarioRunResult); joinVUserScenarioStats(runNumber, lrProjectScenarioResults, scenarioRunResult); joinTransactionScenarioStats(runNumber, lrProjectScenarioResults, scenarioRunResult); joinDurationStats(runNumber, lrProjectScenarioResults, scenarioRunResult); } } }
java
public synchronized void getUpdatedData() { if (!isUpdateDataNeeded()) { return; } this._projectResult = new ProjectLrResults(); _workedBuilds = new ArrayList<Integer>(); RunList<? extends Run> projectBuilds = currentProject.getBuilds(); // updateLastBuild(); for (Run run : projectBuilds) { PerformanceJobReportAction performanceJobReportAction = run.getAction(PerformanceJobReportAction.class); if (performanceJobReportAction == null) { continue; } if (run.isBuilding()) { continue; } int runNumber = run.getNumber(); if (_workedBuilds.contains(runNumber)) { continue; } _workedBuilds.add(runNumber); LrJobResults jobLrResult = performanceJobReportAction.getLrResultBuildDataset(); // get all the ran scenario results from this run and insert them into the project for (Map.Entry<String, JobLrScenarioResult> runResult : jobLrResult.getLrScenarioResults().entrySet()) { // add the scenario if it's the first time it's ran in this build (allows scenarios to be also added // at diffrent time) if (!_projectResult.getScenarioResults().containsKey(runResult.getKey())) { _projectResult.addScenario(new LrProjectScenarioResults(runResult.getKey())); } // Join the SLA rule results LrProjectScenarioResults lrProjectScenarioResults = _projectResult.getScenarioResults().get(runResult.getKey()); if(lrProjectScenarioResults.getBuildCount() > MAX_DISPLAY_BUILDS) { continue; } lrProjectScenarioResults.incBuildCount(); JobLrScenarioResult scenarioRunResult = runResult.getValue(); for (GoalResult goalResult : scenarioRunResult.scenarioSlaResults) { scenarioGoalResult(runNumber, lrProjectScenarioResults, goalResult); } // Join sceanrio stats joinSceanrioConnectionsStats(runNumber, lrProjectScenarioResults, scenarioRunResult); joinVUserScenarioStats(runNumber, lrProjectScenarioResults, scenarioRunResult); joinTransactionScenarioStats(runNumber, lrProjectScenarioResults, scenarioRunResult); joinDurationStats(runNumber, lrProjectScenarioResults, scenarioRunResult); } } }
[ "public", "synchronized", "void", "getUpdatedData", "(", ")", "{", "if", "(", "!", "isUpdateDataNeeded", "(", ")", ")", "{", "return", ";", "}", "this", ".", "_projectResult", "=", "new", "ProjectLrResults", "(", ")", ";", "_workedBuilds", "=", "new", "Arr...
Gets updated data.
[ "Gets", "updated", "data", "." ]
987536f5551bc76fd028d746a951d1fd72c7567a
https://github.com/hpsa/hpe-application-automation-tools-plugin/blob/987536f5551bc76fd028d746a951d1fd72c7567a/src/main/java/com/hp/application/automation/tools/results/PerformanceProjectAction.java#L227-L288
train
hpsa/hpe-application-automation-tools-plugin
src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
RunFromFileSystemModel.getJobDetails
public JSONObject getJobDetails(String mcUrl, String proxyAddress, String proxyUserName, String proxyPassword){ if(StringUtils.isBlank(fsUserName) || StringUtils.isBlank(fsPassword.getPlainText())){ return null; } return JobConfigurationProxy.getInstance().getJobById(mcUrl, fsUserName, fsPassword.getPlainText(), proxyAddress, proxyUserName, proxyPassword, fsJobId); }
java
public JSONObject getJobDetails(String mcUrl, String proxyAddress, String proxyUserName, String proxyPassword){ if(StringUtils.isBlank(fsUserName) || StringUtils.isBlank(fsPassword.getPlainText())){ return null; } return JobConfigurationProxy.getInstance().getJobById(mcUrl, fsUserName, fsPassword.getPlainText(), proxyAddress, proxyUserName, proxyPassword, fsJobId); }
[ "public", "JSONObject", "getJobDetails", "(", "String", "mcUrl", ",", "String", "proxyAddress", ",", "String", "proxyUserName", ",", "String", "proxyPassword", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "fsUserName", ")", "||", "StringUtils", ".", ...
Get proxy details json object. @param mcUrl the mc url @param proxyAddress the proxy address @param proxyUserName the proxy user name @param proxyPassword the proxy password @return the json object
[ "Get", "proxy", "details", "json", "object", "." ]
987536f5551bc76fd028d746a951d1fd72c7567a
https://github.com/hpsa/hpe-application-automation-tools-plugin/blob/987536f5551bc76fd028d746a951d1fd72c7567a/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java#L646-L651
train
Intel-HLS/GKL
src/main/java/com/intel/gkl/smithwaterman/IntelSmithWaterman.java
IntelSmithWaterman.align
@Override public SWNativeAlignerResult align(byte[] refArray, byte[] altArray, SWParameters parameters, SWOverhangStrategy overhangStrategy) { int intStrategy = getStrategy(overhangStrategy); byte[] cigar = new byte[2*Integer.max(refArray.length, altArray.length)]; int offset = alignNative(refArray, altArray, cigar, parameters.getMatchValue(), parameters.getMismatchPenalty(), parameters.getGapOpenPenalty(), parameters.getGapExtendPenalty(), intStrategy); return new SWNativeAlignerResult(new String(cigar).trim(), offset); }
java
@Override public SWNativeAlignerResult align(byte[] refArray, byte[] altArray, SWParameters parameters, SWOverhangStrategy overhangStrategy) { int intStrategy = getStrategy(overhangStrategy); byte[] cigar = new byte[2*Integer.max(refArray.length, altArray.length)]; int offset = alignNative(refArray, altArray, cigar, parameters.getMatchValue(), parameters.getMismatchPenalty(), parameters.getGapOpenPenalty(), parameters.getGapExtendPenalty(), intStrategy); return new SWNativeAlignerResult(new String(cigar).trim(), offset); }
[ "@", "Override", "public", "SWNativeAlignerResult", "align", "(", "byte", "[", "]", "refArray", ",", "byte", "[", "]", "altArray", ",", "SWParameters", "parameters", ",", "SWOverhangStrategy", "overhangStrategy", ")", "{", "int", "intStrategy", "=", "getStrategy",...
Implements the native implementation of SmithWaterman, and returns the Cigar String and alignment_offset @param refArray array of reference data @param altArray array of alternate data
[ "Implements", "the", "native", "implementation", "of", "SmithWaterman", "and", "returns", "the", "Cigar", "String", "and", "alignment_offset" ]
c071276633f01d8198198fb40df468a0dffb0d41
https://github.com/Intel-HLS/GKL/blob/c071276633f01d8198198fb40df468a0dffb0d41/src/main/java/com/intel/gkl/smithwaterman/IntelSmithWaterman.java#L95-L104
train
Intel-HLS/GKL
src/main/java/com/intel/gkl/compression/IntelDeflaterFactory.java
IntelDeflaterFactory.makeDeflater
public Deflater makeDeflater(final int compressionLevel, final boolean gzipCompatible) { if (intelDeflaterSupported) { if ((compressionLevel == 1 && gzipCompatible) || compressionLevel != 1) { return new IntelDeflater(compressionLevel, gzipCompatible); } } logger.warn("IntelDeflater is not supported, using Java.util.zip.Deflater"); return new Deflater(compressionLevel, gzipCompatible); }
java
public Deflater makeDeflater(final int compressionLevel, final boolean gzipCompatible) { if (intelDeflaterSupported) { if ((compressionLevel == 1 && gzipCompatible) || compressionLevel != 1) { return new IntelDeflater(compressionLevel, gzipCompatible); } } logger.warn("IntelDeflater is not supported, using Java.util.zip.Deflater"); return new Deflater(compressionLevel, gzipCompatible); }
[ "public", "Deflater", "makeDeflater", "(", "final", "int", "compressionLevel", ",", "final", "boolean", "gzipCompatible", ")", "{", "if", "(", "intelDeflaterSupported", ")", "{", "if", "(", "(", "compressionLevel", "==", "1", "&&", "gzipCompatible", ")", "||", ...
Returns an IntelDeflater if supported on the platform, otherwise returns a Java Deflater @param compressionLevel the compression level (0-9) @param gzipCompatible if true the use GZIP compatible compression @return a Deflater object
[ "Returns", "an", "IntelDeflater", "if", "supported", "on", "the", "platform", "otherwise", "returns", "a", "Java", "Deflater" ]
c071276633f01d8198198fb40df468a0dffb0d41
https://github.com/Intel-HLS/GKL/blob/c071276633f01d8198198fb40df468a0dffb0d41/src/main/java/com/intel/gkl/compression/IntelDeflaterFactory.java#L32-L40
train
Intel-HLS/GKL
src/main/java/com/intel/gkl/pairhmm/IntelPairHmm.java
IntelPairHmm.initialize
public void initialize(PairHMMNativeArguments args) { if (args == null) { args = new PairHMMNativeArguments(); args.useDoublePrecision = false; args.maxNumberOfThreads = 1; } if(!useFpga && gklUtils.isAvx512Supported()) { logger.info("Using CPU-supported AVX-512 instructions"); } if (args.useDoublePrecision && useFpga) { logger.warn("FPGA PairHMM does not support double precision floating-point. Using AVX PairHMM"); } if(!gklUtils.getFlushToZero()) { logger.info("Flush-to-zero (FTZ) is enabled when running PairHMM"); } initNative(ReadDataHolder.class, HaplotypeDataHolder.class, args.useDoublePrecision, args.maxNumberOfThreads, useFpga); // log information about threads int reqThreads = args.maxNumberOfThreads; if (useOmp) { int availThreads = gklUtils.getAvailableOmpThreads(); int maxThreads = Math.min(reqThreads, availThreads); logger.info("Available threads: " + availThreads); logger.info("Requested threads: " + reqThreads); if (reqThreads > availThreads) { logger.warn("Using " + maxThreads + " available threads, but " + reqThreads + " were requested"); } } else { if (reqThreads != 1) { logger.warn("Ignoring request for " + reqThreads + " threads; not using OpenMP implementation"); } } }
java
public void initialize(PairHMMNativeArguments args) { if (args == null) { args = new PairHMMNativeArguments(); args.useDoublePrecision = false; args.maxNumberOfThreads = 1; } if(!useFpga && gklUtils.isAvx512Supported()) { logger.info("Using CPU-supported AVX-512 instructions"); } if (args.useDoublePrecision && useFpga) { logger.warn("FPGA PairHMM does not support double precision floating-point. Using AVX PairHMM"); } if(!gklUtils.getFlushToZero()) { logger.info("Flush-to-zero (FTZ) is enabled when running PairHMM"); } initNative(ReadDataHolder.class, HaplotypeDataHolder.class, args.useDoublePrecision, args.maxNumberOfThreads, useFpga); // log information about threads int reqThreads = args.maxNumberOfThreads; if (useOmp) { int availThreads = gklUtils.getAvailableOmpThreads(); int maxThreads = Math.min(reqThreads, availThreads); logger.info("Available threads: " + availThreads); logger.info("Requested threads: " + reqThreads); if (reqThreads > availThreads) { logger.warn("Using " + maxThreads + " available threads, but " + reqThreads + " were requested"); } } else { if (reqThreads != 1) { logger.warn("Ignoring request for " + reqThreads + " threads; not using OpenMP implementation"); } } }
[ "public", "void", "initialize", "(", "PairHMMNativeArguments", "args", ")", "{", "if", "(", "args", "==", "null", ")", "{", "args", "=", "new", "PairHMMNativeArguments", "(", ")", ";", "args", ".", "useDoublePrecision", "=", "false", ";", "args", ".", "max...
Initialize native PairHMM with the supplied args. @param args the args used to configure native PairHMM
[ "Initialize", "native", "PairHMM", "with", "the", "supplied", "args", "." ]
c071276633f01d8198198fb40df468a0dffb0d41
https://github.com/Intel-HLS/GKL/blob/c071276633f01d8198198fb40df468a0dffb0d41/src/main/java/com/intel/gkl/pairhmm/IntelPairHmm.java#L63-L101
train
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin
sbt-compiler-maven-plugin/src/main/java/com/google/code/sbt/compiler/plugin/SBTAddManagedSourcesMojo.java
SBTAddManagedSourcesMojo.execute
@Override public void execute() { if ( "pom".equals( project.getPackaging() ) ) { return; } File managedPath = new File( project.getBuild().getDirectory(), "src_managed" ); String managedPathStr = managedPath.getAbsolutePath(); if ( !project.getCompileSourceRoots().contains( managedPathStr ) ) { project.addCompileSourceRoot( managedPathStr ); getLog().debug( "Added source directory: " + managedPathStr ); } }
java
@Override public void execute() { if ( "pom".equals( project.getPackaging() ) ) { return; } File managedPath = new File( project.getBuild().getDirectory(), "src_managed" ); String managedPathStr = managedPath.getAbsolutePath(); if ( !project.getCompileSourceRoots().contains( managedPathStr ) ) { project.addCompileSourceRoot( managedPathStr ); getLog().debug( "Added source directory: " + managedPathStr ); } }
[ "@", "Override", "public", "void", "execute", "(", ")", "{", "if", "(", "\"pom\"", ".", "equals", "(", "project", ".", "getPackaging", "(", ")", ")", ")", "{", "return", ";", "}", "File", "managedPath", "=", "new", "File", "(", "project", ".", "getBu...
Adds default SBT managed sources location to Maven project. <code>${project.build.directory}/src_managed</code> is added to project's compile source roots
[ "Adds", "default", "SBT", "managed", "sources", "location", "to", "Maven", "project", "." ]
cf8b8766956841c13f388eb311d214644dba9137
https://github.com/sbt-compiler-maven-plugin/sbt-compiler-maven-plugin/blob/cf8b8766956841c13f388eb311d214644dba9137/sbt-compiler-maven-plugin/src/main/java/com/google/code/sbt/compiler/plugin/SBTAddManagedSourcesMojo.java#L53-L68
train
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin
sbt-compiler-maven-plugin/src/main/java/com/google/code/sbt/compiler/plugin/SBTAddScalaSourcesMojo.java
SBTAddScalaSourcesMojo.execute
@Override public void execute() { if ( "pom".equals( project.getPackaging() ) ) { return; } File baseDir = project.getBasedir(); File mainScalaPath = new File( baseDir, "src/main/scala" ); if ( mainScalaPath.isDirectory() ) { String mainScalaPathStr = mainScalaPath.getAbsolutePath(); if ( !project.getCompileSourceRoots().contains( mainScalaPathStr ) ) { project.addCompileSourceRoot( mainScalaPathStr ); getLog().debug( "Added source directory: " + mainScalaPathStr ); } } File testScalaPath = new File( baseDir, "src/test/scala" ); if ( testScalaPath.isDirectory() ) { String testScalaPathStr = testScalaPath.getAbsolutePath(); if ( !project.getTestCompileSourceRoots().contains( testScalaPathStr ) ) { project.addTestCompileSourceRoot( testScalaPathStr ); getLog().debug( "Added test source directory: " + testScalaPathStr ); } } }
java
@Override public void execute() { if ( "pom".equals( project.getPackaging() ) ) { return; } File baseDir = project.getBasedir(); File mainScalaPath = new File( baseDir, "src/main/scala" ); if ( mainScalaPath.isDirectory() ) { String mainScalaPathStr = mainScalaPath.getAbsolutePath(); if ( !project.getCompileSourceRoots().contains( mainScalaPathStr ) ) { project.addCompileSourceRoot( mainScalaPathStr ); getLog().debug( "Added source directory: " + mainScalaPathStr ); } } File testScalaPath = new File( baseDir, "src/test/scala" ); if ( testScalaPath.isDirectory() ) { String testScalaPathStr = testScalaPath.getAbsolutePath(); if ( !project.getTestCompileSourceRoots().contains( testScalaPathStr ) ) { project.addTestCompileSourceRoot( testScalaPathStr ); getLog().debug( "Added test source directory: " + testScalaPathStr ); } } }
[ "@", "Override", "public", "void", "execute", "(", ")", "{", "if", "(", "\"pom\"", ".", "equals", "(", "project", ".", "getPackaging", "(", ")", ")", ")", "{", "return", ";", "}", "File", "baseDir", "=", "project", ".", "getBasedir", "(", ")", ";", ...
Adds default Scala sources locations to Maven project. <ul> <li>{@code src/main/scala} is added to project's compile source roots</li> <li>{@code src/test/scala} is added to project's test compile source roots</li> </ul>
[ "Adds", "default", "Scala", "sources", "locations", "to", "Maven", "project", "." ]
cf8b8766956841c13f388eb311d214644dba9137
https://github.com/sbt-compiler-maven-plugin/sbt-compiler-maven-plugin/blob/cf8b8766956841c13f388eb311d214644dba9137/sbt-compiler-maven-plugin/src/main/java/com/google/code/sbt/compiler/plugin/SBTAddScalaSourcesMojo.java#L59-L90
train
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin
sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/Compilers.java
Compilers.getCacheDirectory
public static File getCacheDirectory( File classesDirectory ) { String classesDirectoryName = classesDirectory.getName(); String cacheDirectoryName = classesDirectoryName.replace( TEST_CLASSES, CACHE ).replace( CLASSES, CACHE ); return new File( classesDirectory.getParentFile(), cacheDirectoryName ); }
java
public static File getCacheDirectory( File classesDirectory ) { String classesDirectoryName = classesDirectory.getName(); String cacheDirectoryName = classesDirectoryName.replace( TEST_CLASSES, CACHE ).replace( CLASSES, CACHE ); return new File( classesDirectory.getParentFile(), cacheDirectoryName ); }
[ "public", "static", "File", "getCacheDirectory", "(", "File", "classesDirectory", ")", "{", "String", "classesDirectoryName", "=", "classesDirectory", ".", "getName", "(", ")", ";", "String", "cacheDirectoryName", "=", "classesDirectoryName", ".", "replace", "(", "T...
Returns directory for incremental compilation cache files. @param classesDirectory compilation output directory @return directory for incremental compilation cache files
[ "Returns", "directory", "for", "incremental", "compilation", "cache", "files", "." ]
cf8b8766956841c13f388eb311d214644dba9137
https://github.com/sbt-compiler-maven-plugin/sbt-compiler-maven-plugin/blob/cf8b8766956841c13f388eb311d214644dba9137/sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/Compilers.java#L84-L89
train
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin
sbt-compilers/sbt-compiler-sbt012/src/main/java/com/google/code/sbt/compiler/sbt012/SBT012Compiler.java
SBT012Compiler.getScalacProblems
private CompilationProblem[] getScalacProblems( Problem[] problems ) { CompilationProblem[] result = new CompilationProblem[problems.length]; for ( int i = 0; i < problems.length; i++ ) { Problem problem = problems[i]; Position position = problem.position(); Maybe<Integer> line = position.line(); String lineContent = position.lineContent(); Maybe<Integer> offset = position.offset(); Maybe<Integer> pointer = position.pointer(); Maybe<File> sourceFile = position.sourceFile(); SourcePosition sp = new DefaultSourcePosition( line.isDefined() ? line.get().intValue() : -1, lineContent, offset.isDefined() ? offset.get().intValue() : -1, pointer.isDefined() ? pointer.get().intValue() : -1, sourceFile.isDefined() ? sourceFile.get() : null ); result[i] = new DefaultCompilationProblem( problem.category(), problem.message(), sp, problem.severity().name() ); } return result; }
java
private CompilationProblem[] getScalacProblems( Problem[] problems ) { CompilationProblem[] result = new CompilationProblem[problems.length]; for ( int i = 0; i < problems.length; i++ ) { Problem problem = problems[i]; Position position = problem.position(); Maybe<Integer> line = position.line(); String lineContent = position.lineContent(); Maybe<Integer> offset = position.offset(); Maybe<Integer> pointer = position.pointer(); Maybe<File> sourceFile = position.sourceFile(); SourcePosition sp = new DefaultSourcePosition( line.isDefined() ? line.get().intValue() : -1, lineContent, offset.isDefined() ? offset.get().intValue() : -1, pointer.isDefined() ? pointer.get().intValue() : -1, sourceFile.isDefined() ? sourceFile.get() : null ); result[i] = new DefaultCompilationProblem( problem.category(), problem.message(), sp, problem.severity().name() ); } return result; }
[ "private", "CompilationProblem", "[", "]", "getScalacProblems", "(", "Problem", "[", "]", "problems", ")", "{", "CompilationProblem", "[", "]", "result", "=", "new", "CompilationProblem", "[", "problems", ".", "length", "]", ";", "for", "(", "int", "i", "=",...
scalac problems conversion
[ "scalac", "problems", "conversion" ]
cf8b8766956841c13f388eb311d214644dba9137
https://github.com/sbt-compiler-maven-plugin/sbt-compiler-maven-plugin/blob/cf8b8766956841c13f388eb311d214644dba9137/sbt-compilers/sbt-compiler-sbt012/src/main/java/com/google/code/sbt/compiler/sbt012/SBT012Compiler.java#L141-L163
train
qubole/qds-sdk-java
examples/src/main/java/com/qubole/qds/sdk/java/examples/SparkCommandExample.java
SparkCommandExample.submitScalaProgram
private static void submitScalaProgram(QdsClient client) throws Exception { String sampleProgram = "println(\"hello world\")"; SparkCommandBuilder sparkBuilder = client.command().spark(); // Give a name to the command. (Optional) sparkBuilder.name("spark-scala-test"); //Setting the program here sparkBuilder.program(sampleProgram); //setting the language here sparkBuilder.language("scala"); CommandResponse commandResponse = sparkBuilder.invoke().get(); ResultLatch resultLatch = new ResultLatch(client, commandResponse.getId()); ResultValue resultValue = resultLatch.awaitResult(); System.out.println(resultValue.getResults()); String s = client.command().logs("" + commandResponse.getId()).invoke().get(); System.err.println(s); }
java
private static void submitScalaProgram(QdsClient client) throws Exception { String sampleProgram = "println(\"hello world\")"; SparkCommandBuilder sparkBuilder = client.command().spark(); // Give a name to the command. (Optional) sparkBuilder.name("spark-scala-test"); //Setting the program here sparkBuilder.program(sampleProgram); //setting the language here sparkBuilder.language("scala"); CommandResponse commandResponse = sparkBuilder.invoke().get(); ResultLatch resultLatch = new ResultLatch(client, commandResponse.getId()); ResultValue resultValue = resultLatch.awaitResult(); System.out.println(resultValue.getResults()); String s = client.command().logs("" + commandResponse.getId()).invoke().get(); System.err.println(s); }
[ "private", "static", "void", "submitScalaProgram", "(", "QdsClient", "client", ")", "throws", "Exception", "{", "String", "sampleProgram", "=", "\"println(\\\"hello world\\\")\"", ";", "SparkCommandBuilder", "sparkBuilder", "=", "client", ".", "command", "(", ")", "."...
An Example of submitting Spark Command as a Scala program. Similarly, we can submit Spark Command as a SQL query, R program and Java program.
[ "An", "Example", "of", "submitting", "Spark", "Command", "as", "a", "Scala", "program", ".", "Similarly", "we", "can", "submit", "Spark", "Command", "as", "a", "SQL", "query", "R", "program", "and", "Java", "program", "." ]
c652374075c7b72071f73db960f5f3a43f922afd
https://github.com/qubole/qds-sdk-java/blob/c652374075c7b72071f73db960f5f3a43f922afd/examples/src/main/java/com/qubole/qds/sdk/java/examples/SparkCommandExample.java#L51-L72
train
qubole/qds-sdk-java
examples/src/main/java/com/qubole/qds/sdk/java/examples/SparkCommandExample.java
SparkCommandExample.submitSQLQuery
private static void submitSQLQuery(QdsClient client) throws Exception { String sampleSqlQuery = "select * from default_qubole_airline_origin_destination limit 100"; SparkCommandBuilder sparkBuilder = client.command().spark(); // Give a name to the command. (Optional) sparkBuilder.name("spark-sql-test"); // Setting the sql query sparkBuilder.sql(sampleSqlQuery); CommandResponse commandResponse = sparkBuilder.invoke().get(); ResultLatch resultLatch = new ResultLatch(client, commandResponse.getId()); ResultValue resultValue = resultLatch.awaitResult(); System.out.println(resultValue.getResults()); String s = client.command().logs("" + commandResponse.getId()).invoke().get(); System.err.println(s); }
java
private static void submitSQLQuery(QdsClient client) throws Exception { String sampleSqlQuery = "select * from default_qubole_airline_origin_destination limit 100"; SparkCommandBuilder sparkBuilder = client.command().spark(); // Give a name to the command. (Optional) sparkBuilder.name("spark-sql-test"); // Setting the sql query sparkBuilder.sql(sampleSqlQuery); CommandResponse commandResponse = sparkBuilder.invoke().get(); ResultLatch resultLatch = new ResultLatch(client, commandResponse.getId()); ResultValue resultValue = resultLatch.awaitResult(); System.out.println(resultValue.getResults()); String s = client.command().logs("" + commandResponse.getId()).invoke().get(); System.err.println(s); }
[ "private", "static", "void", "submitSQLQuery", "(", "QdsClient", "client", ")", "throws", "Exception", "{", "String", "sampleSqlQuery", "=", "\"select * from default_qubole_airline_origin_destination limit 100\"", ";", "SparkCommandBuilder", "sparkBuilder", "=", "client", "."...
An example of submitting Spark Command as a SQL query.
[ "An", "example", "of", "submitting", "Spark", "Command", "as", "a", "SQL", "query", "." ]
c652374075c7b72071f73db960f5f3a43f922afd
https://github.com/qubole/qds-sdk-java/blob/c652374075c7b72071f73db960f5f3a43f922afd/examples/src/main/java/com/qubole/qds/sdk/java/examples/SparkCommandExample.java#L77-L96
train
abego/treelayout
org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java
TreeLayout.secondWalk
private void secondWalk(TreeNode v, double m, int level, double levelStart) { // construct the position from the prelim and the level information // The rootLocation affects the way how x and y are changed and in what // direction. double levelChangeSign = getLevelChangeSign(); boolean levelChangeOnYAxis = isLevelChangeInYAxis(); double levelSize = getSizeOfLevel(level); double x = getPrelim(v) + m; double y; AlignmentInLevel alignment = configuration.getAlignmentInLevel(); if (alignment == AlignmentInLevel.Center) { y = levelStart + levelChangeSign * (levelSize / 2); } else if (alignment == AlignmentInLevel.TowardsRoot) { y = levelStart + levelChangeSign * (getNodeThickness(v) / 2); } else { y = levelStart + levelSize - levelChangeSign * (getNodeThickness(v) / 2); } if (!levelChangeOnYAxis) { double t = x; x = y; y = t; } positions.put(v, new NormalizedPosition(x, y)); // update the bounds updateBounds(v, x, y); // recurse if (!tree.isLeaf(v)) { double nextLevelStart = levelStart + (levelSize + configuration.getGapBetweenLevels(level + 1)) * levelChangeSign; for (TreeNode w : tree.getChildren(v)) { secondWalk(w, m + getMod(v), level + 1, nextLevelStart); } } }
java
private void secondWalk(TreeNode v, double m, int level, double levelStart) { // construct the position from the prelim and the level information // The rootLocation affects the way how x and y are changed and in what // direction. double levelChangeSign = getLevelChangeSign(); boolean levelChangeOnYAxis = isLevelChangeInYAxis(); double levelSize = getSizeOfLevel(level); double x = getPrelim(v) + m; double y; AlignmentInLevel alignment = configuration.getAlignmentInLevel(); if (alignment == AlignmentInLevel.Center) { y = levelStart + levelChangeSign * (levelSize / 2); } else if (alignment == AlignmentInLevel.TowardsRoot) { y = levelStart + levelChangeSign * (getNodeThickness(v) / 2); } else { y = levelStart + levelSize - levelChangeSign * (getNodeThickness(v) / 2); } if (!levelChangeOnYAxis) { double t = x; x = y; y = t; } positions.put(v, new NormalizedPosition(x, y)); // update the bounds updateBounds(v, x, y); // recurse if (!tree.isLeaf(v)) { double nextLevelStart = levelStart + (levelSize + configuration.getGapBetweenLevels(level + 1)) * levelChangeSign; for (TreeNode w : tree.getChildren(v)) { secondWalk(w, m + getMod(v), level + 1, nextLevelStart); } } }
[ "private", "void", "secondWalk", "(", "TreeNode", "v", ",", "double", "m", ",", "int", "level", ",", "double", "levelStart", ")", "{", "// construct the position from the prelim and the level information", "// The rootLocation affects the way how x and y are changed and in what",...
In difference to the original algorithm we also pass in extra level information. @param v @param m @param level @param levelStart
[ "In", "difference", "to", "the", "original", "algorithm", "we", "also", "pass", "in", "extra", "level", "information", "." ]
aa73af5803c6ec30db0b4ad192c7cba55d0862d2
https://github.com/abego/treelayout/blob/aa73af5803c6ec30db0b4ad192c7cba55d0862d2/org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java#L642-L684
train
abego/treelayout
org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java
TreeLayout.dumpTree
public void dumpTree(PrintStream printStream, DumpConfiguration dumpConfiguration) { dumpTree(printStream,tree.getRoot(),0, dumpConfiguration); }
java
public void dumpTree(PrintStream printStream, DumpConfiguration dumpConfiguration) { dumpTree(printStream,tree.getRoot(),0, dumpConfiguration); }
[ "public", "void", "dumpTree", "(", "PrintStream", "printStream", ",", "DumpConfiguration", "dumpConfiguration", ")", "{", "dumpTree", "(", "printStream", ",", "tree", ".", "getRoot", "(", ")", ",", "0", ",", "dumpConfiguration", ")", ";", "}" ]
Prints a dump of the tree to the given printStream, using the node's "toString" method. @param printStream &nbsp; @param dumpConfiguration [default: new DumpConfiguration()]
[ "Prints", "a", "dump", "of", "the", "tree", "to", "the", "given", "printStream", "using", "the", "node", "s", "toString", "method", "." ]
aa73af5803c6ec30db0b4ad192c7cba55d0862d2
https://github.com/abego/treelayout/blob/aa73af5803c6ec30db0b4ad192c7cba55d0862d2/org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java#L894-L896
train
abego/treelayout
org.abego.treelayout.demo/src/main/java/org/abego/treelayout/demo/svg/SVGUtil.java
SVGUtil.main
public static void main(String[] args) throws IOException { String s = doc(svg( 160, 200, rect(0, 0, 160, 200, "fill:red;") + svg(10, 10, 100, 100, rect(0, 0, 100, 100, "fill:orange; stroke:rgb(0,0,0);")) + line(20, 20, 100, 100, "stroke:black; stroke-width:2px;") + line(20, 100, 100, 20, "stroke:black; stroke-width:2px;") + text(10, 140, "font-family:verdana; font-size:20px; font-weight:bold;", "Hello world"))); File file = new File("demo.svg"); FileWriter w = null; try { w = new FileWriter(file); w.write(s); } finally { if (w != null) { w.close(); } } System.out.println(String.format("File written: %s", file.getAbsolutePath())); // optionally view the just created file if (args.length > 0 && args[0].equals("-view")) { if (!viewSVG(file)) { System.err.println("'-view' not supported on this platform"); } } }
java
public static void main(String[] args) throws IOException { String s = doc(svg( 160, 200, rect(0, 0, 160, 200, "fill:red;") + svg(10, 10, 100, 100, rect(0, 0, 100, 100, "fill:orange; stroke:rgb(0,0,0);")) + line(20, 20, 100, 100, "stroke:black; stroke-width:2px;") + line(20, 100, 100, 20, "stroke:black; stroke-width:2px;") + text(10, 140, "font-family:verdana; font-size:20px; font-weight:bold;", "Hello world"))); File file = new File("demo.svg"); FileWriter w = null; try { w = new FileWriter(file); w.write(s); } finally { if (w != null) { w.close(); } } System.out.println(String.format("File written: %s", file.getAbsolutePath())); // optionally view the just created file if (args.length > 0 && args[0].equals("-view")) { if (!viewSVG(file)) { System.err.println("'-view' not supported on this platform"); } } }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "IOException", "{", "String", "s", "=", "doc", "(", "svg", "(", "160", ",", "200", ",", "rect", "(", "0", ",", "0", ",", "160", ",", "200", ",", "\"fill:red;\"", ...
Creates a sample SVG file "demo.svg" @param args option '-view': view the just created file (may not be supported on all platforms) @throws IOException &nbsp;
[ "Creates", "a", "sample", "SVG", "file", "demo", ".", "svg" ]
aa73af5803c6ec30db0b4ad192c7cba55d0862d2
https://github.com/abego/treelayout/blob/aa73af5803c6ec30db0b4ad192c7cba55d0862d2/org.abego.treelayout.demo/src/main/java/org/abego/treelayout/demo/svg/SVGUtil.java#L218-L257
train
qubole/qds-sdk-java
src/main/java/com/qubole/qds/sdk/java/client/ResultStreamer.java
ResultStreamer.getResults
public Reader getResults(ResultValue resultValue) throws Exception { if (resultValue.isInline()) { return new StringReader(resultValue.getResults()); } return readFromS3(resultValue.getResult_location()); }
java
public Reader getResults(ResultValue resultValue) throws Exception { if (resultValue.isInline()) { return new StringReader(resultValue.getResults()); } return readFromS3(resultValue.getResult_location()); }
[ "public", "Reader", "getResults", "(", "ResultValue", "resultValue", ")", "throws", "Exception", "{", "if", "(", "resultValue", ".", "isInline", "(", ")", ")", "{", "return", "new", "StringReader", "(", "resultValue", ".", "getResults", "(", ")", ")", ";", ...
Return a stream over the given results. If the results are not inline, the results will come from S3 @param resultValue result @return stream @throws Exception errors
[ "Return", "a", "stream", "over", "the", "given", "results", ".", "If", "the", "results", "are", "not", "inline", "the", "results", "will", "come", "from", "S3" ]
c652374075c7b72071f73db960f5f3a43f922afd
https://github.com/qubole/qds-sdk-java/blob/c652374075c7b72071f73db960f5f3a43f922afd/src/main/java/com/qubole/qds/sdk/java/client/ResultStreamer.java#L81-L89
train
qubole/qds-sdk-java
src/main/java/com/qubole/qds/sdk/java/details/CompositeCommandBuilderImpl.java
CompositeCommandBuilderImpl.checkCommandTypeSupported
private boolean checkCommandTypeSupported(BaseCommand command) { // for command type none or composite // we dont support adding it as base command if ((command.getCommandType() == BaseCommand.COMMAND_TYPE.NONE) || (command.getCommandType() == BaseCommand.COMMAND_TYPE.COMPOSITE)) { return false; } return true; }
java
private boolean checkCommandTypeSupported(BaseCommand command) { // for command type none or composite // we dont support adding it as base command if ((command.getCommandType() == BaseCommand.COMMAND_TYPE.NONE) || (command.getCommandType() == BaseCommand.COMMAND_TYPE.COMPOSITE)) { return false; } return true; }
[ "private", "boolean", "checkCommandTypeSupported", "(", "BaseCommand", "command", ")", "{", "// for command type none or composite", "// we dont support adding it as base command", "if", "(", "(", "command", ".", "getCommandType", "(", ")", "==", "BaseCommand", ".", "COMMAN...
workflow or not
[ "workflow", "or", "not" ]
c652374075c7b72071f73db960f5f3a43f922afd
https://github.com/qubole/qds-sdk-java/blob/c652374075c7b72071f73db960f5f3a43f922afd/src/main/java/com/qubole/qds/sdk/java/details/CompositeCommandBuilderImpl.java#L79-L89
train
abego/treelayout
org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/string/StringUtil.java
StringUtil.quote
public static String quote(String s, String nullResult) { if (s == null) { return nullResult; } StringBuffer result = new StringBuffer(); result.append('"'); int length = s.length(); for (int i = 0; i < length; i++) { char c = s.charAt(i); switch (c) { case '\b': { result.append("\\b"); break; } case '\f': { result.append("\\f"); break; } case '\n': { result.append("\\n"); break; } case '\r': { result.append("\\r"); break; } case '\t': { result.append("\\t"); break; } case '\\': { result.append("\\\\"); break; } case '"': { result.append("\\\""); break; } default: { if (c < ' ' || c >= '\u0080') { String n = Integer.toHexString(c); result.append("\\u"); result.append("0000".substring(n.length())); result.append(n); } else { result.append(c); } } } } result.append('"'); return result.toString(); }
java
public static String quote(String s, String nullResult) { if (s == null) { return nullResult; } StringBuffer result = new StringBuffer(); result.append('"'); int length = s.length(); for (int i = 0; i < length; i++) { char c = s.charAt(i); switch (c) { case '\b': { result.append("\\b"); break; } case '\f': { result.append("\\f"); break; } case '\n': { result.append("\\n"); break; } case '\r': { result.append("\\r"); break; } case '\t': { result.append("\\t"); break; } case '\\': { result.append("\\\\"); break; } case '"': { result.append("\\\""); break; } default: { if (c < ' ' || c >= '\u0080') { String n = Integer.toHexString(c); result.append("\\u"); result.append("0000".substring(n.length())); result.append(n); } else { result.append(c); } } } } result.append('"'); return result.toString(); }
[ "public", "static", "String", "quote", "(", "String", "s", ",", "String", "nullResult", ")", "{", "if", "(", "s", "==", "null", ")", "{", "return", "nullResult", ";", "}", "StringBuffer", "result", "=", "new", "StringBuffer", "(", ")", ";", "result", "...
Returns a quoted version of a given string, i.e. as a Java String Literal. @param s [nullable] the string to quote @param nullResult [default="null"] the String to be returned for null values. @return the nullResult when s is null, otherwise s as a quoted string (i.e. Java String Literal)
[ "Returns", "a", "quoted", "version", "of", "a", "given", "string", "i", ".", "e", ".", "as", "a", "Java", "String", "Literal", "." ]
aa73af5803c6ec30db0b4ad192c7cba55d0862d2
https://github.com/abego/treelayout/blob/aa73af5803c6ec30db0b4ad192c7cba55d0862d2/org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/string/StringUtil.java#L45-L97
train
digitalheir/java-xml-to-json
src/main/java/org/leibnizcenter/xml/TerseJson.java
TerseJson.parse
public static Document parse(JsonReader reader) throws IOException, NotImplemented { reader.beginArray(); int nodeType = reader.nextInt(); CoreDocumentImpl doc = new DocumentImpl(); if (nodeType == Node.ELEMENT_NODE) { addInitialElement(reader, doc); } else if (nodeType == Node.DOCUMENT_NODE) { addInitialDocNode(doc, reader); } else { throw new IllegalStateException("Don't know how to handle root node with type " + nodeType); } reader.endArray(); return doc; }
java
public static Document parse(JsonReader reader) throws IOException, NotImplemented { reader.beginArray(); int nodeType = reader.nextInt(); CoreDocumentImpl doc = new DocumentImpl(); if (nodeType == Node.ELEMENT_NODE) { addInitialElement(reader, doc); } else if (nodeType == Node.DOCUMENT_NODE) { addInitialDocNode(doc, reader); } else { throw new IllegalStateException("Don't know how to handle root node with type " + nodeType); } reader.endArray(); return doc; }
[ "public", "static", "Document", "parse", "(", "JsonReader", "reader", ")", "throws", "IOException", ",", "NotImplemented", "{", "reader", ".", "beginArray", "(", ")", ";", "int", "nodeType", "=", "reader", ".", "nextInt", "(", ")", ";", "CoreDocumentImpl", "...
First element must be a document node or element node @param reader JSON stream @return XML document
[ "First", "element", "must", "be", "a", "document", "node", "or", "element", "node" ]
94b4cef671bea9b79fb6daa685cd5bf78c222179
https://github.com/digitalheir/java-xml-to-json/blob/94b4cef671bea9b79fb6daa685cd5bf78c222179/src/main/java/org/leibnizcenter/xml/TerseJson.java#L35-L51
train
digitalheir/java-xml-to-json
src/main/java/org/leibnizcenter/xml/TerseJson.java
TerseJson.toXml
public Document toXml(InputStream json) throws IOException, NotImplemented { JsonReader reader = null; try { reader = new JsonReader(new InputStreamReader(json, "utf-8")); return parse(reader); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e); } finally { if (reader != null) reader.close(); if (json != null) json.close(); } }
java
public Document toXml(InputStream json) throws IOException, NotImplemented { JsonReader reader = null; try { reader = new JsonReader(new InputStreamReader(json, "utf-8")); return parse(reader); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e); } finally { if (reader != null) reader.close(); if (json != null) json.close(); } }
[ "public", "Document", "toXml", "(", "InputStream", "json", ")", "throws", "IOException", ",", "NotImplemented", "{", "JsonReader", "reader", "=", "null", ";", "try", "{", "reader", "=", "new", "JsonReader", "(", "new", "InputStreamReader", "(", "json", ",", ...
First element must be a document @param json JSON stream @return XML document
[ "First", "element", "must", "be", "a", "document" ]
94b4cef671bea9b79fb6daa685cd5bf78c222179
https://github.com/digitalheir/java-xml-to-json/blob/94b4cef671bea9b79fb6daa685cd5bf78c222179/src/main/java/org/leibnizcenter/xml/TerseJson.java#L214-L225
train
zalando-stups/booties
misc/github-client-parent/github-client-spring/src/main/java/org/zalando/github/spring/StatusesTemplate.java
StatusesTemplate.getCombinedStatus
@Override public CombinedStatus getCombinedStatus(String owner, String repository, String ref) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repository", repository); uriVariables.put("ref", ref); return getRestOperations().exchange(buildUri("/repos/{owner}/{repository}/commits/{ref}/status", uriVariables), HttpMethod.GET, null, CombinedStatus.class).getBody(); }
java
@Override public CombinedStatus getCombinedStatus(String owner, String repository, String ref) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repository", repository); uriVariables.put("ref", ref); return getRestOperations().exchange(buildUri("/repos/{owner}/{repository}/commits/{ref}/status", uriVariables), HttpMethod.GET, null, CombinedStatus.class).getBody(); }
[ "@", "Override", "public", "CombinedStatus", "getCombinedStatus", "(", "String", "owner", ",", "String", "repository", ",", "String", "ref", ")", "{", "Map", "<", "String", ",", "Object", ">", "uriVariables", "=", "new", "HashMap", "<>", "(", ")", ";", "ur...
'ref' can be SHA, branch or tag.
[ "ref", "can", "be", "SHA", "branch", "or", "tag", "." ]
4147ceccfa3c1b0139df86d86bd10f673b05549f
https://github.com/zalando-stups/booties/blob/4147ceccfa3c1b0139df86d86bd10f673b05549f/misc/github-client-parent/github-client-spring/src/main/java/org/zalando/github/spring/StatusesTemplate.java#L73-L82
train
tdomzal/junit-docker-rule
src/main/java/pl/domzal/junit/docker/rule/DockerRule.java
DockerRule.waitForLogMessage
public void waitForLogMessage(final String logSearchString, int waitTime) throws TimeoutException { WaitForContainer.waitForCondition(new LogChecker(this, logSearchString), waitTime, describe()); }
java
public void waitForLogMessage(final String logSearchString, int waitTime) throws TimeoutException { WaitForContainer.waitForCondition(new LogChecker(this, logSearchString), waitTime, describe()); }
[ "public", "void", "waitForLogMessage", "(", "final", "String", "logSearchString", ",", "int", "waitTime", ")", "throws", "TimeoutException", "{", "WaitForContainer", ".", "waitForCondition", "(", "new", "LogChecker", "(", "this", ",", "logSearchString", ")", ",", ...
Stop and wait till given string will show in container output. @param logSearchString String to wait for in container output. @param waitTime Wait time. @throws TimeoutException On wait timeout.
[ "Stop", "and", "wait", "till", "given", "string", "will", "show", "in", "container", "output", "." ]
5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2
https://github.com/tdomzal/junit-docker-rule/blob/5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2/src/main/java/pl/domzal/junit/docker/rule/DockerRule.java#L361-L363
train
tdomzal/junit-docker-rule
src/main/java/pl/domzal/junit/docker/rule/DockerRule.java
DockerRule.waitForExit
public void waitForExit() throws InterruptedException { try { dockerClient.waitContainer(container.id()); } catch (DockerException e) { throw new IllegalStateException(e); } }
java
public void waitForExit() throws InterruptedException { try { dockerClient.waitContainer(container.id()); } catch (DockerException e) { throw new IllegalStateException(e); } }
[ "public", "void", "waitForExit", "(", ")", "throws", "InterruptedException", "{", "try", "{", "dockerClient", ".", "waitContainer", "(", "container", ".", "id", "(", ")", ")", ";", "}", "catch", "(", "DockerException", "e", ")", "{", "throw", "new", "Illeg...
Block until container exit.
[ "Block", "until", "container", "exit", "." ]
5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2
https://github.com/tdomzal/junit-docker-rule/blob/5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2/src/main/java/pl/domzal/junit/docker/rule/DockerRule.java#L368-L374
train
tdomzal/junit-docker-rule
src/main/java/pl/domzal/junit/docker/rule/DockerRule.java
DockerRule.getLog
public String getLog() { try (LogStream stream = dockerClient.logs(container.id(), LogsParam.stdout(), LogsParam.stderr());) { String fullLog = stream.readFully(); if (log.isTraceEnabled()) { log.trace("{} full log: {}", containerShortId, StringUtils.replace(fullLog, "\n", "|")); } return fullLog; } catch (DockerException | InterruptedException e) { throw new IllegalStateException(e); } }
java
public String getLog() { try (LogStream stream = dockerClient.logs(container.id(), LogsParam.stdout(), LogsParam.stderr());) { String fullLog = stream.readFully(); if (log.isTraceEnabled()) { log.trace("{} full log: {}", containerShortId, StringUtils.replace(fullLog, "\n", "|")); } return fullLog; } catch (DockerException | InterruptedException e) { throw new IllegalStateException(e); } }
[ "public", "String", "getLog", "(", ")", "{", "try", "(", "LogStream", "stream", "=", "dockerClient", ".", "logs", "(", "container", ".", "id", "(", ")", ",", "LogsParam", ".", "stdout", "(", ")", ",", "LogsParam", ".", "stderr", "(", ")", ")", ";", ...
Container log.
[ "Container", "log", "." ]
5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2
https://github.com/tdomzal/junit-docker-rule/blob/5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2/src/main/java/pl/domzal/junit/docker/rule/DockerRule.java#L379-L390
train
tdomzal/junit-docker-rule
src/main/java/pl/domzal/junit/docker/rule/DockerRuleBuilder.java
DockerRuleBuilder.keepContainer
public DockerRuleBuilder keepContainer(boolean keepContainer) { if (keepContainer) { this.stopOptions.setOptions(StopOption.KEEP); } else { this.stopOptions.setOptions(StopOption.REMOVE); } return this; }
java
public DockerRuleBuilder keepContainer(boolean keepContainer) { if (keepContainer) { this.stopOptions.setOptions(StopOption.KEEP); } else { this.stopOptions.setOptions(StopOption.REMOVE); } return this; }
[ "public", "DockerRuleBuilder", "keepContainer", "(", "boolean", "keepContainer", ")", "{", "if", "(", "keepContainer", ")", "{", "this", ".", "stopOptions", ".", "setOptions", "(", "StopOption", ".", "KEEP", ")", ";", "}", "else", "{", "this", ".", "stopOpti...
Keep stopped container after test. @deprecated Use {@link #stopOptions(StopOption...)} instead.
[ "Keep", "stopped", "container", "after", "test", "." ]
5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2
https://github.com/tdomzal/junit-docker-rule/blob/5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2/src/main/java/pl/domzal/junit/docker/rule/DockerRuleBuilder.java#L153-L160
train
tdomzal/junit-docker-rule
src/main/java/pl/domzal/junit/docker/rule/DockerRuleBuilder.java
DockerRuleBuilder.env
public DockerRuleBuilder env(String envName, String envValue) { env.add(String.format("%s=%s", envName, envValue)); return this; }
java
public DockerRuleBuilder env(String envName, String envValue) { env.add(String.format("%s=%s", envName, envValue)); return this; }
[ "public", "DockerRuleBuilder", "env", "(", "String", "envName", ",", "String", "envValue", ")", "{", "env", ".", "add", "(", "String", ".", "format", "(", "\"%s=%s\"", ",", "envName", ",", "envValue", ")", ")", ";", "return", "this", ";", "}" ]
Set environment variable in the container.
[ "Set", "environment", "variable", "in", "the", "container", "." ]
5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2
https://github.com/tdomzal/junit-docker-rule/blob/5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2/src/main/java/pl/domzal/junit/docker/rule/DockerRuleBuilder.java#L209-L212
train
tdomzal/junit-docker-rule
src/main/java/pl/domzal/junit/docker/rule/WaitForContainer.java
WaitForContainer.waitForCondition
static void waitForCondition(final StartConditionCheck condition, int timeoutSeconds, final String containerDescription) throws TimeoutException { try { log.info("wait for {} started", condition.describe()); new WaitForUnit(TimeUnit.SECONDS, timeoutSeconds, TimeUnit.SECONDS, 1, new WaitForUnit.WaitForCondition() { @Override public boolean isConditionMet() { return condition.check(); } @Override public String timeoutMessage() { return String.format("timeout waiting for %s in container %s", condition.describe(), containerDescription); } }).startWaiting(); log.info("wait for {} - condition met", condition.describe()); } catch (InterruptedException e) { throw new IllegalStateException(String.format("Interrupted while waiting for %s", condition.describe()), e); } }
java
static void waitForCondition(final StartConditionCheck condition, int timeoutSeconds, final String containerDescription) throws TimeoutException { try { log.info("wait for {} started", condition.describe()); new WaitForUnit(TimeUnit.SECONDS, timeoutSeconds, TimeUnit.SECONDS, 1, new WaitForUnit.WaitForCondition() { @Override public boolean isConditionMet() { return condition.check(); } @Override public String timeoutMessage() { return String.format("timeout waiting for %s in container %s", condition.describe(), containerDescription); } }).startWaiting(); log.info("wait for {} - condition met", condition.describe()); } catch (InterruptedException e) { throw new IllegalStateException(String.format("Interrupted while waiting for %s", condition.describe()), e); } }
[ "static", "void", "waitForCondition", "(", "final", "StartConditionCheck", "condition", ",", "int", "timeoutSeconds", ",", "final", "String", "containerDescription", ")", "throws", "TimeoutException", "{", "try", "{", "log", ".", "info", "(", "\"wait for {} started\""...
Wait till all given conditions are met. @param condition Conditions to wait for - all must be met to continue. @param timeoutSeconds Wait timeout. @param containerDescription Container description. For log and exception message usage only.
[ "Wait", "till", "all", "given", "conditions", "are", "met", "." ]
5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2
https://github.com/tdomzal/junit-docker-rule/blob/5a0ba2fd095d201530d3f9e614bc5e88d0afaeb2/src/main/java/pl/domzal/junit/docker/rule/WaitForContainer.java#L25-L42
train
paymill/paymill-java
src/main/java/com/paymill/services/ClientService.java
ClientService.update
public void update( Client client ) { RestfulUtils.update( ClientService.PATH, client, Client.class, super.httpClient ); }
java
public void update( Client client ) { RestfulUtils.update( ClientService.PATH, client, Client.class, super.httpClient ); }
[ "public", "void", "update", "(", "Client", "client", ")", "{", "RestfulUtils", ".", "update", "(", "ClientService", ".", "PATH", ",", "client", ",", "Client", ".", "class", ",", "super", ".", "httpClient", ")", ";", "}" ]
This function updates the data of a client. To change only a specific attribute you can set this attribute in the update request. All other attributes that should not be edited are not inserted. You can only edit the description, email and credit card. The subscription can not be changed by updating the client data. This has to be done in the subscription call. @param client A {@link Client} with Id.
[ "This", "function", "updates", "the", "data", "of", "a", "client", ".", "To", "change", "only", "a", "specific", "attribute", "you", "can", "set", "this", "attribute", "in", "the", "update", "request", ".", "All", "other", "attributes", "that", "should", "...
17281a0d4376c76f1711af9f09bfc138c90ba65a
https://github.com/paymill/paymill-java/blob/17281a0d4376c76f1711af9f09bfc138c90ba65a/src/main/java/com/paymill/services/ClientService.java#L149-L151
train
paymill/paymill-java
src/main/java/com/paymill/services/ClientService.java
ClientService.delete
public void delete( Client client ) { RestfulUtils.delete( ClientService.PATH, client, Client.class, super.httpClient ); }
java
public void delete( Client client ) { RestfulUtils.delete( ClientService.PATH, client, Client.class, super.httpClient ); }
[ "public", "void", "delete", "(", "Client", "client", ")", "{", "RestfulUtils", ".", "delete", "(", "ClientService", ".", "PATH", ",", "client", ",", "Client", ".", "class", ",", "super", ".", "httpClient", ")", ";", "}" ]
This function deletes a client, but its transactions are not deleted. @param client A {@link Client} with Id.
[ "This", "function", "deletes", "a", "client", "but", "its", "transactions", "are", "not", "deleted", "." ]
17281a0d4376c76f1711af9f09bfc138c90ba65a
https://github.com/paymill/paymill-java/blob/17281a0d4376c76f1711af9f09bfc138c90ba65a/src/main/java/com/paymill/services/ClientService.java#L158-L160
train
paymill/paymill-java
src/main/java/com/paymill/services/PreauthorizationService.java
PreauthorizationService.delete
public void delete( final Preauthorization preauthorization ) { RestfulUtils.delete( PreauthorizationService.PATH, preauthorization, Preauthorization.class, super.httpClient ); }
java
public void delete( final Preauthorization preauthorization ) { RestfulUtils.delete( PreauthorizationService.PATH, preauthorization, Preauthorization.class, super.httpClient ); }
[ "public", "void", "delete", "(", "final", "Preauthorization", "preauthorization", ")", "{", "RestfulUtils", ".", "delete", "(", "PreauthorizationService", ".", "PATH", ",", "preauthorization", ",", "Preauthorization", ".", "class", ",", "super", ".", "httpClient", ...
This function deletes a preauthorization. @param preauthorization The {@link Preauthorization} object to be deleted.
[ "This", "function", "deletes", "a", "preauthorization", "." ]
17281a0d4376c76f1711af9f09bfc138c90ba65a
https://github.com/paymill/paymill-java/blob/17281a0d4376c76f1711af9f09bfc138c90ba65a/src/main/java/com/paymill/services/PreauthorizationService.java#L196-L198
train
paymill/paymill-java
src/main/java/com/paymill/services/OfferService.java
OfferService.delete
public void delete(Offer offer, boolean removeWithSubscriptions) { ParameterMap<String, String> params = new ParameterMap<String, String>(); params.add("remove_with_subscriptions", String.valueOf(removeWithSubscriptions)); RestfulUtils.delete(OfferService.PATH, offer, params, Offer.class, super.httpClient); }
java
public void delete(Offer offer, boolean removeWithSubscriptions) { ParameterMap<String, String> params = new ParameterMap<String, String>(); params.add("remove_with_subscriptions", String.valueOf(removeWithSubscriptions)); RestfulUtils.delete(OfferService.PATH, offer, params, Offer.class, super.httpClient); }
[ "public", "void", "delete", "(", "Offer", "offer", ",", "boolean", "removeWithSubscriptions", ")", "{", "ParameterMap", "<", "String", ",", "String", ">", "params", "=", "new", "ParameterMap", "<", "String", ",", "String", ">", "(", ")", ";", "params", "."...
Remove an offer. @param offer the {@link Offer}. @param removeWithSubscriptions if true, the plan and all subscriptions associated with it will be deleted. If false, only the plan will be deleted.
[ "Remove", "an", "offer", "." ]
17281a0d4376c76f1711af9f09bfc138c90ba65a
https://github.com/paymill/paymill-java/blob/17281a0d4376c76f1711af9f09bfc138c90ba65a/src/main/java/com/paymill/services/OfferService.java#L193-L197
train
apptik/JustJson
json-schema/src/main/java/io/apptik/json/schema/Schema.java
Schema.setId
public <O extends Schema> O setId(String schemaId) { getJson().put("id", schemaId); return (O)this; }
java
public <O extends Schema> O setId(String schemaId) { getJson().put("id", schemaId); return (O)this; }
[ "public", "<", "O", "extends", "Schema", ">", "O", "setId", "(", "String", "schemaId", ")", "{", "getJson", "(", ")", ".", "put", "(", "\"id\"", ",", "schemaId", ")", ";", "return", "(", "O", ")", "this", ";", "}" ]
Should be URI @param schemaId @param <O> @return
[ "Should", "be", "URI" ]
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-schema/src/main/java/io/apptik/json/schema/Schema.java#L245-L248
train
apptik/JustJson
json-schema/src/main/java/io/apptik/json/schema/validation/CommonMatchers.java
CommonMatchers.withCharsLessOrEqualTo
public static Matcher<JsonElement> withCharsLessOrEqualTo(final int value) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { //we do not care for the properties if parent item is not String if (!item.isString()) return true; if (item.asString().length() > value) { mismatchDescription.appendText("String length more than maximum value: " + value); return false; } return true; } @Override public void describeTo(Description description) { description.appendText("String maximum length"); } }; }
java
public static Matcher<JsonElement> withCharsLessOrEqualTo(final int value) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { //we do not care for the properties if parent item is not String if (!item.isString()) return true; if (item.asString().length() > value) { mismatchDescription.appendText("String length more than maximum value: " + value); return false; } return true; } @Override public void describeTo(Description description) { description.appendText("String maximum length"); } }; }
[ "public", "static", "Matcher", "<", "JsonElement", ">", "withCharsLessOrEqualTo", "(", "final", "int", "value", ")", "{", "return", "new", "TypeSafeDiagnosingMatcher", "<", "JsonElement", ">", "(", ")", "{", "@", "Override", "protected", "boolean", "matchesSafely"...
==> STRING ==>
[ "==", ">", "STRING", "==", ">" ]
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-schema/src/main/java/io/apptik/json/schema/validation/CommonMatchers.java#L40-L59
train
apptik/JustJson
json-schema/src/main/java/io/apptik/json/schema/validation/CommonMatchers.java
CommonMatchers.isOfType
public static Matcher<JsonElement> isOfType(final String type) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { if (type.equals(item.getJsonType())) return true; else { mismatchDescription.appendText(", mismatch type '" + item.getJsonType() + "'"); return false; } } @Override public void describeTo(Description description) { description.appendText("\nMatch to type: " + type); } }; }
java
public static Matcher<JsonElement> isOfType(final String type) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { if (type.equals(item.getJsonType())) return true; else { mismatchDescription.appendText(", mismatch type '" + item.getJsonType() + "'"); return false; } } @Override public void describeTo(Description description) { description.appendText("\nMatch to type: " + type); } }; }
[ "public", "static", "Matcher", "<", "JsonElement", ">", "isOfType", "(", "final", "String", "type", ")", "{", "return", "new", "TypeSafeDiagnosingMatcher", "<", "JsonElement", ">", "(", ")", "{", "@", "Override", "protected", "boolean", "matchesSafely", "(", "...
==> COMMON ==>
[ "==", ">", "COMMON", "==", ">" ]
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-schema/src/main/java/io/apptik/json/schema/validation/CommonMatchers.java#L220-L237
train
apptik/JustJson
json-schema/src/main/java/io/apptik/json/schema/validation/CommonMatchers.java
CommonMatchers.areItemsValid
public static Matcher<JsonElement> areItemsValid(final Validator validator) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { //we do not care for the properties if parent item is not JsonArray if (!item.isJsonArray()) return true; for (int i = 0; i < item.asJsonArray().length(); i++) { StringBuilder sb = new StringBuilder(); if (!validator.validate(item.asJsonArray().opt(i), sb)) { mismatchDescription.appendText("item at pos: " + i + ", does not validate by validator " + validator.getTitle()) .appendText("\nDetails: ") .appendText(sb.toString()); return false; } } return true; } @Override public void describeTo(Description description) { description.appendText("are array items valid"); } }; }
java
public static Matcher<JsonElement> areItemsValid(final Validator validator) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { //we do not care for the properties if parent item is not JsonArray if (!item.isJsonArray()) return true; for (int i = 0; i < item.asJsonArray().length(); i++) { StringBuilder sb = new StringBuilder(); if (!validator.validate(item.asJsonArray().opt(i), sb)) { mismatchDescription.appendText("item at pos: " + i + ", does not validate by validator " + validator.getTitle()) .appendText("\nDetails: ") .appendText(sb.toString()); return false; } } return true; } @Override public void describeTo(Description description) { description.appendText("are array items valid"); } }; }
[ "public", "static", "Matcher", "<", "JsonElement", ">", "areItemsValid", "(", "final", "Validator", "validator", ")", "{", "return", "new", "TypeSafeDiagnosingMatcher", "<", "JsonElement", ">", "(", ")", "{", "@", "Override", "protected", "boolean", "matchesSafely...
==> ARRAY ==>
[ "==", ">", "ARRAY", "==", ">" ]
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-schema/src/main/java/io/apptik/json/schema/validation/CommonMatchers.java#L282-L306
train
apptik/JustJson
json-schema/src/main/java/io/apptik/json/schema/validation/CommonMatchers.java
CommonMatchers.maxProperties
public static Matcher<JsonElement> maxProperties(final int maxProperties) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { //we do not care for the properties if parent item is not JsonObject if (!item.isJsonObject()) return true; if (item.asJsonObject().length() > maxProperties) { mismatchDescription.appendText("properties in Json object more than defined"); return false; } return true; } @Override public void describeTo(Description description) { description.appendText("object properties max count"); } }; }
java
public static Matcher<JsonElement> maxProperties(final int maxProperties) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { //we do not care for the properties if parent item is not JsonObject if (!item.isJsonObject()) return true; if (item.asJsonObject().length() > maxProperties) { mismatchDescription.appendText("properties in Json object more than defined"); return false; } return true; } @Override public void describeTo(Description description) { description.appendText("object properties max count"); } }; }
[ "public", "static", "Matcher", "<", "JsonElement", ">", "maxProperties", "(", "final", "int", "maxProperties", ")", "{", "return", "new", "TypeSafeDiagnosingMatcher", "<", "JsonElement", ">", "(", ")", "{", "@", "Override", "protected", "boolean", "matchesSafely",...
==> OBJECT ==>
[ "==", ">", "OBJECT", "==", ">" ]
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-schema/src/main/java/io/apptik/json/schema/validation/CommonMatchers.java#L426-L447
train
apptik/JustJson
json-core/src/main/java/io/apptik/json/JsonElement.java
JsonElement.wrap
public static JsonElement wrap(Object o) throws JsonException { if (o == null) { //null value means not specified i.e.-> no valued will be mapped //Json.null is specific value return null; } if (o instanceof JsonElement) { return (JsonElement) o; } if (o instanceof ElementWrapper) { return ((ElementWrapper) o).getJson(); } if (o instanceof Collection) { return new JsonArray((Collection) o); } else if (o.getClass().isArray()) { return new JsonArray(o); } if (o instanceof Map) { return new JsonObject((Map) o); } if (o instanceof Boolean) { return new JsonBoolean((Boolean) o); } if (o instanceof Number) { return new JsonNumber((Number) o); } if (o instanceof String) { return new JsonString((String) o); } if (o instanceof Character) { return new JsonString(Character.toString((Character) o)); } if (o instanceof ByteBuffer) { return new JsonString(((ByteBuffer) o).asCharBuffer().toString()); } return new JsonString(o.toString()); }
java
public static JsonElement wrap(Object o) throws JsonException { if (o == null) { //null value means not specified i.e.-> no valued will be mapped //Json.null is specific value return null; } if (o instanceof JsonElement) { return (JsonElement) o; } if (o instanceof ElementWrapper) { return ((ElementWrapper) o).getJson(); } if (o instanceof Collection) { return new JsonArray((Collection) o); } else if (o.getClass().isArray()) { return new JsonArray(o); } if (o instanceof Map) { return new JsonObject((Map) o); } if (o instanceof Boolean) { return new JsonBoolean((Boolean) o); } if (o instanceof Number) { return new JsonNumber((Number) o); } if (o instanceof String) { return new JsonString((String) o); } if (o instanceof Character) { return new JsonString(Character.toString((Character) o)); } if (o instanceof ByteBuffer) { return new JsonString(((ByteBuffer) o).asCharBuffer().toString()); } return new JsonString(o.toString()); }
[ "public", "static", "JsonElement", "wrap", "(", "Object", "o", ")", "throws", "JsonException", "{", "if", "(", "o", "==", "null", ")", "{", "//null value means not specified i.e.-> no valued will be mapped", "//Json.null is specific value", "return", "null", ";", "}", ...
Wraps the given object if to JsonXXX object.
[ "Wraps", "the", "given", "object", "if", "to", "JsonXXX", "object", "." ]
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-core/src/main/java/io/apptik/json/JsonElement.java#L129-L166
train
apptik/JustJson
json-schema/src/main/java/io/apptik/json/schema/fetch/SchemaUriFetcher.java
SchemaUriFetcher.fetch
@Override public Schema fetch(URI targetUri, URI srcOrigUri, URI srcId) { Schema res = null; URI schemaUri = convertUri(resolveUri(targetUri, srcOrigUri, srcId)); if(!schemaUri.isAbsolute()) throw new RuntimeException("Json Schema Fetcher works only with absolute URIs"); try { String fragment = schemaUri.getFragment(); JsonObject schemaJson = JsonElement.readFrom(new InputStreamReader(schemaUri.toURL().openStream())).asJsonObject(); if(fragment!=null && !fragment.trim().isEmpty()) { String[] pointers = fragment.split("/"); for (String pointer : pointers) { if (pointer != null && !pointer.trim().isEmpty()) { schemaJson = schemaJson.getJsonObject(pointer); } } } String version = schemaJson.optString("$schema",""); if(version.equals(Schema.VER_4)) { res = new SchemaV4().setSchemaFetcher(this).setOrigSrc(schemaUri).wrap(schemaJson); } else { res = new SchemaV4().setSchemaFetcher(this).setOrigSrc(schemaUri).wrap(schemaJson); } } catch (IOException e) { e.printStackTrace(); } catch (JsonException e) { e.printStackTrace(); } return res; }
java
@Override public Schema fetch(URI targetUri, URI srcOrigUri, URI srcId) { Schema res = null; URI schemaUri = convertUri(resolveUri(targetUri, srcOrigUri, srcId)); if(!schemaUri.isAbsolute()) throw new RuntimeException("Json Schema Fetcher works only with absolute URIs"); try { String fragment = schemaUri.getFragment(); JsonObject schemaJson = JsonElement.readFrom(new InputStreamReader(schemaUri.toURL().openStream())).asJsonObject(); if(fragment!=null && !fragment.trim().isEmpty()) { String[] pointers = fragment.split("/"); for (String pointer : pointers) { if (pointer != null && !pointer.trim().isEmpty()) { schemaJson = schemaJson.getJsonObject(pointer); } } } String version = schemaJson.optString("$schema",""); if(version.equals(Schema.VER_4)) { res = new SchemaV4().setSchemaFetcher(this).setOrigSrc(schemaUri).wrap(schemaJson); } else { res = new SchemaV4().setSchemaFetcher(this).setOrigSrc(schemaUri).wrap(schemaJson); } } catch (IOException e) { e.printStackTrace(); } catch (JsonException e) { e.printStackTrace(); } return res; }
[ "@", "Override", "public", "Schema", "fetch", "(", "URI", "targetUri", ",", "URI", "srcOrigUri", ",", "URI", "srcId", ")", "{", "Schema", "res", "=", "null", ";", "URI", "schemaUri", "=", "convertUri", "(", "resolveUri", "(", "targetUri", ",", "srcOrigUri"...
accepts only absolute URI or converted absolute URI
[ "accepts", "only", "absolute", "URI", "or", "converted", "absolute", "URI" ]
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-schema/src/main/java/io/apptik/json/schema/fetch/SchemaUriFetcher.java#L88-L120
train
apptik/JustJson
json-wrapper/src/main/java/io/apptik/json/wrapper/JsonElementWrapper.java
JsonElementWrapper.tryFetchMetaInfo
private MetaInfo tryFetchMetaInfo(URI jsonSchemaUri) { if (jsonSchemaUri == null) return null; try { metaInfo = doFetchMetaInfo(jsonSchemaUri); Validator validator = metaInfo.getDefaultValidator(); if (validator != null) { getValidators().add(validator); } } catch (Exception ex) { return null; } return metaInfo; }
java
private MetaInfo tryFetchMetaInfo(URI jsonSchemaUri) { if (jsonSchemaUri == null) return null; try { metaInfo = doFetchMetaInfo(jsonSchemaUri); Validator validator = metaInfo.getDefaultValidator(); if (validator != null) { getValidators().add(validator); } } catch (Exception ex) { return null; } return metaInfo; }
[ "private", "MetaInfo", "tryFetchMetaInfo", "(", "URI", "jsonSchemaUri", ")", "{", "if", "(", "jsonSchemaUri", "==", "null", ")", "return", "null", ";", "try", "{", "metaInfo", "=", "doFetchMetaInfo", "(", "jsonSchemaUri", ")", ";", "Validator", "validator", "=...
Tries to fetch a schema and add the default Schema validator for it @param jsonSchemaUri @return
[ "Tries", "to", "fetch", "a", "schema", "and", "add", "the", "default", "Schema", "validator", "for", "it" ]
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-wrapper/src/main/java/io/apptik/json/wrapper/JsonElementWrapper.java#L109-L122
train
apptik/JustJson
json-core/src/main/java/io/apptik/json/util/Util.java
Util.numberToString
public static String numberToString(Number number) throws JsonException { if (number == null) { throw new JsonException("Number must be non-null"); } double doubleValue = number.doubleValue(); // the original returns "-0" instead of "-0.0" for negative zero if (number.equals(NEGATIVE_ZERO)) { return "-0"; } long longValue = number.longValue(); if (doubleValue == (double) longValue) { return Long.toString(longValue); } return number.toString(); }
java
public static String numberToString(Number number) throws JsonException { if (number == null) { throw new JsonException("Number must be non-null"); } double doubleValue = number.doubleValue(); // the original returns "-0" instead of "-0.0" for negative zero if (number.equals(NEGATIVE_ZERO)) { return "-0"; } long longValue = number.longValue(); if (doubleValue == (double) longValue) { return Long.toString(longValue); } return number.toString(); }
[ "public", "static", "String", "numberToString", "(", "Number", "number", ")", "throws", "JsonException", "{", "if", "(", "number", "==", "null", ")", "{", "throw", "new", "JsonException", "(", "\"Number must be non-null\"", ")", ";", "}", "double", "doubleValue"...
Encodes the number as a Json string. @param number a finite value. May not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}.
[ "Encodes", "the", "number", "as", "a", "Json", "string", "." ]
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-core/src/main/java/io/apptik/json/util/Util.java#L137-L155
train
apptik/JustJson
json-core/src/main/java/io/apptik/json/JsonObject.java
JsonObject.merge
public JsonObject merge(JsonObject another) { for (Map.Entry<String, JsonElement> anotherEntry : another) { JsonElement curr = this.opt(anotherEntry.getKey()); if (curr == null) { try { this.put(anotherEntry.getKey(), anotherEntry.getValue()); } catch (JsonException e) { e.printStackTrace(); } } else if (curr.isJsonObject() && anotherEntry.getValue().isJsonObject()) { curr.asJsonObject().merge(anotherEntry.getValue().asJsonObject()); } } return this; }
java
public JsonObject merge(JsonObject another) { for (Map.Entry<String, JsonElement> anotherEntry : another) { JsonElement curr = this.opt(anotherEntry.getKey()); if (curr == null) { try { this.put(anotherEntry.getKey(), anotherEntry.getValue()); } catch (JsonException e) { e.printStackTrace(); } } else if (curr.isJsonObject() && anotherEntry.getValue().isJsonObject()) { curr.asJsonObject().merge(anotherEntry.getValue().asJsonObject()); } } return this; }
[ "public", "JsonObject", "merge", "(", "JsonObject", "another", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "JsonElement", ">", "anotherEntry", ":", "another", ")", "{", "JsonElement", "curr", "=", "this", ".", "opt", "(", "anotherEntry",...
Merge Json Object with another Json Object. It does not change element of another with the same name exists. However if the element is Json Object then it will go down and merge that object. @param another @return
[ "Merge", "Json", "Object", "with", "another", "Json", "Object", ".", "It", "does", "not", "change", "element", "of", "another", "with", "the", "same", "name", "exists", ".", "However", "if", "the", "element", "is", "Json", "Object", "then", "it", "will", ...
c90f0dd7f84df26da4749be8cd9b026fff499a79
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-core/src/main/java/io/apptik/json/JsonObject.java#L783-L797
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java
MarkLogicClient.sync
public void sync() throws MarkLogicSesameException { if(WRITE_CACHE_ENABLED && timerWriteCache != null) timerWriteCache.forceRun(); if(DELETE_CACHE_ENABLED && timerDeleteCache != null) timerDeleteCache.forceRun(); }
java
public void sync() throws MarkLogicSesameException { if(WRITE_CACHE_ENABLED && timerWriteCache != null) timerWriteCache.forceRun(); if(DELETE_CACHE_ENABLED && timerDeleteCache != null) timerDeleteCache.forceRun(); }
[ "public", "void", "sync", "(", ")", "throws", "MarkLogicSesameException", "{", "if", "(", "WRITE_CACHE_ENABLED", "&&", "timerWriteCache", "!=", "null", ")", "timerWriteCache", ".", "forceRun", "(", ")", ";", "if", "(", "DELETE_CACHE_ENABLED", "&&", "timerDeleteCac...
forces write cache to flush triples @throws MarkLogicSesameException
[ "forces", "write", "cache", "to", "flush", "triples" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java#L171-L176
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java
MarkLogicClient.sendAdd
public void sendAdd(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RDFParseException { getClient().performAdd(file, baseURI, dataFormat, this.tx, contexts); }
java
public void sendAdd(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RDFParseException { getClient().performAdd(file, baseURI, dataFormat, this.tx, contexts); }
[ "public", "void", "sendAdd", "(", "File", "file", ",", "String", "baseURI", ",", "RDFFormat", "dataFormat", ",", "Resource", "...", "contexts", ")", "throws", "RDFParseException", "{", "getClient", "(", ")", ".", "performAdd", "(", "file", ",", "baseURI", ",...
add triples from file @param file @param baseURI @param dataFormat @param contexts @throws RDFParseException
[ "add", "triples", "from", "file" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java#L302-L304
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java
MarkLogicClient.sendAdd
public void sendAdd(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RDFParseException, MarkLogicSesameException { getClient().performAdd(in, baseURI, dataFormat, this.tx, contexts); }
java
public void sendAdd(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RDFParseException, MarkLogicSesameException { getClient().performAdd(in, baseURI, dataFormat, this.tx, contexts); }
[ "public", "void", "sendAdd", "(", "InputStream", "in", ",", "String", "baseURI", ",", "RDFFormat", "dataFormat", ",", "Resource", "...", "contexts", ")", "throws", "RDFParseException", ",", "MarkLogicSesameException", "{", "getClient", "(", ")", ".", "performAdd",...
add triples from InputStream @param in @param baseURI @param dataFormat @param contexts
[ "add", "triples", "from", "InputStream" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java#L314-L316
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java
MarkLogicClient.sendAdd
public void sendAdd(String baseURI, Resource subject, URI predicate, Value object, Resource... contexts) throws MarkLogicSesameException { if (WRITE_CACHE_ENABLED) { timerWriteCache.add(subject, predicate, object, contexts); } else { getClient().performAdd(baseURI, (Resource) skolemize(subject), (URI) skolemize(predicate), skolemize(object), this.tx, contexts); } }
java
public void sendAdd(String baseURI, Resource subject, URI predicate, Value object, Resource... contexts) throws MarkLogicSesameException { if (WRITE_CACHE_ENABLED) { timerWriteCache.add(subject, predicate, object, contexts); } else { getClient().performAdd(baseURI, (Resource) skolemize(subject), (URI) skolemize(predicate), skolemize(object), this.tx, contexts); } }
[ "public", "void", "sendAdd", "(", "String", "baseURI", ",", "Resource", "subject", ",", "URI", "predicate", ",", "Value", "object", ",", "Resource", "...", "contexts", ")", "throws", "MarkLogicSesameException", "{", "if", "(", "WRITE_CACHE_ENABLED", ")", "{", ...
add single triple, if cache is enabled will add triple to cache model @param baseURI @param subject @param predicate @param object @param contexts
[ "add", "single", "triple", "if", "cache", "is", "enabled", "will", "add", "triple", "to", "cache", "model" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java#L340-L346
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java
MarkLogicClient.sendRemove
public void sendRemove(String baseURI, Resource subject,URI predicate, Value object, Resource... contexts) throws MarkLogicSesameException { if (DELETE_CACHE_ENABLED) { timerDeleteCache.add(subject, predicate, object, contexts); } else { if (WRITE_CACHE_ENABLED) sync(); getClient().performRemove(baseURI, (Resource) skolemize(subject), (URI) skolemize(predicate), skolemize(object), this.tx, contexts); } }
java
public void sendRemove(String baseURI, Resource subject,URI predicate, Value object, Resource... contexts) throws MarkLogicSesameException { if (DELETE_CACHE_ENABLED) { timerDeleteCache.add(subject, predicate, object, contexts); } else { if (WRITE_CACHE_ENABLED) sync(); getClient().performRemove(baseURI, (Resource) skolemize(subject), (URI) skolemize(predicate), skolemize(object), this.tx, contexts); } }
[ "public", "void", "sendRemove", "(", "String", "baseURI", ",", "Resource", "subject", ",", "URI", "predicate", ",", "Value", "object", ",", "Resource", "...", "contexts", ")", "throws", "MarkLogicSesameException", "{", "if", "(", "DELETE_CACHE_ENABLED", ")", "{"...
remove single triple @param baseURI @param subject @param predicate @param object @param contexts
[ "remove", "single", "triple" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java#L357-L365
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java
MarkLogicClient.commitTransaction
public void commitTransaction() throws MarkLogicTransactionException { if (isActiveTransaction()) { try { sync(); this.tx.commit(); this.tx=null; } catch (MarkLogicSesameException e) { logger.error(e.getLocalizedMessage()); throw new MarkLogicTransactionException(e); } }else{ throw new MarkLogicTransactionException("No active transaction to commit."); } }
java
public void commitTransaction() throws MarkLogicTransactionException { if (isActiveTransaction()) { try { sync(); this.tx.commit(); this.tx=null; } catch (MarkLogicSesameException e) { logger.error(e.getLocalizedMessage()); throw new MarkLogicTransactionException(e); } }else{ throw new MarkLogicTransactionException("No active transaction to commit."); } }
[ "public", "void", "commitTransaction", "(", ")", "throws", "MarkLogicTransactionException", "{", "if", "(", "isActiveTransaction", "(", ")", ")", "{", "try", "{", "sync", "(", ")", ";", "this", ".", "tx", ".", "commit", "(", ")", ";", "this", ".", "tx", ...
commits a transaction @throws MarkLogicTransactionException
[ "commits", "a", "transaction" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java#L402-L415
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java
MarkLogicClient.setGraphPerms
public void setGraphPerms(GraphPermissions graphPerms){ if (graphPerms != null) { getClient().setGraphPerms(graphPerms); }else { getClient().setGraphPerms(getClient().getDatabaseClient().newGraphManager().newGraphPermissions()); } }
java
public void setGraphPerms(GraphPermissions graphPerms){ if (graphPerms != null) { getClient().setGraphPerms(graphPerms); }else { getClient().setGraphPerms(getClient().getDatabaseClient().newGraphManager().newGraphPermissions()); } }
[ "public", "void", "setGraphPerms", "(", "GraphPermissions", "graphPerms", ")", "{", "if", "(", "graphPerms", "!=", "null", ")", "{", "getClient", "(", ")", ".", "setGraphPerms", "(", "graphPerms", ")", ";", "}", "else", "{", "getClient", "(", ")", ".", "...
setter for GraphPermissions @param graphPerms
[ "setter", "for", "GraphPermissions" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClient.java#L517-L524
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepository.java
MarkLogicRepository.getMarkLogicClient
@Override public synchronized MarkLogicClient getMarkLogicClient() { if(null != databaseClient){ this.client = new MarkLogicClient(databaseClient); }else{ this.client = new MarkLogicClient(host, port, user, password, auth); } return this.client; }
java
@Override public synchronized MarkLogicClient getMarkLogicClient() { if(null != databaseClient){ this.client = new MarkLogicClient(databaseClient); }else{ this.client = new MarkLogicClient(host, port, user, password, auth); } return this.client; }
[ "@", "Override", "public", "synchronized", "MarkLogicClient", "getMarkLogicClient", "(", ")", "{", "if", "(", "null", "!=", "databaseClient", ")", "{", "this", ".", "client", "=", "new", "MarkLogicClient", "(", "databaseClient", ")", ";", "}", "else", "{", "...
returns MarkLogicClient object which manages communication to ML server via Java api client @return MarkLogicClient
[ "returns", "MarkLogicClient", "object", "which", "manages", "communication", "to", "ML", "server", "via", "Java", "api", "client" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepository.java#L231-L239
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java
MarkLogicClientImpl.setDatabaseClient
private void setDatabaseClient(DatabaseClient databaseClient) { this.databaseClient = databaseClient; this.sparqlManager = getDatabaseClient().newSPARQLQueryManager(); this.graphManager = getDatabaseClient().newGraphManager(); }
java
private void setDatabaseClient(DatabaseClient databaseClient) { this.databaseClient = databaseClient; this.sparqlManager = getDatabaseClient().newSPARQLQueryManager(); this.graphManager = getDatabaseClient().newGraphManager(); }
[ "private", "void", "setDatabaseClient", "(", "DatabaseClient", "databaseClient", ")", "{", "this", ".", "databaseClient", "=", "databaseClient", ";", "this", ".", "sparqlManager", "=", "getDatabaseClient", "(", ")", ".", "newSPARQLQueryManager", "(", ")", ";", "th...
set databaseclient and instantate related managers @param databaseClient
[ "set", "databaseclient", "and", "instantate", "related", "managers" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java#L107-L111
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java
MarkLogicClientImpl.performAdd
public void performAdd(File file, String baseURI, RDFFormat dataFormat, Transaction tx, Resource... contexts) throws RDFParseException { try { graphManager.setDefaultMimetype(dataFormat.getDefaultMIMEType()); if (dataFormat.equals(RDFFormat.NQUADS) || dataFormat.equals(RDFFormat.TRIG)) { graphManager.mergeGraphs(new FileHandle(file),tx); } else { if (notNull(contexts) && contexts.length>0) { for (int i = 0; i < contexts.length; i++) { if(notNull(contexts[i])){ graphManager.mergeAs(contexts[i].toString(), new FileHandle(file), getGraphPerms(),tx); }else{ graphManager.mergeAs(DEFAULT_GRAPH_URI, new FileHandle(file),getGraphPerms(), tx); } } } else { graphManager.mergeAs(DEFAULT_GRAPH_URI, new FileHandle(file), getGraphPerms(),tx); } } } catch (FailedRequestException e) { logger.error(e.getLocalizedMessage()); throw new RDFParseException("Request to MarkLogic server failed, check file and format."); } }
java
public void performAdd(File file, String baseURI, RDFFormat dataFormat, Transaction tx, Resource... contexts) throws RDFParseException { try { graphManager.setDefaultMimetype(dataFormat.getDefaultMIMEType()); if (dataFormat.equals(RDFFormat.NQUADS) || dataFormat.equals(RDFFormat.TRIG)) { graphManager.mergeGraphs(new FileHandle(file),tx); } else { if (notNull(contexts) && contexts.length>0) { for (int i = 0; i < contexts.length; i++) { if(notNull(contexts[i])){ graphManager.mergeAs(contexts[i].toString(), new FileHandle(file), getGraphPerms(),tx); }else{ graphManager.mergeAs(DEFAULT_GRAPH_URI, new FileHandle(file),getGraphPerms(), tx); } } } else { graphManager.mergeAs(DEFAULT_GRAPH_URI, new FileHandle(file), getGraphPerms(),tx); } } } catch (FailedRequestException e) { logger.error(e.getLocalizedMessage()); throw new RDFParseException("Request to MarkLogic server failed, check file and format."); } }
[ "public", "void", "performAdd", "(", "File", "file", ",", "String", "baseURI", ",", "RDFFormat", "dataFormat", ",", "Transaction", "tx", ",", "Resource", "...", "contexts", ")", "throws", "RDFParseException", "{", "try", "{", "graphManager", ".", "setDefaultMime...
as we use mergeGraphs, baseURI is always file.toURI
[ "as", "we", "use", "mergeGraphs", "baseURI", "is", "always", "file", ".", "toURI" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java#L275-L297
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java
MarkLogicClientImpl.performAdd
public void performAdd(InputStream in, String baseURI, RDFFormat dataFormat, Transaction tx, Resource... contexts) throws RDFParseException, MarkLogicSesameException { try { graphManager.setDefaultMimetype(dataFormat.getDefaultMIMEType()); if (dataFormat.equals(RDFFormat.NQUADS) || dataFormat.equals(RDFFormat.TRIG)) { graphManager.mergeGraphs(new InputStreamHandle(in),tx); } else { if (notNull(contexts) && contexts.length > 0) { for (int i = 0; i < contexts.length; i++) { if (notNull(contexts[i])) { graphManager.mergeAs(contexts[i].toString(), new InputStreamHandle(in), getGraphPerms(), tx); } else { graphManager.mergeAs(DEFAULT_GRAPH_URI, new InputStreamHandle(in),getGraphPerms(), tx); } } } else { graphManager.mergeAs(DEFAULT_GRAPH_URI, new InputStreamHandle(in),getGraphPerms(), tx); } } in.close(); } catch (FailedRequestException e) { logger.error(e.getLocalizedMessage()); throw new RDFParseException("Request to MarkLogic server failed, check input is valid."); } catch (IOException e) { logger.error(e.getLocalizedMessage()); throw new MarkLogicSesameException("IO error"); } }
java
public void performAdd(InputStream in, String baseURI, RDFFormat dataFormat, Transaction tx, Resource... contexts) throws RDFParseException, MarkLogicSesameException { try { graphManager.setDefaultMimetype(dataFormat.getDefaultMIMEType()); if (dataFormat.equals(RDFFormat.NQUADS) || dataFormat.equals(RDFFormat.TRIG)) { graphManager.mergeGraphs(new InputStreamHandle(in),tx); } else { if (notNull(contexts) && contexts.length > 0) { for (int i = 0; i < contexts.length; i++) { if (notNull(contexts[i])) { graphManager.mergeAs(contexts[i].toString(), new InputStreamHandle(in), getGraphPerms(), tx); } else { graphManager.mergeAs(DEFAULT_GRAPH_URI, new InputStreamHandle(in),getGraphPerms(), tx); } } } else { graphManager.mergeAs(DEFAULT_GRAPH_URI, new InputStreamHandle(in),getGraphPerms(), tx); } } in.close(); } catch (FailedRequestException e) { logger.error(e.getLocalizedMessage()); throw new RDFParseException("Request to MarkLogic server failed, check input is valid."); } catch (IOException e) { logger.error(e.getLocalizedMessage()); throw new MarkLogicSesameException("IO error"); } }
[ "public", "void", "performAdd", "(", "InputStream", "in", ",", "String", "baseURI", ",", "RDFFormat", "dataFormat", ",", "Transaction", "tx", ",", "Resource", "...", "contexts", ")", "throws", "RDFParseException", ",", "MarkLogicSesameException", "{", "try", "{", ...
executes merge of triples from InputStream @param in @param baseURI @param dataFormat @param tx @param contexts @throws RDFParseException
[ "executes", "merge", "of", "triples", "from", "InputStream" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java#L309-L335
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java
MarkLogicClientImpl.performAdd
public void performAdd(String baseURI, Resource subject, URI predicate, Value object, Transaction tx, Resource... contexts) throws MarkLogicSesameException { StringBuilder sb = new StringBuilder(); if(notNull(contexts) && contexts.length>0) { if (notNull(baseURI)) sb.append("BASE <" + baseURI + ">\n"); sb.append("INSERT DATA { "); for (int i = 0; i < contexts.length; i++) { if (notNull(contexts[i])) { sb.append("GRAPH <" + contexts[i].stringValue() + "> { ?s ?p ?o .} "); } else { sb.append("GRAPH <" + DEFAULT_GRAPH_URI + "> { ?s ?p ?o .} "); } } sb.append("}"); } else { sb.append("INSERT DATA { GRAPH <" + DEFAULT_GRAPH_URI + "> {?s ?p ?o .}}"); } SPARQLQueryDefinition qdef = sparqlManager.newQueryDefinition(sb.toString()); if (notNull(ruleset) ) {qdef.setRulesets(ruleset);} if(notNull(graphPerms)){ qdef.setUpdatePermissions(graphPerms);} if(notNull(baseURI) && !baseURI.isEmpty()){ qdef.setBaseUri(baseURI);} if(notNull(subject)) qdef.withBinding("s", subject.stringValue()); if(notNull(predicate)) qdef.withBinding("p", predicate.stringValue()); if(notNull(object)) bindObject(qdef, "o", object); sparqlManager.executeUpdate(qdef, tx); }
java
public void performAdd(String baseURI, Resource subject, URI predicate, Value object, Transaction tx, Resource... contexts) throws MarkLogicSesameException { StringBuilder sb = new StringBuilder(); if(notNull(contexts) && contexts.length>0) { if (notNull(baseURI)) sb.append("BASE <" + baseURI + ">\n"); sb.append("INSERT DATA { "); for (int i = 0; i < contexts.length; i++) { if (notNull(contexts[i])) { sb.append("GRAPH <" + contexts[i].stringValue() + "> { ?s ?p ?o .} "); } else { sb.append("GRAPH <" + DEFAULT_GRAPH_URI + "> { ?s ?p ?o .} "); } } sb.append("}"); } else { sb.append("INSERT DATA { GRAPH <" + DEFAULT_GRAPH_URI + "> {?s ?p ?o .}}"); } SPARQLQueryDefinition qdef = sparqlManager.newQueryDefinition(sb.toString()); if (notNull(ruleset) ) {qdef.setRulesets(ruleset);} if(notNull(graphPerms)){ qdef.setUpdatePermissions(graphPerms);} if(notNull(baseURI) && !baseURI.isEmpty()){ qdef.setBaseUri(baseURI);} if(notNull(subject)) qdef.withBinding("s", subject.stringValue()); if(notNull(predicate)) qdef.withBinding("p", predicate.stringValue()); if(notNull(object)) bindObject(qdef, "o", object); sparqlManager.executeUpdate(qdef, tx); }
[ "public", "void", "performAdd", "(", "String", "baseURI", ",", "Resource", "subject", ",", "URI", "predicate", ",", "Value", "object", ",", "Transaction", "tx", ",", "Resource", "...", "contexts", ")", "throws", "MarkLogicSesameException", "{", "StringBuilder", ...
executes INSERT of single triple @param baseURI @param subject @param predicate @param object @param tx @param contexts @throws MarkLogicSesameException
[ "executes", "INSERT", "of", "single", "triple" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java#L348-L373
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java
MarkLogicClientImpl.performClear
public void performClear(Transaction tx, Resource... contexts) { if(notNull(contexts)) { for (int i = 0; i < contexts.length; i++) { if (notNull(contexts[i])) { graphManager.delete(contexts[i].stringValue(), tx); } else { graphManager.delete(DEFAULT_GRAPH_URI, tx); } } }else{ graphManager.delete(DEFAULT_GRAPH_URI, tx); } }
java
public void performClear(Transaction tx, Resource... contexts) { if(notNull(contexts)) { for (int i = 0; i < contexts.length; i++) { if (notNull(contexts[i])) { graphManager.delete(contexts[i].stringValue(), tx); } else { graphManager.delete(DEFAULT_GRAPH_URI, tx); } } }else{ graphManager.delete(DEFAULT_GRAPH_URI, tx); } }
[ "public", "void", "performClear", "(", "Transaction", "tx", ",", "Resource", "...", "contexts", ")", "{", "if", "(", "notNull", "(", "contexts", ")", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "contexts", ".", "length", ";", "i", "+...
clears triples from named graph @param tx @param contexts
[ "clears", "triples", "from", "named", "graph" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java#L417-L429
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java
MarkLogicClientImpl.setRulesets
public void setRulesets(SPARQLRuleset ... rulesets) { if(notNull(rulesets)) { List<SPARQLRuleset> list = new ArrayList<>(); for(Object r : rulesets) { if(r != null && rulesets.length > 0) { list.add((SPARQLRuleset)r); } } this.ruleset = list.toArray(new SPARQLRuleset[list.size()]); }else{ this.ruleset = null; } }
java
public void setRulesets(SPARQLRuleset ... rulesets) { if(notNull(rulesets)) { List<SPARQLRuleset> list = new ArrayList<>(); for(Object r : rulesets) { if(r != null && rulesets.length > 0) { list.add((SPARQLRuleset)r); } } this.ruleset = list.toArray(new SPARQLRuleset[list.size()]); }else{ this.ruleset = null; } }
[ "public", "void", "setRulesets", "(", "SPARQLRuleset", "...", "rulesets", ")", "{", "if", "(", "notNull", "(", "rulesets", ")", ")", "{", "List", "<", "SPARQLRuleset", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Object", "r"...
setter for rulesets, filters out nulls @param rulesets
[ "setter", "for", "rulesets", "filters", "out", "nulls" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java#L454-L466
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java
MarkLogicClientImpl.getSPARQLBindings
protected SPARQLBindings getSPARQLBindings(SPARQLQueryBindingSet bindings) { SPARQLBindings sps = new SPARQLBindingsImpl(); for (Binding binding : bindings) { sps.bind(binding.getName(), binding.getValue().stringValue()); } return sps; }
java
protected SPARQLBindings getSPARQLBindings(SPARQLQueryBindingSet bindings) { SPARQLBindings sps = new SPARQLBindingsImpl(); for (Binding binding : bindings) { sps.bind(binding.getName(), binding.getValue().stringValue()); } return sps; }
[ "protected", "SPARQLBindings", "getSPARQLBindings", "(", "SPARQLQueryBindingSet", "bindings", ")", "{", "SPARQLBindings", "sps", "=", "new", "SPARQLBindingsImpl", "(", ")", ";", "for", "(", "Binding", "binding", ":", "bindings", ")", "{", "sps", ".", "bind", "("...
converts Sesame BindingSet to java api client SPARQLBindings @param bindings @return
[ "converts", "Sesame", "BindingSet", "to", "java", "api", "client", "SPARQLBindings" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicClientImpl.java#L530-L536
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/TripleCache.java
TripleCache.run
@Override public synchronized void run(){ Date now = new Date(); if ( !cache.isEmpty() && ((cache.size() > cacheSize - 1) || (now.getTime() - lastCacheAccess.getTime() > cacheMillis))) { try { flush(); } catch (RepositoryException e) { log.error(e.getLocalizedMessage()); throw new RuntimeException(e); } catch (MalformedQueryException e) { log.error(e.getLocalizedMessage()); throw new RuntimeException(e); } catch (UpdateExecutionException e) { log.error(e.getLocalizedMessage()); throw new RuntimeException(e); } catch (IOException e) { log.error(e.getLocalizedMessage()); throw new RuntimeException(e); } } }
java
@Override public synchronized void run(){ Date now = new Date(); if ( !cache.isEmpty() && ((cache.size() > cacheSize - 1) || (now.getTime() - lastCacheAccess.getTime() > cacheMillis))) { try { flush(); } catch (RepositoryException e) { log.error(e.getLocalizedMessage()); throw new RuntimeException(e); } catch (MalformedQueryException e) { log.error(e.getLocalizedMessage()); throw new RuntimeException(e); } catch (UpdateExecutionException e) { log.error(e.getLocalizedMessage()); throw new RuntimeException(e); } catch (IOException e) { log.error(e.getLocalizedMessage()); throw new RuntimeException(e); } } }
[ "@", "Override", "public", "synchronized", "void", "run", "(", ")", "{", "Date", "now", "=", "new", "Date", "(", ")", ";", "if", "(", "!", "cache", ".", "isEmpty", "(", ")", "&&", "(", "(", "cache", ".", "size", "(", ")", ">", "cacheSize", "-", ...
tests to see if we should flush cache
[ "tests", "to", "see", "if", "we", "should", "flush", "cache" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/TripleCache.java#L130-L151
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/TripleCache.java
TripleCache.forceRun
public synchronized void forceRun() throws MarkLogicSesameException { log.debug(String.valueOf(cache.size())); if( !cache.isEmpty()) { try { flush(); } catch (RepositoryException e) { throw new MarkLogicSesameException("Could not flush write cache, encountered repository issue.",e); } catch (MalformedQueryException e) { throw new MarkLogicSesameException("Could not flush write cache, query was malformed.",e); } catch (UpdateExecutionException e) { throw new MarkLogicSesameException("Could not flush write cache, query update failed.",e); } catch (IOException e) { throw new MarkLogicSesameException("Could not flush write cache, encountered IO issue.",e); } } }
java
public synchronized void forceRun() throws MarkLogicSesameException { log.debug(String.valueOf(cache.size())); if( !cache.isEmpty()) { try { flush(); } catch (RepositoryException e) { throw new MarkLogicSesameException("Could not flush write cache, encountered repository issue.",e); } catch (MalformedQueryException e) { throw new MarkLogicSesameException("Could not flush write cache, query was malformed.",e); } catch (UpdateExecutionException e) { throw new MarkLogicSesameException("Could not flush write cache, query update failed.",e); } catch (IOException e) { throw new MarkLogicSesameException("Could not flush write cache, encountered IO issue.",e); } } }
[ "public", "synchronized", "void", "forceRun", "(", ")", "throws", "MarkLogicSesameException", "{", "log", ".", "debug", "(", "String", ".", "valueOf", "(", "cache", ".", "size", "(", ")", ")", ")", ";", "if", "(", "!", "cache", ".", "isEmpty", "(", ")"...
min forces the cache to flush if there is anything in it @throws MarkLogicSesameException
[ "min", "forces", "the", "cache", "to", "flush", "if", "there", "is", "anything", "in", "it" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/TripleCache.java#L160-L175
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/TripleCache.java
TripleCache.add
public synchronized void add(Resource subject, URI predicate, Value object, Resource... contexts) throws MarkLogicSesameException { cache.add(subject,predicate,object,contexts); if( cache.size() > cacheSize - 1){ forceRun(); } }
java
public synchronized void add(Resource subject, URI predicate, Value object, Resource... contexts) throws MarkLogicSesameException { cache.add(subject,predicate,object,contexts); if( cache.size() > cacheSize - 1){ forceRun(); } }
[ "public", "synchronized", "void", "add", "(", "Resource", "subject", ",", "URI", "predicate", ",", "Value", "object", ",", "Resource", "...", "contexts", ")", "throws", "MarkLogicSesameException", "{", "cache", ".", "add", "(", "subject", ",", "predicate", ","...
add triple to cache Model @param subject @param predicate @param object @param contexts
[ "add", "triple", "to", "cache", "Model" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/TripleCache.java#L185-L190
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.prepareQuery
@Override public Query prepareQuery(String queryString, String baseURI) throws RepositoryException, MalformedQueryException { return prepareQuery(QueryLanguage.SPARQL, queryString, baseURI); }
java
@Override public Query prepareQuery(String queryString, String baseURI) throws RepositoryException, MalformedQueryException { return prepareQuery(QueryLanguage.SPARQL, queryString, baseURI); }
[ "@", "Override", "public", "Query", "prepareQuery", "(", "String", "queryString", ",", "String", "baseURI", ")", "throws", "RepositoryException", ",", "MalformedQueryException", "{", "return", "prepareQuery", "(", "QueryLanguage", ".", "SPARQL", ",", "queryString", ...
overload for prepareQuery @param queryString @param baseURI @return MarkLogicQuery @throws RepositoryException @throws MalformedQueryException
[ "overload", "for", "prepareQuery" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L164-L167
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.prepareQuery
@Override public MarkLogicQuery prepareQuery(QueryLanguage queryLanguage, String queryString, String baseURI) throws RepositoryException, MalformedQueryException { // function routing based on query form if (SPARQL.equals(queryLanguage)) { String queryStringWithoutProlog = QueryParserUtil.removeSPARQLQueryProlog(queryString).toUpperCase(); if (queryStringWithoutProlog.startsWith("SELECT")) { return prepareTupleQuery(queryLanguage, queryString, baseURI); //must be a TupleQuery } else if (queryStringWithoutProlog.startsWith("ASK")) { return prepareBooleanQuery(queryLanguage, queryString, baseURI); //must be a BooleanQuery } else { return prepareGraphQuery(queryLanguage, queryString, baseURI); //all the rest use GraphQuery } } throw new UnsupportedQueryLanguageException("Unsupported query language " + queryLanguage.getName()); }
java
@Override public MarkLogicQuery prepareQuery(QueryLanguage queryLanguage, String queryString, String baseURI) throws RepositoryException, MalformedQueryException { // function routing based on query form if (SPARQL.equals(queryLanguage)) { String queryStringWithoutProlog = QueryParserUtil.removeSPARQLQueryProlog(queryString).toUpperCase(); if (queryStringWithoutProlog.startsWith("SELECT")) { return prepareTupleQuery(queryLanguage, queryString, baseURI); //must be a TupleQuery } else if (queryStringWithoutProlog.startsWith("ASK")) { return prepareBooleanQuery(queryLanguage, queryString, baseURI); //must be a BooleanQuery } else { return prepareGraphQuery(queryLanguage, queryString, baseURI); //all the rest use GraphQuery } } throw new UnsupportedQueryLanguageException("Unsupported query language " + queryLanguage.getName()); }
[ "@", "Override", "public", "MarkLogicQuery", "prepareQuery", "(", "QueryLanguage", "queryLanguage", ",", "String", "queryString", ",", "String", "baseURI", ")", "throws", "RepositoryException", ",", "MalformedQueryException", "{", "// function routing based on query form", ...
base method for prepareQuery routes to all other query forms (prepareTupleQuery,prepareBooleanQuery,prepareGraphQuery) @param queryLanguage @param queryString @param baseURI @return MarkLogicQuery @throws RepositoryException @throws MalformedQueryException
[ "base", "method", "for", "prepareQuery" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L195-L213
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.prepareGraphQuery
@Override public MarkLogicGraphQuery prepareGraphQuery(String queryString,String baseURI) throws RepositoryException, MalformedQueryException { return prepareGraphQuery(QueryLanguage.SPARQL, queryString, baseURI); }
java
@Override public MarkLogicGraphQuery prepareGraphQuery(String queryString,String baseURI) throws RepositoryException, MalformedQueryException { return prepareGraphQuery(QueryLanguage.SPARQL, queryString, baseURI); }
[ "@", "Override", "public", "MarkLogicGraphQuery", "prepareGraphQuery", "(", "String", "queryString", ",", "String", "baseURI", ")", "throws", "RepositoryException", ",", "MalformedQueryException", "{", "return", "prepareGraphQuery", "(", "QueryLanguage", ".", "SPARQL", ...
overload for prepareGraphQuery @param queryString @param baseURI @return MarkLogicGraphQuery @throws RepositoryException @throws MalformedQueryException
[ "overload", "for", "prepareGraphQuery" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L296-L299
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.prepareBooleanQuery
@Override public MarkLogicBooleanQuery prepareBooleanQuery(String queryString) throws RepositoryException, MalformedQueryException { return prepareBooleanQuery(QueryLanguage.SPARQL, queryString, null); }
java
@Override public MarkLogicBooleanQuery prepareBooleanQuery(String queryString) throws RepositoryException, MalformedQueryException { return prepareBooleanQuery(QueryLanguage.SPARQL, queryString, null); }
[ "@", "Override", "public", "MarkLogicBooleanQuery", "prepareBooleanQuery", "(", "String", "queryString", ")", "throws", "RepositoryException", ",", "MalformedQueryException", "{", "return", "prepareBooleanQuery", "(", "QueryLanguage", ".", "SPARQL", ",", "queryString", ",...
overload for prepareBooleanQuery @param queryString @return MarkLogicBooleanQuery @throws RepositoryException @throws MalformedQueryException
[ "overload", "for", "prepareBooleanQuery" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L343-L346
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.prepareUpdate
@Override public MarkLogicUpdateQuery prepareUpdate(String queryString,String baseURI) throws RepositoryException, MalformedQueryException { return prepareUpdate(QueryLanguage.SPARQL, queryString, baseURI); }
java
@Override public MarkLogicUpdateQuery prepareUpdate(String queryString,String baseURI) throws RepositoryException, MalformedQueryException { return prepareUpdate(QueryLanguage.SPARQL, queryString, baseURI); }
[ "@", "Override", "public", "MarkLogicUpdateQuery", "prepareUpdate", "(", "String", "queryString", ",", "String", "baseURI", ")", "throws", "RepositoryException", ",", "MalformedQueryException", "{", "return", "prepareUpdate", "(", "QueryLanguage", ".", "SPARQL", ",", ...
overload for prepareUpdate @param queryString @param baseURI @return MarkLogicUpdateQuery @throws RepositoryException @throws MalformedQueryException
[ "overload", "for", "prepareUpdate" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L416-L419
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.prepareUpdate
@Override public MarkLogicUpdateQuery prepareUpdate(QueryLanguage queryLanguage, String queryString, String baseURI) throws RepositoryException, MalformedQueryException { if (QueryLanguage.SPARQL.equals(queryLanguage)) { return new MarkLogicUpdateQuery(this.client, new SPARQLQueryBindingSet(), baseURI, queryString, defaultGraphPerms, defaultQueryDef, defaultRulesets); } throw new UnsupportedQueryLanguageException("Unsupported query language " + queryLanguage.getName()); }
java
@Override public MarkLogicUpdateQuery prepareUpdate(QueryLanguage queryLanguage, String queryString, String baseURI) throws RepositoryException, MalformedQueryException { if (QueryLanguage.SPARQL.equals(queryLanguage)) { return new MarkLogicUpdateQuery(this.client, new SPARQLQueryBindingSet(), baseURI, queryString, defaultGraphPerms, defaultQueryDef, defaultRulesets); } throw new UnsupportedQueryLanguageException("Unsupported query language " + queryLanguage.getName()); }
[ "@", "Override", "public", "MarkLogicUpdateQuery", "prepareUpdate", "(", "QueryLanguage", "queryLanguage", ",", "String", "queryString", ",", "String", "baseURI", ")", "throws", "RepositoryException", ",", "MalformedQueryException", "{", "if", "(", "QueryLanguage", ".",...
base method for prepareUpdate @param queryLanguage @param queryString @param baseURI @return MarkLogicUpdateQuery @throws RepositoryException @throws MalformedQueryException
[ "base", "method", "for", "prepareUpdate" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L445-L451
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.getContextIDs
@Override public RepositoryResult<Resource> getContextIDs() throws RepositoryException { try{ TupleQuery tupleQuery = prepareTupleQuery(QueryLanguage.SPARQL, ALL_GRAPH_URIS); TupleQueryResult result = tupleQuery.evaluate(); return new RepositoryResult<Resource>( new ExceptionConvertingIteration<Resource, RepositoryException>( new ConvertingIteration<BindingSet, Resource, QueryEvaluationException>(result) { @Override protected Resource convert(BindingSet bindings) throws QueryEvaluationException { return (Resource) bindings.getValue("g"); } }) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } }
java
@Override public RepositoryResult<Resource> getContextIDs() throws RepositoryException { try{ TupleQuery tupleQuery = prepareTupleQuery(QueryLanguage.SPARQL, ALL_GRAPH_URIS); TupleQueryResult result = tupleQuery.evaluate(); return new RepositoryResult<Resource>( new ExceptionConvertingIteration<Resource, RepositoryException>( new ConvertingIteration<BindingSet, Resource, QueryEvaluationException>(result) { @Override protected Resource convert(BindingSet bindings) throws QueryEvaluationException { return (Resource) bindings.getValue("g"); } }) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } }
[ "@", "Override", "public", "RepositoryResult", "<", "Resource", ">", "getContextIDs", "(", ")", "throws", "RepositoryException", "{", "try", "{", "TupleQuery", "tupleQuery", "=", "prepareTupleQuery", "(", "QueryLanguage", ".", "SPARQL", ",", "ALL_GRAPH_URIS", ")", ...
returns list of graph names as Resource @throws RepositoryException
[ "returns", "list", "of", "graph", "names", "as", "Resource" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L458-L486
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.getStatements
public RepositoryResult<Statement> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred) throws RepositoryException { try { if (isQuadMode()) { TupleQuery tupleQuery = prepareTupleQuery(GET_STATEMENTS); setBindings(tupleQuery, subj, pred, obj); tupleQuery.setIncludeInferred(includeInferred); TupleQueryResult qRes = tupleQuery.evaluate(); return new RepositoryResult<Statement>( new ExceptionConvertingIteration<Statement, RepositoryException>( toStatementIteration(qRes, subj, pred, obj)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } else if (subj != null && pred != null && obj != null) { if (hasStatement(subj, pred, obj, includeInferred)) { Statement st = new StatementImpl(subj, pred, obj); CloseableIteration<Statement, RepositoryException> cursor; cursor = new SingletonIteration<Statement, RepositoryException>(st); return new RepositoryResult<Statement>(cursor); } else { return new RepositoryResult<Statement>(new EmptyIteration<Statement, RepositoryException>()); } } GraphQuery query = prepareGraphQuery(EVERYTHING); setBindings(query, subj, pred, obj); GraphQueryResult result = query.evaluate(); return new RepositoryResult<Statement>( new ExceptionConvertingIteration<Statement, RepositoryException>(result) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } }
java
public RepositoryResult<Statement> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred) throws RepositoryException { try { if (isQuadMode()) { TupleQuery tupleQuery = prepareTupleQuery(GET_STATEMENTS); setBindings(tupleQuery, subj, pred, obj); tupleQuery.setIncludeInferred(includeInferred); TupleQueryResult qRes = tupleQuery.evaluate(); return new RepositoryResult<Statement>( new ExceptionConvertingIteration<Statement, RepositoryException>( toStatementIteration(qRes, subj, pred, obj)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } else if (subj != null && pred != null && obj != null) { if (hasStatement(subj, pred, obj, includeInferred)) { Statement st = new StatementImpl(subj, pred, obj); CloseableIteration<Statement, RepositoryException> cursor; cursor = new SingletonIteration<Statement, RepositoryException>(st); return new RepositoryResult<Statement>(cursor); } else { return new RepositoryResult<Statement>(new EmptyIteration<Statement, RepositoryException>()); } } GraphQuery query = prepareGraphQuery(EVERYTHING); setBindings(query, subj, pred, obj); GraphQueryResult result = query.evaluate(); return new RepositoryResult<Statement>( new ExceptionConvertingIteration<Statement, RepositoryException>(result) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } }
[ "public", "RepositoryResult", "<", "Statement", ">", "getStatements", "(", "Resource", "subj", ",", "URI", "pred", ",", "Value", "obj", ",", "boolean", "includeInferred", ")", "throws", "RepositoryException", "{", "try", "{", "if", "(", "isQuadMode", "(", ")",...
returns all statements @param subj @param pred @param obj @param includeInferred @throws RepositoryException
[ "returns", "all", "statements" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L497-L537
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.getStatements
@Override public RepositoryResult<Statement> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException { if (contexts == null) { contexts = new Resource[] { null }; } try { if (isQuadMode()) { StringBuilder sb = new StringBuilder(); sb.append("SELECT * WHERE { GRAPH ?ctx { ?s ?p ?o } filter (?ctx = ("); boolean first = true; for (Resource context : contexts) { if (first) { first = !first; } else { sb.append(","); } if (notNull(context)) { sb.append("IRI(\"" + context.toString() + "\")"); } else { sb.append("IRI(\""+DEFAULT_GRAPH_URI+"\")"); } } sb.append(") ) }"); TupleQuery tupleQuery = prepareTupleQuery(sb.toString()); tupleQuery.setIncludeInferred(includeInferred); setBindings(tupleQuery, subj, pred, obj, (Resource) null); TupleQueryResult qRes = tupleQuery.evaluate(); return new RepositoryResult<Statement>( new ExceptionConvertingIteration<Statement, RepositoryException>( toStatementIteration(qRes, subj, pred, obj)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } else if (subj != null && pred != null && obj != null) { if (hasStatement(subj, pred, obj, includeInferred, contexts)) { Statement st = new StatementImpl(subj, pred, obj); CloseableIteration<Statement, RepositoryException> cursor; cursor = new SingletonIteration<Statement, RepositoryException>(st); return new RepositoryResult<Statement>(cursor); } else { return new RepositoryResult<Statement>(new EmptyIteration<Statement, RepositoryException>()); } } else { MarkLogicGraphQuery query = prepareGraphQuery(EVERYTHING); setBindings(query, subj, pred, obj, contexts); GraphQueryResult result = query.evaluate(); return new RepositoryResult<Statement>( new ExceptionConvertingIteration<Statement, RepositoryException>(result) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } }
java
@Override public RepositoryResult<Statement> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException { if (contexts == null) { contexts = new Resource[] { null }; } try { if (isQuadMode()) { StringBuilder sb = new StringBuilder(); sb.append("SELECT * WHERE { GRAPH ?ctx { ?s ?p ?o } filter (?ctx = ("); boolean first = true; for (Resource context : contexts) { if (first) { first = !first; } else { sb.append(","); } if (notNull(context)) { sb.append("IRI(\"" + context.toString() + "\")"); } else { sb.append("IRI(\""+DEFAULT_GRAPH_URI+"\")"); } } sb.append(") ) }"); TupleQuery tupleQuery = prepareTupleQuery(sb.toString()); tupleQuery.setIncludeInferred(includeInferred); setBindings(tupleQuery, subj, pred, obj, (Resource) null); TupleQueryResult qRes = tupleQuery.evaluate(); return new RepositoryResult<Statement>( new ExceptionConvertingIteration<Statement, RepositoryException>( toStatementIteration(qRes, subj, pred, obj)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } else if (subj != null && pred != null && obj != null) { if (hasStatement(subj, pred, obj, includeInferred, contexts)) { Statement st = new StatementImpl(subj, pred, obj); CloseableIteration<Statement, RepositoryException> cursor; cursor = new SingletonIteration<Statement, RepositoryException>(st); return new RepositoryResult<Statement>(cursor); } else { return new RepositoryResult<Statement>(new EmptyIteration<Statement, RepositoryException>()); } } else { MarkLogicGraphQuery query = prepareGraphQuery(EVERYTHING); setBindings(query, subj, pred, obj, contexts); GraphQueryResult result = query.evaluate(); return new RepositoryResult<Statement>( new ExceptionConvertingIteration<Statement, RepositoryException>(result) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } }
[ "@", "Override", "public", "RepositoryResult", "<", "Statement", ">", "getStatements", "(", "Resource", "subj", ",", "URI", "pred", ",", "Value", "obj", ",", "boolean", "includeInferred", ",", "Resource", "...", "contexts", ")", "throws", "RepositoryException", ...
returns statements from supplied context TBD - should share code path with above getStatements @param subj @param pred @param obj @param includeInferred @param contexts @throws RepositoryException
[ "returns", "statements", "from", "supplied", "context" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L551-L614
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.size
@Override public long size() throws RepositoryException{ try { MarkLogicTupleQuery tupleQuery = prepareTupleQuery(COUNT_EVERYTHING); tupleQuery.setIncludeInferred(false); tupleQuery.setRulesets((SPARQLRuleset)null); tupleQuery.setConstrainingQueryDefinition((QueryDefinition)null); TupleQueryResult qRes = tupleQuery.evaluate(); // just one answer BindingSet result = qRes.next(); qRes.close(); return ((Literal) result.getBinding("ct").getValue()).longValue(); } catch (QueryEvaluationException | MalformedQueryException e) { throw new RepositoryException(e); } }
java
@Override public long size() throws RepositoryException{ try { MarkLogicTupleQuery tupleQuery = prepareTupleQuery(COUNT_EVERYTHING); tupleQuery.setIncludeInferred(false); tupleQuery.setRulesets((SPARQLRuleset)null); tupleQuery.setConstrainingQueryDefinition((QueryDefinition)null); TupleQueryResult qRes = tupleQuery.evaluate(); // just one answer BindingSet result = qRes.next(); qRes.close(); return ((Literal) result.getBinding("ct").getValue()).longValue(); } catch (QueryEvaluationException | MalformedQueryException e) { throw new RepositoryException(e); } }
[ "@", "Override", "public", "long", "size", "(", ")", "throws", "RepositoryException", "{", "try", "{", "MarkLogicTupleQuery", "tupleQuery", "=", "prepareTupleQuery", "(", "COUNT_EVERYTHING", ")", ";", "tupleQuery", ".", "setIncludeInferred", "(", "false", ")", ";"...
returns number of triples in the entire triple store @return long @throws RepositoryException
[ "returns", "number", "of", "triples", "in", "the", "entire", "triple", "store" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L781-L796
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.size
@Override public long size(Resource... contexts) throws RepositoryException { if (contexts == null) { contexts = new Resource[] { null }; } try { StringBuilder sb = new StringBuilder(); sb.append("SELECT (count(?s) as ?ct) where { GRAPH ?g { ?s ?p ?o }"); boolean first = true; // with no args, measure the whole triple store. if (contexts != null && contexts.length > 0) { sb.append("filter (?g = ("); for (Resource context : contexts) { if (first) { first = !first; } else { sb.append(","); } if (context == null) { sb.append("IRI(\""+DEFAULT_GRAPH_URI+"\")"); } else { sb.append("IRI(\"" + context.toString() + "\")"); } } sb.append(") )"); }else{ sb.append("filter (?g = (IRI(\""+DEFAULT_GRAPH_URI+"\")))"); } sb.append("}"); logger.debug(sb.toString()); MarkLogicTupleQuery tupleQuery = prepareTupleQuery(sb.toString()); tupleQuery.setIncludeInferred(false); tupleQuery.setRulesets((SPARQLRuleset) null); tupleQuery.setConstrainingQueryDefinition((QueryDefinition)null); TupleQueryResult qRes = tupleQuery.evaluate(); // just one answer BindingSet result = qRes.next(); qRes.close(); // if 'null' was one or more of the arguments, then totalSize will be non-zero. return ((Literal) result.getBinding("ct").getValue()).longValue(); } catch (QueryEvaluationException | MalformedQueryException e) { throw new RepositoryException(e); } }
java
@Override public long size(Resource... contexts) throws RepositoryException { if (contexts == null) { contexts = new Resource[] { null }; } try { StringBuilder sb = new StringBuilder(); sb.append("SELECT (count(?s) as ?ct) where { GRAPH ?g { ?s ?p ?o }"); boolean first = true; // with no args, measure the whole triple store. if (contexts != null && contexts.length > 0) { sb.append("filter (?g = ("); for (Resource context : contexts) { if (first) { first = !first; } else { sb.append(","); } if (context == null) { sb.append("IRI(\""+DEFAULT_GRAPH_URI+"\")"); } else { sb.append("IRI(\"" + context.toString() + "\")"); } } sb.append(") )"); }else{ sb.append("filter (?g = (IRI(\""+DEFAULT_GRAPH_URI+"\")))"); } sb.append("}"); logger.debug(sb.toString()); MarkLogicTupleQuery tupleQuery = prepareTupleQuery(sb.toString()); tupleQuery.setIncludeInferred(false); tupleQuery.setRulesets((SPARQLRuleset) null); tupleQuery.setConstrainingQueryDefinition((QueryDefinition)null); TupleQueryResult qRes = tupleQuery.evaluate(); // just one answer BindingSet result = qRes.next(); qRes.close(); // if 'null' was one or more of the arguments, then totalSize will be non-zero. return ((Literal) result.getBinding("ct").getValue()).longValue(); } catch (QueryEvaluationException | MalformedQueryException e) { throw new RepositoryException(e); } }
[ "@", "Override", "public", "long", "size", "(", "Resource", "...", "contexts", ")", "throws", "RepositoryException", "{", "if", "(", "contexts", "==", "null", ")", "{", "contexts", "=", "new", "Resource", "[", "]", "{", "null", "}", ";", "}", "try", "{...
returns number of triples in supplied context @param contexts @return long @throws RepositoryException
[ "returns", "number", "of", "triples", "in", "supplied", "context" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L805-L849
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.add
@Override public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { getClient().sendAdd(in, baseURI, dataFormat, contexts); }
java
@Override public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { getClient().sendAdd(in, baseURI, dataFormat, contexts); }
[ "@", "Override", "public", "void", "add", "(", "InputStream", "in", ",", "String", "baseURI", ",", "RDFFormat", "dataFormat", ",", "Resource", "...", "contexts", ")", "throws", "IOException", ",", "RDFParseException", ",", "RepositoryException", "{", "getClient", ...
add triples via inputstream @param in @param baseURI @param dataFormat @param contexts @throws IOException @throws RDFParseException @throws RepositoryException
[ "add", "triples", "via", "inputstream" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L978-L981
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.add
@Override public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { if(notNull(baseURI)) { getClient().sendAdd(file, baseURI, dataFormat, contexts); }else{ getClient().sendAdd(file, file.toURI().toString(), dataFormat, contexts); } }
java
@Override public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { if(notNull(baseURI)) { getClient().sendAdd(file, baseURI, dataFormat, contexts); }else{ getClient().sendAdd(file, file.toURI().toString(), dataFormat, contexts); } }
[ "@", "Override", "public", "void", "add", "(", "File", "file", ",", "String", "baseURI", ",", "RDFFormat", "dataFormat", ",", "Resource", "...", "contexts", ")", "throws", "IOException", ",", "RDFParseException", ",", "RepositoryException", "{", "if", "(", "no...
add triples via File will use file uri as base URI if none supplied @param file @param baseURI @param dataFormat @param contexts @throws IOException @throws RDFParseException @throws RepositoryException
[ "add", "triples", "via", "File" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L996-L1003
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.add
@Override public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { getClient().sendAdd(reader, baseURI, dataFormat, contexts); }
java
@Override public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { getClient().sendAdd(reader, baseURI, dataFormat, contexts); }
[ "@", "Override", "public", "void", "add", "(", "Reader", "reader", ",", "String", "baseURI", ",", "RDFFormat", "dataFormat", ",", "Resource", "...", "contexts", ")", "throws", "IOException", ",", "RDFParseException", ",", "RepositoryException", "{", "getClient", ...
add triples via Reader @param reader @param baseURI @param dataFormat @param contexts @throws IOException @throws RDFParseException @throws RepositoryException
[ "add", "triples", "via", "Reader" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L1016-L1019
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.add
@Override public void add(URL url, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { if(notNull(baseURI)) { getClient().sendAdd(new URL(url.toString()).openStream(), baseURI, dataFormat, contexts); }else{ getClient().sendAdd(new URL(url.toString()).openStream(), url.toString(), dataFormat, contexts); } }
java
@Override public void add(URL url, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { if(notNull(baseURI)) { getClient().sendAdd(new URL(url.toString()).openStream(), baseURI, dataFormat, contexts); }else{ getClient().sendAdd(new URL(url.toString()).openStream(), url.toString(), dataFormat, contexts); } }
[ "@", "Override", "public", "void", "add", "(", "URL", "url", ",", "String", "baseURI", ",", "RDFFormat", "dataFormat", ",", "Resource", "...", "contexts", ")", "throws", "IOException", ",", "RDFParseException", ",", "RepositoryException", "{", "if", "(", "notN...
add triples via URL sets base URI to url if none is supplied @param url @param baseURI @param dataFormat @param contexts @throws IOException @throws RDFParseException @throws RepositoryException
[ "add", "triples", "via", "URL" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L1034-L1041
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.addWithoutCommit
@Override protected void addWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts) throws RepositoryException { add(subject, predicate, object, contexts); }
java
@Override protected void addWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts) throws RepositoryException { add(subject, predicate, object, contexts); }
[ "@", "Override", "protected", "void", "addWithoutCommit", "(", "Resource", "subject", ",", "URI", "predicate", ",", "Value", "object", ",", "Resource", "...", "contexts", ")", "throws", "RepositoryException", "{", "add", "(", "subject", ",", "predicate", ",", ...
add without commit note- supplied to honor interface @param subject @param predicate @param object @param contexts @throws RepositoryException
[ "add", "without", "commit" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L1204-L1207
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.removeWithoutCommit
@Override protected void removeWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts) throws RepositoryException { remove(subject, predicate, object, contexts); }
java
@Override protected void removeWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts) throws RepositoryException { remove(subject, predicate, object, contexts); }
[ "@", "Override", "protected", "void", "removeWithoutCommit", "(", "Resource", "subject", ",", "URI", "predicate", ",", "Value", "object", ",", "Resource", "...", "contexts", ")", "throws", "RepositoryException", "{", "remove", "(", "subject", ",", "predicate", "...
remove without commit supplied to honor interface @param subject @param predicate @param object @param contexts @throws RepositoryException
[ "remove", "without", "commit" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L1220-L1223
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.setDefaultGraphPerms
@Override public void setDefaultGraphPerms(GraphPermissions graphPerms) { if(notNull(graphPerms)) { this.defaultGraphPerms = graphPerms; }else{ this.defaultGraphPerms = client.emptyGraphPerms(); } }
java
@Override public void setDefaultGraphPerms(GraphPermissions graphPerms) { if(notNull(graphPerms)) { this.defaultGraphPerms = graphPerms; }else{ this.defaultGraphPerms = client.emptyGraphPerms(); } }
[ "@", "Override", "public", "void", "setDefaultGraphPerms", "(", "GraphPermissions", "graphPerms", ")", "{", "if", "(", "notNull", "(", "graphPerms", ")", ")", "{", "this", ".", "defaultGraphPerms", "=", "graphPerms", ";", "}", "else", "{", "this", ".", "defa...
sets default graph permissions to be used by all queries @param graphPerms
[ "sets", "default", "graph", "permissions", "to", "be", "used", "by", "all", "queries" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L1294-L1301
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.configureWriteCache
@Override public void configureWriteCache(long initDelay, long delayCache, long cacheSize){ client.initTimer(initDelay, delayCache,cacheSize); }
java
@Override public void configureWriteCache(long initDelay, long delayCache, long cacheSize){ client.initTimer(initDelay, delayCache,cacheSize); }
[ "@", "Override", "public", "void", "configureWriteCache", "(", "long", "initDelay", ",", "long", "delayCache", ",", "long", "cacheSize", ")", "{", "client", ".", "initTimer", "(", "initDelay", ",", "delayCache", ",", "cacheSize", ")", ";", "}" ]
customise write cache interval and cache size. @param initDelay - initial interval before write cache is checked @param delayCache - interval (ms) to check write cache @param cacheSize - size (# triples) of write cache
[ "customise", "write", "cache", "interval", "and", "cache", "size", "." ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L1374-L1377
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
MarkLogicRepositoryConnection.mergeResource
private static Resource[] mergeResource(Resource o, Resource... arr) { if(o != null) { Resource[] newArray = new Resource[arr.length + 1]; newArray[0] = o; System.arraycopy(arr, 0, newArray, 1, arr.length); return newArray; }else{ return arr; } }
java
private static Resource[] mergeResource(Resource o, Resource... arr) { if(o != null) { Resource[] newArray = new Resource[arr.length + 1]; newArray[0] = o; System.arraycopy(arr, 0, newArray, 1, arr.length); return newArray; }else{ return arr; } }
[ "private", "static", "Resource", "[", "]", "mergeResource", "(", "Resource", "o", ",", "Resource", "...", "arr", ")", "{", "if", "(", "o", "!=", "null", ")", "{", "Resource", "[", "]", "newArray", "=", "new", "Resource", "[", "arr", ".", "length", "+...
private utility for merging Resource varargs @param o @param arr @return
[ "private", "utility", "for", "merging", "Resource", "varargs" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L1450-L1460
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/TripleDeleteCache.java
TripleDeleteCache.flush
protected synchronized void flush() throws RepositoryException, MalformedQueryException, UpdateExecutionException, IOException { if (cache.isEmpty()) { return; } StringBuffer entireQuery = new StringBuffer(); SPARQLQueryBindingSet bindingSet = new SPARQLQueryBindingSet(); for (Namespace ns :cache.getNamespaces()){ entireQuery.append("PREFIX "+ns.getPrefix()+": <"+ns.getName()+">. "); } entireQuery.append("DELETE DATA { "); Set<Resource> distinctCtx = new HashSet<Resource>(); for (Resource context :cache.contexts()) { distinctCtx.add(context); } for (Resource ctx : distinctCtx) { if (ctx != null) { entireQuery.append(" GRAPH <" + ctx + "> { "); } for (Statement stmt : cache.filter(null, null, null, ctx)) { entireQuery.append("<" + stmt.getSubject().stringValue() + "> "); entireQuery.append("<" + stmt.getPredicate().stringValue() + "> "); Value object=stmt.getObject(); if (object instanceof Literal) { Literal lit = (Literal) object; entireQuery.append("\""); entireQuery.append(SPARQLUtil.encodeString(lit.getLabel())); entireQuery.append("\""); if(null == lit.getLanguage()) { entireQuery.append("^^<" + lit.getDatatype().stringValue() + ">"); }else{ entireQuery.append("@" + lit.getLanguage().toString()); } } else { entireQuery.append("<" + object.stringValue() + "> "); } entireQuery.append("."); } if (ctx != null) { entireQuery.append(" }"); } } entireQuery.append("} "); log.info(entireQuery.toString()); client.sendUpdateQuery(entireQuery.toString(),bindingSet,false,null); lastCacheAccess = new Date(); //log.info("success writing cache: {}",String.valueOf(cache.size())); cache.clear(); }
java
protected synchronized void flush() throws RepositoryException, MalformedQueryException, UpdateExecutionException, IOException { if (cache.isEmpty()) { return; } StringBuffer entireQuery = new StringBuffer(); SPARQLQueryBindingSet bindingSet = new SPARQLQueryBindingSet(); for (Namespace ns :cache.getNamespaces()){ entireQuery.append("PREFIX "+ns.getPrefix()+": <"+ns.getName()+">. "); } entireQuery.append("DELETE DATA { "); Set<Resource> distinctCtx = new HashSet<Resource>(); for (Resource context :cache.contexts()) { distinctCtx.add(context); } for (Resource ctx : distinctCtx) { if (ctx != null) { entireQuery.append(" GRAPH <" + ctx + "> { "); } for (Statement stmt : cache.filter(null, null, null, ctx)) { entireQuery.append("<" + stmt.getSubject().stringValue() + "> "); entireQuery.append("<" + stmt.getPredicate().stringValue() + "> "); Value object=stmt.getObject(); if (object instanceof Literal) { Literal lit = (Literal) object; entireQuery.append("\""); entireQuery.append(SPARQLUtil.encodeString(lit.getLabel())); entireQuery.append("\""); if(null == lit.getLanguage()) { entireQuery.append("^^<" + lit.getDatatype().stringValue() + ">"); }else{ entireQuery.append("@" + lit.getLanguage().toString()); } } else { entireQuery.append("<" + object.stringValue() + "> "); } entireQuery.append("."); } if (ctx != null) { entireQuery.append(" }"); } } entireQuery.append("} "); log.info(entireQuery.toString()); client.sendUpdateQuery(entireQuery.toString(),bindingSet,false,null); lastCacheAccess = new Date(); //log.info("success writing cache: {}",String.valueOf(cache.size())); cache.clear(); }
[ "protected", "synchronized", "void", "flush", "(", ")", "throws", "RepositoryException", ",", "MalformedQueryException", ",", "UpdateExecutionException", ",", "IOException", "{", "if", "(", "cache", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "String...
flushes the cache, writing triples as graph @throws MarkLogicSesameException
[ "flushes", "the", "cache", "writing", "triples", "as", "graph" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/TripleDeleteCache.java#L54-L104
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicBooleanQuery.java
MarkLogicBooleanQuery.evaluate
@Override public boolean evaluate() throws QueryEvaluationException { try { sync(); return getMarkLogicClient().sendBooleanQuery(getQueryString(), getBindings(), getIncludeInferred(),getBaseURI()); }catch (RepositoryException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch (IOException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch(FailedRequestException e){ throw new QueryEvaluationException(e.getMessage(), e); } }
java
@Override public boolean evaluate() throws QueryEvaluationException { try { sync(); return getMarkLogicClient().sendBooleanQuery(getQueryString(), getBindings(), getIncludeInferred(),getBaseURI()); }catch (RepositoryException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch (IOException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch(FailedRequestException e){ throw new QueryEvaluationException(e.getMessage(), e); } }
[ "@", "Override", "public", "boolean", "evaluate", "(", ")", "throws", "QueryEvaluationException", "{", "try", "{", "sync", "(", ")", ";", "return", "getMarkLogicClient", "(", ")", ".", "sendBooleanQuery", "(", "getQueryString", "(", ")", ",", "getBindings", "(...
evaluate boolean query @return boolean @throws QueryEvaluationException
[ "evaluate", "boolean", "query" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicBooleanQuery.java#L65-L79
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicBackgroundGraphResult.java
MarkLogicBackgroundGraphResult.handleClose
@Override protected void handleClose() throws QueryEvaluationException { try { super.handleClose(); }catch(Exception e){ logger.error("MarkLogicBackgroundGraphResult handleClose() stream closed exception",e); throw new QueryEvaluationException(e); } }
java
@Override protected void handleClose() throws QueryEvaluationException { try { super.handleClose(); }catch(Exception e){ logger.error("MarkLogicBackgroundGraphResult handleClose() stream closed exception",e); throw new QueryEvaluationException(e); } }
[ "@", "Override", "protected", "void", "handleClose", "(", ")", "throws", "QueryEvaluationException", "{", "try", "{", "super", ".", "handleClose", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"MarkLogicBackgrou...
wrap exception, debug log
[ "wrap", "exception", "debug", "log" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/MarkLogicBackgroundGraphResult.java#L86-L94
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicGraphQuery.java
MarkLogicGraphQuery.evaluate
@Override public GraphQueryResult evaluate() throws QueryEvaluationException { try { sync(); return getMarkLogicClient().sendGraphQuery(getQueryString(),getBindings(),getIncludeInferred(),getBaseURI()); } catch (IOException e) { throw new QueryEvaluationException(e); } catch (MarkLogicSesameException e) { throw new QueryEvaluationException(e); } }
java
@Override public GraphQueryResult evaluate() throws QueryEvaluationException { try { sync(); return getMarkLogicClient().sendGraphQuery(getQueryString(),getBindings(),getIncludeInferred(),getBaseURI()); } catch (IOException e) { throw new QueryEvaluationException(e); } catch (MarkLogicSesameException e) { throw new QueryEvaluationException(e); } }
[ "@", "Override", "public", "GraphQueryResult", "evaluate", "(", ")", "throws", "QueryEvaluationException", "{", "try", "{", "sync", "(", ")", ";", "return", "getMarkLogicClient", "(", ")", ".", "sendGraphQuery", "(", "getQueryString", "(", ")", ",", "getBindings...
evaluate graph query @return GraphQueryResult @throws QueryEvaluationException
[ "evaluate", "graph", "query" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicGraphQuery.java#L66-L77
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicQuery.java
MarkLogicQuery.setBinding
public void setBinding(String name, String stringValue) { bindingSet.addBinding(name, ValueFactoryImpl.getInstance().createURI(stringValue)); }
java
public void setBinding(String name, String stringValue) { bindingSet.addBinding(name, ValueFactoryImpl.getInstance().createURI(stringValue)); }
[ "public", "void", "setBinding", "(", "String", "name", ",", "String", "stringValue", ")", "{", "bindingSet", ".", "addBinding", "(", "name", ",", "ValueFactoryImpl", ".", "getInstance", "(", ")", ".", "createURI", "(", "stringValue", ")", ")", ";", "}" ]
set individual binding @param name @param stringValue
[ "set", "individual", "binding" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicQuery.java#L140-L142
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicQuery.java
MarkLogicQuery.setBinding
@Override public void setBinding(String name, Value value) { bindingSet.addBinding(name, value); }
java
@Override public void setBinding(String name, Value value) { bindingSet.addBinding(name, value); }
[ "@", "Override", "public", "void", "setBinding", "(", "String", "name", ",", "Value", "value", ")", "{", "bindingSet", ".", "addBinding", "(", "name", ",", "value", ")", ";", "}" ]
set individual binding and value @param name @param value
[ "set", "individual", "binding", "and", "value" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicQuery.java#L149-L152
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicTupleQuery.java
MarkLogicTupleQuery.evaluate
public TupleQueryResult evaluate(long start, long pageLength) throws QueryEvaluationException { try { sync(); return getMarkLogicClient().sendTupleQuery(getQueryString(), getBindings(), start, pageLength, getIncludeInferred(), getBaseURI()); }catch (RepositoryException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch(FailedRequestException e){ throw new QueryEvaluationException(e.getMessage(), e); } }
java
public TupleQueryResult evaluate(long start, long pageLength) throws QueryEvaluationException { try { sync(); return getMarkLogicClient().sendTupleQuery(getQueryString(), getBindings(), start, pageLength, getIncludeInferred(), getBaseURI()); }catch (RepositoryException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e); }catch(FailedRequestException e){ throw new QueryEvaluationException(e.getMessage(), e); } }
[ "public", "TupleQueryResult", "evaluate", "(", "long", "start", ",", "long", "pageLength", ")", "throws", "QueryEvaluationException", "{", "try", "{", "sync", "(", ")", ";", "return", "getMarkLogicClient", "(", ")", ".", "sendTupleQuery", "(", "getQueryString", ...
evaluate tuple query with pagination @param start @param pageLength @return TupleQueryResult @throws QueryEvaluationException
[ "evaluate", "tuple", "query", "with", "pagination" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicTupleQuery.java#L79-L91
train
marklogic/marklogic-sesame
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicUpdateQuery.java
MarkLogicUpdateQuery.execute
@Override public void execute() throws UpdateExecutionException { try { sync(); getMarkLogicClient().sendUpdateQuery(getQueryString(), getBindings(), getIncludeInferred(), getBaseURI()); }catch(ForbiddenUserException | FailedRequestException e){ throw new UpdateExecutionException(e); } catch (RepositoryException e) { throw new UpdateExecutionException(e); } catch (MalformedQueryException e) { throw new UpdateExecutionException(e); } catch (IOException e) { throw new UpdateExecutionException(e); } }
java
@Override public void execute() throws UpdateExecutionException { try { sync(); getMarkLogicClient().sendUpdateQuery(getQueryString(), getBindings(), getIncludeInferred(), getBaseURI()); }catch(ForbiddenUserException | FailedRequestException e){ throw new UpdateExecutionException(e); } catch (RepositoryException e) { throw new UpdateExecutionException(e); } catch (MalformedQueryException e) { throw new UpdateExecutionException(e); } catch (IOException e) { throw new UpdateExecutionException(e); } }
[ "@", "Override", "public", "void", "execute", "(", ")", "throws", "UpdateExecutionException", "{", "try", "{", "sync", "(", ")", ";", "getMarkLogicClient", "(", ")", ".", "sendUpdateQuery", "(", "getQueryString", "(", ")", ",", "getBindings", "(", ")", ",", ...
execute update query @throws UpdateExecutionException
[ "execute", "update", "query" ]
d5b668ed2b3d5e90c9f1d5096012813c272062a2
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/query/MarkLogicUpdateQuery.java#L65-L79
train
jponge/lzma-java
src/main/java/lzma/sdk/lz/InWindow.java
InWindow.getMatchLen
public int getMatchLen(int index, int distance, int limit) { if (_streamEndWasReached) { if ((_pos + index) + limit > _streamPos) { limit = _streamPos - (_pos + index); } } distance++; // Byte *pby = _buffer + (size_t)_pos + index; int pby = _bufferOffset + _pos + index; int i; for (i = 0; i < limit && _bufferBase[pby + i] == _bufferBase[pby + i - distance]; i++) { } return i; }
java
public int getMatchLen(int index, int distance, int limit) { if (_streamEndWasReached) { if ((_pos + index) + limit > _streamPos) { limit = _streamPos - (_pos + index); } } distance++; // Byte *pby = _buffer + (size_t)_pos + index; int pby = _bufferOffset + _pos + index; int i; for (i = 0; i < limit && _bufferBase[pby + i] == _bufferBase[pby + i - distance]; i++) { } return i; }
[ "public", "int", "getMatchLen", "(", "int", "index", ",", "int", "distance", ",", "int", "limit", ")", "{", "if", "(", "_streamEndWasReached", ")", "{", "if", "(", "(", "_pos", "+", "index", ")", "+", "limit", ">", "_streamPos", ")", "{", "limit", "=...
index + limit have not to exceed _keepSizeAfter;
[ "index", "+", "limit", "have", "not", "to", "exceed", "_keepSizeAfter", ";" ]
763aeed49d92ca607c5c1e09fce7af611d59f2aa
https://github.com/jponge/lzma-java/blob/763aeed49d92ca607c5c1e09fce7af611d59f2aa/src/main/java/lzma/sdk/lz/InWindow.java#L159-L177
train
zalando-stups/spring-boot-etcd
zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java
EtcdClient.get
public EtcdResponse get(String key) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); return execute(builder, HttpMethod.GET, null, EtcdResponse.class); }
java
public EtcdResponse get(String key) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); return execute(builder, HttpMethod.GET, null, EtcdResponse.class); }
[ "public", "EtcdResponse", "get", "(", "String", "key", ")", "throws", "EtcdException", "{", "UriComponentsBuilder", "builder", "=", "UriComponentsBuilder", ".", "fromUriString", "(", "KEYSPACE", ")", ";", "builder", ".", "pathSegment", "(", "key", ")", ";", "ret...
Returns the node with the given key from etcd. @param key the node's key @return the response from etcd with the node @throws EtcdException in case etcd returned an error
[ "Returns", "the", "node", "with", "the", "given", "key", "from", "etcd", "." ]
6b4f48663d424777326c38b1e7da75c8b68a3841
https://github.com/zalando-stups/spring-boot-etcd/blob/6b4f48663d424777326c38b1e7da75c8b68a3841/zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java#L211-L216
train
zalando-stups/spring-boot-etcd
zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java
EtcdClient.put
public EtcdResponse put(final String key, final String value) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1); payload.set("value", value); return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class); }
java
public EtcdResponse put(final String key, final String value) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1); payload.set("value", value); return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class); }
[ "public", "EtcdResponse", "put", "(", "final", "String", "key", ",", "final", "String", "value", ")", "throws", "EtcdException", "{", "UriComponentsBuilder", "builder", "=", "UriComponentsBuilder", ".", "fromUriString", "(", "KEYSPACE", ")", ";", "builder", ".", ...
Sets the value of the node with the given key in etcd. Any previously existing key-value pair is returned as prevNode in the etcd response. @param key the node's key @param value the node's value @return the response from etcd with the node @throws EtcdException in case etcd returned an error
[ "Sets", "the", "value", "of", "the", "node", "with", "the", "given", "key", "in", "etcd", ".", "Any", "previously", "existing", "key", "-", "value", "pair", "is", "returned", "as", "prevNode", "in", "the", "etcd", "response", "." ]
6b4f48663d424777326c38b1e7da75c8b68a3841
https://github.com/zalando-stups/spring-boot-etcd/blob/6b4f48663d424777326c38b1e7da75c8b68a3841/zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java#L250-L258
train
zalando-stups/spring-boot-etcd
zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java
EtcdClient.delete
public EtcdResponse delete(final String key) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); return execute(builder, HttpMethod.DELETE, null, EtcdResponse.class); }
java
public EtcdResponse delete(final String key) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); return execute(builder, HttpMethod.DELETE, null, EtcdResponse.class); }
[ "public", "EtcdResponse", "delete", "(", "final", "String", "key", ")", "throws", "EtcdException", "{", "UriComponentsBuilder", "builder", "=", "UriComponentsBuilder", ".", "fromUriString", "(", "KEYSPACE", ")", ";", "builder", ".", "pathSegment", "(", "key", ")",...
Deletes the node with the given key from etcd. @param key the node's key @return the response from etcd with the node @throws EtcdException in case etcd returned an error
[ "Deletes", "the", "node", "with", "the", "given", "key", "from", "etcd", "." ]
6b4f48663d424777326c38b1e7da75c8b68a3841
https://github.com/zalando-stups/spring-boot-etcd/blob/6b4f48663d424777326c38b1e7da75c8b68a3841/zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java#L294-L299
train
zalando-stups/spring-boot-etcd
zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java
EtcdClient.listMembers
public EtcdMemberResponse listMembers() throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(MEMBERSPACE); return execute(builder, HttpMethod.GET, null, EtcdMemberResponse.class); }
java
public EtcdMemberResponse listMembers() throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(MEMBERSPACE); return execute(builder, HttpMethod.GET, null, EtcdMemberResponse.class); }
[ "public", "EtcdMemberResponse", "listMembers", "(", ")", "throws", "EtcdException", "{", "UriComponentsBuilder", "builder", "=", "UriComponentsBuilder", ".", "fromUriString", "(", "MEMBERSPACE", ")", ";", "return", "execute", "(", "builder", ",", "HttpMethod", ".", ...
Returns a representation of all members in the etcd cluster. @return the members @throws EtcdException in case etcd returned an error
[ "Returns", "a", "representation", "of", "all", "members", "in", "the", "etcd", "cluster", "." ]
6b4f48663d424777326c38b1e7da75c8b68a3841
https://github.com/zalando-stups/spring-boot-etcd/blob/6b4f48663d424777326c38b1e7da75c8b68a3841/zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java#L581-L584
train
zalando-stups/spring-boot-etcd
zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java
EtcdClient.updateMembers
private void updateMembers() { try { List<String> locations = new ArrayList<String>(); EtcdMemberResponse response = listMembers(); EtcdMember[] members = response.getMembers(); for (EtcdMember member : members) { String[] clientUrls = member.getClientURLs(); if (clientUrls != null) { for (String clientUrl : clientUrls) { try { String version = template.getForObject(clientUrl + "/version", String.class); if (version == null) { locations.add(clientUrl); } } catch (RestClientException e) { log.debug("ignoring URI " + clientUrl + " because of error.", e); } } } } if (!locations.isEmpty()) { this.locations = locations.toArray(new String[locations.size()]); } else { log.debug("not updating locations because no location is found"); } } catch (EtcdException e) { log.error("Could not update etcd cluster member.", e); } }
java
private void updateMembers() { try { List<String> locations = new ArrayList<String>(); EtcdMemberResponse response = listMembers(); EtcdMember[] members = response.getMembers(); for (EtcdMember member : members) { String[] clientUrls = member.getClientURLs(); if (clientUrls != null) { for (String clientUrl : clientUrls) { try { String version = template.getForObject(clientUrl + "/version", String.class); if (version == null) { locations.add(clientUrl); } } catch (RestClientException e) { log.debug("ignoring URI " + clientUrl + " because of error.", e); } } } } if (!locations.isEmpty()) { this.locations = locations.toArray(new String[locations.size()]); } else { log.debug("not updating locations because no location is found"); } } catch (EtcdException e) { log.error("Could not update etcd cluster member.", e); } }
[ "private", "void", "updateMembers", "(", ")", "{", "try", "{", "List", "<", "String", ">", "locations", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "EtcdMemberResponse", "response", "=", "listMembers", "(", ")", ";", "EtcdMember", "[", "]...
Updates the locations of the etcd cluster members.
[ "Updates", "the", "locations", "of", "the", "etcd", "cluster", "members", "." ]
6b4f48663d424777326c38b1e7da75c8b68a3841
https://github.com/zalando-stups/spring-boot-etcd/blob/6b4f48663d424777326c38b1e7da75c8b68a3841/zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java#L627-L658
train
zalando-stups/spring-boot-etcd
zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java
EtcdClient.execute
private <T> T execute(UriComponentsBuilder uriTemplate, HttpMethod method, MultiValueMap<String, String> requestData, Class<T> responseType) throws EtcdException { long startTimeMillis = System.currentTimeMillis(); int retry = -1; ResourceAccessException lastException = null; do { lastException = null; URI uri = uriTemplate.buildAndExpand(locations[locationIndex]).toUri(); RequestEntity<MultiValueMap<String, String>> requestEntity = new RequestEntity<>(requestData, null, method, uri); try { ResponseEntity<T> responseEntity = template.exchange(requestEntity, responseType); return responseEntity.getBody(); } catch (HttpStatusCodeException e) { EtcdError error = null; try { error = responseConverter.getObjectMapper().readValue(e.getResponseBodyAsByteArray(), EtcdError.class); } catch (IOException ex) { error = null; } throw new EtcdException(error, "Failed to execute " + requestEntity + ".", e); } catch (ResourceAccessException e) { log.debug("Failed to execute " + requestEntity + ", retrying if possible.", e); if (locationIndex == locations.length - 1) { locationIndex = 0; } else { locationIndex++; } lastException = e; } } while (retry <= retryCount && System.currentTimeMillis() - startTimeMillis < retryDuration); if (lastException != null) { throw lastException; } else { return null; } }
java
private <T> T execute(UriComponentsBuilder uriTemplate, HttpMethod method, MultiValueMap<String, String> requestData, Class<T> responseType) throws EtcdException { long startTimeMillis = System.currentTimeMillis(); int retry = -1; ResourceAccessException lastException = null; do { lastException = null; URI uri = uriTemplate.buildAndExpand(locations[locationIndex]).toUri(); RequestEntity<MultiValueMap<String, String>> requestEntity = new RequestEntity<>(requestData, null, method, uri); try { ResponseEntity<T> responseEntity = template.exchange(requestEntity, responseType); return responseEntity.getBody(); } catch (HttpStatusCodeException e) { EtcdError error = null; try { error = responseConverter.getObjectMapper().readValue(e.getResponseBodyAsByteArray(), EtcdError.class); } catch (IOException ex) { error = null; } throw new EtcdException(error, "Failed to execute " + requestEntity + ".", e); } catch (ResourceAccessException e) { log.debug("Failed to execute " + requestEntity + ", retrying if possible.", e); if (locationIndex == locations.length - 1) { locationIndex = 0; } else { locationIndex++; } lastException = e; } } while (retry <= retryCount && System.currentTimeMillis() - startTimeMillis < retryDuration); if (lastException != null) { throw lastException; } else { return null; } }
[ "private", "<", "T", ">", "T", "execute", "(", "UriComponentsBuilder", "uriTemplate", ",", "HttpMethod", "method", ",", "MultiValueMap", "<", "String", ",", "String", ">", "requestData", ",", "Class", "<", "T", ">", "responseType", ")", "throws", "EtcdExceptio...
Executes the given method on the given location using the given request data. @param uri the location @param method the HTTP method @param requestData the request data @return the etcd response @throws EtcdException in case etcd returned an error
[ "Executes", "the", "given", "method", "on", "the", "given", "location", "using", "the", "given", "request", "data", "." ]
6b4f48663d424777326c38b1e7da75c8b68a3841
https://github.com/zalando-stups/spring-boot-etcd/blob/6b4f48663d424777326c38b1e7da75c8b68a3841/zalando-boot-etcd/src/main/java/org/zalando/boot/etcd/EtcdClient.java#L674-L717
train
metamx/java-util
src/main/java/com/metamx/common/collect/MoreIterators.java
MoreIterators.before
public static <X> Iterator<X> before(final Iterator<X> iterator, final Runnable f) { return new Iterator<X>() { private final Runnable fOnlyOnce = new RunOnlyOnce(f); @Override public boolean hasNext() { fOnlyOnce.run(); return iterator.hasNext(); } @Override public X next() { fOnlyOnce.run(); return iterator.next(); } @Override public void remove() { fOnlyOnce.run(); iterator.remove(); } }; }
java
public static <X> Iterator<X> before(final Iterator<X> iterator, final Runnable f) { return new Iterator<X>() { private final Runnable fOnlyOnce = new RunOnlyOnce(f); @Override public boolean hasNext() { fOnlyOnce.run(); return iterator.hasNext(); } @Override public X next() { fOnlyOnce.run(); return iterator.next(); } @Override public void remove() { fOnlyOnce.run(); iterator.remove(); } }; }
[ "public", "static", "<", "X", ">", "Iterator", "<", "X", ">", "before", "(", "final", "Iterator", "<", "X", ">", "iterator", ",", "final", "Runnable", "f", ")", "{", "return", "new", "Iterator", "<", "X", ">", "(", ")", "{", "private", "final", "Ru...
Run f immediately before the first element of iterator is generated. Exceptions raised by f will prevent the requested behavior on the underlying iterator, and can be handled by the caller.
[ "Run", "f", "immediately", "before", "the", "first", "element", "of", "iterator", "is", "generated", ".", "Exceptions", "raised", "by", "f", "will", "prevent", "the", "requested", "behavior", "on", "the", "underlying", "iterator", "and", "can", "be", "handled"...
9d204043da1136e94fb2e2d63e3543a29bf54b4d
https://github.com/metamx/java-util/blob/9d204043da1136e94fb2e2d63e3543a29bf54b4d/src/main/java/com/metamx/common/collect/MoreIterators.java#L34-L61
train
metamx/java-util
src/main/java/com/metamx/common/collect/MoreIterators.java
MoreIterators.after
public static <X> Iterator<X> after(final Iterator<X> iterator, final Runnable f) { return new Iterator<X>() { private final Runnable fOnlyOnce = new RunOnlyOnce(f); @Override public boolean hasNext() { final boolean hasNext = iterator.hasNext(); if (!hasNext) { fOnlyOnce.run(); } return hasNext; } @Override public X next() { try { return iterator.next(); } catch (NoSuchElementException e) { fOnlyOnce.run(); // (f exceptions are prohibited because they destroy e here) throw e; } } @Override public void remove() { iterator.remove(); } }; }
java
public static <X> Iterator<X> after(final Iterator<X> iterator, final Runnable f) { return new Iterator<X>() { private final Runnable fOnlyOnce = new RunOnlyOnce(f); @Override public boolean hasNext() { final boolean hasNext = iterator.hasNext(); if (!hasNext) { fOnlyOnce.run(); } return hasNext; } @Override public X next() { try { return iterator.next(); } catch (NoSuchElementException e) { fOnlyOnce.run(); // (f exceptions are prohibited because they destroy e here) throw e; } } @Override public void remove() { iterator.remove(); } }; }
[ "public", "static", "<", "X", ">", "Iterator", "<", "X", ">", "after", "(", "final", "Iterator", "<", "X", ">", "iterator", ",", "final", "Runnable", "f", ")", "{", "return", "new", "Iterator", "<", "X", ">", "(", ")", "{", "private", "final", "Run...
Run f immediately after the last element of iterator is generated. Exceptions must not be raised by f.
[ "Run", "f", "immediately", "after", "the", "last", "element", "of", "iterator", "is", "generated", ".", "Exceptions", "must", "not", "be", "raised", "by", "f", "." ]
9d204043da1136e94fb2e2d63e3543a29bf54b4d
https://github.com/metamx/java-util/blob/9d204043da1136e94fb2e2d63e3543a29bf54b4d/src/main/java/com/metamx/common/collect/MoreIterators.java#L67-L101
train