Example #1
0
 @Override
 public void readFields(DataInput input) throws IOException {
   byte[] tableNameBytes = Bytes.readByteArray(input);
   PName tableName = new PNameImpl(tableNameBytes);
   PTableType tableType = PTableType.values()[WritableUtils.readVInt(input)];
   long sequenceNumber = WritableUtils.readVLong(input);
   long timeStamp = input.readLong();
   byte[] pkNameBytes = Bytes.readByteArray(input);
   String pkName = pkNameBytes.length == 0 ? null : Bytes.toString(pkNameBytes);
   int nColumns = WritableUtils.readVInt(input);
   List<PColumn> columns = Lists.newArrayListWithExpectedSize(nColumns);
   for (int i = 0; i < nColumns; i++) {
     PColumn column = new PColumnImpl();
     column.readFields(input);
     columns.add(column);
   }
   Map<String, byte[][]> guidePosts = new HashMap<String, byte[][]>();
   int size = WritableUtils.readVInt(input);
   for (int i = 0; i < size; i++) {
     String key = WritableUtils.readString(input);
     int valueSize = WritableUtils.readVInt(input);
     byte[][] value = new byte[valueSize][];
     for (int j = 0; j < valueSize; j++) {
       value[j] = Bytes.readByteArray(input);
     }
     guidePosts.put(key, value);
   }
   PTableStats stats = new PTableStatsImpl(guidePosts);
   init(tableName, tableType, timeStamp, sequenceNumber, pkName, columns, stats);
 }
 public SmartNameFieldMappers smartName(String smartName, @Nullable String[] types) {
   if (types == null || types.length == 0) {
     return smartName(smartName);
   }
   if (types.length == 1 && types[0].equals("_all")) {
     return smartName(smartName);
   }
   for (String type : types) {
     DocumentMapper documentMapper = mappers.get(type);
     // we found a mapper
     if (documentMapper != null) {
       // see if we find a field for it
       FieldMappers mappers = documentMapper.mappers().smartName(smartName);
       if (mappers != null) {
         return new SmartNameFieldMappers(this, mappers, documentMapper, false);
       }
     }
   }
   // did not find explicit field in the type provided, see if its prefixed with type
   int dotIndex = smartName.indexOf('.');
   if (dotIndex != -1) {
     String possibleType = smartName.substring(0, dotIndex);
     DocumentMapper possibleDocMapper = mappers.get(possibleType);
     if (possibleDocMapper != null) {
       String possibleName = smartName.substring(dotIndex + 1);
       FieldMappers mappers = possibleDocMapper.mappers().smartName(possibleName);
       if (mappers != null) {
         return new SmartNameFieldMappers(this, mappers, possibleDocMapper, true);
       }
     }
   }
   // we did not find the field mapping in any of the types, so don't go and try to find
   // it in other types...
   return null;
 }
Example #3
0
  /**
   * 注册配置
   *
   * @param configuration Rest服务基础配置
   */
  public static void register(RestServiceConfiguration configuration) {

    CONFIG_FOR_NAME.put(configuration.getConfigurationName(), configuration);
    CONFIG_FOR_SERVICE_NAME.put(configuration.getCgiServiceName(), configuration);
    CONFIG_FOR_ENV.put(configuration.getEnvironment(), configuration);
    DEFAULT_CONFIG = configuration;
  }
