示例#1
0
 @Override
 public List<Mutation>
     toRowMutations() { // TODO: change to List<Mutation> once it implements Row
   List<Mutation> mutations = new ArrayList<Mutation>(3);
   if (deleteRow != null) {
     // Include only deleteRow mutation if present because it takes precedence over all others
     mutations.add(deleteRow);
   } else {
     // Because we cannot enforce a not null constraint on a KV column (since we don't know if
     // the row exists when
     // we upsert it), se instead add a KV that is always emtpy. This allows us to imitate SQL
     // semantics given the
     // way HBase works.
     setValues.add(
         SchemaUtil.getEmptyColumnFamily(getColumnFamilies()),
         QueryConstants.EMPTY_COLUMN_BYTES,
         ts,
         ByteUtil.EMPTY_BYTE_ARRAY);
     mutations.add(setValues);
     if (!unsetValues.isEmpty()) {
       mutations.add(unsetValues);
     }
   }
   return mutations;
 }
示例#2
0
 public String getString(int start, int end) {
   StringBuilder buffer = new StringBuilder(parsedArgs.get(start));
   for (int i = start + 1; i < end + 1; ++i) {
     buffer.append(" ").append(parsedArgs.get(i));
   }
   return buffer.toString();
 }
示例#3
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);
 }
 /**
  * 将j.stack文件中有用的两行拿出来
  *
  * @param filename
  * @return
  */
 public List<String[]> getLine(String filename) throws Exception {
   if (filename == null) throw new FileNotFoundException();
   Closer closer = Closer.create();
   String[] rawData = {"", ""};
   List<String[]> rawDatas = new ArrayList<String[]>();
   URL url = Resources.getResource(filename);
   try {
     FileReader reader = closer.register(new FileReader(url.getPath()));
     LineReader lineReader = new LineReader(reader);
     String line = "";
     while ((line = lineReader.readLine()) != null) {
       if (line.indexOf("\"") > -1) { // 匹配第一行
         rawData = new String[2];
         rawData[0] = line;
       }
       if (line.indexOf("java.lang.Thread.State") > -1) { // 匹配第二行,取当前线程的状态
         rawData[1] = line.trim().split(" ")[1];
         rawDatas.add(rawData);
       }
     }
   } finally {
     closer.close();
   }
   return rawDatas;
 }
示例#5
0
 public Token getSuccessor(Token token) {
   List tokens = sortedTokens();
   int index = Collections.binarySearch(tokens, token);
   assert index >= 0
       : token + " not found in " + StringUtils.join(tokenToEndPointMap.keySet(), ", ");
   return (Token) ((index == (tokens.size() - 1)) ? tokens.get(0) : tokens.get(index + 1));
 }
  private static List<FunctionDescriptor> getSuperFunctionsForMethod(
      @NotNull PsiMethodWrapper method,
      @NotNull BindingTrace trace,
      @NotNull ClassDescriptor containingClass) {
    List<FunctionDescriptor> superFunctions = Lists.newArrayList();

    Map<ClassDescriptor, JetType> superclassToSupertype =
        getSuperclassToSupertypeMap(containingClass);

    Multimap<FqName, Pair<FunctionDescriptor, PsiMethod>> superclassToFunctions =
        getSuperclassToFunctionsMultimap(method, trace.getBindingContext(), containingClass);

    for (HierarchicalMethodSignature superSignature :
        method.getPsiMethod().getHierarchicalMethodSignature().getSuperSignatures()) {
      PsiMethod superMethod = superSignature.getMethod();

      PsiClass psiClass = superMethod.getContainingClass();
      assert psiClass != null;
      String classFqNameString = psiClass.getQualifiedName();
      assert classFqNameString != null;
      FqName classFqName = new FqName(classFqNameString);

      if (!JavaToKotlinClassMap.getInstance().mapPlatformClass(classFqName).isEmpty()) {
        for (FunctionDescriptor superFun :
            JavaToKotlinMethodMap.INSTANCE.getFunctions(superMethod, containingClass)) {
          superFunctions.add(substituteSuperFunction(superclassToSupertype, superFun));
        }
        continue;
      }

      DeclarationDescriptor superFun =
          superMethod instanceof JetClsMethod
              ? trace.get(
                  BindingContext.DECLARATION_TO_DESCRIPTOR,
                  ((JetClsMethod) superMethod).getOrigin())
              : findSuperFunction(superclassToFunctions.get(classFqName), superMethod);
      if (superFun == null) {
        reportCantFindSuperFunction(method);
        continue;
      }

      assert superFun instanceof FunctionDescriptor : superFun.getClass().getName();

      superFunctions.add(
          substituteSuperFunction(superclassToSupertype, (FunctionDescriptor) superFun));
    }

    // sorting for diagnostic stability
    Collections.sort(
        superFunctions,
        new Comparator<FunctionDescriptor>() {
          @Override
          public int compare(FunctionDescriptor fun1, FunctionDescriptor fun2) {
            FqNameUnsafe fqName1 = getFQName(fun1.getContainingDeclaration());
            FqNameUnsafe fqName2 = getFQName(fun2.getContainingDeclaration());
            return fqName1.getFqName().compareTo(fqName2.getFqName());
          }
        });
    return superFunctions;
  }
