_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21200 | SpoilerElement.addSpoiler | train | public static void addSpoiler(Message message, String lang, String hint) {
message.addExtension(new SpoilerElement(lang, hint));
} | java | {
"resource": ""
} |
q21201 | SpoilerElement.getSpoilers | train | public static Map<String, String> getSpoilers(Message message) {
if (!containsSpoiler(message)) {
return Collections.emptyMap();
}
List<ExtensionElement> spoilers = message.getExtensions(SpoilerElement.ELEMENT, NAMESPACE);
Map<String, String> map = new HashMap<>();
... | java | {
"resource": ""
} |
q21202 | AgentSession.getAgentRoster | train | public AgentRoster getAgentRoster() throws NotConnectedException, InterruptedException {
if (agentRoster == null) {
agentRoster = new AgentRoster(connection, workgroupJID);
}
// This might be the first time the user has asked for the roster. If so, we
// want to wait up to 2... | java | {
"resource": ""
} |
q21203 | AgentSession.setMetaData | train | public void setMetaData(String key, String val) throws XMPPException, SmackException, InterruptedException {
synchronized (this.metaData) {
List<String> oldVals = metaData.get(key);
if (oldVals == null || !oldVals.get(0).equals(val)) {
oldVals.set(0, val);
... | java | {
"resource": ""
} |
q21204 | AgentSession.removeMetaData | train | public void removeMetaData(String key) throws XMPPException, SmackException, InterruptedException {
synchronized (this.metaData) {
List<String> oldVal = metaData.remove(key);
if (oldVal != null) {
setStatus(presenceMode, maxChats);
}
}
} | java | {
"resource": ""
} |
q21205 | AgentSession.setOnline | train | public void setOnline(boolean online) throws XMPPException, SmackException, InterruptedException {
// If the online status hasn't changed, do nothing.
if (this.online == online) {
return;
}
Presence presence;
// If the user is going online...
if (online) {
... | java | {
"resource": ""
} |
q21206 | AgentSession.dequeueUser | train | public void dequeueUser(EntityJid userID) throws XMPPException, NotConnectedException, InterruptedException {
// todo: this method simply won't work right now.
DepartQueuePacket departPacket = new DepartQueuePacket(workgroupJID, userID);
// PENDING
this.connection.sendStanza(departPacke... | java | {
"resource": ""
} |
q21207 | AgentSession.getOccupantsInfo | train | public OccupantsInfo getOccupantsInfo(String roomID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
OccupantsInfo request = new OccupantsInfo(roomID);
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
OccupantsInfo response = (Occ... | java | {
"resource": ""
} |
q21208 | AgentSession.getQueue | train | public WorkgroupQueue getQueue(String queueName) {
Resourcepart queueNameResourcepart;
try {
queueNameResourcepart = Resourcepart.from(queueName);
}
catch (XmppStringprepException e) {
throw new IllegalArgumentException(e);
}
return getQueue(queueN... | java | {
"resource": ""
} |
q21209 | AgentSession.addOfferListener | train | public void addOfferListener(OfferListener offerListener) {
synchronized (offerListeners) {
if (!offerListeners.contains(offerListener)) {
offerListeners.add(offerListener);
}
}
} | java | {
"resource": ""
} |
q21210 | AgentSession.addInvitationListener | train | public void addInvitationListener(WorkgroupInvitationListener invitationListener) {
synchronized (invitationListeners) {
if (!invitationListeners.contains(invitationListener)) {
invitationListeners.add(invitationListener);
}
}
} | java | {
"resource": ""
} |
q21211 | AgentSession.setNote | train | public void setNote(String sessionID, String note) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
ChatNotes notes = new ChatNotes();
notes.setType(IQ.Type.set);
notes.setTo(workgroupJID);
notes.setSessionID(sessionID);
notes.setNote... | java | {
"resource": ""
} |
q21212 | AgentSession.getNote | train | public ChatNotes getNote(String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
ChatNotes request = new ChatNotes();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
request.setSessionID(sessionID);
ChatNotes res... | java | {
"resource": ""
} |
q21213 | AgentSession.getAgentHistory | train | public AgentChatHistory getAgentHistory(EntityBareJid jid, int maxSessions, Date startDate) throws XMPPException, NotConnectedException, InterruptedException {
AgentChatHistory request;
if (startDate != null) {
request = new AgentChatHistory(jid, maxSessions, startDate);
}
el... | java | {
"resource": ""
} |
q21214 | AgentSession.getSearchSettings | train | public SearchSettings getSearchSettings() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
SearchSettings request = new SearchSettings();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
SearchSettings response = connection.createSt... | java | {
"resource": ""
} |
q21215 | AgentSession.getMacros | train | public MacroGroup getMacros(boolean global) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Macros request = new Macros();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
request.setPersonal(!global);
Macros response = con... | java | {
"resource": ""
} |
q21216 | AgentSession.saveMacros | train | public void saveMacros(MacroGroup group) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Macros request = new Macros();
request.setType(IQ.Type.set);
request.setTo(workgroupJID);
request.setPersonal(true);
request.setPersonalMacroGrou... | java | {
"resource": ""
} |
q21217 | AgentSession.getChatMetadata | train | public Map<String, List<String>> getChatMetadata(String sessionID) throws XMPPException, NotConnectedException, InterruptedException {
ChatMetadata request = new ChatMetadata();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
request.setSessionID(sessionID);
ChatMetad... | java | {
"resource": ""
} |
q21218 | AgentSession.getGenericSettings | train | public GenericSettings getGenericSettings(XMPPConnection con, String query) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
GenericSettings setting = new GenericSettings();
setting.setType(IQ.Type.get);
setting.setTo(workgroupJID);
GenericSe... | java | {
"resource": ""
} |
q21219 | TransportCandidate.isNull | train | public boolean isNull() {
if (ip == null) {
return true;
} else if (ip.length() == 0) {
return true;
} else if (port < 0) {
return true;
} else {
return false;
}
} | java | {
"resource": ""
} |
q21220 | ICECandidate.compareTo | train | @Override
public int compareTo(ICECandidate arg) {
if (getPreference() < arg.getPreference()) {
return -1;
} else if (getPreference() > arg.getPreference()) {
return 1;
}
return 0;
} | java | {
"resource": ""
} |
q21221 | PacketParserUtils.parseStanza | train | public static Stanza parseStanza(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws Exception {
ParserUtils.assertAtStartTag(parser);
final String name = parser.getName();
switch (name) {
case Message.ELEMENT:
return parseMessage(parser, outerXmlEnvironment);
... | java | {
"resource": ""
} |
q21222 | PacketParserUtils.parseMessage | train | public static Message parseMessage(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
ParserUtils.assertAtStartTag(parser);
assert (parser.getName().equals(Message.ELEMENT));
XmlEnvironment messageXmlEnvironment = XmlEnv... | java | {
"resource": ""
} |
q21223 | PacketParserUtils.parsePresence | train | public static Presence parsePresence(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
ParserUtils.assertAtStartTag(parser);
final int initialDepth = parser.getDepth();
XmlEnvironment presenceXmlEnvironment = XmlEnvironm... | java | {
"resource": ""
} |
q21224 | PacketParserUtils.parseIQ | train | public static IQ parseIQ(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws Exception {
ParserUtils.assertAtStartTag(parser);
final int initialDepth = parser.getDepth();
XmlEnvironment iqXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
IQ iqPacket = null;
... | java | {
"resource": ""
} |
q21225 | PacketParserUtils.parseMechanisms | train | public static Collection<String> parseMechanisms(XmlPullParser parser)
throws XmlPullParserException, IOException {
List<String> mechanisms = new ArrayList<String>();
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType =... | java | {
"resource": ""
} |
q21226 | PacketParserUtils.parseCompressionFeature | train | public static Compress.Feature parseCompressionFeature(XmlPullParser parser)
throws IOException, XmlPullParserException {
assert (parser.getEventType() == XmlPullParser.START_TAG);
String name;
final int initialDepth = parser.getDepth();
List<String> methods = new Lin... | java | {
"resource": ""
} |
q21227 | PacketParserUtils.parseSASLFailure | train | public static SASLFailure parseSASLFailure(XmlPullParser parser) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
String condition = null;
Map<String, String> descriptiveTexts = null;
outerloop: while (true) {
int eventType = parser.nex... | java | {
"resource": ""
} |
q21228 | PacketParserUtils.parseStreamError | train | public static StreamError parseStreamError(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
final int initialDepth = parser.getDepth();
List<ExtensionElement> extensions = new ArrayList<>();
Map<String, String> descript... | java | {
"resource": ""
} |
q21229 | PacketParserUtils.parseError | train | public static StanzaError.Builder parseError(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
final int initialDepth = parser.getDepth();
Map<String, String> descriptiveTexts = null;
XmlEnvironment stanzaErrorXmlEnviron... | java | {
"resource": ""
} |
q21230 | PacketParserUtils.parseExtensionElement | train | public static ExtensionElement parseExtensionElement(String elementName, String namespace,
XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
ParserUtils.assertAtStartTag(parser);
// See if a provider is regis... | java | {
"resource": ""
} |
q21231 | MessageEventManager.fireMessageEventRequestListeners | train | private void fireMessageEventRequestListeners(
Jid from,
String packetID,
String methodName) {
try {
Method method =
MessageEventRequestListener.class.getDeclaredMethod(
methodName,
new Class<?>[] { Jid.class, String.cla... | java | {
"resource": ""
} |
q21232 | MessageEventManager.fireMessageEventNotificationListeners | train | private void fireMessageEventNotificationListeners(
Jid from,
String packetID,
String methodName) {
try {
Method method =
MessageEventNotificationListener.class.getDeclaredMethod(
methodName,
new Class<?>[] { Jid.class, ... | java | {
"resource": ""
} |
q21233 | MessageEventManager.sendDeliveredNotification | train | public void sendDeliveredNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException {
// Create the message to send
Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message
MessageEvent messageEvent = new MessageEvent();
... | java | {
"resource": ""
} |
q21234 | MessageEventManager.sendDisplayedNotification | train | public void sendDisplayedNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException {
// Create the message to send
Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message
MessageEvent messageEvent = new MessageEvent();
... | java | {
"resource": ""
} |
q21235 | MessageEventManager.sendComposingNotification | train | public void sendComposingNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException {
// Create the message to send
Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message
MessageEvent messageEvent = new MessageEvent();
... | java | {
"resource": ""
} |
q21236 | MessageEventManager.sendCancelledNotification | train | public void sendCancelledNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException {
// Create the message to send
Message msg = new Message(to);
// Create a MessageEvent Package and add it to the message
MessageEvent messageEvent = new MessageEvent();
... | java | {
"resource": ""
} |
q21237 | StreamNegotiator.createInitiationAccept | train | protected static StreamInitiation createInitiationAccept(
StreamInitiation streamInitiationOffer, String[] namespaces) {
StreamInitiation response = new StreamInitiation();
response.setTo(streamInitiationOffer.getFrom());
response.setFrom(streamInitiationOffer.getTo());
respo... | java | {
"resource": ""
} |
q21238 | AccountManager.getInstance | train | public static synchronized AccountManager getInstance(XMPPConnection connection) {
AccountManager accountManager = INSTANCES.get(connection);
if (accountManager == null) {
accountManager = new AccountManager(connection);
INSTANCES.put(connection, accountManager);
}
... | java | {
"resource": ""
} |
q21239 | AccountManager.supportsAccountCreation | train | public boolean supportsAccountCreation() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// TODO: Replace this body with isSupported() and possible deprecate this method.
// Check if we already know that the server supports creating new accounts
if ... | java | {
"resource": ""
} |
q21240 | AccountManager.createAccount | train | public void createAccount(Localpart username, String password) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// Create a map for all the required attributes, but give them blank values.
Map<String, String> attributes = new HashMap<>();
for (String... | java | {
"resource": ""
} |
q21241 | AccountManager.changePassword | train | public void changePassword(String newPassword) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
if (!connection().isSecureConnection() && !allowSensitiveOperationOverInsecureConnection) {
throw new IllegalStateException("Changing password over insecure co... | java | {
"resource": ""
} |
q21242 | AccountManager.deleteAccount | train | public void deleteAccount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Map<String, String> attributes = new HashMap<>();
// To delete an account, we add a single attribute, "remove", that is blank.
attributes.put("remove", "");
Registrat... | java | {
"resource": ""
} |
q21243 | PingManager.maybeSchedulePingServerTask | train | private synchronized void maybeSchedulePingServerTask(int delta) {
maybeStopPingServerTask();
if (pingInterval > 0) {
int nextPingIn = pingInterval - delta;
LOGGER.fine("Scheduling ServerPingTask in " + nextPingIn + " seconds (pingInterval="
+ pingInte... | java | {
"resource": ""
} |
q21244 | EntityCapsManager.addDiscoverInfoByNode | train | static void addDiscoverInfoByNode(String nodeVer, DiscoverInfo info) {
CAPS_CACHE.put(nodeVer, info);
if (persistentCache != null)
persistentCache.addDiscoverInfoByNodePersistent(nodeVer, info);
} | java | {
"resource": ""
} |
q21245 | EntityCapsManager.getDiscoveryInfoByNodeVer | train | public static DiscoverInfo getDiscoveryInfoByNodeVer(String nodeVer) {
DiscoverInfo info = CAPS_CACHE.lookup(nodeVer);
// If it was not in CAPS_CACHE, try to retrieve the information from persistentCache
if (info == null && persistentCache != null) {
info = persistentCache.lookup(no... | java | {
"resource": ""
} |
q21246 | EntityCapsManager.areEntityCapsSupported | train | public boolean areEntityCapsSupported(Jid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return sdm.supportsFeature(jid, NAMESPACE);
} | java | {
"resource": ""
} |
q21247 | EntityCapsManager.updateLocalEntityCaps | train | private void updateLocalEntityCaps() {
XMPPConnection connection = connection();
DiscoverInfo discoverInfo = new DiscoverInfo();
discoverInfo.setType(IQ.Type.result);
sdm.addDiscoverInfoTo(discoverInfo);
// getLocalNodeVer() will return a result only after currentCapsVersion is... | java | {
"resource": ""
} |
q21248 | EntityCapsManager.verifyDiscoverInfoVersion | train | public static boolean verifyDiscoverInfoVersion(String ver, String hash, DiscoverInfo info) {
// step 3.3 check for duplicate identities
if (info.containsDuplicateIdentities())
return false;
// step 3.4 check for duplicate features
if (info.containsDuplicateFeatures())
... | java | {
"resource": ""
} |
q21249 | OmemoKeyUtil.preKeyPublicKeysForBundle | train | public HashMap<Integer, byte[]> preKeyPublicKeysForBundle(TreeMap<Integer, T_PreKey> preKeyHashMap) {
HashMap<Integer, byte[]> out = new HashMap<>();
for (Map.Entry<Integer, T_PreKey> e : preKeyHashMap.entrySet()) {
out.put(e.getKey(), preKeyForBundle(e.getValue()));
}
return... | java | {
"resource": ""
} |
q21250 | OmemoKeyUtil.addInBounds | train | public static int addInBounds(int value, int added) {
int avail = Integer.MAX_VALUE - value;
if (avail < added) {
return added - avail;
} else {
return value + added;
}
} | java | {
"resource": ""
} |
q21251 | DiscoverItems.addItems | train | public void addItems(Collection<Item> itemsToAdd) {
if (itemsToAdd == null) return;
for (Item i : itemsToAdd) {
addItem(i);
}
} | java | {
"resource": ""
} |
q21252 | Chat.sendMessage | train | public void sendMessage(Message message) throws NotConnectedException, InterruptedException {
// Force the recipient, message type, and thread ID since the user elected
// to send the message through this chat object.
message.setTo(participant);
message.setType(Message.Type.chat);
... | java | {
"resource": ""
} |
q21253 | CarbonManager.getInstanceFor | train | public static synchronized CarbonManager getInstanceFor(XMPPConnection connection) {
CarbonManager carbonManager = INSTANCES.get(connection);
if (carbonManager == null) {
carbonManager = new CarbonManager(connection);
INSTANCES.put(connection, carbonManager);
}
... | java | {
"resource": ""
} |
q21254 | CarbonManager.setCarbonsEnabled | train | public synchronized void setCarbonsEnabled(final boolean new_state) throws NoResponseException,
XMPPErrorException, NotConnectedException, InterruptedException {
if (enabled_state == new_state)
return;
IQ setIQ = carbonsEnabledIQ(new_state);
connection().createS... | java | {
"resource": ""
} |
q21255 | AMPManager.isServiceEnabled | train | public static boolean isServiceEnabled(XMPPConnection connection) {
connection.getXMPPServiceDomain();
return ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(AMPExtension.NAMESPACE);
} | java | {
"resource": ""
} |
q21256 | AMPManager.isActionSupported | train | public static boolean isActionSupported(XMPPConnection connection, AMPExtension.Action action) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
String featureName = AMPExtension.NAMESPACE + "?action=" + action.toString();
return isFeatureSupportedByServer(con... | java | {
"resource": ""
} |
q21257 | AMPManager.isConditionSupported | train | public static boolean isConditionSupported(XMPPConnection connection, String conditionName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
String featureName = AMPExtension.NAMESPACE + "?condition=" + conditionName;
return isFeatureSupportedByServer(connect... | java | {
"resource": ""
} |
q21258 | SubProcessKernel.getTotalCommandBytes | train | private int getTotalCommandBytes(SubProcessCommandLineArgs commands) {
int size = 0;
for (SubProcessCommandLineArgs.Command c : commands.getParameters()) {
size += c.value.length();
}
return size;
} | java | {
"resource": ""
} |
q21259 | SubProcessKernel.collectProcessResultsBytes | train | private byte[] collectProcessResultsBytes(Process process, ProcessBuilder builder,
SubProcessIOFiles outPutFiles) throws Exception {
Byte[] results;
try {
LOG.debug(String.format("Executing process %s", createLogEntryFromInputs(builder.command())));
// If process exit value is not 0 then s... | java | {
"resource": ""
} |
q21260 | SubProcessKernel.appendExecutablePath | train | private ProcessBuilder appendExecutablePath(ProcessBuilder builder) {
String executable = builder.command().get(0);
if (executable == null) {
throw new IllegalArgumentException(
"No executable provided to the Process Builder... we will do... nothing... ");
}
builder.command().set(0,
... | java | {
"resource": ""
} |
q21261 | GameStats.configureSessionWindowWrite | train | protected static Map<String, WriteWindowedToBigQuery.FieldInfo<Double>>
configureSessionWindowWrite() {
Map<String, WriteWindowedToBigQuery.FieldInfo<Double>> tableConfigure = new HashMap<>();
tableConfigure.put(
"window_start",
new WriteWindowedToBigQuery.FieldInfo<>(
"STRING... | java | {
"resource": ""
} |
q21262 | FileUtils.createDirectoriesOnWorker | train | public static void createDirectoriesOnWorker(SubProcessConfiguration configuration)
throws IOException {
try {
Path path = Paths.get(configuration.getWorkerPath());
if (!path.toFile().exists()) {
Files.createDirectories(path);
LOG.info(String.format("Created Folder %s ", path.to... | java | {
"resource": ""
} |
q21263 | InjectorUtils.getClient | train | public static Pubsub getClient(final HttpTransport httpTransport,
final JsonFactory jsonFactory)
throws IOException {
checkNotNull(httpTransport);
checkNotNull(jsonFactory);
GoogleCredential credential =
GoogleCredential.getApplicationDefault(httpT... | java | {
"resource": ""
} |
q21264 | InjectorUtils.createTopic | train | public static void createTopic(Pubsub client, String fullTopicName)
throws IOException {
System.out.println("fullTopicName " + fullTopicName);
try {
client.projects().topics().get(fullTopicName).execute();
} catch (GoogleJsonResponseException e) {
if (e.getStatusCode() == HttpStatusCodes... | java | {
"resource": ""
} |
q21265 | StatefulTeamScore.configureCompleteWindowedTableWrite | train | private static Map<String, FieldInfo<KV<String, Integer>>> configureCompleteWindowedTableWrite() {
Map<String, WriteWindowedToBigQuery.FieldInfo<KV<String, Integer>>> tableConfigure =
new HashMap<>();
tableConfigure.put(
"team", new WriteWindowedToBigQuery.FieldInfo<>("STRING", (c, w) -> c.elem... | java | {
"resource": ""
} |
q21266 | RemoteFileUtil.delete | train | public void delete(URI src) {
Path dst = null;
try {
dst = paths.get(src);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
try {
Files.deleteIfExists(dst);
paths.invalidate(src);
} catch (IOException e) {
String msg = String.format("Failed to delet... | java | {
"resource": ""
} |
q21267 | RemoteFileUtil.delete | train | public void delete(List<URI> srcs) {
for (URI src : srcs) {
delete(src);
}
paths.invalidateAll(srcs);
} | java | {
"resource": ""
} |
q21268 | RemoteFileUtil.copyToLocal | train | private static void copyToLocal(Metadata src, Path dst) throws IOException {
FileChannel dstCh = FileChannel.open(
dst, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW);
ReadableByteChannel srcCh = FileSystems.open(src.resourceId());
long srcSize = src.sizeBytes();
long copied = 0;
d... | java | {
"resource": ""
} |
q21269 | RemoteFileUtil.copyToRemote | train | private static void copyToRemote(Path src, URI dst) throws IOException {
ResourceId dstId = FileSystems.matchNewResource(dst.toString(), false);
WritableByteChannel dstCh = FileSystems.create(dstId, MimeTypes.BINARY);
FileChannel srcCh = FileChannel.open(src, StandardOpenOption.READ);
long srcSize = src... | java | {
"resource": ""
} |
q21270 | JoinExamples.joinEvents | train | static PCollection<String> joinEvents(PCollection<TableRow> eventsTable,
PCollection<TableRow> countryCodes) throws Exception {
final TupleTag<String> eventInfoTag = new TupleTag<>();
final TupleTag<String> countryInfoTag = new TupleTag<>();
// transform both input collections to tuple collections, ... | java | {
"resource": ""
} |
q21271 | LeaderBoard.configureWindowedTableWrite | train | protected static Map<String, WriteWindowedToBigQuery.FieldInfo<KV<String, Integer>>>
configureWindowedTableWrite() {
Map<String, WriteWindowedToBigQuery.FieldInfo<KV<String, Integer>>> tableConfigure =
new HashMap<>();
tableConfigure.put(
"team", new WriteWindowedToBigQuery.FieldInfo<>("S... | java | {
"resource": ""
} |
q21272 | LeaderBoard.configureGlobalWindowBigQueryWrite | train | protected static Map<String, WriteToBigQuery.FieldInfo<KV<String, Integer>>>
configureGlobalWindowBigQueryWrite() {
Map<String, WriteToBigQuery.FieldInfo<KV<String, Integer>>> tableConfigure =
configureBigQueryWrite();
tableConfigure.put(
"processing_time",
new WriteToBigQuery.Fie... | java | {
"resource": ""
} |
q21273 | Snippets.formatCoGbkResults | train | public static String formatCoGbkResults(
String name, Iterable<String> emails, Iterable<String> phones) {
List<String> emailsList = new ArrayList<>();
for (String elem : emails) {
emailsList.add("'" + elem + "'");
}
Collections.sort(emailsList);
String emailsStr = "[" + String.join(", "... | java | {
"resource": ""
} |
q21274 | Snippets.coGroupByKeyTuple | train | public static PCollection<String> coGroupByKeyTuple(
TupleTag<String> emailsTag,
TupleTag<String> phonesTag,
PCollection<KV<String, String>> emails,
PCollection<KV<String, String>> phones) {
// [START CoGroupByKeyTuple]
PCollection<KV<String, CoGbkResult>> results =
KeyedPCollec... | java | {
"resource": ""
} |
q21275 | BigtableUtil.getClusterSizes | train | public static Map<String, Integer> getClusterSizes(
final String projectId,
final String instanceId
) throws IOException, GeneralSecurityException {
try (BigtableClusterUtilities clusterUtil = BigtableClusterUtilities
.forInstance(projectId, instanceId)) {
return Collections.unmodifiable... | java | {
"resource": ""
} |
q21276 | ExampleUtils.setupBigQueryTable | train | public void setupBigQueryTable() throws IOException {
ExampleBigQueryTableOptions bigQueryTableOptions =
options.as(ExampleBigQueryTableOptions.class);
if (bigQueryTableOptions.getBigQueryDataset() != null
&& bigQueryTableOptions.getBigQueryTable() != null
&& bigQueryTableOptions.getBigQ... | java | {
"resource": ""
} |
q21277 | ExampleUtils.tearDown | train | private void tearDown() {
pendingMessages.add("*************************Tear Down*************************");
ExamplePubsubTopicAndSubscriptionOptions pubsubOptions =
options.as(ExamplePubsubTopicAndSubscriptionOptions.class);
if (!pubsubOptions.getPubsubTopic().isEmpty()) {
try {
dele... | java | {
"resource": ""
} |
q21278 | ExampleUtils.waitToFinish | train | public void waitToFinish(PipelineResult result) {
pipelinesToCancel.add(result);
if (!options.as(ExampleOptions.class).getKeepJobsRunning()) {
addShutdownHook(pipelinesToCancel);
}
try {
result.waitUntilFinish();
} catch (UnsupportedOperationException e) {
// Do nothing if the give... | java | {
"resource": ""
} |
q21279 | StreamingWordExtract.main | train | public static void main(String[] args) throws IOException {
StreamingWordExtractOptions options = PipelineOptionsFactory.fromArgs(args)
.withValidation()
.as(StreamingWordExtractOptions.class);
options.setStreaming(true);
options.setBigQuerySchema(StringToRowConverter.getSchema());
Exam... | java | {
"resource": ""
} |
q21280 | SubProcessIOFiles.close | train | @Override
public void close() throws IOException {
if (Files.exists(outFile)) {
Files.delete(outFile);
}
if (Files.exists(errFile)) {
Files.delete(errFile);
}
if (Files.exists(resultFile)) {
Files.delete(resultFile);
}
} | java | {
"resource": ""
} |
q21281 | SubProcessIOFiles.copyOutPutFilesToBucket | train | public void copyOutPutFilesToBucket(SubProcessConfiguration configuration, String params) {
if (Files.exists(outFile) || Files.exists(errFile)) {
try {
outFileLocation = FileUtils.copyFileFromWorkerToGCS(configuration, outFile);
} catch (Exception ex) {
LOG.error("Error uploading log fil... | java | {
"resource": ""
} |
q21282 | WriteToBigQuery.getSchema | train | protected TableSchema getSchema() {
List<TableFieldSchema> fields = new ArrayList<>();
for (Map.Entry<String, FieldInfo<InputT>> entry : fieldInfo.entrySet()) {
String key = entry.getKey();
FieldInfo<InputT> fcnInfo = entry.getValue();
String bqType = fcnInfo.getFieldType();
fields.add(n... | java | {
"resource": ""
} |
q21283 | WriteToBigQuery.getTable | train | static TableReference getTable(String projectId, String datasetId, String tableName) {
TableReference table = new TableReference();
table.setDatasetId(datasetId);
table.setProjectId(projectId);
table.setTableId(tableName);
return table;
} | java | {
"resource": ""
} |
q21284 | AsyncLookupDoFn.flush | train | private void flush(Consumer<Result> outputFn) {
Result r = results.poll();
while (r != null) {
outputFn.accept(r);
resultCount++;
r = results.poll();
}
} | java | {
"resource": ""
} |
q21285 | PatchedBigQueryTableRowIterator.open | train | public void open() throws IOException, InterruptedException {
if (queryConfig != null) {
ref = executeQueryAndWaitForCompletion();
}
// Get table schema.
schema = getTable(ref).getSchema();
} | java | {
"resource": ""
} |
q21286 | PatchedBigQueryTableRowIterator.getTypedCellValue | train | @Nullable private Object getTypedCellValue(TableFieldSchema fieldSchema, Object v) {
if (Data.isNull(v)) {
return null;
}
if (Objects.equals(fieldSchema.getMode(), "REPEATED")) {
TableFieldSchema elementSchema = fieldSchema.clone().setMode("REQUIRED");
@SuppressWarnings("unchecked")
... | java | {
"resource": ""
} |
q21287 | PatchedBigQueryTableRowIterator.getTable | train | private Table getTable(TableReference ref) throws IOException, InterruptedException {
Bigquery.Tables.Get get =
client.tables().get(ref.getProjectId(), ref.getDatasetId(), ref.getTableId());
return executeWithBackOff(
get,
String.format(
"Error opening BigQuery table %s of d... | java | {
"resource": ""
} |
q21288 | PatchedBigQueryTableRowIterator.deleteTable | train | private void deleteTable(String datasetId, String tableId)
throws IOException, InterruptedException {
executeWithBackOff(
client.tables().delete(projectId, datasetId, tableId),
String.format(
"Error when trying to delete the temporary table %s in dataset %s of project %s. "
... | java | {
"resource": ""
} |
q21289 | PatchedBigQueryTableRowIterator.deleteDataset | train | private void deleteDataset(String datasetId) throws IOException, InterruptedException {
executeWithBackOff(
client.datasets().delete(projectId, datasetId),
String.format(
"Error when trying to delete the temporary dataset %s in project %s. "
+ "Manual deletion may be required... | java | {
"resource": ""
} |
q21290 | PatchedBigQueryTableRowIterator.executeWithBackOff | train | public static <T> T executeWithBackOff(AbstractGoogleClientRequest<T> client, String error)
throws IOException, InterruptedException {
Sleeper sleeper = Sleeper.DEFAULT;
BackOff backOff =
BackOffAdapter.toGcpBackOff(
FluentBackoff.DEFAULT
.withMaxRetries(MAX_RETRIES).wi... | java | {
"resource": ""
} |
q21291 | Injector.randomElement | train | private static String randomElement(ArrayList<String> list) {
int index = random.nextInt(list.size());
return list.get(index);
} | java | {
"resource": ""
} |
q21292 | Injector.randomTeam | train | private static TeamInfo randomTeam(ArrayList<TeamInfo> list) {
int index = random.nextInt(list.size());
TeamInfo team = list.get(index);
// If the selected team is expired, remove it and return a new team.
long currTime = System.currentTimeMillis();
if ((team.getEndTimeInMillis() < currTime) || team... | java | {
"resource": ""
} |
q21293 | Injector.addLiveTeam | train | private static synchronized TeamInfo addLiveTeam() {
String teamName = randomElement(COLORS) + randomElement(ANIMALS);
String robot = null;
// Decide if we want to add a robot to the team.
if (random.nextInt(ROBOT_PROBABILITY) == 0) {
robot = "Robot-" + random.nextInt(NUM_ROBOTS);
}
// Cre... | java | {
"resource": ""
} |
q21294 | Injector.removeTeam | train | private static synchronized void removeTeam(int teamIndex) {
TeamInfo removedTeam = liveTeams.remove(teamIndex);
System.out.println("[-" + removedTeam + "]");
} | java | {
"resource": ""
} |
q21295 | Injector.generateEvent | train | private static String generateEvent(Long currTime, int delayInMillis) {
TeamInfo team = randomTeam(liveTeams);
String teamName = team.getTeamName();
String user;
final int parseErrorRate = 900000;
String robot = team.getRobot();
// If the team has an associated robot team member...
if (robo... | java | {
"resource": ""
} |
q21296 | Injector.addTimeInfoToEvent | train | private static String addTimeInfoToEvent(String message, Long currTime, int delayInMillis) {
String eventTimeString =
Long.toString((currTime - delayInMillis) / 1000 * 1000);
// Add a (redundant) 'human-readable' date string to make the data semantics more clear.
String dateString = GameConstants.DA... | java | {
"resource": ""
} |
q21297 | Injector.publishData | train | public static void publishData(int numMessages, int delayInMillis)
throws IOException {
List<PubsubMessage> pubsubMessages = new ArrayList<>();
for (int i = 0; i < Math.max(1, numMessages); i++) {
Long currTime = System.currentTimeMillis();
String message = generateEvent(currTime, delayInMill... | java | {
"resource": ""
} |
q21298 | Injector.publishDataToFile | train | public static void publishDataToFile(String fileName, int numMessages, int delayInMillis)
throws IOException {
PrintWriter out = new PrintWriter(new OutputStreamWriter(
new BufferedOutputStream(new FileOutputStream(fileName, true)), "UTF-8"));
try {
for (int i = 0; i < Math.max(1, numMessag... | java | {
"resource": ""
} |
q21299 | DeletionInfo.isDeleted | train | public boolean isDeleted(Cell cell)
{
// We do rely on this test: if topLevel.markedForDeleteAt is MIN_VALUE, we should not
// consider the column deleted even if timestamp=MIN_VALUE, otherwise this break QueryFilter.isRelevant
if (isLive())
return false;
if (cell.timestamp() <= topLevel.marked... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.