Example #4
0
  /**
   * Store given Table instance to the schema
   *
   * @param table The Table instance to store
   * @throws IllegalArgumentException if Table is already stored
   */
  public void storeTableInstance(Table table) {
    if (tableInstances.containsKey(table.name))
      throw new IllegalArgumentException(
          String.format("Table %s was already initialized.", table.name));

    tableInstances.put(table.name, table);
  }
 public SmartNameObjectMapper smartNameObjectMapper(String smartName, @Nullable String[] types) {
   if (types == null || types.length == 0) {
     return smartNameObjectMapper(smartName);
   }
   if (types.length == 1 && types[0].equals("_all")) {
     return smartNameObjectMapper(smartName);
   }
   for (String type : types) {
     DocumentMapper possibleDocMapper = mappers.get(type);
     if (possibleDocMapper != null) {
       ObjectMapper mapper = possibleDocMapper.objectMappers().get(smartName);
       if (mapper != null) {
         return new SmartNameObjectMapper(mapper, possibleDocMapper);
       }
     }
   }
   // did not find one, see if its prefixed by type
   int dotIndex = smartName.indexOf('.');
   if (dotIndex != -1) {
     String possibleType = smartName.substring(0, dotIndex);
     DocumentMapper possibleDocMapper = mappers.get(possibleType);
     if (possibleDocMapper != null) {
       String possiblePath = smartName.substring(dotIndex + 1);
       ObjectMapper mapper = possibleDocMapper.objectMappers().get(possiblePath);
       if (mapper != null) {
         return new SmartNameObjectMapper(mapper, possibleDocMapper);
       }
     }
   }
   // did not explicitly find one under the types provided, or prefixed by type...
   return null;
 }
Example #6
0
 private ImmutableList<ColumnIdent> getPrimaryKey() {
   Map<String, Object> metaMap = getNested(defaultMappingMap, "_meta");
   if (metaMap != null) {
     ImmutableList.Builder<ColumnIdent> builder = ImmutableList.builder();
     Object pKeys = metaMap.get("primary_keys");
     if (pKeys != null) {
       if (pKeys instanceof String) {
         builder.add(ColumnIdent.fromPath((String) pKeys));
         return builder.build();
       } else if (pKeys instanceof Collection) {
         Collection keys = (Collection) pKeys;
         if (!keys.isEmpty()) {
           for (Object pkey : keys) {
             builder.add(ColumnIdent.fromPath(pkey.toString()));
           }
           return builder.build();
         }
       }
     }
   }
   if (getCustomRoutingCol() == null && partitionedByList.isEmpty()) {
     hasAutoGeneratedPrimaryKey = true;
     return ImmutableList.of(ID_IDENT);
   }
   return ImmutableList.of();
 }
Example #7
0
 /**
  * get the real column properties from a possible array mapping, keeping most of this stuff inside
  * "inner"
  */
 private Map<String, Object> furtherColumnProperties(Map<String, Object> columnProperties) {
   if (columnProperties.get("inner") != null) {
     return (Map<String, Object>) columnProperties.get("inner");
   } else {
     return columnProperties;
   }
 }
Example #8
0
 @NonNull
 public IAndroidTarget[] getMissingTargets() {
   synchronized (mLocalPackages) {
     if (mCachedMissingTargets == null) {
       Map<MissingTarget, MissingTarget> result = Maps.newHashMap();
       Set<ISystemImage> seen = Sets.newHashSet();
       for (IAndroidTarget target : getTargets()) {
         Collections.addAll(seen, target.getSystemImages());
       }
       for (LocalPkgInfo local : getPkgsInfos(PkgType.PKG_ADDON_SYS_IMAGE)) {
         LocalAddonSysImgPkgInfo info = (LocalAddonSysImgPkgInfo) local;
         ISystemImage image = info.getSystemImage();
         if (!seen.contains(image)) {
           addOrphanedSystemImage(image, info.getDesc(), result);
         }
       }
       for (LocalPkgInfo local : getPkgsInfos(PkgType.PKG_SYS_IMAGE)) {
         LocalSysImgPkgInfo info = (LocalSysImgPkgInfo) local;
         ISystemImage image = info.getSystemImage();
         if (!seen.contains(image)) {
           addOrphanedSystemImage(image, info.getDesc(), result);
         }
       }
       mCachedMissingTargets = result.keySet();
     }
     return mCachedMissingTargets.toArray(new IAndroidTarget[mCachedMissingTargets.size()]);
   }
 }
