public static ImmutableList <AclEntry> ToAclEntries(int[] entries) { ImmutableList.Builder <AclEntry> b = new ImmutableList.Builder <AclEntry>(); foreach (int entry in entries) { AclEntry aclEntry = ToAclEntry(entry); b.Add(aclEntry); } return((ImmutableList <AclEntry>)b.Build()); }
/// <param name="offset">start endpoint (inclusive)</param> /// <param name="length">number of path components</param> /// <returns>sub-list of the path</returns> public virtual IList <string> GetPath(int offset, int length) { Preconditions.CheckArgument(offset >= 0 && length >= 0 && offset + length <= path .Length); ImmutableList.Builder <string> components = ImmutableList.Builder(); for (int i = offset; i < offset + length; i++) { components.Add(DFSUtil.Bytes2String(path[i])); } return((ImmutableList <string>)components.Build()); }
public static ImmutableList <QuotaByStorageTypeEntry> LoadQuotaByStorageTypeEntries (FsImageProto.INodeSection.QuotaByStorageTypeFeatureProto proto) { ImmutableList.Builder <QuotaByStorageTypeEntry> b = ImmutableList.Builder(); foreach (FsImageProto.INodeSection.QuotaByStorageTypeEntryProto quotaEntry in proto .GetQuotasList()) { StorageType type = PBHelper.ConvertStorageType(quotaEntry.GetStorageType()); long quota = quotaEntry.GetQuota(); b.Add(new QuotaByStorageTypeEntry.Builder().SetStorageType(type).SetQuota(quota). Build()); } return((ImmutableList <QuotaByStorageTypeEntry>)b.Build()); }
public ImmutableList <CompressDecompressTester.TesterPair <T, E> > FilterOnAssumeWhat (ImmutableList <CompressDecompressTester.TesterPair <T, E> > pairs) { ImmutableList.Builder <CompressDecompressTester.TesterPair <T, E> > builder = ImmutableList .Builder(); foreach (CompressDecompressTester.TesterPair <T, E> pair in pairs) { if (Org.Apache.Hadoop.IO.Compress.CompressDecompressTester.IsAvailable(pair)) { builder.Add(pair); } } return((ImmutableList <CompressDecompressTester.TesterPair <T, E> >)builder.Build() ); }
internal static ImmutableList <AclEntry> GetEntriesFromAclFeature(AclFeature aclFeature ) { if (aclFeature == null) { return(ImmutableList.Of <AclEntry>()); } ImmutableList.Builder <AclEntry> b = new ImmutableList.Builder <AclEntry>(); for (int pos = 0; pos < aclFeature.GetEntriesSize(); pos++) { entry = aclFeature.GetEntryAt(pos); b.Add(AclEntryStatusFormat.ToAclEntry(entry)); } return((ImmutableList <AclEntry>)b.Build()); }
public static ImmutableList <AclEntry> LoadAclEntries(FsImageProto.INodeSection.AclFeatureProto proto, string[] stringTable) { ImmutableList.Builder <AclEntry> b = ImmutableList.Builder(); foreach (int v in proto.GetEntriesList()) { int p = v & AclEntryPermMask; int t = (v >> AclEntryTypeOffset) & AclEntryTypeMask; int s = (v >> AclEntryScopeOffset) & AclEntryScopeMask; int nid = (v >> AclEntryNameOffset) & AclEntryNameMask; string name = stringTable[nid]; b.Add(new AclEntry.Builder().SetName(name).SetPermission(FsactionValues[p]).SetScope (AclEntryScopeValues[s]).SetType(AclEntryTypeValues[t]).Build()); } return((ImmutableList <AclEntry>)b.Build()); }
/// <exception cref="System.IO.IOException"/> private static ImmutableList <long> LoadINodeReferenceSection(InputStream @in) { Log.Info("Loading inode references"); ImmutableList.Builder <long> builder = ImmutableList.Builder(); long counter = 0; while (true) { FsImageProto.INodeReferenceSection.INodeReference e = FsImageProto.INodeReferenceSection.INodeReference .ParseDelimitedFrom(@in); if (e == null) { break; } ++counter; builder.Add(e.GetReferredId()); } Log.Info("Loaded " + counter + " inode references"); return((ImmutableList <long>)builder.Build()); }
public static ImmutableList <XAttr> LoadXAttrs(FsImageProto.INodeSection.XAttrFeatureProto proto, string[] stringTable) { ImmutableList.Builder <XAttr> b = ImmutableList.Builder(); foreach (FsImageProto.INodeSection.XAttrCompactProto xAttrCompactProto in proto.GetXAttrsList ()) { int v = xAttrCompactProto.GetName(); int nid = (v >> XattrNameOffset) & XattrNameMask; int ns = (v >> XattrNamespaceOffset) & XattrNamespaceMask; ns |= ((v >> XattrNamespaceExtOffset) & XattrNamespaceExtMask) << 2; string name = stringTable[nid]; byte[] value = null; if (xAttrCompactProto.GetValue() != null) { value = xAttrCompactProto.GetValue().ToByteArray(); } b.Add(new XAttr.Builder().SetNameSpace(XattrNamespaceValues[ns]).SetName(name).SetValue (value).Build()); } return((ImmutableList <XAttr>)b.Build()); }
public override void AssertWhat(Filter filter, int numInsertions, int hashId, ImmutableSet <int> falsePositives) { Random rnd = new Random(); DataOutputBuffer @out = new DataOutputBuffer(); DataInputBuffer @in = new DataInputBuffer(); try { Filter tempFilter = BloomFilterCommonTester.GetSymmetricFilter(filter.GetType(), numInsertions, hashId); ImmutableList.Builder <int> blist = ImmutableList.Builder(); for (int i = 0; i < this.slotSize; i++) { blist.Add(rnd.Next(numInsertions * 2)); } ImmutableList <int> list = ((ImmutableList <int>)blist.Build()); // mark bits for later check foreach (int slot in list) { filter.Add(new Key(Runtime.GetBytesForString(slot.ToString()))); } filter.Write(@out); @in.Reset(@out.GetData(), @out.GetLength()); tempFilter.ReadFields(@in); foreach (int slot_1 in list) { Assert.True("read/write mask check filter error on " + slot_1, filter.MembershipTest(new Key(Runtime.GetBytesForString(slot_1.ToString( ))))); } } catch (IOException ex) { NUnit.Framework.Assert.Fail("error ex !!!" + ex); } }