Package org.lilyproject.linkindex

Examples of org.lilyproject.linkindex.LinkIndex


        Configuration hbaseConf = HBaseConfiguration.create();
        hbaseConf.set("hbase.zookeeper.quorum", zkConnectionString);

        IndexManager indexManager = new IndexManager(hbaseConf, new HBaseTableFactoryImpl(hbaseConf));

        LinkIndex linkIndex = new LinkIndex(indexManager, lilyClient);

        //
        // Determine the index to query
        //
        boolean incoming = true; // false = outgoing
        if (cmd.hasOption(indexOption.getOpt())) {
            String index = cmd.getOptionValue(indexOption.getOpt());
            if (index.equals("incoming") || index.equals("backward")) {
                incoming = true;
            } else if (index.equals("outgoing") || index.equals("forward")) {
                incoming = false;
            } else {
                System.err.println("Invalid index name: " + index);
                return -1;
            }
        }

        //
        // Determine the record id
        //
        String recordIdParam = cmd.getOptionValue(recordIdOption.getOpt());
        if (recordIdParam == null) {
            System.out.println("Specify record id with -" + recordIdOption.getOpt());
            return 1;
        }
        RecordId recordId = repository.getIdGenerator().fromString(recordIdParam);

        //
        // Determine the vtag
        //
        SchemaId vtagId = null;
        if (cmd.hasOption(vtagOption.getOpt())) {
            String vtagParam = cmd.getOptionValue(vtagOption.getOpt());
            vtagId = typeManager.getFieldTypeByName(new QName("org.lilyproject.vtag", vtagParam)).getId();
        }

        //
        // Determine the field
        //
        SchemaId fieldId = null;
        if (cmd.hasOption(fieldOption.getOpt())) {
            if (vtagId == null) {
                System.err.println("A field can only be specified in combination with a vtag.");
                return -1;
            }

            String fieldParam = cmd.getOptionValue(fieldOption.getOpt());
            FieldType field = typeManager.getFieldTypeByName(QName.fromString(fieldParam));
            fieldId = field.getId();

            if (!field.getValueType().getDeepestValueType().getBaseName().equals("LINK")) {
                System.err.println("The field '" + field.getName() + "' is not a link field.");
                return -1;
            }
        }

        //
        // Perform the query
        //
        if (incoming) {
            System.out.println("Querying the incoming links (backward index)");
            System.out.println("Record id: " + recordId);
            System.out.println("vtag id: " + vtagId + getFieldTypeNameSuffix(vtagId));
            System.out.println("field id: " + fieldId + getFieldTypeNameSuffix(fieldId));
            System.out.println();
            if (fieldId != null) {
                Set<RecordId> records = linkIndex.getReferrers(recordId, vtagId, fieldId);
                printRecords(records);
            } else {
                Set<FieldedLink> fieldedLinks = linkIndex.getFieldedReferrers(recordId, vtagId);
                printFieldedLinks(fieldedLinks);
            }
        } else {
            System.out.println("Querying the outgoing links (forward index)");
            System.out.println("Record id: " + recordId);
            System.out.println("vtag id: " + vtagId + getFieldTypeNameSuffix(vtagId));
            System.out.println("field id: " + fieldId + getFieldTypeNameSuffix(fieldId));
            System.out.println();
            if (fieldId != null) {
                Set<RecordId> records = linkIndex.getForwardLinks(recordId, vtagId, fieldId);
                printRecords(records);
            } else {
                Set<FieldedLink> fieldedLinks = linkIndex.getFieldedForwardLinks(recordId, vtagId);
                printFieldedLinks(fieldedLinks);
            }
        }

        return 0;
View Full Code Here


        }

        if (linkIndexEnabled) {
            IndexManager indexManager = new IndexManager(hbaseConf, tableFactory);

            LinkIndex linkIndex = new LinkIndex(indexManager, /* TODO multiple repositories */ repositoryManager);

            LinkIndexUpdater linkIndexUpdater = new LinkIndexUpdater(repositoryManager, linkIndex);

            sepConsumer = new SepConsumer("LinkIndexUpdater", 0L, linkIndexUpdater, threads, hostName,
                    new ZooKeeperItfAdapter(zk), hbaseConf, new LilyPayloadExtractor());
View Full Code Here

        repository = (Repository)repoSetup.getRepositoryManager().getDefaultRepository().getDefaultTable();
        ids = repository.getIdGenerator();

        IndexManager indexManager = new IndexManager(repoSetup.getHadoopConf());

        linkIndex = new LinkIndex(indexManager, repoSetup.getRepositoryManager());

        repoSetup.getSepModel().addSubscription("LinkIndexUpdater");
        repoSetup.getTableManager().createTable(TABLE_A);
        repoSetup.getTableManager().createTable(TABLE_B);
        repoSetup.getTableManager().createTable(TABLE_C);
View Full Code Here

TOP

Related Classes of org.lilyproject.linkindex.LinkIndex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.