示例#7
0
 private static void checkVariableArguments(
     List<FieldValue> values, int size, boolean allowNulls) {
   boolean success = (values.size() >= size) && (allowNulls ? true : !values.contains(null));
   if (!success) {
     throw new EvaluationException();
   }
 }
示例#8
0
    @Override
    public FieldValue evaluate(List<FieldValue> values) {

      if (values.size() != 2) {
        throw new EvaluationException();
      }

      FieldValue left = values.get(0);
      FieldValue right = values.get(1);

      // "If one of the input fields of a simple arithmetic function is a missing value, the result
      // evaluates to missing value"
      if (left == null || right == null) {
        return null;
      }

      DataType dataType = TypeUtil.getResultDataType(left.getDataType(), right.getDataType());

      Number result;

      try {
        result = evaluate(left.asNumber(), right.asNumber());
      } catch (ArithmeticException ae) {
        throw new InvalidResultException(null);
      }

      return FieldValueUtil.create(cast(dataType, result));
    }
示例#9
0
 private ImmutableList<ColumnIdent> getPartitionedBy() {
   ImmutableList.Builder<ColumnIdent> builder = ImmutableList.builder();
   for (List<String> partitionedByInfo : partitionedByList) {
     builder.add(ColumnIdent.fromPath(partitionedByInfo.get(0)));
   }
   return builder.build();
 }
示例#10
0
 final Set<UUID> getPlayers() {
   ImmutableSet.Builder<UUID> setBuilder = ImmutableSet.builder();
   if (pool != null) {
     try (Jedis rsc = pool.getResource()) {
       List<String> keys = new ArrayList<>();
       for (String i : getServerIds()) {
         keys.add("proxy:" + i + ":usersOnline");
       }
       if (!keys.isEmpty()) {
         Set<String> users = rsc.sunion(keys.toArray(new String[keys.size()]));
         if (users != null && !users.isEmpty()) {
           for (String user : users) {
             try {
               setBuilder = setBuilder.add(UUID.fromString(user));
             } catch (IllegalArgumentException ignored) {
             }
           }
         }
       }
     } catch (JedisConnectionException e) {
       // Redis server has disappeared!
       getLogger()
           .log(
               Level.SEVERE,
               "Unable to get connection from pool - did your Redis server go away?",
               e);
       throw new RuntimeException("Unable to get all players online", e);
     }
   }
   return setBuilder.build();
 }
 private void updateEstimatedCompactionsByTasks(List<List<SSTableReader>> tasks) {
   int n = 0;
   for (List<SSTableReader> bucket : tasks) {
     if (bucket.size() >= cfs.getMinimumCompactionThreshold())
       n += Math.ceil((double) bucket.size() / cfs.getMaximumCompactionThreshold());
   }
   estimatedRemainingTasks = n;
 }
  /**
   * 清除掉没有处于waiting on condition状态的线程
   *
   * @param rawDatas
   * @return
   */
  public List<String[]> remove(List<String[]> rawDatas) {
    List<String[]> pickedData = Lists.newArrayList();
    for (String[] temp : rawDatas) {
      if (temp[0].lastIndexOf("waiting on condition") > -1) pickedData.add(temp);
    }

    return pickedData;
  }
示例#13
0
    @Override
    public FieldValue evaluate(List<FieldValue> values) {
      checkVariableArguments(values, 2);

      Boolean result = evaluate(values.get(0), values.subList(1, values.size()));

      return FieldValueUtil.create(result);
    }