Example #9
0
 private List<String> getCurrentServerIds(boolean nag, boolean lagged) {
   try (Jedis jedis = pool.getResource()) {
     long time = getRedisTime(jedis.time());
     int nagTime = 0;
     if (nag) {
       nagTime = nagAboutServers.decrementAndGet();
       if (nagTime <= 0) {
         nagAboutServers.set(10);
       }
     }
     ImmutableList.Builder<String> servers = ImmutableList.builder();
     Map<String, String> heartbeats = jedis.hgetAll("heartbeats");
     for (Map.Entry<String, String> entry : heartbeats.entrySet()) {
       try {
         long stamp = Long.parseLong(entry.getValue());
         if (lagged ? time >= stamp + 30 : time <= stamp + 30) servers.add(entry.getKey());
         else if (nag && nagTime <= 0) {
           getLogger()
               .severe(
                   entry.getKey()
                       + " is "
                       + (time - stamp)
                       + " seconds behind! (Time not synchronized or server down?)");
         }
       } catch (NumberFormatException ignored) {
       }
     }
     return servers.build();
   } catch (JedisConnectionException e) {
     getLogger().log(Level.SEVERE, "Unable to fetch server IDs", e);
     return Collections.singletonList(configuration.getServerId());
   }
 }
 private MapMessage newMapMessage(Map<String, Object> body) throws JMSException {
   MapMessage message = new MapMessageImpl();
   for (String key : body.keySet()) {
     Object value = body.get(key);
     message.setObject(key, value);
   }
   return message;
 }
Example #11
0
 private IndexReferenceInfo.Builder getOrCreateIndexBuilder(ColumnIdent ident) {
   IndexReferenceInfo.Builder builder = indicesBuilder.get(ident);
   if (builder == null) {
     builder = new IndexReferenceInfo.Builder();
     indicesBuilder.put(ident, builder);
   }
   return builder;
 }
Example #12
0
  private int repeatInternal(
      @NotNull PseudocodeImpl originalPseudocode,
      @Nullable Label startLabel,
      @Nullable Label finishLabel,
      int labelCount) {
    Integer startIndex =
        startLabel != null
            ? ((PseudocodeLabel) startLabel).getTargetInstructionIndex()
            : Integer.valueOf(0);
    assert startIndex != null;
    Integer finishIndex =
        finishLabel != null
            ? ((PseudocodeLabel) finishLabel).getTargetInstructionIndex()
            : Integer.valueOf(originalPseudocode.mutableInstructionList.size());
    assert finishIndex != null;

    Map<Label, Label> originalToCopy = Maps.newLinkedHashMap();
    Multimap<Instruction, Label> originalLabelsForInstruction = HashMultimap.create();
    for (PseudocodeLabel label : originalPseudocode.labels) {
      Integer index = label.getTargetInstructionIndex();
      if (index == null) continue; // label is not bounded yet
      if (label == startLabel || label == finishLabel) continue;

      if (startIndex <= index && index <= finishIndex) {
        originalToCopy.put(label, label.copy(labelCount++));
        originalLabelsForInstruction.put(getJumpTarget(label), label);
      }
    }
    for (Label label : originalToCopy.values()) {
      labels.add((PseudocodeLabel) label);
    }
    for (int index = startIndex; index < finishIndex; index++) {
      Instruction originalInstruction = originalPseudocode.mutableInstructionList.get(index);
      repeatLabelsBindingForInstruction(
          originalInstruction, originalToCopy, originalLabelsForInstruction);
      Instruction copy = copyInstruction(originalInstruction, originalToCopy);
      addInstruction(copy);
      if (originalInstruction == originalPseudocode.errorInstruction
          && copy instanceof SubroutineExitInstruction) {
        errorInstruction = (SubroutineExitInstruction) copy;
      }
      if (originalInstruction == originalPseudocode.exitInstruction
          && copy instanceof SubroutineExitInstruction) {
        exitInstruction = (SubroutineExitInstruction) copy;
      }
      if (originalInstruction == originalPseudocode.sinkInstruction
          && copy instanceof SubroutineSinkInstruction) {
        sinkInstruction = (SubroutineSinkInstruction) copy;
      }
    }
    if (finishIndex < mutableInstructionList.size()) {
      repeatLabelsBindingForInstruction(
          originalPseudocode.mutableInstructionList.get(finishIndex),
          originalToCopy,
          originalLabelsForInstruction);
    }
    return labelCount;
  }
