Returns the clustering key contained in the specified Lucene field value.

@param bytesRef The {@link BytesRef} containing the raw clustering key to be get.
@return The clustering key contained in the specified Lucene field value.
517523
public final CellName clusteringKey(BytesRef bytesRef) {
        String string = bytesRef.utf8ToString();
        ByteBuffer bb = ByteBufferUtils.fromString(string);
        return cellNameType.cellFromByteBuffer(bb);
    }
1101558
public final int getDBIndex(byte[] key) {
        if(key == null) return -1;
        
        byte[] metaBytes = _index.lookup(key);
        if(metaBytes == null) return -1;
        
        IndexMeta meta = IndexMeta.parse(metaBytes);
        if(meta == null) return -1;
        
        return meta.getDataAddr();
    }
856151
private int getIndex(PdfName key) {
		for (int i = 0; i < VIEWER_PREFERENCES.length; i++) {
			if (VIEWER_PREFERENCES[i].equals(key))
				return i;
		}
		return -1;
	}
80375
protected String getKey(final String ref, final String filename, final String extension) {
        return prefix + ref + "/" + filename + "." + extension;
    }
980147
public static CellNameType getIndexComparator(CFMetaData baseMetadata, ColumnDefinition cfDef)
    {
        if (cfDef.type.isCollection() && cfDef.type.isMultiCell())
        {
            switch (((CollectionType)cfDef.type).kind)
            {
                case LIST:
                    return CompositesIndexOnCollectionValue.buildIndexComparator(baseMetadata, cfDef);
                case SET:
                    return CompositesIndexOnCollectionKey.buildIndexComparator(baseMetadata, cfDef);
                case MAP:
                    return cfDef.hasIndexOption(SecondaryIndex.INDEX_KEYS_OPTION_NAME)
                         ? CompositesIndexOnCollectionKey.buildIndexComparator(baseMetadata, cfDef)
                         : CompositesIndexOnCollectionValue.buildIndexComparator(baseMetadata, cfDef);
            }
        }

        switch (cfDef.kind)
        {
            case CLUSTERING_COLUMN:
                return CompositesIndexOnClusteringKey.buildIndexComparator(baseMetadata, cfDef);
            case REGULAR:
                return CompositesIndexOnRegular.buildIndexComparator(baseMetadata, cfDef);
            case PARTITION_KEY:
                return CompositesIndexOnPartitionKey.buildIndexComparator(baseMetadata, cfDef);
            //case COMPACT_VALUE:
            //    return CompositesIndexOnCompactValue.buildIndexComparator(baseMetadata, cfDef);
        }
        throw new AssertionError();
    }
350851
def touidref(src, dst, src_relation, src_portal_type, fieldname):
    
    field = dst.getField(fieldname)
    refs = src.getRefs(relationship=src_relation)

    if len(refs) == 1:
        value = get_uid(refs[0])
    elif len(refs) > 1:
        value = filter(lambda x: x, [get_uid(ref) for ref in refs])
    else:
        value = field.get(src)
    if not value:
        value = ''
    if not field:
        raise RuntimeError('Cannot find field %s/%s' % (fieldname, src))
    if field.required and not value:
        logger.exception('Required %s field %s/%s has no value' %
                         (src.portal_type, src, fieldname))
    field.set(src, value)
621583
@Override
  protected Bitmap decodeByteArrayAsPurgeable(
      CloseableReference<PooledByteBuffer> bytesRef, BitmapFactory.Options options) {
    final PooledByteBuffer pooledByteBuffer = bytesRef.get();
    final int length = pooledByteBuffer.size();
    final CloseableReference<byte[]> encodedBytesArrayRef = mFlexByteArrayPool.get(length);
    try {
      final byte[] encodedBytesArray = encodedBytesArrayRef.get();
      pooledByteBuffer.read(0, encodedBytesArray, 0, length);
      Bitmap bitmap = BitmapFactory.decodeByteArray(
          encodedBytesArray,
          0,
          length,
          options);
      return Preconditions.checkNotNull(bitmap, "BitmapFactory returned null");
    } finally {
      CloseableReference.closeSafely(encodedBytesArrayRef);
    }
  }