示例#14
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;
  }
  public static List<NameValuePair> convertAttributesToNameValuePair(
      Map<String, String> aAttributes) {
    List<NameValuePair> myNameValuePairs = Lists.newArrayList();

    for (Map.Entry<String, String> myEntry : aAttributes.entrySet()) {
      myNameValuePairs.add(new BasicNameValuePair(myEntry.getKey(), myEntry.getValue()));
    }
    return myNameValuePairs;
  }
示例#16
0
 public List<Range> getPendingRanges(String table, InetAddress endpoint) {
   List<Range> ranges = new ArrayList<Range>();
   for (Map.Entry<Range, InetAddress> entry : getPendingRangesMM(table).entries()) {
     if (entry.getValue().equals(endpoint)) {
       ranges.add(entry.getKey());
     }
   }
   return ranges;
 }
  private JavaDescriptorResolver.ValueParameterDescriptors
      modifyValueParametersAccordingToSuperMethods(
          @NotNull
              JavaDescriptorResolver.ValueParameterDescriptors
                  parameters // descriptors built by parameters resolver
          ) {
    // we are not processing receiver type specifically:
    // if this function comes from Kotlin, then we don't need to do it, if it doesn't, then it can't
    // have receiver

    List<ValueParameterDescriptor> resultParameters = Lists.newArrayList();

    for (ValueParameterDescriptor originalParam : parameters.getDescriptors()) {
      final int index = originalParam.getIndex();
      List<TypeAndVariance> typesFromSuperMethods =
          ContainerUtil.map(
              superFunctions,
              new Function<FunctionDescriptor, TypeAndVariance>() {
                @Override
                public TypeAndVariance fun(FunctionDescriptor superFunction) {
                  return new TypeAndVariance(
                      superFunction.getValueParameters().get(index).getType(), INVARIANT);
                }
              });

      VarargCheckResult varargCheckResult = checkVarargInSuperFunctions(originalParam);

      JetType altType =
          modifyTypeAccordingToSuperMethods(
              varargCheckResult.parameterType,
              typesFromSuperMethods,
              MEMBER_SIGNATURE_CONTRAVARIANT);

      resultParameters.add(
          new ValueParameterDescriptorImpl(
              originalParam.getContainingDeclaration(),
              index,
              originalParam.getAnnotations(),
              originalParam.getName(),
              altType,
              originalParam.declaresDefaultValue(),
              varargCheckResult.isVararg
                  ? KotlinBuiltIns.getInstance().getArrayElementType(altType)
                  : null));
    }

    JetType originalReceiverType = parameters.getReceiverType();
    if (originalReceiverType != null) {
      JetType substituted =
          SignaturesUtil.createSubstitutorForFunctionTypeParameters(autoTypeParameterToModified)
              .substitute(originalReceiverType, INVARIANT);
      assert substituted != null;
      return new JavaDescriptorResolver.ValueParameterDescriptors(substituted, resultParameters);
    } else {
      return new JavaDescriptorResolver.ValueParameterDescriptors(null, resultParameters);
    }
  }
示例#18
0
 /*
  * Recursive descent into subclusters.
  */
 private static void flatten(ArrayList<Cluster> flattened, Collection<Cluster> clusters) {
   for (Cluster c : clusters) {
     flattened.add(c);
     final List<Cluster> subclusters = c.getSubclusters();
     if (!subclusters.isEmpty()) {
       flatten(flattened, subclusters);
     }
   }
 }
示例#19
0
 @NotNull
 private static List<Label> copyLabels(
     Collection<Label> labels, Map<Label, Label> originalToCopy) {
   List<Label> newLabels = Lists.newArrayList();
   for (Label label : labels) {
     Label newLabel = originalToCopy.get(label);
     newLabels.add(newLabel != null ? newLabel : label);
   }
   return newLabels;
 }
示例#20
0
 /**
  * @param statType
  * @param statisticsStorage
  * @return Multiset<Integer> containing experiment counts across all efo attributes
  */
 public static Multiset<Integer> getScoresAcrossAllEfos(
     final StatisticsType statType, final StatisticsStorage statisticsStorage) {
   List<Attribute> efoAttrs = new ArrayList<Attribute>();
   for (String efo : statisticsStorage.getEfos()) {
     efoAttrs.add(new EfoAttribute(efo));
   }
   StatisticsQueryCondition statsQuery = new StatisticsQueryCondition(statType);
   statsQuery.and(getStatisticsOrQuery(efoAttrs, statType, 1, statisticsStorage));
   return getExperimentCounts(statsQuery, statisticsStorage, null);
 }
