code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static String applyUriReplace(String uriSource, Configuration conf) {
if (uriSource == null) return null;
String[] uriReplace = conf.getStrings(OUTPUT_URI_REPLACE);
if (uriReplace == null) return uriSource;
for (int i = 0; i < uriReplace.length - 1; i += 2) {
String re... | java |
public static String applyPrefixSuffix(String uriSource,
Configuration conf) {
if (uriSource == null) return null;
String prefix = conf.get(OUTPUT_URI_PREFIX);
String suffix = conf.get(OUTPUT_URI_SUFFIX);
if (prefix == null && suffix == null) {
return uriSource;
... | java |
public static String[] expandArguments(String[] args) throws Exception {
List<String> options = new ArrayList<String>();
for (int i = 0; i < args.length; i++) {
if (args[i].equals(OPTIONS_FILE)) {
if (i == args.length - 1) {
throw new Exception("Missing o... | java |
private static String removeQuotesEncolosingOption(
String fileName, String option) throws Exception {
// Attempt to remove double quotes. If successful, return.
String option1 = removeQuoteCharactersIfNecessary(fileName, option, '"');
if (!option1.equals(option)) {
// Q... | java |
private static String removeQuoteCharactersIfNecessary(String fileName,
String option, char quote) throws Exception {
boolean startingQuote = (option.charAt(0) == quote);
boolean endingQuote = (option.charAt(option.length() - 1) == quote);
if (startingQuote && endingQuote) {
... | java |
private int assignThreads(int splitIndex, int splitCount) {
if (threadsPerSplit > 0) {
return threadsPerSplit;
}
if (splitCount == 1) {
return threadCount;
}
if (splitCount * minThreads > threadCount) {
return minThreads;
}
if (splitIndex %... | java |
public void configFields(Configuration conf, String[] fields)
throws IllegalArgumentException, IOException {
for (int i = 0; i < fields.length; i++) {
fields[i] = fields[i].trim();
if ("".equals(fields[i])) {
LOG.warn("Column " + (i+1) + " has no header and w... | java |
public void setClient(AerospikeClient client) {
this.client = client;
this.updatePolicy = new WritePolicy(this.client.writePolicyDefault);
this.updatePolicy.recordExistsAction = RecordExistsAction.UPDATE_ONLY;
this.insertPolicy = new WritePolicy(this.client.writePolicyDefault);
this.insertPolicy.recordExistsA... | java |
public KeyRecordIterator select(String namespace, String set, Filter filter, Qualifier... qualifiers) {
Statement stmt = new Statement();
stmt.setNamespace(namespace);
stmt.setSetName(set);
if (filter != null)
stmt.setFilters(filter);
return select(stmt, qualifiers);
} | java |
public void insert(String namespace, String set, Key key, List<Bin> bins) {
insert(namespace, set, key, bins, 0);
} | java |
public void insert(String namespace, String set, Key key, List<Bin> bins, int ttl) {
this.client.put(this.insertPolicy, key, bins.toArray(new Bin[0]));
} | java |
public void insert(Statement stmt, KeyQualifier keyQualifier, List<Bin> bins) {
insert(stmt, keyQualifier, bins, 0);
} | java |
public void insert(Statement stmt, KeyQualifier keyQualifier, List<Bin> bins, int ttl) {
Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName());
// Key key = new Key(stmt.getNamespace(), stmt.getSetName(), keyQualifier.getValue1());
this.client.put(this.insertPolicy, key, bins.toArray(new Bin[0])... | java |
public Map<String, Long> update(Statement stmt, List<Bin> bins, Qualifier... qualifiers) {
if (qualifiers != null && qualifiers.length == 1 && qualifiers[0] instanceof KeyQualifier) {
KeyQualifier keyQualifier = (KeyQualifier) qualifiers[0];
Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName())... | java |
public Map<String, Long> delete(Statement stmt, Qualifier... qualifiers) {
if (qualifiers == null || qualifiers.length == 0) {
/*
* There are no qualifiers, so delete every record in the set
* using Scan UDF delete
*/
ExecuteTask task = client.execute(null, stmt, QUERY_MODULE, "delete_record");
t... | java |
public synchronized void refreshNamespaces() {
/*
* cache namespaces
*/
if (this.namespaceCache == null) {
this.namespaceCache = new TreeMap<String, Namespace>();
Node[] nodes = client.getNodes();
for (Node node : nodes) {
try {
String namespaceString = Info.request(getInfoPolicy(), node, "n... | java |
public synchronized void refreshIndexes() {
/*
* cache index by Bin name
*/
if (this.indexCache == null)
this.indexCache = new TreeMap<String, Index>();
Node[] nodes = client.getNodes();
for (Node node : nodes) {
if (node.isActive()) {
try {
String indexString = Info.request(getInfoPolicy(... | java |
public synchronized void refreshModules() {
if (this.moduleCache == null)
this.moduleCache = new TreeMap<String, Module>();
boolean loadedModules = false;
Node[] nodes = client.getNodes();
for (Node node : nodes) {
try {
String packagesString = Info.request(infoPolicy, node, "udf-list");
if (!pac... | java |
@Override
public void close() throws IOException {
if (this.client != null)
this.client.close();
indexCache.clear();
indexCache = null;
updatePolicy = null;
insertPolicy = null;
infoPolicy = null;
queryPolicy = null;
moduleCache.clear();
moduleCache = null;
} | java |
public void setIndexInfo(String info) {
//ns=phobos_sindex:set=longevity:indexname=str_100_idx:num_bins=1:bins=str_100_bin:type=TEXT:sync_state=synced:state=RW;
//ns=test:set=Customers:indexname=mail_index_userss:bin=email:type=STRING:indextype=LIST:path=email:sync_state=synced:state=RW
if (!info.isEmpty()) {
... | java |
public void clear() {
Record record = this.client.get(null, key, tailBin, topBin);
long tail = record.getLong(tailBin);
long top = record.getLong(topBin);
List<Key> subKeys = subrecordKeys(tail, top);
for (Key key : subKeys) {
this.client.delete(null, key);
}
} | java |
public void destroy() {
clear();
this.client.operate(null, key, Operation.put(Bin.asNull(binName)));
} | java |
List<Key> subrecordKeys(long lowTime, long highTime) {
List<Key> keys = new ArrayList<Key>();
long lowBucketNumber = bucketNumber(lowTime);
long highBucketNumber = bucketNumber(highTime);
for (long index = lowBucketNumber; index <= highBucketNumber; index += this.bucketSize) {
keys.add(formSubrecordKey(index... | java |
public void update(Value value) {
if (size() == 0) {
add(value);
} else {
Key subKey = makeSubKey(value);
client.put(this.policy, subKey, new Bin(ListElementBinName, value));
}
} | java |
public void remove(Value value) {
Key subKey = makeSubKey(value);
List<byte[]> digestList = getDigestList();
int index = digestList.indexOf(subKey.digest);
client.delete(this.policy, subKey);
client.operate(this.policy, this.key, ListOperation.remove(this.binNameString, index));
} | java |
public void remove(List<Value> values) {
Key[] keys = makeSubKeys(values);
List<byte[]> digestList = getDigestList();
// int startIndex = digestList.IndexOf (subKey.digest);
// int count = values.Count;
// foreach (Key key in keys){
//
// client.Delete (this.policy, key);
// }
// client.Operat... | java |
@SuppressWarnings("serial")
public List<?> find(Value value) throws AerospikeException {
Key subKey = makeSubKey(value);
Record record = client.get(this.policy, subKey, ListElementBinName);
if (record != null) {
final Object result = record.getValue(ListElementBinName);
return new ArrayList<Object>() {{
... | java |
public void destroy() {
List<byte[]> digestList = getDigestList();
client.put(this.policy, this.key, Bin.asNull(this.binNameString));
for (byte[] digest : digestList) {
Key subKey = new Key(this.key.namespace, digest, null, null);
client.delete(this.policy, subKey);
}
} | java |
public int size() {
Record record = client.operate(this.policy, this.key, ListOperation.size(this.binNameString));
if (record != null) {
return record.getInt(this.binNameString);
}
return 0;
} | java |
public static void printInfo(String title, String infoString) {
if (infoString == null) {
System.out.println("Null info string");
return;
}
String[] outerParts = infoString.split(";");
System.out.println(title);
for (String s : outerParts) {
String[] innerParts = s.split(":");
for (String parts :... | java |
public static String infoAll(AerospikeClient client, String cmd) {
Node[] nodes = client.getNodes();
StringBuilder results = new StringBuilder();
for (Node node : nodes) {
results.append(Info.request(node.getHost().name, node.getHost().port, cmd)).append("\n");
}
return results.toString();
} | java |
public static Map<String, String> toMap(String source) {
HashMap<String, String> responses = new HashMap<String, String>();
String values[] = source.split(";");
for (String value : values) {
String nv[] = value.split("=");
if (nv.length >= 2) {
responses.put(nv[0], nv[1]);
} else if (nv.length == 1... | java |
public static List<NameValuePair> toNameValuePair(Object parent, Map<String, String> map) {
List<NameValuePair> list = new ArrayList<NameValuePair>();
for (String key : map.keySet()) {
NameValuePair nvp = new NameValuePair(parent, key, map.get(key));
list.add(nvp);
}
return list;
} | java |
public static MultiPoint of(Stream<Point> points) {
return of(points.collect(Collectors.toList()));
} | java |
public static LinearRing of(Iterable<Point> points) {
LinearPositions.Builder builder = LinearPositions.builder();
for(Point point : points) {
builder.addSinglePosition(point.positions());
}
return new LinearRing(builder.build());
} | java |
public List<Point> points() {
return positions().children().stream()
.map(Point::new)
.collect(Collectors.toList());
} | java |
public static Point from(double lon, double lat, double alt) {
return new Point(new SinglePosition(lon, lat, alt));
} | java |
public void fireEvent(final Event<?> event)
{
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
bus.fireEventFromSource(event, dialog.getInterfaceModel().getId());
}
});
} | java |
@Override
public void onInteractionEvent(final InteractionEvent event) {
QName id = event.getId();
QName source = (QName)event.getSource();
final Set<Procedure> collection = procedures.get(id);
Procedure execution = null;
if(collection!=null)
{
for(Proce... | java |
public void onSaveDatasource(AddressTemplate template, final String dsName, final Map changeset) {
dataSourceStore.saveDatasource(template, dsName, changeset,
new SimpleCallback<ResponseWrapper<Boolean>>() {
@Override
public void onSuccess(ResponseWrapper... | java |
@Override
public void onCreateProperty(String reference, PropertyRecord prop) {
presenter.onCreateXAProperty(reference, prop);
} | java |
protected void code(String template, String packageName, String className, Supplier<Map<String, Object>> context) {
StringBuffer code = generate(template, context);
writeCode(packageName, className, code);
} | java |
protected void resource(String template, String packageName, String resourceName, Supplier<Map<String, Object>> context) {
StringBuffer code = generate(template, context);
writeResource(packageName, resourceName, code);
} | java |
public void flushChildScopes(QName unitId) {
Set<Integer> childScopes = findChildScopes(unitId);
for(Integer scopeId : childScopes)
{
MutableContext mutableContext = statementContexts.get(scopeId);
mutableContext.clearStatements();
}
} | java |
public boolean isWithinActiveScope(final QName unitId) {
final Node<Scope> self = dialog.getScopeModel().findNode(
dialog.findUnit(unitId).getScopeId()
);
final Scope scopeOfUnit = self.getData();
int parentScopeId = getParentScope(unitId).getId();
Scope activeS... | java |
public ModelNode fromChangeSet(ResourceAddress resourceAddress, Map<String, Object> changeSet) {
ModelNode define = new ModelNode();
define.get(ADDRESS).set(resourceAddress);
define.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
ModelNode undefine = new ModelNode();
undefine.get(ADDRE... | java |
public List<T> apply(Predicate<T> predicate, List<T> candidates)
{
List<T> filtered = new ArrayList<T>(candidates.size());
for(T entity : candidates)
{
if(predicate.appliesTo(entity))
filtered.add(entity);
}
return filtered;
} | java |
static void parseSubsystems(ModelNode node, List<Subsystem> subsystems) {
List<Property> properties = node.get("subsystem").asPropertyList();
for (Property property : properties) {
Subsystem subsystem = new Subsystem(property.getName(), property.getValue());
subsystems.add(subsys... | java |
private static void assignKeyFromAddressNode(ModelNode payload, ModelNode address) {
List<Property> props = address.asPropertyList();
Property lastToken = props.get(props.size()-1);
payload.get("entity.key").set(lastToken.getValue().asString());
} | java |
public void navigateHandlerView() {
// if endpoint tab
if (tabLayoutpanel.getSelectedIndex() == 1) {
if (endpointHandlerPages.getPage() == 0)
endpointHandlerPages.showPage(1);
// else the client tab
} else if (tabLayoutpanel.getSelectedIndex() == 2) {
... | java |
@SuppressWarnings("unchecked")
public <T extends ElementType> boolean positiveLookaheadBefore(
ElementType before,
T... expected
) {
Character lookahead;
for (int i = 1; i <= elements.length; i++) {
lookahead = lookahead(i);
if (before.isMatchedBy(lookahea... | java |
private void pushState(final S state) {
this.state = state;
header.setHTML(TEMPLATE.header(currentStep().getTitle()));
clearError();
body.showWidget(state); // will call onShow(C) for the current step
footer.back.setEnabled(state != initialState());
footer.next
... | java |
public void showAddDialog(final ModelNode address, boolean isSingleton, SecurityContext securityContext, ModelNode description) {
String resourceAddress = AddressUtils.asKey(address, isSingleton);
if(securityContext.getOperationPriviledge(resourceAddress, "add").isGranted()) {
_showAddDial... | java |
public void onSaveFilter(AddressTemplate address, String name, Map changeset) {
operationDelegate.onSaveResource(address, name, changeset, defaultSaveOpCallbacks);
} | java |
private boolean configUpdated() {
try {
URL url = ctx.getResource(resourcesDir + configResource);
URLConnection con;
if (url == null) return false ;
con = url.openConnection();
long lastModified = con.getLastModified();
long XHP_LAST_MODIFI... | java |
public <T extends Mapping> T getMapping(MappingType type)
{
return (T) mappings.get(type);
} | java |
public <T extends Mapping> T findMapping(MappingType type)
{
return (T) this.findMapping(type, DEFAULT_PREDICATE);
} | java |
public void transform( InputStream xmlIS,
InputStream xslIS,
Map params,
OutputStream result,
String encoding) {
try {
TransformerFactory trFac = TransformerFactory.newInstance();
... | java |
protected static String jsonEscape(final String orig) {
final int length = orig.length();
final StringBuilder builder = new StringBuilder(length + 32);
builder.append('"');
for (int i = 0; i < length; i = orig.offsetByCodePoints(i,1)) {
final char cp = orig.charAt(i);
... | java |
public String toJSONString(final boolean compact) {
final StringBuilder builder = new StringBuilder();
formatAsJSON(builder, 0, !compact);
return builder.toString();
} | java |
public <T> void set(String key, T value) {
data.put(key, value);
} | java |
public void single(final C context, Outcome<C> outcome, final Function<C> function) {
SingletonControl ctrl = new SingletonControl(context, outcome);
progress.reset(1);
function.execute(ctrl);
} | java |
@SuppressWarnings("unchecked")
public void series(final Outcome outcome, final Function... functions) {
_series(null, outcome, functions); // generic signature problem, hence null
} | java |
@SafeVarargs
public final void waterfall(final C context, final Outcome<C> outcome, final Function<C>... functions) {
_series(context, outcome, functions);
} | java |
@SuppressWarnings("unchecked")
public void parallel(C context, final Outcome<C> outcome, final Function<C>... functions) {
final C finalContext = context != null ? context : (C) EMPTY_CONTEXT;
final CountingControl ctrl = new CountingControl(finalContext, functions);
progress.reset(functions... | java |
public void whilst(Precondition condition, final Outcome outcome, final Function function) {
whilst(condition, outcome, function, -1);
} | java |
private static void assertConsumer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {
Set<Resource<ResourceType>> producedTypes = unit.getOutputs();
for (Resource<ResourceType> resource : producedTypes) {
boolean match = false;
for(QName id : b... | java |
private static void assertProducer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {
Set<Resource<ResourceType>> consumedTypes = unit.getInputs();
for (Resource<ResourceType> resource : consumedTypes) {
boolean match = false;
for(QName id : beh... | java |
public void setChoices(List<String> choices) {
if (!limitChoices) throw new IllegalArgumentException("Attempted to set choices when choices are not limited.");
List<String> sorted = new ArrayList<String>();
sorted.addAll(choices);
Collections.sort(sorted);
((ComboBoxItem)this.na... | java |
public String getResourceType() {
if (!tokens.isEmpty() && tokens.getLast().hasKey()) {
return tokens.getLast().getKey();
}
return null;
} | java |
public void reset() {
for (long i = 0; i < idCounter; i++) {
localStorage.removeItem(key(i));
}
idCounter = 0;
localStorage.removeItem(documentsKey());
localStorage.removeItem(indexKey());
resetInternal();
Log.info("Reset index to " + indexKey());
... | java |
public List<Property> asPropertyList() throws IllegalArgumentException {
if(ModelValue.UNDEFINED == value)
return Collections.EMPTY_LIST;
else
return value.asPropertyList();
} | java |
public ModelNode setExpression(final String newValue) {
if (newValue == null) {
throw new IllegalArgumentException("newValue is null");
}
checkProtect();
value = new ExpressionValue(newValue);
return this;
} | java |
public ModelNode set(final String newValue) {
if (newValue == null) {
throw new IllegalArgumentException("newValue is null");
}
checkProtect();
value = new StringModelValue(newValue);
return this;
} | java |
public void onCreateResource(final AddressTemplate addressTemplate, final String name, final ModelNode payload,
final Callback... callback) {
ModelNode op = payload.clone();
op.get(ADDRESS).set(addressTemplate.resolve(statementContext, name));
op.get(OP).set(ADD)... | java |
public void onSaveResource(final AddressTemplate addressTemplate, final String name,
Map<String, Object> changedValues, final Callback... callback) {
final ResourceAddress address = addressTemplate.resolve(statementContext, name);
final ModelNodeAdapter adapter = new Mode... | java |
public void prepare(Element anchor, T item) {
this.currentAnchor = anchor;
this.currentItem = item;
if(!this.timer.isRunning())
{
timer.schedule(DELAY_MS);
}
} | java |
public void setWidgetMinSize(Widget child, int minSize) {
assertIsChild(child);
Splitter splitter = getAssociatedSplitter(child);
// The splitter is null for the center element.
if (splitter != null) {
splitter.setMinSize(minSize);
}
} | java |
public void setWidgetToggleDisplayAllowed(Widget child, boolean allowed) {
assertIsChild(child);
Splitter splitter = getAssociatedSplitter(child);
// The splitter is null for the center element.
if (splitter != null) {
splitter.setToggleDisplayAllowed(allowed);
}
... | java |
private void onItemSelected(TreeItem treeItem) {
treeItem.getElement().focus();
final LinkedList<String> path = resolvePath(treeItem);
formView.clearDisplay();
descView.clearDisplay();
ModelNode address = toAddress(path);
ModelNode displayAddress = address.clone();
... | java |
public void updateRootTypes(ModelNode address, List<ModelNode> modelNodes) {
deck.showWidget(CHILD_VIEW);
tree.clear();
descView.clearDisplay();
formView.clearDisplay();
offsetDisplay.clear();
// IMPORTANT: when pin down is active, we need to consider the offset to calc... | java |
public void updateChildrenTypes(ModelNode address, List<ModelNode> modelNodes) {
TreeItem rootItem = findTreeItem(tree, address);
addChildrenTypes((ModelTreeItem) rootItem, modelNodes);
} | java |
private ServerGroupRecord model2ServerGroup(String groupName, ModelNode model) {
ServerGroupRecord record = factory.serverGroup().as();
record.setName(groupName);
record.setProfileName(model.get("profile").asString());
record.setSocketBinding(model.get("socket-binding-group").asString()... | java |
public AuthorisationDecision getReadPriviledge() {
return checkPriviledge(new Priviledge() {
@Override
public boolean isGranted(Constraints c) {
boolean readable = c.isReadResource();
if (!readable)
Log.info("read privilege denied for... | java |
public static void setValue(ModelNode target, ModelType type, Object propValue) {
if (type.equals(ModelType.STRING)) {
target.set((String) propValue);
} else if (type.equals(ModelType.INT)) {
target.set((Integer) propValue);
} else if (type.equals(ModelType.DOUBLE)) {
... | java |
private void doGroupCheck() {
if (!hasTabs()) return;
for (String groupName : getGroupNames()) {
String tabName = getGroupedAttribtes(groupName).get(0).getTabName();
for (PropertyBinding propBinding : getGroupedAttribtes(groupName)) {
if (!tabName.equals(pr... | java |
public void onRemoveChildResource(final ModelNode address, final ModelNode selection) {
final ModelNode fqAddress = AddressUtils.toFqAddress(address, selection.asString());
_loadMetaData(fqAddress, new ResourceData(true), new Outcome<ResourceData>() {
@Override
p... | java |
private void _onRemoveChildResource(final ModelNode address, final ModelNode selection) {
final ModelNode fqAddress = AddressUtils.toFqAddress(address, selection.asString());
final ModelNode operation = new ModelNode();
operation.get(OP).set(REMOVE);
operation.get(ADDRESS).set(fqAddres... | java |
public void onPrepareAddChildResource(final ModelNode address, final boolean isSingleton) {
_loadMetaData(address, new ResourceData(true), new Outcome<ResourceData>() {
@Override
public void onFailure(ResourceData context) {
Console.error("Failed ... | java |
private void populateRepackagedToCredentialReference(ModelNode payload, String repackagedPropName, String propertyName) {
ModelNode value = payload.get(repackagedPropName);
if (payload.hasDefined(repackagedPropName) && value.asString().trim().length() > 0) {
payload.get(CREDENTIAL_REFERENCE)... | java |
public Map<String, Integer> getRequiredStatements() {
Map<String, Integer> required = new HashMap<String,Integer>();
for(Token token : address)
{
if(!token.hasKey())
{
// a single token or token expression
// These are currently skipped: S... | java |
private HttpURLConnection getURLConnection(String str)
throws MalformedURLException {
try {
if (isHttps) {
/* when communicating with the server which has unsigned or invalid
* certificate (https), SSLException or IOException is thrown.
* ... | java |
public InputStream getInputStream() {
try
{
int responseCode = this.urlConnection.getResponseCode();
try
{
// HACK: manually follow redirects, for the login to work
// HTTPUrlConnection auto redirect doesn't respect the provided header... | java |
public InputStream doPost(byte[] postData, String contentType) {
this.urlConnection.setDoOutput(true);
if (contentType != null) this.urlConnection.setRequestProperty( "Content-type", contentType );
OutputStream out = null;
try {
out = this.getOutputStream();
if(o... | java |
public void toggle() {
Command cmd = state.isPrimary() ? command1 : command2;
setState(state.other());
cmd.execute();
} | java |
public void setState(State state) {
this.state = state;
setText(state.isPrimary() ? text1 : text2);
} | java |
public String getNormalizedLocalPart() {
int i = localPart.indexOf("#");
if(i!=-1)
return localPart.substring(0, i);
else
return localPart;
} | java |
private boolean createChild(Property sibling, String parentURI) {
boolean skipped = sibling.getName().equals("children");
if (!skipped) {
//dump(sibling);
String dataType = null;
String uri = "";
if (sibling.getValue().hasDefined("class-name")) {
... | java |
@Override
public void selectTab(final String text) {
for (int i = 0; i < tabs.size(); i++) {
if (text.equals(tabs.get(i).getText())) {
selectTab(i);
return;
}
}
// not found in visible tabs, should be in off-page
for (OffPageTe... | java |
private void parseResponse(ModelNode response, AsyncCallback<Map<String,String>> callback) {
//System.out.println(response.toString());
Map<String, String> serverValues = new HashMap<String,String>();
if(isStandalone)
{
serverValues.put("Standalone Server", response.get(RE... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.