707119
@Override
	protected Reader getContentReader(String mid, IResource resource, HttpServletRequest request,
			MutableObject<List<ICacheKeyGenerator>> keyGensRef) throws IOException {

		final String sourceMethod = "getContentReader"; //$NON-NLS-1$
		final boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(sourceClass, sourceMethod, new Object[]{mid, resource, request, keyGensRef});
		}

		// Call super class implementation and determine if we need to update the cache key generators
		Reader result = super.getContentReader(mid, resource, request, keyGensRef);
		if (isFeatureDependent) {
			List<ICacheKeyGenerator> keyGens = keyGensRef.getValue();
			if (resource.getPath().toLowerCase().endsWith(LESS_SUFFIX)) {
				Set<String> dependentFeatures = threadLocalDependentFeatures.get();
				if (keyGens == null) {
					keyGens = getCacheKeyGenerators(getAggregator());
				}
				FeatureSetCacheKeyGenerator fsKeyGen = (FeatureSetCacheKeyGenerator)keyGens.get(2);
				// Cache key generators need to be updated if existing one is provisional or if there are new dependent features
				if (fsKeyGen.isProvisional() || !fsKeyGen.getFeatureSet().containsAll(dependentFeatures)) {
					List<ICacheKeyGenerator> newKeyGens = new ArrayList<ICacheKeyGenerator>();
					newKeyGens.add(keyGens.get(0));
					newKeyGens.add(keyGens.get(1));
					FeatureSetCacheKeyGenerator newFsKeyGen = new FeatureSetCacheKeyGenerator(dependentFeatures, false);
					newKeyGens.add(newFsKeyGen.combine(fsKeyGen));
					keyGensRef.setValue(newKeyGens);
					if (isTraceLogging) {
						log.logp(Level.FINER, sourceClass, sourceMethod, "Key generators updated: " + KeyGenUtil.toString(newKeyGens)); //$NON-NLS-1$
					}
				}
			} else {
				// We're processing a CSS file.  See if we need to provide key gens
				if (keyGens == null) {
					keyGensRef.setValue(super.getCacheKeyGenerators(getAggregator()));
				}
			}
		}
		if (isTraceLogging) {
			log.exiting(sourceClass, sourceMethod, result);
		}
		return result;
	}
871975
def get_labels(self, field):
        """"""
        return {c: self.cluster_meta.get(field, c)
                for c in self.clustering.cluster_ids}
1191271
@Override
  public byte[] toBytes(HdfsStatsKey hdfsStatsKey) {
    if (hdfsStatsKey == null || hdfsStatsKey.getQualifiedPathKey() == null) {
      return HdfsConstants.EMPTY_BYTES;
    } else {
      if (StringUtils.isBlank(hdfsStatsKey.getQualifiedPathKey().getNamespace())) {
        // hadoop1 or non federated namespace
        return ByteUtil.join(HdfsConstants.SEP_BYTES,
          Bytes.toBytes(Long.toString(hdfsStatsKey.getEncodedRunId())),
          Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getCluster()),
          Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getPath()));
      } else {
        // include federated namespace
        return ByteUtil.join(HdfsConstants.SEP_BYTES,
          Bytes.toBytes(Long.toString(hdfsStatsKey.getEncodedRunId())),
          Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getCluster()),
          Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getPath()),
          Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getNamespace()));
      }
    }
  }
672112
public static String getByteArrayDataAsString(String contentEncoding, byte[] bytes) {
        ByteArrayOutputStream byteout = null;
        if (contentEncoding != null &&
                contentEncoding.equals("gzip")) {
            // GZIP
            ByteArrayInputStream bytein = null;
            GZIPInputStream zis = null;
            try {
                bytein = new ByteArrayInputStream(bytes);
                zis = new GZIPInputStream(bytein);
                byteout = new ByteArrayOutputStream();

                int res = 0;
                byte buf[] = new byte[1024];
                while (res >= 0) {
                    res = zis.read(buf, 0, buf.length);
                    if (res > 0) {
                        byteout.write(buf, 0, res);
                    }
                }

                zis.close();
                bytein.close();
                byteout.close();
                return byteout.toString();
            } catch (Exception e) {
                // No action to take
            }
        } else if (contentEncoding != null &&
                contentEncoding.equals("deflate")) {
            try {
                // DEFLATE
                byte[] buffer = new byte[1024];
                Inflater decompresser = new Inflater();
                byteout = new ByteArrayOutputStream();
                decompresser.setInput(bytes);
                while (!decompresser.finished()) {
                    int count = decompresser.inflate(buffer);
                    byteout.write(buffer, 0, count);
                }
                byteout.close();
                decompresser.end();

                return byteout.toString();
            } catch (Exception e) {
                // No action to take
            }
        }

        return new String(bytes);
    }
