proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
google_gson | gson/metrics/src/main/java/com/google/gson/metrics/NonUploadingCaliperRunner.java | NonUploadingCaliperRunner | run | class NonUploadingCaliperRunner {
private NonUploadingCaliperRunner() {}
private static String[] concat(String first, String... others) {
if (others.length == 0) {
return new String[] {first};
} else {
String[] result = new String[others.length + 1];
result[0] = first;
System.arrayc... |
// Disable result upload; Caliper uploads results to webapp by default, see
// https://github.com/google/caliper/issues/356
CaliperMain.main(c, concat("-Cresults.upload.options.url=", args));
| 152 | 68 | 220 | <no_super_class> |
google_gson | gson/metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java | JacksonStreamParser | parse | class JacksonStreamParser implements Parser {
@Override
public void parse(char[] data, Document document) throws Exception {<FILL_FUNCTION_BODY>}
} |
JsonFactory jsonFactory =
new JsonFactoryBuilder()
.configure(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, false)
.build();
com.fasterxml.jackson.core.JsonParser jp =
jsonFactory.createParser(new CharArrayReader(data));
int depth = 0;
do {
... | 44 | 327 | 371 | <no_super_class> |
google_gson | gson/metrics/src/main/java/com/google/gson/metrics/SerializationBenchmark.java | SerializationBenchmark | timeObjectSerialization | class SerializationBenchmark {
private Gson gson;
private BagOfPrimitives bag;
@Param private boolean pretty;
public static void main(String[] args) {
NonUploadingCaliperRunner.run(SerializationBenchmark.class, args);
}
@BeforeExperiment
void setUp() throws Exception {
this.gson = pretty ? new ... |
for (int i = 0; i < reps; ++i) {
gson.toJson(bag);
}
| 170 | 34 | 204 | <no_super_class> |
google_gson | gson/proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java | Builder | serialize | class Builder {
private final Set<Extension<FieldOptions, String>> serializedNameExtensions;
private final Set<Extension<EnumValueOptions, String>> serializedEnumValueExtensions;
private EnumSerialization enumSerialization;
private CaseFormat protoFormat;
private CaseFormat jsonFormat;
private ... |
JsonObject ret = new JsonObject();
final Map<FieldDescriptor, Object> fields = src.getAllFields();
for (Map.Entry<FieldDescriptor, Object> fieldPair : fields.entrySet()) {
final FieldDescriptor desc = fieldPair.getKey();
String name = getCustSerializedName(desc.getOptions(), desc.getName());
... | 1,496 | 318 | 1,814 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/bdb/AutoKryo.java | AutoKryo | newInstance | class AutoKryo extends Kryo {
protected ArrayList<Class<?>> registeredClasses = new ArrayList<Class<?>>();
@Override
protected void handleUnregisteredClass(@SuppressWarnings("rawtypes") Class type) {
System.err.println("UNREGISTERED FOR KRYO "+type+" in "+registeredClasses.get(0));
sup... |
SerializationException ex = null;
try {
return super.newInstance(type);
} catch (SerializationException se) {
ex = se;
}
try {
Constructor<?> constructor = CONSTRUCTOR_CACHE.get(type);
if(constructor == null) {
con... | 409 | 302 | 711 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/bdb/DisposableStoredSortedMap.java | DisposableStoredSortedMap | dispose | class DisposableStoredSortedMap<K,V> extends StoredSortedMap<K,V> {
final private static Logger LOGGER =
Logger.getLogger(DisposableStoredSortedMap.class.getName());
protected Database db;
public DisposableStoredSortedMap(Database db, EntryBinding<K> arg1, EntityBinding<V> arg2, boolean ... |
String name = null;
try {
if(this.db!=null) {
name = this.db.getDatabaseName();
this.db.close();
this.db.getEnvironment().removeDatabase(null, name);
this.db = null;
}
} catch (DatabaseException e)... | 371 | 121 | 492 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/bdb/KryoBinding.java | KryoBinding | getBuffer | class KryoBinding<K> implements EntryBinding<K> {
protected Class<K> baseClass;
protected AutoKryo kryo = new AutoKryo();
protected ThreadLocal<WeakReference<ObjectBuffer>> threadBuffer = new ThreadLocal<WeakReference<ObjectBuffer>>() {
@Override
protected WeakReference<ObjectBuffer> initi... |
WeakReference<ObjectBuffer> ref = threadBuffer.get();
ObjectBuffer ob = ref.get();
if (ob == null) {
ob = new ObjectBuffer(kryo,16*1024,Integer.MAX_VALUE);
threadBuffer.set(new WeakReference<ObjectBuffer>(ob));
}
return ob;
| 430 | 91 | 521 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/bdb/StoredQueue.java | StoredQueue | hookupDatabase | class StoredQueue<E extends Serializable> extends AbstractQueue<E> {
@SuppressWarnings("unused")
private static final Logger logger =
Logger.getLogger(StoredQueue.class.getName());
protected transient StoredSortedMap<Long,E> queueMap; // Long -> E
protected transient Database queueDb; // Datab... |
EntryBinding<E> valueBinding = TupleBinding.getPrimitiveBinding(clsOrNull);
if(valueBinding == null) {
valueBinding = new SerialBinding<E>(classCatalog, clsOrNull);
}
queueDb = db;
queueMap = new StoredSortedMap<Long,E>(
db,
TupleBindi... | 908 | 112 | 1,020 | <methods>public boolean add(E) ,public boolean addAll(Collection<? extends E>) ,public void clear() ,public E element() ,public E remove() <variables> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/checkpointing/Checkpoint.java | Checkpoint | saveWriter | class Checkpoint implements InitializingBean {
private final static Logger LOGGER =
Logger.getLogger(Checkpoint.class.getName());
/** format for serial numbers */
public static final DecimalFormat INDEX_FORMAT = new DecimalFormat("00000");
/** Name of file written with timestamp into vali... |
try {
File targetFile = new File(getCheckpointDir().getFile(),beanName+"-"+extraName);
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("opening for writing: " + targetFile);
}
return new BufferedWriter(new FileWriter(targetFile));
... | 1,303 | 160 | 1,463 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/io/Arc2Warc.java | Arc2Warc | transform | class Arc2Warc {
protected RecordIDGenerator generator = new UUIDGenerator();
private static void usage(HelpFormatter formatter, Options options,
int exitCode) {
formatter.printHelp("java org.archive.io.arc.Arc2Warc " +
"[--force] ARC_INPUT WARC_OUTPUT", options);
System.e... |
WARCWriter writer = null;
// No point digesting. Digest is available after reading of ARC which
// is too late for inclusion in WARC.
reader.setDigest(false);
try {
BufferedOutputStream bos =
new BufferedOutputStream(new FileOutputStream(warc));
// Get the body of the first ARC reco... | 1,359 | 683 | 2,042 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/io/CrawlerJournal.java | CrawlerJournal | close | class CrawlerJournal implements Closeable {
private static final Logger LOGGER = Logger.getLogger(
CrawlerJournal.class.getName());
/** prefix for error lines*/
public static final String LOG_ERROR = "E ";
/** prefix for timestamp lines */
public static final String LOG_TIMESTAMP = ... |
if (this.out == null) {
return;
}
try {
this.out.flush();
this.out.close();
this.out = null;
} catch (IOException e) {
LOGGER.log(Level.SEVERE,"problem closing journal", e);
}
| 1,402 | 80 | 1,482 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/io/Warc2Arc.java | Warc2Arc | transform | class Warc2Arc {
private static void usage(HelpFormatter formatter, Options options,
int exitCode) {
formatter.printHelp("java org.archive.io.arc.Warc2Arc " +
"[--force] [--prefix=PREFIX] [--suffix=SUFFIX] WARC_INPUT " +
"OUTPUT_DIR",
options);
System.exit(e... |
FileUtils.assertReadable(warc);
FileUtils.assertReadable(dir);
WARCReader reader = WARCReaderFactory.get(warc);
List<String> metadata = new ArrayList<String>();
metadata.add("Made from " + reader.getReaderIdentifier() + " by " +
this.getClass().getName() + "/" + getRevisi... | 1,719 | 181 | 1,900 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/net/ClientFTP.java | ClientFTP | disconnect | class ClientFTP extends FTPClient implements ProtocolCommandListener {
private final Logger logger = Logger.getLogger(this.getClass().getName());
// Records the conversation on the ftp control channel. The format is based on "curl -v".
protected StringBuilder controlConversation;
protected Socket data... |
String remoteHostPort = getRemoteAddress().getHostAddress() + ":"
+ getRemotePort();
super.disconnect();
recordAdditionalInfo("Closed control connection to " + remoteHostPort);
| 1,015 | 52 | 1,067 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/net/ClientSFTP.java | ClientSFTP | getLsFileMap | class ClientSFTP {
private final Logger logger = Logger.getLogger(getClass().getName());
protected StringBuilder controlConversation;
protected Socket dataSocket;
protected Session session = null;
protected Channel channel = null;
protected ChannelSftp channelSFTP = null;
public ClientSFTP() {
this.controlC... |
Map<String, Boolean> hashMap = new HashMap<>();
Vector<ChannelSftp.LsEntry> vector = channelSFTP.ls(paramString);
for(ChannelSftp.LsEntry lsEntry : vector) {
String str = lsEntry.getFilename();
if (!".".equals(str)) {
if (!"..".equals(str)) {
String str1 = paramString + "/" + str;
boolean... | 1,004 | 177 | 1,181 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/net/UURI.java | UURI | readObjectData | class UURI extends UsableURI implements CustomSerialization {
private static final long serialVersionUID = -8946640480772772310L;
public UURI(String fixup, boolean b, String charset) throws URIException {
super(fixup, b, charset);
}
public UURI(UsableURI base, UsableURI relative) throws URIEx... |
try {
parseUriReference(StringSerializer.get(buffer), true);
} catch (URIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
| 286 | 52 | 338 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/net/UURIFactory.java | UURIFactory | makeOne | class UURIFactory extends UsableURIFactory {
private static final long serialVersionUID = -7969477276065915936L;
/**
* The single instance of this factory.
*/
private static final UURIFactory factory = new UURIFactory();
/**
* @param uri URI as string.
* @return An ins... |
// return new UURI(base, relative);
return new UURI(base, relative);
| 340 | 26 | 366 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/spring/BeanFieldsPatternValidator.java | PropertyPatternRule | test | class PropertyPatternRule {
protected String propertyName;
protected Pattern requiredPattern;
protected String errorMessage;
public PropertyPatternRule(String name, String pat, String msg) {
propertyName = name;
requiredPattern = Pattern.compile(pat);
... |
Matcher m = requiredPattern.matcher(
(CharSequence)wrapper.getPropertyValue(propertyName));
if(!m.matches()) {
errors.rejectValue(propertyName, null, errorMessage);
}
| 124 | 65 | 189 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/spring/ConfigFile.java | ConfigFile | obtainWriter | class ConfigFile extends ConfigPath implements ReadSource, WriteTarget {
private static final long serialVersionUID = 1L;
public ConfigFile() {
super();
}
public ConfigFile(String name, String path) {
super(name, path);
}
public Reader obtainReader() {
try ... |
try {
return new OutputStreamWriter(
new FileOutputStream(getFile(), append),
"UTF-8");
} catch (IOException e) {
throw new RuntimeException(e);
}
| 268 | 62 | 330 | <methods>public void <init>() ,public void <init>(java.lang.String, java.lang.String) ,public org.archive.spring.ConfigPath getBase() ,public java.io.File getFile() ,public java.lang.String getName() ,public java.lang.String getPath() ,public org.archive.spring.ConfigPath merge(org.archive.spring.ConfigPath) ,public vo... |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/spring/ConfigPath.java | ConfigPath | getFile | class ConfigPath implements Serializable {
private static final long serialVersionUID = 1L;
protected String name;
protected String path;
protected ConfigPath base;
public ConfigPath() {
super();
}
public ConfigPath(String name, String path) {
super();... |
String interpolatedPath;
if (configurer != null) {
interpolatedPath = configurer.interpolate(path);
} else {
interpolatedPath = path;
}
return base == null || interpolatedPath.startsWith("/")
? new File(interpolatedPath)
... | 521 | 108 | 629 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/spring/ConfigPathConfigurer.java | ConfigPathConfigurer | fixupPaths | class ConfigPathConfigurer
implements
BeanPostProcessor,
ApplicationListener<ApplicationEvent>,
ApplicationContextAware,
Ordered {
private static final Logger logger =
Logger.getLogger(ConfigPathConfigurer.class.getName());
protected Map<String,Object> allBeans = new HashMa... |
BeanWrapperImpl wrapper = new BeanWrapperImpl(bean);
for(PropertyDescriptor d : wrapper.getPropertyDescriptors()) {
if (d.getPropertyType().isAssignableFrom(ConfigPath.class)
|| d.getPropertyType().isAssignableFrom(ConfigFile.class)) {
Object value =... | 1,391 | 329 | 1,720 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/spring/HeritrixLifecycleProcessor.java | HeritrixLifecycleProcessor | onRefresh | class HeritrixLifecycleProcessor extends DefaultLifecycleProcessor implements BeanNameAware {
protected String name;
@Override
public void onRefresh() {<FILL_FUNCTION_BODY>}
@Override
public void setBeanName(String name) {
this.name = name;
}
public String getBeanName() {
... |
// do nothing: we do not want to auto-start
| 106 | 17 | 123 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/spring/KeyedProperties.java | KeyedProperties | withOverridesDo | class KeyedProperties extends ConcurrentSkipListMap<String,Object> {
private static final long serialVersionUID = 2L;
private static final Logger logger = Logger.getLogger(KeyedProperties.class.getName());
/** the alternate global property-paths leading to this map
* TODO: consider if dete... |
try {
loadOverridesFrom(ocontext);
todo.run();
} finally {
clearOverridesFrom(ocontext);
}
| 1,101 | 53 | 1,154 | <methods>public void <init>() ,public void <init>(Comparator<? super java.lang.String>) ,public void <init>(Map<? extends java.lang.String,? extends java.lang.Object>) ,public void <init>(SortedMap<java.lang.String,? extends java.lang.Object>) ,public Entry<java.lang.String,java.lang.Object> ceilingEntry(java.lang.Stri... |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/spring/PathSharingContext.java | PathSharingContext | getConfigurationFile | class PathSharingContext extends FileSystemXmlApplicationContext {
private static Logger LOGGER =
Logger.getLogger(PathSharingContext.class.getName());
public PathSharingContext(String configLocation) throws BeansException {
super(configLocation);
}
public PathSharingContext(Stri... |
String primaryConfigurationPath = getPrimaryConfigurationPath();
if (primaryConfigurationPath.startsWith("file:")) {
// strip URI-scheme if present (as is usual)
try {
return new File(new URI(primaryConfigurationPath));
} catch (URISyntaxExcept... | 1,420 | 116 | 1,536 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/spring/Sheet.java | Sheet | prime | class Sheet implements BeanFactoryAware, BeanNameAware {
@SuppressWarnings("unused")
private static final long serialVersionUID = 9129011082185864377L;
/**
* unique name of this Sheet; if Sheet has a beanName from original
* configuration, that is always the name -- but the name might
... |
for (String fullpath : map.keySet()) {
int lastDot = fullpath.lastIndexOf(".");
String beanPath = fullpath.substring(0,lastDot);
String terminalProp = fullpath.substring(lastDot+1);
Object value = map.get(fullpath);
int i = beanPath.indexOf(".... | 694 | 503 | 1,197 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/surt/SURTTokenizer.java | SURTTokenizer | nextSearch | class SURTTokenizer {
private final static String EXACT_SUFFIX = "\t";
private String remainder;
private boolean triedExact;
private boolean triedFull;
private boolean choppedArgs;
private boolean choppedPath;
private boolean choppedLogin;
private boolean... |
if(!triedExact) {
triedExact = true;
//remainder = remainder.substring(0,remainder.length()-1);
return remainder + EXACT_SUFFIX;
}
if(!triedFull) {
triedFull = true;
... | 565 | 529 | 1,094 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/BloomFilter64bit.java | BloomFilter64bit | add | class BloomFilter64bit implements Serializable, BloomFilter {
private static final long serialVersionUID = 3L;
/** The expected number of inserts; determines calculated size */
private final long expectedInserts;
/** The number of elements currently in the filter. It may be
* smaller than the a... |
boolean added = delegate.put(s);
if (added) {
size++;
}
return added;
| 1,320 | 34 | 1,354 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/Histotable.java | Histotable | getTotal | class Histotable<K> extends TreeMap<K,Long> {
private static final long serialVersionUID = 310306238032568623L;
/**
* Record one more occurrence of the given object key.
*
* @param key Object key.
*/
public void tally(K key) {
tally(key,1L);
}
/**
* Re... |
long total = 0;
for (Long el : values()) {
total += el;
}
return total;
| 1,286 | 36 | 1,322 | <methods>public void <init>() ,public void <init>(Comparator<? super K>) ,public void <init>(Map<? extends K,? extends java.lang.Long>) ,public void <init>(SortedMap<K,? extends java.lang.Long>) ,public Entry<K,java.lang.Long> ceilingEntry(K) ,public K ceilingKey(K) ,public void clear() ,public java.lang.Object clone()... |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/JSONUtils.java | JSONUtils | putAllLongs | class JSONUtils {
@SuppressWarnings("unchecked")
public static void putAllLongs(Map<String,Long> targetMap, JSONObject sourceJson) throws JSONException {<FILL_FUNCTION_BODY>}
@SuppressWarnings("unchecked")
public static void putAllAtomicLongs(Map<String,AtomicLong> targetMap, JSONObject sourceJs... |
for(String k : new Iteratorable<String>(sourceJson.keys())) {
targetMap.put(k, sourceJson.getLong(k));
}
| 165 | 48 | 213 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/JavaLiterals.java | JavaLiterals | escape | class JavaLiterals {
public static String escape(String raw) {<FILL_FUNCTION_BODY>}
public static String unescape(String escaped) {
StringBuffer raw = new StringBuffer();
for(int i = 0; i<escaped.length(); i++) {
char c = escaped.charAt(i);
if (c!='\\') {
raw.append(c);
} else {
... |
StringBuffer escaped = new StringBuffer();
for(int i = 0; i<raw.length(); i++) {
char c = raw.charAt(i);
switch (c) {
case '\b':
escaped.append("\\b");
break;
case '\t':
escaped.append("\\t");
break;
case '\n':
escaped.append... | 564 | 314 | 878 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/JndiUtils.java | JndiUtils | getReference | class JndiUtils {
/**
* Syntax that will work with jmx ObjectNames (i.e. will escape '.' and
* will add treat ',' and '=' specially.
*/
private static final Properties COMPOUND_NAME_SYNTAX = new Properties();
static {
COMPOUND_NAME_SYNTAX.put("jndi.syntax.direction", "left_to_right");... |
Reference r = new Reference(String.class.getName());
Hashtable<String,String> ht = on.getKeyPropertyList();
r.add(new StringRefAddr("host", (String)ht.get("host")));
r.add(new StringRefAddr("name", (String)ht.get("name")));
// Put in a value to serve as a unique 'key'.
r.add(n... | 1,453 | 128 | 1,581 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/KeyTool.java | KeyTool | main | class KeyTool {
public static void main(String[] args) {<FILL_FUNCTION_BODY>}
} |
try {
Class<?> cl;
try {
// java 6 and 7
cl = ClassLoader.getSystemClassLoader().loadClass("sun.security.tools.KeyTool");
} catch (ClassNotFoundException e) {
// java 8
cl = ClassLoader.getSystemClassLoader().loadClass("sun.security.tools.keytool.Main");
}
Method main = cl.getMethod("m... | 31 | 339 | 370 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/LongToIntConsistentHash.java | LongToIntConsistentHash | bucketFor | class LongToIntConsistentHash {
protected static final int DEFAULT_REPLICAS = 128;
protected TreeMap<Long,Integer> circle = new TreeMap<Long,Integer>();
protected int replicasInstalledUpTo=-1;
protected int numReplicas;
public LongToIntConsistentHash() {
this(DEFAULT_REPLICAS);
... |
installReplicasUpTo(upTo);
NavigableMap<Long, Integer> tailMap = circle.tailMap(longHash, true);
Map.Entry<Long,Integer> match = null;
for(Map.Entry<Long,Integer> candidate : tailMap.entrySet()) {
if(candidate.getValue() < upTo) {
match = can... | 756 | 161 | 917 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ObjectIdentityMemCache.java | ObjectIdentityMemCache | getOrUse | class ObjectIdentityMemCache<V extends IdentityCacheable>
implements ObjectIdentityCache<V> {
protected ConcurrentHashMap<String, V> map;
public ObjectIdentityMemCache() {
map = new ConcurrentHashMap<String, V>();
}
public ObjectIdentityMemCache(int cap, float load, int conc)... |
V val = map.get(key);
if (val==null && supplierOrNull!=null) {
val = supplierOrNull.get();
V prevVal = map.putIfAbsent(key, val);
if(prevVal!=null) {
val = prevVal;
}
}
if (val != null) {
val.setIde... | 383 | 126 | 509 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/OneLineSimpleLayout.java | OneLineSimpleLayout | format | class OneLineSimpleLayout extends Layout {
private OneLineSimpleLogger logger = new OneLineSimpleLogger();
@Override
public void activateOptions() {
}
@Override
public String format(LoggingEvent event) {<FILL_FUNCTION_BODY>}
protected java.util.logging.Level convertLevel(org.apache.log4j... |
java.util.logging.Level level = convertLevel(event.getLevel());
LogRecord logRecord = new LogRecord(level, event.getMessage().toString());
logRecord.setLoggerName(event.getLoggerName());
logRecord.setMillis(event.getTimeStamp());
logRecord.setSourceClassName(event.getLoggerName... | 353 | 138 | 491 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/OneLineSimpleLogger.java | OneLineSimpleLogger | format | class OneLineSimpleLogger extends SimpleFormatter {
/**
* Date instance.
*
* Keep around instance of date.
*/
private Date date = new Date();
/**
* Field position instance.
*
* Keep around this instance.
*/
private FieldPosition position = new FieldPos... |
this.buffer.setLength(0);
this.date.setTime(record.getMillis());
this.position.setBeginIndex(0);
this.formatter.format(this.date, buffer, this.position);
buffer.append(' ');
buffer.append(record.getLevel().getLocalizedName());
buffer.append(" thread-");
b... | 437 | 373 | 810 | <methods>public void <init>() ,public java.lang.String format(java.util.logging.LogRecord) <variables>private final java.lang.String format |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/PaddingStringBuffer.java | PaddingStringBuffer | append | class PaddingStringBuffer {
// The buffer.
protected StringBuffer buffer;
// Location in current line
protected int linePos;
/**
* Create a new PaddingStringBuffer
*
*/
public PaddingStringBuffer() {
buffer = new StringBuffer();
linePos=0;
}
/** append a... |
buffer.append(string);
if ( string.indexOf('\n') == -1 ){
linePos+=string.length();
} else {
while ( string.indexOf('\n') == -1 ){
string = string.substring(string.indexOf('\n'));
}
linePos=string.length();
}
return... | 991 | 94 | 1,085 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/PrefixFinder.java | PrefixFinder | find | class PrefixFinder {
/**
* Extracts prefixes of a given string from a SortedSet. If an element
* of the given set is a prefix of the given string, then that element
* is added to the result list.
*
* <p>Put another way, for every element in the result list, the following
* express... |
LinkedList<String> result = new LinkedList<String>();
set = headSetInclusive(set, input);
for (String last = last(set); last != null; last = last(set)) {
if (input.startsWith(last)) {
result.push(last);
set = set.headSet(last);
} else {
... | 931 | 172 | 1,103 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ReportUtils.java | ReportUtils | shortReportLine | class ReportUtils {
/**
* Utility method to get a String shortReportLine from Reporter
* @param rep Reporter to get shortReportLine from
* @return String of report
*/
public static String shortReportLine(Reporter rep) {<FILL_FUNCTION_BODY>}
} |
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try {
rep.shortReportLineTo(pw);
} catch (IOException e) {
// not really possible
e.printStackTrace();
}
pw.flush();
return sw.toString();
| 79 | 82 | 161 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/TestUtils.java | TestUtils | makeSuite | class TestUtils {
private static final Logger logger =
Logger.getLogger(TestUtils.class.getName());
/**
* Temporarily exhaust memory, forcing weak/soft references to
* be broken.
*/
public static void forceScarceMemory() {
// force soft references to be broken
Linked... |
TestSuite result = new TestSuite("All Tests");
if (!dir.exists()) {
throw new IllegalArgumentException(dir + " does not exist.");
}
scanSuite(result, srcRoot, dir);
return result;
| 1,119 | 63 | 1,182 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/bdbje/EnhancedEnvironment.java | EnhancedEnvironment | getClassCatalog | class EnhancedEnvironment extends Environment {
protected StoredClassCatalog classCatalog;
protected Database classCatalogDB;
/**
* Constructor
*
* @param envHome directory in which to open environment
* @param envConfig config options
* @throws DatabaseException
*/
... |
if(classCatalog == null) {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setReadOnly(this.getConfig().getReadOnly());
try {
classCatalogDB = openDatabase(null, "classCatalog", dbConfig);
cl... | 389 | 137 | 526 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/fingerprint/ArrayLongFPCache.java | ArrayLongFPCache | contains | class ArrayLongFPCache implements LongFPSet {
public static final int DEFAULT_CAPACITY = 1 << 20; // 1 million, 8MB
public static final int DEFAULT_SMEAR = 5;
protected long cache[] = new long[DEFAULT_CAPACITY];
protected int smear = DEFAULT_SMEAR;
protected int count = 0;
public void set... |
int index = Math.abs((int) (l % cache.length));
for(int i = index; i < index + smear; i++) {
if(cache[i%cache.length]==l) {
return true;
}
}
return false;
| 632 | 73 | 705 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/fingerprint/LongFPSetCache.java | LongFPSetCache | discard | class LongFPSetCache extends MemLongFPSet {
private static final long serialVersionUID = -5307436423975825566L;
long sweepHand = 0;
public LongFPSetCache() {
super();
}
public LongFPSetCache(int capacityPowerOfTwo, float loadFactor) {
super(capacityPowerOfTwo, loadFactor);
... |
int toDiscard = i;
while(toDiscard>0) {
if(slots[(int)sweepHand]==0) {
removeAt(sweepHand);
toDiscard--;
} else {
if (slots[(int)sweepHand]>0) {
slots[(int)sweepHand]--;
}
}
... | 202 | 129 | 331 | <methods>public void <init>() ,public void <init>(int, float) ,public boolean quickContains(long) <variables>private static final int DEFAULT_CAPACITY_POWER_OF_TWO,private static final float DEFAULT_LOAD_FACTOR,private static java.util.logging.Logger logger,private static final long serialVersionUID,protected byte[] sl... |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/fingerprint/LongFPSetTestCase.java | LongFPSetTestCase | testContains | class LongFPSetTestCase extends TestCase {
/** the unerlying FPSet we wish to test */
private LongFPSet fpSet;
/**
* Create a new LongFPSetTest object
*
* @param testName the name of the test
*/
public LongFPSetTestCase(final String testName) {
super(testName);
}
p... |
long l1 = (long) 1234;
long l2 = (long) 2345;
long l3 = (long) 1334;
assertEquals("empty set to start", 0, fpSet.count());
fpSet.add(l1);
fpSet.add(l2);
assertTrue("contains l1", fpSet.contains(l1));
assertTrue("contains l2", fpSet.contains(l2));
... | 807 | 146 | 953 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/fingerprint/MemLongFPSet.java | MemLongFPSet | grow | class MemLongFPSet extends AbstractLongFPSet
implements LongFPSet, Serializable {
private static final long serialVersionUID = -4301879539092625698L;
private static Logger logger =
Logger.getLogger(MemLongFPSet.class.getName());
private static final int DEFAULT_CAPACITY_POWER_OF_TWO = 10... |
// Catastrophic event. Log its occurrence.
logger.info("Doubling fingerprinting slots to "
+ (1 << this.capacityPowerOfTwo));
long[] oldValues = values;
byte[] oldSlots = slots;
capacityPowerOfTwo++;
values = new long[1 << capacityPowerOfTwo];
slots ... | 647 | 198 | 845 | <methods>public void <init>() ,public void <init>(int, float) ,public boolean add(long) ,public boolean contains(long) ,public long count() ,public boolean quickContains(long) ,public boolean remove(long) <variables>protected static byte EMPTY,protected int capacityPowerOfTwo,protected long count,protected float loadFa... |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/iterator/CompositeIterator.java | CompositeIterator | hasNext | class CompositeIterator<E> implements Iterator<E> {
protected ArrayList<Iterator<E>> iterators = new ArrayList<Iterator<E>>();
protected Iterator<E> currentIterator;
protected int indexOfCurrentIterator = -1;
/**
* Moves to the next (non empty) iterator. Returns false if there are no
* more (... |
if(currentIterator!=null && currentIterator.hasNext()) {
// Got more
return true;
} else {
// Have got more if we can queue up a new iterator.
return nextIterator();
}
| 558 | 60 | 618 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ms/BlockInputStream.java | BlockInputStream | read | class BlockInputStream extends SeekInputStream {
/**
* The starting block number.
*/
private int start;
/**
* The current block.
*/
private int block;
/**
* The BlockFileSystem that produced this stream.
*/
private BlockFileSystem bfs;
... |
if (!ensureBuffer()) {
return 0;
}
int rem = BLOCK_SIZE - (int)(position % BLOCK_SIZE);
len = Math.min(len, rem);
int c = raw.read(b, ofs, len);
position += c;
expectedRawPosition += c;
blockBytesRead++;
return len;
| 1,097 | 94 | 1,191 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ms/Cp1252.java | Cp1252 | createTable | class Cp1252 {
/**
* The translation table. If x is an unsigned byte from a .doc
* text stream, then XLAT[x] is the Unicode character that byte
* represents.
*/
final private static char[] XLAT = createTable();
/**
* Static utility library, do not instantiate.
*/ ... |
char[] result = new char[256];
byte[] b = new byte[1];
for (int i = 0; i < 256; i++) try {
b[0] = (byte)i;
String s = new String(b, "Cp1252");
result[i] = s.charAt(0);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e... | 281 | 120 | 401 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ms/DefaultBlockFileSystem.java | DefaultBlockFileSystem | getNextBlock | class DefaultBlockFileSystem implements BlockFileSystem {
/**
* Pointers per BAT block.
*/
final private static int POINTERS_PER_BAT = 128;
/**
* Size of a BAT pointer in bytes. (In other words, 4).
*/
final private static int BAT_POINTER_SIZE = BLOCK_SIZE / POINTERS_PER_BAT;
... |
if (block < 0) {
return block;
}
// Index into the header array of BAT blocks.
int headerIndex = block / POINTERS_PER_BAT;
// Index within that BAT block of the block we're interested in.
int batBlockIndex = block % POINTERS_PER_BAT;
... | 1,467 | 142 | 1,609 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ms/DefaultEntry.java | DefaultEntry | list | class DefaultEntry implements Entry {
private DefaultBlockFileSystem origin;
private String name;
private EntryType type;
private int previous;
private int next;
private int child;
private int startBlock;
private int size;
private int index;
public DefaultEntry(De... |
if (child < 0) {
throw new IllegalStateException("Can't list non-directory.");
}
Entry child = getChild();
ArrayList<Entry> r = new ArrayList<Entry>();
list(r, child);
return r;
| 874 | 66 | 940 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ms/Doc.java | Doc | getText | class Doc {
final private static Logger LOGGER = Logger.getLogger(Doc.class.getName());
/**
* Static utility library, do not instantiate.
*/
private Doc() {
}
/**
* Returns the text of the .doc file with the given file name.
*
* @param docFilename the na... |
List<Entry> entries = wordDoc.getRoot().list();
Entry main = find(entries, "WordDocument");
SeekInputStream mainStream = main.open();
mainStream.position(10);
int flags = Endian.littleChar(mainStream);
boolean complex = (flags & 0x0004) == 0x0004;
boolea... | 713 | 508 | 1,221 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ms/HeaderBlock.java | HeaderBlock | toString | class HeaderBlock {
private ByteBuffer buffer;
public HeaderBlock(ByteBuffer buffer) {
// FIXME: Read the fields we're interested in directly from stream
this.buffer = buffer;
buffer.order(ByteOrder.LITTLE_ENDIAN);
}
public long getFileType() {
r... |
StringBuilder sb = new StringBuilder("HeaderBlock{");
sb.append("fileType=" + getFileType());
sb.append(" propertiesStart=" + getEntriesStart());
sb.append(" batCount=" + getBATCount());
sb.append(" extendedBATStart=" + getExtendedBATStart());
sb.append(" extendedBATCoun... | 364 | 157 | 521 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ms/Piece.java | Piece | toString | class Piece {
private boolean unicode;
private int charPosStart;
private int charPosLimit;
private int filePos;
public Piece(int filePos, int start, int end, boolean unicode) {
this.filePos = filePos;
this.charPosStart = start;
this.charPosLimit = end;
this.unic... |
StringBuilder sb = new StringBuilder();
sb.append("Piece{filePos=").append(filePos);
sb.append(" start=").append(charPosStart);
sb.append(" end=").append(charPosLimit);
sb.append(" unicode=").append(unicode);
sb.append("}");
return sb.toString();
| 241 | 91 | 332 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ms/PieceReader.java | PieceReader | read | class PieceReader extends SeekReader {
private PieceTable table;
private SeekInputStream doc;
private boolean unicode;
private int charPos;
private int limit;
public PieceReader(PieceTable table, SeekInputStream doc)
throws IOException {
this.table = table;
this.doc ... |
// FIXME: Think of a faster implementation that will work with
// both unicode and non-unicode.
seekIfNecessary();
if (doc == null) {
throw new IOException("Stream closed.");
}
if (charPos >= table.getMaxCharPos()) {
return 0;
}
fo... | 606 | 148 | 754 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/commons/src/main/java/org/archive/util/ms/PieceTable.java | PieceTable | next | class PieceTable {
private final static Logger LOGGER
= Logger.getLogger(PieceTable.class.getName());
/** The bit that indicates if a piece uses Cp1252 or unicode. */
protected final static int CP1252_INDICATOR = 1 << 30;
/** The mask to use to clear the Cp1252 flag bit. */
protected fin... |
if (current >= count) {
currentPiece = null;
return null;
}
int cp;
if (current == count - 1) {
cp = maxCharPos;
} else {
charPos.position(current * 4);
cp = Endian.littleInt(charPos);
}
... | 1,573 | 367 | 1,940 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/crawler/frontier/AMQPUrlReceiver.java | StarterRestarter | run | class StarterRestarter extends Thread {
public StarterRestarter(String name) {
super(name);
}
@Override
public void run() {<FILL_FUNCTION_BODY>}
public void startConsumer() throws IOException, TimeoutException {
Consumer consumer = new UrlConsumer(chann... |
while (!Thread.interrupted()) {
try {
lock.lockInterruptibly();
logger.finest("Checking consumerTag=" + consumerTag + " and pauseConsumer=" + pauseConsumer);
try {
if (consumerTag == null && !pauseConsumer) ... | 244 | 328 | 572 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/crawler/prefetch/HostQuotaEnforcer.java | HostQuotaEnforcer | shouldProcess | class HostQuotaEnforcer extends Processor {
protected ServerCache serverCache;
public ServerCache getServerCache() {
return this.serverCache;
}
@Autowired
public void setServerCache(ServerCache serverCache) {
this.serverCache = serverCache;
}
protected String host;
publ... |
String uriHostname = serverCache.getHostFor(curi.getUURI()).getHostName();
if (getApplyToSubdomains() && InternetDomainName.isValid(host) && InternetDomainName.isValid(uriHostname)) {
InternetDomainName h = InternetDomainName.from(host);
InternetDomainName uriHostOrAncestor = In... | 592 | 225 | 817 | <methods>public non-sealed void <init>() ,public void doCheckpoint(org.archive.checkpointing.Checkpoint) throws java.io.IOException,public void finishCheckpoint(org.archive.checkpointing.Checkpoint) ,public static java.lang.String flattenVia(org.archive.modules.CrawlURI) ,public java.lang.String getBeanName() ,public b... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/crawler/prefetch/SourceQuotaEnforcer.java | SourceQuotaEnforcer | innerProcessResult | class SourceQuotaEnforcer extends Processor {
protected String sourceTag;
public void setSourceTag(String sourceTag) {
this.sourceTag = sourceTag;
}
public String getSourceTag() {
return sourceTag;
}
protected Map<String, Long> quotas = new HashMap<String, Long>();
public M... |
if (!shouldProcess(curi)) {
return ProcessResult.PROCEED;
}
CrawledBytesHistotable stats = statisticsTracker.getSourceStats(curi.getSourceTag());
for (Entry<String, Long> quota: quotas.entrySet()) {
if (stats.get(quota.getKey()) >= quota.getValue()) {
... | 390 | 173 | 563 | <methods>public non-sealed void <init>() ,public void doCheckpoint(org.archive.checkpointing.Checkpoint) throws java.io.IOException,public void finishCheckpoint(org.archive.checkpointing.Checkpoint) ,public static java.lang.String flattenVia(org.archive.modules.CrawlURI) ,public java.lang.String getBeanName() ,public b... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/crawler/reporting/XmlCrawlSummaryReport.java | XmlCrawlSummaryReport | write | class XmlCrawlSummaryReport extends Report {
private String scheduledDate;
public void setScheduledDate(String scheduledDate) {
this.scheduledDate = scheduledDate;
}
public String getScheduledDate() {
return this.scheduledDate;
}
@Override
public void write(PrintWriter wr... |
Map<String,Object> info = new LinkedHashMap<String,Object>();
CrawlStatSnapshot snapshot = stats.getLastSnapshot();
info.put("crawlName",
((BaseWARCWriterProcessor) stats.appCtx.getBean("warcWriter")).getPrefix());
info.put("crawlJobShortName",
stats.... | 138 | 811 | 949 | <methods>public void <init>() ,public abstract java.lang.String getFilename() ,public boolean getShouldReportAtEndOfCrawl() ,public boolean getShouldReportDuringCrawl() ,public void setShouldReportAtEndOfCrawl(boolean) ,public void setShouldReportDuringCrawl(boolean) ,public abstract void write(java.io.PrintWriter, org... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/AMQPProducer.java | AMQPProducer | connect | class AMQPProducer {
static protected final Logger logger = Logger.getLogger(AMQPProducer.class.getName());
protected String amqpUri;
protected String exchange;
protected String routingKey;
public AMQPProducer(String amqpUri, String exchange, String routingKey) {
this.amqpUri = amqpUri;
... |
ConnectionFactory factory = new ConnectionFactory();
try {
factory.setUri(amqpUri);
connection = factory.newConnection();
boolean wasDown = serverLooksDown.getAndSet(false);
if (wasDown) {
logger.info(amqpUri + " is back up, connected suc... | 575 | 144 | 719 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/AMQPProducerProcessor.java | AMQPProducerProcessor | amqpProducer | class AMQPProducerProcessor extends Processor {
protected final Logger logger = Logger.getLogger(getClass().getName());
{
setAmqpUri("amqp://guest:guest@localhost:5672/%2f");
}
public String getAmqpUri() {
return (String) kp.get("amqpUri");
}
public void setAmqpUri(String uri) ... |
if (amqpProducer == null) {
amqpProducer = new AMQPProducer(getAmqpUri(), getExchange(), getRoutingKey());
}
return amqpProducer;
| 794 | 58 | 852 | <methods>public non-sealed void <init>() ,public void doCheckpoint(org.archive.checkpointing.Checkpoint) throws java.io.IOException,public void finishCheckpoint(org.archive.checkpointing.Checkpoint) ,public static java.lang.String flattenVia(org.archive.modules.CrawlURI) ,public java.lang.String getBeanName() ,public b... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/AMQPPublishProcessor.java | AMQPPublishProcessor | buildJsonMessage | class AMQPPublishProcessor extends AMQPProducerProcessor implements Serializable, ApplicationContextAware {
private static final long serialVersionUID = 2L;
public static final String A_SENT_TO_AMQP = "sentToAMQP"; // annotation
protected ApplicationContext appCtx;
public void setApplicationContext(A... |
JSONObject message = new JSONObject().put("url", curi.toString());
if (getClientId() != null) {
message.put("clientId", getClientId());
}
if (getExtraInfo() != null) {
for (String k: getExtraInfo().keySet()) {
message.put(k, getExtraInfo().get(k... | 929 | 293 | 1,222 | <methods>public non-sealed void <init>() ,public java.lang.String getAmqpUri() ,public java.lang.String getExchange() ,public java.lang.String getRoutingKey() ,public void setAmqpUri(java.lang.String) ,public void setExchange(java.lang.String) ,public void setRoutingKey(java.lang.String) ,public synchronized void stop(... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/AMQPUrlWaiter.java | AMQPUrlWaiter | checkAMQPUrlWait | class AMQPUrlWaiter implements ApplicationListener<ApplicationEvent> {
public AMQPUrlWaiter() {}
static protected final Logger logger = Logger.getLogger(AMQPUrlWaiter.class.getName());
protected int urlsPublished = 0;
protected int urlsReceived = 0;
protected CrawlController controller;
publ... |
if (controller.getState() == CrawlController.State.EMPTY && (urlsPublished == 0 || urlsReceived > 0)) {
logger.info("crawl controller state is empty and we have received " + urlsReceived +
" urls from AMQP, and published " + urlsPublished +
", stoppin... | 266 | 124 | 390 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/deciderules/DecideRuleSequenceWithAMQPFeed.java | DecideRuleSequenceWithAMQPFeed | buildJson | class DecideRuleSequenceWithAMQPFeed extends DecideRuleSequence {
private static final long serialVersionUID = 1L;
private static final Logger logger =
Logger.getLogger(DecideRuleSequenceWithAMQPFeed.class.getName());
protected String amqpUri = "amqp://guest:guest@localhost:5672/%2f";
publ... |
JSONObject jo = new JSONObject();
jo.put("timestamp", ArchiveUtils.getLog17Date(System.currentTimeMillis()));
jo.put("decisiveRuleNo", decisiveRuleNumber);
jo.put("decisiveRule", decisiveRule.getClass().getSimpleName());
jo.put("result", result.toString());
jo.put("ur... | 808 | 213 | 1,021 | <methods>public non-sealed void <init>() ,public java.lang.String getBeanName() ,public boolean getLogExtraInfo() ,public boolean getLogToFile() ,public org.archive.modules.SimpleFileLoggerProvider getLoggerModule() ,public List<org.archive.modules.deciderules.DecideRule> getRules() ,public org.archive.modules.net.Serv... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/deciderules/ExpressionDecideRule.java | ExpressionDecideRule | evaluate | class ExpressionDecideRule extends PredicatedDecideRule {
private static final long serialVersionUID = 1L;
private static final Logger logger =
Logger.getLogger(ExpressionDecideRule.class.getName());
{
setGroovyExpression("");
}
public void setGroovyExpression(String groovyExpr... |
HashMap<String, Object> binding = new HashMap<String, Object>();
binding.put("curi", curi);
return String.valueOf(true).equals(groovyTemplate().make(binding).toString());
| 362 | 58 | 420 | <methods>public void <init>() ,public org.archive.modules.deciderules.DecideResult getDecision() ,public org.archive.modules.deciderules.DecideResult onlyDecision(org.archive.modules.CrawlURI) ,public void setDecision(org.archive.modules.deciderules.DecideResult) <variables>private static final long serialVersionUID |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/extractor/ExtractorPDFContent.java | ExtractorPDFContent | innerExtract | class ExtractorPDFContent extends ContentExtractor {
@SuppressWarnings("unused")
private static final long serialVersionUID = 3L;
private static final Logger LOGGER =
Logger.getLogger(ExtractorPDFContent.class.getName());
public static final Pattern URLPattern = Pattern.compile(
"... |
ArrayList<String> uris = new ArrayList<String>();
File tempFile = null;
try {
tempFile = File.createTempFile("heritrix-ExtractorPDFContent", "tmp.pdf");
curi.getRecorder().copyContentBodyTo(tempFile);
try (PDDocument document = Loader.loadPDF(tempFile)) {
... | 928 | 878 | 1,806 | <methods>public non-sealed void <init>() <variables> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/extractor/ExtractorYoutubeChannelFormatStream.java | ExtractorYoutubeChannelFormatStream | extract | class ExtractorYoutubeChannelFormatStream extends
ExtractorYoutubeFormatStream {
private static Logger logger =
Logger.getLogger(ExtractorYoutubeChannelFormatStream.class.getName());
{
setExtractLimit(1);
}
@Override
protected boolean shouldProcess(CrawlURI uri... |
ReplayCharSequence cs;
try {
cs = uri.getRecorder().getContentReplayCharSequence();
} catch (IOException e) {
uri.getNonFatalFailures().add(e);
logger.log(Level.WARNING, "Failed get of replay char sequence in "
+ Thread.currentThread().get... | 193 | 401 | 594 | <methods>public non-sealed void <init>() ,public java.lang.Integer getExtractLimit() ,public List<java.lang.String> getItagPriority() ,public void setExtractLimit(java.lang.Integer) ,public void setItagPriority(List<java.lang.String>) <variables>private static final List<java.lang.String> DEFAULT_ITAG_PRIORITY,private ... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/extractor/KnowledgableExtractorJS.java | CustomizedCrawlURIFacade | considerStrings | class CustomizedCrawlURIFacade extends CrawlURI {
private static final long serialVersionUID = 1l;
protected CrawlURI wrapped;
protected UURI baseURI;
public CustomizedCrawlURIFacade(CrawlURI wrapped, UURI baseURI) {
super(wrapped.getUURI(), wrapped.getPathFromSeed(), wrapp... |
CrawlURI baseUri = curi;
Matcher m = TextUtils.getMatcher("jQuery\\.extend\\(Drupal\\.settings,[^'\"]*['\"]basePath['\"]:[^'\"]*['\"]([^'\"]+)['\"]", cs);
if (m.find()) {
String basePath = m.group(1);
try {
basePath = StringEscapeUtils.unescapeJavaScrip... | 396 | 552 | 948 | <methods>public non-sealed void <init>() ,public long considerStrings(org.archive.modules.extractor.Extractor, org.archive.modules.CrawlURI, java.lang.CharSequence) ,public long considerStrings(org.archive.modules.extractor.Extractor, org.archive.modules.CrawlURI, java.lang.CharSequence, boolean) <variables>protected s... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/postprocessor/AMQPCrawlLogFeed.java | AMQPCrawlLogFeed | stop | class AMQPCrawlLogFeed extends AMQPProducerProcessor implements Lifecycle {
protected Frontier frontier;
public Frontier getFrontier() {
return this.frontier;
}
/** Autowired frontier, needed to determine when a url is finished. */
@Autowired
public void setFrontier(Frontier frontier) {... |
if (!isRunning) {
return;
}
if (dumpPendingAtClose) {
if (frontier instanceof BdbFrontier) {
Closure closure = new Closure() {
public void execute(Object curi) {
try {
innerProcessR... | 705 | 243 | 948 | <methods>public non-sealed void <init>() ,public java.lang.String getAmqpUri() ,public java.lang.String getExchange() ,public java.lang.String getRoutingKey() ,public void setAmqpUri(java.lang.String) ,public void setExchange(java.lang.String) ,public void setRoutingKey(java.lang.String) ,public synchronized void stop(... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/postprocessor/CrawlLogJsonBuilder.java | CrawlLogJsonBuilder | buildJson | class CrawlLogJsonBuilder {
protected static Object checkForNull(Object o) {
return o != null ? o : JSONObject.NULL;
}
public static JSONObject buildJson(CrawlURI curi, Map<String,String> extraFields, ServerCache serverCache) {<FILL_FUNCTION_BODY>}
} |
JSONObject jo = new JSONObject();
jo.put("timestamp", ArchiveUtils.getLog17Date(System.currentTimeMillis()));
for (Entry<String, String> entry: extraFields.entrySet()) {
jo.put(entry.getKey(), entry.getValue());
}
jo.put("content_length", curi.isHttpTransaction() ... | 88 | 712 | 800 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/postprocessor/KafkaCrawlLogFeed.java | KafkaCrawlLogFeed | kafkaProducer | class KafkaCrawlLogFeed extends Processor implements Lifecycle {
protected static final Logger logger = Logger.getLogger(KafkaCrawlLogFeed.class.getName());
protected Frontier frontier;
public Frontier getFrontier() {
return this.frontier;
}
/** Autowired frontier, needed to determine when... |
if (kafkaProducer == null) {
synchronized (this) {
if (kafkaProducer == null) {
final Properties props = new Properties();
props.put("bootstrap.servers", getBrokerList());
props.put("acks", "1");
props.p... | 1,456 | 491 | 1,947 | <methods>public non-sealed void <init>() ,public void doCheckpoint(org.archive.checkpointing.Checkpoint) throws java.io.IOException,public void finishCheckpoint(org.archive.checkpointing.Checkpoint) ,public static java.lang.String flattenVia(org.archive.modules.CrawlURI) ,public java.lang.String getBeanName() ,public b... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/postprocessor/WARCLimitEnforcer.java | WARCLimitEnforcer | innerProcess | class WARCLimitEnforcer extends Processor {
private final static Logger log =
Logger.getLogger(WARCLimitEnforcer.class.getName());
protected Map<String, Map<String, Long>> limits = new HashMap<String, Map<String, Long>>();
/**
* Should match structure of {@link BaseWARCWriterProcessor#get... |
for (String j: limits.keySet()) {
for (String k: limits.get(j).keySet()) {
Long limit = limits.get(j).get(k);
AtomicLong value = null;
if(getWarcWriters() !=null && getWarcWriters().size()>0) {
value = new AtomicLong(0);
... | 511 | 339 | 850 | <methods>public non-sealed void <init>() ,public void doCheckpoint(org.archive.checkpointing.Checkpoint) throws java.io.IOException,public void finishCheckpoint(org.archive.checkpointing.Checkpoint) ,public static java.lang.String flattenVia(org.archive.modules.CrawlURI) ,public java.lang.String getBeanName() ,public b... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/recrawl/FetchHistoryHelper.java | FetchHistoryHelper | getFetchHistory | class FetchHistoryHelper {
private static final Log logger = LogFactory.getLog(FetchHistoryHelper.class);
/**
* key for storing timestamp in crawl history map.
*/
public static final String A_TIMESTAMP = ".ts";
/**
* returns a Map to store recrawl data, positioned properly in CrawlURI's
* fetch his... |
Map<String, Object>[] history = uri.getFetchHistory();
if (history == null) {
// there's no history records at all.
// FetchHistoryProcessor assumes history is HashMap[], not Map[].
history = new HashMap[historyLength];
uri.setFetchHistory(history);
}
for (int i = 0; i < history... | 532 | 328 | 860 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/recrawl/TroughContentDigestHistory.java | TroughContentDigestHistory | onApplicationEvent | class TroughContentDigestHistory extends AbstractContentDigestHistory implements HasKeyedProperties, ApplicationListener<CrawlStateEvent> {
private static final Logger logger = Logger.getLogger(TroughContentDigestHistory.class.getName());
protected KeyedProperties kp = new KeyedProperties();
public KeyedPr... |
switch(event.getState()) {
case PREPARING:
try {
// initializes TroughClient and starts promoter thread as a side effect
troughClient().registerSchema(SCHEMA_ID, SCHEMA_SQL);
} catch (Exception e) {
// can happen. hopefully someone... | 1,225 | 296 | 1,521 | <methods>public non-sealed void <init>() ,public abstract void load(org.archive.modules.CrawlURI) ,public abstract void store(org.archive.modules.CrawlURI) <variables> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/recrawl/hbase/HBase.java | HBase | configuration | class HBase implements Lifecycle {
private static final Logger logger =
Logger.getLogger(HBase.class.getName());
protected Configuration conf = null;
private Map<String,String> properties;
public Map<String,String> getProperties() {
return properties;
}
public void setPr... |
if (conf == null) {
conf = HBaseConfiguration.create();
}
return conf;
| 582 | 31 | 613 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/recrawl/hbase/HBasePersistLoadProcessor.java | HBasePersistLoadProcessor | shouldProcess | class HBasePersistLoadProcessor extends HBasePersistProcessor {
private static final Logger logger =
Logger.getLogger(HBasePersistLoadProcessor.class.getName());
@Override
protected ProcessResult innerProcessResult(CrawlURI uri) throws InterruptedException {
byte[] key = rowKeyForURI(ur... |
// TODO: we want deduplicate robots.txt, too.
//if (uri.isPrerequisite()) return false;
String scheme = uri.getUURI().getScheme();
if (!(scheme.equals("http") || scheme.equals("https") || scheme.equals("ftp") || scheme.equals("sftp"))) {
return false;
}
retu... | 405 | 101 | 506 | <methods>public non-sealed void <init>() ,public org.archive.modules.recrawl.hbase.RecrawlDataSchema getSchema() ,public void setSchema(org.archive.modules.recrawl.hbase.RecrawlDataSchema) ,public void setTable(org.archive.modules.recrawl.hbase.HBaseTableBean) <variables>protected org.archive.modules.recrawl.hbase.Recr... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/recrawl/hbase/HBasePersistStoreProcessor.java | HBasePersistStoreProcessor | innerProcess | class HBasePersistStoreProcessor extends HBasePersistProcessor implements FetchStatusCodes, RecrawlAttributeConstants {
private static final Logger logger = Logger.getLogger(HBasePersistStoreProcessor.class.getName());
protected boolean addColumnFamily = false;
public boolean getAddColumnFamily() {
... |
Put p = schema.createPut(uri);
int tryCount = 0;
do {
tryCount++;
try {
table.put(p);
return;
} catch (RetriesExhaustedWithDetailsException e) {
if (e.getCause(0) instanceof NoSuchColumnFamilyException && getAdd... | 590 | 416 | 1,006 | <methods>public non-sealed void <init>() ,public org.archive.modules.recrawl.hbase.RecrawlDataSchema getSchema() ,public void setSchema(org.archive.modules.recrawl.hbase.RecrawlDataSchema) ,public void setTable(org.archive.modules.recrawl.hbase.HBaseTableBean) <variables>protected org.archive.modules.recrawl.hbase.Recr... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/recrawl/hbase/HBaseTable.java | HBaseTable | start | class HBaseTable extends HBaseTableBean {
static final Logger logger =
Logger.getLogger(HBaseTable.class.getName());
protected boolean create = false;
protected HConnection hconn = null;
protected ThreadLocal<HTableInterface> htable = new ThreadLocal<HTableInterface>();
public boolean... |
if (getCreate()) {
int attempt = 1;
while (true) {
try {
HBaseAdmin admin = hbase.admin();
if (!admin.tableExists(htableName)) {
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(htableName));
... | 653 | 245 | 898 | <methods>public void <init>() ,public abstract Result get(Get) throws java.io.IOException,public org.archive.modules.recrawl.hbase.HBase getHbase() ,public abstract HTableDescriptor getHtableDescriptor() throws java.io.IOException,public java.lang.String getHtableName() ,public java.lang.String getName() ,public boolea... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/recrawl/hbase/MultiColumnRecrawlDataSchema.java | MultiColumnRecrawlDataSchema | load | class MultiColumnRecrawlDataSchema extends RecrawlDataSchemaBase implements RecrawlDataSchema, RecrawlAttributeConstants {
static final Logger logger = Logger.getLogger(MultiColumnRecrawlDataSchema.class.getName());
public static final byte[] COLUMN_STATUS = Bytes.toBytes("s");
public static final byte[] C... |
// check for "do-not-crawl" flag - any non-empty data tells not to crawl this
// URL.
byte[] nocrawl = result.getValue(columnFamily, COLUMN_NOCRAWL);
if (nocrawl != null && nocrawl.length > 0) {
// fetch status set to S_DEEMED_CHAFF, because this do-not-crawl flag
... | 881 | 580 | 1,461 | <methods>public void <init>() ,public java.lang.String getColumnFamily() ,public int getHistoryLength() ,public org.archive.modules.canonicalize.CanonicalizationRule getKeyRule() ,public boolean isUseCanonicalString() ,public byte[] rowKeyForURI(org.archive.modules.CrawlURI) ,public void setColumnFamily(java.lang.Strin... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/recrawl/hbase/RecrawlDataSchemaBase.java | RecrawlDataSchemaBase | rowKeyForURI | class RecrawlDataSchemaBase implements RecrawlDataSchema {
private static final Logger logger = Logger.getLogger(RecrawlDataSchemaBase.class.getName());
/**
* default value for {@link #columnFamily}.
*/
public static final byte[] DEFAULT_COLUMN_FAMILY = Bytes.toBytes("f");
protected byte[] co... |
if (useCanonicalString) {
// TODO: use keyRule if specified.
return Bytes.toBytes(PersistProcessor.persistKeyFor(curi));
} else {
return Bytes.toBytes(curi.toString());
}
| 915 | 67 | 982 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/modules/recrawl/hbase/SingleColumnJsonRecrawlDataSchema.java | SingleColumnJsonRecrawlDataSchema | load | class SingleColumnJsonRecrawlDataSchema extends RecrawlDataSchemaBase
implements RecrawlDataSchema {
static final Logger logger = Logger.getLogger(SingleColumnJsonRecrawlDataSchema.class.getName());
public static byte[] DEFAULT_COLUMN = Bytes.toBytes("r");
// JSON property names for re-crawl data properti... |
// check for "do-not-crawl" flag - any non-empty data tells not to crawl this
// URL.
byte[] nocrawl = result.getValue(columnFamily, COLUMN_NOCRAWL);
if (nocrawl != null && nocrawl.length > 0) {
// fetch status set to S_DEEMED_CHAFF, because this do-not-crawl flag
... | 1,008 | 635 | 1,643 | <methods>public void <init>() ,public java.lang.String getColumnFamily() ,public int getHistoryLength() ,public org.archive.modules.canonicalize.CanonicalizationRule getKeyRule() ,public boolean isUseCanonicalString() ,public byte[] rowKeyForURI(org.archive.modules.CrawlURI) ,public void setColumnFamily(java.lang.Strin... |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/net/chrome/ChromeClient.java | ChromeClient | callInSession | class ChromeClient implements Closeable {
private static final Logger logger = Logger.getLogger(ChromeClient.class.getName());
private static final int RPC_TIMEOUT_SECONDS = 60;
private final DevtoolsSocket devtoolsSocket;
private final AtomicLong nextMessageId = new AtomicLong(0);
private final Ma... |
JSONObject params = new JSONObject();
if (keysAndValues.length % 2 != 0) {
throw new IllegalArgumentException("keysAndValues.length must even");
}
for (int i = 0; i < keysAndValues.length; i += 2) {
params.put((String)keysAndValues[i], keysAndValues[i + 1]);
... | 1,174 | 108 | 1,282 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/net/chrome/ChromeProcess.java | ChromeProcess | readDevtoolsUriFromStderr | class ChromeProcess implements Closeable {
private static final Logger logger = Logger.getLogger(ExtractorChrome.class.getName());
private static final String[] DEFAULT_EXECUTABLES = {"chromium-browser", "chromium", "google-chrome",
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"... |
BufferedReader stderr = new BufferedReader(new InputStreamReader(process.getErrorStream(), ISO_8859_1));
CompletableFuture<String> future = new CompletableFuture<>();
Thread thread = new Thread(() -> {
String listenMsg = "DevTools listening on ";
try {
wh... | 1,376 | 323 | 1,699 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/net/chrome/ChromeRequest.java | ChromeRequest | getResponseBody | class ChromeRequest {
private final ChromeWindow window;
private final String id;
private JSONObject requestJson;
private JSONObject rawRequestHeaders;
private JSONObject responseJson;
private JSONObject rawResponseHeaders;
private String responseHeadersText;
private final long beginTime... |
JSONObject reply = window.call("Network.getResponseBody", "requestId", id);
byte[] body;
if (reply.getBoolean("base64Encoded")) {
body = Base64.getDecoder().decode(reply.getString("body"));
} else {
body = reply.getString("body").getBytes(StandardCharsets.UTF_8);... | 1,029 | 102 | 1,131 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/net/chrome/ChromeWindow.java | ChromeWindow | handleEvent | class ChromeWindow implements Closeable {
private static final Logger logger = Logger.getLogger(ChromeWindow.class.getName());
private final ChromeClient client;
private final String targetId;
private final String sessionId;
private boolean closed;
private CompletableFuture<Void> loadEventFutur... |
if (closed) return;
// Run event handlers on a different thread so we don't block the websocket receiving thread.
// That would cause a deadlock if an event handler itself made an RPC call as the response could
// never be processed.
// We use a single thread per window though a... | 1,846 | 143 | 1,989 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/contrib/src/main/java/org/archive/net/chrome/InterceptedRequest.java | InterceptedRequest | fulfill | class InterceptedRequest {
private final String id;
private final ChromeRequest request;
private final ChromeWindow window;
private boolean handled;
public InterceptedRequest(ChromeWindow window, String id, ChromeRequest request) {
this.window = window;
this.id = id;
this.re... |
setHandled();
JSONArray headerArray = new JSONArray();
for (Map.Entry<String,String> entry : headers) {
JSONObject object = new JSONObject();
object.put("name", entry.getKey());
object.put("value", entry.getValue());
headerArray.put(object);
... | 244 | 164 | 408 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/framework/BeanLookupBindings.java | BeanLookupBindings | get | class BeanLookupBindings extends SimpleBindings {
private final ApplicationContext appCtx;
public BeanLookupBindings(ApplicationContext appCtx) {
if (appCtx == null) throw new NullPointerException("appCtx");
this.appCtx = appCtx;
}
public BeanLookupBindings(ApplicationContext appCtx, ... |
Object ret = super.get(key);
if (ret == null && key instanceof String) {
try {
ret = appCtx.getBean((String) key);
} catch (BeansException e) {}
}
return ret;
| 236 | 65 | 301 | <methods>public void <init>() ,public void <init>(Map<java.lang.String,java.lang.Object>) ,public void clear() ,public boolean containsKey(java.lang.Object) ,public boolean containsValue(java.lang.Object) ,public Set<Entry<java.lang.String,java.lang.Object>> entrySet() ,public java.lang.Object get(java.lang.Object) ,pu... |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/framework/CheckpointValidator.java | CheckpointValidator | validate | class CheckpointValidator implements Validator {
@Override
public boolean supports(Class<?> cls) {
return Checkpoint.class.isAssignableFrom(cls);
}
@Override
public void validate(Object target, Errors errors) {<FILL_FUNCTION_BODY>}
} |
Checkpoint cp = ((CheckpointService)target).getRecoveryCheckpoint();
if(cp==null) {
return;
}
if(!Checkpoint.hasValidStamp(cp.getCheckpointDir().getFile())) {
errors.rejectValue(
"recoveryCheckpoint.checkpointDir",
null,
... | 81 | 116 | 197 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/framework/CrawlJob.java | JobLogFormatter | isLaunchable | class JobLogFormatter extends Formatter {
@Override
public String format(LogRecord record) {
StringBuilder sb = new StringBuilder();
sb
.append(new DateTime(record.getMillis()))
.append(" ")
.append(record.getLevel())
... |
if (!hasApplicationContext()) {
// ok to try launch if not yet built
return true;
}
if (!hasValidApplicationContext()) {
// never launch if specifically invalid
return false;
}
// launchable if cc not yet instantiated or ... | 1,167 | 114 | 1,281 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/framework/CrawlLimitEnforcer.java | CrawlLimitEnforcer | checkForLimitsExceeded | class CrawlLimitEnforcer implements ApplicationListener<ApplicationEvent> {
/**
* Maximum number of bytes to download. Once this number is exceeded
* the crawler will stop. A value of zero means no upper limit.
*/
protected long maxBytesDownload = 0L;
public long getMaxBytesDownload(... |
if (maxBytesDownload > 0 && snapshot.bytesProcessed >= maxBytesDownload) {
controller.requestCrawlStop(CrawlStatus.FINISHED_DATA_LIMIT);
} else if (maxNovelBytes > 0 && snapshot.novelBytes >= maxNovelBytes) {
controller.requestCrawlStop(CrawlStatus.FINISHED_DATA_LIMIT);
... | 1,161 | 415 | 1,576 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/framework/Scoper.java | Scoper | start | class Scoper extends Processor implements Lifecycle {
protected DecideRule scope;
public DecideRule getScope() {
return this.scope;
}
@Autowired
public void setScope(DecideRule scope) {
this.scope = scope;
}
protected Logger fileLogger = null;
{
setLogT... |
if(isRunning) {
return;
}
if (getLogToFile() && fileLogger == null) {
fileLogger = loggerModule.setupSimpleLog(getBeanName());
}
isRunning = true;
| 672 | 62 | 734 | <methods>public non-sealed void <init>() ,public void doCheckpoint(org.archive.checkpointing.Checkpoint) throws java.io.IOException,public void finishCheckpoint(org.archive.checkpointing.Checkpoint) ,public static java.lang.String flattenVia(org.archive.modules.CrawlURI) ,public java.lang.String getBeanName() ,public b... |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/AntiCalendarCostAssignmentPolicy.java | AntiCalendarCostAssignmentPolicy | costOf | class AntiCalendarCostAssignmentPolicy extends UnitCostAssignmentPolicy {
private static final long serialVersionUID = 3L;
public static String CALENDARISH =
"(?i)(calendar)|(year)|(month)|(day)|(date)|(viewcal)" +
"|(\\D19\\d\\d\\D)|(\\D20\\d\\d\\D)|(event)|(yr=)" +
"|(cal... |
int cost = super.costOf(curi);
Matcher m = TextUtils.getMatcher(CALENDARISH, curi.toString());
if (m.find()) {
cost++;
// TODO: consider if multiple occurrences should cost more
}
TextUtils.recycleMatcher(m);
return cost;
| 211 | 88 | 299 | <methods>public non-sealed void <init>() ,public int costOf(org.archive.modules.CrawlURI) <variables>private static final long serialVersionUID |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/AssignmentLevelSurtQueueAssignmentPolicy.java | AssignmentLevelSurtQueueAssignmentPolicy | getClassKey | class AssignmentLevelSurtQueueAssignmentPolicy extends
SurtAuthorityQueueAssignmentPolicy {
private static final long serialVersionUID = -1533545293624791702L;
@Override
public String getClassKey(CrawlURI curi) {<FILL_FUNCTION_BODY>}
} |
if(getDeferToPrevious() && !StringUtils.isEmpty(curi.getClassKey())) {
return curi.getClassKey();
}
UURI basis = curi.getPolicyBasisUURI();
String candidate = super.getClassKey(curi);
candidate = PublicSuffixes.reduceSurtToAssignmentLevel(candidate);
if(!StringUtils.isEmpty(getForceQueueAss... | 91 | 252 | 343 | <methods>public non-sealed void <init>() <variables>private static final long serialVersionUID |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/BdbWorkQueue.java | BdbWorkQueue | insertItem | class BdbWorkQueue extends WorkQueue
implements Serializable {
private static final long serialVersionUID = 1L;
private static Logger LOGGER =
Logger.getLogger(BdbWorkQueue.class.getName());
/**
* All items in this queue have this same 'origin'
* prefix to their keys.
*/
private... |
try {
final BdbMultipleWorkQueues queues = ((BdbFrontier) frontier)
.getWorkQueues();
queues.put(curi, overwriteIfPresent);
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Inserted into " + getPrefixClassKey(this.origin) +
... | 1,293 | 144 | 1,437 | <methods>public void <init>(java.lang.String) ,public final int compareTo(java.util.concurrent.Delayed) ,public synchronized void considerActive() ,public synchronized long deleteMatching(org.archive.crawler.frontier.WorkQueueFrontier, java.lang.String) ,public void expend(int) ,public java.lang.String getClassKey() ,p... |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/BucketQueueAssignmentPolicy.java | BucketQueueAssignmentPolicy | getClassKey | class BucketQueueAssignmentPolicy extends QueueAssignmentPolicy {
private static final long serialVersionUID = 3L;
private static final int DEFAULT_NOIP_BITMASK = 1023;
private static final int DEFAULT_QUEUES_HOSTS_MODULO = 1021;
protected ServerCache serverCache;
public ServerCache getServerCach... |
CrawlHost host;
host = serverCache.getHostFor(curi.getUURI());
if(host == null) {
return "NO-HOST";
} else if(host.getIP() == null) {
return "NO-IP-".concat(Long.toString(Math.abs((long) host
.getHostName().hashCode()) & DEFAULT_NOIP_... | 211 | 151 | 362 | <methods>public non-sealed void <init>() ,public abstract java.lang.String getClassKey(org.archive.modules.CrawlURI) ,public java.lang.String getForceQueueAssignment() ,public org.archive.spring.KeyedProperties getKeyedProperties() ,public int maximumNumberOfKeys() ,public void setForceQueueAssignment(java.lang.String)... |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/DelayedWorkQueue.java | DelayedWorkQueue | compareTo | class DelayedWorkQueue implements Delayed, Serializable {
private static final long serialVersionUID = 1L;
public String classKey;
public long wakeTime;
/**
* Reference to the WorkQueue, perhaps saving a deserialization
* from allQueues.
*/
protected transient WorkQueue workQueu... |
if (this == obj) {
return 0; // for exact identity only
}
DelayedWorkQueue other = (DelayedWorkQueue) obj;
if (wakeTime > other.getWakeTime()) {
return 1;
}
if (wakeTime < other.getWakeTime()) {
return -1;
}
// at this ... | 386 | 135 | 521 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/HostnameQueueAssignmentPolicy.java | HostnameQueueAssignmentPolicy | getCoreKey | class HostnameQueueAssignmentPolicy
extends URIAuthorityBasedQueueAssignmentPolicy {
private static final long serialVersionUID = 3L;
@Override
protected String getCoreKey(UURI basis) {<FILL_FUNCTION_BODY>}
} |
String scheme = basis.getScheme();
String candidate = null;
try {
candidate = basis.getAuthorityMinusUserinfo();
} catch (URIException ue) {}// let next line handle
if(StringUtils.isEmpty(candidate)) {
return null;
}
if (UURIFact... | 68 | 191 | 259 | <methods>public non-sealed void <init>() ,public java.lang.String getClassKey(org.archive.modules.CrawlURI) ,public boolean getDeferToPrevious() ,public int getParallelQueues() ,public boolean getParallelQueuesRandomAssignment() ,public void setDeferToPrevious(boolean) ,public void setParallelQueues(int) ,public void s... |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/IPQueueAssignmentPolicy.java | IPQueueAssignmentPolicy | getClassKey | class IPQueueAssignmentPolicy
extends HostnameQueueAssignmentPolicy {
private static final long serialVersionUID = 3L;
protected ServerCache serverCache;
public ServerCache getServerCache() {
return this.serverCache;
}
@Autowired
public void setServerCache(ServerCache serverCache) {... |
CrawlHost host = serverCache.getHostFor(cauri.getUURI());
if (host == null || host.getIP() == null) {
// if no server or no IP, use superclass implementation
return super.getClassKey(cauri);
}
// use dotted-decimal IP address
return host.getIP().getHostAd... | 125 | 93 | 218 | <methods>public non-sealed void <init>() <variables>private static final long serialVersionUID |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/RecyclingSerialBinding.java | RecyclingSerialBinding | objectToEntry | class RecyclingSerialBinding<K> extends SerialBinding<K> {
/**
* Thread-local cache of reusable FastOutputStream
*/
protected ThreadLocal<FastOutputStream> fastOutputStreamHolder
= new ThreadLocal<FastOutputStream>();
private ClassCatalog classCatalog;
private Class<K> baseClass;
... |
if (baseClass != null && !baseClass.isInstance(object)) {
throw new IllegalArgumentException(
"Data object class (" + object.getClass() +
") not an instance of binding's base class (" +
baseClass + ')');
}
Fast... | 421 | 180 | 601 | <no_super_class> |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/SurtAuthorityQueueAssignmentPolicy.java | SurtAuthorityQueueAssignmentPolicy | getSurtAuthority | class SurtAuthorityQueueAssignmentPolicy
extends URIAuthorityBasedQueueAssignmentPolicy {
private static final long serialVersionUID = 3L;
@Override
protected String getCoreKey(UURI basis) {
String candidate = getSurtAuthority(basis.getSurtForm());
return candidate.replace(':','#');
... |
int indexOfOpen = surt.indexOf("://(");
int indexOfClose = surt.indexOf(")");
if (indexOfOpen == -1 || indexOfClose == -1
|| ((indexOfOpen + 4) >= indexOfClose)) {
return DEFAULT_CLASS_KEY;
}
return surt.substring(indexOfOpen + 4, indexOfClose);
| 118 | 93 | 211 | <methods>public non-sealed void <init>() ,public java.lang.String getClassKey(org.archive.modules.CrawlURI) ,public boolean getDeferToPrevious() ,public int getParallelQueues() ,public boolean getParallelQueuesRandomAssignment() ,public void setDeferToPrevious(boolean) ,public void setParallelQueues(int) ,public void s... |
internetarchive_heritrix3 | heritrix3/engine/src/main/java/org/archive/crawler/frontier/URIAuthorityBasedQueueAssignmentPolicy.java | URIAuthorityBasedQueueAssignmentPolicy | getSubqueue | class URIAuthorityBasedQueueAssignmentPolicy
extends
QueueAssignmentPolicy
implements
HasKeyedProperties {
private static final long serialVersionUID = 3L;
//for when neat class-key fails us
protected static String DEFAULT_CLASS_KEY = "default...";
protected LongToIntConsistentHash c... |
String basis = bucketBasis(basisUuri);
if(StringUtils.isEmpty(basis)) {
return 0;
}
return conhash.bucketFor(basis, parallelQueues);
| 1,128 | 63 | 1,191 | <methods>public non-sealed void <init>() ,public abstract java.lang.String getClassKey(org.archive.modules.CrawlURI) ,public java.lang.String getForceQueueAssignment() ,public org.archive.spring.KeyedProperties getKeyedProperties() ,public int maximumNumberOfKeys() ,public void setForceQueueAssignment(java.lang.String)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.