Example #13
0
 private Map<String, Tag> findLastParent(final String[] parts) {
   Map<String, Tag> map = NBTStorage.this.root;
   for (int i = 0; i < parts.length - 1; ++i) {
     if (!map.containsKey(parts[i]) || !(map.get(parts[i]) instanceof CompoundTag)) {
       return null;
     }
     map = map.get(parts[i]).getValue();
   }
   return map;
 }
  public String urlTransform(String baseurl, Map<String, String> param) {
    String url = baseurl;

    for (String key : param.keySet()) {
      url = url + "&" + key + "=" + param.get(key);
    }

    System.out.println(url);
    return url;
  }
Example #15
0
 @Override
 public void removeKey(final String key) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   final Map<String, Tag> parent = this.findLastParent(parts);
   parent.remove(parts[parts.length - 1]);
 }
 private static Map<ClassDescriptor, JetType> getSuperclassToSupertypeMap(
     ClassDescriptor containingClass) {
   Map<ClassDescriptor, JetType> superclassToSupertype = Maps.newHashMap();
   for (JetType supertype : TypeUtils.getAllSupertypes(containingClass.getDefaultType())) {
     ClassifierDescriptor superclass = supertype.getConstructor().getDeclarationDescriptor();
     assert superclass instanceof ClassDescriptor;
     superclassToSupertype.put((ClassDescriptor) superclass, supertype);
   }
   return superclassToSupertype;
 }
 /** @return a copy of the endpoint-to-id map for read-only operations */
 public Map<InetAddress, UUID> getEndpointToHostIdMapForReading() {
   lock.readLock().lock();
   try {
     Map<InetAddress, UUID> readMap = new HashMap<InetAddress, UUID>();
     readMap.putAll(endpointToHostIdMap);
     return readMap;
   } finally {
     lock.readLock().unlock();
   }
 }
  @NotNull
  private ClassifierDescriptor modifyTypeClassifier(
      @NotNull JetType autoType, @NotNull List<TypeAndVariance> typesFromSuper) {
    ClassifierDescriptor classifier = autoType.getConstructor().getDeclarationDescriptor();
    if (!(classifier instanceof ClassDescriptor)) {
      assert classifier != null : "no declaration descriptor for type " + autoType;

      if (classifier instanceof TypeParameterDescriptor
          && autoTypeParameterToModified.containsKey(classifier)) {
        return autoTypeParameterToModified.get(classifier);
      }
      return classifier;
    }
    ClassDescriptor klass = (ClassDescriptor) classifier;

    CollectionClassMapping collectionMapping = CollectionClassMapping.getInstance();

    boolean someSupersMutable = false;
    boolean someSupersCovariantReadOnly = false;
    boolean someSupersNotCovariantReadOnly = false;
    for (TypeAndVariance typeFromSuper : typesFromSuper) {
      ClassifierDescriptor classifierFromSuper =
          typeFromSuper.type.getConstructor().getDeclarationDescriptor();
      if (classifierFromSuper instanceof ClassDescriptor) {
        ClassDescriptor classFromSuper = (ClassDescriptor) classifierFromSuper;

        if (collectionMapping.isMutableCollection(classFromSuper)) {
          someSupersMutable = true;
        } else if (collectionMapping.isReadOnlyCollection(classFromSuper)) {
          if (typeFromSuper.varianceOfPosition == Variance.OUT_VARIANCE) {
            someSupersCovariantReadOnly = true;
          } else {
            someSupersNotCovariantReadOnly = true;
          }
        }
      }
    }

    if (someSupersMutable && someSupersNotCovariantReadOnly) {
      reportError("Incompatible types in superclasses: " + typesFromSuper);
      return classifier;
    } else if (someSupersMutable) {
      if (collectionMapping.isReadOnlyCollection(klass)) {
        return collectionMapping.convertReadOnlyToMutable(klass);
      }
    } else if (someSupersNotCovariantReadOnly || someSupersCovariantReadOnly) {
      if (collectionMapping.isMutableCollection(klass)) {
        return collectionMapping.convertMutableToReadOnly(klass);
      }
    }

    ClassifierDescriptor fixed =
        PropagationHeuristics.tryToFixOverridingTWithRawType(this, typesFromSuper);
    return fixed != null ? fixed : classifier;
  }
  public static Map<String, String> validateOptions(Map<String, String> options)
      throws ConfigurationException {
    Map<String, String> uncheckedOptions = AbstractCompactionStrategy.validateOptions(options);
    uncheckedOptions =
        DateTieredCompactionStrategyOptions.validateOptions(options, uncheckedOptions);

    uncheckedOptions.remove(CFPropDefs.KW_MINCOMPACTIONTHRESHOLD);
    uncheckedOptions.remove(CFPropDefs.KW_MAXCOMPACTIONTHRESHOLD);

    return uncheckedOptions;
  }
    public List<Vertex> getProductAssociations(Vertex v) {
      Map<Vertex, Edge> adjacent = Maps.newHashMap(graph.row(v));
      adjacent.putAll(graph.column(v));

      return adjacent
          .entrySet()
          .stream()
          .sorted((e1, e2) -> e2.getValue().weight - e1.getValue().weight)
          .map(Map.Entry::getKey)
          .collect(Collectors.toList());
    }
