當前位置: 首頁>>代碼示例>>Java>>正文


Java ListMultimap.entries方法代碼示例

本文整理匯總了Java中com.google.common.collect.ListMultimap.entries方法的典型用法代碼示例。如果您正苦於以下問題:Java ListMultimap.entries方法的具體用法?Java ListMultimap.entries怎麽用?Java ListMultimap.entries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.ListMultimap的用法示例。


在下文中一共展示了ListMultimap.entries方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUserPermissions

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
static List<UserPermission> getUserPermissions(
    Configuration conf, byte[] entryName)
throws IOException {
  ListMultimap<String,TablePermission> allPerms = getPermissions(
    conf, entryName);

  List<UserPermission> perms = new ArrayList<UserPermission>();

  for (Map.Entry<String, TablePermission> entry : allPerms.entries()) {
    UserPermission up = new UserPermission(Bytes.toBytes(entry.getKey()),
        entry.getValue().getTableName(), entry.getValue().getFamily(),
        entry.getValue().getQualifier(), entry.getValue().getActions());
    perms.add(up);
  }
  return perms;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:AccessControlLists.java

示例2: updateGlobalCache

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
 * Updates the internal global permissions cache
 *
 * @param userPerms
 */
private void updateGlobalCache(ListMultimap<String,TablePermission> userPerms) {
  PermissionCache<Permission> newCache = null;
  try {
    newCache = initGlobal(conf);
    for (Map.Entry<String,TablePermission> entry : userPerms.entries()) {
      if (AuthUtil.isGroupPrincipal(entry.getKey())) {
        newCache.putGroup(AuthUtil.getGroupName(entry.getKey()),
            new Permission(entry.getValue().getActions()));
      } else {
        newCache.putUser(entry.getKey(), new Permission(entry.getValue().getActions()));
      }
    }
    globalCache = newCache;
    mtime.incrementAndGet();
  } catch (IOException e) {
    // Never happens
    LOG.error("Error occured while updating the global cache", e);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:25,代碼來源:TableAuthManager.java

示例3: updateTableCache

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
 * Updates the internal permissions cache for a single table, splitting
 * the permissions listed into separate caches for users and groups to optimize
 * group lookups.
 *
 * @param table
 * @param tablePerms
 */
private void updateTableCache(TableName table,
                              ListMultimap<String,TablePermission> tablePerms) {
  PermissionCache<TablePermission> newTablePerms = new PermissionCache<TablePermission>();

  for (Map.Entry<String,TablePermission> entry : tablePerms.entries()) {
    if (AuthUtil.isGroupPrincipal(entry.getKey())) {
      newTablePerms.putGroup(AuthUtil.getGroupName(entry.getKey()), entry.getValue());
    } else {
      newTablePerms.putUser(entry.getKey(), entry.getValue());
    }
  }

  tableCache.put(table, newTablePerms);
  mtime.incrementAndGet();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:TableAuthManager.java

示例4: updateNsCache

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
 * Updates the internal permissions cache for a single table, splitting
 * the permissions listed into separate caches for users and groups to optimize
 * group lookups.
 *
 * @param namespace
 * @param tablePerms
 */
private void updateNsCache(String namespace,
                           ListMultimap<String, TablePermission> tablePerms) {
  PermissionCache<TablePermission> newTablePerms = new PermissionCache<TablePermission>();

  for (Map.Entry<String, TablePermission> entry : tablePerms.entries()) {
    if (AuthUtil.isGroupPrincipal(entry.getKey())) {
      newTablePerms.putGroup(AuthUtil.getGroupName(entry.getKey()), entry.getValue());
    } else {
      newTablePerms.putUser(entry.getKey(), entry.getValue());
    }
  }

  nsCache.put(namespace, newTablePerms);
  mtime.incrementAndGet();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:TableAuthManager.java

示例5: propertyMapMatch

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
private boolean propertyMapMatch(
        MemgraphCypherQueryContext ctx,
        Element element,
        ListMultimap<String, CypherAstBase> propertiesMap,
        ExpressionScope scope
) {
    for (Map.Entry<String, CypherAstBase> propertyEntry : propertiesMap.entries()) {
        Object propertyValue = element.getPropertyValue(propertyEntry.getKey());
        Object expressionValue = ctx.getExpressionExecutor().executeExpression(ctx, propertyEntry.getValue(), scope);
        if (!ObjectUtils.equals(propertyValue, expressionValue)) {
            return false;
        }
    }
    return true;
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:16,代碼來源:MatchClauseExecutor.java

示例6: testAclTableEntries

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
@Test
public void testAclTableEntries() throws Exception {
  String userTestNamespace = "userTestNsp";
  try(Connection conn = ConnectionFactory.createConnection(conf);
      Table acl = conn.getTable(AccessControlLists.ACL_TABLE_NAME)) {
    ListMultimap<String, TablePermission> perms =
        AccessControlLists.getNamespacePermissions(conf, TEST_NAMESPACE);

    perms = AccessControlLists.getNamespacePermissions(conf, TEST_NAMESPACE);
    for (Map.Entry<String, TablePermission> entry : perms.entries()) {
      LOG.debug(entry);
    }
    assertEquals(6, perms.size());

    // Grant and check state in ACL table
    grantOnNamespace(UTIL, userTestNamespace, TEST_NAMESPACE,
      Permission.Action.WRITE);

    Result result = acl.get(new Get(Bytes.toBytes(userTestNamespace)));
    assertTrue(result != null);
    perms = AccessControlLists.getNamespacePermissions(conf, TEST_NAMESPACE);
    assertEquals(7, perms.size());
    List<TablePermission> namespacePerms = perms.get(userTestNamespace);
    assertTrue(perms.containsKey(userTestNamespace));
    assertEquals(1, namespacePerms.size());
    assertEquals(TEST_NAMESPACE,
      namespacePerms.get(0).getNamespace());
    assertEquals(null, namespacePerms.get(0).getFamily());
    assertEquals(null, namespacePerms.get(0).getQualifier());
    assertEquals(1, namespacePerms.get(0).getActions().length);
    assertEquals(Permission.Action.WRITE, namespacePerms.get(0).getActions()[0]);

    // Revoke and check state in ACL table
    revokeFromNamespace(UTIL, userTestNamespace, TEST_NAMESPACE,
      Permission.Action.WRITE);

    perms = AccessControlLists.getNamespacePermissions(conf, TEST_NAMESPACE);
    assertEquals(6, perms.size());
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:41,代碼來源:TestNamespaceCommands.java

示例7: executeFirstMatchConstraint

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
private List<? extends Element> executeFirstMatchConstraint(
        MemgraphCypherQueryContext ctx,
        MatchConstraint<?, ?> matchConstraint,
        ExpressionScope scope
) {
    try {
        List<String> labelNames = getLabelNamesFromMatchConstraint(matchConstraint);
        ListMultimap<String, CypherAstBase> propertiesMap = getPropertiesMapFromElementPatterns(ctx, matchConstraint.getPatterns());
        Iterable<? extends Element> elements;
        if (labelNames.size() == 0 && propertiesMap.size() == 0) {
            if (matchConstraint instanceof NodeMatchConstraint) {
                elements = ctx.getGraph().getVertices(ctx.getFetchHints(), ctx.getAuthorizations());
            } else if (matchConstraint instanceof RelationshipMatchConstraint) {
                elements = ctx.getGraph().getEdges(ctx.getFetchHints(), ctx.getAuthorizations());
            } else {
                throw new MemgraphCypherNotImplemented("unexpected constraint type: " + matchConstraint.getClass().getName());
            }
        } else {
            Query query = ctx.getGraph().query(ctx.getAuthorizations());

            if (labelNames.size() > 0) {
                Stream<String> labelNamesStream = labelNames.stream()
                        .map(ctx::normalizeLabelName);

                if (matchConstraint instanceof NodeMatchConstraint) {

                    query = labelNamesStream
                            .reduce(
                                    query,
                                    (q, labelName) -> q.has(ctx.getLabelPropertyName(), labelName),
                                    (q, q2) -> q
                            );
                } else if (matchConstraint instanceof RelationshipMatchConstraint) {
                    List<String> normalizedLabelNames = labelNamesStream.collect(Collectors.toList());
                    query = query.hasEdgeLabel(normalizedLabelNames);
                } else {
                    throw new MemgraphCypherNotImplemented("unexpected constraint type: " + matchConstraint.getClass().getName());
                }
            }

            for (Map.Entry<String, CypherAstBase> propertyMatch : propertiesMap.entries()) {
                Object value = ctx.getExpressionExecutor().executeExpression(ctx, propertyMatch.getValue(), scope);
                if (value instanceof CypherAstBase) {
                    throw new MemgraphException("unexpected value: " + value.getClass().getName() + ": " + value);
                }
                if (value instanceof List) {
                    query.has(propertyMatch.getKey(), Contains.IN, value);
                } else {
                    query.has(propertyMatch.getKey(), value);
                }
            }

            if (matchConstraint instanceof NodeMatchConstraint) {
                elements = query.vertices(ctx.getFetchHints());
            } else if (matchConstraint instanceof RelationshipMatchConstraint) {
                elements = query.edges(ctx.getFetchHints());
            } else {
                throw new MemgraphCypherNotImplemented("unexpected constraint type: " + matchConstraint.getClass().getName());
            }
        }

        return Lists.newArrayList(elements);
    } catch (MemgraphPropertyNotDefinedException e) {
        LOGGER.error(e.getMessage());
        return Lists.newArrayList();
    }
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:68,代碼來源:MatchClauseExecutor.java


注:本文中的com.google.common.collect.ListMultimap.entries方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。