private static BigInteger CalculateRef(byte[] initIV, long counter) { byte[] cb = Longs.ToByteArray(counter); BigInteger bi = new BigInteger(1, initIV); return(bi.Add(new BigInteger(1, cb))); }
/// <summary> /// Create a new cyclic vertex search for the provided graph. /// </summary> /// <param name="graph">adjacency list representation of a graph</param> internal RegularCyclicVertexSearch(IReadOnlyList <IReadOnlyList <int> > graph) { this.g = graph; int n = graph.Count; // skip search if empty graph if (n == 0) { return; } state = new long[n]; // start from vertex 0 Search(0, 0L, 0L); // if disconnected we have not visited all vertices int v = 1; while (Longs.BitCount(visited) != n) { // haven't visited v, start a new search from there if (!Visited(v)) { Search(v, 0L, 0L); } v++; } // no longer needed for the lifetime of the object state = null; }
public EUID(byte[] bytes) { byte[] newBytes = Extend(bytes); long high = Longs.FromByteArray(newBytes, 0); long low = Longs.FromByteArray(newBytes, 8); _value = Int128.Create(low, high); }
public static void releaseDocs(Longs docs) { touchvgPINVOKE.GiCoreView_releaseDocs(Longs.getCPtr(docs)); if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } }
public static void releaseShapesArray(Longs shapes) { touchvgPINVOKE.GiCoreView_releaseShapesArray(Longs.getCPtr(shapes)); if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } }
public virtual void TestLongFieldCache() { Directory dir = NewDirectory(); IndexWriterConfig cfg = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())); cfg.SetMergePolicy(NewLogMergePolicy()); RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, cfg); Document doc = new Document(); LongField field = new LongField("f", 0L, Field.Store.YES); doc.Add(field); long[] values = new long[TestUtil.NextInt(Random(), 1, 10)]; for (int i = 0; i < values.Length; ++i) { long v; switch (Random().Next(10)) { case 0: v = long.MinValue; break; case 1: v = 0; break; case 2: v = long.MaxValue; break; default: v = TestUtil.NextLong(Random(), -10, 10); break; } values[i] = v; if (v == 0 && Random().NextBoolean()) { // missing iw.AddDocument(new Document()); } else { field.LongValue = v; iw.AddDocument(doc); } } iw.ForceMerge(1); DirectoryReader reader = iw.Reader; Longs longs = FieldCache.DEFAULT.GetLongs(GetOnlySegmentReader(reader), "f", false); for (int i = 0; i < values.Length; ++i) { Assert.AreEqual(values[i], longs.Get(i)); } reader.Dispose(); iw.Dispose(); dir.Dispose(); }
public int drawAll(Longs docs, int gs, GiCanvas canvas, Ints ignoreIds) { int ret = touchvgPINVOKE.GiCoreView_drawAll__SWIG_2(swigCPtr, Longs.getCPtr(docs), gs, GiCanvas.getCPtr(canvas), Ints.getCPtr(ignoreIds)); if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public int dynDraw(Longs shapes, int gs, GiCanvas canvas) { int ret = touchvgPINVOKE.GiCoreView_dynDraw__SWIG_1(swigCPtr, Longs.getCPtr(shapes), gs, GiCanvas.getCPtr(canvas)); if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public int acquireFrontDocs(Longs docs) { int ret = touchvgPINVOKE.GiCoreView_acquireFrontDocs(swigCPtr, Longs.getCPtr(docs)); if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public int acquireDynamicShapesArray(Longs shapes) { int ret = touchvgPINVOKE.GiCoreView_acquireDynamicShapesArray(swigCPtr, Longs.getCPtr(shapes)); if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public void TestNumberOfTrailingZeros() { for (int i = 0; i < 63; ++i) { Assert.AreEqual(i, Longs.NumberOfTrailingZeros(1L << i)); Assert.AreEqual(i, Longs.NumberOfTrailingZeros(-1L << i)); } Assert.AreEqual(63, Longs.NumberOfTrailingZeros(long.MinValue)); Assert.AreEqual(64, Longs.NumberOfTrailingZeros(0L)); }
public void TestNumberOfLeadingZeros() { for (int i = 0; i < 63; ++i) { Assert.AreEqual(i, Longs.NumberOfLeadingZeros((long)(0x8000000000000000UL >> i))); Assert.AreEqual(i, Longs.NumberOfLeadingZeros((long)(0xFFFFFFFFFFFFFFFFUL >> i))); } Assert.AreEqual(63, Longs.NumberOfLeadingZeros(1L)); Assert.AreEqual(64, Longs.NumberOfLeadingZeros(0L)); }
/// <summary> /// Find the next index that the <i>cycle</i> intersects with by at least two /// vertices. If the intersect of a vertex set with another contains more /// then two vertices it cannot be edge disjoint. /// </summary> /// <param name="start">start searching from here</param> /// <param name="cycle">test whether any current cycles are fused with this one</param> /// <returns>the index of the first fused after 'start', -1 if none</returns> private int IndexOfFused(int start, long cycle) { for (int i = start; i < cycles.Count(); i++) { long intersect = cycles[i] & cycle; if (intersect != 0 && Longs.BitCount(intersect) > 1) { return(i); } } return(-1); }
public Form1() { InitializeComponent(); FM = new FormMgr(this); WindowMessages = Sender.AllWMMessages(); SendMessageMessage.Items.AddRange(WindowMessages.ToArray()); SendMessageResult.Text = ""; Longs = Sender.AllGWLs(); SetWindowLongIndex.Items.AddRange(Longs.ToArray()); SetWindowLongLong_SingleSelect.Visible = true; SetWindowLongLong_MultiSelect.Visible = false; }
internal static ILayout GetLayout(string dataType, Config config, FieldConfig fieldConfig) { string vtype = string.Empty; if (Shorts.Contains(dataType) || Integers.Contains(dataType) || Longs.Contains(dataType)) { vtype = "int"; if (dataType.EndsWith("_strict")) { vtype = "int-strict"; } if (dataType.EndsWith("_strict2")) { vtype = "int-strict2"; } return(new TextBox(config, fieldConfig, vtype)); } if (Decimals.Contains(dataType)) { vtype = "dec"; if (dataType.EndsWith("_strict")) { vtype = "dec-strict"; } if (dataType.EndsWith("_strict2")) { vtype = "dec-strict2"; } return(new TextBox(config, fieldConfig, vtype)); } if (Bools.Contains(dataType)) { return(new Radios(config, fieldConfig)); } if (Dates.Contains(dataType)) { return(new TextBox(config, fieldConfig, "date")); } return(Files.Contains(dataType) ? new TextBox(config, fieldConfig, "file") : new TextBox(config, fieldConfig)); }
/// <summary> /// Convert the bits of a <see cref="long"/> to an array of integers. The size of /// the output array is the number of bits set in the value. /// </summary> /// <param name="set">value to convert</param> /// <returns>array of the set bits in the long value</returns> internal static int[] ToArray(long set) { int[] vertices = new int[Longs.BitCount(set)]; int i = 0; // fill the cyclic vertices with the bits that have been set for (int v = 0; i < vertices.Length; v++) { if (IsBitSet(set, v)) { vertices[i++] = v; } } return(vertices); }
/// <summary> /// Add the cycle vertices to our discovered cycles. The cycle is first /// checked to see if it is isolated (shares at most one vertex) or /// <i>potentially</i> fused. /// </summary> /// <param name="cycle">newly discovered cyclic vertex set</param> private void Add(long cycle) { long intersect = cyclic & cycle; // intersect by more then 1 vertex, we 'may' have a fused cycle if (intersect != 0 && Longs.BitCount(intersect) > 1) { AddFused(cycle); } else { AddIsolated(cycle); } cyclic |= cycle; }
/// <exception cref="System.IO.IOException"/> private void LazyOpen() { if (ch != null) { return; } // Load current value. byte[] data = null; try { data = Files.ToByteArray(file); } catch (FileNotFoundException) { } // Expected - this will use default value. if (data != null && data.Length != 0) { if (data.Length != Longs.Bytes) { throw new IOException("File " + file + " had invalid length: " + data.Length); } value = Longs.FromByteArray(data); } else { value = defaultVal; } // Now open file for future writes. RandomAccessFile raf = new RandomAccessFile(file, "rw"); try { ch = raf.GetChannel(); } finally { if (ch == null) { IOUtils.CloseStream(raf); } } }
/// <exception cref="Com.Google.Protobuf.ServiceException"/> public virtual ClientDatanodeProtocolProtos.GetHdfsBlockLocationsResponseProto GetHdfsBlockLocations (RpcController controller, ClientDatanodeProtocolProtos.GetHdfsBlockLocationsRequestProto request) { HdfsBlocksMetadata resp; try { string poolId = request.GetBlockPoolId(); IList <Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> > tokens = new AList <Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> >(request.GetTokensCount ()); foreach (SecurityProtos.TokenProto b in request.GetTokensList()) { tokens.AddItem(PBHelper.Convert(b)); } long[] blockIds = Longs.ToArray(request.GetBlockIdsList()); // Call the real implementation resp = impl.GetHdfsBlocksMetadata(poolId, blockIds, tokens); } catch (IOException e) { throw new ServiceException(e); } IList <ByteString> volumeIdsByteStrings = new AList <ByteString>(resp.GetVolumeIds( ).Count); foreach (byte[] b_1 in resp.GetVolumeIds()) { volumeIdsByteStrings.AddItem(ByteString.CopyFrom(b_1)); } // Build and return the response ClientDatanodeProtocolProtos.GetHdfsBlockLocationsResponseProto.Builder builder = ClientDatanodeProtocolProtos.GetHdfsBlockLocationsResponseProto.NewBuilder(); builder.AddAllVolumeIds(volumeIdsByteStrings); builder.AddAllVolumeIndexes(resp.GetVolumeIndexes()); return((ClientDatanodeProtocolProtos.GetHdfsBlockLocationsResponseProto)builder. Build()); }
public int acquireFrontDocs(Longs docs) { int ret = touchvgPINVOKE.GiCoreView_acquireFrontDocs(swigCPtr, Longs.getCPtr(docs)); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public int acquireDynamicShapesArray(Longs shapes) { int ret = touchvgPINVOKE.GiCoreView_acquireDynamicShapesArray(swigCPtr, Longs.getCPtr(shapes)); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void releaseShapesArray(Longs shapes) { touchvgPINVOKE.GiCoreView_releaseShapesArray(Longs.getCPtr(shapes)); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); }
public static void releaseDocs(Longs docs) { touchvgPINVOKE.GiCoreView_releaseDocs(Longs.getCPtr(docs)); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); }
public bool recordShapes(bool forUndo, int tick, int changeCount, int doc, int shapes, Longs exts) { bool ret = touchvgPINVOKE.GiCoreView_recordShapes__SWIG_2(swigCPtr, forUndo, tick, changeCount, doc, shapes, Longs.getCPtr(exts)); return ret; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Longs obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
public int drawAll(Longs docs, int gs, GiCanvas canvas, Ints ignoreIds) { int ret = touchvgPINVOKE.GiCoreView_drawAll__SWIG_2(swigCPtr, Longs.getCPtr(docs), gs, GiCanvas.getCPtr(canvas), Ints.getCPtr(ignoreIds)); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public override string ToString() { return("Metadata for " + blockIds.Length + " blocks in " + blockPoolId + ": " + Joiner .On(",").Join(Longs.AsList(blockIds))); }
/// <exception cref="System.IO.IOException"/> public virtual HdfsBlocksMetadata GetHdfsBlocksMetadata(string blockPoolId, long[] blockIds, IList <Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> > tokens ) { IList <SecurityProtos.TokenProto> tokensProtos = new AList <SecurityProtos.TokenProto >(tokens.Count); foreach (Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> t in tokens) { tokensProtos.AddItem(PBHelper.Convert(t)); } // Build the request ClientDatanodeProtocolProtos.GetHdfsBlockLocationsRequestProto request = ((ClientDatanodeProtocolProtos.GetHdfsBlockLocationsRequestProto )ClientDatanodeProtocolProtos.GetHdfsBlockLocationsRequestProto.NewBuilder().SetBlockPoolId (blockPoolId).AddAllBlockIds(Longs.AsList(blockIds)).AddAllTokens(tokensProtos). Build()); // Send the RPC ClientDatanodeProtocolProtos.GetHdfsBlockLocationsResponseProto response; try { response = rpcProxy.GetHdfsBlockLocations(NullController, request); } catch (ServiceException e) { throw ProtobufHelper.GetRemoteException(e); } // List of volumes in the response IList <ByteString> volumeIdsByteStrings = response.GetVolumeIdsList(); IList <byte[]> volumeIds = new AList <byte[]>(volumeIdsByteStrings.Count); foreach (ByteString bs in volumeIdsByteStrings) { volumeIds.AddItem(bs.ToByteArray()); } // Array of indexes into the list of volumes, one per block IList <int> volumeIndexes = response.GetVolumeIndexesList(); // Parsed HdfsVolumeId values, one per block return(new HdfsBlocksMetadata(blockPoolId, blockIds, volumeIds, volumeIndexes)); }
public bool recordShapes(bool forUndo, int tick, int changeCount, int doc, int shapes, Longs exts) { bool ret = touchvgPINVOKE.GiCoreView_recordShapes__SWIG_2(swigCPtr, forUndo, tick, changeCount, doc, shapes, Longs.getCPtr(exts)); return(ret); }
public int Compare(EditLogInputStream a, EditLogInputStream b) { return(Longs.Compare(b.GetLastTxId(), a.GetLastTxId())); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Longs obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public int dynDraw(Longs shapes, int gs, GiCanvas canvas) { int ret = touchvgPINVOKE.GiCoreView_dynDraw__SWIG_1(swigCPtr, Longs.getCPtr(shapes), gs, GiCanvas.getCPtr(canvas)); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
internal static void Multiply(ulong[] x, ulong[] y) { //ulong x0 = x[0], x1 = x[1]; //ulong y0 = y[0], y1 = y[1]; //ulong z0 = 0, z1 = 0, z2 = 0; //for (int j = 0; j < 64; ++j) //{ // ulong m0 = (ulong)((long)x0 >> 63); x0 <<= 1; // z0 ^= (y0 & m0); // z1 ^= (y1 & m0); // ulong m1 = (ulong)((long)x1 >> 63); x1 <<= 1; // z1 ^= (y0 & m1); // z2 ^= (y1 & m1); // ulong c = (ulong)((long)(y1 << 63) >> 8); // y1 = (y1 >> 1) | (y0 << 63); // y0 = (y0 >> 1) ^ (c & E1UL); //} //z0 ^= z2 ^ (z2 >> 1) ^ (z2 >> 2) ^ (z2 >> 7); //z1 ^= (z2 << 63) ^ (z2 << 62) ^ (z2 << 57); //x[0] = z0; //x[1] = z1; /* * "Three-way recursion" as described in "Batch binary Edwards", Daniel J. Bernstein. * * Without access to the high part of a 64x64 product x * y, we use a bit reversal to calculate it: * rev(x) * rev(y) == rev((x * y) << 1) */ ulong x0 = x[0], x1 = x[1]; ulong y0 = y[0], y1 = y[1]; ulong x0r = Longs.Reverse(x0), x1r = Longs.Reverse(x1); ulong y0r = Longs.Reverse(y0), y1r = Longs.Reverse(y1); ulong h0 = Longs.Reverse(ImplMul64(x0r, y0r)); ulong h1 = ImplMul64(x0, y0) << 1; ulong h2 = Longs.Reverse(ImplMul64(x1r, y1r)); ulong h3 = ImplMul64(x1, y1) << 1; ulong h4 = Longs.Reverse(ImplMul64(x0r ^ x1r, y0r ^ y1r)); ulong h5 = ImplMul64(x0 ^ x1, y0 ^ y1) << 1; ulong z0 = h0; ulong z1 = h1 ^ h0 ^ h2 ^ h4; ulong z2 = h2 ^ h1 ^ h3 ^ h5; ulong z3 = h3; z1 ^= z3 ^ (z3 >> 1) ^ (z3 >> 2) ^ (z3 >> 7); // z2 ^= (z3 << 63) ^ (z3 << 62) ^ (z3 << 57); z2 ^= (z3 << 62) ^ (z3 << 57); z0 ^= z2 ^ (z2 >> 1) ^ (z2 >> 2) ^ (z2 >> 7); z1 ^= (z2 << 63) ^ (z2 << 62) ^ (z2 << 57); x[0] = z0; x[1] = z1; }
public virtual void TestNonIndexedFields() { Directory dir = NewDirectory(); RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, Similarity, TimeZone); Document doc = new Document(); doc.Add(new StoredField("bogusbytes", "bogus")); doc.Add(new StoredField("bogusshorts", "bogus")); doc.Add(new StoredField("bogusints", "bogus")); doc.Add(new StoredField("boguslongs", "bogus")); doc.Add(new StoredField("bogusfloats", "bogus")); doc.Add(new StoredField("bogusdoubles", "bogus")); doc.Add(new StoredField("bogusterms", "bogus")); doc.Add(new StoredField("bogustermsindex", "bogus")); doc.Add(new StoredField("bogusmultivalued", "bogus")); doc.Add(new StoredField("bogusbits", "bogus")); iw.AddDocument(doc); DirectoryReader ir = iw.Reader; iw.Dispose(); AtomicReader ar = GetOnlySegmentReader(ir); IFieldCache cache = FieldCache.DEFAULT; cache.PurgeAllCaches(); Assert.AreEqual(0, cache.CacheEntries.Length); Bytes bytes = cache.GetBytes(ar, "bogusbytes", true); Assert.AreEqual(0, bytes.Get(0)); Shorts shorts = cache.GetShorts(ar, "bogusshorts", true); Assert.AreEqual(0, shorts.Get(0)); Ints ints = cache.GetInts(ar, "bogusints", true); Assert.AreEqual(0, ints.Get(0)); Longs longs = cache.GetLongs(ar, "boguslongs", true); Assert.AreEqual(0, longs.Get(0)); Floats floats = cache.GetFloats(ar, "bogusfloats", true); Assert.AreEqual(0, floats.Get(0), 0.0f); Doubles doubles = cache.GetDoubles(ar, "bogusdoubles", true); Assert.AreEqual(0, doubles.Get(0), 0.0D); BytesRef scratch = new BytesRef(); BinaryDocValues binaries = cache.GetTerms(ar, "bogusterms", true); binaries.Get(0, scratch); Assert.AreEqual(0, scratch.Length); SortedDocValues sorted = cache.GetTermsIndex(ar, "bogustermsindex"); Assert.AreEqual(-1, sorted.GetOrd(0)); sorted.Get(0, scratch); Assert.AreEqual(0, scratch.Length); SortedSetDocValues sortedSet = cache.GetDocTermOrds(ar, "bogusmultivalued"); sortedSet.Document = 0; Assert.AreEqual(SortedSetDocValues.NO_MORE_ORDS, sortedSet.NextOrd()); Bits bits = cache.GetDocsWithField(ar, "bogusbits"); Assert.IsFalse(bits.Get(0)); // check that we cached nothing Assert.AreEqual(0, cache.CacheEntries.Length); ir.Dispose(); dir.Dispose(); }