Example #21
0
 private ColumnIdent getCustomRoutingCol() {
   if (defaultMappingMetaData != null) {
     Map<String, Object> metaMap = getNested(defaultMappingMap, "_meta");
     if (metaMap != null) {
       String routingPath = (String) metaMap.get("routing");
       if (routingPath != null && !routingPath.equals(ID)) {
         return ColumnIdent.fromPath(routingPath);
       }
     }
   }
   return null;
 }
 /**
  * @return a (stable copy, won't be modified) Token to Endpoint map for all the normal and
  *     bootstrapping nodes in the cluster.
  */
 public Map<Token, InetAddress> getNormalAndBootstrappingTokenToEndpointMap() {
   lock.readLock().lock();
   try {
     Map<Token, InetAddress> map =
         new HashMap<Token, InetAddress>(tokenToEndpointMap.size() + bootstrapTokens.size());
     map.putAll(tokenToEndpointMap);
     map.putAll(bootstrapTokens);
     return map;
   } finally {
     lock.readLock().unlock();
   }
 }
 /**
  * If no experiments were specified, inject into statisticsQuery a superset of all experiments for
  * which stats exist across all attributes
  *
  * @param statisticsQuery
  * @param statisticsStorage
  */
 private static void setQueryExperiments(
     StatisticsQueryCondition statisticsQuery, StatisticsStorage statisticsStorage) {
   Set<ExperimentInfo> exps = statisticsQuery.getExperiments();
   if (exps
       .isEmpty()) { // No experiments conditions were specified - assemble a superset of all
                     // experiments for which stats exist across all attributes
     for (EfAttribute attr : statisticsQuery.getAttributes()) {
       Map<ExperimentInfo, ConciseSet> expsToStats =
           getStatisticsForAttribute(statisticsQuery.getStatisticsType(), attr, statisticsStorage);
       if (expsToStats != null) exps.addAll(expsToStats.keySet());
     }
     statisticsQuery.inExperiments(exps);
   }
 }
  // purchase product and return relevant product recommendations
  public List<Product> purchase(Customer customer, Product product) {
    purchasesCache.put(customer.id, product.id);

    ProductAssociativityGraph graph = productAssociativityGraphMap.get(product.category);
    Vertex v = Vertex.create(product.id);
    List<Vertex> associations = graph.getProductAssociations(v);

    int recommendSize = Math.min(associations.size(), maxNumRecommendations);
    return associations
        .stream()
        .map(vertex -> productCache.get(vertex.productId))
        .limit(recommendSize)
        .collect(Collectors.toList());
  }
