当前位置: 首页>>代码示例>>Java>>正文


Java ObjectParser类代码示例

本文整理汇总了Java中it.unimi.dsi.lang.ObjectParser的典型用法代码示例。如果您正苦于以下问题:Java ObjectParser类的具体用法?Java ObjectParser怎么用?Java ObjectParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ObjectParser类属于it.unimi.dsi.lang包,在下文中一共展示了ObjectParser类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import it.unimi.dsi.lang.ObjectParser; //导入依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException, IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
	SimpleJSAP jsap = new SimpleJSAP( SequentialHyperBall.class.getName(), "Prints an approximation of the neighbourhood function.",
		new Parameter[] {
			new FlaggedOption( "log2m", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'l', "log2m", "The logarithm of the number of registers." ),
			new FlaggedOption( "upperBound", JSAP.LONGSIZE_PARSER, Long.toString( Long.MAX_VALUE ), JSAP.NOT_REQUIRED, 'u', "upper-bound", "An upper bound to the number of iteration (default: the graph size)." ),
			new FlaggedOption( "threshold", JSAP.DOUBLE_PARSER, Double.toString( 1E-3 ), JSAP.NOT_REQUIRED, 't', "threshould", "A threshould that will be used to stop the computation by absolute or relative increment." ),
			new Switch( "spec", 's', "spec", "The source is not a basename but rather a specification of the form <ImmutableGraphImplementation>(arg,arg,...)." ),
			new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
		}		
	);

	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	final boolean spec = jsapResult.getBoolean( "spec" );
	final String basename = jsapResult.getString( "basename" );
	final ProgressLogger pl = new ProgressLogger( LOGGER );
	final int log2m = jsapResult.getInt( "log2m" );
	
	final ImmutableGraph graph = spec ? ObjectParser.fromSpec( basename, ImmutableGraph.class, GraphClassParser.PACKAGE ) : ImmutableGraph.loadOffline( basename );
	
	SequentialHyperBall shb = new SequentialHyperBall( graph, log2m, pl, Util.randomSeed() );
	TextIO.storeDoubles( shb.approximateNeighbourhoodFunction( jsapResult.getLong( "upperBound" ), jsapResult.getDouble( "threshold" ) ), System.out );
	shb.close();
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:26,代码来源:SequentialHyperBall.java

示例2: main

import it.unimi.dsi.lang.ObjectParser; //导入依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException, IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
	SimpleJSAP jsap = new SimpleJSAP( ExactNeighbourhoodFunction.class.getName(), "Prints the neighbourhood function.",
		new Parameter[] {
			new Switch( "spec", 's', "spec", "The source is not a basename but rather a specification of the form <ImmutableGraphImplementation>(arg,arg,...)." ),
			new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
		}		
	);

	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	final boolean spec = jsapResult.getBoolean( "spec" );
	final String basename = jsapResult.getString( "basename" );
	final ProgressLogger pl = new ProgressLogger( LOGGER );
	
	final ImmutableGraph graph = spec ? ObjectParser.fromSpec( basename, ImmutableGraph.class, GraphClassParser.PACKAGE ) : ImmutableGraph.loadOffline( basename );
	
	final ExactNeighbourhoodFunction neighbourhoodFunction = new ExactNeighbourhoodFunction( graph, pl );
	pl.start( "Computing..." );
	TextIO.storeDoubles( neighbourhoodFunction.neighbourhoodFunction(), System.out );
	pl.done();
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:23,代码来源:ExactNeighbourhoodFunction.java

示例3: main

