Пример #1
0
func NewUnique(conf *config.Config, fmtr lattice.Formatter, reporter miners.Reporter, histogramName string) (*Unique, error) {
	seen, err := conf.BytesIntMultiMap("unique-seen")
	if err != nil {
		return nil, err
	}
	var histogram io.WriteCloser = nil
	if histogramName != "" {
		histogram, err = os.Create(conf.OutputFile(histogramName + ".csv"))
		if err != nil {
			return nil, err
		}
	}
	u := &Unique{
		fmtr:      fmtr,
		Seen:      seen,
		Reporter:  reporter,
		histogram: histogram,
	}
	return u, nil
}
Пример #2
0
func NewDigraph(config *config.Config, dc *Config) (g *Digraph, err error) {
	if dc.MaxEdges <= 0 {
		dc.MaxEdges = int(math.MaxInt32)
	}
	if dc.MaxVertices <= 0 {
		dc.MaxVertices = int(math.MaxInt32)
	}
	if dc.MinEdges > dc.MaxEdges {
		dc.MinEdges = dc.MaxEdges - 1
	}
	if dc.MinVertices > dc.MaxVertices {
		dc.MinVertices = dc.MaxVertices - 1
	}
	nodeAttrs, err := config.IntJsonMultiMap("digraph-node-attrs")
	if err != nil {
		return nil, err
	}
	parents, err := config.MultiMap("digraph-parents")
	if err != nil {
		return nil, err
	}
	parentCount, err := config.BytesIntMultiMap("digraph-parent-count")
	if err != nil {
		return nil, err
	}
	children, err := config.MultiMap("digraph-children")
	if err != nil {
		return nil, err
	}
	childCount, err := config.BytesIntMultiMap("digraph-child-count")
	if err != nil {
		return nil, err
	}
	canonKids, err := config.MultiMap("digraph-canon-kids")
	if err != nil {
		return nil, err
	}
	canonKidCount, err := config.BytesIntMultiMap("digraph-canon-kid-count")
	if err != nil {
		return nil, err
	}
	embeddings, err := config.SubgraphEmbeddingMultiMap("digraph-embeddings")
	if err != nil {
		return nil, err
	}
	var unsupEmbs subgraph_embedding.MultiMap = nil
	if dc.Mode&EmbeddingPruning == EmbeddingPruning {
		unsupEmbs, err = config.SubgraphEmbeddingMultiMap("digraph-unsupported-embeddings")
		if err != nil {
			return nil, err
		}
	}
	var overlap subgraph_overlap.MultiMap = nil
	if dc.Mode&OverlapPruning == OverlapPruning {
		overlap, err = config.SubgraphOverlapMultiMap("digraph-overlap")
		if err != nil {
			return nil, err
		}
	}
	exts, err := config.BytesExtensionMultiMap("digraph-extensions")
	if err != nil {
		return nil, err
	}
	var unexts bytes_extension.MultiMap
	if dc.Mode&ExtensionPruning == ExtensionPruning {
		unexts, err = config.BytesExtensionMultiMap("digraph-unsupported-extensions")
		if err != nil {
			return nil, err
		}
	}
	frequency, err := config.BytesIntMultiMap("digraph-pattern-frequency")
	if err != nil {
		return nil, err
	}
	g = &Digraph{
		Config:        *dc,
		NodeAttrs:     nodeAttrs,
		Embeddings:    embeddings,
		UnsupEmbs:     unsupEmbs,
		Overlap:       overlap,
		Extensions:    exts,
		UnsupExts:     unexts,
		Parents:       parents,
		ParentCount:   parentCount,
		Children:      children,
		ChildCount:    childCount,
		CanonKids:     canonKids,
		CanonKidCount: canonKidCount,
		Frequency:     frequency,
		config:        config,
		pool:          pool.New(config.Workers()),
	}
	return g, nil
}