Example #25
0
 private static void addOrphanedSystemImage(
     ISystemImage image, IPkgDesc desc, Map<MissingTarget, MissingTarget> targets) {
   IdDisplay vendor = desc.getVendor();
   MissingTarget target =
       new MissingTarget(
           vendor == null ? null : vendor.getDisplay(),
           desc.getTag().getDisplay(),
           desc.getAndroidVersion());
   MissingTarget existing = targets.get(target);
   if (existing == null) {
     existing = target;
     targets.put(target, target);
   }
   existing.addSystemImage(image);
 }
Example #26
0
 private static Instruction copyInstruction(
     @NotNull Instruction instruction, @NotNull Map<Label, Label> originalToCopy) {
   if (instruction instanceof AbstractJumpInstruction) {
     Label originalTarget = ((AbstractJumpInstruction) instruction).getTargetLabel();
     if (originalToCopy.containsKey(originalTarget)) {
       return ((AbstractJumpInstruction) instruction).copy(originalToCopy.get(originalTarget));
     }
   }
   if (instruction instanceof NondeterministicJumpInstruction) {
     List<Label> originalTargets =
         ((NondeterministicJumpInstruction) instruction).getTargetLabels();
     List<Label> copyTargets = copyLabels(originalTargets, originalToCopy);
     return ((NondeterministicJumpInstruction) instruction).copy(copyTargets);
   }
   return ((InstructionImpl) instruction).copy();
 }
Example #27
0
  // never expose this to the outside world, we need to reparse the doc mapper so we get fresh
  // instances of field mappers to properly remove existing doc mapper
  private DocumentMapper merge(DocumentMapper mapper) {
    synchronized (typeMutex) {
      if (mapper.type().length() == 0) {
        throw new InvalidTypeNameException("mapping type name is empty");
      }
      if (mapper.type().charAt(0) == '_' && !PercolatorService.TYPE_NAME.equals(mapper.type())) {
        throw new InvalidTypeNameException(
            "mapping type name [" + mapper.type() + "] can't start with '_'");
      }
      if (mapper.type().contains("#")) {
        throw new InvalidTypeNameException(
            "mapping type name [" + mapper.type() + "] should not include '#' in it");
      }
      if (mapper.type().contains(",")) {
        throw new InvalidTypeNameException(
            "mapping type name [" + mapper.type() + "] should not include ',' in it");
      }
      if (mapper.type().contains(".")) {
        logger.warn(
            "Type [{}] contains a '.', it is recommended not to include it within a type name",
            mapper.type());
      }
      // we can add new field/object mappers while the old ones are there
      // since we get new instances of those, and when we remove, we remove
      // by instance equality
      DocumentMapper oldMapper = mappers.get(mapper.type());

      if (oldMapper != null) {
        DocumentMapper.MergeResult result = oldMapper.merge(mapper, mergeFlags().simulate(false));
        if (result.hasConflicts()) {
          // TODO: What should we do???
          if (logger.isDebugEnabled()) {
            logger.debug(
                "merging mapping for type [{}] resulted in conflicts: [{}]",
                mapper.type(),
                Arrays.toString(result.conflicts()));
          }
        }
        return oldMapper;
      } else {
        FieldMapperListener.Aggregator fieldMappersAgg = new FieldMapperListener.Aggregator();
        mapper.traverse(fieldMappersAgg);
        addFieldMappers(
            fieldMappersAgg.mappers.toArray(new FieldMapper[fieldMappersAgg.mappers.size()]));
        mapper.addFieldMapperListener(fieldMapperListener, false);

        ObjectMapperListener.Aggregator objectMappersAgg = new ObjectMapperListener.Aggregator();
        mapper.traverse(objectMappersAgg);
        addObjectMappers(
            objectMappersAgg.mappers.toArray(new ObjectMapper[objectMappersAgg.mappers.size()]));
        mapper.addObjectMapperListener(objectMapperListener, false);

        mappers = newMapBuilder(mappers).put(mapper.type(), mapper).map();
        for (DocumentTypeListener typeListener : typeListeners) {
          typeListener.created(mapper.type());
        }
        return mapper;
      }
    }
  }
