_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q162400
BookKeeperJournalManager.purgeLogsOlderThan
train
@Override public void purgeLogsOlderThan(long minTxIdToKeep) throws IOException { checkEnv(); Collection<EditLogLedgerMetadata> ledgers = metadataManager.listLedgers(false); // Don't list in-progress ledgers for (EditLogLedgerMetadata ledger : ledgers) { if (ledger.getFirstTxId() < minTxId...
java
{ "resource": "" }
q162401
CoronaSerializer.readToken
train
public void readToken(String parentFieldName, JsonToken expectedToken) throws IOException { JsonToken currentToken = jsonParser.nextToken(); if (currentToken != expectedToken) { throw new IOException("Expected a " + expectedToken.toString() + " token when reading the value of the field: " + ...
java
{ "resource": "" }
q162402
CoronaSerializer.getFieldName
train
public String getFieldName() throws IOException { if (jsonParser.getCurrentToken() != JsonToken.FIELD_NAME) { throw new IOException("Expected a field of type " + JsonToken.FIELD_NAME + ", but found a field of type " + jsonParser.getCurrentToken()); }...
java
{ "resource": "" }
q162403
BlockListAsLongs.setBlock
train
void setBlock(final int index, final Block b) { blockList[index2BlockId(index)] = b.getBlockId(); blockList[index2BlockLen(index)] = b.getNumBytes(); blockList[index2BlockGenStamp(index)] = b.getGenerationStamp(); }
java
{ "resource": "" }
q162404
UtilizationReporter.main
train
public static void main(String argv[]) throws Exception { try { Configuration conf = new Configuration(); UtilizationReporter utilizationReporter = new UtilizationReporter(conf); utilizationReporter.start(); } catch (Throwable e) { System.err.println(e); LOG.error(St...
java
{ "resource": "" }
q162405
AvatarDataNode.getNameNodeAddress
train
static InetSocketAddress getNameNodeAddress(Configuration conf, String cname, String rpcKey, String cname2) { String fs = conf.get(cname); String fs1 = conf.get(rpcKey); String fs2 = conf.get(cname2); Configuration newconf = new Configuration(conf); ...
java
{ "resource": "" }
q162406
MD5MD5CRC32FileChecksum.write
train
public static void write(XMLOutputter xml, MD5MD5CRC32FileChecksum that ) throws IOException { xml.startTag(MD5MD5CRC32FileChecksum.class.getName()); if (that != null) { xml.attribute("bytesPerCRC", "" + that.bytesPerCRC); xml.attribute("crcPerBlock", "" + that.crcPerBlock); xml.attribut...
java
{ "resource": "" }
q162407
MD5MD5CRC32FileChecksum.valueOf
train
public static MD5MD5CRC32FileChecksum valueOf(Attributes attrs ) throws SAXException { final String bytesPerCRC = attrs.getValue("bytesPerCRC"); final String crcPerBlock = attrs.getValue("crcPerBlock"); final String md5 = attrs.getValue("md5"); if (bytesPerCRC == null || crcPerBlock == null || md5...
java
{ "resource": "" }
q162408
XmlTokenizer.getNextElementsValue
train
private String getNextElementsValue(String wantedName) throws IOException { boolean gotSTART_ELEMENT = false; try { int eventType = in.getEventType(); while(true) { switch(eventType) { case XMLStreamConstants.CHARACTERS: // 4 if(gotSTART_ELEMENT) { // XML ...
java
{ "resource": "" }
q162409
CurrentInProgressMetadata.update
train
public void update(String newPath) throws IOException { String id = hostname + Thread.currentThread().getId(); CurrentInProgressMetadataWritable cip = localWritable.get(); cip.set(id, newPath); byte[] data = WritableUtil.writableToByteArray(cip); try { zooKeeper.setData(fullyQualifiedZNode, da...
java
{ "resource": "" }
q162410
CurrentInProgressMetadata.read
train
public String read() throws IOException { CurrentInProgressMetadataWritable cip = localWritable.get(); if (readAndUpdateVersion(cip)) { return cip.getPath(); } else { if (LOG.isDebugEnabled()) { LOG.debug(fullyQualifiedZNode + " is currently clear."); } } return null; }
java
{ "resource": "" }
q162411
CurrentInProgressMetadata.clear
train
public void clear() throws IOException { try { zooKeeper.setData(fullyQualifiedZNode, null, expectedZNodeVersion.get()); } catch (KeeperException.BadVersionException e) { LOG.error(fullyQualifiedZNode + " has been updated by another process", e); throw new StaleVersionException(fully...
java
{ "resource": "" }
q162412
ProgressWheel.onSizeChanged
train
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); setupBounds(w, h); setupPaints(); invalidate(); }
java
{ "resource": "" }
q162413
ProgressWheel.setupPaints
train
private void setupPaints() { barPaint.setColor(barColor); barPaint.setAntiAlias(true); barPaint.setStyle(Style.STROKE); barPaint.setStrokeWidth(barWidth); rimPaint.setColor(rimColor); rimPaint.setAntiAlias(true); rimPaint.setStyle(Style.STROKE); rimPaint.setStrokeWidth(rimWidth); }
java
{ "resource": "" }
q162414
ProgressWheel.setupBounds
train
private void setupBounds(int layout_width, int layout_height) { int paddingTop = getPaddingTop(); int paddingBottom = getPaddingBottom(); int paddingLeft = getPaddingLeft(); int paddingRight = getPaddingRight(); if (!fillRadius) { // Width should equal to Height, find the min value to setup t...
java
{ "resource": "" }
q162415
ProgressWheel.parseAttributes
train
private void parseAttributes(TypedArray a) { // We transform the default values from DIP to pixels DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics); rimWidth = (int) TypedValue.applyDimens...
java
{ "resource": "" }
q162416
ProgressWheel.setInstantProgress
train
public void setInstantProgress(float progress) { if (isSpinning) { mProgress = 0.0f; isSpinning = false; } if (progress > 1.0f) { progress -= 1.0f; } else if (progress < 0) { progress = 0; } if (progress == mTargetProgress) { return; } mTargetProgress = M...
java
{ "resource": "" }
q162417
ProgressWheel.setProgress
train
public void setProgress(float progress) { if (isSpinning) { mProgress = 0.0f; isSpinning = false; runCallback(); } if (progress > 1.0f) { progress -= 1.0f; } else if (progress < 0) { progress = 0; } if (progress == mTargetProgress) { return; } // I...
java
{ "resource": "" }
q162418
AbstractRefreshWebappMojo.execute
train
@Override public void execute() throws MojoExecutionException { if (StringUtils.isBlank(this.refreshPort)) { this.refreshPort = "8080"; } // Do a ping to see if the server is up, if not, log and just exit if (!ping()) { getLog().warn("Connection failed to " +...
java
{ "resource": "" }
q162419
AbstractRefreshWebappMojo.refreshWebScripts
train
protected void refreshWebScripts(String url) { // Create the Refresh URL for the Alfresco Tomcat server URL alfrescoTomcatUrl = buildFinalUrl(url); if (alfrescoTomcatUrl == null) { getLog().error("Could not build refresh URL for " + refreshWebappName + ", " + getAbortedMsg()); ...
java
{ "resource": "" }
q162420
AbstractRefreshWebappMojo.clearDependencyCaches
train
protected void clearDependencyCaches(String url) { // Create the Clear Cache URL for the Alfresco Tomcat server URL alfrescoTomcatUrl = buildFinalUrl(url); if (alfrescoTomcatUrl == null) { getLog().error("Could not build clear dependency caches URL for " + refresh...
java
{ "resource": "" }
q162421
AbstractRefreshWebappMojo.makePostCall
train
private void makePostCall(URL alfrescoTomcatUrl, List<NameValuePair> postData, String operation) { CloseableHttpClient client = null; CloseableHttpResponse response = null; try { // Set up a HTTP POST request to the Alfresco Webapp we are targeting HttpHost targetHost = n...
java
{ "resource": "" }
q162422
AbstractRunMojo.getPort
train
protected String getPort() { String port = tomcatPort; if (mavenTomcatPort != null) { port = mavenTomcatPort; getLog().info( "Tomcat Port overridden by property maven.tomcat.port"); } return port; }
java
{ "resource": "" }
q162423
AbstractRunMojo.tomcatIsRunning
train
protected boolean tomcatIsRunning() { CloseableHttpClient client= HttpClients.createDefault(); CloseableHttpResponse response = null; try { HttpGet httpget = new HttpGet("http://localhost:" + getPort() + "/alfresco"); response = client.execute(httpget); get...
java
{ "resource": "" }
q162424
AbstractRunMojo.copyAlfrescoLicense
train
protected void copyAlfrescoLicense() throws MojoExecutionException { final String warOutputDir = getWarOutputDir(PLATFORM_WAR_PREFIX_NAME); final String licDestDir = warOutputDir + "/WEB-INF/classes/alfresco/extension/license"; getLog().info("Copying Alfresco Enterprise license to: " + licDest...
java
{ "resource": "" }
q162425
AbstractRunMojo.copyShareConfigCustom
train
protected void copyShareConfigCustom() throws MojoExecutionException { final String warOutputDir = getWarOutputDir(SHARE_WAR_PREFIX_NAME); final String distDir = warOutputDir + "/WEB-INF/classes/alfresco/web-extension/"; String repoUrl = project.getProperties().getProperty("alfresco.repo.url"); ...
java
{ "resource": "" }
q162426
AbstractRunMojo.copyHotswapAgentProperties
train
protected void copyHotswapAgentProperties(String warPrefix) throws MojoExecutionException { if ( copyHotswapAgentConfig == false ) { return; } final String warOutputDir = getWarOutputDir(warPrefix) + "/WEB-INF/classes/"; getLog().info("Copying " + warPrefix + "-hotswap-age...
java
{ "resource": "" }
q162427
AbstractRunMojo.packageAndInstallCustomWar
train
protected String packageAndInstallCustomWar(String warName) throws MojoExecutionException { final String warArtifactId = "${project.artifactId}-" + warName; final String warSourceDir = getWarOutputDir(warName); // Package the customized war file // Note. don't use the maven-war-plugin h...
java
{ "resource": "" }
q162428
DatasetTarget.outputBundle
train
private static FormatBundle<DatasetKeyOutputFormat> outputBundle(Configuration conf) { FormatBundle<DatasetKeyOutputFormat> bundle = FormatBundle .forOutput(DatasetKeyOutputFormat.class); for (Map.Entry<String, String> entry : conf) { bundle.set(entry.getKey(), entry.getValue()); } return ...
java
{ "resource": "" }
q162429
SchemaValidationUtil.hasErrors
train
private static boolean hasErrors(Symbol symbol) { switch(symbol.kind) { case ALTERNATIVE: return hasErrors(symbol, ((Symbol.Alternative) symbol).symbols); case EXPLICIT_ACTION: return false; case IMPLICIT_ACTION: return symbol instanceof Symbol.ErrorAction; case REPEA...
java
{ "resource": "" }
q162430
JSONSchemaCommand.run
train
@Override public int run() throws IOException { Preconditions.checkArgument(samplePaths != null && !samplePaths.isEmpty(), "Sample JSON path is required"); Preconditions.checkArgument(samplePaths.size() == 1, "Only one JSON sample can be given"); // assume fields are nullable by default, ...
java
{ "resource": "" }
q162431
KiteConfigurationService.loadKiteConf
train
private void loadKiteConf(Services services) throws IOException { String[] paths = services.getConf().getStrings(KITE_CONFIGURATION); if (paths != null && paths.length != 0) { kiteConf = new Configuration(false); for(String path : paths) { if (path.startsWith("hdfs")) { Path p = ...
java
{ "resource": "" }
q162432
HBaseClientTemplate.get
train
public Result get(Get get) { HTableInterface table = pool.getTable(tableName); try { for (GetModifier getModifier : getModifiers) { get = getModifier.modifyGet(get); } try { return table.get(get); } catch (IOException e) { throw new DatasetIOException("Error perfo...
java
{ "resource": "" }
q162433
HBaseClientTemplate.get
train
public Result get(Get get, GetModifier getModifier) { if (getModifier != null) { get = getModifier.modifyGet(get); } return get(get); }
java
{ "resource": "" }
q162434
HBaseClientTemplate.put
train
public boolean put(PutAction putAction) { HTableInterface table = pool.getTable(tableName); try { return put(putAction, table); } finally { if (table != null) { try { table.close(); } catch (IOException e) { throw new DatasetIOException("Error putting table ba...
java
{ "resource": "" }
q162435
HBaseClientTemplate.put
train
public boolean put(PutAction putAction, HTableInterface table) { for (PutActionModifier putActionModifier : putActionModifiers) { putAction = putActionModifier.modifyPutAction(putAction); } Put put = putAction.getPut(); if (putAction.getVersionCheckAction() != null) { byte[] versionBytes = n...
java
{ "resource": "" }
q162436
HBaseClientTemplate.put
train
public boolean put(PutAction putAction, PutActionModifier putActionModifier) { if (putActionModifier != null) { putAction = putActionModifier.modifyPutAction(putAction); } return put(putAction); }
java
{ "resource": "" }
q162437
HBaseClientTemplate.put
train
public <E> boolean put(E entity, EntityMapper<E> entityMapper) { return put(entity, null, entityMapper); }
java
{ "resource": "" }
q162438
HBaseClientTemplate.put
train
public <E> boolean put(E entity, PutActionModifier putActionModifier, EntityMapper<E> entityMapper) { PutAction putAction = entityMapper.mapFromEntity(entity); return put(putAction, putActionModifier); }
java
{ "resource": "" }
q162439
HBaseClientTemplate.increment
train
public <E> long increment(PartitionKey key, String fieldName, long amount, EntityMapper<E> entityMapper) { Increment increment = entityMapper.mapToIncrement(key, fieldName, amount); HTableInterface table = pool.getTable(tableName); Result result; try { result = table.increment(increment); ...
java
{ "resource": "" }
q162440
HBaseClientTemplate.delete
train
public boolean delete(DeleteAction deleteAction) { HTableInterface table = pool.getTable(tableName); try { for (DeleteActionModifier deleteActionModifier : deleteActionModifiers) { deleteAction = deleteActionModifier.modifyDeleteAction(deleteAction); } Delete delete = deleteAction.getD...
java
{ "resource": "" }
q162441
HBaseClientTemplate.delete
train
public boolean delete(DeleteAction deleteAction, DeleteActionModifier deleteActionModifier) { if (deleteActionModifier != null) { deleteAction = deleteActionModifier.modifyDeleteAction(deleteAction); } return delete(deleteAction); }
java
{ "resource": "" }
q162442
HBaseClientTemplate.delete
train
public boolean delete(PartitionKey key, Set<String> columns, VersionCheckAction checkAction, KeySerDe keySerDe) { return delete(key, columns, checkAction, null, keySerDe); }
java
{ "resource": "" }
q162443
HBaseClientTemplate.delete
train
public boolean delete(PartitionKey key, Set<String> columns, VersionCheckAction checkAction, DeleteActionModifier deleteActionModifier, KeySerDe keySerDe) { byte[] keyBytes = keySerDe.serialize(key); Delete delete = new Delete(keyBytes); for (String requiredColumn : columns) { String[] fam...
java
{ "resource": "" }
q162444
HBaseClientTemplate.getScannerBuilder
train
public <E> EntityScannerBuilder<E> getScannerBuilder( EntityMapper<E> entityMapper) { EntityScannerBuilder<E> builder = new BaseEntityScanner.Builder<E>(pool, tableName, entityMapper); for (ScanModifier scanModifier : scanModifiers) { builder.addScanModifier(scanModifier); } return b...
java
{ "resource": "" }
q162445
HBaseClientTemplate.createBatch
train
public <E> EntityBatch<E> createBatch(EntityMapper<E> entityMapper, long writeBufferSize) { return new BaseEntityBatch<E>(this, entityMapper, pool, tableName, writeBufferSize); }
java
{ "resource": "" }
q162446
PartialPathConversion.toKey
train
public StorageKey toKey(Path fromPath, StorageKey storage) { final List<FieldPartitioner> partitioners = Accessor.getDefault().getFieldPartitioners(storage.getPartitionStrategy()); //Strip off the root directory to get partition segments String truncatedPath = fromPath.toString(); if(trunca...
java
{ "resource": "" }
q162447
FluentIterable.toArray
train
@GwtIncompatible("Array.newArray(Class, int)") public final E[] toArray(Class<E> type) { return Iterables.toArray(iterable, type); }
java
{ "resource": "" }
q162448
KeyRangeIterable.start
train
private static <T> Iterator<T> start(T singleton) { return Collections.singleton(singleton).iterator(); }
java
{ "resource": "" }
q162449
CSVProperties.coalesce
train
private static <T> T coalesce(T... values) { for (T value : values) { if (value != null) { return value; } } return null; }
java
{ "resource": "" }
q162450
MemcmpEncoder.writeInt
train
@Override public void writeInt(int n) throws IOException { byte[] intBytes = new byte[] { (byte) ((n >>> 24) ^ 0x80), (byte) (n >>> 16), (byte) (n >>> 8), (byte) n }; out.write(intBytes); }
java
{ "resource": "" }
q162451
MemcmpEncoder.writeLong
train
@Override public void writeLong(long n) throws IOException { byte[] intBytes = new byte[] { (byte) ((n >>> 56) ^ 0x80), (byte) (n >>> 48), (byte) (n >>> 40), (byte) (n >>> 32), (byte) (n >>> 24), (byte) (n >>> 16), (byte) (n >>> 8), (byte) n }; out.write(intBytes); }
java
{ "resource": "" }
q162452
UserProfileExample.printUserProfies
train
public void printUserProfies() { EntityScanner<UserProfileModel> scanner = userProfileDao.getScanner(); scanner.initialize(); try { for (UserProfileModel entity : scanner) { System.out.println(entity.toString()); } } finally { // scanners need to be closed. scanner.close(...
java
{ "resource": "" }
q162453
UserProfileExample.printUserProfileActionsForLastName
train
public void printUserProfileActionsForLastName(String lastName) { // Create a partial key that will allow us to start the scanner from the // first user record that has last name equal to the one provided. PartitionKey startKey = new PartitionKey("lastName"); // Get the scanner with the start key. Null...
java
{ "resource": "" }
q162454
UserProfileExample.create
train
public void create(String firstName, String lastName, boolean married) { long ts = System.currentTimeMillis(); UserProfileModel profileModel = UserProfileModel.newBuilder() .setFirstName(firstName).setLastName(lastName).setMarried(married) .setCreated(ts).build(); UserActionsModel actionsMo...
java
{ "resource": "" }
q162455
UserProfileExample.updateUserProfile
train
public void updateUserProfile(String firstName, String lastName, boolean married) { // Get the timestamp we'll use to set the value of the profile_updated // action. long ts = System.currentTimeMillis(); // Construct the key we'll use to fetch the user. PartitionKey key = new PartitionKey(las...
java
{ "resource": "" }
q162456
UserProfileExample.addAction
train
public void addAction(String firstName, String lastName, String actionType, String actionValue) { // Create a new UserActionsModel, and add a new actions map to it with a // single action value. Even if one exists in this row, since it has a lone // keyAsColumn field, it won't remove any actions that ...
java
{ "resource": "" }
q162457
UserProfileExample.registerSchemas
train
private void registerSchemas(Configuration conf, SchemaManager schemaManager) throws InterruptedException { HBaseAdmin admin; try { // Construct an HBaseAdmin object (required by schema tool), and delete it // if it exists so we start fresh. admin = new HBaseAdmin(conf); if (admin....
java
{ "resource": "" }
q162458
UserProfileExample.main
train
public static void main(String[] args) throws InterruptedException { UserProfileExample example = new UserProfileExample(); // Let's create some user profiles example.create("John", "Doe", true); example.create("Jane", "Doe", false); example.create("Foo", "Bar", false); // Now print those user...
java
{ "resource": "" }
q162459
FastJavaScriptEngine.parse
train
private Class parse(String str, ScriptContext ctx) throws ScriptException { String fileName = getFileName(ctx); String sourcePath = getSourcePath(ctx); String classPath = getClassPath(ctx); Map<String, byte[]> classBytes = compiler.compile(fileName, str, ctx.getErrorWriter(), sourcePath, classPath); ...
java
{ "resource": "" }
q162460
AvroEntitySerDe.getColumnDecoder
train
private Decoder getColumnDecoder(Schema writtenFieldAvroSchema, InputStream in) { // Use a special Avro decoder that has special handling for int, long, // and String types. See ColumnDecoder for more information. if (writtenFieldAvroSchema.getType() == Type.INT || writtenFieldAvroSchema.getType() =...
java
{ "resource": "" }
q162461
AvroEntitySerDe.getColumnEncoder
train
private Encoder getColumnEncoder(Schema fieldAvroSchema, OutputStream out) { // Use a special Avro encoder that has special handling for int, long, // and String types. See ColumnEncoder for more information. if (fieldAvroSchema.getType() == Type.INT || fieldAvroSchema.getType() == Type.LONG ...
java
{ "resource": "" }
q162462
EntityScannerBuilder.addEqualFilter
train
public EntityScannerBuilder<E> addEqualFilter(String fieldName, Object filterValue) { SingleFieldEntityFilter singleFieldEntityFilter = new SingleFieldEntityFilter( entityMapper.getEntitySchema(), entityMapper.getEntitySerDe(), fieldName, filterValue, CompareFilter.CompareOp.EQUAL); filter...
java
{ "resource": "" }
q162463
EntityScannerBuilder.addRegexMatchFilter
train
public EntityScannerBuilder<E> addRegexMatchFilter(String fieldName, String regexString) { RegexEntityFilter regexEntityFilter = new RegexEntityFilter( entityMapper.getEntitySchema(), entityMapper.getEntitySerDe(), fieldName, regexString); filterList.add(regexEntityFilter.getFilter()); ...
java
{ "resource": "" }
q162464
EntityScannerBuilder.addIsMissingFilter
train
public EntityScannerBuilder<E> addIsMissingFilter(String fieldName) { SingleFieldEntityFilter singleFieldEntityFilter = new SingleFieldEntityFilter( entityMapper.getEntitySchema(), entityMapper.getEntitySerDe(), fieldName, "++++NON_SHALL_PASS++++", CompareFilter.CompareOp.EQUAL); SingleColumnVal...
java
{ "resource": "" }
q162465
AvroEntityComposer.initRecordBuilderFactories
train
private void initRecordBuilderFactories() { for (FieldMapping fieldMapping : avroSchema.getColumnMappingDescriptor().getFieldMappings()) { if (fieldMapping.getMappingType() == MappingType.KEY_AS_COLUMN) { String fieldName = fieldMapping.getFieldName(); Schema fieldSchema = avroSchema.getAvroSc...
java
{ "resource": "" }
q162466
ColumnMapping.getRequiredColumns
train
public Set<String> getRequiredColumns() { Set<String> set = new HashSet<String>(); for (FieldMapping fieldMapping : fieldMappings) { if (FieldMapping.MappingType.KEY == fieldMapping.getMappingType()) { continue; } else if (FieldMapping.MappingType.KEY_AS_COLUMN == fieldMapping.getMappingType...
java
{ "resource": "" }
q162467
ColumnMapping.getRequiredColumnFamilies
train
public Set<String> getRequiredColumnFamilies() { Set<String> set = new HashSet<String>(); for (FieldMapping mapping : fieldMappings) { if (FieldMapping.MappingType.KEY != mapping.getMappingType()) set.add(mapping.getFamilyAsString()); } return set; }
java
{ "resource": "" }
q162468
HdfsService.shouldFormatDFSCluster
train
private static boolean shouldFormatDFSCluster(String localDFSLocation, boolean clean) { boolean format = true; File f = new File(localDFSLocation); if (f.exists() && f.isDirectory() && !clean) { format = false; } return format; }
java
{ "resource": "" }
q162469
HdfsService.configureDFSCluster
train
private static Configuration configureDFSCluster(Configuration config, String localDFSLocation, String bindIP, int namenodeRpcPort, int namenodeHttpPort, int datanodePort, int datanodeIpcPort, int datanodeHttpPort) { logger.info("HDFS force binding to ip: " + bindIP); config = new KiteCompati...
java
{ "resource": "" }
q162470
Constraints.filter
train
public <E> Iterator<E> filter(Iterator<E> iterator, EntityAccessor<E> accessor) { return Iterators.filter(iterator, toEntityPredicate(accessor)); }
java
{ "resource": "" }
q162471
Constraints.alignedWithBoundaries
train
@SuppressWarnings("unchecked") public boolean alignedWithBoundaries() { if (constraints.isEmpty()) { return true; } else if (strategy == null) { // constraints must align with partitions, which requires a strategy return false; } Multimap<String, FieldPartitioner> partitioners = Has...
java
{ "resource": "" }
q162472
Constraints.toNormalizedQueryMap
train
public Map<String, String> toNormalizedQueryMap() { Map<String, String> query = Maps.newTreeMap(); return toQueryMap(query, true); }
java
{ "resource": "" }
q162473
HiveSchemaConverter.startsWith
train
private static boolean startsWith(String[] left, List<String> right) { // short circuit if a match isn't possible if (left.length < right.size()) { return false; } for (int i = 0; i < right.size(); i += 1) { if (!left[i].equals(right.get(i))) { return false; } } retur...
java
{ "resource": "" }
q162474
KeySchema.position
train
public int position(String fieldName) { if (fieldPositions.containsKey(fieldName)) { return fieldPositions.get(fieldName); } else { throw new DatasetException("Cannot recover " + fieldName + " from key"); } }
java
{ "resource": "" }
q162475
PartitionExpression.toExpression
train
public static String toExpression(PartitionStrategy partitionStrategy) { List<FieldPartitioner> fieldPartitioners = partitionStrategy .getFieldPartitioners(); if (fieldPartitioners.size() == 1) { return PartitionFunctions.toExpression(fieldPartitioners.get(0)); } StringBuilder sb = new Str...
java
{ "resource": "" }
q162476
VersionedAvroEntityMapper.initializeEntityVersionEntityMapper
train
private void initializeEntityVersionEntityMapper() { AvroEntitySchema avroEntitySchema = schemaParser .parseEntitySchema(managedSchemaEntityVersionSchema); avroEntitySchema = AvroUtils.mergeSpecificStringTypes( ManagedSchemaEntityVersion.class, avroEntitySchema); AvroEntityComposer<ManagedSc...
java
{ "resource": "" }
q162477
VersionedAvroEntityMapper.updateEntityMappers
train
private void updateEntityMappers() { for (Entry<Integer, EntitySchema> entry : schemaManager.getEntitySchemas( tableName, entityName).entrySet()) { if (!entityMappers.containsKey(entry.getKey())) { AvroEntitySchema writtenSchema = (AvroEntitySchema) entry.getValue(); EntityMapper<ENTIT...
java
{ "resource": "" }
q162478
RangeFieldPartitioner.transformClosed
train
private Range<String> transformClosed(Range<String> range) { if (range.hasLowerBound()) { String lower = range.lowerEndpoint(); // the special case, (a, _] and apply(a) == a is handled by skipping a String afterLower = domain.next(apply(lower)); if (afterLower != null) { if (range.ha...
java
{ "resource": "" }
q162479
FileSystemUtil.deleteParentDirectoriesIfEmpty
train
static boolean deleteParentDirectoriesIfEmpty(FileSystem fs, Path root, Path path) throws IOException { boolean deleted = false; try { for (Path current = path.getParent(); !current.equals(root) && !(current.getParent() == null); current = current.getParent()) { final FileSta...
java
{ "resource": "" }
q162480
FileSystemUtil.supportsRename
train
public static boolean supportsRename(URI fsUri, Configuration conf) { String fsUriScheme = fsUri.getScheme(); // Only S3 is known to not support renaming, but allow configuration override. // This logic is intended as a temporary placeholder solution and should // be revisited once HADOOP-9565 has been...
java
{ "resource": "" }
q162481
CSVAppender.valueString
train
private static String valueString(Object value, Schema schema) { if (value == null || schema.getType() == Schema.Type.NULL) { return null; } switch (schema.getType()) { case BOOLEAN: case FLOAT: case DOUBLE: case INT: case LONG: case STRING: return value.to...
java
{ "resource": "" }
q162482
DatasetKeyOutputFormat.loadOrCreateJobDataset
train
@SuppressWarnings("unchecked") private static <E> Dataset<E> loadOrCreateJobDataset(JobContext jobContext) { Dataset<Object> dataset = load(jobContext).getDataset(); String jobDatasetName = getJobDatasetName(jobContext); DatasetRepository repo = getDatasetRepository(jobContext); if (repo.exists(TEMP_N...
java
{ "resource": "" }
q162483
SchemaTool.createOrMigrateSchemaDirectory
train
public void createOrMigrateSchemaDirectory(String schemaDirectory, boolean createTableAndFamilies) throws InterruptedException { List<String> schemaStrings; if (schemaDirectory.startsWith(CLASSPATH_PREFIX)) { URL dirURL = getClass().getClassLoader().getResource( schemaDirectory.substring(C...
java
{ "resource": "" }
q162484
SchemaTool.prepareManagedSchema
train
private boolean prepareManagedSchema(String tableName, String entitySchemaString) { String entityName = getEntityNameFromSchemaString(entitySchemaString); AvroEntitySchema entitySchema = parser .parseEntitySchema(entitySchemaString); AvroKeySchema keySchema = parser.parseKeySchema(entitySchema...
java
{ "resource": "" }
q162485
SchemaTool.prepareTableDescriptor
train
private HTableDescriptor prepareTableDescriptor(String tableName, String entitySchemaString) { HTableDescriptor descriptor = new HTableDescriptor( Bytes.toBytes(tableName)); AvroEntitySchema entitySchema = parser .parseEntitySchema(entitySchemaString); Set<String> familiesToAdd = entit...
java
{ "resource": "" }
q162486
SchemaTool.createTables
train
private void createTables(Collection<HTableDescriptor> tableDescriptors) throws InterruptedException { try { Set<String> tablesCreated = Sets.newHashSet(); Multimap<String, HTableDescriptor> pendingTableUpdates = ArrayListMultimap .create(); for (HTableDescriptor tableDescriptor : ...
java
{ "resource": "" }
q162487
SchemaTool.modifyTable
train
private void modifyTable(String tableName, HTableDescriptor newDescriptor) { LOG.info("Modifying table " + tableName); HColumnDescriptor[] newFamilies = newDescriptor.getColumnFamilies(); try { List<HColumnDescriptor> columnsToAdd = Lists.newArrayList(); HTableDescriptor currentFamilies = hbaseA...
java
{ "resource": "" }
q162488
SchemaTool.getSchemaStringFromFile
train
private String getSchemaStringFromFile(File schemaFile) { String schemaString; FileInputStream fis = null; try { fis = new FileInputStream(schemaFile); schemaString = AvroUtils.inputStreamToString(fis); } catch (IOException e) { throw new DatasetException(e); } finally { if (...
java
{ "resource": "" }
q162489
SchemaTool.getSchemaStringsFromDir
train
private List<String> getSchemaStringsFromDir(File dir) { List<String> schemaStrings = new ArrayList<String>(); Collection<File> schemaFiles = FileUtils.listFiles(dir, new SuffixFileFilter(".avsc"), TrueFileFilter.INSTANCE); for (File schemaFile : schemaFiles) { schemaStrings.add(getSchemaStrin...
java
{ "resource": "" }
q162490
SchemaTool.getSchemaStringsFromJar
train
private List<String> getSchemaStringsFromJar(String jarPath, String directoryPath) { LOG.info("Getting schema strings in: " + directoryPath + ", from jar: " + jarPath); JarFile jar; try { jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8")); } catch (UnsupportedEncodingException e)...
java
{ "resource": "" }
q162491
Loader.setMetaStoreURI
train
private static void setMetaStoreURI( Configuration conf, Map<String, String> match) { try { // If the host is set, construct a new MetaStore URI and set the property // in the Configuration. Otherwise, do not change the MetaStore URI. String host = match.get(URIPattern.HOST); if (host ...
java
{ "resource": "" }
q162492
XMLStreamCopier.copy
train
public void copy(boolean isFragmentMode) throws XMLStreamException { int ev = isFragmentMode ? XMLStreamConstants.START_ELEMENT : XMLStreamConstants.START_DOCUMENT; reader.require(ev, null, null); int depth = 0; ev = reader.getEventType(); while (true) { switch (ev) { case XMLStreamConstants.START...
java
{ "resource": "" }
q162493
HBaseUtils.mergePuts
train
public static Put mergePuts(byte[] keyBytes, List<Put> putList) { Put put = new Put(keyBytes); for (Put putToMerge : putList) { Map<byte[], List<KeyValue>> familyMap = (Map<byte[], List<KeyValue>>) GET_FAMILY_MAP_METHOD.invoke(putToMerge); for (List<KeyValue> keyValueList : familyM...
java
{ "resource": "" }
q162494
HBaseUtils.mergePutActions
train
public static PutAction mergePutActions(byte[] keyBytes, List<PutAction> putActionList) { VersionCheckAction checkAction = null; List<Put> putsToMerge = new ArrayList<Put>(); for (PutAction putActionToMerge : putActionList) { putsToMerge.add(putActionToMerge.getPut()); VersionCheckAction c...
java
{ "resource": "" }
q162495
HBaseUtils.addColumnsToOperation
train
private static void addColumnsToOperation(Collection<String> columns, Operation operation) { // Keep track of whole family additions Set<String> familySet = new HashSet<String>(); // Iterate through each of the required columns for (String column : columns) { // Split the column by : (family : c...
java
{ "resource": "" }
q162496
HBaseUtils.addColumnsToScan
train
public static void addColumnsToScan(Collection<String> columns, final Scan scan) { addColumnsToOperation(columns, new Operation() { @Override public void addColumn(byte[] family, byte[] column) { scan.addColumn(family, column); } @Override public void addFamily(byte[] family) ...
java
{ "resource": "" }
q162497
HBaseUtils.addColumnsToGet
train
public static void addColumnsToGet(Collection<String> columns, final Get get) { addColumnsToOperation(columns, new Operation() { @Override public void addColumn(byte[] family, byte[] column) { get.addColumn(family, column); } @Override public void addFamily(byte[] family) { ...
java
{ "resource": "" }
q162498
XMLInputFactoryCreator.setupProperties
train
protected void setupProperties(XMLInputFactory factory) { factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE); try { factory.setProperty(XMLInputFactory.IS_V...
java
{ "resource": "" }
q162499
FileSystemMetadataProvider.pathForMetadata
train
private Path pathForMetadata(String namespace, String name) { return pathForMetadata(rootDirectory, namespace, name); }
java
{ "resource": "" }