import it.unimi.dsi.lang.ObjectParser; //导入依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException {
	SimpleJSAP jsap = new SimpleJSAP( StronglyConnectedComponents.class.getName(), 
			"Computes the strongly connected components (and optionally the buckets) of a graph of given basename. The resulting data is saved " +
			"in files stemmed from the given basename with extension .scc (a list of binary integers specifying the " +
			"component of each node), .sccsizes (a list of binary integer specifying the size of each component) and .buckets " +
			" (a serialised LongArrayBigVector specifying buckets). Please use suitable JVM options to set a large stack size.",
			new Parameter[] {
		new Switch( "sizes", 's', "sizes", "Compute component sizes." ),
		new Switch( "renumber", 'r', "renumber", "Renumber components in decreasing-size order." ),
		new Switch( "buckets", 'b', "buckets", "Compute buckets (nodes belonging to a bucket component, i.e., a terminal nondangling component)." ),
		new FlaggedOption( "filter", new ObjectParser( LabelledArcFilter.class, GraphClassParser.PACKAGE ), JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'f', "filter", "A filter for labelled arcs; requires the provided graph to be arc labelled." ),
		new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
		new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
		new UnflaggedOption( "resultsBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The basename of the resulting files." ),
	}		
	);

	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );

	final String basename = jsapResult.getString( "basename" );
	final String resultsBasename = jsapResult.getString( "resultsBasename", basename );
	final LabelledArcFilter filter = (LabelledArcFilter)jsapResult.getObject( "filter" );
	ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );

	final StronglyConnectedComponents components = 
		filter != null ? StronglyConnectedComponents.compute( ArcLabelledImmutableGraph.load( basename ), filter, jsapResult.getBoolean( "buckets" ), pl )
				: StronglyConnectedComponents.compute( ImmutableGraph.load( basename ), jsapResult.getBoolean( "buckets" ), pl );

	if ( jsapResult.getBoolean( "sizes" ) || jsapResult.getBoolean( "renumber" ) ) {
		final int size[] = components.computeSizes();
		if ( jsapResult.getBoolean( "renumber" ) ) components.sortBySize( size );
		if ( jsapResult.getBoolean( "sizes" ) ) BinIO.storeInts( size, resultsBasename + ".sccsizes" );
	}
	BinIO.storeInts(  components.component, resultsBasename + ".scc" );
	if ( components.buckets != null ) BinIO.storeObject( components.buckets, resultsBasename + ".buckets" );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:38,代码来源:StronglyConnectedComponents.java

示例4: main

import it.unimi.dsi.lang.ObjectParser; //导入依赖的package包/类
public static void main( String args[] ) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException, JSAPException, ClassNotFoundException, InstantiationException  {
	String sourceBasename, destBasename;
	Class<?> graphClass;

	SimpleJSAP jsap = new SimpleJSAP( ASCIIGraph.class.getName(), "Reads a graph with a given basename, or a given spec, and writes it out in ASCII format with another basename",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph" ),
					new FlaggedOption( "shift", JSAP.INTEGER_PARSER, null, JSAP.NOT_REQUIRED, 'S', "shift", "A shift that will be added to each node index." ),
					new Switch( "spec", 's', "spec", "The source is not a basename but rather a spec of the form ImmutableGraphClass(arg,arg,...)." ),
					new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
					new UnflaggedOption( "sourceBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source graph, or a source spec if --spec was given; it is immaterial when --once is specified." ),
					new UnflaggedOption( "destBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the destination graph" ),
				}		
			);
			
	JSAPResult jsapResult = jsap.parse( args );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	
	graphClass = jsapResult.getClass( "graphClass" );
	sourceBasename = jsapResult.getString( "sourceBasename" );
	destBasename = jsapResult.getString( "destBasename" );
	final boolean spec = jsapResult.getBoolean( "spec" );

	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );

	if ( graphClass != null && spec ) {
		System.err.println( "Options --graphClass and --spec are incompatible" );
		return;
	}

	ImmutableGraph graph;
	if ( !spec )
		graph = graphClass != null 
		? (ImmutableGraph)graphClass.getMethod( "loadSequential", CharSequence.class, ProgressLogger.class ).invoke( null, sourceBasename, pl )
		: ImmutableGraph.loadSequential( sourceBasename, pl );
	else
		graph = ObjectParser.fromSpec( sourceBasename, ImmutableGraph.class, GraphClassParser.PACKAGE );
	if ( jsapResult.userSpecified( "shift" ) ) ASCIIGraph.store( graph, jsapResult.getInt( "shift" ), destBasename );
	else ASCIIGraph.store( graph, destBasename );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:41,代码来源:ASCIIGraph.java

示例5: main