示例#21
0
 public String[] getParsedSlice(int index) {
   String[] slice = new String[parsedArgs.size() - index];
   System.arraycopy(
       parsedArgs.toArray(new String[parsedArgs.size()]),
       index,
       slice,
       0,
       parsedArgs.size() - index);
   return slice;
 }
示例#22
0
 public String[] getParsedPaddedSlice(int index, int padding) {
   String[] slice = new String[parsedArgs.size() - index + padding];
   System.arraycopy(
       parsedArgs.toArray(new String[parsedArgs.size()]),
       index,
       slice,
       padding,
       parsedArgs.size() - index);
   return slice;
 }
示例#23
0
    @Override
    public FieldValue evaluate(List<FieldValue> values) {
      checkArguments(values, 2);

      FieldValue left = values.get(0);
      FieldValue right = values.get(1);

      Boolean result = evaluate((left).compareToValue(right));

      return FieldValueUtil.create(result);
    }
 @NotNull
 private static List<TypeAndVariance> getTypes(
     @NotNull List<TypeProjectionAndVariance> projections) {
   List<TypeAndVariance> types = Lists.newArrayList();
   for (TypeProjectionAndVariance projection : projections) {
     types.add(
         new TypeAndVariance(
             projection.typeProjection.getType(),
             merge(projection.varianceOfPosition, projection.typeProjection.getProjectionKind())));
   }
   return types;
 }
示例#25
0
    @Override
    public FieldValue evaluate(List<FieldValue> values) {
      checkVariableArguments(values, 2);

      Boolean result = (values.get(0)).asBoolean();

      for (int i = 1; i < values.size(); i++) {
        result = evaluate(result, (values.get(i)).asBoolean());
      }

      return FieldValueUtil.create(result);
    }
示例#26
0
 @Override
 public Iterable<DataKey> getSubKeys() {
   final Tag tag = this.findLastTag(this.path, false);
   if (!(tag instanceof CompoundTag)) {
     return (Iterable<DataKey>) Collections.emptyList();
   }
   final List<DataKey> subKeys = (List<DataKey>) Lists.newArrayList();
   for (final String name : ((CompoundTag) tag).getValue().keySet()) {
     subKeys.add(new NBTKey(this.createRelativeKey(name)));
   }
   return subKeys;
 }
 public ControllerRequest(Class<? extends Controller> controllerClass, Matcher matchedUrl) {
   this.controllerClass = controllerClass;
   if (matchedUrl.groupCount() > 0) {
     List<String> argsList = new ArrayList<String>(matchedUrl.groupCount());
     for (int i = 1; i <= matchedUrl.groupCount(); i++) {
       argsList.add(matchedUrl.group(i));
     }
     this.args = argsList;
   } else {
     this.args = new ArrayList<String>(0);
   }
 }
  @Override
  public synchronized AbstractCompactionTask getNextBackgroundTask(int gcBefore) {
    if (!isEnabled()) return null;

    while (true) {
      List<SSTableReader> latestBucket = getNextBackgroundSSTables(gcBefore);

      if (latestBucket.isEmpty()) return null;

      if (cfs.getDataTracker().markCompacting(latestBucket))
        return new CompactionTask(cfs, latestBucket, gcBefore, false);
    }
  }
示例#29
0
  public static QuantileDigest merge(List<QuantileDigest> digests) {
    if (digests.isEmpty()) {
      throw new RuntimeException("Digests to be unioned should not be empty!");
    }

    QuantileDigest ret = digests.get(0);

    for (int i = 1; i < digests.size(); i++) {
      ret.merge(digests.get(i));
    }

    return ret;
  }
示例#30
0
 @Override
 public Iterable<Vertex> getVertices() {
   if (!addedRelations.isEmpty()) {
     // There are possible new vertices
     List<Vertex> newVs = new ArrayList<Vertex>();
     for (InternalVertex v : vertexCache.getAll()) {
       if (v.isNew() && !(v instanceof TitanType)) newVs.add(v);
     }
     return Iterables.concat(newVs, new VertexIterable(graph, this));
   } else {
     return (Iterable) new VertexIterable(graph, this);
   }
 }