Example #28
0
 /**
  * Returns smart field mappers based on a smart name. A smart name is one that can optioannly be
  * prefixed with a type (and then a '.'). If it is, then the {@link
  * MapperService.SmartNameFieldMappers} will have the doc mapper set.
  *
  * <p>
  *
  * <p>It also (without the optional type prefix) try and find the {@link FieldMappers} for the
  * specific name. It will first try to find it based on the full name (with the dots if its a
  * compound name). If it is not found, will try and find it based on the indexName (which can be
  * controlled in the mapping), and last, will try it based no the name itself.
  *
  * <p>
  *
  * <p>If nothing is found, returns null.
  */
 public SmartNameFieldMappers smartName(String smartName) {
   int dotIndex = smartName.indexOf('.');
   if (dotIndex != -1) {
     String possibleType = smartName.substring(0, dotIndex);
     DocumentMapper possibleDocMapper = mappers.get(possibleType);
     if (possibleDocMapper != null) {
       String possibleName = smartName.substring(dotIndex + 1);
       FieldMappers mappers = possibleDocMapper.mappers().smartName(possibleName);
       if (mappers != null) {
         return new SmartNameFieldMappers(this, mappers, possibleDocMapper, true);
       }
     }
   }
   FieldMappers fieldMappers = fullName(smartName);
   if (fieldMappers != null) {
     return new SmartNameFieldMappers(this, fieldMappers, null, false);
   }
   fieldMappers = indexName(smartName);
   if (fieldMappers != null) {
     return new SmartNameFieldMappers(this, fieldMappers, null, false);
   }
   fieldMappers = name(smartName);
   if (fieldMappers != null) {
     return new SmartNameFieldMappers(this, fieldMappers, null, false);
   }
   return null;
 }
Example #29
0
  private boolean isInDistanceInternal(
      int distance, NetworkNode from, NetworkNode to, TwoNetworkNodes cachePairKey) {
    if (from.equals(to)) return true;

    if (distance == 0) return false;

    if (SimpleNetwork.areNodesConnecting(from, to)) return true;

    // Breadth-first search of the network
    Set<NetworkNode> visitedNodes = Sets.newHashSet();
    visitedNodes.add(from);

    Set<NetworkNode> networkingNodesToTest = Sets.newHashSet();
    listConnectedNotVisitedNetworkingNodes(visitedNodes, from, networkingNodesToTest);
    int distanceSearched = 1;
    while (distanceSearched < distance) {
      distanceSearched++;

      for (NetworkNode nodeToTest : networkingNodesToTest) {
        if (SimpleNetwork.areNodesConnecting(nodeToTest, to)) {
          distanceCache.put(cachePairKey, distanceSearched);
          return true;
        }
        visitedNodes.add(nodeToTest);
      }

      Set<NetworkNode> nextNetworkingNodesToTest = Sets.newHashSet();
      for (NetworkNode nodeToTest : networkingNodesToTest)
        listConnectedNotVisitedNetworkingNodes(visitedNodes, nodeToTest, nextNetworkingNodesToTest);

      networkingNodesToTest = nextNetworkingNodesToTest;
    }

    return false;
  }
Example #30
0
 public void removeRelation(InternalRelation relation) {
   Preconditions.checkArgument(!relation.isRemoved());
   relation = relation.it();
   // Delete from Vertex
   for (int i = 0; i < relation.getLen(); i++) {
     relation.getVertex(i).removeRelation(relation);
   }
   // Update transaction data structures
   if (relation.isNew()) {
     addedRelations.remove(relation);
     if (isVertexIndexProperty(relation)) newVertexIndexEntries.remove((TitanProperty) relation);
   } else {
     Preconditions.checkArgument(relation.isLoaded());
     if (deletedRelations == EMPTY_DELETED_RELATIONS) {
       if (config.isSingleThreaded()) {
         deletedRelations = new HashMap<Long, InternalRelation>();
       } else {
         synchronized (this) {
           if (deletedRelations == EMPTY_DELETED_RELATIONS)
             deletedRelations = new ConcurrentHashMap<Long, InternalRelation>();
         }
       }
     }
     deletedRelations.put(Long.valueOf(relation.getID()), relation);
   }
 }