import it.unimi.dsi.lang.ObjectParser; //导入依赖的package包/类
public static void main(final String[] arg) throws Exception {
	final SimpleJSAP jsap = new SimpleJSAP(ParallelFilteredProcessorRunner.class.getName(), "Processes a store.",
			new Parameter[] {
			new FlaggedOption("filter", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'f', "filter", "A WarcRecord filter that recods must pass in order to be processed."),
	 		new FlaggedOption("processor", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'p', "processor", "A processor to be applied to data.").setAllowMultipleDeclarations(true),
		 	new FlaggedOption("writer", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'w', "writer", "A writer to be applied to the results.").setAllowMultipleDeclarations(true),
			new FlaggedOption("output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "output", "The output filename  (- for stdout).").setAllowMultipleDeclarations(true),
			new FlaggedOption("threads", JSAP.INTSIZE_PARSER, Integer.toString(Runtime.getRuntime().availableProcessors()), JSAP.NOT_REQUIRED, 'T', "threads", "The number of threads to be used."),
			new Switch("sequential", 'S', "sequential"),
			new UnflaggedOption("store", JSAP.STRING_PARSER, JSAP.NOT_REQUIRED, "The name of the store (if omitted, stdin)."),
	});

	final JSAPResult jsapResult = jsap.parse(arg);
	if (jsap.messagePrinted()) return;

	final String filterSpec = jsapResult.getString("filter");
	final Filter<WarcRecord> filter;
	if (filterSpec != null) {
		final FilterParser<WarcRecord> parser = new FilterParser<>(WarcRecord.class);
		filter = parser.parse(filterSpec);
	} else
		filter = null;
	final InputStream in = jsapResult.userSpecified("store") ? new FastBufferedInputStream(new FileInputStream(jsapResult.getString("store"))) : System.in;
	final ParallelFilteredProcessorRunner parallelFilteredProcessorRunner = new ParallelFilteredProcessorRunner(in, filter);

	final String[] processor =  jsapResult.getStringArray("processor");
	final String[] writer =  jsapResult.getStringArray("writer");
	final String[] output =  jsapResult.getStringArray("output");
	if (processor.length != writer.length) throw new IllegalArgumentException("You must specify the same number or processors and writers");
	if (output.length != writer.length) throw new IllegalArgumentException("You must specify the same number or output specifications and writers");

	final String[] packages = new String[] { ParallelFilteredProcessorRunner.class.getPackage().getName() };
	final PrintStream[] ops = new PrintStream[processor.length];
	for (int i = 0; i < processor.length; i++) {
		ops[i] = "-".equals(output[i]) ? System.out : new PrintStream(new FastBufferedOutputStream(new FileOutputStream(output[i])), false, "UTF-8");
		// TODO: these casts to SOMETHING<Object> are necessary for compilation under Eclipse. Check in the future.
		parallelFilteredProcessorRunner.add((Processor<Object>)ObjectParser.fromSpec(processor[i], Processor.class, packages, new String[] { "getInstance" }),
				(Writer<Object>)ObjectParser.fromSpec(writer[i], Writer.class,  packages, new String[] { "getInstance" }),
				ops[i]);
	}

	if (jsapResult.userSpecified("sequential")) parallelFilteredProcessorRunner.runSequentially();
	else parallelFilteredProcessorRunner.run(jsapResult.getInt("threads"));

	for (int i = 0; i < processor.length; i++) ops[i].close();

}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:48,代码来源:ParallelFilteredProcessorRunner.java

示例6: main

import it.unimi.dsi.lang.ObjectParser; //导入依赖的package包/类
public static void main( String arg[] ) throws JSAPException, IOException, IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException, InstantiationException {
	final SimpleJSAP jsap = new SimpleJSAP( ArcRelabelledImmutableGraph.class.getName(), 
			"Relabels a graph with given basename, with integer labels, saving it with a different basename and " +
			"using another (typically: different) type of integer labels, specified via a spec, and possibly using " +
			"a different kind of graph class.",
			new Parameter[] {
					new FlaggedOption( "underlyingGraphClass", GraphClassParser.getParser(), BVGraph.class.getName(), JSAP.NOT_REQUIRED, 'u', "underlying-graph-class", "Forces a Java immutable graph class to be used for saving the underlying graph (if the latter did not exist before)." ),
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), BitStreamArcLabelledImmutableGraph.class.getName(), JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java arc-labelled graph class to be used for saving." ),
					new UnflaggedOption( "spec", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The label spec (e.g. FixedWidthIntLabel(FOO,10))." ),
					new UnflaggedOption( "source", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source arc-labelled graph." ),
					new UnflaggedOption( "target", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the target arc-labelled graph." ),
				}		
			);
	
	final JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) System.exit( 1 );
	final Class<?> destClass = jsapResult.getClass( "graphClass" );
	final Class<?> underlyingDestClass = jsapResult.getClass( "underlyingGraphClass" );
	final String sourceBasename = jsapResult.getString( "source" );
	final String targetBasename = jsapResult.getString( "target" );
	final String spec = jsapResult.getString( "spec" );
	final Label label = ObjectParser.fromSpec( new File( sourceBasename ).getParent(), spec, Label.class );
	
	ImmutableGraph source = ImmutableGraph.loadOffline( sourceBasename );
	if ( ! ( source instanceof ArcLabelledImmutableGraph ) ) throw new IllegalArgumentException( "The graph " + sourceBasename + " of class " + sourceBasename.getClass().getName() + " is not arc-labelled" );
	ArcLabelledImmutableGraph labSource = (ArcLabelledImmutableGraph)source;
	
	if ( ! ( labSource.prototype() instanceof AbstractIntLabel && label instanceof AbstractIntLabel ) ) throw new IllegalArgumentException( "Relabelling from command line is only allowed for int labels, not for " + labSource.prototype().getClass().getName() + " -> " + label.getClass().getName());
	ArcLabelledImmutableGraph labTarget = new ArcRelabelledImmutableGraph( labSource, label, ArcRelabelledImmutableGraph.INT_LABEL_CONVERSION_STRATEGY );

	ProgressLogger pl = new ProgressLogger( LOGGER );

	Properties prop = new Properties();
	prop.load( new FileInputStream( sourceBasename + ImmutableGraph.PROPERTIES_EXTENSION ) );
	String underlyingBasename = prop.getProperty( ArcLabelledImmutableGraph.UNDERLYINGGRAPH_PROPERTY_KEY ); // Tries to get the underlying basename
	if ( underlyingBasename == null ) 
		// If the underlying did not exist, we store it with a fixed basename variant
		underlyingDestClass.getMethod( "store", ImmutableGraph.class, CharSequence.class, ProgressLogger.class )
		.invoke( null, labTarget, underlyingBasename = targetBasename + ArcLabelledImmutableGraph.UNDERLYINGGRAPH_SUFFIX, pl ); 		
	
	destClass.getMethod( "store", ArcLabelledImmutableGraph.class, CharSequence.class, CharSequence.class, ProgressLogger.class )
		.invoke( null, labTarget, targetBasename, underlyingBasename, pl ); 
	
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:45,代码来源:ArcRelabelledImmutableGraph.java

示例7: main

import it.unimi.dsi.lang.ObjectParser; //导入依赖的package包/类
public static void main( String args[] ) throws SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException, JSAPException, ClassNotFoundException,
		InstantiationException {
	String source, dest;
	Class<?> graphClass;

	final SimpleJSAP jsap = new SimpleJSAP(
			BVGraph.class.getName(),
			"Compresses a graph using the Elias-Fano representation. Source and destination are basenames from which suitable filenames will be stemmed; alternatively, if the suitable option was specified, source is a spec (see below). For more information about the compression techniques, see the Javadoc documentation.",
			new Parameter[] {
					new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph." ),
					new Switch( "spec", 's', "spec", "The source is not a basename but rather a specification of the form <ImmutableGraphImplementation>(arg,arg,...)." ),
					new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval",
							"The minimum time interval between activity logs in milliseconds." ),
					new FlaggedOption( "log2Quantum", JSAP.INTEGER_PARSER, Integer.toString( DEFAULT_LOG_2_QUANTUM ), JSAP.NOT_REQUIRED, 'q', "--log2-quantum",
							"The base-two logarithm of the indexing quantum." ),
					new Switch( "offline", 'o', "offline", "Use the offline load method to reduce memory consumption." ),
					new Switch( "once", '1', "once", "Use the read-once load method to read a graph from standard input." ),
					new Switch( "list", 'L', "list", "Precomputes an Elias-Fano list of offsets for the source graph." ),
					new Switch( "fixedWidthList", 'F', "fixed-width-list", "Precomputes a list of fixed-width offsets for the source graph." ),
					new UnflaggedOption( "sourceBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY,
							"The basename of the source graph, or a source spec if --spec was given; it is immaterial when --once is specified." ),
					new UnflaggedOption( "destBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY,
							"The basename of the destination graph; if omitted, no recompression is performed. This is useful in conjunction with --offsets and --list." ),
			}
			);

	final JSAPResult jsapResult = jsap.parse( args );
	if ( jsap.messagePrinted() ) System.exit( 1 );

	final boolean offline = jsapResult.getBoolean( "offline" );
	final boolean once = jsapResult.getBoolean( "once" );
	final boolean spec = jsapResult.getBoolean( "spec" );
	final boolean list = jsapResult.getBoolean( "list" );
	final boolean fixedWidthList = jsapResult.getBoolean( "fixedWidthList" );
	final int log2Quantum = jsapResult.getInt( "log2Quantum" );
	graphClass = jsapResult.getClass( "graphClass" );
	source = jsapResult.getString( "sourceBasename" );
	dest = jsapResult.getString( "destBasename" );

	final ImmutableGraph graph;
	final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );

	if ( graphClass != null ) {
		if ( spec ) {
			System.err.println( "Options --graph-class and --spec are incompatible" );
			System.exit( 1 );
		}
		if ( once ) graph = (ImmutableGraph)graphClass.getMethod( LoadMethod.ONCE.toMethod(), InputStream.class ).invoke( null, System.in );
		else if ( list || fixedWidthList || offline ) graph = (ImmutableGraph)graphClass.getMethod( LoadMethod.OFFLINE.toMethod(), CharSequence.class ).invoke( null, source );
		else graph = (ImmutableGraph)graphClass.getMethod( LoadMethod.SEQUENTIAL.toMethod(), CharSequence.class, ProgressLogger.class ).invoke( null, source, pl );
	}
	else {
		if ( !spec ) graph = once ? ImmutableGraph.loadOnce( System.in ) : offline ? ImmutableGraph.loadOffline( source, pl ) : ImmutableGraph.loadSequential( source, pl );
		else graph = ObjectParser.fromSpec( source, ImmutableGraph.class, GraphClassParser.PACKAGE );
	}

	if ( dest != null ) {
		if ( list || fixedWidthList ) throw new IllegalArgumentException( "You cannot specify a destination graph with these options" );
		EFGraph.store( graph, dest, log2Quantum, DEFAULT_CACHE_SIZE, ByteOrder.nativeOrder(), pl );
	}
	else {
		if ( !( graph instanceof EFGraph ) ) throw new IllegalArgumentException( "The source graph is not an EFGraph" );
		final InputBitStream offsets = new InputBitStream( graph.basename() + OFFSETS_EXTENSION );
		final long sizeInBits = new File( graph.basename() + GRAPH_EXTENSION ).length() * Byte.SIZE + 1;
		final OffsetsLongIterator offsetsIterator = new OffsetsLongIterator( offsets, graph.numNodes() );
		if ( list ) {
			BinIO.storeObject( new EliasFanoMonotoneLongBigList( graph.numNodes() + 1, sizeInBits, offsetsIterator ), graph.basename() + OFFSETS_BIG_LIST_EXTENSION );
		}
		else if ( fixedWidthList ) {
			final LongBigList t = LongArrayBitVector.getInstance().asLongBigList( Fast.length( sizeInBits ) );
			while ( offsetsIterator.hasNext() )
				t.add( offsetsIterator.nextLong() );
			BinIO.storeObject( t, graph.basename() + OFFSETS_BIG_LIST_EXTENSION );
		}
		offsets.close();
	}
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:78,代码来源:EFGraph.java

示例8: HTMLParser

import it.unimi.dsi.lang.ObjectParser; //导入依赖的package包/类
/**
 * Builds a parser with a fixed buffer of {@link #CHAR_BUFFER_SIZE} characters for link extraction and, possibly, digesting a page.
 *
 * @param messageDigest the name of a message-digest algorithm, or the empty string if no digest will be computed.
 * @param textProcessorSpec the specification of a text processor that will be passed to an {@link ObjectParser}.
 * @param crossAuthorityDuplicates a string whose value can only be "true" or "false" that is used to determine if you want to check for cross-authority duplicates.
 * @throws NoSuchAlgorithmException
 */
@SuppressWarnings("unchecked")
public HTMLParser(final String messageDigest, final String textProcessorSpec, final String crossAuthorityDuplicates) throws NoSuchAlgorithmException, IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, IOException {
	this(BinaryParser.forName(messageDigest), (TextProcessor<T>)ObjectParser.fromSpec(textProcessorSpec), Util.parseBoolean(crossAuthorityDuplicates));
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:13,代码来源:HTMLParser.java

示例9: parsersFromSpecs

import it.unimi.dsi.lang.ObjectParser; //导入依赖的package包/类
/** Given an array of parser specifications, it returns the corresponding list of parsers (only
 *  the correct specifications are put in the list.
 *
 * @param specs the parser specifications (they will be parsed using {@link ObjectParser}.
 * @return a list of parsers built according to the specifications (only the parseable items are put in the list).
 */
public static ArrayList<Parser<?>> parsersFromSpecs(String[] specs) throws IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, IOException {
	final ArrayList<Parser<?>> parsers = new ArrayList<>();
	for(final String spec : specs) parsers.add(ObjectParser.fromSpec(spec, Parser.class, new String[] { "it.unimi.di.law.bubing.parser" }));
	return parsers;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:12,代码来源:RuntimeConfiguration.java


注:本文中的it.unimi.dsi.lang.ObjectParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。