294723
public com.google.protobuf.ByteString
      getRefererBytes() {
    java.lang.Object ref = referer_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      referer_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
487202
@Override
    public byte[] getKey() {
        StringBuilder sb = new StringBuilder(64);
        sb.append(clusterName).append(MetricUtils.AT).append(topologyId).append(MetricUtils.AT)
                .append(metaType).append(MetricUtils.AT).append(id);
        return sb.toString().getBytes();
    }
1207779
static ByteBuffer getRowKeyRaw(int shardId, long tableUuid, byte[] contentKeyBytes) {
        checkArgument(shardId >= 0 && shardId < 256);

        // Assemble a single array which is "1 byte shard id + 8 byte table uuid + n-byte content key".
        ByteBuffer rowKey = ByteBuffer.allocate(9 + contentKeyBytes.length);
        rowKey.put((byte) shardId);
        rowKey.putLong(tableUuid);
        rowKey.put(contentKeyBytes);

        rowKey.flip();
        return rowKey;
    }
1220243
@Override
    public IWordDeserializer getDeserializer(HLLType type, int wordLength, byte[] bytes) {
        return new BigEndianAscendingWordDeserializer(wordLength, paddingBytes(type), bytes);
    }
1315732
public static ByteSink asCompressedByteSink(File f) throws IOException {
    return GZIPByteSink.gzipCompress(Files.asByteSink(f));
  }
1007800
@Nonnull
  public static ISimpleURL getAsURLData (@Nonnull final String sHref,
                                         @Nullable final IDecoder <String, String> aParameterDecoder)
  {
    ValueEnforcer.notNull (sHref, "Href");

    final String sRealHref = sHref.trim ();

    // Is it a protocol that does not allow for query parameters?
    final IURLProtocol eProtocol = URLProtocolRegistry.getInstance ().getProtocol (sRealHref);
    if (eProtocol != null && !eProtocol.allowsForQueryParameters ())
      return new URLData (sRealHref, null, null);

    if (GlobalDebug.isDebugMode ())
      if (eProtocol != null)
        try
        {
          new URL (sRealHref);
        }
        catch (final MalformedURLException ex)
        {
          if (LOGGER.isWarnEnabled ())
            LOGGER.warn ("java.net.URL claims URL '" + sRealHref + "' to be invalid: " + ex.getMessage ());
        }

    String sPath;
    URLParameterList aParams = null;
    String sAnchor;

    // First get the anchor out
    String sRemainingHref = sRealHref;
    final int nIndexAnchor = sRemainingHref.indexOf (HASH);
    if (nIndexAnchor >= 0)
    {
      // Extract anchor
      sAnchor = sRemainingHref.substring (nIndexAnchor + 1).trim ();
      sRemainingHref = sRemainingHref.substring (0, nIndexAnchor).trim ();
    }
    else
      sAnchor = null;

    // Find parameters
    final int nQuestionIndex = sRemainingHref.indexOf (QUESTIONMARK);
    if (nQuestionIndex >= 0)
    {
      // Use everything after the '?'
      final String sQueryString = sRemainingHref.substring (nQuestionIndex + 1).trim ();

      // Maybe empty, if the URL ends with a '?'
      if (StringHelper.hasText (sQueryString))
        aParams = getParsedQueryParameters (sQueryString, aParameterDecoder);

      sPath = sRemainingHref.substring (0, nQuestionIndex).trim ();
    }
    else
      sPath = sRemainingHref;

    return new URLData (sPath, aParams, sAnchor);
  }